From 81eeec5fae11f56fc76e526d6ee0ea28d90db285 Mon Sep 17 00:00:00 2001 From: Christian Speckner Date: Tue, 19 Mar 2019 21:08:35 +0100 Subject: [PATCH] Adapt access checks to modified BSS section. --- src/emucore/CartCDF.cxx | 26 ++++++++++++++++++++++---- src/emucore/CartCDF.hxx | 18 +++++++++--------- src/emucore/Thumbulator.cxx | 5 +++++ src/emucore/Thumbulator.hxx | 3 ++- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index d33224ae5..9b2fee21b 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -37,6 +37,25 @@ #define FAST_FETCH_ON ((myMode & 0x0F) == 0) #define DIGITAL_AUDIO_ON ((myMode & 0xF0) == 0) +namespace { + Thumbulator::ConfigureFor thumulatorConfiguration(CartridgeCDF::CDFSubtype subtype) + { + switch (subtype) { + case CartridgeCDF::CDFSubtype::CDF0: + return Thumbulator::ConfigureFor::CDF; + + case CartridgeCDF::CDFSubtype::CDF1: + return Thumbulator::ConfigureFor::CDF1; + + case CartridgeCDF::CDFSubtype::CDFJ: + return Thumbulator::ConfigureFor::CDFJ; + + default: + throw runtime_error("unreachable"); + } + } +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CartridgeCDF::CartridgeCDF(const BytePtr& image, uInt32 size, const string& md5, const Settings& settings) @@ -61,14 +80,13 @@ CartridgeCDF::CartridgeCDF(const BytePtr& image, uInt32 size, // Pointer to the display RAM myDisplayImage = myCDFRAM + DSRAM; - setVersion(); + setupVersion(); // Create Thumbulator ARM emulator bool devSettings = settings.getBool("dev.settings"); myThumbEmulator = make_unique( reinterpret_cast(myImage), reinterpret_cast(myCDFRAM), 32768, - devSettings ? settings.getBool("dev.thumb.trapfatal") : false, myCDFSubtype == CDFSubtype::CDF0 ? - Thumbulator::ConfigureFor::CDF : Thumbulator::ConfigureFor::CDF1, this); + devSettings ? settings.getBool("dev.thumb.trapfatal") : false, thumulatorConfiguration(myCDFSubtype), this); setInitialState(); } @@ -644,7 +662,7 @@ uInt8 CartridgeCDF::readFromDatastream(uInt8 index) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void CartridgeCDF::setVersion() +void CartridgeCDF::setupVersion() { uInt8 subversion = 0; diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 7a3f9a3c9..5248bb5d3 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -45,6 +45,14 @@ class CartridgeCDF : public Cartridge friend CartridgeCDFInfoWidget; friend class CartridgeRamCDFWidget; + public: + + enum class CDFSubtype { + CDF0, + CDF1, + CDFJ + }; + public: /** Create a new cartridge using the specified image @@ -199,15 +207,7 @@ class CartridgeCDF : public Cartridge uInt32 getWaveform(uInt8 index) const; uInt32 getWaveformSize(uInt8 index) const; uInt32 getSample(); - void setVersion(); - - private: - - enum class CDFSubtype { - CDF0, - CDF1, - CDFJ - }; + void setupVersion(); private: // The 32K ROM image of the cartridge diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index ec6352124..4940dd379 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -369,6 +369,9 @@ bool Thumbulator::isProtected(uInt32 addr) case ConfigureFor::CDF1: return (addr < 0x0800) && (addr > 0x0028) && !((addr >= 0x00a0) && (addr < (0x00a0 + 284))); + case ConfigureFor::CDFJ: + return (addr < 0x0800) && (addr > 0x0028) && !((addr >= 0x0098) && (addr < (0x0098 + 292))); + case ConfigureFor::BUS: return (addr < 0x06d8) && (addr > 0x0028); } @@ -1412,6 +1415,7 @@ int Thumbulator::execute() break; case ConfigureFor::CDF1: + case ConfigureFor::CDFJ: // this subroutine interface is used in the CDF driver, // it starts at address 0x00000750 // _SetNote: @@ -2517,6 +2521,7 @@ int Thumbulator::reset() case ConfigureFor::BUS: case ConfigureFor::CDF: case ConfigureFor::CDF1: + case ConfigureFor::CDFJ: reg_norm[14] = 0x00000800; // Link Register reg_norm[15] = 0x0000080B; // Program Counter break; diff --git a/src/emucore/Thumbulator.hxx b/src/emucore/Thumbulator.hxx index b879ee50e..aa0eb9f70 100644 --- a/src/emucore/Thumbulator.hxx +++ b/src/emucore/Thumbulator.hxx @@ -51,10 +51,11 @@ class Thumbulator public: // control cartridge specific features of the Thumbulator class, // such as the start location for calling custom code - enum ConfigureFor { + enum class ConfigureFor { BUS, // cartridges of type BUS CDF, // cartridges of type CDF CDF1, // cartridges of type CDF version 1 + CDFJ, // cartrdiges of type CDFJ DPCplus // cartridges of type DPC+ };