Skip to content

Commit

Permalink
remove duplicate GB Flash reading function
Browse files Browse the repository at this point in the history
  • Loading branch information
smesgr9000 committed May 12, 2024
1 parent dc47202 commit 38b2b24
Showing 1 changed file with 29 additions and 42 deletions.
71 changes: 29 additions & 42 deletions Cart_Reader/GB.ino
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ static const char GameSharkRead[] PROGMEM = "Read GBC GameShark";
static const char GameSharkWrite[] PROGMEM = "Write GBC GameShark";
static const char* const menuOptionsGBDatel[] PROGMEM = { MegaMemRead, MegaMemWrite, GameSharkRead, GameSharkWrite };

bool gbxFlashCFI() {
// Flash CFI
display_Clear();
display_Update();
setup_GB();
mode = CORE_GB;

// Change working dir to root
sd.chdir("/");
// Launch filebrowser
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select file"));
display_Clear();
identifyCFI_GB();
if (!writeCFI_GB()) {
display_Clear();
println_Msg(F("Flashing failed, time out!"));
// Prints string out of the common strings array either with or without newline
print_STR(press_button_STR, 1);
display_Update();
return false;
}
return true;
}

// Start menu for both GB and GBA
void gbxMenu() {
// create menu with title and 5 options to choose from
Expand Down Expand Up @@ -212,53 +238,14 @@ void gbxMenu() {

case 1:
// Flash CFI
display_Clear();
display_Update();
setup_GB();
mode = CORE_GB;

// Change working dir to root
sd.chdir("/");
// Launch filebrowser
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select file"));
display_Clear();
identifyCFI_GB();
if (!writeCFI_GB()) {
display_Clear();
println_Msg(F("Flashing failed, time out!"));
// Prints string out of the common strings array either with or without newline
print_STR(press_button_STR, 1);
display_Update();
wait();
}
// Reset
gbxFlashCFI();
wait();
resetArduino();
break;

case 2:
// Flash CFI and Save
display_Clear();
display_Update();
setup_GB();
mode = CORE_GB;

// Change working dir to root
sd.chdir("/");
// Launch filebrowser
filePath[0] = '\0';
sd.chdir("/");
fileBrowser(F("Select file"));
display_Clear();
identifyCFI_GB();
if (!writeCFI_GB()) {
display_Clear();
println_Msg(F("Flashing failed, time out!"));
// Prints string out of the common strings array either with or without newline
print_STR(press_button_STR, 1);
display_Update();
// Flash CFI and save
if (!gbxFlashCFI()) {
wait();
resetArduino();
}
Expand Down

0 comments on commit 38b2b24

Please sign in to comment.