mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-24 03:51:54 +01:00
commit
7fef6d45b6
@ -9,10 +9,10 @@ static const char ngpMenuItem1[] PROGMEM = "Read Rom";
|
||||
static const char ngpMenuItemReset[] PROGMEM = "Reset";
|
||||
static const char* const menuOptionsNGP[] PROGMEM = {ngpMenuItem1, ngpMenuItemReset};
|
||||
|
||||
static const char ngpRomItem1[] PROGMEM = "4 Mbits";
|
||||
static const char ngpRomItem2[] PROGMEM = "8 Mbits";
|
||||
static const char ngpRomItem3[] PROGMEM = "16 Mbits";
|
||||
static const char ngpRomItem4[] PROGMEM = "32 Mbits";
|
||||
static const char ngpRomItem1[] PROGMEM = "4 Mbits / 512 KB";
|
||||
static const char ngpRomItem2[] PROGMEM = "8 Mbits / 1 MB";
|
||||
static const char ngpRomItem3[] PROGMEM = "16 Mbits / 2 MB";
|
||||
static const char ngpRomItem4[] PROGMEM = "32 Mbits / 4 MB";
|
||||
static const char* const ngpRomOptions[] PROGMEM = {ngpRomItem1, ngpRomItem2, ngpRomItem3, ngpRomItem4};
|
||||
|
||||
char ngpRomVersion[3];
|
||||
@ -42,18 +42,13 @@ void setup_NGP() {
|
||||
|
||||
PORTH |= ((1 << 0) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6));
|
||||
|
||||
println_Msg(F("Initializing..."));
|
||||
display_Update();
|
||||
|
||||
if (getCartInfo_NGP())
|
||||
printCartInfo_NGP();
|
||||
else {
|
||||
println_Msg(F("NeoGeo Pocket"));
|
||||
println_Msg(F(""));
|
||||
println_Msg(F(""));
|
||||
println_Msg(F("Cartridge read error"));
|
||||
println_Msg(F(""));
|
||||
println_Msg(F("Press Button..."));
|
||||
display_Update();
|
||||
wait();
|
||||
}
|
||||
else
|
||||
print_Error(F("Cartridge read error"), true);
|
||||
}
|
||||
|
||||
void ngpMenu() {
|
||||
@ -99,49 +94,23 @@ bool getCartInfo_NGP() {
|
||||
*(tmp + 0) = deviceID;
|
||||
*(tmp + 1) = manufacturerID;
|
||||
|
||||
// select rom size depending of the chip IDs
|
||||
switch (romSize) {
|
||||
// detection error
|
||||
case 0xffff:
|
||||
return false;
|
||||
break;
|
||||
|
||||
// 4 Mbits
|
||||
case 0x98ab:
|
||||
cartSize = 524288;
|
||||
break;
|
||||
// Toshiba ?
|
||||
case 0x204c:
|
||||
cartSize = 524288;
|
||||
break;
|
||||
|
||||
// 8 Mbits
|
||||
// Toshiba
|
||||
case 0x982c:
|
||||
cartSize = 1048576;
|
||||
break;
|
||||
// Samsung
|
||||
case 0xec2c:
|
||||
cartSize = 1048576;
|
||||
break;
|
||||
|
||||
// 16 Mbits
|
||||
// Toshiba
|
||||
case 0x982f:
|
||||
cartSize = 2097152;
|
||||
break;
|
||||
// Samsung
|
||||
case 0xec2f:
|
||||
cartSize = 2097152;
|
||||
break;
|
||||
case 0x98ab: cartSize = 524288; break; // 4 Mbits Toshiba
|
||||
case 0x204c: cartSize = 524288; break; // 4 Mbits STMicroelectronics ?
|
||||
case 0x982c: cartSize = 1048576; break; // 8 Mbits Toshiba
|
||||
case 0xec2c: cartSize = 1048576; break; // 8 Mbits Samsung
|
||||
case 0x982f: cartSize = 2097152; break; // 16 Mbits Toshiba
|
||||
case 0xec2f: cartSize = 2097152; break; // 16 Mbits Samsung
|
||||
case 0xffff: return false; break; // detection error (no cart inserted or hw problem)
|
||||
}
|
||||
|
||||
// reset to read mode
|
||||
dataOut();
|
||||
writeByte_NGP(0x0, 0xf0);
|
||||
|
||||
dataIn();
|
||||
|
||||
// confirm NGP cart recognition
|
||||
dataIn();
|
||||
for (uint32_t addr = 0; addr < 28; addr++)
|
||||
sdBuffer[addr] = readByte_NGP(addr);
|
||||
if (memcmp_P(sdBuffer, PSTR("COPYRIGHT BY SNK CORPORATION"), 28) != 0 && memcmp_P(sdBuffer, PSTR(" LICENSED BY SNK CORPORATION"), 28) != 0)
|
||||
@ -150,7 +119,7 @@ bool getCartInfo_NGP() {
|
||||
// get app ID
|
||||
snprintf(cartID, 5, "%02X%02X", readByte_NGP(0x21), readByte_NGP(0x20));
|
||||
|
||||
// force rom size to 32Mbits for few titles
|
||||
// force rom size to 32 Mbits for few titles
|
||||
if (strcmp(cartID,"0060") == 0 || strcmp(cartID,"0061") == 0 || strcmp(cartID,"0069") == 0 )
|
||||
cartSize = 4194304;
|
||||
|
||||
@ -192,6 +161,7 @@ void printCartInfo_NGP() {
|
||||
print_Msg(F("Rom Size: "));
|
||||
if (cartSize == 0) {
|
||||
println_Msg(F("Unknown"));
|
||||
// display the chip IDs if unknown
|
||||
print_Msg(F("Chip ID: "));
|
||||
println_Msg(String(manufacturerID,HEX) + " " + String(deviceID,HEX));
|
||||
}
|
||||
@ -217,22 +187,18 @@ void readROM_NGP(char *outPathBuf, size_t bufferSize) {
|
||||
// wait for user choice to come back from the question box menu
|
||||
switch (ngpRomMenu) {
|
||||
case 0:
|
||||
// 4 Mbits
|
||||
cartSize = 524288;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// 8 Mbits
|
||||
cartSize = 1048576;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// 16 Mbits
|
||||
cartSize = 2097152;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// 32 Mbits
|
||||
cartSize = 4194304;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user