Update GB.ino

This updates the GBC Gameshark functions to check the Chip ID before performing any other functions, which ensures a good connection with the Gameshark cartridge and prevents erroneous dumps or writes due to poor connection.
This commit is contained in:
Richard Weick 2023-10-01 12:46:10 -05:00 committed by GitHub
parent c873d3cf9d
commit 0e04c1c1a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3363,27 +3363,6 @@ void readGameshark_GB() {
strcpy(fileName, "Gameshark");
strcat(fileName, ".GB");
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/ROM/Gameshark/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear();
print_STR(saving_to_STR, 0);
print_Msg(folder);
println_Msg(F("/..."));
display_Update();
// write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_FatalError(create_file_STR);
}
word finalAddress = 0x5FFF;
word startAddress= 0x4000;
word bankAddress = 0x7FE1;
@ -3418,9 +3397,38 @@ void readGameshark_GB() {
delay(100);
if (flashid == 0xBFB5) {
display_Clear();
println_Msg(F("SST 39SF010"));
println_Msg(F("Rom Size: 128 KB"));
display_Update();
} else {
display_Clear();
println_Msg(F("Unknown Flash ID"));
println_Msg(F("Check Cartridge Connection"));
print_STR(press_button_STR, 1);
display_Update();
wait();
mainMenu();
}
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/ROM/Gameshark/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
print_STR(saving_to_STR, 0);
print_Msg(folder);
println_Msg(F("/..."));
display_Update();
// write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_FatalError(create_file_STR);
}
// Initialize progress bar
@ -3455,21 +3463,6 @@ void readGameshark_GB() {
****************************************************/
// Write Datel GBC Gameshark Device
void writeGameshark_GB() {
// Launch filebrowser
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select file"));
display_Clear();
byte byte1;
bool toggle = true;
// Create filepath
sprintf(filePath, "%s/%s", filePath, fileName);
// Open file on sd card
if (myFile.open(filePath, O_READ)) {
// Enable Rom Banks
readByte_GB(0x101);
readByte_GB(0x108);
@ -3499,14 +3492,29 @@ void writeGameshark_GB() {
writeByte_GB(0x5555, 0xF0);
if (flashid != 0xBFB5) {
display_Clear();
println_Msg(F("Unknown Flash ID"));
println_Msg(flashid);
println_Msg(F("Check Cartridge Connection"));
print_STR(press_button_STR, 1);
display_Update();
wait();
mainMenu();
}
}
// Launch filebrowser
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select file"));
display_Clear();
byte byte1;
bool toggle = true;
// Create filepath
sprintf(filePath, "%s/%s", filePath, fileName);
// Open file on sd card
myFile.open(filePath, O_READ);
if (flashid == 0xBFB5) {
println_Msg(F("SST 39SF010"));