From af8c5a5133a9993b7f685969a1a367b0888ac720 Mon Sep 17 00:00:00 2001 From: stephena Date: Mon, 12 Apr 2010 19:56:14 +0000 Subject: [PATCH] Added 'PageType' infrastructure to PageAccess, which basically informs the rest of the system about how a page of address space is to be treated (READ, WRITE, READWRITE). This makes it much easier to track if a read from the write port has occurred. As such, the _rwport command should now be somewhat faster. Eventually, the debugger/disassembler will use this info to colorize the output. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2004 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/debugger/CartDebug.cxx | 20 ++++++----------- src/debugger/CartDebug.hxx | 2 -- src/debugger/Debugger.cxx | 5 +++++ src/emucore/Cart0840.cxx | 13 +++++------ src/emucore/Cart2K.cxx | 6 ++++-- src/emucore/Cart3E.cxx | 28 +++++++++++++----------- src/emucore/Cart3F.cxx | 17 ++++++++------- src/emucore/Cart4A50.cxx | 2 ++ src/emucore/Cart4K.cxx | 1 + src/emucore/CartAR.cxx | 2 ++ src/emucore/CartCV.cxx | 15 +++++++------ src/emucore/CartDPC.cxx | 24 ++++++++++----------- src/emucore/CartDPCPlus.cxx | 1 + src/emucore/CartE0.cxx | 16 ++++++++------ src/emucore/CartE7.cxx | 43 +++++++++++++++++++++---------------- src/emucore/CartEF.cxx | 18 +++++++++------- src/emucore/CartEFSC.cxx | 25 +++++++++++---------- src/emucore/CartF0.cxx | 15 +++++++------ src/emucore/CartF4.cxx | 15 +++++++------ src/emucore/CartF4SC.cxx | 25 +++++++++++---------- src/emucore/CartF6.cxx | 15 +++++++------ src/emucore/CartF6SC.cxx | 25 +++++++++++---------- src/emucore/CartF8.cxx | 15 +++++++------ src/emucore/CartF8SC.cxx | 25 +++++++++++---------- src/emucore/CartFA.cxx | 25 +++++++++++---------- src/emucore/CartFE.cxx | 1 + src/emucore/CartMC.cxx | 5 +++++ src/emucore/CartSB.cxx | 15 +++++++------ src/emucore/CartUA.cxx | 4 +++- src/emucore/CartX07.cxx | 12 +++++------ src/emucore/M6532.cxx | 9 +++----- src/emucore/System.cxx | 6 ++++++ src/emucore/System.hxx | 22 ++++++++++++++++++- src/emucore/TIA.cxx | 5 +---- 34 files changed, 274 insertions(+), 203 deletions(-) diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index b133416f1..750d16883 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -33,7 +33,6 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const RamAreaList& areas) addRamArea(0x80, 128, 0, 0); // Add extended RAM - myRamAreas = areas; for(RamAreaList::const_iterator i = areas.begin(); i != areas.end(); ++i) addRamArea(i->start, i->size, i->roffset, i->woffset); @@ -125,25 +124,18 @@ void CartDebug::triggerReadFromWritePort(uInt16 addr) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int CartDebug::readFromWritePort() { - uInt16 peekAddress = myRWPortAddress; + uInt16 addr = myRWPortAddress; myRWPortAddress = 0; // A read from the write port occurs when the read is actually in the write // port address space AND the last access was actually a read (the latter // differentiates between reads that are normally part of a write cycle vs. // ones that are illegal) - if(mySystem.m6502().lastReadAddress() && peekAddress & 0x1000) - { - uInt16 addr = peekAddress & 0x0FFF; - for(RamAreaList::const_iterator i = myRamAreas.begin(); i != myRamAreas.end(); ++i) - { - uInt16 start = (i->start + i->woffset) & 0x0FFF; - uInt16 end = (i->start + i->woffset + i->size) & 0x0FFF; - if(addr >= start && addr < end) - return peekAddress; - } - } - return 0; + if(mySystem.m6502().lastReadAddress() && + (mySystem.getPageType(addr) & System::PAGE_WRITE) == System::PAGE_WRITE) + return addr; + else + return 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/debugger/CartDebug.hxx b/src/debugger/CartDebug.hxx index 919acb832..6426d97e0 100644 --- a/src/debugger/CartDebug.hxx +++ b/src/debugger/CartDebug.hxx @@ -213,8 +213,6 @@ class CartDebug : public DebuggerSystem CartState myState; CartState myOldState; - RamAreaList myRamAreas; - // A pointer to an array of start addresses for each bank in a cart // The startup bank will normally be 0xfffc, while the others are // determined when the debugger is first opened diff --git a/src/debugger/Debugger.cxx b/src/debugger/Debugger.cxx index 443f2b7b5..0f2aa645f 100644 --- a/src/debugger/Debugger.cxx +++ b/src/debugger/Debugger.cxx @@ -674,6 +674,7 @@ GUI::Rect Debugger::getTabBounds() const bool Debugger::addFunction(const string& name, const string& definition, Expression* exp, bool builtin) { +cerr << "adding function: " << name << endl; functions.insert(make_pair(name, exp)); if(!builtin) functionDefs.insert(make_pair(name, definition)); @@ -762,6 +763,10 @@ void Debugger::getCompletions(const char* in, StringList& list) const if(BSPF_strncasecmp(l, in, strlen(in)) == 0) list.push_back(l); } + + +for(uInt32 i = 0; i < list.size(); ++i) +cerr << list[i] << endl; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Cart0840.cxx b/src/emucore/Cart0840.cxx index e9278360a..d6e419b85 100644 --- a/src/emucore/Cart0840.cxx +++ b/src/emucore/Cart0840.cxx @@ -68,13 +68,13 @@ void Cartridge0840::install(System& system) // Set the page accessing methods for the hot spots System::PageAccess access; + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; + for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for bank 0 bank(myStartBank); @@ -157,8 +157,9 @@ void Cartridge0840::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index 196494625..38a8f185e 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -76,11 +76,13 @@ void Cartridge2K::install(System& system) // Map ROM image into the system System::PageAccess access; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; + for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) { - access.device = this; access.directPeekBase = &myImage[address & myMask]; - access.directPokeBase = 0; mySystem->setPageAccess(address >> shift, access); } } diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 2ae8c1bef..c2fcdb6bc 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -70,25 +70,26 @@ void Cartridge3E::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1800 & mask) == 0); + System::PageAccess access; + // Set the page accessing methods for the hot spots (for 100% emulation // we need to chain any accesses below 0x40 to the TIA. Our poke() method // does this via mySystem->tiaPoke(...), at least until we come up with a // cleaner way to do it). - System::PageAccess access; + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READWRITE; for(uInt32 i = 0x00; i < 0x40; i += (1 << shift)) - { - access.device = this; - access.directPeekBase = 0; - access.directPokeBase = 0; mySystem->setPageAccess(i >> shift, access); - } // Setup the second segment to always point to the last ROM slice + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 j = 0x1800; j < 0x2000; j += (1 << shift)) { - access.device = this; access.directPeekBase = &myImage[(mySize - 2048) + (j & 0x07FF)]; - access.directPokeBase = 0; mySystem->setPageAccess(j >> shift, access); } @@ -180,9 +181,10 @@ void Cartridge3E::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; - + access.device = this; + access.type = System::PAGE_READ; + // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) { @@ -202,9 +204,10 @@ void Cartridge3E::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; - + access.device = this; + access.type = System::PAGE_READ; + // Map read-port RAM image into the system for(address = 0x1000; address < 0x1400; address += (1 << shift)) { @@ -213,6 +216,7 @@ void Cartridge3E::bank(uInt16 bank) } access.directPeekBase = 0; + access.type = System::PAGE_WRITE; // Map write-port RAM image into the system for(address = 0x1400; address < 0x1800; address += (1 << shift)) diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index 0fd3c56fa..f55e16172 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -66,20 +66,20 @@ void Cartridge3F::install(System& system) // does this via mySystem->tiaPoke(...), at least until we come up with a // cleaner way to do it). System::PageAccess access; + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READWRITE; for(uInt32 i = 0x00; i < 0x40; i += (1 << shift)) - { - access.device = this; - access.directPeekBase = 0; - access.directPokeBase = 0; mySystem->setPageAccess(i >> shift, access); - } // Setup the second segment to always point to the last ROM slice + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 j = 0x1800; j < 0x2000; j += (1 << shift)) { - access.device = this; access.directPeekBase = &myImage[(mySize - 2048) + (j & 0x07FF)]; - access.directPokeBase = 0; mySystem->setPageAccess(j >> shift, access); } @@ -144,8 +144,9 @@ void Cartridge3F::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index 03b1dfec3..cb8454b26 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -73,6 +73,8 @@ void Cartridge4A50::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; // We don't yet indicate RAM areas + for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) mySystem->setPageAccess(i >> shift, access); diff --git a/src/emucore/Cart4K.cxx b/src/emucore/Cart4K.cxx index e84b7d8ee..7ff05af68 100644 --- a/src/emucore/Cart4K.cxx +++ b/src/emucore/Cart4K.cxx @@ -54,6 +54,7 @@ void Cartridge4K::install(System& system) System::PageAccess access; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index ed5caae67..66aec9327 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -98,6 +98,8 @@ void CartridgeAR::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; // We don't yet indicate RAM areas + for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) mySystem->setPageAccess(i >> shift, access); diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 1e8f917be..330cc5112 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -87,29 +87,32 @@ void CartridgeCV::install(System& system) System::PageAccess access; // Map ROM image into the system + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 address = 0x1800; address < 0x2000; address += (1 << shift)) { - access.device = this; access.directPeekBase = &myImage[address & 0x07FF]; - access.directPokeBase = 0; mySystem->setPageAccess(address >> mySystem->pageShift(), access); } // Set the page accessing method for the RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1400; j < 0x1800; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x03FF]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1000; k < 0x1400; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x03FF]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } } diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index 779a22f8d..be2d4febe 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -88,24 +88,23 @@ void CartridgeDPC::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Set the page accessing method for the DPC reading & writing pages + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READWRITE; for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(j >> shift, access); - } // Install pages for the startup bank bank(myStartBank); @@ -430,8 +429,9 @@ void CartridgeDPC::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map Program ROM image into the system for(uInt32 address = 0x1080; address < (0x1FF8U & ~mask); diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index 2b43c96bc..6b0986f85 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -100,6 +100,7 @@ void CartridgeDPCPlus::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) mySystem->setPageAccess(i >> shift, access); diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index d643d36e7..0bfbd2450 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -57,10 +57,12 @@ void CartridgeE0::install(System& system) assert(((0x1000 & mask) == 0) && ((0x1400 & mask) == 0) && ((0x1800 & mask) == 0) && ((0x1C00 & mask) == 0)); - // Set the page acessing methods for the first part of the last segment System::PageAccess access; + + // Set the page acessing methods for the first part of the last segment access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = 0x1C00; i < (0x1FE0U & ~mask); i += (1 << shift)) { access.directPeekBase = &myImage[7168 + (i & 0x03FF)]; @@ -72,10 +74,9 @@ void CartridgeE0::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; for(uInt32 j = (0x1FE0 & ~mask); j < 0x2000; j += (1 << shift)) - { mySystem->setPageAccess(j >> shift, access); - } // Install some default slices for the other segments segmentZero(4); @@ -138,8 +139,9 @@ void CartridgeE0::segmentZero(uInt16 slice) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 address = 0x1000; address < 0x1400; address += (1 << shift)) { @@ -161,8 +163,9 @@ void CartridgeE0::segmentOne(uInt16 slice) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 address = 0x1400; address < 0x1800; address += (1 << shift)) { @@ -184,8 +187,9 @@ void CartridgeE0::segmentTwo(uInt16 slice) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 address = 0x1800; address < 0x1C00; address += (1 << shift)) { diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index b232c2549..483187b6c 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -70,22 +70,23 @@ void CartridgeE7::install(System& system) assert(((0x1400 & mask) == 0) && ((0x1800 & mask) == 0) && ((0x1900 & mask) == 0) && ((0x1A00 & mask) == 0)); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Setup the second segment to always point to the last ROM slice + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 j = 0x1A00; j < (0x1FE0U & ~mask); j += (1 << shift)) { - access.device = this; access.directPeekBase = &myImage[7 * 2048 + (j & 0x07FF)]; - access.directPokeBase = 0; mySystem->setPageAccess(j >> shift, access); } myCurrentSlice[1] = 7; @@ -176,21 +177,22 @@ void CartridgeE7::bankRAM(uInt16 bank) System::PageAccess access; // Set the page accessing method for the 256 bytes of RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1800; j < 0x1900; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[1024 + offset + (j & 0x00FF)]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the 256 bytes of RAM reading pages - access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1900; k < 0x1A00; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[1024 + offset + (k & 0x00FF)]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } myBankChanged = true; @@ -212,31 +214,34 @@ void CartridgeE7::bank(uInt16 slice) if(slice != 7) { // Map ROM image into first segment + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) { - access.device = this; access.directPeekBase = &myImage[offset + (address & 0x07FF)]; - access.directPokeBase = 0; mySystem->setPageAccess(address >> shift, access); } } else { // Set the page accessing method for the 1K slice of RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1000; j < 0x1400; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x03FF]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the 1K slice of RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1400; k < 0x1800; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x03FF]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } } diff --git a/src/emucore/CartEF.cxx b/src/emucore/CartEF.cxx index d1dd7de17..be53d52f5 100644 --- a/src/emucore/CartEF.cxx +++ b/src/emucore/CartEF.cxx @@ -55,15 +55,15 @@ void CartridgeEF::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1000 & mask) == 0); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for the startup bank bank(myStartBank); @@ -104,10 +104,12 @@ void CartridgeEF::bank(uInt16 bank) uInt16 shift = mySystem->pageShift(); uInt16 mask = mySystem->pageMask(); - // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; + + // Setup the page access methods for the current bank access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < (0x1FE0U & ~mask); diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index b1e48a890..a3229c9e6 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -62,31 +62,33 @@ void CartridgeEFSC::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1000 & mask) == 0); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Set the page accessing method for the RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x007F]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x007F]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } @@ -149,8 +151,9 @@ void CartridgeEFSC::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1100; address < (0x1FE0U & ~mask); diff --git a/src/emucore/CartF0.cxx b/src/emucore/CartF0.cxx index 1f0d99d87..31f3f774e 100644 --- a/src/emucore/CartF0.cxx +++ b/src/emucore/CartF0.cxx @@ -56,15 +56,15 @@ void CartridgeF0::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1000 & mask) == 0); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF0 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for bank 1 myCurrentBank = 0; @@ -109,8 +109,9 @@ void CartridgeF0::incbank() // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < (0x1FF0U & ~mask); diff --git a/src/emucore/CartF4.cxx b/src/emucore/CartF4.cxx index 6472cd906..7de0b6397 100644 --- a/src/emucore/CartF4.cxx +++ b/src/emucore/CartF4.cxx @@ -56,15 +56,15 @@ void CartridgeF4::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1000 & mask) == 0); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF4 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for the startup bank bank(myStartBank); @@ -111,8 +111,9 @@ void CartridgeF4::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < (0x1FF4U & ~mask); diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index 578e0c452..4c5e016cb 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -62,31 +62,33 @@ void CartridgeF4SC::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF4 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Set the page accessing method for the RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x007F]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x007F]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } @@ -152,8 +154,9 @@ void CartridgeF4SC::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1100; address < (0x1FF4U & ~mask); diff --git a/src/emucore/CartF6.cxx b/src/emucore/CartF6.cxx index c3fa49fe4..143042182 100644 --- a/src/emucore/CartF6.cxx +++ b/src/emucore/CartF6.cxx @@ -55,15 +55,15 @@ void CartridgeF6::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1000 & mask) == 0); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF6 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Upon install we'll setup the startup bank bank(myStartBank); @@ -151,8 +151,9 @@ void CartridgeF6::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < (0x1FF6U & ~mask); diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index 022038b78..7d47d3955 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -62,31 +62,33 @@ void CartridgeF6SC::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF6 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Set the page accessing method for the RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x007F]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x007F]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } @@ -195,8 +197,9 @@ void CartridgeF6SC::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1100; address < (0x1FF6U & ~mask); diff --git a/src/emucore/CartF8.cxx b/src/emucore/CartF8.cxx index 34ed930d5..8f3f4659a 100644 --- a/src/emucore/CartF8.cxx +++ b/src/emucore/CartF8.cxx @@ -56,15 +56,15 @@ void CartridgeF8::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert((0x1000 & mask) == 0); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for the startup bank bank(myStartBank); @@ -132,8 +132,9 @@ void CartridgeF8::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < (0x1FF8U & ~mask); diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index 067ef62d9..fa83aec1d 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -62,31 +62,33 @@ void CartridgeF8SC::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Set the page accessing method for the RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x007F]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x007F]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } @@ -175,8 +177,9 @@ void CartridgeF8SC::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1100; address < (0x1FF8U & ~mask); diff --git a/src/emucore/CartFA.cxx b/src/emucore/CartFA.cxx index 6ae060fa4..4289e3d93 100644 --- a/src/emucore/CartFA.cxx +++ b/src/emucore/CartFA.cxx @@ -62,31 +62,33 @@ void CartridgeFA::install(System& system) // Make sure the system we're being installed in has a page size that'll work assert(((0x1100 & mask) == 0) && ((0x1200 & mask) == 0)); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Set the page accessing method for the RAM writing pages + access.directPeekBase = 0; + access.device = this; + access.type = System::PAGE_WRITE; for(uInt32 j = 0x1000; j < 0x1100; j += (1 << shift)) { - access.device = this; - access.directPeekBase = 0; access.directPokeBase = &myRAM[j & 0x00FF]; mySystem->setPageAccess(j >> shift, access); } // Set the page accessing method for the RAM reading pages + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 k = 0x1100; k < 0x1200; k += (1 << shift)) { - access.device = this; access.directPeekBase = &myRAM[k & 0x00FF]; - access.directPokeBase = 0; mySystem->setPageAccess(k >> shift, access); } @@ -185,8 +187,9 @@ void CartridgeFA::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1200; address < (0x1FF8U & ~mask); diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index 0f3800d8b..acda6bea0 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -58,6 +58,7 @@ void CartridgeFE::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) mySystem->setPageAccess(i >> shift, access); } diff --git a/src/emucore/CartMC.cxx b/src/emucore/CartMC.cxx index 336107c20..830ece60a 100644 --- a/src/emucore/CartMC.cxx +++ b/src/emucore/CartMC.cxx @@ -80,10 +80,15 @@ void CartridgeMC::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READWRITE; for(uInt32 i = 0x00; i < 0x40; i += (1 << shift)) mySystem->setPageAccess(i >> shift, access); // Map the cartridge into the system + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // We don't yet indicate RAM areas for(uInt32 j = 0x1000; j < 0x2000; j += (1 << shift)) mySystem->setPageAccess(j >> shift, access); } diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index b27727c2d..be00e8bb0 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -71,15 +71,15 @@ void CartridgeSB::install(System& system) myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> shift); myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> shift); - // Set the page accessing methods for the hot spots System::PageAccess access; + + // Set the page accessing methods for the hot spots + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for startup bank bank(myStartBank); @@ -136,8 +136,9 @@ void CartridgeSB::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index b05fc0269..dcc9a354b 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -64,6 +64,7 @@ void CartridgeUA::install(System& system) access.directPeekBase = 0; access.directPokeBase = 0; access.device = this; + access.type = System::PAGE_READ; mySystem->setPageAccess(0x0220 >> shift, access); mySystem->setPageAccess(0x0240 >> shift, access); @@ -144,8 +145,9 @@ void CartridgeUA::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) diff --git a/src/emucore/CartX07.cxx b/src/emucore/CartX07.cxx index 1fed44871..94a484ac3 100644 --- a/src/emucore/CartX07.cxx +++ b/src/emucore/CartX07.cxx @@ -61,13 +61,12 @@ void CartridgeX07::install(System& system) // The hotspots use almost all addresses below 0x1000, so we simply grab them // all and forward the TIA/RIOT calls from the peek and poke methods. System::PageAccess access; + access.directPeekBase = 0; + access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READWRITE; for(uInt32 i = 0x00; i < 0x1000; i += (1 << shift)) - { - access.directPeekBase = 0; - access.directPokeBase = 0; - access.device = this; mySystem->setPageAccess(i >> shift, access); - } // Install pages for the startup bank bank(myStartBank); @@ -130,8 +129,9 @@ void CartridgeX07::bank(uInt16 bank) // Setup the page access methods for the current bank System::PageAccess access; - access.device = this; access.directPokeBase = 0; + access.device = this; + access.type = System::PAGE_READ; // Map ROM image into the system for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index f222327d4..22434aa21 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -91,18 +91,15 @@ void M6532::install(System& system, Device& device) // All accesses are to the given device System::PageAccess access; + access.directPeekBase = 0; + access.directPokeBase = 0; access.device = &device; + access.type = System::PAGE_READWRITE; // We're installing in a 2600 system for(int address = 0; address < 8192; address += (1 << shift)) - { if((address & 0x1080) == 0x0080) - { - access.directPeekBase = 0; - access.directPokeBase = 0; mySystem->setPageAccess(address >> shift, access); - } - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index c0a000957..a5ce98cb9 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -179,6 +179,12 @@ const System::PageAccess& System::getPageAccess(uInt16 page) const return myPageAccessTable[page]; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +System::PageType System::getPageType(uInt16 addr) const +{ + return myPageAccessTable[(addr & myAddressMask) >> myPageShift].type; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void System::setDirtyPage(uInt16 addr) { diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index 9bf31881c..1fbe6145d 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -287,6 +287,12 @@ class System : public Serializable void unlockDataBus(); public: + enum PageType { + PAGE_READ = 1 << 0, + PAGE_WRITE = 1 << 1, + PAGE_READWRITE = PAGE_READ | PAGE_WRITE + }; + /** Structure used to specify access methods for a page */ @@ -310,9 +316,15 @@ class System : public Serializable /** Pointer to the device associated with this page or to the system's - null device if the page hasn't been mapped to a device + null device if the page hasn't been mapped to a device. */ Device* device; + + /** + The manner in which the pages are accessed by the system + (READ, WRITE, READ|WRITE) + */ + PageType type; }; /** @@ -331,6 +343,14 @@ class System : public Serializable */ const PageAccess& getPageAccess(uInt16 page) const; + /** + Get the page type for the given address. + + @param addr The address contained in the page in questions + @return The type of page that contains the given address + */ + PageType getPageType(uInt16 addr) const; + /** Mark the page containing this address as being dirty. diff --git a/src/emucore/TIA.cxx b/src/emucore/TIA.cxx index 4c3291a48..a148ccd33 100644 --- a/src/emucore/TIA.cxx +++ b/src/emucore/TIA.cxx @@ -295,15 +295,12 @@ void TIA::install(System& system, Device& device) access.directPeekBase = 0; access.directPokeBase = 0; access.device = &device; + access.type = System::PAGE_READWRITE; // We're installing in a 2600 system for(uInt32 i = 0; i < 8192; i += (1 << shift)) - { if((i & 0x1080) == 0x0000) - { mySystem->setPageAccess(i >> shift, access); - } - } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -