Improved 3E auto detection

This commit is contained in:
thrust26 2020-04-20 20:46:28 +02:00
parent 9981b256c7
commit abeac8877e
1 changed files with 10 additions and 5 deletions

View File

@ -620,11 +620,16 @@ bool CartDetector::isProbably0840(const ByteBuffer& image, size_t size)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDetector::isProbably3E(const ByteBuffer& image, size_t size)
{
// 3E cart bankswitching is triggered by storing the bank number
// in address 3E using 'STA $3E', commonly followed by an
// immediate mode LDA
uInt8 signature[] = { 0x85, 0x3E, 0xA9, 0x00 }; // STA $3E; LDA #$00
return searchForBytes(image.get(), size, signature, 4, 1);
// 3E cart RAM bankswitching is triggered by storing the bank number
// in address 3E using 'STA $3E', ROM bankswitching is triggered by
// storing the bank number in address 3F using 'STA $3F'.
// We expect the latter will be present at least 2 times, since there
// are at least two banks
uInt8 signature1[] = { 0x85, 0x3E }; // STA $3E
uInt8 signature2[] = { 0x85, 0x3F }; // STA $3F
return searchForBytes(image.get(), size, signature1, 2, 1)
&& searchForBytes(image.get(), size, signature2, 2, 2);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -