From cb22a9e75f11363712b89d958550af22480261e2 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 2 Sep 2020 19:29:35 -0230 Subject: [PATCH 1/4] libretro: Updated VS2017 project. This has been broken for months, so I wonder whether we should keep it. --- src/libretro/Stella.vcxproj | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libretro/Stella.vcxproj b/src/libretro/Stella.vcxproj index f92e5ea11..2d0a777db 100644 --- a/src/libretro/Stella.vcxproj +++ b/src/libretro/Stella.vcxproj @@ -140,8 +140,14 @@ + + + + + + @@ -174,8 +180,6 @@ - - @@ -248,7 +252,6 @@ - @@ -276,6 +279,7 @@ + @@ -296,23 +300,25 @@ + + - - + + @@ -325,6 +331,7 @@ + From 283d9b14e3714e3c63186eb1db1633a5329e236b Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sat, 5 Sep 2020 16:16:12 +0200 Subject: [PATCH 2/4] made changes in controller widgets and switches highlighted in SWCHA(R)/SWCHB(R) made SWCHB(R) editable in debugger --- src/debugger/RiotDebug.cxx | 10 ++++++---- src/debugger/gui/RiotWidget.cxx | 13 ++++++++++++- src/debugger/gui/RiotWidget.hxx | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/debugger/RiotDebug.cxx b/src/debugger/RiotDebug.cxx index 0a71c6d92..4484944aa 100644 --- a/src/debugger/RiotDebug.cxx +++ b/src/debugger/RiotDebug.cxx @@ -75,10 +75,11 @@ const DebuggerState& RiotDebug::getState() void RiotDebug::saveOldState() { // Port A & B registers - myOldState.SWCHA_R = swcha(); + // read from myState where other widgets can update pins directly + myOldState.SWCHA_R = myState.SWCHA_R; // swcha(); myOldState.SWCHA_W = mySystem.m6532().myOutA; myOldState.SWACNT = swacnt(); - myOldState.SWCHB_R = swchb(); + myOldState.SWCHB_R = myState.SWCHB_R; // swchb(); myOldState.SWCHB_W = mySystem.m6532().myOutB; myOldState.SWBCNT = swbcnt(); Debugger::set_bits(myOldState.SWCHA_R, myOldState.swchaReadBits); @@ -93,8 +94,9 @@ void RiotDebug::saveOldState() myOldState.INPT1 = inpt(1); myOldState.INPT2 = inpt(2); myOldState.INPT3 = inpt(3); - myOldState.INPT4 = inpt(4); - myOldState.INPT5 = inpt(5); + // read from myState where other widgets can update pins directly + myOldState.INPT4 = myState.INPT4; // inpt(4); + myOldState.INPT5 = myState.INPT5; // inpt(5); myOldState.INPTLatch = vblank(6); myOldState.INPTDump = vblank(7); diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index 43514e072..d589026c2 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -98,7 +98,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, // SWCHB bits in 'peek' mode xpos = 10; ypos += lineHeight + 5; - CREATE_IO_REGS("SWCHB(R)", mySWCHBReadBits, 0, false) + CREATE_IO_REGS("SWCHB(R)", mySWCHBReadBits, kSWCHBRBitsID, true) // Timer registers (R/W) static constexpr std::array writeNames = { @@ -417,6 +417,17 @@ void RiotWidget::handleCommand(CommandSender* sender, int cmd, int data, int id) rport.setPin(Controller::DigitalPin::Four, value & 0b00001000); break; } + case kSWCHBRBitsID: + { + value = Debugger::get_bits(mySWCHBReadBits->getState()); + + riot.reset( value & 0b00000001); + riot.select(value & 0b00000010); + riot.tvType(value & 0b00001000); + riot.diffP0(value & 0b01000000); + riot.diffP1(value & 0b10000000); + break; + } default: break; } diff --git a/src/debugger/gui/RiotWidget.hxx b/src/debugger/gui/RiotWidget.hxx index fdfd699ef..dfbe16ce2 100644 --- a/src/debugger/gui/RiotWidget.hxx +++ b/src/debugger/gui/RiotWidget.hxx @@ -76,7 +76,7 @@ class RiotWidget : public Widget, public CommandSender kTim1TID, kTim8TID, kTim64TID, kTim1024TID, kTimWriteID, kSWCHABitsID, kSWACNTBitsID, kSWCHBBitsID, kSWBCNTBitsID, kP0DiffChanged, kP1DiffChanged, kTVTypeChanged, kSelectID, kResetID, - kSWCHARBitsID, kPauseID + kSWCHARBitsID, kSWCHBRBitsID, kPauseID }; private: From 66b3245c5abe7ace41c0294510be3a586d03f347 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sun, 6 Sep 2020 19:10:08 +0200 Subject: [PATCH 3/4] enhanced UA bank switching to support more Brazilian carts (fixes #698) --- Changes.txt | 2 ++ src/debugger/gui/CartUAWidget.cxx | 2 +- src/emucore/CartDetector.cxx | 9 ++++++--- src/emucore/CartUA.cxx | 18 ++++++++++++++---- src/emucore/CartUA.hxx | 4 +++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Changes.txt b/Changes.txt index 31e2254ef..b3929fb3c 100644 --- a/Changes.txt +++ b/Changes.txt @@ -39,6 +39,8 @@ * Added option to select the audio device. + * Further enhanced UA bankswitching to support more Brazilian carts. + * Added option to display detected settings info when a ROM is loaded. * Added another oddball TIA glitch option for delayed background color. diff --git a/src/debugger/gui/CartUAWidget.cxx b/src/debugger/gui/CartUAWidget.cxx index f6ae16bc7..02728b52d 100644 --- a/src/debugger/gui/CartUAWidget.cxx +++ b/src/debugger/gui/CartUAWidget.cxx @@ -47,7 +47,7 @@ string CartridgeUAWidget::hotspotStr(int bank, int, bool prefix) uInt16 hotspot = myCart.hotspot() + (bank ^ (mySwappedHotspots ? 1 : 0)) * myHotspotDelta; info << "(" << (prefix ? "hotspot " : ""); - info << "$" << Common::Base::HEX1 << hotspot << ", $" << (hotspot | 0x80); + info << "$" << Common::Base::HEX1 << hotspot << ", $" << (hotspot | 0x80) << ", $" << (hotspot | 0xf80); info << ")"; return info.str(); diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index 0ecc6e82e..dba8bb3e4 100644 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -708,15 +708,18 @@ bool CartDetector::isProbablyUA(const ByteBuffer& image, size_t size) // using 'STA $240' or 'LDA $240' // Similar Brazilian (Digivison) cart bankswitching switches to bank 1 by accessing address 0x2C0 // using 'BIT $2C0', 'STA $2C0' or 'LDA $2C0' - uInt8 signature[6][3] = { + // Other Brazilian (Atari Mania) ROM's bankswitching switches to bank 1 by accessing address 0xFC0 + // using 'BIT $FA0', 'BIT $FC0' or 'STA $FA0' + uInt8 signature[7][3] = { { 0x8D, 0x40, 0x02 }, // STA $240 (Funky Fish, Pleiades) { 0xAD, 0x40, 0x02 }, // LDA $240 (???) { 0xBD, 0x1F, 0x02 }, // LDA $21F,X (Gingerbread Man) { 0x2C, 0xC0, 0x02 }, // BIT $2C0 (Time Pilot) { 0x8D, 0xC0, 0x02 }, // STA $2C0 (Fathom, Vanguard) - { 0xAD, 0xC0, 0x02 } // LDA $2C0 (Mickey) + { 0xAD, 0xC0, 0x02 }, // LDA $2C0 (Mickey) + { 0x2C, 0xC0, 0x0F } // BIT $FC0 (H.E.R.O., Kung-Fu Master) }; - for(uInt32 i = 0; i < 6; ++i) + for(uInt32 i = 0; i < 7; ++i) if(searchForBytes(image, size, signature[i], 3)) return true; diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index e73f166db..83afca20e 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -39,11 +39,21 @@ void CartridgeUA::install(System& system) // Set the page accessing methods for the hot spots System::PageAccess access(this, System::PageAccessType::READ); - mySystem->setPageAccess(0x0220, access); - mySystem->setPageAccess(0x0240, access); - mySystem->setPageAccess(0x0220 | 0x80, access); - mySystem->setPageAccess(0x0240 | 0x80, access); + // Map all potential addresses + // - A11, A10 and A8 are not connected to RIOT + // - A9 is the fixed part of the hotspot address + // - A7 is used by Brazilian carts + // - A5 and A4 determine bank + for(uInt16 a11 = 0; a11 <= 1; ++a11) + for(uInt16 a10 = 0; a10 <= 1; ++a10) + for(uInt16 a8 = 0; a8 <= 1; ++a8) + for(uInt16 a7 = 0; a7 <= 1; ++a7) + { + uInt16 addr = (a11 << 11) + (a10 << 10) + (a8 << 8) + (a7 << 7); + mySystem->setPageAccess(0x0220 | addr, access); + mySystem->setPageAccess(0x0240 | addr, access); + } // Install pages for the startup bank bank(startBank()); } diff --git a/src/emucore/CartUA.hxx b/src/emucore/CartUA.hxx index 95d4d022d..f5b25803f 100644 --- a/src/emucore/CartUA.hxx +++ b/src/emucore/CartUA.hxx @@ -28,7 +28,9 @@ /** Cartridge class used for UA Limited's 8K bankswitched games. There are two 4K banks, which are switched by accessing $0220 (bank 0) and - $0240 (bank 1). + $0240 (bank 1). Similar addresses are used by Brazilian carts, e.g. + $02A0, $02C0 and $0FA0, $0FC0. The code accepts further potential + hotspot addresses. @author Bradford W. Mott, Thomas Jentzsch */ From 0587d911d512986f2caf05507615e1c080210e67 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Tue, 8 Sep 2020 12:26:05 +0200 Subject: [PATCH 4/4] addressing #694, this seems to fix it (internal RAM bank segment addresses were exceeding 64K) --- src/emucore/CartEnhanced.cxx | 2 +- src/emucore/CartEnhanced.hxx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/emucore/CartEnhanced.cxx b/src/emucore/CartEnhanced.cxx index b401da819..4696fc963 100644 --- a/src/emucore/CartEnhanced.cxx +++ b/src/emucore/CartEnhanced.cxx @@ -295,7 +295,7 @@ bool CartridgeEnhanced::bank(uInt16 bank, uInt16 segment) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -inline uInt16 CartridgeEnhanced::romAddressSegmentOffset(uInt16 address) const +inline uInt32 CartridgeEnhanced::romAddressSegmentOffset(uInt16 address) const { return myCurrentSegOffset[((address & ROM_MASK) >> myBankShift) % myBankSegs]; } diff --git a/src/emucore/CartEnhanced.hxx b/src/emucore/CartEnhanced.hxx index 98fb8e910..33bd95993 100644 --- a/src/emucore/CartEnhanced.hxx +++ b/src/emucore/CartEnhanced.hxx @@ -275,7 +275,7 @@ class CartridgeEnhanced : public Cartridge @param address The address to get the offset for @return The calculated offset */ - uInt16 romAddressSegmentOffset(uInt16 address) const; + uInt32 romAddressSegmentOffset(uInt16 address) const; /** Get the RAM offset of the segment of the given address