diff options
author | smesgr9000 <smesgr9000> | 2024-06-01 09:58:23 +0200 |
---|---|---|
committer | smesgr9000 <smesgr9000> | 2024-06-01 09:58:23 +0200 |
commit | ad69abdf57d49e27a0670393c9a42a0c196ba17d (patch) | |
tree | 74cc20ea4e866b0fa7250dd1f33475174784a13b /Cart_Reader | |
parent | 22e06d8ec1c2fdbd3d02f72e49a3b41cf88b6033 (diff) | |
download | cartreader-ad69abdf57d49e27a0670393c9a42a0c196ba17d.tar.gz cartreader-ad69abdf57d49e27a0670393c9a42a0c196ba17d.zip |
use common function to create file/folder and increment foldern counter
Diffstat (limited to 'Cart_Reader')
-rw-r--r-- | Cart_Reader/N64.ino | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/Cart_Reader/N64.ino b/Cart_Reader/N64.ino index dab9c8f..e8d08a1 100644 --- a/Cart_Reader/N64.ino +++ b/Cart_Reader/N64.ino @@ -48,9 +48,6 @@ String CRC2 = ""; unsigned long flashSize;
#endif
-static const char N64_EEP_FILENAME_FMT[] PROGMEM = "%s.eep";
-static const char N64_SAVE_DIRNAME_FMT[] PROGMEM = "N64/SAVE/%s/%d";
-
/******************************************
Menu
*****************************************/
@@ -2281,22 +2278,7 @@ boolean readEepromPageList(byte* output, byte page_number, byte page_count) { void readEeprom() {
if ((saveType == 5) || (saveType == 6)) {
// Get name, add extension and convert to char array for sd lib
- snprintf_P(fileName, sizeof(fileName), N64_EEP_FILENAME_FMT, romName);
-
- // create a new folder for the save file
- EEPROM_readAnything(0, foldern);
- snprintf_P(folder, sizeof(folder), N64_SAVE_DIRNAME_FMT, romName, foldern);
- sd.mkdir(folder, true);
- sd.chdir(folder);
-
- // write new folder number back to eeprom
- foldern = foldern + 1;
- EEPROM_writeAnything(0, foldern);
-
- // Open file on sd card
- if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
- print_FatalError(create_file_STR);
- }
+ createFolderAndOpenFile("N64", "SAVE", romName, "eep");
for (int i = 0; i < eepPages; i += sizeof(sdBuffer) / 8) {
// If any missing bytes error out
@@ -2421,16 +2403,7 @@ void readSram(unsigned long sramSize, byte flashramType) { } else {
print_FatalError(F("Savetype Error"));
}
- createFolder("N64", "SAVE", romName, suffix);
-
- // write new folder number back to eeprom
- foldern = foldern + 1;
- EEPROM_writeAnything(0, foldern);
-
- // Open file on sd card
- if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
- print_FatalError(sd_error_STR);
- }
+ createFolderAndOpenFile("N64", "SAVE", romName, suffix);
for (unsigned long currByte = sramBase; currByte < (sramBase + (sramSize / flashramType)); currByte += offset) {
// Set the address
|