From 28d1a443c687a1f4e15810d82e9eede718db5a0a Mon Sep 17 00:00:00 2001 From: Stephen White Date: Mon, 2 Dec 2019 19:33:40 +1100 Subject: [PATCH] Put the bus read and writes back to v1.19 timings. Fixes the need to overclock a Pi3 for Option A hardware. Hopefully fixes #160 --- src/iec_bus.cpp | 13 +++---------- src/main.cpp | 43 ++++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/iec_bus.cpp b/src/iec_bus.cpp index 8287f91..85b31d0 100644 --- a/src/iec_bus.cpp +++ b/src/iec_bus.cpp @@ -392,16 +392,9 @@ void IEC_Bus::RefreshOuts1541(void) if (OutputSound) set |= 1 << PIGPIO_OUT_SOUND; else clear |= 1 << PIGPIO_OUT_SOUND; #endif - if (oldClears != clear) - { - write32(ARM_GPIO_GPCLR0, clear); - oldClears = clear; - } - if (oldSets != set) - { - write32(ARM_GPIO_GPSET0, set); - oldSets = set; - } + + write32(ARM_GPIO_GPCLR0, clear); + write32(ARM_GPIO_GPSET0, set); } void IEC_Bus::PortB_OnPortOut(void* pUserData, unsigned char status) diff --git a/src/main.cpp b/src/main.cpp index 52a923c..719c2a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -548,7 +548,9 @@ void UpdateScreen() if (screenLCD) { +#if not defined(EXPERIMENTALZERO) core0RefreshingScreen.Acquire(); +#endif IEC_Bus::WaitMicroSeconds(100); @@ -557,7 +559,9 @@ void UpdateScreen() screenLCD->RefreshRows(0, 1); IEC_Bus::WaitMicroSeconds(100); +#if not defined(EXPERIMENTALZERO) core0RefreshingScreen.Release(); +#endif } } @@ -574,13 +578,17 @@ void UpdateScreen() if (screenLCD) { +#if not defined(EXPERIMENTALZERO) core0RefreshingScreen.Acquire(); +#endif IEC_Bus::WaitMicroSeconds(100); screenLCD->PrintText(false, 0, 0, tempBuffer, 0, RGBA(0xff, 0xff, 0xff, 0xff)); // screenLCD->SetContrast(255.0/79.0*track); screenLCD->RefreshRows(0, 1); IEC_Bus::WaitMicroSeconds(100); +#if not defined(EXPERIMENTALZERO) core0RefreshingScreen.Release(); +#endif } } @@ -793,6 +801,8 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser) while (exitReason == EXIT_UNKNOWN) { + if (refreshOutsAfterCPUStep) + IEC_Bus::ReadEmulationMode1541(); if (pi1541.m6502.SYNC()) // About to start a new instruction. { @@ -847,16 +857,7 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser) } } - if (options.SoundOnGPIO() && headSoundCounter > 0) - { - headSoundFreqCounter--; // Continue updating a GPIO non DMA sound. - if (headSoundFreqCounter <= 0) - { - headSoundFreqCounter = headSoundFreq; - headSoundCounter -= headSoundFreq * 8; - IEC_Bus::OutputSound = !IEC_Bus::OutputSound; - } - } + #endif } @@ -911,9 +912,25 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser) } while (ctAfter == ctBefore); } ctBefore = ctAfter; - IEC_Bus::ReadEmulationMode1541(); - if (cycleCount >= FAST_BOOT_CYCLES) // cycleCount is used so we can quickly get through 1541's self test code. This will make the emulated 1541 responsive to commands asap. During this time we don't need to set outputs. - IEC_Bus::RefreshOuts1541(); // Now output all outputs. + + if (!refreshOutsAfterCPUStep) + { + IEC_Bus::ReadEmulationMode1541(); + if (cycleCount >= FAST_BOOT_CYCLES) // cycleCount is used so we can quickly get through 1541's self test code. This will make the emulated 1541 responsive to commands asap. During this time we don't need to set outputs. + IEC_Bus::RefreshOuts1541(); // Now output all outputs. + } +#if not defined(EXPERIMENTALZERO) + if (options.SoundOnGPIO() && headSoundCounter > 0) + { + headSoundFreqCounter--; // Continue updating a GPIO non DMA sound. + if (headSoundFreqCounter <= 0) + { + headSoundFreqCounter = headSoundFreq; + headSoundCounter -= headSoundFreq * 8; + IEC_Bus::OutputSound = !IEC_Bus::OutputSound; + } + } +#endif if (numberOfImages > 1) {