adapted UA bankswitching to new Brazilian carts (except Mickey)

This commit is contained in:
Thomas Jentzsch 2019-07-28 09:58:38 +02:00
parent 78cce1e50b
commit bd39c0836f
4 changed files with 28 additions and 16 deletions

View File

@ -39,17 +39,17 @@ CartridgeUAWidget::CartridgeUAWidget(
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $" << spot << ")\n";
<< "$" << (start + 0xFFF) << " (hotspots = $" << spot << ", $" << (spot | 0x80) << ")\n";
}
int xpos = 10,
ypos = addBaseInformation(size, "UA Limited", info.str()) + myLineHeight;
VariantList items;
VarList::push_back(items, "0 ($220)");
VarList::push_back(items, "1 ($240)");
VarList::push_back(items, "0 ($220, $2A0)");
VarList::push_back(items, "1 ($240, $2C0)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFx) "),
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFx, $FFx)"),
myLineHeight, items, "Set bank ",
_font.getStringWidth("Set bank "), kBankChanged);
myBank->setTarget(this);
@ -87,9 +87,9 @@ string CartridgeUAWidget::bankState()
{
ostringstream& buf = buffer();
static const char* const spot[] = { "$220", "$240" };
static const char* const spot[] = { "$220, $2A0", "$240, $2C0" };
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
<< ", hotspots = " << spot[myCart.getBank()];
return buf.str();
}

View File

@ -966,12 +966,17 @@ bool CartDetector::isProbablyUA(const ByteBuffer& image, uInt32 size)
{
// UA cart bankswitching switches to bank 1 by accessing address 0x240
// using 'STA $240' or 'LDA $240'
uInt8 signature[3][3] = {
// Similar Brazilian cart bankswitching switches to bank 1 by accessing address 0x2C0
// using 'BIT $2C0', 'STA $2C0' or 'LDA $2C0'
uInt8 signature[6][3] = {
{ 0x8D, 0x40, 0x02 }, // STA $240
{ 0xAD, 0x40, 0x02 }, // LDA $240
{ 0xBD, 0x1F, 0x02 } // LDA $21F,X
{ 0xBD, 0x1F, 0x02 }, // LDA $21F,X
{ 0x2C, 0xC0, 0x02 }, // BIT $2C0
{ 0x8D, 0xC0, 0x02 }, // STA $2C0
{ 0xAD, 0xC0, 0x02 } // LDA $2C0
};
for(uInt32 i = 0; i < 3; ++i)
for(uInt32 i = 0; i < 6; ++i)
if(searchForBytes(image.get(), size, signature[i], 3, 1))
return true;

View File

@ -44,12 +44,15 @@ void CartridgeUA::install(System& system)
// 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);
myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0220);
myHotSpotPageAccess[1] = mySystem->getPageAccess(0x0220 | 0x80);
// Set the page accessing methods for the hot spots
System::PageAccess access(this, System::PageAccessType::READ);
mySystem->setPageAccess(0x0220, access);
mySystem->setPageAccess(0x0240, access);
mySystem->setPageAccess(0x0220 | 0x80, access);
mySystem->setPageAccess(0x0240 | 0x80, access);
// Install pages for the startup bank
bank(startBank());
@ -61,7 +64,7 @@ uInt8 CartridgeUA::peek(uInt16 address)
address &= 0x1FFF;
// Switch banks if necessary
switch(address)
switch(address & 0x1260)
{
case 0x0220:
// Set the current bank to the lower 4k bank
@ -79,7 +82,8 @@ uInt8 CartridgeUA::peek(uInt16 address)
// Because of the way accessing is set up, we will only get here
// when doing a TIA read
return myHotSpotPageAccess.device->peek(address);
int hotspot = ((address & 0x80) >> 7);
return myHotSpotPageAccess[hotspot].device->peek(address);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -88,7 +92,7 @@ bool CartridgeUA::poke(uInt16 address, uInt8 value)
address &= 0x1FFF;
// Switch banks if necessary
switch(address)
switch(address & 0x1260)
{
case 0x0220:
// Set the current bank to the lower 4k bank
@ -106,8 +110,11 @@ bool CartridgeUA::poke(uInt16 address, uInt8 value)
// Because of the way accessing is set up, we will may get here by
// doing a write to TIA or cart; we ignore the cart write
if(!(address & 0x1000))
myHotSpotPageAccess.device->poke(address, value);
if (!(address & 0x1000))
{
int hotspot = ((address & 0x80) >> 7);
myHotSpotPageAccess[hotspot].device->poke(address, value);
}
return false;
}

View File

@ -154,7 +154,7 @@ class CartridgeUA : public Cartridge
uInt8 myImage[8192];
// Previous Device's page access
System::PageAccess myHotSpotPageAccess;
System::PageAccess myHotSpotPageAccess[2];
// Indicates the offset into the ROM image (aligns to current bank)
uInt16 myBankOffset;