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() {
strcpy(fileName, romName);
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);
createFolder("ATARI", "ROM", romName, "a26");
display_Clear();
print_Msg(F("Saving to "));

View File

@ -216,14 +216,7 @@ void readSegment_5200(uint16_t startaddr, uint16_t endaddr) {
//******************************************
void readROM_5200() {
strcpy(fileName, romName);
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);
createFolder("5200", "ROM", romName, "a52");
display_Clear();
print_STR(saving_to_STR, 0);

View File

@ -342,14 +342,7 @@ void bankSwitch_7800(uint16_t addr) {
//******************************************
void readROM_7800() {
strcpy(fileName, romName);
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);
createFolder("7800", "ROM", romName, "a78");
display_Clear();
print_STR(saving_to_STR, 0);

View File

@ -150,14 +150,7 @@ void readSegment_ARC(uint16_t startaddr, uint16_t endaddr) {
}
void readROM_ARC() {
strcpy(fileName, romName);
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);
createFolder("ARC", "ROM", romName, "bin");
display_Clear();
print_Msg(F("Saving to "));

View File

@ -364,14 +364,7 @@ void readPorts_C64() {
// GAME HIGH/EXROM LOW: ROML = $8000
void readROM_C64() {
strcpy(fileName, romName);
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);
createFolder("C64", "ROM", romName, "bin");
display_Clear();
print_STR(saving_to_STR, 0);

View File

@ -162,15 +162,7 @@ void readSegment_COL(uint32_t startaddr, uint32_t endaddr) {
}
void readROM_COL() {
strcpy(fileName, romName);
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);
createFolder("COL", "ROM", romName, "col");
display_Clear();
print_STR(saving_to_STR, 0);

View File

@ -668,6 +668,16 @@ int int_pow(int base, int exp) { // Power for int
}
#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
void seek_first_letter_in_database(FsFile& database, byte myLetter) {
char gamename_str[3];

View File

@ -392,14 +392,7 @@ uint8_t readData_FAIRCHILD() {
}
void readROM_FAIRCHILD() {
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);
createFolder("FAIRCHILD", "ROM", romName, "bin");
display_Clear();
print_Msg(F("Saving to "));
@ -479,16 +472,8 @@ void readROM_FAIRCHILD() {
wait();
}
void read16K_FAIRCHILD() // Read 16K Bytes
{
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);
void read16K_FAIRCHILD() { // Read 16K Bytes
createFolder("FAIRCHILD", "ROM", romName, "bin");
display_Clear();
print_Msg(F("Saving to "));

View File

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

View File

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

View File

@ -268,13 +268,7 @@ void readRAM_GPC() {
controlIn_SNES();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, "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);
createFolder("SNES", "ROM", "GPC4M", "sfc");
//clear the screen
display_Clear();

View File

@ -303,14 +303,7 @@ void readSegment_INTV(uint32_t startaddr, uint32_t endaddr) {
// MODIFIED READ ROUTINE FOR ALL 10 MAPPERS
void readROM_INTV() {
strcpy(fileName, romName);
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);
createFolder("INTV", "ROM", romName, "int");
display_Clear();
print_STR(saving_to_STR, 0);

View File

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

View File

@ -1424,14 +1424,7 @@ void readROM_MD() {
dataIn_MD();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("MD", "ROM", romName, "BIN");
display_Clear();
print_STR(saving_to_STR, 0);
@ -1853,14 +1846,7 @@ void readSram_MD() {
dataIn_MD();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("MD", "SAVE", romName, "srm");
// write new folder number back to eeprom
foldern = foldern + 1;
@ -2714,15 +2700,7 @@ void readEEP_MD() {
dataIn_MD();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("MD", "SAVE", romName, "eep");
// write new folder number back to eeprom
foldern = foldern + 1;
@ -2814,14 +2792,7 @@ void readBram_MD() {
dataIn_MD();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, "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);
createFolder("MD", "RAM", "Cart", "brm");
// write new folder number back to eeprom
foldern = foldern + 1;
@ -2909,14 +2880,7 @@ void readRealtec_MD() {
dataIn_MD();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("MD", "ROM", romName, "MD");
display_Clear();
print_STR(saving_to_STR, 0);

View File

@ -343,14 +343,7 @@ void readROM_MSX() {
println_Msg(F("ROM SIZE 0K"));
display_Update();
} else {
strcpy(fileName, romName);
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);
createFolder("MSX", "ROM", romName, "bin");
display_Clear();
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
strcpy(fileName, romName);
const char* suffix;
if (saveType == 4) {
strcat(fileName, ".fla");
suffix = "fla";
} else if (saveType == 1) {
strcat(fileName, ".sra");
suffix = "sra";
} else {
print_FatalError(F("Savetype Error"));
}
// 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);
createFolder("N64", "SAVE", romName, suffix);
// write new folder number back to eeprom
foldern = foldern + 1;
@ -2821,14 +2816,7 @@ void getFramType() {
// dumping rom slow
void readRom_N64() {
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("N64", "ROM", romName, "Z64");
// clear the screen
// display_Clear();
@ -2876,14 +2864,7 @@ void readRom_N64() {
// dumping rom fast
uint32_t readRom_N64() {
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("N64", "ROM", romName, "Z64");
// clear the screen
// display_Clear();

View File

@ -709,15 +709,8 @@ bool selectMapping(FsFile& database) {
}
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
strcpy(fileName, romName);
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);
// Get name, add extension and convert to char array for sd lib
createFolder("NES", "ROM", romName, fileSuffix);
display_Clear();
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() {
read_NES(".nes", iNES_HEADER, 16, true);
read_NES("nes", iNES_HEADER, 16, true);
}
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();
// generate fullname of rom file
snprintf(fileName, FILENAME_LENGTH, "%s.ngp", romName);
// 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);
createFolder("NGP", "ROM", romName, "ngp");
// filling output file path to buffer
if (outPathBuf != NULL && bufferSize > 0)
@ -263,13 +257,7 @@ void scanChip_NGP() {
display_Clear();
// generate name of report file
snprintf(fileName, FILENAME_LENGTH, "%s.txt", romName);
// 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);
createFolder("NGP", "ROM", romName, "txt");
print_Msg(F("Saving chip report to "));
print_Msg(folder);

View File

@ -212,14 +212,7 @@ void bankSwitch_ODY2(uint16_t addr, uint8_t data) {
}
void readROM_ODY2() {
strcpy(fileName, romName);
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);
createFolder("ODY2", "ROM", romName, "bin");
display_Clear();
print_Msg(F("Saving to "));

View File

@ -751,15 +751,7 @@ void read_rom_PCE(void) {
println_Msg(F("KB"));
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, "PCEROM");
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);
createFolder("PCE", "ROM", "PCEROM", "pce");
print_Msg(F("Saving ROM to "));
print_Msg(folder);

View File

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

View File

@ -239,14 +239,7 @@ void writeData_POKE(uint32_t addr, uint8_t data) {
//******************************************
void readROM_POKE() {
strcpy(fileName, romName);
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);
createFolder("POKE", "ROM", romName, "min");
display_Clear();
print_STR(saving_to_STR, 0);

View File

@ -882,14 +882,7 @@ void readROM_SFM() {
controlIn_SFM();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("NP", "ROM", romName, "sfc");
//clear the screen
display_Clear();

View File

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

View File

@ -1291,14 +1291,7 @@ void readROM_SNES() {
controlIn_SNES();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("SNES", "ROM", romName, "sfc");
//clear the screen
display_Clear();
@ -1657,14 +1650,7 @@ void readSRAM() {
controlIn_SNES();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, romName);
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);
createFolder("SNES", "SAVE", romName, "srm");
// write new folder number back to eeprom
foldern = foldern + 1;

View File

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

View File

@ -288,13 +288,7 @@ void readSRAM_SV() {
controlIn_SNES();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, "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);
createFolder("SNES", "SAVE", "BSX", "srm");
// write new folder number back to eeprom
foldern = foldern + 1;
@ -419,13 +413,7 @@ void readROM_SV() {
controlIn_SNES();
// Get name, add extension and convert to char array for sd lib
strcpy(fileName, "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);
createFolder("SNES", "ROM", "MEMPACK", "bs");
//clear the screen
display_Clear();

View File

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

View File

@ -196,14 +196,7 @@ void readSegment_VECTREX(uint16_t startaddr, uint16_t endaddr) {
//******************************************
void readROM_VECTREX() {
strcpy(fileName, romName);
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);
createFolder("VECTREX", "ROM", romName, "vec");
display_Clear();
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() {
// generate fullname of rom file
snprintf(fileName, FILENAME_LENGTH, "%s.sav", romName);
// 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);
createFolder("WS", "SAVE", romName, "save");
display_Clear();
print_Msg(F("Saving "));
@ -706,13 +700,7 @@ static void writeSRAM_WS() {
static void readEEPROM_WS() {
// generate fullname of eep file
snprintf(fileName, FILENAME_LENGTH, "%s.eep", romName);
// 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);
createFolder("WS", "SAVE", romName, "eep");
display_Clear();
print_Msg(F("Saving "));

View File

@ -185,15 +185,7 @@ uint8_t readByte_WSV(uint32_t addr) {
//******************************************
void readROM_WSV() {
strcpy(fileName, romName);
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);
createFolder("WSV", "ROM", romName, "sv");
display_Clear();
print_STR(saving_to_STR, 0);