From bd52880a4691e4690d6b18079480c706cfac72d2 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 1 Dec 2017 12:03:19 +0100 Subject: [PATCH] minimal Cart class refactoring --- src/emucore/Cart.cxx | 8 +++++++- src/emucore/Cart.hxx | 7 +++++++ src/emucore/CartFE.cxx | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 560d64a98..2cb87e469 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -91,13 +91,19 @@ void Cartridge::createCodeAccessBase(uInt32 size) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge::initializeRAM(uInt8* arr, uInt32 size, uInt8 val) const { - if(mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.ramrandom" : "plr.ramrandom")) + if(randomInitialRAM()) for(uInt32 i = 0; i < size; ++i) arr[i] = mySystem->randGenerator().next(); else memset(arr, val, size); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool Cartridge::randomInitialRAM() const +{ + return mySettings.getBool(mySettings.getBool("dev.settings") ? "dev.ramrandom" : "plr.ramrandom"); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Cartridge::randomizeStartBank() { diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 41ba2ba37..0cbce75cc 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -195,6 +195,13 @@ class Cartridge : public Device */ void initializeRAM(uInt8* arr, uInt32 size, uInt8 val = 0) const; + /** + Checks if initial RAM randomization is enabled + + @return Whether the initial RAM should be randomized + */ + bool randomInitialRAM() const; + /** Defines the startup bank. if 'bank' is negative, a random bank will be selected. diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index ab10e831c..9c2069f81 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -30,7 +30,7 @@ CartridgeFE::CartridgeFE(const BytePtr& image, uInt32 size, memcpy(myImage, image.get(), std::min(8192u, size)); createCodeAccessBase(8192); - myStartBank = 0; // For now, we assume this; more research is needed + myStartBank = 0; // Decathlon requires this, since there is no startup vector in bank 1 } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -