small improvement on FC bankswitching

This commit is contained in:
thrust26 2019-12-18 19:12:04 +01:00
parent dbfc6ef3a5
commit 7ae5b49633
2 changed files with 11 additions and 5 deletions

View File

@ -946,12 +946,12 @@ bool CartDetector::isProbablyFA2(const ByteBuffer& image, size_t)
bool CartDetector::isProbablyFC(const ByteBuffer& image, size_t size) bool CartDetector::isProbablyFC(const ByteBuffer& image, size_t size)
{ {
// FC bankswitching uses consecutive writes to 3 hotspots // FC bankswitching uses consecutive writes to 3 hotspots
uInt8 signature[2][6] = { uInt8 signature[3][6] = {
{ 0x8d, 0xf8, 0x1f, 0x4a, 0x4a, 0x8d }, // STA $1FF8, LSR, LSR, STA... Power Play Arcade Menus, 3-D Ghost Attack { 0x8d, 0xf8, 0x1f, 0x4a, 0x4a, 0x8d }, // STA $1FF8, LSR, LSR, STA... Power Play Arcade Menus, 3-D Ghost Attack
{ 0x8d, 0xf8, 0xff, 0x8d, 0xfc, 0xff }, // STA $FFF8, STA $FFFC Surf's Up (4K) { 0x8d, 0xf8, 0xff, 0x8d, 0xfc, 0xff }, // STA $FFF8, STA $FFFC Surf's Up (4K)
//{ 0x8c, 0xf9, 0xff, 0xad, 0xfc, 0xff } // STY $FFF9, LDA $FFFC 3-D Havoc (patched for F8, ignore!) { 0x8c, 0xf9, 0xff, 0xad, 0xfc, 0xff } // STY $FFF9, LDA $FFFC 3-D Havoc
}; };
for (uInt32 i = 0; i < 2; ++i) for (uInt32 i = 0; i < 3; ++i)
if (searchForBytes(image.get(), size, signature[i], 6, 1)) if (searchForBytes(image.get(), size, signature[i], 6, 1))
return true; return true;

View File

@ -86,8 +86,14 @@ bool CartridgeFC::poke(uInt16 address, uInt8 value)
case 0x0FF9: case 0x0FF9:
// Set the high bits of target 4k bank // Set the high bits of target 4k bank
myTargetBank += value << 2; if (value << 2 < bankCount())
myTargetBank %= bankCount(); {
myTargetBank += value << 2;
myTargetBank %= bankCount();
}
else
// special handling when both values are identical (e.g. 4/4 or 5/5)
myTargetBank = value % bankCount();
break; break;
case 0x0FFC: case 0x0FFC: