From 809722750ae98a36ab33e7963f7783490eeb9d41 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Sun, 28 Apr 2019 15:27:15 +1000 Subject: [PATCH] Improved compatability for the Neon loader. --- src/iec_bus.cpp | 18 ++++++++++++------ src/iec_bus.h | 5 ++++- src/main.cpp | 25 +++++++++++++------------ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/iec_bus.cpp b/src/iec_bus.cpp index e30dba5..b4e7587 100644 --- a/src/iec_bus.cpp +++ b/src/iec_bus.cpp @@ -20,6 +20,8 @@ static int buttonCount = sizeof(ButtonPinFlags) / sizeof(unsigned); +u32 IEC_Bus::oldClears = 0; +u32 IEC_Bus::oldSets = 0; u32 IEC_Bus::PIGPIO_MASK_IN_ATN = 1 << PIGPIO_ATN; u32 IEC_Bus::PIGPIO_MASK_IN_DATA = 1 << PIGPIO_DATA; u32 IEC_Bus::PIGPIO_MASK_IN_CLOCK = 1 << PIGPIO_CLOCK; @@ -72,7 +74,6 @@ unsigned IEC_Bus::gplev0; void IEC_Bus::ReadBrowseMode(void) { - IOPort* portB = 0; gplev0 = read32(ARM_GPIO_GPLEV0); int index; @@ -87,9 +88,6 @@ void IEC_Bus::ReadBrowseMode(void) PI_Atn = ATNIn; } - if (portB && (portB->GetDirection() & 0x10) == 0) - AtnaDataSetToOut = false; // If the ATNA PB4 gets set to an input then we can't be pulling data low. (Maniac Mansion does this) - if (!AtnaDataSetToOut && !DataSetToOut) // only sense if we have not brought the line low (because we can't as we have the pin set to output but we can simulate in software) { bool DATAIn = (gplev0 & PIGPIO_MASK_IN_DATA) == (invertIECInputs ? PIGPIO_MASK_IN_DATA : 0); @@ -311,8 +309,16 @@ void IEC_Bus::RefreshOuts1541(void) if (OutputSound) set |= 1 << PIGPIO_OUT_SOUND; else clear |= 1 << PIGPIO_OUT_SOUND; - write32(ARM_GPIO_GPCLR0, clear); - write32(ARM_GPIO_GPSET0, set); + if (oldClears != clear) + { + write32(ARM_GPIO_GPCLR0, clear); + oldClears = clear; + } + if (oldSets != set) + { + write32(ARM_GPIO_GPSET0, set); + oldSets = set; + } } void IEC_Bus::PortB_OnPortOut(void* pUserData, unsigned char status) diff --git a/src/iec_bus.h b/src/iec_bus.h index 8d944c5..ed088c6 100644 --- a/src/iec_bus.h +++ b/src/iec_bus.h @@ -495,7 +495,7 @@ public: static inline bool IsClockReleased() { return !PI_Clock; } static inline bool GetPI_Reset() { return PI_Reset; } static inline bool IsDataSetToOut() { return DataSetToOut; } - static inline bool IsAtnaDataSetToOut() { return AtnaDataSetToOut; } + //static inline bool IsAtnaDataSetToOut() { return AtnaDataSetToOut; } static inline bool IsClockSetToOut() { return ClockSetToOut; } static inline bool IsReset() { return Resetting; } @@ -595,6 +595,9 @@ public: static bool OutputSound; private: + static u32 oldClears; + static u32 oldSets; + static bool splitIECLines; static bool invertIECInputs; static bool invertIECOutputs; diff --git a/src/main.cpp b/src/main.cpp index 66ebdea..8cee4f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -686,7 +686,6 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser) while (exitReason == EXIT_UNKNOWN) { - IEC_Bus::ReadEmulationMode1541(); if (pi1541.m6502.SYNC()) // About to start a new instruction. { @@ -750,6 +749,16 @@ 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; + } + } } @@ -802,17 +811,9 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser) } while (ctAfter == ctBefore); } ctBefore = ctAfter; - - 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; - } - } + 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 (numberOfImages > 1) {