From 481b9d1c04f7ad80dc0d1ce3bcf16a98b9363a19 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Fri, 21 Feb 2020 11:05:52 +0100 Subject: [PATCH] add high score support for CDF, DPC+ and BUS add high score data for Draconian RC6 and SF2 (RC8) --- src/common/HighScoresManager.cxx | 13 ++++++++++--- src/common/HighScoresManager.hxx | 5 +++-- src/common/stella.pro | 14 ++++++++++++++ src/emucore/Cart.hxx | 14 ++++++++++++++ src/emucore/CartBUS.cxx | 9 +++++++++ src/emucore/CartBUS.hxx | 14 ++++++++++++++ src/emucore/CartCDF.cxx | 9 +++++++++ src/emucore/CartCDF.hxx | 14 ++++++++++++++ src/emucore/CartDPCPlus.cxx | 9 +++++++++ src/emucore/CartDPCPlus.hxx | 17 ++++++++++++++++- src/gui/GameInfoDialog.cxx | 3 +-- 11 files changed, 113 insertions(+), 8 deletions(-) diff --git a/src/common/HighScoresManager.cxx b/src/common/HighScoresManager.cxx index 275569b2d..0589e4b2c 100644 --- a/src/common/HighScoresManager.cxx +++ b/src/common/HighScoresManager.cxx @@ -44,9 +44,11 @@ #include "OSystem.hxx" #include "PropsSet.hxx" +#include "System.hxx" +#include "Cart.hxx" #include "Console.hxx" #include "Launcher.hxx" -#include "System.hxx" + #include "HighScoresManager.hxx" @@ -65,8 +67,10 @@ Int16 HighScoresManager::peek(uInt16 addr) const { if (myOSystem.hasConsole()) { - System& system = myOSystem.console().system(); - return system.peek(addr); + if(addr < 0x100u || myOSystem.console().cartridge().internalRamSize() == 0) + return myOSystem.console().system().peek(addr); + else + return myOSystem.console().cartridge().internalRamGetValue(addr); } return -1; } @@ -454,6 +458,9 @@ Int32 HighScoresManager::convert(uInt32 val, uInt32 maxVal, bool isBCD, bool zer if (isBCD) val = fromBCD(val); + if(val == -1) + return 0; + // limit to maxVal's bits val %= 1 << bits; val += zeroBased ? 1 : 0; diff --git a/src/common/HighScoresManager.hxx b/src/common/HighScoresManager.hxx index a7f07daf7..a800e061a 100644 --- a/src/common/HighScoresManager.hxx +++ b/src/common/HighScoresManager.hxx @@ -123,6 +123,9 @@ class HighScoresManager // and adjusted for BCD and zero based data Int32 convert(uInt32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const; + // Peek into memory + Int16 peek(uInt16 addr) const; + private: enum { //IDX_ARM_RAM = 0, @@ -177,8 +180,6 @@ class HighScoresManager Properties& properties(Properties& props) const; // Get value from highscore propterties at given index string getPropIdx(const Properties& props, PropType type, uInt32 idx = 0) const; - // Peek into memory - Int16 peek(uInt16 addr) const; Int32 fromBCD(uInt8 bcd) const; diff --git a/src/common/stella.pro b/src/common/stella.pro index 6f25d146d..293bf7d8b 100644 --- a/src/common/stella.pro +++ b/src/common/stella.pro @@ -1,3 +1,11 @@ +"Cart.MD5" "05215b73ec33b502449ee726ac6b201f" +"Cart.Name" "draconian_20171013_RC6" +"Display.Phosphor" "YES" +"Cart.Variations" "4" +"Cart.Formats" "8,0,B,0,B,1,SECT.,D,1" +"Cart.Addresses" "177B,177A,1779,1778,811,1780" +"" + "Cart.MD5" "081e2c114c9c20b61acf25fc95c71bf4" "Cart.Manufacturer" "Parker Brothers, Ed English, David Lamkins" "Cart.ModelNo" "PB5300" @@ -27,6 +35,12 @@ "Cart.Addresses" "FD,FE,FF,FC" "" +"Cart.MD5" "541cac55ebcf7891d9d51c415922303f" +"Cart.Name" "SF2_20131217_RC8_NTSC" +"Cart.Formats" "8" +"Cart.Addresses" "1CF7,1CF6,1CF5,1CF4" +"" + "Cart.MD5" "6dda84fb8e442ecf34241ac0d1d91d69" "Cart.Manufacturer" "Atari - GCC, Douglas B. Macrae" "Cart.ModelNo" "CX2677" diff --git a/src/emucore/Cart.hxx b/src/emucore/Cart.hxx index 9e8d40a4b..9d79d390a 100644 --- a/src/emucore/Cart.hxx +++ b/src/emucore/Cart.hxx @@ -106,6 +106,20 @@ class Cartridge : public Device */ virtual bool bankChanged(); + /** + Query the internal RAM size of the cart. + + @return The internal RAM size + */ + virtual uInt32 internalRamSize() const { return 0; } + + /** + Read a byte from cart internal RAM. + + @return The value of the interal RAM byte + */ + virtual uInt8 internalRamGetValue(uInt16 addr) const { return 0; } + #ifdef DEBUGGER_SUPPORT /** To be called at the start of each instruction. diff --git a/src/emucore/CartBUS.cxx b/src/emucore/CartBUS.cxx index c34593e73..5ae98c756 100644 --- a/src/emucore/CartBUS.cxx +++ b/src/emucore/CartBUS.cxx @@ -541,6 +541,15 @@ uInt32 CartridgeBUS::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) return 0; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt8 CartridgeBUS::internalRamGetValue(uInt16 addr) const +{ + if(addr < internalRamSize()) + return myBUSRAM[addr]; + else + return 0; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeBUS::save(Serializer& out) const { diff --git a/src/emucore/CartBUS.hxx b/src/emucore/CartBUS.hxx index d00e90133..2aa1e9610 100644 --- a/src/emucore/CartBUS.hxx +++ b/src/emucore/CartBUS.hxx @@ -147,6 +147,20 @@ class CartridgeBUS : public Cartridge */ uInt32 thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) override; + /** + Query the internal RAM size of the cart. + + @return The internal RAM size + */ + uInt32 internalRamSize() const override { return 8_KB; } + + /** + Read a byte from cart internal RAM. + + @return The value of the interal RAM byte + */ + uInt8 internalRamGetValue(uInt16 addr) const override; + #ifdef DEBUGGER_SUPPORT /** diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index 052a1b523..c47154fb8 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -487,6 +487,15 @@ uInt32 CartridgeCDF::thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) return 0; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt8 CartridgeCDF::internalRamGetValue(uInt16 addr) const +{ + if(addr < internalRamSize()) + return myCDFRAM[addr]; + else + return 0; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeCDF::save(Serializer& out) const { diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 5e65bc4d4..614744e23 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -151,6 +151,20 @@ class CartridgeCDF : public Cartridge */ uInt32 thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) override; + /** + Query the internal RAM size of the cart. + + @return The internal RAM size + */ + uInt32 internalRamSize() const override { return 8_KB; } + + /** + Read a byte from cart internal RAM. + + @return The value of the interal RAM byte + */ + uInt8 internalRamGetValue(uInt16 addr) const override; + #ifdef DEBUGGER_SUPPORT /** Get debugger widget responsible for accessing the inner workings diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 9071b69d8..5758479d2 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -633,6 +633,15 @@ const uInt8* CartridgeDPCPlus::getImage(size_t& size) const return myImage.data() + (myImage.size() - mySize); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +uInt8 CartridgeDPCPlus::internalRamGetValue(uInt16 addr) const +{ + if(addr < internalRamSize()) + return myDPCRAM[addr]; + else + return 0; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartridgeDPCPlus::save(Serializer& out) const { diff --git a/src/emucore/CartDPCPlus.hxx b/src/emucore/CartDPCPlus.hxx index abc14f21d..cc2997396 100644 --- a/src/emucore/CartDPCPlus.hxx +++ b/src/emucore/CartDPCPlus.hxx @@ -45,7 +45,7 @@ class System; class CartridgeDPCPlus : public Cartridge { friend class CartridgeDPCPlusWidget; - friend class CartridgeRamDPCPlusWidget; + friend class CartridgeRamDPCPlusWidget; public: /** @@ -142,6 +142,21 @@ class CartridgeDPCPlus : public Cartridge */ string name() const override { return "CartridgeDPC+"; } + /** + Query the internal RAM size of the cart. + + @return The internal RAM size + */ + uInt32 internalRamSize() const override { return 8_KB; } + + /** + Read a byte from cart internal RAM. + + @return The value of the interal RAM byte + */ + uInt8 internalRamGetValue(uInt16 addr) const override; + + #ifdef DEBUGGER_SUPPORT /** Get debugger widget responsible for accessing the inner workings diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 74f4c4db6..5eaea5ee8 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -1176,14 +1176,13 @@ void GameInfoDialog::setAddressVal(EditTextWidget* addressWidget, EditTextWidget if (instance().hasConsole() && valWidget->isEnabled()) { - System& system = instance().console().system(); uInt16 addr; uInt8 val; ostringstream ss; // convert to number and read from memory addr = stringToIntBase16(strAddr, HSM::DEFAULT_ADDRESS); - val = system.peek(addr); + val = instance().highScores().peek(addr); val = instance().highScores().convert(val, maxVal, isBCD, zeroBased); // format output and display in value widget