diff options
author | sanni <[email protected]> | 2023-02-19 21:45:52 +0100 |
---|---|---|
committer | sanni <[email protected]> | 2023-02-19 21:45:52 +0100 |
commit | 782db58ab1e6a4028e09965c4d3267210f7d50c8 (patch) | |
tree | c289a51172c507b290306efa33d3e3e0d8a95311 | |
parent | b623b46e4cb63a38609bb6e3cbd0bc9a094ba894 (diff) | |
download | cartreader-782db58ab1e6a4028e09965c4d3267210f7d50c8.tar.gz cartreader-782db58ab1e6a4028e09965c4d3267210f7d50c8.zip |
Add fallback if ROM size in MD header is 0
-rw-r--r-- | Cart_Reader/MD.ino | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Cart_Reader/MD.ino b/Cart_Reader/MD.ino index 69b74d1..659555a 100644 --- a/Cart_Reader/MD.ino +++ b/Cart_Reader/MD.ino @@ -1091,6 +1091,17 @@ void getCartInfo_MD() { cartSize = 0x80000;
}
+ // Some games are missing the ROM size in the header, in this case calculate ROM size by looking for mirror of the first line of the ROM
+ // This does not work for cartridges that have SRAM mapped directly after the maskrom like Striker (Europe)
+ if ((cartSize < 0x8000) || (cartSize > 0xEAF400)) {
+ for (cartSize = 0x20000 / 2; cartSize < 0x400000 / 2; cartSize += 0x20000 / 2) {
+ if ((readWord_MD(0x0) == readWord_MD(cartSize)) && (readWord_MD(0x1) == readWord_MD(0x1 + cartSize)) && (readWord_MD(0x2) == readWord_MD(0x2 + cartSize)) && (readWord_MD(0x3) == readWord_MD(0x3 + cartSize)) && (readWord_MD(0x4) == readWord_MD(0x4 + cartSize)) && (readWord_MD(0x5) == readWord_MD(0x5 + cartSize)) && (readWord_MD(0x6) == readWord_MD(0x6 + cartSize)) && (readWord_MD(0x7) == readWord_MD(0x7 + cartSize)) && (readWord_MD(0x8) == readWord_MD(0x8 + cartSize))) {
+ break;
+ }
+ }
+ cartSize = cartSize * 2;
+ }
+
display_Clear();
println_Msg(F("Cart Info"));
println_Msg(F(" "));
@@ -1249,9 +1260,6 @@ void readROM_MD() { byte buffer[1024] = { 0 };
- // get current time
- // unsigned long startTime = millis();
-
// Phantasy Star/Beyond Oasis with 74HC74 and 74HC139 switch ROM/SRAM at address 0x200000
if (0x200000 < cartSize && cartSize < 0x400000) {
enableSram_MD(0);
@@ -1475,12 +1483,6 @@ void readROM_MD() { writeSSF2Map(0x50987F, 7); // 0xA130FF
}
- // print elapsed time
- //print_Msg(F("Time elapsed: "));
- //print_Msg((millis() - startTime) / 1000);
- //println_Msg(F("s"));
- //display_Update();
-
// Calculate internal checksum
print_Msg(F("Internal checksum..."));
display_Update();
|