mirror of https://github.com/stella-emu/stella.git
Made the SUPERbank bankswitching code a little easier to follow, and
fixed a bug in the startup bank. According to the documentation, it should always start in the last bank. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1410 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
6baa7c8311
commit
897e05d58a
|
@ -23,17 +23,16 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
CartridgeSB::CartridgeSB(const uInt8* image, uInt32 size)
|
CartridgeSB::CartridgeSB(const uInt8* image, uInt32 size)
|
||||||
: mySize(size)
|
: mySize(size),
|
||||||
|
myLastBank((mySize>>12)-1)
|
||||||
{
|
{
|
||||||
// Allocate array for the ROM image
|
// Allocate array for the ROM image
|
||||||
myImage = new uInt8[mySize];
|
myImage = new uInt8[mySize];
|
||||||
|
|
||||||
// Copy the ROM image into my buffer
|
// Copy the ROM image into my buffer
|
||||||
for(uInt32 addr = 0; addr < mySize; ++addr)
|
for(uInt32 addr = 0; addr < mySize; ++addr)
|
||||||
{
|
|
||||||
myImage[addr] = image[addr];
|
myImage[addr] = image[addr];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
CartridgeSB::~CartridgeSB()
|
CartridgeSB::~CartridgeSB()
|
||||||
|
@ -44,8 +43,8 @@ CartridgeSB::~CartridgeSB()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void CartridgeSB::reset()
|
void CartridgeSB::reset()
|
||||||
{
|
{
|
||||||
// Upon reset we switch to bank 0
|
// Upon reset we switch to the last bank
|
||||||
bank(0);
|
bank(myLastBank);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -60,19 +59,17 @@ void CartridgeSB::install(System& system)
|
||||||
|
|
||||||
// Get the page accessing methods for the hot spots since they overlap
|
// 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
|
// areas within the TIA we'll need to forward requests to the TIA
|
||||||
|
myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0800 >> shift);
|
||||||
myHotSpotPageAccess0 = mySystem->getPageAccess(0x0800 >> shift);
|
myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0900 >> shift);
|
||||||
myHotSpotPageAccess1 = mySystem->getPageAccess(0x0900 >> shift);
|
myHotSpotPageAccess[2] = mySystem->getPageAccess(0x0A00 >> shift);
|
||||||
myHotSpotPageAccess2 = mySystem->getPageAccess(0x0A00 >> shift);
|
myHotSpotPageAccess[3] = mySystem->getPageAccess(0x0B00 >> shift);
|
||||||
myHotSpotPageAccess3 = mySystem->getPageAccess(0x0B00 >> shift);
|
myHotSpotPageAccess[4] = mySystem->getPageAccess(0x0C00 >> shift);
|
||||||
myHotSpotPageAccess4 = mySystem->getPageAccess(0x0C00 >> shift);
|
myHotSpotPageAccess[5] = mySystem->getPageAccess(0x0D00 >> shift);
|
||||||
myHotSpotPageAccess5 = mySystem->getPageAccess(0x0D00 >> shift);
|
myHotSpotPageAccess[6] = mySystem->getPageAccess(0x0E00 >> shift);
|
||||||
myHotSpotPageAccess6 = mySystem->getPageAccess(0x0E00 >> shift);
|
myHotSpotPageAccess[7] = mySystem->getPageAccess(0x0F00 >> shift);
|
||||||
myHotSpotPageAccess7 = mySystem->getPageAccess(0x0F00 >> shift);
|
|
||||||
|
|
||||||
// Set the page accessing methods for the hot spots
|
// Set the page accessing methods for the hot spots
|
||||||
System::PageAccess access;
|
System::PageAccess access;
|
||||||
|
|
||||||
for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift))
|
for(uInt32 i = 0x0800; i < 0x0FFF; i += (1 << shift))
|
||||||
{
|
{
|
||||||
access.directPeekBase = 0;
|
access.directPeekBase = 0;
|
||||||
|
@ -81,48 +78,25 @@ void CartridgeSB::install(System& system)
|
||||||
mySystem->setPageAccess(i >> shift, access);
|
mySystem->setPageAccess(i >> shift, access);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Install pages for bank 0
|
// Install pages for startup bank
|
||||||
bank(0);
|
bank(myLastBank);
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
uInt8 CartridgeSB::peek(uInt16 address)
|
uInt8 CartridgeSB::peek(uInt16 address)
|
||||||
{
|
{
|
||||||
address = address & (0x17FF+(mySize>>12));
|
address = address & (0x17FF+(mySize>>12));
|
||||||
|
|
||||||
// Switch banks if necessary
|
// Switch banks if necessary
|
||||||
if ((address & 0x1800) == 0x0800) bank(address & ((mySize>>12)-1));
|
if ((address & 0x1800) == 0x0800)
|
||||||
|
bank(address & myLastBank);
|
||||||
|
|
||||||
if(!(address & 0x1000))
|
if(!(address & 0x1000))
|
||||||
{
|
{
|
||||||
switch (address & 0x0F00)
|
// Because of the way we've set up accessing above, we can only
|
||||||
{
|
// get here when the addresses are from 0x800 - 0xFFF
|
||||||
case 0x0800:
|
int hotspot = ((address & 0x0F00) >> 8) - 8;
|
||||||
return myHotSpotPageAccess0.device->peek(address);
|
return myHotSpotPageAccess[hotspot].device->peek(address);
|
||||||
break;
|
|
||||||
case 0x0900:
|
|
||||||
return myHotSpotPageAccess1.device->peek(address);
|
|
||||||
break;
|
|
||||||
case 0x0A00:
|
|
||||||
return myHotSpotPageAccess2.device->peek(address);
|
|
||||||
break;
|
|
||||||
case 0x0B00:
|
|
||||||
return myHotSpotPageAccess3.device->peek(address);
|
|
||||||
break;
|
|
||||||
case 0x0C00:
|
|
||||||
return myHotSpotPageAccess4.device->peek(address);
|
|
||||||
break;
|
|
||||||
case 0x0D00:
|
|
||||||
return myHotSpotPageAccess5.device->peek(address);
|
|
||||||
break;
|
|
||||||
case 0x0E00:
|
|
||||||
return myHotSpotPageAccess6.device->peek(address);
|
|
||||||
break;
|
|
||||||
case 0x0F00:
|
|
||||||
return myHotSpotPageAccess7.device->peek(address);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -132,41 +106,17 @@ uInt8 CartridgeSB::peek(uInt16 address)
|
||||||
void CartridgeSB::poke(uInt16 address, uInt8 value)
|
void CartridgeSB::poke(uInt16 address, uInt8 value)
|
||||||
{
|
{
|
||||||
address = address & (0x17FF+(mySize>>12));
|
address = address & (0x17FF+(mySize>>12));
|
||||||
|
|
||||||
// Switch banks if necessary
|
// Switch banks if necessary
|
||||||
if ((address & 0x1800) == 0x0800) bank(address & ((mySize>>12)-1));
|
if((address & 0x1800) == 0x0800)
|
||||||
|
bank(address & myLastBank);
|
||||||
|
|
||||||
if(!(address & 0x1000))
|
if(!(address & 0x1000))
|
||||||
{
|
{
|
||||||
|
// Because of the way we've set up accessing above, we can only
|
||||||
switch (address & 0x0F00)
|
// get here when the addresses are from 0x800 - 0xFFF
|
||||||
{
|
int hotspot = ((address & 0x0F00) >> 8) - 8;
|
||||||
case 0x0800:
|
myHotSpotPageAccess[hotspot].device->poke(address, value);
|
||||||
return myHotSpotPageAccess0.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0900:
|
|
||||||
return myHotSpotPageAccess1.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0A00:
|
|
||||||
return myHotSpotPageAccess2.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0B00:
|
|
||||||
return myHotSpotPageAccess3.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0C00:
|
|
||||||
return myHotSpotPageAccess4.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0D00:
|
|
||||||
return myHotSpotPageAccess5.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0E00:
|
|
||||||
return myHotSpotPageAccess6.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
case 0x0F00:
|
|
||||||
return myHotSpotPageAccess7.device->poke(address, value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +129,6 @@ void CartridgeSB::bank(uInt16 bank)
|
||||||
myCurrentBank = bank;
|
myCurrentBank = bank;
|
||||||
uInt32 offset = myCurrentBank * 4096;
|
uInt32 offset = myCurrentBank * 4096;
|
||||||
uInt16 shift = mySystem->pageShift();
|
uInt16 shift = mySystem->pageShift();
|
||||||
// uInt16 mask = mySystem->pageMask();
|
|
||||||
|
|
||||||
// Setup the page access methods for the current bank
|
// Setup the page access methods for the current bank
|
||||||
System::PageAccess access;
|
System::PageAccess access;
|
||||||
|
|
|
@ -135,22 +135,18 @@ class CartridgeSB : public Cartridge
|
||||||
virtual void poke(uInt16 address, uInt8 value);
|
virtual void poke(uInt16 address, uInt8 value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Indicates which bank is currently active
|
|
||||||
uInt16 myCurrentBank;
|
|
||||||
|
|
||||||
// The 128-256K ROM image and size of the cartridge
|
// The 128-256K ROM image and size of the cartridge
|
||||||
uInt8* myImage;
|
uInt8* myImage;
|
||||||
uInt32 mySize;
|
uInt32 mySize;
|
||||||
|
|
||||||
|
// Indicates which bank is currently active
|
||||||
|
uInt16 myCurrentBank;
|
||||||
|
|
||||||
|
// Indicates the last bank
|
||||||
|
uInt16 myLastBank;
|
||||||
|
|
||||||
// Previous Device's page access
|
// Previous Device's page access
|
||||||
System::PageAccess myHotSpotPageAccess0;
|
System::PageAccess myHotSpotPageAccess[8];
|
||||||
System::PageAccess myHotSpotPageAccess1;
|
|
||||||
System::PageAccess myHotSpotPageAccess2;
|
|
||||||
System::PageAccess myHotSpotPageAccess3;
|
|
||||||
System::PageAccess myHotSpotPageAccess4;
|
|
||||||
System::PageAccess myHotSpotPageAccess5;
|
|
||||||
System::PageAccess myHotSpotPageAccess6;
|
|
||||||
System::PageAccess myHotSpotPageAccess7;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue