mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-27 23:14:14 +01:00
V4.9: Improve WS Initialization
Thanks to skaman. The code does a deeper sanity check of the header data when initializing the cart. It avoids having to constantly press buttons to reinit the cart. Carts can still not initialize the MBC properly but that's normal for the WonderSwan. Clean the pins on the cart and check that the cart and adapter are seated properly. If the cart doesn't unlock immediately, then let the sketch run for a bit. For stubborn carts, a power cycle might be necessary. The sketch fixes a few typos, removes some trailing spaces, and adds another ROM size (used by Benesse Pocket Challenge V2 carts).
This commit is contained in:
parent
7b263115a5
commit
cfb9e39cbf
@ -2,8 +2,8 @@
|
|||||||
Cartridge Reader for Arduino Mega2560
|
Cartridge Reader for Arduino Mega2560
|
||||||
|
|
||||||
Author: sanni
|
Author: sanni
|
||||||
Date: 12.04.2020
|
Date: 20.04.2020
|
||||||
Version: 4.8
|
Version: 4.9
|
||||||
|
|
||||||
SD lib: https://github.com/greiman/SdFat
|
SD lib: https://github.com/greiman/SdFat
|
||||||
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
LCD lib: https://github.com/adafruit/Adafruit_SSD1306
|
||||||
@ -16,7 +16,7 @@
|
|||||||
MichlK - ROM-Reader for Super Nintendo
|
MichlK - ROM-Reader for Super Nintendo
|
||||||
Jeff Saltzman - 4-Way Button
|
Jeff Saltzman - 4-Way Button
|
||||||
Wayne and Layne - Video-Game-Shield menu
|
Wayne and Layne - Video-Game-Shield menu
|
||||||
skaman - SNES enhancements, SA1/BSX sram support, GB flash fix, MD improvements, Famicom dumper
|
skaman - SNES enhancements, SA1/BSX sram support, GB flash fix, MD improvements, Famicom dumper, WS improvements
|
||||||
nocash - Nintendo Power and GBA Eeprom commands and lots of other info
|
nocash - Nintendo Power and GBA Eeprom commands and lots of other info
|
||||||
crazynation - N64 bus timing
|
crazynation - N64 bus timing
|
||||||
hkz/themanbehindthecurtain - N64 flashram commands
|
hkz/themanbehindthecurtain - N64 flashram commands
|
||||||
@ -43,7 +43,7 @@
|
|||||||
**********************************************************************************/
|
**********************************************************************************/
|
||||||
#include <SdFat.h>
|
#include <SdFat.h>
|
||||||
|
|
||||||
char ver[5] = "4.8";
|
char ver[5] = "4.9";
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Options
|
Options
|
||||||
|
@ -72,16 +72,50 @@ void setup_WS()
|
|||||||
display_Clear();
|
display_Clear();
|
||||||
|
|
||||||
// unlock MMC
|
// unlock MMC
|
||||||
if (!unlockMMC2003_WS())
|
// if (!unlockMMC2003_WS())
|
||||||
print_Error(F("Can't initial MMC"), true);
|
// print_Error(F("Can't initial MMC"), true);
|
||||||
|
|
||||||
if (getCartInfo_WS() != 0xea)
|
// if (getCartInfo_WS() != 0xea)
|
||||||
print_Error(F("Rom header read error"), true);
|
// print_Error(F("Rom header read error"), true);
|
||||||
|
|
||||||
|
display.println("Initializing...");
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
do {
|
||||||
|
unlockMMC2003_WS();
|
||||||
|
}
|
||||||
|
while (!headerCheck());
|
||||||
|
|
||||||
|
getCartInfo_WS();
|
||||||
|
|
||||||
showCartInfo_WS();
|
showCartInfo_WS();
|
||||||
mode = mode_WS;
|
mode = mode_WS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean headerCheck() {
|
||||||
|
dataIn_WS();
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < 16; i += 2)
|
||||||
|
* ((uint16_t*)(sdBuffer + i)) = readWord_WS(0xffff0 + i);
|
||||||
|
|
||||||
|
uint8_t startByte = sdBuffer[0];
|
||||||
|
if (startByte == 0xEA) { // Start should be 0xEA
|
||||||
|
uint8_t zeroByte = sdBuffer[5];
|
||||||
|
if (zeroByte == 0) { // Zero Byte
|
||||||
|
uint8_t systemByte = sdBuffer[7];
|
||||||
|
if (systemByte < 2) { // System < 2
|
||||||
|
uint8_t revisionByte = sdBuffer[9];
|
||||||
|
if ((revisionByte < 7) || (revisionByte == 0x80)) { // Known Revisions: 0 to 6 and 0x80
|
||||||
|
uint8_t sizeByte = sdBuffer[10];
|
||||||
|
if (sizeByte < 10) // Rom Size < 10
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void wsMenu()
|
void wsMenu()
|
||||||
{
|
{
|
||||||
uint8_t mainMenu = (wsWitch ? 5 : 4);
|
uint8_t mainMenu = (wsWitch ? 5 : 4);
|
||||||
@ -109,7 +143,7 @@ void wsMenu()
|
|||||||
case 0: println_Msg(F("No save for this game")); break;
|
case 0: println_Msg(F("No save for this game")); break;
|
||||||
case 1: readSRAM_WS(); break;
|
case 1: readSRAM_WS(); break;
|
||||||
case 2: readEEPROM_WS(); break;
|
case 2: readEEPROM_WS(); break;
|
||||||
default: println_Msg(F("Unknow save type")); break;
|
default: println_Msg(F("Unknown save type")); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -133,7 +167,7 @@ void wsMenu()
|
|||||||
verifyEEPROM_WS();
|
verifyEEPROM_WS();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: println_Msg(F("Unknow save type")); break;
|
default: println_Msg(F("Unknown save type")); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -162,8 +196,8 @@ uint8_t getCartInfo_WS()
|
|||||||
{
|
{
|
||||||
dataIn_WS();
|
dataIn_WS();
|
||||||
|
|
||||||
for (uint32_t i = 0; i < 16; i += 2)
|
// for (uint32_t i = 0; i < 16; i += 2)
|
||||||
* ((uint16_t*)(sdBuffer + i)) = readWord_WS(0xffff0 + i);
|
// *((uint16_t*)(sdBuffer + i)) = readWord_WS(0xffff0 + i);
|
||||||
|
|
||||||
wsGameChecksum = *(uint16_t*)(sdBuffer + 14);
|
wsGameChecksum = *(uint16_t*)(sdBuffer + 14);
|
||||||
wsWitch = false;
|
wsWitch = false;
|
||||||
@ -299,6 +333,7 @@ uint8_t getCartInfo_WS()
|
|||||||
case 0x02: saveType = 1; sramSize = 256; break;
|
case 0x02: saveType = 1; sramSize = 256; break;
|
||||||
case 0x03: saveType = 1; sramSize = 1024; break;
|
case 0x03: saveType = 1; sramSize = 1024; break;
|
||||||
case 0x04: saveType = 1; sramSize = 2048; break;
|
case 0x04: saveType = 1; sramSize = 2048; break;
|
||||||
|
case 0x05: saveType = 1; sramSize = 4096; break;
|
||||||
case 0x10: saveType = 2; sramSize = 1; break;
|
case 0x10: saveType = 2; sramSize = 1; break;
|
||||||
case 0x20: saveType = 2; sramSize = 16; break;
|
case 0x20: saveType = 2; sramSize = 16; break;
|
||||||
case 0x50: saveType = 2; sramSize = 8; break;
|
case 0x50: saveType = 2; sramSize = 8; break;
|
||||||
@ -339,7 +374,7 @@ void showCartInfo_WS()
|
|||||||
default: println_Msg(sramSize, HEX); break;
|
default: println_Msg(sramSize, HEX); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_Msg(F("Vesion: 1."));
|
print_Msg(F("Version: 1."));
|
||||||
println_Msg(romVersion, HEX);
|
println_Msg(romVersion, HEX);
|
||||||
|
|
||||||
print_Msg(F("Checksum: "));
|
print_Msg(F("Checksum: "));
|
||||||
|
Loading…
Reference in New Issue
Block a user