Update MD.ino

- Moved code to retrieve the cart name earlier and possibly rely on it to identify a game instead of game ID + CRC
- Moved code to regroup the different game checks
- Some comments and conditions get reduced
This commit is contained in:
PsyK0p4T 2024-09-12 23:19:45 +02:00 committed by GitHub
parent d5252f2211
commit 1d2a016d3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -760,13 +760,26 @@ void getCartInfo_MD() {
id[c + 1] = loByte; id[c + 1] = loByte;
} }
// Get cart name
for (byte c = 0; c < 48; c += 2) {
// split word
word myWord = readWord_MD((0x150 + c) / 2);
byte loByte = myWord & 0xFF;
byte hiByte = myWord >> 8;
// write to buffer
sdBuffer[c] = hiByte;
sdBuffer[c + 1] = loByte;
}
romName[copyToRomName_MD(romName, sdBuffer, sizeof(romName) - 1)] = 0;
// Identify games using SVP chip // Identify games using SVP chip
if (!strncmp("GM MK-1229 ", id, 11) || !strncmp("GM G-7001 ", id, 11)) // Virtua Racing (E/U/J) if (!strncmp("GM MK-1229 ", id, 11) || !strncmp("GM G-7001 ", id, 11)) // Virtua Racing (E/U/J)
isSVP = 1; isSVP = 1;
else else
isSVP = 0; isSVP = 0;
// Fix cartridge sizes according to no-intro database // Fix cartridge sizes and checksums according to no-intro database
if (cartSize == 0x400000) { if (cartSize == 0x400000) {
switch (chksum) { switch (chksum) {
case 0xCE25: // Super Street Fighter 2 (J) 40Mbit case 0xCE25: // Super Street Fighter 2 (J) 40Mbit
@ -893,173 +906,159 @@ void getCartInfo_MD() {
} }
} }
// Fatman (Japan).md // Fatman (Japan)
if (!strncmp("GM T-44013 ", id, 11) && (chksum == 0xFFFF)) { if (!strncmp("GM T-44013 ", id, 11) && (chksum == 0xFFFF)) {
chksum = 0xC560; chksum = 0xC560;
cartSize = 0xA0000; cartSize = 0xA0000;
} }
// Slaughter Sport (USA)
if (!strncmp("GMT5604600jJ", romName, 12) && (chksum == 0xFFFF)) {
strcpy(romName, "SLAUGHTERSPORT");
chksum = 0x6BAE;
}
// Beggar Prince (Rev 1)(Aftermarket) // Fixes aftermarket cartridges
// Beggar Prince (Rev 1)
if (!strncmp("SF-001", id, 6) && (chksum == 0x3E08)) { if (!strncmp("SF-001", id, 6) && (chksum == 0x3E08)) {
cartSize = 0x400000; cartSize = 0x400000;
} }
// Legend of Wukong
// Legend of Wukong (Aftermarket)
if (!strncmp("SF-002", id, 6) && (chksum == 0x12B0)) { if (!strncmp("SF-002", id, 6) && (chksum == 0x12B0)) {
chksum = 0x45C6; chksum = 0x45C6;
} }
// YM2612 Instrument Editor
// YM2612 Instrument Editor (Aftermarket)
if (!strncmp("GM 10101010", id, 11) && (chksum == 0xC439)) { if (!strncmp("GM 10101010", id, 11) && (chksum == 0xC439)) {
chksum = 0x21B0; chksum = 0x21B0;
cartSize = 0x100000; cartSize = 0x100000;
} }
// Technoptimistic
// Technoptimistic (Aftermarket)
if (!strncmp("MU REMUTE01", id, 11) && (chksum == 0x0000)) { if (!strncmp("MU REMUTE01", id, 11) && (chksum == 0x0000)) {
chksum = 0xB55C; chksum = 0xB55C;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Decoder
// Decoder (Aftermarket)
if (!strncmp("GM REMUTE02", id, 11) && (chksum == 0x0000)) { if (!strncmp("GM REMUTE02", id, 11) && (chksum == 0x0000)) {
chksum = 0x5426; chksum = 0x5426;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Handy Harvy
// Handy Harvy (Aftermarket)
if (!strncmp("GM HHARVYSG", id, 11) && (chksum == 0x0000)) { if (!strncmp("GM HHARVYSG", id, 11) && (chksum == 0x0000)) {
chksum = 0xD9D2; chksum = 0xD9D2;
cartSize = 0x100000; cartSize = 0x100000;
} }
// Jim Power - The Lost Dimension in 3D
// Jim Power - The Lost Dimension in 3D (Aftermarket)
if (!strncmp("GM T-107036", id, 11) && (chksum == 0x0000)) { if (!strncmp("GM T-107036", id, 11) && (chksum == 0x0000)) {
chksum = 0xAA28; chksum = 0xAA28;
} }
// mikeyeldey95
// mikeyeldey95 (Aftermarket)
if (!strncmp("GM 00000000-43", id, 14) && (chksum == 0x0000)) { if (!strncmp("GM 00000000-43", id, 14) && (chksum == 0x0000)) {
chksum = 0x921B; chksum = 0x921B;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Enryuu Seiken Xiao-Mei
// Enryuu Seiken Xiao-Mei (Aftermarket)
if (!strncmp("GM 00000000-00", id, 14) && (chksum == 0x1E0C)) { if (!strncmp("GM 00000000-00", id, 14) && (chksum == 0x1E0C)) {
chksum = 0xE7E5; chksum = 0xE7E5;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Life on Earth - Reimagined
// Life on Earth - Reimagined (Aftermarket)
if (!strncmp("GM 00000000-00", id, 14) && (chksum == 0x6BD5)) { if (!strncmp("GM 00000000-00", id, 14) && (chksum == 0x6BD5)) {
chksum = 0x1FEA; chksum = 0x1FEA;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Sasha Darko's Sacred Line I
// Sasha Darko's Sacred Line I (Aftermarket)
if (!strncmp("GM 00000005-00", id, 14) && (chksum == 0x9F34)) { if (!strncmp("GM 00000005-00", id, 14) && (chksum == 0x9F34)) {
chksum = 0xA094; chksum = 0xA094;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Sasha Darko's Sacred Line II
// Sasha Darko's Sacred Line II (Aftermarket)
if (!strncmp("GM 00000005-00", id, 14) && (chksum == 0x0E9B)) { if (!strncmp("GM 00000005-00", id, 14) && (chksum == 0x0E9B)) {
chksum = 0x6B4B; chksum = 0x6B4B;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Sasha Darko's Sacred Line (Watermelon Release)
// Sasha Darko's Sacred Line (Watermelon Release) (Aftermarket)
if (!strncmp("GM T-574323-00", id, 14) && (chksum == 0xAEDD)) { if (!strncmp("GM T-574323-00", id, 14) && (chksum == 0xAEDD)) {
cartSize = 0x400000; cartSize = 0x400000;
} }
// Kromasphere
// Kromasphere (Aftermarket)
if (!strncmp("GM MK-0000 -00", id, 14) && (chksum == 0xC536)) { if (!strncmp("GM MK-0000 -00", id, 14) && (chksum == 0xC536)) {
chksum = 0xFAB1; chksum = 0xFAB1;
cartSize = 0x200000; cartSize = 0x200000;
} }
// YM2017
// YM2017 (Aftermarket)
if (!strncmp("GM CSET0001-02", id, 14) && (chksum == 0x0000)) { if (!strncmp("GM CSET0001-02", id, 14) && (chksum == 0x0000)) {
chksum = 0xE3A9; chksum = 0xE3A9;
} }
// The Curse of Illmore Bay
// The Curse of Illmore Bay (Aftermarket)
if (!strncmp("1774 ", id, 14) && (chksum == 0x0000)) { if (!strncmp("1774 ", id, 14) && (chksum == 0x0000)) {
chksum = 0x6E34; chksum = 0x6E34;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Coffee Crisis
// Coffee Crisis (Aftermarket)
if (!strncmp("JN-20160131-03", id, 14) && (chksum == 0x0000)) { if (!strncmp("JN-20160131-03", id, 14) && (chksum == 0x0000)) {
chksum = 0x8040; chksum = 0x8040;
cartSize = 0x400000; cartSize = 0x400000;
} }
// Romeow & Julicat
if (!strncmp("ROMEOWJULICAT", romName, 13) && (chksum == 0x0000)) {
chksum = 0xB094;
cartSize = 0x200000;
}
// Sonic & Knuckles Check // Sonic & Knuckles checks
SnKmode = 0; SnKmode = 0;
if (chksum == 0xDFB3) { if (!strcmp("GM MK-1563 -00", id) && (chksum == 0xDFB3)) {
char labelLockon[17];
memset(labelLockon, 0, 17);
//Sonic & Knuckles ID:GM MK-1563 -00 // Get labelLockon
if (!strcmp("GM MK-1563 -00", id)) { for (byte c = 0; c < 16; c += 2) {
char labelLockon[17]; // split word
memset(labelLockon, 0, 17); word myWord = readWord_MD((0x200100 + c) / 2);
byte loByte = myWord & 0xFF;
byte hiByte = myWord >> 8;
// Get labelLockon // write to buffer
for (byte c = 0; c < 16; c += 2) { labelLockon[c] = hiByte;
labelLockon[c + 1] = loByte;
}
// check Lock-on game presence
if (!(strcmp("SEGA MEGA DRIVE ", labelLockon) & strcmp("SEGA GENESIS ", labelLockon))) {
char idLockon[15];
memset(idLockon, 0, 15);
// Lock-on cart checksum
chksumLockon = readWord_MD(0x1000C7);
// Lock-on cart size
cartSizeLockon = ((long(readWord_MD(0x1000D2)) << 16) | readWord_MD(0x1000D3)) + 1;
// Get IdLockon
for (byte c = 0; c < 14; c += 2) {
// split word // split word
word myWord = readWord_MD((0x200100 + c) / 2); word myWord = readWord_MD((0x200180 + c) / 2);
byte loByte = myWord & 0xFF; byte loByte = myWord & 0xFF;
byte hiByte = myWord >> 8; byte hiByte = myWord >> 8;
// write to buffer // write to buffer
labelLockon[c] = hiByte; idLockon[c] = hiByte;
labelLockon[c + 1] = loByte; idLockon[c + 1] = loByte;
} }
// check Lock-on game presence if (!strncmp("GM 00001009-0", idLockon, 13) || !strncmp("GM 00004049-0", idLockon, 13)) { // Sonic1 ID:GM 00001009-0? or GM 00004049-0?
if (!(strcmp("SEGA MEGA DRIVE ", labelLockon) & strcmp("SEGA GENESIS ", labelLockon))) { SnKmode = 2;
char idLockon[15]; } else if (!strcmp("GM 00001051-00", idLockon) || !strcmp("GM 00001051-01", idLockon) || !strcmp("GM 00001051-02", idLockon)) { // Sonic2 ID:GM 00001051-00 or GM 00001051-01 or GM 00001051-02
memset(idLockon, 0, 15); SnKmode = 3;
// Prepare Sonic2 Banks
// Lock-on cart checksum writeSSF2Map(0x509878, 1); // 0xA130F1
chksumLockon = readWord_MD(0x1000C7); } else if (!strcmp("GM MK-1079 -00", idLockon)) { // Sonic3 ID:GM MK-1079 -00
// Lock-on cart size SnKmode = 4;
cartSizeLockon = ((long(readWord_MD(0x1000D2)) << 16) | readWord_MD(0x1000D3)) + 1; } else { // Other game
SnKmode = 5;
// Get IdLockon
for (byte c = 0; c < 14; c += 2) {
// split word
word myWord = readWord_MD((0x200180 + c) / 2);
byte loByte = myWord & 0xFF;
byte hiByte = myWord >> 8;
// write to buffer
idLockon[c] = hiByte;
idLockon[c + 1] = loByte;
}
if (!strncmp("GM 00001009-0", idLockon, 13) || !strncmp("GM 00004049-0", idLockon, 13)) {
//Sonic1 ID:GM 00001009-0? or GM 00004049-0?
SnKmode = 2;
} else if (!strcmp("GM 00001051-00", idLockon) || !strcmp("GM 00001051-01", idLockon) || !strcmp("GM 00001051-02", idLockon)) {
//Sonic2 ID:GM 00001051-00 or GM 00001051-01 or GM 00001051-02
SnKmode = 3;
// Prepare Sonic2 Banks
writeSSF2Map(0x509878, 1); // 0xA130F1
} else if (!strcmp("GM MK-1079 -00", idLockon)) {
//Sonic3 ID:GM MK-1079 -00
SnKmode = 4;
} else {
//Other game
SnKmode = 5;
}
} else {
SnKmode = 1;
} }
} else {
SnKmode = 1;
} }
} }
@ -1234,25 +1233,6 @@ void getCartInfo_MD() {
} }
} }
// Get name
for (byte c = 0; c < 48; c += 2) {
// split word
word myWord = readWord_MD((0x150 + c) / 2);
byte loByte = myWord & 0xFF;
byte hiByte = myWord >> 8;
// write to buffer
sdBuffer[c] = hiByte;
sdBuffer[c + 1] = loByte;
}
romName[copyToRomName_MD(romName, sdBuffer, sizeof(romName) - 1)] = 0;
//Check for Slaughter Sport
if (!strncmp("GMT5604600jJ", romName, 12) && (chksum == 0xFFFF)) {
strcpy(romName, "SLAUGHTERSPORT");
chksum = 0x6BAE;
}
//Get Lock-on cart name //Get Lock-on cart name
if (SnKmode >= 2) { if (SnKmode >= 2) {
char romNameLockon[12]; char romNameLockon[12];
@ -3015,4 +2995,4 @@ void force_cartSize_MD() {
//****************************************** //******************************************
// End of File // End of File
//****************************************** //******************************************