add option to clear display and remove duplicate code

This commit is contained in:
smesgr9000 2024-05-25 14:25:35 +02:00
parent 6abe29fcd9
commit 41182a7eb0
28 changed files with 39 additions and 73 deletions

View File

@ -298,8 +298,7 @@ boolean checkE7(uint16_t bank) {
void readROM_2600() { void readROM_2600() {
createFolder("ATARI", "ROM", romName, "a26"); createFolder("ATARI", "ROM", romName, "a26");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -218,8 +218,7 @@ void readSegment_5200(uint16_t startaddr, uint16_t endaddr) {
void readROM_5200() { void readROM_5200() {
createFolder("5200", "ROM", romName, "a52"); createFolder("5200", "ROM", romName, "a52");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -344,8 +344,7 @@ void bankSwitch_7800(uint16_t addr) {
void readROM_7800() { void readROM_7800() {
createFolder("7800", "ROM", romName, "a78"); createFolder("7800", "ROM", romName, "a78");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -152,8 +152,7 @@ void readSegment_ARC(uint16_t startaddr, uint16_t endaddr) {
void readROM_ARC() { void readROM_ARC() {
createFolder("ARC", "ROM", romName, "bin"); createFolder("ARC", "ROM", romName, "bin");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -366,8 +366,7 @@ void readPorts_C64() {
void readROM_C64() { void readROM_C64() {
createFolder("C64", "ROM", romName, "bin"); createFolder("C64", "ROM", romName, "bin");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -164,8 +164,7 @@ void readSegment_COL(uint32_t startaddr, uint32_t endaddr) {
void readROM_COL() { void readROM_COL() {
createFolder("COL", "ROM", romName, "col"); createFolder("COL", "ROM", romName, "col");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -678,8 +678,11 @@ void createFolder(const char* system, const char* subfolder, const char* gameNam
sd.chdir(folder); sd.chdir(folder);
} }
void printAndIncrementFolder() { void printAndIncrementFolder(bool displayClear = false) {
// Save location // Save location
if(displayClear) {
display_Clear();
}
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
print_Msg(folder); print_Msg(folder);
println_Msg(F("/...")); println_Msg(F("/..."));

View File

@ -394,8 +394,7 @@ uint8_t readData_FAIRCHILD() {
void readROM_FAIRCHILD() { void readROM_FAIRCHILD() {
createFolder("FAIRCHILD", "ROM", romName, "bin"); createFolder("FAIRCHILD", "ROM", romName, "bin");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -1109,8 +1109,7 @@ void readROM_GB() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("GB", "ROM", romName, "gb"); createFolder("GB", "ROM", romName, "gb");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
@ -1457,8 +1456,7 @@ void readSRAMFLASH_MBC6_GB() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("GB", "SAVE", romName, "sav"); createFolder("GB", "SAVE", romName, "sav");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
@ -2528,8 +2526,7 @@ void readPelican_GB() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("GB", "ROM", "Pelican", "GB"); createFolder("GB", "ROM", "Pelican", "GB");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -823,9 +823,7 @@ void readROM_GBA() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("GBA", "ROM", romName, "gba"); createFolder("GBA", "ROM", romName, "gba");
//clear the screen printAndIncrementFolder(true);
display_Clear();
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -271,8 +271,7 @@ void readRAM_GPC() {
createFolder("SNES", "ROM", "GPC4M", "sfc"); createFolder("SNES", "ROM", "GPC4M", "sfc");
//clear the screen //clear the screen
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -305,8 +305,7 @@ void readSegment_INTV(uint32_t startaddr, uint32_t endaddr) {
void readROM_INTV() { void readROM_INTV() {
createFolder("INTV", "ROM", romName, "int"); createFolder("INTV", "ROM", romName, "int");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -524,8 +524,7 @@ void readROM_LOOPY() {
createFolder("LOOPY", "ROM", romName, "bin"); createFolder("LOOPY", "ROM", romName, "bin");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_FatalError(sd_error_STR); print_FatalError(sd_error_STR);

View File

@ -1426,8 +1426,7 @@ void readROM_MD() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("MD", "ROM", romName, "BIN"); createFolder("MD", "ROM", romName, "BIN");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
@ -2875,8 +2874,7 @@ void readRealtec_MD() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("MD", "ROM", romName, "MD"); createFolder("MD", "ROM", romName, "MD");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -345,8 +345,7 @@ void readROM_MSX() {
} else { } else {
createFolder("MSX", "ROM", romName, "bin"); createFolder("MSX", "ROM", romName, "bin");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -713,8 +713,7 @@ void read_NES(const char* fileSuffix, const byte* header, const uint8_t headersi
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("NES", "ROM", romName, fileSuffix); createFolder("NES", "ROM", romName, fileSuffix);
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -214,8 +214,7 @@ void readROM_NGP(char* outPathBuf, size_t bufferSize) {
if (outPathBuf != NULL && bufferSize > 0) if (outPathBuf != NULL && bufferSize > 0)
snprintf(outPathBuf, bufferSize, "%s/%s", folder, fileName); snprintf(outPathBuf, bufferSize, "%s/%s", folder, fileName);
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -214,8 +214,7 @@ void bankSwitch_ODY2(uint16_t addr, uint8_t data) {
void readROM_ODY2() { void readROM_ODY2() {
createFolder("ODY2", "ROM", romName, "bin"); createFolder("ODY2", "ROM", romName, "bin");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -241,8 +241,7 @@ void writeData_POKE(uint32_t addr, uint8_t data) {
void readROM_POKE() { void readROM_POKE() {
createFolder("POKE", "ROM", romName, "min"); createFolder("POKE", "ROM", romName, "min");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -558,8 +558,7 @@ void readROM_SMS() {
createFolder("SG1000", "ROM", romName, "sg"); createFolder("SG1000", "ROM", romName, "sg");
} }
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// Open file on sd card // Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
@ -650,8 +649,7 @@ void readSRAM_SMS() {
} }
createFolder(system, "SAVE", romName, "sav"); createFolder(system, "SAVE", romName, "sav");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// Create file on sd card // Create file on sd card
if (myFile.open(fileName, O_RDWR | O_CREAT)) { if (myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -1293,9 +1293,7 @@ void readROM_SNES() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
createFolder("SNES", "ROM", romName, "sfc"); createFolder("SNES", "ROM", romName, "sfc");
//clear the screen printAndIncrementFolder(true);
display_Clear();
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -169,8 +169,7 @@ void readRom_ST(unsigned int bankStart, unsigned int bankEnd) {
// create a new folder to save rom file // create a new folder to save rom file
createFolder("ST", "ROM", "SUFAMI_TURBO", "st"); createFolder("ST", "ROM", "SUFAMI_TURBO", "st");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -151,8 +151,7 @@ static void readROM_Acan() {
EEPROM_readAnything(0, foldern); EEPROM_readAnything(0, foldern);
snprintf(folder, FILEPATH_LENGTH, "/ACAN/ROM/%d", foldern); snprintf(folder, FILEPATH_LENGTH, "/ACAN/ROM/%d", foldern);
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
sd.mkdir(folder, true); sd.mkdir(folder, true);
sd.chdir(folder); sd.chdir(folder);
@ -190,8 +189,7 @@ static void readSRAM_Acan() {
EEPROM_readAnything(0, foldern); EEPROM_readAnything(0, foldern);
snprintf(folder, FILEPATH_LENGTH, "/ACAN/SAVE/%d", foldern); snprintf(folder, FILEPATH_LENGTH, "/ACAN/SAVE/%d", foldern);
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
sd.mkdir(folder, true); sd.mkdir(folder, true);
sd.chdir(folder); sd.chdir(folder);
@ -282,8 +280,7 @@ static void readUM6650() {
EEPROM_readAnything(0, foldern); EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "/ACAN/UM6650/%d", foldern); snprintf(folder, sizeof(folder), "/ACAN/UM6650/%d", foldern);
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
sd.mkdir(folder, true); sd.mkdir(folder, true);
sd.chdir(folder); sd.chdir(folder);

View File

@ -416,8 +416,7 @@ void readROM_SV() {
createFolder("SNES", "ROM", "MEMPACK", "bs"); createFolder("SNES", "ROM", "MEMPACK", "bs");
//clear the screen //clear the screen
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
//open file on sd card //open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {

View File

@ -412,8 +412,7 @@ void readROM_VB() {
createFolder("VBOY", "ROM", romName, "vb"); createFolder("VBOY", "ROM", romName, "vb");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
if (!myFile.open(fileName, O_RDWR | O_CREAT)) { if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_FatalError(sd_error_STR); print_FatalError(sd_error_STR);

View File

@ -198,8 +198,7 @@ void readSegment_VECTREX(uint16_t startaddr, uint16_t endaddr) {
void readROM_VECTREX() { void readROM_VECTREX() {
createFolder("VECTREX", "ROM", romName, "vec"); createFolder("VECTREX", "ROM", romName, "vec");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))

View File

@ -489,8 +489,7 @@ static uint16_t readROM_WS(char *outPathBuf, size_t bufferSize) {
if (outPathBuf != NULL && bufferSize > 0) if (outPathBuf != NULL && bufferSize > 0)
snprintf(outPathBuf, bufferSize, "%s/%s", folder, fileName); snprintf(outPathBuf, bufferSize, "%s/%s", folder, fileName);
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
@ -556,8 +555,7 @@ static void readSRAM_WS() {
// generate fullname of rom file // generate fullname of rom file
createFolder("WS", "SAVE", romName, "save"); createFolder("WS", "SAVE", romName, "save");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR); print_FatalError(create_file_STR);
@ -689,8 +687,7 @@ static void readEEPROM_WS() {
// generate fullname of eep file // generate fullname of eep file
createFolder("WS", "SAVE", romName, "eep"); createFolder("WS", "SAVE", romName, "eep");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR); print_FatalError(create_file_STR);

View File

@ -187,8 +187,7 @@ uint8_t readByte_WSV(uint32_t addr) {
void readROM_WSV() { void readROM_WSV() {
createFolder("WSV", "ROM", romName, "sv"); createFolder("WSV", "ROM", romName, "sv");
display_Clear(); printAndIncrementFolder(true);
printAndIncrementFolder();
// open file on sdcard // open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) if (!myFile.open(fileName, O_RDWR | O_CREAT))