remove duplicate code to create folder

This commit is contained in:
smesgr9000 2024-05-12 15:37:11 +02:00
parent 38b2b2476b
commit 9f0aa09197
31 changed files with 82 additions and 450 deletions

View File

@ -296,14 +296,7 @@ boolean checkE7(uint16_t bank) {
} }
void readROM_2600() { void readROM_2600() {
strcpy(fileName, romName); createFolder("ATARI", "ROM", romName, "a26");
strcat(fileName, ".a26");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "ATARI/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving to ")); print_Msg(F("Saving to "));

View File

@ -216,14 +216,7 @@ void readSegment_5200(uint16_t startaddr, uint16_t endaddr) {
//****************************************** //******************************************
void readROM_5200() { void readROM_5200() {
strcpy(fileName, romName); createFolder("5200", "ROM", romName, "a52");
strcat(fileName, ".a52");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "5200/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -342,14 +342,7 @@ void bankSwitch_7800(uint16_t addr) {
//****************************************** //******************************************
void readROM_7800() { void readROM_7800() {
strcpy(fileName, romName); createFolder("7800", "ROM", romName, "a78");
strcat(fileName, ".a78");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "7800/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -150,14 +150,7 @@ void readSegment_ARC(uint16_t startaddr, uint16_t endaddr) {
} }
void readROM_ARC() { void readROM_ARC() {
strcpy(fileName, romName); createFolder("ARC", "ROM", romName, "bin");
strcat(fileName, ".bin");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "ARC/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving to ")); print_Msg(F("Saving to "));

View File

@ -364,14 +364,7 @@ void readPorts_C64() {
// GAME HIGH/EXROM LOW: ROML = $8000 // GAME HIGH/EXROM LOW: ROML = $8000
void readROM_C64() { void readROM_C64() {
strcpy(fileName, romName); createFolder("C64", "ROM", romName, "bin");
strcat(fileName, ".bin");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "C64/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -162,15 +162,7 @@ void readSegment_COL(uint32_t startaddr, uint32_t endaddr) {
} }
void readROM_COL() { void readROM_COL() {
strcpy(fileName, romName); createFolder("COL", "ROM", romName, "col");
strcat(fileName, ".col");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
// sprintf(folder, "COL/ROM/%s/%d", romName, foldern);
sprintf(folder, "COL/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -668,6 +668,16 @@ int int_pow(int base, int exp) { // Power for int
} }
#endif #endif
void createFolder(const char* system, const char* subfolder, const char* gameName, const char* fileSuffix) {
snprintf(fileName, FILENAME_LENGTH, "%s.%s", gameName, fileSuffix);
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "%s/%s/%s/%d", system, subfolder, gameName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
}
// move file pointer to first game line with matching letter. If no match is found the last database entry is selected // move file pointer to first game line with matching letter. If no match is found the last database entry is selected
void seek_first_letter_in_database(FsFile& database, byte myLetter) { void seek_first_letter_in_database(FsFile& database, byte myLetter) {
char gamename_str[3]; char gamename_str[3];

View File

@ -392,14 +392,7 @@ uint8_t readData_FAIRCHILD() {
} }
void readROM_FAIRCHILD() { void readROM_FAIRCHILD() {
strcpy(fileName, romName); createFolder("FAIRCHILD", "ROM", romName, "bin");
strcat(fileName, ".bin");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "FAIRCHILD/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving to ")); print_Msg(F("Saving to "));
@ -479,16 +472,8 @@ void readROM_FAIRCHILD() {
wait(); wait();
} }
void read16K_FAIRCHILD() // Read 16K Bytes void read16K_FAIRCHILD() { // Read 16K Bytes
{ createFolder("FAIRCHILD", "ROM", romName, "bin");
strcpy(fileName, romName);
strcat(fileName, ".bin");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "FAIRCHILD/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving to ")); print_Msg(F("Saving to "));

View File

@ -996,7 +996,7 @@ void getCartInfo_GB() {
// ROM banks // ROM banks
romBanks = 2; romBanks = 2;
if(romSize >= 0x01 && romSize <= 0x08) { if (romSize >= 0x01 && romSize <= 0x08) {
romBanks = int_pow(2, romSize + 1); romBanks = int_pow(2, romSize + 1);
} }
@ -1107,14 +1107,7 @@ void getCartInfo_GB() {
// Read ROM // Read ROM
void readROM_GB() { 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
strcpy(fileName, romName); createFolder("GB", "ROM", romName, "gb");
strcat(fileName, ".GB");
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -1322,14 +1315,7 @@ void readSRAM_GB() {
if (lastByte > 0) { if (lastByte > 0) {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("GB", "SAVE", romName, "sav");
strcat(fileName, ".sav");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -1476,14 +1462,7 @@ unsigned long verifySRAM_GB() {
// Read SRAM + FLASH save data of MBC6 // Read SRAM + FLASH save data of MBC6
void readSRAMFLASH_MBC6_GB() { 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
strcpy(fileName, romName); createFolder("GB", "SAVE", romName, "sav");
strcat(fileName, ".sav");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -1711,14 +1690,7 @@ void writeSRAMFLASH_MBC6_GB() {
void readEEPROM_MBC7_GB() { void readEEPROM_MBC7_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
strcpy(fileName, romName); createFolder("GB", "SAVE", romName, "sav");
strcat(fileName, ".sav");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -1932,7 +1904,7 @@ void writeFlash29F_GB(byte MBC, boolean flashErase) {
// ROM banks // ROM banks
romBanks = 2; romBanks = 2;
if(romSize >= 0x01 && romSize <= 0x07) { if (romSize >= 0x01 && romSize <= 0x07) {
romBanks = int_pow(2, romSize + 1); romBanks = int_pow(2, romSize + 1);
} }
@ -2354,7 +2326,7 @@ bool writeCFI_GB() {
// ROM banks // ROM banks
romBanks = 2; romBanks = 2;
if(romSize >= 0x01 && romSize <= 0x07) { if (romSize >= 0x01 && romSize <= 0x07) {
romBanks = int_pow(2, romSize + 1); romBanks = int_pow(2, romSize + 1);
} }
@ -2568,14 +2540,7 @@ bool writeCFI_GB() {
// Read Pelican GBC Device - All Brainboys, MonsterBrains, Codebreakers // Read Pelican GBC Device - All Brainboys, MonsterBrains, Codebreakers
void readPelican_GB() { 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
strcpy(fileName, "Pelican"); createFolder("GB", "ROM", "Pelican", "GB");
strcat(fileName, ".GB");
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/ROM/Pelican/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -3027,14 +2992,7 @@ bool isToggle(byte byte1, byte byte2) {
// Read Mega Memory Card Rom and Save Backup Data // Read Mega Memory Card Rom and Save Backup Data
void readMegaMem_GB() { void readMegaMem_GB() {
// Dump the Rom // Dump the Rom
strcpy(fileName, "Rom"); createFolder("GB", "ROM", "MegaMem", "GB");
strcat(fileName, ".GB");
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GB/ROM/MegaMem/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -3349,10 +3307,6 @@ void writeMegaMem_GB() {
***************************************************/ ***************************************************/
// Read Datel GBC Gameshark Device // Read Datel GBC Gameshark Device
void readGameshark_GB() { void readGameshark_GB() {
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, "Gameshark");
strcat(fileName, ".GB");
word finalAddress = 0x5FFF; word finalAddress = 0x5FFF;
word startAddress = 0x4000; word startAddress = 0x4000;
word bankAddress = 0x7FE1; word bankAddress = 0x7FE1;
@ -3401,11 +3355,8 @@ void readGameshark_GB() {
mainMenu(); mainMenu();
} }
// create a new folder for the rom file // Get name, add extension and convert to char array for sd lib
EEPROM_readAnything(0, foldern); createFolder("GB", "ROM", "Gameshark", "GB");
sprintf(folder, "GB/ROM/Gameshark/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
print_Msg(folder); print_Msg(folder);

View File

@ -821,14 +821,7 @@ void getCartInfo_GBA() {
// Dump ROM // Dump ROM
void readROM_GBA() { 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
strcpy(fileName, romName); createFolder("GBA", "ROM", romName, "gba");
strcat(fileName, ".gba");
// create a new folder for the rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GBA/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
//clear the screen //clear the screen
display_Clear(); display_Clear();
@ -935,14 +928,7 @@ boolean compare_checksum_GBA() {
void readSRAM_GBA(boolean browseFile, uint32_t sramSize, uint32_t pos) { void readSRAM_GBA(boolean browseFile, uint32_t sramSize, uint32_t pos) {
if (browseFile) { if (browseFile) {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("GBA", "SAVE", romName, "srm");
strcat(fileName, ".srm");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// Save location // Save location
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -1076,14 +1062,7 @@ void readFRAM_GBA(unsigned long framSize) {
PORTH &= ~((1 << 0) | (1 << 6)); PORTH &= ~((1 << 0) | (1 << 6));
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("GBA", "SAVE", romName, "srm");
strcat(fileName, ".srm");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// Save location // Save location
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -1480,15 +1459,7 @@ void readFLASH_GBA(boolean browseFile, uint32_t flashSize, uint32_t pos) {
if (browseFile) { if (browseFile) {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("GBA", "SAVE", romName, "fla");
strcat(fileName, ".fla");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// Save location // Save location
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -1724,15 +1695,7 @@ void writeEeprom_GBA(word eepSize) {
// Read eeprom to file // Read eeprom to file
void readEeprom_GBA(word eepSize) { void readEeprom_GBA(word eepSize) {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("GBA", "SAVE", romName, "eep");
strcat(fileName, ".eep");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "GBA/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// Save location // Save location
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -268,13 +268,7 @@ void readRAM_GPC() {
controlIn_SNES(); controlIn_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
strcpy(fileName, "GPC4M.sfc"); createFolder("SNES", "ROM", "GPC4M", "sfc");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "SNES/ROM/%s/%d", "GPC4M", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
//clear the screen //clear the screen
display_Clear(); display_Clear();

View File

@ -303,14 +303,7 @@ void readSegment_INTV(uint32_t startaddr, uint32_t endaddr) {
// MODIFIED READ ROUTINE FOR ALL 10 MAPPERS // MODIFIED READ ROUTINE FOR ALL 10 MAPPERS
void readROM_INTV() { void readROM_INTV() {
strcpy(fileName, romName); createFolder("INTV", "ROM", romName, "int");
strcat(fileName, ".int");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "INTV/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -522,12 +522,7 @@ void getCartInfo_LOOPY() {
void readROM_LOOPY() { void readROM_LOOPY() {
dataIn_LOOPY(); dataIn_LOOPY();
sprintf(fileName, "%s.bin", romName); createFolder("LOOPY", "ROM", romName, "bin");
EEPROM_readAnything(0, foldern);
sprintf(folder, "LOOPY/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -657,12 +652,7 @@ void formatSRAM_LOOPY() {
void readSRAM_LOOPY() { void readSRAM_LOOPY() {
dataIn_LOOPY(); dataIn_LOOPY();
sprintf(fileName, "%s.sav", romName); createFolder("LOOPY", "SAVE", romName, "sav");
EEPROM_readAnything(0, foldern);
sprintf(folder, "LOOPY/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
foldern = foldern + 1; foldern = foldern + 1;
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);

View File

@ -1424,14 +1424,7 @@ void readROM_MD() {
dataIn_MD(); dataIn_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
strcpy(fileName, romName); createFolder("MD", "ROM", romName, "BIN");
strcat(fileName, ".BIN");
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(folder, "MD/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -1853,14 +1846,7 @@ void readSram_MD() {
dataIn_MD(); dataIn_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
strcpy(fileName, romName); createFolder("MD", "SAVE", romName, "srm");
strcat(fileName, ".srm");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "MD/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -2714,15 +2700,7 @@ void readEEP_MD() {
dataIn_MD(); dataIn_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
strcpy(fileName, romName); createFolder("MD", "SAVE", romName, "eep");
strcat(fileName, ".eep");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sd.chdir();
sprintf(folder, "MD/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -2814,14 +2792,7 @@ void readBram_MD() {
dataIn_MD(); dataIn_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
strcpy(fileName, "Cart.brm"); createFolder("MD", "RAM", "Cart", "brm");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sd.chdir();
sprintf(folder, "MD/RAM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -2909,14 +2880,7 @@ void readRealtec_MD() {
dataIn_MD(); dataIn_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
strcpy(fileName, romName); createFolder("MD", "ROM", romName, "MD");
strcat(fileName, ".MD");
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(folder, "MD/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -343,14 +343,7 @@ void readROM_MSX() {
println_Msg(F("ROM SIZE 0K")); println_Msg(F("ROM SIZE 0K"));
display_Update(); display_Update();
} else { } else {
strcpy(fileName, romName); createFolder("MSX", "ROM", romName, "bin");
strcat(fileName, ".bin");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "MSX/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -2412,21 +2412,16 @@ void readSram(unsigned long sramSize, byte flashramType) {
} }
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); const char* suffix;
if (saveType == 4) { if (saveType == 4) {
strcat(fileName, ".fla"); suffix = "fla";
} else if (saveType == 1) { } else if (saveType == 1) {
strcat(fileName, ".sra"); suffix = "sra";
} else { } else {
print_FatalError(F("Savetype Error")); print_FatalError(F("Savetype Error"));
} }
createFolder("N64", "SAVE", romName, suffix);
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "N64/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -2821,14 +2816,7 @@ void getFramType() {
// dumping rom slow // dumping rom slow
void readRom_N64() { void readRom_N64() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("N64", "ROM", romName, "Z64");
strcat(fileName, ".Z64");
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(folder, "N64/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// clear the screen // clear the screen
// display_Clear(); // display_Clear();
@ -2876,14 +2864,7 @@ void readRom_N64() {
// dumping rom fast // dumping rom fast
uint32_t readRom_N64() { uint32_t readRom_N64() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("N64", "ROM", romName, "Z64");
strcat(fileName, ".Z64");
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(folder, "N64/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// clear the screen // clear the screen
// display_Clear(); // display_Clear();

View File

@ -710,14 +710,7 @@ bool selectMapping(FsFile& database) {
void read_NES(const char* fileSuffix, const byte* header, const uint8_t headersize, const boolean renamerom) { void read_NES(const char* fileSuffix, const byte* header, const uint8_t headersize, const boolean renamerom) {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("NES", "ROM", romName, fileSuffix);
strcat(fileName, fileSuffix);
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(folder, "NES/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -770,11 +763,11 @@ void read_NES(const char* fileSuffix, const byte* header, const uint8_t headersi
} }
void readRom_NES() { void readRom_NES() {
read_NES(".nes", iNES_HEADER, 16, true); read_NES("nes", iNES_HEADER, 16, true);
} }
void readRaw_NES() { void readRaw_NES() {
read_NES(".bin", NULL, 0, false); read_NES("bin", NULL, 0, false);
} }
/****************************************** /******************************************

View File

@ -208,13 +208,7 @@ void readROM_NGP(char* outPathBuf, size_t bufferSize) {
changeSize_NGP(); changeSize_NGP();
// generate fullname of rom file // generate fullname of rom file
snprintf(fileName, FILENAME_LENGTH, "%s.ngp", romName); createFolder("NGP", "ROM", romName, "ngp");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "NGP/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// filling output file path to buffer // filling output file path to buffer
if (outPathBuf != NULL && bufferSize > 0) if (outPathBuf != NULL && bufferSize > 0)
@ -263,13 +257,7 @@ void scanChip_NGP() {
display_Clear(); display_Clear();
// generate name of report file // generate name of report file
snprintf(fileName, FILENAME_LENGTH, "%s.txt", romName); createFolder("NGP", "ROM", romName, "txt");
// create a new folder to save report file
EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "NGP/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
print_Msg(F("Saving chip report to ")); print_Msg(F("Saving chip report to "));
print_Msg(folder); print_Msg(folder);

View File

@ -212,14 +212,7 @@ void bankSwitch_ODY2(uint16_t addr, uint8_t data) {
} }
void readROM_ODY2() { void readROM_ODY2() {
strcpy(fileName, romName); createFolder("ODY2", "ROM", romName, "bin");
strcat(fileName, ".bin");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "ODY2/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving to ")); print_Msg(F("Saving to "));

View File

@ -751,15 +751,7 @@ void read_rom_PCE(void) {
println_Msg(F("KB")); println_Msg(F("KB"));
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, "PCEROM"); createFolder("PCE", "ROM", "PCEROM", "pce");
strcat(fileName, ".pce");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sd.chdir("/");
sprintf(folder, "PCE/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
print_Msg(F("Saving ROM to ")); print_Msg(F("Saving ROM to "));
print_Msg(folder); print_Msg(folder);

View File

@ -425,12 +425,7 @@ void readSingleROM_PCW() {
println_Msg(FS(FSTRING_EMPTY)); println_Msg(FS(FSTRING_EMPTY));
// Create file // Create file
strcpy(fileName, romName); createFolder("PCW", "ROM", romName, "pcw");
strcat(fileName, ".pcw");
EEPROM_readAnything(0, foldern);
sprintf(folder, "PCW/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
print_Msg(folder); print_Msg(folder);
@ -564,12 +559,7 @@ void readMultiROM_PCW() {
println_Msg(FS(FSTRING_EMPTY)); println_Msg(FS(FSTRING_EMPTY));
// Create file // Create file
strcpy(fileName, romName); createFolder("PCW", "ROM", romName, "pcw");
strcat(fileName, ".pcw");
EEPROM_readAnything(0, foldern);
sprintf(folder, "PCW/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
print_Msg(folder); print_Msg(folder);
@ -633,13 +623,7 @@ void readMultiROM_PCW() {
//****************************************** //******************************************
void readSRAM_PCW() { // readSRAM_1A() void readSRAM_PCW() { // readSRAM_1A()
strcpy(fileName, romName); createFolder("PCW", "SAVE", romName, "srm");
strcat(fileName, ".srm");
EEPROM_readAnything(0, foldern);
sprintf(folder, "PCW/SAVE/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
foldern = foldern + 1; foldern = foldern + 1;
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);

View File

@ -239,14 +239,7 @@ void writeData_POKE(uint32_t addr, uint8_t data) {
//****************************************** //******************************************
void readROM_POKE() { void readROM_POKE() {
strcpy(fileName, romName); createFolder("POKE", "ROM", romName, "min");
strcat(fileName, ".min");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "POKE/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -882,14 +882,7 @@ void readROM_SFM() {
controlIn_SFM(); controlIn_SFM();
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); createFolder("NP", "ROM", romName, "sfc");
strcat(fileName, ".sfc");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "NP/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
//clear the screen //clear the screen
display_Clear(); display_Clear();

View File

@ -550,24 +550,14 @@ void getCartInfo_SMS() {
//****************************************** //******************************************
void readROM_SMS() { void readROM_SMS() {
// Get name, add extension depending on the system and convert to char array for sd lib // Get name, add extension depending on the system and convert to char array for sd lib
EEPROM_readAnything(0, foldern);
strcpy(fileName, romName);
if (system_sms) { if (system_sms) {
strcat(fileName, ".sms"); createFolder("SMS", "ROM", romName, "sms");
sprintf(folder, "SMS/ROM/%s/%d", romName, foldern);
} else if (system_gg) { } else if (system_gg) {
strcat(fileName, ".gg"); createFolder("GG", "ROM", romName, "gg");
sprintf(folder, "GG/ROM/%s/%d", romName, foldern);
} else { } else {
strcat(fileName, ".sg"); createFolder("SG1000", "ROM", romName, "sg");
sprintf(folder, "SG1000/ROM/%s/%d", romName, foldern);
} }
// Create a new folder
sd.chdir("/");
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
print_Msg(folder); print_Msg(folder);
@ -658,20 +648,14 @@ void readROM_SMS() {
///***************************************** ///*****************************************
void readSRAM_SMS() { void readSRAM_SMS() {
// Get name, add extension and convert to char array for sd lib // Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName); const char* system;
strcat(fileName, ".sav");
EEPROM_readAnything(0, foldern);
if (system_gg) { if (system_gg) {
sprintf(folder, "GG/SAVE/%s/%d", romName, foldern); system = "GG";
} else { } else {
sprintf(folder, "SMS/SAVE/%s/%d", romName, foldern); system = "SMS";
} }
createFolder(system, "SAVE", romName, "sav");
// Create a new folder
sd.chdir("/");
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -1291,14 +1291,7 @@ void readROM_SNES() {
controlIn_SNES(); controlIn_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
strcpy(fileName, romName); createFolder("SNES", "ROM", romName, "sfc");
strcat(fileName, ".sfc");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "SNES/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
//clear the screen //clear the screen
display_Clear(); display_Clear();
@ -1657,14 +1650,7 @@ void readSRAM() {
controlIn_SNES(); controlIn_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
strcpy(fileName, romName); createFolder("SNES", "SAVE", romName, "srm");
strcat(fileName, ".srm");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "SNES/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;

View File

@ -167,11 +167,7 @@ void readSlot(bool cartSlot) {
// Read ST rom to SD card // Read ST rom to SD card
void readRom_ST(unsigned int bankStart, unsigned int bankEnd) { 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
EEPROM_readAnything(0, foldern); createFolder("ST", "ROM", "SUFAMI_TURBO", "st");
strcpy(fileName, "SUFAMI_TURBO.st");
sprintf(folder, "ST/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -288,13 +288,7 @@ void readSRAM_SV() {
controlIn_SNES(); controlIn_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
strcpy(fileName, "BSX.srm"); createFolder("SNES", "SAVE", "BSX", "srm");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "SNES/SAVE/BSX/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
// write new folder number back to eeprom // write new folder number back to eeprom
foldern = foldern + 1; foldern = foldern + 1;
@ -419,13 +413,7 @@ void readROM_SV() {
controlIn_SNES(); controlIn_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
strcpy(fileName, "MEMPACK.bs"); createFolder("SNES", "ROM", "MEMPACK", "bs");
// create a new folder for the save file
EEPROM_readAnything(0, foldern);
sprintf(folder, "SNES/ROM/%s/%d", "MEMPACK", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
//clear the screen //clear the screen
display_Clear(); display_Clear();

View File

@ -410,13 +410,7 @@ void getCartInfo_VB() {
void readROM_VB() { void readROM_VB() {
dataIn_VB(); dataIn_VB();
strcpy(fileName, romName); createFolder("VBOY", "ROM", romName, "vb");
strcat(fileName, ".vb");
EEPROM_readAnything(0, foldern);
sprintf(folder, "VBOY/ROM/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);
@ -513,13 +507,7 @@ void writeSRAM_VB() {
void readSRAM_VB() { void readSRAM_VB() {
dataIn_VB(); dataIn_VB();
strcpy(fileName, romName); createFolder("VBOY", "SAVE", romName, "srm");
strcat(fileName, ".srm");
EEPROM_readAnything(0, foldern);
sprintf(folder, "VBOY/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
foldern = foldern + 1; foldern = foldern + 1;
EEPROM_writeAnything(0, foldern); EEPROM_writeAnything(0, foldern);

View File

@ -196,14 +196,7 @@ void readSegment_VECTREX(uint16_t startaddr, uint16_t endaddr) {
//****************************************** //******************************************
void readROM_VECTREX() { void readROM_VECTREX() {
strcpy(fileName, romName); createFolder("VECTREX", "ROM", romName, "vec");
strcat(fileName, ".vec");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
sprintf(folder, "VECTREX/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);

View File

@ -561,13 +561,7 @@ static uint16_t readROM_WS(char *outPathBuf, size_t bufferSize) {
static void readSRAM_WS() { static void readSRAM_WS() {
// generate fullname of rom file // generate fullname of rom file
snprintf(fileName, FILENAME_LENGTH, "%s.sav", romName); createFolder("WS", "SAVE", romName, "save");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "WS/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving ")); print_Msg(F("Saving "));
@ -706,13 +700,7 @@ static void writeSRAM_WS() {
static void readEEPROM_WS() { static void readEEPROM_WS() {
// generate fullname of eep file // generate fullname of eep file
snprintf(fileName, FILENAME_LENGTH, "%s.eep", romName); createFolder("WS", "SAVE", romName, "eep");
// create a new folder for storing eep file
EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "WS/SAVE/%s/%d", romName, foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_Msg(F("Saving ")); print_Msg(F("Saving "));

View File

@ -185,15 +185,7 @@ uint8_t readByte_WSV(uint32_t addr) {
//****************************************** //******************************************
void readROM_WSV() { void readROM_WSV() {
strcpy(fileName, romName); createFolder("WSV", "ROM", romName, "sv");
strcat(fileName, ".sv");
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
//sprintf(folder, "WSV/ROM/%s/%d", romName, foldern);
sprintf(folder, "WSV/ROM/%d", foldern);
sd.mkdir(folder, true);
sd.chdir(folder);
display_Clear(); display_Clear();
print_STR(saving_to_STR, 0); print_STR(saving_to_STR, 0);