From da8dc3d94e00b286c41d340d052f13752c8241de Mon Sep 17 00:00:00 2001 From: smesgr9000 Date: Sun, 16 Jun 2024 10:39:47 +0200 Subject: [PATCH] replace duplicate code with common folder creation function --- Cart_Reader/FAIRCHILD.ino | 17 +---------------- Cart_Reader/PCE.ino | 10 +--------- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/Cart_Reader/FAIRCHILD.ino b/Cart_Reader/FAIRCHILD.ino index ca1fe73..03b7111 100644 --- a/Cart_Reader/FAIRCHILD.ino +++ b/Cart_Reader/FAIRCHILD.ino @@ -458,22 +458,7 @@ void readROM_FAIRCHILD() { } void read16K_FAIRCHILD() { // Read 16K Bytes - createFolder("FAIRCHILD", "ROM", romName, "bin"); - - display_Clear(); - print_STR(saving_to_STR, 0); - print_Msg(folder); - println_Msg(F("/...")); - display_Update(); - - // open file on sdcard - if (!myFile.open(fileName, O_RDWR | O_CREAT)) { - print_FatalError(create_file_STR); - } - - // write new folder number back to EEPROM - foldern++; - EEPROM_writeAnything(0, foldern); + createFolderAndOpenFile("FAIRCHILD", "ROM", romName, "bin"); unsigned long cartsize = FAIRCHILD[fairchildsize] * 0x400; for (uint16_t y = 0; y < 0x20; y++) { diff --git a/Cart_Reader/PCE.ino b/Cart_Reader/PCE.ino index b4e6ba5..7e9aaff 100644 --- a/Cart_Reader/PCE.ino +++ b/Cart_Reader/PCE.ino @@ -753,15 +753,7 @@ void read_rom_PCE(void) { // Get name, add extension and convert to char array for sd lib createFolder("PCE", "ROM", "PCEROM", "pce"); - print_Msg(F("Saving ROM to ")); - print_Msg(folder); - print_Msg(F("/")); - println_Msg(fileName); - display_Update(); - - // write new folder number back to eeprom - foldern = foldern + 1; - EEPROM_writeAnything(0, foldern); + printAndIncrementFolder(); //open file on sd card if (!myFile.open(fileName, O_RDWR | O_CREAT)) {