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