Speed up accesses to System by using constants. It's fine to make

a class more generic, but when it's never used, all it does it slow
things down.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3016 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-10-26 00:40:27 +00:00
parent ba926bc4f6
commit 1a09d37d1b
41 changed files with 319 additions and 587 deletions

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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);
}
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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.

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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);
}
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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);
}
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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);
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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);
}
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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)

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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

View File

@ -17,7 +17,6 @@
// $Id: CartSB.cxx,v 1.0 2007/10/11
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -17,7 +17,6 @@
// $Id$
//============================================================================
#include <cassert>
#include <cstring>
#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;
}

View File

@ -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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -