From 2145c3808774078a53b4b33a8ff51e0d7417beb4 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 3 Jun 2012 18:05:14 +0000 Subject: [PATCH] Fixed bugs in DPC+ scheme; reset wasn't actually resetting the Harmony RAM, and state saving wasn't working at all. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2523 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- Changes.txt | 10 ++++++++-- src/emucore/Cart.cxx | 2 +- src/emucore/CartDPCPlus.cxx | 29 +++++++++++++++++++++++++++-- src/emucore/System.hxx | 2 +- src/emucore/Thumbulator.cxx | 2 +- src/emucore/Thumbulator.hxx | 4 ++-- 6 files changed, 40 insertions(+), 9 deletions(-) diff --git a/Changes.txt b/Changes.txt index 08f63252b..728cb23e1 100644 --- a/Changes.txt +++ b/Changes.txt @@ -12,6 +12,14 @@ Release History =========================================================================== +3.7 to 3.7.1: (xxxx xx, 2012) + + * Fixed several bugs in DPC+ bankswitching scheme, including ability to + load and save state files. + +-Have fun! + + 3.6.1 to 3.7: (June 1, 2012) * Added Blargg TV effects, with presets for Composite, S-video, RGB, @@ -83,8 +91,6 @@ * Updated included PNG library to latest stable version. --Have fun! - 3.6 to 3.6.1: (March 30, 2012) diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index e2e5f7d35..a43861e37 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -302,7 +302,7 @@ void Cartridge::registerRamArea(uInt16 start, uInt16 size, void Cartridge::triggerReadFromWritePort(uInt16 address) { #ifdef DEBUGGER_SUPPORT - if(!mySystem->autodectMode()) + if(!mySystem->autodetectMode()) Debugger::debugger().cartDebug().triggerReadFromWritePort(address); #endif } diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 7c8b65cf3..45a019582 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -49,7 +49,6 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size, // Pointer to the display RAM myDisplayImage = myDPCRAM + 0xC00; - memset(myDPCRAM, 0, 8192); // Pointer to the Frequency ROM (1K @ 28K offset) myFrequencyImage = myProgramImage + 0x7000; @@ -71,6 +70,9 @@ CartridgeDPCPlus::CartridgeDPCPlus(const uInt8* image, uInt32 size, settings.getBool("thumb.trapfatal")); #endif + // Reset various ROM and RAM locations + memset(myDPCRAM, 0, 8192); + // Copy DPC display data to Harmony RAM memcpy(myDisplayImage, myProgramImage + 0x6000, 0x1000); @@ -106,6 +108,23 @@ void CartridgeDPCPlus::reset() mySystemCycles = mySystem->cycles(); myFractionalClocks = 0.0; + // Reset various ROM and RAM locations + memset(myDPCRAM, 0, 8192); + + // Copy initial DPC display data and Frequency table state to Harmony RAM + memcpy(myDisplayImage, myProgramImage + 0x6000, 0x1400); + + // Initialize the DPC data fetcher registers + for(uInt16 i = 0; i < 8; ++i) + myTops[i] = myBottoms[i] = myCounters[i] = myFractionalIncrements[i] = + myFractionalCounters[i] = 0; + + // Set waveforms to first waveform entry + myMusicWaveforms[0] = myMusicWaveforms[1] = myMusicWaveforms[2] = 0; + + // Initialize the DPC's random number generator register (must be non-zero) + myRandomNumber = 0x2B435044; // "DPC+" + // Upon reset we switch to the startup bank bank(myStartBank); } @@ -209,7 +228,7 @@ inline void CartridgeDPCPlus::callFunction(uInt8 value) myThumbEmulator->run(); } catch(const string& error) { - if(!mySystem->autodectMode()) + if(!mySystem->autodetectMode()) { #ifdef DEBUGGER_SUPPORT Debugger::debugger().startWithFatalError(error); @@ -661,6 +680,9 @@ bool CartridgeDPCPlus::save(Serializer& out) const // Indicates which bank is currently active out.putShort(myCurrentBank); + // Harmony RAM + out.putByteArray(myDPCRAM, 8192); + // The top registers for the data fetchers out.putByteArray(myTops, 8); @@ -718,6 +740,9 @@ bool CartridgeDPCPlus::load(Serializer& in) // Indicates which bank is currently active myCurrentBank = in.getShort(); + // Harmony RAM + in.getByteArray(myDPCRAM, 8192); + // The top registers for the data fetchers in.getByteArray(myTops, 8); diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index a2f6b9f76..0177ba2db 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -214,7 +214,7 @@ class System : public Serializable /** Answers whether the system is currently in device autodetect mode. */ - bool autodectMode() const { return mySystemInAutodetect; } + bool autodetectMode() const { return mySystemInAutodetect; } public: /** diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index e69139d94..e16689f76 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -31,7 +31,7 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Thumbulator::Thumbulator(uInt16* rom_ptr, uInt16* ram_ptr, bool traponfatal) +Thumbulator::Thumbulator(const uInt16* rom_ptr, uInt16* ram_ptr, bool traponfatal) : rom(rom_ptr), ram(ram_ptr), copydata(0), diff --git a/src/emucore/Thumbulator.hxx b/src/emucore/Thumbulator.hxx index 5bb075157..dacb221e0 100644 --- a/src/emucore/Thumbulator.hxx +++ b/src/emucore/Thumbulator.hxx @@ -62,7 +62,7 @@ class Thumbulator { public: - Thumbulator(uInt16* rom, uInt16* ram, bool traponfatal); + Thumbulator(const uInt16* rom, uInt16* ram, bool traponfatal); ~Thumbulator(); /** @@ -119,7 +119,7 @@ class Thumbulator int reset ( void ); private: - uInt16* rom; + const uInt16* rom; uInt16* ram; Int32 copydata;