Skip to content

Commit

Permalink
add option to clear display and remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
smesgr9000 committed May 25, 2024
1 parent 6abe29f commit 41182a7
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 73 deletions.
3 changes: 1 addition & 2 deletions Cart_Reader/2600.ino
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ boolean checkE7(uint16_t bank) {
void readROM_2600() {
createFolder("ATARI", "ROM", romName, "a26");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/5200.ino
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ void readSegment_5200(uint16_t startaddr, uint16_t endaddr) {
void readROM_5200() {
createFolder("5200", "ROM", romName, "a52");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/7800.ino
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ void bankSwitch_7800(uint16_t addr) {
void readROM_7800() {
createFolder("7800", "ROM", romName, "a78");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/ARC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ void readSegment_ARC(uint16_t startaddr, uint16_t endaddr) {
void readROM_ARC() {
createFolder("ARC", "ROM", romName, "bin");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/C64.ino
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ void readPorts_C64() {
void readROM_C64() {
createFolder("C64", "ROM", romName, "bin");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/COLV.ino
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ void readSegment_COL(uint32_t startaddr, uint32_t endaddr) {
void readROM_COL() {
createFolder("COL", "ROM", romName, "col");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
5 changes: 4 additions & 1 deletion Cart_Reader/Cart_Reader.ino
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,11 @@ void createFolder(const char* system, const char* subfolder, const char* gameNam
sd.chdir(folder);
}

void printAndIncrementFolder() {
void printAndIncrementFolder(bool displayClear = false) {
// Save location
if(displayClear) {
display_Clear();
}
print_STR(saving_to_STR, 0);
print_Msg(folder);
println_Msg(F("/..."));
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/FAIRCHILD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ uint8_t readData_FAIRCHILD() {
void readROM_FAIRCHILD() {
createFolder("FAIRCHILD", "ROM", romName, "bin");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
9 changes: 3 additions & 6 deletions Cart_Reader/GB.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,7 @@ void readROM_GB() {
// Get name, add extension and convert to char array for sd lib
createFolder("GB", "ROM", romName, "gb");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down Expand Up @@ -1457,8 +1456,7 @@ void readSRAMFLASH_MBC6_GB() {
// Get name, add extension and convert to char array for sd lib
createFolder("GB", "SAVE", romName, "sav");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down Expand Up @@ -2528,8 +2526,7 @@ void readPelican_GB() {
// Get name, add extension and convert to char array for sd lib
createFolder("GB", "ROM", "Pelican", "GB");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
4 changes: 1 addition & 3 deletions Cart_Reader/GBA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,7 @@ void readROM_GBA() {
// Get name, add extension and convert to char array for sd lib
createFolder("GBA", "ROM", romName, "gba");

//clear the screen
display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/GPC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ void readRAM_GPC() {
createFolder("SNES", "ROM", "GPC4M", "sfc");

//clear the screen
display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/INTV.ino
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ void readSegment_INTV(uint32_t startaddr, uint32_t endaddr) {
void readROM_INTV() {
createFolder("INTV", "ROM", romName, "int");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/LOOPY.ino
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,7 @@ void readROM_LOOPY() {

createFolder("LOOPY", "ROM", romName, "bin");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_FatalError(sd_error_STR);
Expand Down
6 changes: 2 additions & 4 deletions Cart_Reader/MD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1426,8 +1426,7 @@ void readROM_MD() {
// Get name, add extension and convert to char array for sd lib
createFolder("MD", "ROM", romName, "BIN");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

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

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/MSX.ino
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ void readROM_MSX() {
} else {
createFolder("MSX", "ROM", romName, "bin");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/NES.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
createFolder("NES", "ROM", romName, fileSuffix);

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/NGP.ino
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ void readROM_NGP(char* outPathBuf, size_t bufferSize) {
if (outPathBuf != NULL && bufferSize > 0)
snprintf(outPathBuf, bufferSize, "%s/%s", folder, fileName);

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/ODY2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ void bankSwitch_ODY2(uint16_t addr, uint8_t data) {
void readROM_ODY2() {
createFolder("ODY2", "ROM", romName, "bin");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/POKEMINI.ino
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ void writeData_POKE(uint32_t addr, uint8_t data) {
void readROM_POKE() {
createFolder("POKE", "ROM", romName, "min");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
6 changes: 2 additions & 4 deletions Cart_Reader/SMS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,7 @@ void readROM_SMS() {
createFolder("SG1000", "ROM", romName, "sg");
}

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down Expand Up @@ -650,8 +649,7 @@ void readSRAM_SMS() {
}
createFolder(system, "SAVE", romName, "sav");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// Create file on sd card
if (myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
4 changes: 1 addition & 3 deletions Cart_Reader/SNES.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1293,9 +1293,7 @@ void readROM_SNES() {
// Get name, add extension and convert to char array for sd lib
createFolder("SNES", "ROM", romName, "sfc");

//clear the screen
display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/ST.ino
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ void readRom_ST(unsigned int bankStart, unsigned int bankEnd) {
// create a new folder to save rom file
createFolder("ST", "ROM", "SUFAMI_TURBO", "st");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
9 changes: 3 additions & 6 deletions Cart_Reader/SUPRACAN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ static void readROM_Acan() {
EEPROM_readAnything(0, foldern);
snprintf(folder, FILEPATH_LENGTH, "/ACAN/ROM/%d", foldern);

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

sd.mkdir(folder, true);
sd.chdir(folder);
Expand Down Expand Up @@ -190,8 +189,7 @@ static void readSRAM_Acan() {
EEPROM_readAnything(0, foldern);
snprintf(folder, FILEPATH_LENGTH, "/ACAN/SAVE/%d", foldern);

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

sd.mkdir(folder, true);
sd.chdir(folder);
Expand Down Expand Up @@ -282,8 +280,7 @@ static void readUM6650() {
EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "/ACAN/UM6650/%d", foldern);

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

sd.mkdir(folder, true);
sd.chdir(folder);
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/SV.ino
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ void readROM_SV() {
createFolder("SNES", "ROM", "MEMPACK", "bs");

//clear the screen
display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

//open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/VBOY.ino
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ void readROM_VB() {

createFolder("VBOY", "ROM", romName, "vb");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
print_FatalError(sd_error_STR);
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/VECTREX.ino
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ void readSegment_VECTREX(uint16_t startaddr, uint16_t endaddr) {
void readROM_VECTREX() {
createFolder("VECTREX", "ROM", romName, "vec");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down
9 changes: 3 additions & 6 deletions Cart_Reader/WS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ static uint16_t readROM_WS(char *outPathBuf, size_t bufferSize) {
if (outPathBuf != NULL && bufferSize > 0)
snprintf(outPathBuf, bufferSize, "%s/%s", folder, fileName);

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down Expand Up @@ -556,8 +555,7 @@ static void readSRAM_WS() {
// generate fullname of rom file
createFolder("WS", "SAVE", romName, "save");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR);
Expand Down Expand Up @@ -689,8 +687,7 @@ static void readEEPROM_WS() {
// generate fullname of eep file
createFolder("WS", "SAVE", romName, "eep");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR);
Expand Down
3 changes: 1 addition & 2 deletions Cart_Reader/WSV.ino
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ uint8_t readByte_WSV(uint32_t addr) {
void readROM_WSV() {
createFolder("WSV", "ROM", romName, "sv");

display_Clear();
printAndIncrementFolder();
printAndIncrementFolder(true);

// open file on sdcard
if (!myFile.open(fileName, O_RDWR | O_CREAT))
Expand Down

0 comments on commit 41182a7

Please sign in to comment.