V30D: Fixed dumping error with all japanese rom names and no game code either

Example cartridge: Super Family Tennis
This commit is contained in:
sanni 2017-11-21 12:25:55 +01:00 committed by GitHub
parent 012ce3626c
commit 8613f79382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 113 additions and 20 deletions

View File

@ -2,8 +2,8 @@
Cartridge Reader for Arduino Mega2560 Cartridge Reader for Arduino Mega2560
Author: sanni Author: sanni
Date: 2017-11-19 Date: 2017-11-21
Version: V30C Version: V30D
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
@ -35,20 +35,20 @@
infinest - help with GB Memory cart infinest - help with GB Memory cart
**********************************************************************************/ **********************************************************************************/
char ver[5] = "V30C"; char ver[5] = "V30D";
/****************************************** /******************************************
Define Starting Point Define Starting Point
******************************************/ ******************************************/
// mainMenu, n64Menu, snsMenu, npMenu, gbxMenu, segaMenu, flashMenu // mainMenu, n64Menu, snsMenu, gbxMenu, segaMenu, flashMenu
#define startMenu mainMenu #define startMenu mainMenu
/****************************************** /******************************************
Define Output Define Output
******************************************/ ******************************************/
// enable_OLED to 0 and enable_Serial to 1 // enable_OLED to 0 and enable_Serial to 1
#define enable_OLED 1 #define enable_OLED 0
#define enable_Serial 0 #define enable_Serial 1
/****************************************** /******************************************
Define Input Define Input
@ -508,22 +508,28 @@ void print_Error(const __FlashStringHelper *errorMessage, boolean forceReset) {
display_Update(); display_Update();
if (forceReset) { if (forceReset) {
println_Msg(F("")); if (enable_Serial) {
println_Msg(F("Press Button...")); println_Msg(F("Fatal Error, please reset"));
display_Update(); while (1);
wait();
if (ignoreError == 0) {
asm volatile (" jmp 0");
} }
else { else {
ignoreError = 0;
display_Clear();
println_Msg(F("")); println_Msg(F(""));
println_Msg(F("")); println_Msg(F("Press Button..."));
println_Msg(F(""));
println_Msg(F(" Error Overwrite"));
display_Update(); display_Update();
delay(2000); wait();
if (ignoreError == 0) {
asm volatile (" jmp 0");
}
else {
ignoreError = 0;
display_Clear();
println_Msg(F(""));
println_Msg(F(""));
println_Msg(F(""));
println_Msg(F(" Error Overwrite"));
display_Update();
delay(2000);
}
} }
} }
} }
@ -635,11 +641,41 @@ void wait_serial() {
while (Serial.available() == 0) { while (Serial.available() == 0) {
} }
incomingByte = Serial.read() - 48; incomingByte = Serial.read() - 48;
if (incomingByte == 53) {
// Open file on sd card
sd.chdir(folder);
if (myFile.open(fileName, O_READ)) {
// Get rom size from file
fileSize = myFile.fileSize();
// Send file
for (unsigned long currByte = 0; currByte < fileSize; currByte += 512) {
myFile.read(sdBuffer, 512);
// Blink led
if (currByte % 2048 == 0)
PORTB ^= (1 << 4);
for (int c = 0; c < 512; c++) {
Serial.write(sdBuffer[c]);
}
}
// Close the file:
myFile.close();
}
else {
print_Error(F("Can't open file"), true);
}
}
Serial.println(""); Serial.println("");
} }
byte questionBox_Serial(const char* question, char answers[7][20], int num_answers, int default_choice) { byte questionBox_Serial(const char* question, char answers[7][20], int num_answers, int default_choice) {
// Print menu to serial monitor // Print menu to serial monitor
if (enable_Serial && filebrowse) {
Serial.print("Filebrowser: ");
}
Serial.print(question); Serial.print(question);
Serial.println(F(" Menu")); Serial.println(F(" Menu"));
for (byte i = 0; i < num_answers; i++) { for (byte i = 0; i < num_answers; i++) {
@ -657,6 +693,44 @@ byte questionBox_Serial(const char* question, char answers[7][20], int num_answe
// Read the incoming byte: // Read the incoming byte:
incomingByte = Serial.read() - 48; incomingByte = Serial.read() - 48;
// Import file (i)
if (incomingByte == 57) {
if (filebrowse == 1) {
// Make sure we have an import directory
sd.mkdir("IMPORT", true);
// Create and open file on sd card
EEPROM_readAnything(10, foldern);
sprintf(fileName, "IMPORT/%d.bin", foldern);
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_Error(F("Can't create file on SD"), true);
}
// Read file from serial
fileSize = 0;
while (Serial.available() > 0) {
myFile.write(Serial.read());
fileSize++;
// Blink led
PORTB ^= (1 << 4);
}
// Close the file:
myFile.close();
// Write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(10, foldern);
print_Msg("Imported ");
print_Msg(fileSize);
print_Msg(" bytes to file ");
println_Msg(fileName);
return 7;
}
}
// Page up (u)
if (incomingByte == 69) { if (incomingByte == 69) {
if (filebrowse == 1) { if (filebrowse == 1) {
if (currPage > 1) { if (currPage > 1) {
@ -667,8 +741,9 @@ byte questionBox_Serial(const char* question, char answers[7][20], int num_answe
root = 1; root = 1;
} }
} }
} }
// Page down (d)
else if (incomingByte == 52) { else if (incomingByte == 52) {
if ((numPages > currPage) && (filebrowse == 1)) { if ((numPages > currPage) && (filebrowse == 1)) {
lastPage = currPage; lastPage = currPage;
@ -1156,6 +1231,10 @@ page:
case 6: case 6:
strcpy(fileName, fileNames[6 + ((currPage - 1) * 7)]); strcpy(fileName, fileNames[6 + ((currPage - 1) * 7)]);
break; break;
case 7:
// File import
break;
} }
// Add directory to our filepath if we just entered a new directory // Add directory to our filepath if we just entered a new directory

View File

@ -649,7 +649,21 @@ boolean checkcart_SNES() {
romName[3] = 'C'; romName[3] = 'C';
romName[4] = '-'; romName[4] = '-';
for (unsigned int i = 0; i < 4; i++) { for (unsigned int i = 0; i < 4; i++) {
romName[i + 5] = readBank_SNES(0, 0xFFB2 + i); myByte = readBank_SNES(0, 0xFFB2 + i);
if (((char(myByte) >= 48 && char(myByte) <= 57) || (char(myByte) >= 65 && char(myByte) <= 122)) && myLength < 4) {
romName[myLength + 5] = char(myByte);
myLength++;
}
}
if (myLength == 0) {
// Rom code unknown
romName[0] = 'U';
romName[1] = 'N';
romName[2] = 'K';
romName[3] = 'N';
romName[4] = 'O';
romName[5] = 'W';
romName[6] = 'N';
} }
} }