diff --git a/src/emucore/Cart0840.cxx b/src/emucore/Cart0840.cxx index bce40ce84..9c4ab4259 100644 --- a/src/emucore/Cart0840.cxx +++ b/src/emucore/Cart0840.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -51,27 +50,22 @@ void Cartridge0840::reset() void Cartridge0840::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Get the page accessing methods for the hot spots since they overlap // areas within the TIA we'll need to forward requests to the TIA - myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> shift); - myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> shift); - myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> shift); - myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> shift); - myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> shift); - myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> shift); - myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> shift); - myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> shift); + myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> System::PAGE_SHIFT); + myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> System::PAGE_SHIFT); + myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> System::PAGE_SHIFT); // Set the page accessing methods for the hot spots System::PageAccess access(this, System::PA_READ); - for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Install pages for bank 0 bank(myStartBank); @@ -150,17 +144,16 @@ bool Cartridge0840::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x2000; address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/Cart2K.cxx b/src/emucore/Cart2K.cxx index e99f4e3fe..f5e93635b 100644 --- a/src/emucore/Cart2K.cxx +++ b/src/emucore/Cart2K.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -70,20 +69,14 @@ void Cartridge2K::reset() void Cartridge2K::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Map ROM image into the system System::PageAccess access(this, System::PA_READ); - - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x2000; address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[address & myMask]; access.codeAccessBase = &myCodeAccessBase[address & myMask]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } diff --git a/src/emucore/Cart3E.cxx b/src/emucore/Cart3E.cxx index 50cba480d..80b01aa61 100644 --- a/src/emucore/Cart3E.cxx +++ b/src/emucore/Cart3E.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -65,11 +64,6 @@ void Cartridge3E::reset() void Cartridge3E::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1800 & mask) == 0); System::PageAccess access(this, System::PA_READWRITE); @@ -77,16 +71,16 @@ void Cartridge3E::install(System& system) // 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). - for(uInt32 i = 0x00; i < 0x40; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x00; i < 0x40; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Setup the second segment to always point to the last ROM slice access.type = System::PA_READ; - for(uInt32 j = 0x1800; j < 0x2000; j += (1 << shift)) + for(uInt32 j = 0x1800; j < 0x2000; j += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[(mySize - 2048) + (j & 0x07FF)]; access.codeAccessBase = &myCodeAccessBase[(mySize - 2048) + (j & 0x07FF)]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Install pages for the startup bank into the first segment @@ -173,17 +167,17 @@ bool Cartridge3E::bank(uInt16 bank) } uInt32 offset = myCurrentBank << 11; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x1800; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x07FF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x07FF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } else @@ -193,29 +187,28 @@ bool Cartridge3E::bank(uInt16 bank) myCurrentBank = bank + 256; uInt32 offset = bank << 10; - uInt16 shift = mySystem->pageShift(); uInt32 address; // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map read-port RAM image into the system - for(address = 0x1000; address < 0x1400; address += (1 << shift)) + for(address = 0x1000; address < 0x1400; address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[offset + (address & 0x03FF)]; access.codeAccessBase = &myCodeAccessBase[mySize + offset + (address & 0x03FF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } access.directPeekBase = 0; access.type = System::PA_WRITE; // Map write-port RAM image into the system - for(address = 0x1400; address < 0x1800; address += (1 << shift)) + for(address = 0x1400; address < 0x1800; address += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[offset + (address & 0x03FF)]; access.codeAccessBase = &myCodeAccessBase[mySize + offset + (address & 0x03FF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } return myBankChanged = true; diff --git a/src/emucore/Cart3F.cxx b/src/emucore/Cart3F.cxx index b0bdd2a78..b0669d88f 100644 --- a/src/emucore/Cart3F.cxx +++ b/src/emucore/Cart3F.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,11 +57,6 @@ void Cartridge3F::reset() void Cartridge3F::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1800 & mask) == 0); System::PageAccess access(this, System::PA_READWRITE); @@ -70,16 +64,16 @@ void Cartridge3F::install(System& system) // 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). - for(uInt32 i = 0x00; i < 0x40; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x00; i < 0x40; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Setup the second segment to always point to the last ROM slice access.type = System::PA_READ; - for(uInt32 j = 0x1800; j < 0x2000; j += (1 << shift)) + for(uInt32 j = 0x1800; j < 0x2000; j += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[(mySize - 2048) + (j & 0x07FF)]; access.codeAccessBase = &myCodeAccessBase[(mySize - 2048) + (j & 0x07FF)]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Install pages for startup bank into the first segment @@ -139,17 +133,17 @@ bool Cartridge3F::bank(uInt16 bank) } uInt32 offset = myCurrentBank << 11; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x1800; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x07FF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x07FF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/Cart4A50.cxx b/src/emucore/Cart4A50.cxx index 4acf2e145..5ab75fc01 100644 --- a/src/emucore/Cart4A50.cxx +++ b/src/emucore/Cart4A50.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -77,17 +76,11 @@ void Cartridge4A50::reset() void Cartridge4A50::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Map all of the accesses to call peek and poke (We don't yet indicate RAM areas) System::PageAccess access(this, System::PA_READ); - - for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x1000; i < 0x2000; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Mirror all access in TIA and RIOT; by doing so we're taking responsibility // for that address space in peek and poke below. diff --git a/src/emucore/Cart4K.cxx b/src/emucore/Cart4K.cxx index 0f9fc9667..6b7667377 100644 --- a/src/emucore/Cart4K.cxx +++ b/src/emucore/Cart4K.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -47,20 +46,15 @@ void Cartridge4K::reset() void Cartridge4K::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); - - System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + System::PageAccess access(this, System::PA_READ); + for(uInt32 address = 0x1000; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[address & 0x0FFF]; access.codeAccessBase = &myCodeAccessBase[address & 0x0FFF]; - mySystem->setPageAccess(address >> mySystem->pageShift(), access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } diff --git a/src/emucore/Cart4KSC.cxx b/src/emucore/Cart4KSC.cxx index 61f8ad326..9ac578a53 100644 --- a/src/emucore/Cart4KSC.cxx +++ b/src/emucore/Cart4KSC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -53,39 +52,34 @@ void Cartridge4KSC::reset() void Cartridge4KSC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Map ROM image into the system - for(uInt32 address = 0x1100; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1100; address < 0x2000; address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[address & 0x0FFF]; access.codeAccessBase = &myCodeAccessBase[address & 0x0FFF]; - mySystem->setPageAccess(address >> mySystem->pageShift(), access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } diff --git a/src/emucore/CartAR.cxx b/src/emucore/CartAR.cxx index bad5d93a7..c0b5d91fd 100644 --- a/src/emucore/CartAR.cxx +++ b/src/emucore/CartAR.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "M6502.hxx" @@ -96,19 +95,13 @@ void CartridgeAR::systemCyclesReset() void CartridgeAR::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); my6502 = &(mySystem->m6502()); - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); - // Map all of the accesses to call peek and poke (we don't yet indicate RAM areas) System::PageAccess access(this, System::PA_READ); - - for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x1000; i < 0x2000; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); bankConfiguration(0); } diff --git a/src/emucore/CartBF.cxx b/src/emucore/CartBF.cxx index 006e91d0c..77a6f6922 100644 --- a/src/emucore/CartBF.cxx +++ b/src/emucore/CartBF.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -52,9 +51,6 @@ void CartridgeBF::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Install pages for the startup bank bank(myStartBank); } @@ -91,25 +87,24 @@ bool CartridgeBF::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1F80 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1F80 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1F80U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1F80U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartBFSC.cxx b/src/emucore/CartBFSC.cxx index 122ec2829..f6c6b8998 100644 --- a/src/emucore/CartBFSC.cxx +++ b/src/emucore/CartBFSC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeBFSC::reset() void CartridgeBFSC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -139,25 +133,24 @@ bool CartridgeBFSC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1F80 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1F80 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1100; address < (0x1F80U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1100; address < (0x1F80U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartCM.cxx b/src/emucore/CartCM.cxx index e6b7341bc..8653744bf 100644 --- a/src/emucore/CartCM.cxx +++ b/src/emucore/CartCM.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -61,10 +60,6 @@ void CartridgeCM::reset() void CartridgeCM::install(System& system) { mySystem = &system; - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Mirror all access in RIOT; by doing so we're taking responsibility // for that address space in peek and poke below. @@ -111,7 +106,6 @@ bool CartridgeCM::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Although this scheme contains four 4K ROM banks and one 2K RAM bank, // it's easier to think of things in terms of 2K slices, as follows: @@ -124,15 +118,17 @@ bool CartridgeCM::bank(uInt16 bank) System::PageAccess access(this, System::PA_READ); // Lower 2K (always ROM) - for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x1800; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } // Upper 2K (RAM or ROM) - for(uInt32 address = 0x1800; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1800; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.type = System::PA_READWRITE; @@ -152,7 +148,7 @@ bool CartridgeCM::bank(uInt16 bank) else access.directPokeBase = 0; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 9de09b2cb..87e536393 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "OSystem.hxx" @@ -85,16 +84,11 @@ void CartridgeCTY::systemCyclesReset() void CartridgeCTY::install(System& system) { mySystem = &system; - uInt16 mask = mySystem->pageMask(); - uInt16 shift = mySystem->pageShift(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1000 & mask) == 0) && ((0x1080 & mask) == 0)); // Map all RAM accesses to call peek and poke System::PageAccess access(this, System::PA_READ); - for(uInt32 i = 0x1000; i < 0x1080; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x1000; i < 0x1080; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Install pages for the startup bank bank(myStartBank); @@ -252,14 +246,14 @@ bool CartridgeCTY::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); - for(uInt32 address = 0x1080; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1080; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[myCurrentBank + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartCV.cxx b/src/emucore/CartCV.cxx index 28943f08b..4e25a072d 100644 --- a/src/emucore/CartCV.cxx +++ b/src/emucore/CartCV.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -81,40 +80,36 @@ void CartridgeCV::reset() void CartridgeCV::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1800 & mask) == 0); System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1800; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1800; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[address & 0x07FF]; access.codeAccessBase = &myCodeAccessBase[address & 0x07FF]; - mySystem->setPageAccess(address >> mySystem->pageShift(), access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM writing pages access.directPeekBase = 0; access.codeAccessBase = 0; access.type = System::PA_WRITE; - for(uInt32 j = 0x1400; j < 0x1800; j += (1 << shift)) + for(uInt32 j = 0x1400; j < 0x1800; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x03FF]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1000; k < 0x1400; k += (1 << shift)) + for(uInt32 k = 0x1000; k < 0x1400; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x03FF]; access.codeAccessBase = &myCodeAccessBase[2048 + (k & 0x03FF)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } } diff --git a/src/emucore/CartDASH.cxx b/src/emucore/CartDASH.cxx index a0c75bba4..965bee2be 100644 --- a/src/emucore/CartDASH.cxx +++ b/src/emucore/CartDASH.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -74,20 +73,14 @@ void CartridgeDASH::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1800 & mask) == 0); - System::PageAccess access(this, System::PA_READWRITE); // 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). - for (uInt32 i = 0x00; i < 0x40; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for (uInt32 i = 0x00; i < 0x40; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Initialise bank values for all ROM/RAM access // This is used to reverse-lookup from address to bank location @@ -182,7 +175,7 @@ bool CartridgeDASH::bankRAM(uInt8 bank) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeDASH::bankRAMSlot(uInt16 bank) { - uInt16 shift = mySystem->pageShift(); + uInt16 shift = System::PAGE_SHIFT; uInt16 bankNumber = (bank >> BANK_BITS) & 3; // which bank # we are switching TO (BITS D6,D7) to 512 byte block uInt16 currentBank = bank & BIT_BANK_MASK; // Wrap around/restrict to valid range @@ -240,8 +233,6 @@ bool CartridgeDASH::bankROM(uInt8 bank) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeDASH::bankROMSlot(uInt16 bank) { - uInt16 shift = mySystem->pageShift(); - uInt16 bankNumber = (bank >> BANK_BITS) & 3; // which bank # we are switching TO (BITS D6,D7) uInt16 currentBank = bank & BIT_BANK_MASK; // Wrap around/restrict to valid range bool upper = bank & BITMASK_LOWERUPPER; // is this the lower or upper 512b @@ -256,18 +247,16 @@ void CartridgeDASH::bankROMSlot(uInt16 bank) { uInt32 start = 0x1000 + (bankNumber << ROM_BANK_TO_POWER) + (upper ? ROM_BANK_SIZE / 2 : 0); uInt32 end = start + ROM_BANK_SIZE / 2 - 1; - for (uInt32 address = start; address <= end; address += (1 << shift)) { + for (uInt32 address = start; address <= end; address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[startCurrentBank + (address & (ROM_BANK_SIZE - 1))]; access.codeAccessBase = &myCodeAccessBase[startCurrentBank + (address & (ROM_BANK_SIZE - 1))]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CartridgeDASH::initializeBankState() { - const uInt16& shift = mySystem->pageShift(); - // Switch in each 512b slot for (uInt32 b = 0; b < 8; b++) { if (bankInUse[b] == BANK_UNDEFINED) { @@ -276,8 +265,8 @@ void CartridgeDASH::initializeBankState() { System::PageAccess access(this, System::PA_READ); uInt32 start = 0x1000 + (b << RAM_BANK_TO_POWER); uInt32 end = start + RAM_BANK_SIZE - 1; - for (uInt32 address = start; address <= end; address += (1 << shift)) - mySystem->setPageAccess(address >> shift, access); + for (uInt32 address = start; address <= end; address += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } else if (bankInUse[b] & BITMASK_ROMRAM) diff --git a/src/emucore/CartDF.cxx b/src/emucore/CartDF.cxx index 14eb12997..1b8202f49 100644 --- a/src/emucore/CartDF.cxx +++ b/src/emucore/CartDF.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -52,9 +51,6 @@ void CartridgeDF::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Install pages for the startup bank bank(myStartBank); } @@ -91,25 +87,24 @@ bool CartridgeDF::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FC0 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FC0 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1FC0U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1FC0U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartDFSC.cxx b/src/emucore/CartDFSC.cxx index 2fdb2e4bc..f09ed452a 100644 --- a/src/emucore/CartDFSC.cxx +++ b/src/emucore/CartDFSC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeDFSC::reset() void CartridgeDFSC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -139,25 +133,24 @@ bool CartridgeDFSC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FC0 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FC0 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1100; address < (0x1FC0U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1100; address < (0x1FC0U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartDPC.cxx b/src/emucore/CartDPC.cxx index f704bda10..454c7f7de 100644 --- a/src/emucore/CartDPC.cxx +++ b/src/emucore/CartDPC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -85,17 +84,11 @@ void CartridgeDPC::systemCyclesReset() void CartridgeDPC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); - - System::PageAccess access(this, System::PA_READWRITE); // Set the page accessing method for the DPC reading & writing pages - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) - mySystem->setPageAccess(j >> shift, access); + System::PageAccess access(this, System::PA_READWRITE); + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); // Install pages for the startup bank bank(myStartBank); @@ -415,25 +408,24 @@ bool CartridgeDPC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF8 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1080; address < (0x1FF8U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1080; address < (0x1FF8U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myProgramImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartDPCPlus.cxx b/src/emucore/CartDPCPlus.cxx index c5ecbbdb2..adaade59e 100644 --- a/src/emucore/CartDPCPlus.cxx +++ b/src/emucore/CartDPCPlus.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #ifdef DEBUGGER_SUPPORT @@ -128,17 +127,11 @@ void CartridgeDPCPlus::systemCyclesReset() void CartridgeDPCPlus::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); - - System::PageAccess access(this, System::PA_READ); // Map all of the accesses to call peek and poke - for(uInt32 i = 0x1000; i < 0x1080; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + System::PageAccess access(this, System::PA_READ); + for(uInt32 i = 0x1000; i < 0x1080; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Install pages for the startup bank bank(myStartBank); @@ -607,16 +600,16 @@ bool CartridgeDPCPlus::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map Program ROM image into the system - for(uInt32 address = 0x1080; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1080; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartE0.cxx b/src/emucore/CartE0.cxx index 3fe4abc94..2d05c355b 100644 --- a/src/emucore/CartE0.cxx +++ b/src/emucore/CartE0.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -52,21 +51,16 @@ void CartridgeE0::reset() void CartridgeE0::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1000 & mask) == 0) && ((0x1400 & mask) == 0) && - ((0x1800 & mask) == 0) && ((0x1C00 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page acessing methods for the first part of the last segment - for(uInt32 i = 0x1C00; i < (0x1FE0U & ~mask); i += (1 << shift)) + for(uInt32 i = 0x1C00; i < (0x1FE0U & ~System::PAGE_MASK); + i += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[7168 + (i & 0x03FF)]; access.codeAccessBase = &myCodeAccessBase[7168 + (i & 0x03FF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } myCurrentSlice[3] = 7; @@ -74,8 +68,9 @@ void CartridgeE0::install(System& system) access.directPeekBase = 0; access.codeAccessBase = &myCodeAccessBase[8128]; access.type = System::PA_READ; - for(uInt32 j = (0x1FE0 & ~mask); j < 0x2000; j += (1 << shift)) - mySystem->setPageAccess(j >> shift, access); + for(uInt32 j = (0x1FE0 & ~System::PAGE_MASK); j < 0x2000; + j += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); // Install some default slices for the other segments segmentZero(4); @@ -134,7 +129,7 @@ void CartridgeE0::segmentZero(uInt16 slice) // Remember the new slice myCurrentSlice[0] = slice; uInt16 offset = slice << 10; - uInt16 shift = mySystem->pageShift(); + uInt16 shift = System::PAGE_SHIFT; // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); @@ -156,7 +151,7 @@ void CartridgeE0::segmentOne(uInt16 slice) // Remember the new slice myCurrentSlice[1] = slice; uInt16 offset = slice << 10; - uInt16 shift = mySystem->pageShift(); + uInt16 shift = System::PAGE_SHIFT; // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); @@ -178,16 +173,16 @@ void CartridgeE0::segmentTwo(uInt16 slice) // Remember the new slice myCurrentSlice[2] = slice; uInt16 offset = slice << 10; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); - for(uInt32 address = 0x1800; address < 0x1C00; address += (1 << shift)) + for(uInt32 address = 0x1800; address < 0x1C00; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x03FF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x03FF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } myBankChanged = true; } diff --git a/src/emucore/CartE7.cxx b/src/emucore/CartE7.cxx index 6e3516c12..230879746 100644 --- a/src/emucore/CartE7.cxx +++ b/src/emucore/CartE7.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -61,28 +60,24 @@ void CartridgeE7::reset() void CartridgeE7::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1400 & mask) == 0) && ((0x1800 & mask) == 0) && - ((0x1900 & mask) == 0) && ((0x1A00 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FE0 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[8128]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the second segment to always point to the last ROM slice - for(uInt32 j = 0x1A00; j < (0x1FE0U & ~mask); j += (1 << shift)) + for(uInt32 j = 0x1A00; j < (0x1FE0U & ~System::PAGE_MASK); + j += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[7 * 2048 + (j & 0x07FF)]; access.codeAccessBase = &myCodeAccessBase[7 * 2048 + (j & 0x07FF)]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } myCurrentSlice[1] = 7; @@ -166,7 +161,7 @@ void CartridgeE7::bankRAM(uInt16 bank) // Remember what bank we're in myCurrentRAM = bank; uInt16 offset = bank << 8; - uInt16 shift = mySystem->pageShift(); + uInt16 shift = System::PAGE_SHIFT; // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_WRITE); @@ -199,7 +194,6 @@ bool CartridgeE7::bank(uInt16 slice) // Remember what bank we're in myCurrentSlice[0] = slice; uInt16 offset = slice << 11; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank if(slice != 7) @@ -207,11 +201,12 @@ bool CartridgeE7::bank(uInt16 slice) System::PageAccess access(this, System::PA_READ); // Map ROM image into first segment - for(uInt32 address = 0x1000; address < 0x1800; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x1800; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x07FF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x07FF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } } else @@ -219,21 +214,21 @@ bool CartridgeE7::bank(uInt16 slice) System::PageAccess access(this, System::PA_WRITE); // Set the page accessing method for the 1K slice of RAM writing pages - for(uInt32 j = 0x1000; j < 0x1400; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1400; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x03FF]; access.codeAccessBase = &myCodeAccessBase[8192 + (j & 0x03FF)]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the 1K slice of RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1400; k < 0x1800; k += (1 << shift)) + for(uInt32 k = 0x1400; k < 0x1800; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x03FF]; access.codeAccessBase = &myCodeAccessBase[8192 + (k & 0x03FF)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } } return myBankChanged = true; diff --git a/src/emucore/CartEF.cxx b/src/emucore/CartEF.cxx index f2899c19a..f7c32b579 100644 --- a/src/emucore/CartEF.cxx +++ b/src/emucore/CartEF.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -52,9 +51,6 @@ void CartridgeEF::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Install pages for the startup bank bank(myStartBank); } @@ -91,25 +87,24 @@ bool CartridgeEF::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FE0 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1FE0U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1FE0U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartEFSC.cxx b/src/emucore/CartEFSC.cxx index 339f470b5..ce4362636 100644 --- a/src/emucore/CartEFSC.cxx +++ b/src/emucore/CartEFSC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeEFSC::reset() void CartridgeEFSC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -139,25 +133,24 @@ bool CartridgeEFSC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FE0 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FE0 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1100; address < (0x1FE0U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1100; address < (0x1FE0U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartF0.cxx b/src/emucore/CartF0.cxx index a844dc0d7..0f2c541b7 100644 --- a/src/emucore/CartF0.cxx +++ b/src/emucore/CartF0.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -53,9 +52,6 @@ void CartridgeF0::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Install pages for bank 1 myCurrentBank = 0; incbank(); @@ -94,25 +90,24 @@ void CartridgeF0::incbank() myCurrentBank++; myCurrentBank &= 0x0F; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF0 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF0 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1FF0U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1FF0U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } myBankChanged = true; } diff --git a/src/emucore/CartF4.cxx b/src/emucore/CartF4.cxx index bad472cb0..d0457c368 100644 --- a/src/emucore/CartF4.cxx +++ b/src/emucore/CartF4.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "Random.hxx" @@ -53,9 +52,6 @@ void CartridgeF4::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Install pages for the startup bank bank(myStartBank); } @@ -96,25 +92,24 @@ bool CartridgeF4::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF4 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF4 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1FF4U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1FF4U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartF4SC.cxx b/src/emucore/CartF4SC.cxx index 4f1956bef..f8844005f 100644 --- a/src/emucore/CartF4SC.cxx +++ b/src/emucore/CartF4SC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeF4SC::reset() void CartridgeF4SC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -142,25 +136,24 @@ bool CartridgeF4SC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF4 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF4 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1100; address < (0x1FF4U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1100; address < (0x1FF4U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartF6.cxx b/src/emucore/CartF6.cxx index 39645d67d..7b5584898 100644 --- a/src/emucore/CartF6.cxx +++ b/src/emucore/CartF6.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -52,9 +51,6 @@ void CartridgeF6::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Upon install we'll setup the startup bank bank(myStartBank); } @@ -136,25 +132,24 @@ bool CartridgeF6::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF6 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF6 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1FF6U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1FF6U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartF6SC.cxx b/src/emucore/CartF6SC.cxx index ba2d82aa1..014c11baa 100644 --- a/src/emucore/CartF6SC.cxx +++ b/src/emucore/CartF6SC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeF6SC::reset() void CartridgeF6SC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -185,25 +179,24 @@ bool CartridgeF6SC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF6 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF6 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1100; address < (0x1FF6U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1100; address < (0x1FF6U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartF8.cxx b/src/emucore/CartF8.cxx index 8eb2f9576..a38f66b31 100644 --- a/src/emucore/CartF8.cxx +++ b/src/emucore/CartF8.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -60,9 +59,6 @@ void CartridgeF8::install(System& system) { mySystem = &system; - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mySystem->pageMask()) == 0); - // Install pages for the startup bank bank(myStartBank); } @@ -124,25 +120,24 @@ bool CartridgeF8::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF8 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1000; address < (0x1FF8U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1000; address < (0x1FF8U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartF8SC.cxx b/src/emucore/CartF8SC.cxx index b4b928db1..3c63345a8 100644 --- a/src/emucore/CartF8SC.cxx +++ b/src/emucore/CartF8SC.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeF8SC::reset() void CartridgeF8SC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1080 & mask) == 0) && ((0x1100 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1080; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1080; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x007F]; access.codeAccessBase = &myCodeAccessBase[j & 0x007F]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1080; k < 0x1100; k += (1 << shift)) + for(uInt32 k = 0x1080; k < 0x1100; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x007F]; access.codeAccessBase = &myCodeAccessBase[0x80 + (k & 0x007F)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -165,25 +159,24 @@ bool CartridgeF8SC::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF8 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1100; address < (0x1FF8U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1100; address < (0x1FF8U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartFA.cxx b/src/emucore/CartFA.cxx index 3a8c3285e..224605215 100644 --- a/src/emucore/CartFA.cxx +++ b/src/emucore/CartFA.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,31 +57,26 @@ void CartridgeFA::reset() void CartridgeFA::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1100 & mask) == 0) && ((0x1200 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1100; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1100; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x00FF]; access.codeAccessBase = &myCodeAccessBase[j & 0x00FF]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1100; k < 0x1200; k += (1 << shift)) + for(uInt32 k = 0x1100; k < 0x1200; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x00FF]; access.codeAccessBase = &myCodeAccessBase[0x100 + (k & 0x00FF)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -175,25 +169,24 @@ bool CartridgeFA::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF8 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF8 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1200; address < (0x1FF8U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1200; address < (0x1FF8U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartFA2.cxx b/src/emucore/CartFA2.cxx index 1b5f537a6..d4218a9d7 100644 --- a/src/emucore/CartFA2.cxx +++ b/src/emucore/CartFA2.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "OSystem.hxx" @@ -74,31 +73,26 @@ void CartridgeFA2::reset() void CartridgeFA2::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert(((0x1100 & mask) == 0) && ((0x1200 & mask) == 0)); System::PageAccess access(this, System::PA_READ); // Set the page accessing method for the RAM writing pages access.type = System::PA_WRITE; - for(uInt32 j = 0x1000; j < 0x1100; j += (1 << shift)) + for(uInt32 j = 0x1000; j < 0x1100; j += (1 << System::PAGE_SHIFT)) { access.directPokeBase = &myRAM[j & 0x00FF]; access.codeAccessBase = &myCodeAccessBase[j & 0x00FF]; - mySystem->setPageAccess(j >> shift, access); + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // Set the page accessing method for the RAM reading pages access.directPokeBase = 0; access.type = System::PA_READ; - for(uInt32 k = 0x1100; k < 0x1200; k += (1 << shift)) + for(uInt32 k = 0x1100; k < 0x1200; k += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myRAM[k & 0x00FF]; access.codeAccessBase = &myCodeAccessBase[0x100 + (k & 0x00FF)]; - mySystem->setPageAccess(k >> shift, access); + mySystem->setPageAccess(k >> System::PAGE_SHIFT, access); } // Install pages for the startup bank @@ -245,25 +239,24 @@ bool CartridgeFA2::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = (0x1FF4 & ~mask); i < 0x2000; i += (1 << shift)) + for(uInt32 i = (0x1FF4 & ~System::PAGE_MASK); i < 0x2000; + i += (1 << System::PAGE_SHIFT)) { access.codeAccessBase = &myCodeAccessBase[offset + (i & 0x0FFF)]; - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // Setup the page access methods for the current bank - for(uInt32 address = 0x1200; address < (0x1FF4U & ~mask); - address += (1 << shift)) + for(uInt32 address = 0x1200; address < (0x1FF4U & ~System::PAGE_MASK); + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartFE.cxx b/src/emucore/CartFE.cxx index b962c538c..507945b53 100644 --- a/src/emucore/CartFE.cxx +++ b/src/emucore/CartFE.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -57,17 +56,11 @@ void CartridgeFE::reset() void CartridgeFE::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); - - System::PageAccess access(this, System::PA_READ); // Map all of the accesses to call peek and poke - for(uInt32 i = 0x1000; i < 0x2000; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + System::PageAccess access(this, System::PA_READ); + for(uInt32 i = 0x1000; i < 0x2000; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartMC.cxx b/src/emucore/CartMC.cxx index 8ae429f24..faee3d9fa 100644 --- a/src/emucore/CartMC.cxx +++ b/src/emucore/CartMC.cxx @@ -68,12 +68,12 @@ void CartridgeMC::reset() void CartridgeMC::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); +/* // Make sure the system we're being installed in has a page size that'll work assert(((0x1000 & mask) == 0) && ((0x1400 & mask) == 0) && ((0x1800 & mask) == 0) && ((0x1C00 & mask) == 0)); +*/ // Set the page accessing methods for the hot spots in the TIA. For // correct emulation I would need to chain any accesses below 0x40 to @@ -84,13 +84,13 @@ void CartridgeMC::install(System& system) // System::PageAccess access(this, System::PA_READWRITE); - for(uInt32 i = 0x00; i < 0x40; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x00; i < 0x40; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Map the cartridge into the system access.type = System::PA_READ; // We don't yet indicate RAM areas - for(uInt32 j = 0x1000; j < 0x2000; j += (1 << shift)) - mySystem->setPageAccess(j >> shift, access); + for(uInt32 j = 0x1000; j < 0x2000; j += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(j >> System::PAGE_SHIFT, access); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/CartMDM.cxx b/src/emucore/CartMDM.cxx index b1b43a85e..75309e5c3 100644 --- a/src/emucore/CartMDM.cxx +++ b/src/emucore/CartMDM.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -58,27 +57,22 @@ void CartridgeMDM::reset() void CartridgeMDM::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Get the page accessing methods for the hot spots since they overlap // areas within the TIA we'll need to forward requests to the TIA - myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> shift); - myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> shift); - myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> shift); - myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> shift); - myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> shift); - myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> shift); - myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> shift); - myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> shift); + myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> System::PAGE_SHIFT); + myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> System::PAGE_SHIFT); + myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> System::PAGE_SHIFT); // Set the page accessing methods for the hot spots System::PageAccess access(this, System::PA_READWRITE); - for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Install pages for bank 0 bank(myStartBank); @@ -122,17 +116,17 @@ bool CartridgeMDM::bank(uInt16 bank) // Wrap around to a valid bank number if necessary myCurrentBank = bank % bankCount(); uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } // Accesses above bank 127 disable further bankswitching; we're only diff --git a/src/emucore/CartSB.cxx b/src/emucore/CartSB.cxx index 0836bb69a..28155605b 100644 --- a/src/emucore/CartSB.cxx +++ b/src/emucore/CartSB.cxx @@ -17,7 +17,6 @@ // $Id: CartSB.cxx,v 1.0 2007/10/11 //============================================================================ -#include #include #include "System.hxx" @@ -57,28 +56,23 @@ void CartridgeSB::reset() void CartridgeSB::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Get the page accessing methods for the hot spots since they overlap // areas within the TIA we'll need to forward requests to the TIA - myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> shift); - myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> shift); - myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> shift); - myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> shift); - myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> shift); - myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> shift); - myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> shift); - myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> shift); + myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> System::PAGE_SHIFT); + myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> System::PAGE_SHIFT); + myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> System::PAGE_SHIFT); + myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> System::PAGE_SHIFT); System::PageAccess access(this, System::PA_READ); // Set the page accessing methods for the hot spots - for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Install pages for startup bank bank(myStartBank); @@ -131,17 +125,17 @@ bool CartridgeSB::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartUA.cxx b/src/emucore/CartUA.cxx index 4bcbbe5e8..2e04603ba 100644 --- a/src/emucore/CartUA.cxx +++ b/src/emucore/CartUA.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -51,20 +50,15 @@ void CartridgeUA::reset() void CartridgeUA::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1000 & mask) == 0); // Get the page accessing methods for the hot spots since they overlap // areas within the TIA we'll need to forward requests to the TIA - myHotSpotPageAccess = mySystem->getPageAccess(0x0220 >> shift); + myHotSpotPageAccess = mySystem->getPageAccess(0x0220 >> System::PAGE_SHIFT); // Set the page accessing methods for the hot spots System::PageAccess access(this, System::PA_READ); - mySystem->setPageAccess(0x0220 >> shift, access); - mySystem->setPageAccess(0x0240 >> shift, access); + mySystem->setPageAccess(0x0220 >> System::PAGE_SHIFT, access); + mySystem->setPageAccess(0x0240 >> System::PAGE_SHIFT, access); // Install pages for the startup bank bank(myStartBank); @@ -139,17 +133,17 @@ bool CartridgeUA::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = bank; uInt16 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/CartX07.cxx b/src/emucore/CartX07.cxx index 82f754bee..2df3bcd00 100644 --- a/src/emucore/CartX07.cxx +++ b/src/emucore/CartX07.cxx @@ -17,7 +17,6 @@ // $Id$ //============================================================================ -#include #include #include "System.hxx" @@ -53,18 +52,13 @@ void CartridgeX07::reset() void CartridgeX07::install(System& system) { mySystem = &system; - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // 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 // 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(this, System::PA_READWRITE); - for(uInt32 i = 0x00; i < 0x1000; i += (1 << shift)) - mySystem->setPageAccess(i >> shift, access); + for(uInt32 i = 0x00; i < 0x1000; i += (1 << System::PAGE_SHIFT)) + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); // Install pages for the startup bank bank(myStartBank); @@ -123,17 +117,17 @@ bool CartridgeX07::bank(uInt16 bank) // Remember what bank we're in myCurrentBank = (bank & 0x0f); uInt32 offset = myCurrentBank << 12; - uInt16 shift = mySystem->pageShift(); // Setup the page access methods for the current bank System::PageAccess access(this, System::PA_READ); // Map ROM image into the system - for(uInt32 address = 0x1000; address < 0x2000; address += (1 << shift)) + for(uInt32 address = 0x1000; address < 0x2000; + address += (1 << System::PAGE_SHIFT)) { access.directPeekBase = &myImage[offset + (address & 0x0FFF)]; access.codeAccessBase = &myCodeAccessBase[offset + (address & 0x0FFF)]; - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } return myBankChanged = true; } diff --git a/src/emucore/M6532.cxx b/src/emucore/M6532.cxx index dfd96183a..6b2ba2b8a 100644 --- a/src/emucore/M6532.cxx +++ b/src/emucore/M6532.cxx @@ -115,20 +115,14 @@ void M6532::install(System& system, Device& device) { // Remember which system I'm installed in mySystem = &system; - - uInt16 shift = mySystem->pageShift(); - uInt16 mask = mySystem->pageMask(); - - // Make sure the system we're being installed in has a page size that'll work - assert((0x1080 & mask) == 0); // All accesses are to the given device System::PageAccess access(&device, System::PA_READWRITE); // We're installing in a 2600 system - for(int address = 0; address < 8192; address += (1 << shift)) + for(int address = 0; address < 8192; address += (1 << System::PAGE_SHIFT)) if((address & 0x1080) == 0x0080) - mySystem->setPageAccess(address >> shift, access); + mySystem->setPageAccess(address >> System::PAGE_SHIFT, access); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/System.cxx b/src/emucore/System.cxx index c9a4e47f6..77d92a343 100644 --- a/src/emucore/System.cxx +++ b/src/emucore/System.cxx @@ -27,12 +27,8 @@ #include "System.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -System::System(uInt16 n, uInt16 m) - : myAddressMask((1 << n) - 1), - myPageShift(m), - myPageMask((1 << m) - 1), - myNumberOfPages(1 << (n - m)), - myNumberOfDevices(0), +System::System() + : myNumberOfDevices(0), myM6502(0), myTIA(0), myCycles(0), @@ -40,19 +36,16 @@ System::System(uInt16 n, uInt16 m) myDataBusLocked(false), mySystemInAutodetect(false) { - // Make sure the arguments are reasonable - assert((1 <= m) && (m <= n) && (n <= 16)); - // Create a new random number generator myRandom = new Random(); // Allocate page table and dirty list - myPageAccessTable = new PageAccess[myNumberOfPages]; - myPageIsDirtyTable = new bool[myNumberOfPages]; + myPageAccessTable = new PageAccess[NUM_PAGES]; + myPageIsDirtyTable = new bool[NUM_PAGES]; // Initialize page access table PageAccess access(&myNullDevice, System::PA_READ); - for(int page = 0; page < myNumberOfPages; ++page) + for(int page = 0; page < NUM_PAGES; ++page) { setPageAccess(page, access); myPageIsDirtyTable[page] = false; @@ -159,7 +152,7 @@ void System::resetCycles() void System::setPageAccess(uInt16 page, const PageAccess& access) { // Make sure the page is within range - assert(page < myNumberOfPages); + assert(page < NUM_PAGES); // Make sure the access methods make sense assert(access.device != 0); @@ -171,7 +164,7 @@ void System::setPageAccess(uInt16 page, const PageAccess& access) const System::PageAccess& System::getPageAccess(uInt16 page) const { // Make sure the page is within range - assert(page < myNumberOfPages); + assert(page < NUM_PAGES); return myPageAccessTable[page]; } @@ -179,20 +172,20 @@ const System::PageAccess& System::getPageAccess(uInt16 page) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - System::PageAccessType System::getPageAccessType(uInt16 addr) const { - return myPageAccessTable[(addr & myAddressMask) >> myPageShift].type; + return myPageAccessTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT].type; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void System::setDirtyPage(uInt16 addr) { - myPageIsDirtyTable[(addr & myAddressMask) >> myPageShift] = true; + myPageIsDirtyTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT] = true; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool System::isPageDirty(uInt16 start_addr, uInt16 end_addr) const { - uInt16 start_page = (start_addr & myAddressMask) >> myPageShift; - uInt16 end_page = (end_addr & myAddressMask) >> myPageShift; + uInt16 start_page = (start_addr & ADDRESS_MASK) >> PAGE_SHIFT; + uInt16 end_page = (end_addr & ADDRESS_MASK) >> PAGE_SHIFT; for(uInt16 page = start_page; page <= end_page; ++page) if(myPageIsDirtyTable[page]) @@ -204,19 +197,19 @@ bool System::isPageDirty(uInt16 start_addr, uInt16 end_addr) const // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void System::clearDirtyPages() { - for(uInt32 i = 0; i < myNumberOfPages; ++i) + for(uInt32 i = 0; i < NUM_PAGES; ++i) myPageIsDirtyTable[i] = false; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt8 System::peek(uInt16 addr, uInt8 flags) { - PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift]; + PageAccess& access = myPageAccessTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT]; #ifdef DEBUGGER_SUPPORT // Set access type if(access.codeAccessBase) - *(access.codeAccessBase + (addr & myPageMask)) |= flags; + *(access.codeAccessBase + (addr & PAGE_MASK)) |= flags; else access.device->setAccessFlags(addr, flags); #endif @@ -224,7 +217,7 @@ uInt8 System::peek(uInt16 addr, uInt8 flags) // See if this page uses direct accessing or not uInt8 result; if(access.directPeekBase) - result = *(access.directPeekBase + (addr & myPageMask)); + result = *(access.directPeekBase + (addr & PAGE_MASK)); else result = access.device->peek(addr); @@ -239,14 +232,14 @@ uInt8 System::peek(uInt16 addr, uInt8 flags) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void System::poke(uInt16 addr, uInt8 value) { - uInt16 page = (addr & myAddressMask) >> myPageShift; + uInt16 page = (addr & ADDRESS_MASK) >> PAGE_SHIFT; PageAccess& access = myPageAccessTable[page]; // See if this page uses direct accessing or not if(access.directPokeBase) { // Since we have direct access to this poke, we can dirty its page - *(access.directPokeBase + (addr & myPageMask)) = value; + *(access.directPokeBase + (addr & PAGE_MASK)) = value; myPageIsDirtyTable[page] = true; } else @@ -265,10 +258,10 @@ void System::poke(uInt16 addr, uInt8 value) uInt8 System::getAccessFlags(uInt16 addr) const { #ifdef DEBUGGER_SUPPORT - PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift]; + PageAccess& access = myPageAccessTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT]; if(access.codeAccessBase) - return *(access.codeAccessBase + (addr & myPageMask)); + return *(access.codeAccessBase + (addr & PAGE_MASK)); else return access.device->getAccessFlags(addr); #else @@ -280,10 +273,10 @@ uInt8 System::getAccessFlags(uInt16 addr) const void System::setAccessFlags(uInt16 addr, uInt8 flags) { #ifdef DEBUGGER_SUPPORT - PageAccess& access = myPageAccessTable[(addr & myAddressMask) >> myPageShift]; + PageAccess& access = myPageAccessTable[(addr & ADDRESS_MASK) >> PAGE_SHIFT]; if(access.codeAccessBase) - *(access.codeAccessBase + (addr & myPageMask)) |= flags; + *(access.codeAccessBase + (addr & PAGE_MASK)) |= flags; else access.device->setAccessFlags(addr, flags); #endif @@ -346,10 +339,6 @@ bool System::load(Serializer& in) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - System::System(const System& s) - : myAddressMask(s.myAddressMask), - myPageShift(s.myPageShift), - myPageMask(s.myPageMask), - myNumberOfPages(s.myNumberOfPages) { assert(false); } diff --git a/src/emucore/System.hxx b/src/emucore/System.hxx index ca44afcb2..4f18cc59e 100644 --- a/src/emucore/System.hxx +++ b/src/emucore/System.hxx @@ -49,19 +49,28 @@ class System : public Serializable { public: /** - Create a new system with an addressing space of 2^n bytes and - pages of 2^m bytes. - - @param n Log base 2 of the addressing space size - @param m Log base 2 of the page size + Create a new system with an addressing space of 2^13 bytes and + pages of 2^6 bytes. */ - System(uInt16 n = 13, uInt16 m = 6); + System(); /** Destructor */ virtual ~System(); + // Mask to apply to an address before accessing memory + static const uInt16 ADDRESS_MASK = (1 << 13) - 1; + + // Amount to shift an address by to determine what page it's on + static const uInt16 PAGE_SHIFT = 6; + + // Mask to apply to an address to obtain its page offset + static const uInt16 PAGE_MASK = (1 << PAGE_SHIFT) - 1; + + // Number of pages in the system + static const uInt16 NUM_PAGES = 1 << (13 - PAGE_SHIFT); + public: /** Reset the system cycle counter, the attached devices, and the @@ -148,27 +157,6 @@ class System : public Serializable */ const NullDevice& nullDevice() const { return myNullDevice; } - /** - Get the total number of pages available in the system. - - @return The total number of pages available - */ - uInt16 numberOfPages() const { return myNumberOfPages; } - - /** - Get the amount to right shift an address by to obtain its page. - - @return The amount to right shift an address by to get its page - */ - uInt16 pageShift() const { return myPageShift; } - - /** - Get the mask to apply to an address to obtain its page offset. - - @return The mask to apply to an address to obtain its page offset - */ - uInt16 pageMask() const { return myPageMask; } - public: /** Get the number of system cycles which have passed since the last @@ -414,18 +402,6 @@ class System : public Serializable string name() const { return "System"; } private: - // Mask to apply to an address before accessing memory - const uInt16 myAddressMask; - - // Amount to shift an address by to determine what page it's on - const uInt16 myPageShift; - - // Mask to apply to an address to obtain its page offset - const uInt16 myPageMask; - - // Number of pages in the system - const uInt16 myNumberOfPages; - // Pointer to a dynamically allocated array of PageAccess structures PageAccess* myPageAccessTable; diff --git a/src/emucore/TIA.cxx b/src/emucore/TIA.cxx index a08d4f817..ed950fcd3 100644 --- a/src/emucore/TIA.cxx +++ b/src/emucore/TIA.cxx @@ -252,16 +252,15 @@ void TIA::install(System& system, Device& device) // Remember which system I'm installed in mySystem = &system; - uInt16 shift = mySystem->pageShift(); mySystem->resetCycles(); // All accesses are to the given device System::PageAccess access(&device, System::PA_READWRITE); // We're installing in a 2600 system - for(uInt32 i = 0; i < 8192; i += (1 << shift)) + for(uInt32 i = 0; i < 8192; i += (1 << System::PAGE_SHIFT)) if((i & 0x1080) == 0x0000) - mySystem->setPageAccess(i >> shift, access); + mySystem->setPageAccess(i >> System::PAGE_SHIFT, access); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -