From 04073548bdb30a108e69881465b0ceab326bfd8e Mon Sep 17 00:00:00 2001 From: thrust26 Date: Thu, 2 Apr 2020 11:07:04 +0200 Subject: [PATCH] fix CartFE to update access flags and counters --- src/emucore/Cart.cxx | 3 ++- src/emucore/CartFE.cxx | 20 ++++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/emucore/Cart.cxx b/src/emucore/Cart.cxx index 2c2700c31..beb76855d 100644 --- a/src/emucore/Cart.cxx +++ b/src/emucore/Cart.cxx @@ -180,6 +180,7 @@ uInt16 Cartridge::bankOrigin(uInt16 bank) const { // isolate the high 3 address bits, count them and // select the most frequent to define the bank origin + // TODO: origin for banks smaller than 4K const int intervals = 0x8000 / 0x100; uInt32 offset = bank * bankSize(); //uInt16 addrMask = (4_KB - 1) & ~(bankSize(bank) - 1); @@ -211,7 +212,7 @@ uInt16 Cartridge::bankOrigin(uInt16 bank) const maxIdx = idx; } } - return maxIdx << 13 | 0x1000 | (offset & 0xfff); + return maxIdx << 13 | 0x1000; //| (offset & 0xfff); } #endif diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index c827906f9..eaa17bc4d 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -49,11 +49,6 @@ void CartridgeFE::install(System& system) System::PageAccess access(this, System::PageAccessType::READWRITE); for(uInt16 addr = 0x180; addr < 0x200; addr += System::PAGE_SIZE) mySystem->setPageAccess(addr, access); - - // Map all of the cart accesses to call peek and poke - access.type = System::PageAccessType::READ; - for(uInt16 addr = 0x1000; addr < 0x2000; addr += System::PAGE_SIZE) - mySystem->setPageAccess(addr, access); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -104,6 +99,19 @@ bool CartridgeFE::bank(uInt16 bank) return false; myBankOffset = bank << 12; + + System::PageAccess access(this, System::PageAccessType::READ); + + // Setup the page access methods for the current bank + // Map all of the cart accesses to call peek and poke + for(uInt16 addr = 0x1000; addr < 0x2000; addr += System::PAGE_SIZE) + { + access.romAccessBase = &myRomAccessBase[myBankOffset + (addr & 0x0FFF)]; + access.romPeekCounter = &myRomAccessCounter[addr & 0x0FFF]; + access.romPokeCounter = &myRomAccessCounter[addr & 0x0FFF + myImage.size()]; + mySystem->setPageAccess(addr, access); + } + return myBankChanged = true; } @@ -160,7 +168,7 @@ bool CartridgeFE::load(Serializer& in) } catch(...) { - cerr << "ERROR: CartridgeF8SC::load" << endl; + cerr << "ERROR: CartridgeFE::load" << endl; return false; }