aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPsyK0p4T <[email protected]>2023-02-05 02:27:19 +0100
committerGitHub <[email protected]>2023-02-05 02:27:19 +0100
commitc68234b9ee747e19a5d15f7bf8be5b5e9efef1e6 (patch)
treeaa7e7e7c2f637b96a387cd7fbcba11232530330f
parent5cefd8362cd5aa6ce600c3e1ec4f5eb41c94ff39 (diff)
downloadcartreader-c68234b9ee747e19a5d15f7bf8be5b5e9efef1e6.tar.gz
cartreader-c68234b9ee747e19a5d15f7bf8be5b5e9efef1e6.zip
Update MD.ino
- Modified Beggar Prince rev.1 detection method - Added Legend of Wukong support
-rw-r--r--Cart_Reader/MD.ino43
1 files changed, 26 insertions, 17 deletions
diff --git a/Cart_Reader/MD.ino b/Cart_Reader/MD.ino
index ae89b73..051dcba 100644
--- a/Cart_Reader/MD.ino
+++ b/Cart_Reader/MD.ino
@@ -687,16 +687,32 @@ void getCartInfo_MD() {
// Set control
dataIn_MD();
+ // Get cart size
cartSize = ((long(readWord_MD(0xD2)) << 16) | readWord_MD(0xD3)) + 1;
+ // Check for 32x compatibility
if ((readWord_MD(0x104 / 2) == 0x2033) && (readWord_MD(0x106 / 2) == 0x3258))
is32x = 1;
else
is32x = 0;
- // Cart Checksum
+ // Get cart checksum
chksum = readWord_MD(0xC7);
+ // Get cart ID
+ char id[15];
+ memset(id, 0, 15);
+ for (byte c = 0; c < 14; c += 2) {
+ // split word
+ word myWord = readWord_MD((0x180 + c) / 2);
+ byte loByte = myWord & 0xFF;
+ byte hiByte = myWord >> 8;
+
+ // write to buffer
+ id[c] = hiByte;
+ id[c + 1] = loByte;
+ }
+
// Zero Wing Check
if (cartSize == 0x80000) {
switch (chksum) {
@@ -733,27 +749,18 @@ void getCartInfo_MD() {
}
// Beggar Prince rev.1 Check
- if ((cartSize == 0x4ED02021) && (chksum == 0x3E08)) {
+ if (!strncmp("SF-001", id, 6) && (chksum == 0x3E08)) {
cartSize = 0x400000;
}
+ // Legend of Wukong Check
+ if (!strncmp("SF-002", id, 6) && (chksum == 0x12B0)) {
+ chksum = 0x45C6;
+ }
+
// Sonic & Knuckles Check
SnKmode = 0;
if (chksum == 0xDFB3) {
- char id[15];
- memset(id, 0, 15);
-
- // Get ID
- for (byte c = 0; c < 14; c += 2) {
- // split word
- word myWord = readWord_MD((0x180 + c) / 2);
- byte loByte = myWord & 0xFF;
- byte hiByte = myWord >> 8;
-
- // write to buffer
- id[c] = hiByte;
- id[c + 1] = loByte;
- }
//Sonic & Knuckles ID:GM MK-1563 -00
if (!strcmp("GM MK-1563 -00", id)) {
@@ -882,7 +889,9 @@ void getCartInfo_MD() {
sramEnd = 0x203fff;
}
// Check alignment of sram
- if ((sramBase == 0x200001) || (sramBase == 0x300001)) { // ADDED 0x300001 FOR HARDBALL '95 (U)
+ // 0x300001 for HARDBALL '95 (U)
+ // 0x3C0001 for Legend of Wukong (Aftermarket)
+ if ((sramBase == 0x200001) || (sramBase == 0x300001) || (sramBase == 0x3C0001)) {
// low byte
saveType = 1; // ODD
sramSize = (sramEnd - sramBase + 2) / 2;