V25C: Changed ID'ing of 32MB N64 Repros

This commit is contained in:
sanni 2017-06-06 10:07:11 +02:00 committed by GitHub
parent abf99f9e1f
commit 876190b17e
2 changed files with 31 additions and 23 deletions

View File

@ -2,15 +2,15 @@
Cartridge Reader for Arduino Mega2560 Cartridge Reader for Arduino Mega2560
Author: sanni Author: sanni
Date: 2017-06-03 Date: 2017-06-06
Version: V25B Version: V25C
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
Clockgen: https://github.com/etherkit/Si5351Arduino Clockgen: https://github.com/etherkit/Si5351Arduino
RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools RGB Tools lib: https://github.com/joushx/Arduino-RGB-Tools
Compiled with Arduino 1.8.2 Compiled with Arduino 1.8.3
Thanks to: Thanks to:
MichlK - ROM-Reader for Super Nintendo MichlK - ROM-Reader for Super Nintendo
@ -34,7 +34,7 @@
YamaArashi - GBA flashrom bank switch command YamaArashi - GBA flashrom bank switch command
**********************************************************************************/ **********************************************************************************/
char ver[5] = "V25B"; char ver[5] = "V25C";
/****************************************** /******************************************
Define Output Define Output
@ -165,7 +165,7 @@ int incomingByte;
int choice = 0; int choice = 0;
// Temporary array that holds the menu option read out of progmem // Temporary array that holds the menu option read out of progmem
char menuOptions[7][20]; char menuOptions[7][20];
boolean ignoreError; boolean ignoreError = 0;
// File browser // File browser
char fileName[26]; char fileName[26];
@ -962,7 +962,8 @@ void wait_btn() {
// if the cart readers input button is pressed long // if the cart readers input button is pressed long
if (b == 3) { if (b == 3) {
if (errorLvl) { if (errorLvl) {
ignoreError = 1; // Debug
//ignoreError = 1;
errorLvl = 0; errorLvl = 0;
} }
break; break;

View File

@ -2165,7 +2165,7 @@ void resetFlashrom_N64(unsigned long flashBase) {
} }
void idFlashrom_N64() { void idFlashrom_N64() {
// Size of repro cartridge // Size of repro cartridge if no ID is found
cartSize = 0; cartSize = 0;
// Send ID command to first flashrom // Send ID command to first flashrom
@ -2182,16 +2182,18 @@ void idFlashrom_N64() {
// Read flashrom ID // Read flashrom ID
sprintf(flashid, "%04X", readWord_N64()); sprintf(flashid, "%04X", readWord_N64());
// Reset flashrom to read mode // Check for known ID
if (strcmp(flashid, "227E") == 0)
resetFlashrom_N64(romBase);
else if ((strcmp(flashid, "8813") == 0) || (strcmp(flashid, "8816") == 0))
resetReadmode_N64();
if ((strcmp(flashid, "227E") == 0) || (strcmp(flashid, "8816") == 0)) { if ((strcmp(flashid, "227E") == 0) || (strcmp(flashid, "8816") == 0)) {
// Reset flashrom to read mode
if (strcmp(flashid, "227E") == 0)
resetFlashrom_N64(romBase);
else if ((strcmp(flashid, "8813") == 0) || (strcmp(flashid, "8816") == 0))
resetReadmode_N64();
// Found first flashrom chip, set to 32MB
cartSize = 32; cartSize = 32;
// Send ID command to second flashrom // Send ID command to possible second flashrom
setAddress_N64(romBase + 0x2000000 + (0x555 << 1)); setAddress_N64(romBase + 0x2000000 + (0x555 << 1));
writeWord_N64(0xAA); writeWord_N64(0xAA);
setAddress_N64(romBase + 0x2000000 + (0x2AA << 1)); setAddress_N64(romBase + 0x2000000 + (0x2AA << 1));
@ -2203,16 +2205,21 @@ void idFlashrom_N64() {
setAddress_N64(romBase + 0x2000000); setAddress_N64(romBase + 0x2000000);
readWord_N64(); readWord_N64();
// Read flashrom ID // Read flashrom ID
sprintf(flashid, "%04X", readWord_N64()); sprintf(cartID, "%04X", readWord_N64());
if ((strcmp(flashid, "227E") == 0) || (strcmp(flashid, "8813") == 0)) {
cartSize = 64;
}
// Reset flashrom to read mode // Check if second flashrom chip is present
if (strcmp(flashid, "227E") == 0) if ((strcmp(cartID, "227E") == 0) || (strcmp(cartID, "8813") == 0)) {
resetFlashrom_N64(romBase); cartSize = 64;
else if ((strcmp(flashid, "8813") == 0) || (strcmp(flashid, "8816") == 0)) strncpy(flashid , cartID, 5);
resetReadmode_N64();
// Reset flashrom to read mode
if (strcmp(flashid, "227E") == 0)
resetFlashrom_N64(romBase + 0x2000000);
else if ((strcmp(flashid, "8813") == 0) || (strcmp(flashid, "8816") == 0))
resetReadmode_N64();
}
// Empty cartID string
cartID[0] = '\0';
} }
} }