From 71a66ec9ba89861c6a63f41d51d34236a9b8ebbf Mon Sep 17 00:00:00 2001 From: cd-w Date: Sat, 19 Sep 2020 13:03:04 -0700 Subject: [PATCH] Add romSize and ramSize functions --- .gitignore | 1 + src/.vscode/settings.json | 61 --------------------- src/debugger/gui/CartCDFInfoWidget.cxx | 28 +++------- src/debugger/gui/CartCDFWidget.cxx | 4 +- src/emucore/CartCDF.cxx | 73 +++++++++++++++----------- src/emucore/CartCDF.hxx | 15 ++++++ 6 files changed, 67 insertions(+), 115 deletions(-) delete mode 100644 src/.vscode/settings.json diff --git a/.gitignore b/.gitignore index 8e6d3e86a..e1dce7f74 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ build/ src/macosx/M6502.ins *.dSYM .vscode/c_cpp_properties.json +.vscode/settings.json src/windows/sdl/* src/windows/x64/* src/windows/Win32/* diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json deleted file mode 100644 index f1745352d..000000000 --- a/src/.vscode/settings.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "bitset": "cpp", - "string_view": "cpp", - "initializer_list": "cpp", - "regex": "cpp", - "utility": "cpp", - "memory": "cpp", - "random": "cpp", - "optional": "cpp", - "atomic": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "chrono": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "map": "cpp", - "memory_resource": "cpp", - "numeric": "cpp", - "ratio": "cpp", - "set": "cpp", - "string": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "fstream": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "cinttypes": "cpp", - "typeinfo": "cpp" - } -} \ No newline at end of file diff --git a/src/debugger/gui/CartCDFInfoWidget.cxx b/src/debugger/gui/CartCDFInfoWidget.cxx index ab183af33..a1db55cdf 100644 --- a/src/debugger/gui/CartCDFInfoWidget.cxx +++ b/src/debugger/gui/CartCDFInfoWidget.cxx @@ -23,27 +23,15 @@ CartridgeCDFInfoWidget::CartridgeCDFInfoWidget( int x, int y, int w, int h, CartridgeCDF& cart) : CartDebugWidget(boss, lfont, nfont, x, y, w, h) { - uInt32 size; ostringstream info; - if (cart.myCDFSubtype == CartridgeCDF::CDFSubtype::CDFJplus) { - size = 512 * 1024; - info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n" - << "512K ROM (seven 4K banks are accessible to 2600)\n" - << "32K RAM\n" - << "Functions accessible @ $FFF0 - $FFF3\n" - << "Banks accessible @ $FFF4 to $FFFB\n" - << "Startup bank = " << cart.startBank() << "\n"; - - } else { - size = 8 * 4096; - info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n" - << "32K ROM (seven 4K banks are accessible to 2600)\n" - << "8K RAM\n" - << "Functions accessible @ $FFF0 - $FFF3\n" - << "Banks accessible @ $FFF4 to $FFFB\n" - << "Startup bank = " << cart.startBank() << "\n"; - } + info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n" + << (cart.romSize() / 1024) << "K ROM\n" + << (cart.ramSize() / 1024) << "K RAM\n" + << "Seven 4K banks are available to 2600\n" + << "Functions accessible @ $FFF0 - $FFF3\n" + << (cart.isCDFJplus() ? "Banks accessible @ $FFF4 to $FFFA\n" : "Banks accessible @ $FFF5 to $FFFB\n") + << "Startup bank = " << cart.startBank() << "\n"; #if 0 // Eventually, we should query this from the debugger/disassembler @@ -56,7 +44,7 @@ CartridgeCDFInfoWidget::CartridgeCDFInfoWidget( } #endif - addBaseInformation(size, "AtariAge", info.str()); + addBaseInformation(cart.romSize(), "AtariAge", info.str()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/gui/CartCDFWidget.cxx b/src/debugger/gui/CartCDFWidget.cxx index f037e1412..23027495e 100644 --- a/src/debugger/gui/CartCDFWidget.cxx +++ b/src/debugger/gui/CartCDFWidget.cxx @@ -410,7 +410,7 @@ string CartridgeCDFWidget::bankState() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 CartridgeCDFWidget::internalRamSize() { - return isCDFJplus() ? 32*1024 : 8*1024; + return myCart.ramSize(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -502,5 +502,5 @@ bool CartridgeCDFWidget::isCDFJ() const bool CartridgeCDFWidget::isCDFJplus() const { - return (myCart.myCDFSubtype == CartridgeCDF::CDFSubtype::CDFJplus); + return (myCart.isCDFJplus()); } \ No newline at end of file diff --git a/src/emucore/CartCDF.cxx b/src/emucore/CartCDF.cxx index dc24eb29b..1155c307a 100644 --- a/src/emucore/CartCDF.cxx +++ b/src/emucore/CartCDF.cxx @@ -75,15 +75,12 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size, // Detect cart version setupVersion(); - // CDFJ+ has different settings - bool cdfjPlus = (myCDFSubtype == CDFSubtype::CDFJplus); - // The lowest 2K is not accessible to the debugger - createRomAccessArrays(cdfjPlus ? 510_KB : 28_KB); + createRomAccessArrays(isCDFJplus() ? 510_KB : 28_KB); // Pointer to the program ROM // which starts after the 2K driver (and 2K C Code for CDF) - myProgramImage = myImage.get() + (cdfjPlus ? 2_KB : 4_KB); + myProgramImage = myImage.get() + (isCDFJplus() ? 2_KB : 4_KB); // Pointer to CDF driver in RAM myDriverImage = myRAM.data(); @@ -93,7 +90,7 @@ CartridgeCDF::CartridgeCDF(const ByteBuffer& image, size_t size, // C addresses uInt32 cBase, cStart, cStack; - if (cdfjPlus) { + if (isCDFJplus()) { cBase = getUInt32(myImage.get(), 0x17F8) & 0xFFFFFFFE; // C Base Address cStart = cBase; // C Start Address cStack = getUInt32(myImage.get(), 0x17F4); // C Stack @@ -123,7 +120,7 @@ void CartridgeCDF::reset() initializeRAM(myRAM.data()+2_KB, myRAM.size()-2_KB); // CDF always starts in bank 6, CDFJ+ in bank 0 - initializeStartBank((myCDFSubtype == CDFSubtype::CDFJplus) ? 0 : 6); + initializeStartBank(isCDFJplus() ? 0 : 6); myAudioCycles = myARMCycles = 0; myFractionalClocks = 0.0; @@ -218,8 +215,6 @@ inline void CartridgeCDF::callFunction(uInt8 value) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 CartridgeCDF::peek(uInt16 address) { - bool cdfjPlus = (myCDFSubtype == CDFSubtype::CDFJplus); - address &= 0x0FFF; uInt8 peekvalue = myProgramImage[myBankOffset + address]; @@ -239,7 +234,7 @@ uInt8 CartridgeCDF::peek(uInt16 address) ++myJMPoperandAddress; pointer = getDatastreamPointer(myFastJumpStream); - if (cdfjPlus) { + if (isCDFJplus()) { value = myDisplayImage[ pointer >> 16 ]; pointer += 0x00010000; // always increment by 1 } else { @@ -316,35 +311,35 @@ uInt8 CartridgeCDF::peek(uInt16 address) switch(address) { case 0x0FF4: - bank(cdfjPlus ? 0 : 6); + bank(isCDFJplus() ? 0 : 6); break; case 0x0FF5: - bank(cdfjPlus ? 1 : 0); + bank(isCDFJplus() ? 1 : 0); break; case 0x0FF6: - bank(cdfjPlus ? 2 : 1); + bank(isCDFJplus() ? 2 : 1); break; case 0x0FF7: - bank(cdfjPlus ? 3 : 2); + bank(isCDFJplus() ? 3 : 2); break; case 0x0FF8: - bank(cdfjPlus ? 4 : 3); + bank(isCDFJplus() ? 4 : 3); break; case 0x0FF9: - bank(cdfjPlus ? 5 : 4); + bank(isCDFJplus() ? 5 : 4); break; case 0x0FFA: - bank(cdfjPlus ? 6 : 5); + bank(isCDFJplus() ? 6 : 5); break; case 0x0FFB: - bank(cdfjPlus ? 0 : 6); + bank(isCDFJplus() ? 0 : 6); break; default: @@ -361,14 +356,13 @@ uInt8 CartridgeCDF::peek(uInt16 address) bool CartridgeCDF::poke(uInt16 address, uInt8 value) { uInt32 pointer; - bool cdfjPlus = (myCDFSubtype == CDFSubtype::CDFJplus); address &= 0x0FFF; switch(address) { case 0x0FF0: // DSWRITE pointer = getDatastreamPointer(COMMSTREAM); - if (cdfjPlus) { + if (isCDFJplus()) { myDisplayImage[ pointer >> 16 ] = value; pointer += 0x00010000; // always increment by 1 when writing } else { @@ -381,7 +375,7 @@ bool CartridgeCDF::poke(uInt16 address, uInt8 value) case 0x0FF1: // DSPTR pointer = getDatastreamPointer(COMMSTREAM); pointer <<= 8; - if (cdfjPlus) { + if (isCDFJplus()) { pointer &= 0xff000000; pointer |= (value << 16); } else { @@ -400,35 +394,35 @@ bool CartridgeCDF::poke(uInt16 address, uInt8 value) break; case 0x00FF4: - bank(cdfjPlus ? 0 : 6); + bank(isCDFJplus() ? 0 : 6); break; case 0x0FF5: - bank(cdfjPlus ? 1 : 0); + bank(isCDFJplus() ? 1 : 0); break; case 0x0FF6: - bank(cdfjPlus ? 2 : 1); + bank(isCDFJplus() ? 2 : 1); break; case 0x0FF7: - bank(cdfjPlus ? 3 : 2); + bank(isCDFJplus() ? 3 : 2); break; case 0x0FF8: - bank(cdfjPlus ? 4 : 3); + bank(isCDFJplus() ? 4 : 3); break; case 0x0FF9: - bank(cdfjPlus ? 5 : 4); + bank(isCDFJplus() ? 5 : 4); break; case 0x0FFA: - bank(cdfjPlus ? 6 : 5); + bank(isCDFJplus() ? 6 : 5); break; case 0x0FFB: - bank(cdfjPlus ? 0 : 6); + bank(isCDFJplus() ? 0 : 6); break; default: @@ -654,7 +648,7 @@ uInt32 CartridgeCDF::getWaveform(uInt8 index) const result -= (0x40000000 + 2_KB); - if (myCDFSubtype != CDFSubtype::CDFJplus) { + if (!isCDFJplus()) { if (result >= 4096) { result &= 4095; } @@ -698,8 +692,7 @@ uInt8 CartridgeCDF::readFromDatastream(uInt8 index) uInt16 increment = getDatastreamIncrement(index); uInt8 value; - bool cdfjPlus = (myCDFSubtype == CDFSubtype::CDFJplus); - if (cdfjPlus) { + if (isCDFJplus()) { value = myDisplayImage[ pointer >> 16 ]; pointer += (increment << 8); } else { @@ -794,6 +787,22 @@ string CartridgeCDF::name() const } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeCDF::isCDFJplus() const +{ + return (myCDFSubtype == CDFSubtype::CDFJplus); +} + +uInt32 CartridgeCDF::ramSize() const +{ + return isCDFJplus() ? 32_KB : 8_KB; +} + +uInt32 CartridgeCDF::romSize() const +{ + return isCDFJplus() ? 512_KB : 32_KB; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifdef DEBUGGER_SUPPORT CartDebugWidget* CartridgeCDF::debugWidget(GuiObject* boss, const GUI::Font& lfont, diff --git a/src/emucore/CartCDF.hxx b/src/emucore/CartCDF.hxx index 180c08f44..fd374d9df 100644 --- a/src/emucore/CartCDF.hxx +++ b/src/emucore/CartCDF.hxx @@ -154,6 +154,21 @@ class CartridgeCDF : public Cartridge */ uInt32 thumbCallback(uInt8 function, uInt32 value1, uInt32 value2) override; + /** + Set if we are using CDFJ+ bankswitching + */ + bool isCDFJplus() const; + + /** + Size of SRAM (RAM) area in cart + */ + uInt32 ramSize() const; + + /** + Size of Flash memory (ROM) area in cart + */ + uInt32 romSize() const; + #ifdef DEBUGGER_SUPPORT /** Get debugger widget responsible for accessing the inner workings