mirror of
https://github.com/sanni/cartreader.git
synced 2024-11-15 01:15:06 +01:00
use common function to create file/folder and increment foldern counter
This commit is contained in:
parent
22e06d8ec1
commit
ad69abdf57
@ -48,9 +48,6 @@ String CRC2 = "";
|
|||||||
unsigned long flashSize;
|
unsigned long flashSize;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const char N64_EEP_FILENAME_FMT[] PROGMEM = "%s.eep";
|
|
||||||
static const char N64_SAVE_DIRNAME_FMT[] PROGMEM = "N64/SAVE/%s/%d";
|
|
||||||
|
|
||||||
/******************************************
|
/******************************************
|
||||||
Menu
|
Menu
|
||||||
*****************************************/
|
*****************************************/
|
||||||
@ -2281,22 +2278,7 @@ boolean readEepromPageList(byte* output, byte page_number, byte page_count) {
|
|||||||
void readEeprom() {
|
void readEeprom() {
|
||||||
if ((saveType == 5) || (saveType == 6)) {
|
if ((saveType == 5) || (saveType == 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
|
||||||
snprintf_P(fileName, sizeof(fileName), N64_EEP_FILENAME_FMT, romName);
|
createFolderAndOpenFile("N64", "SAVE", romName, "eep");
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < eepPages; i += sizeof(sdBuffer) / 8) {
|
for (int i = 0; i < eepPages; i += sizeof(sdBuffer) / 8) {
|
||||||
// If any missing bytes error out
|
// If any missing bytes error out
|
||||||
@ -2421,16 +2403,7 @@ void readSram(unsigned long sramSize, byte flashramType) {
|
|||||||
} else {
|
} else {
|
||||||
print_FatalError(F("Savetype Error"));
|
print_FatalError(F("Savetype Error"));
|
||||||
}
|
}
|
||||||
createFolder("N64", "SAVE", romName, suffix);
|
createFolderAndOpenFile("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);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned long currByte = sramBase; currByte < (sramBase + (sramSize / flashramType)); currByte += offset) {
|
for (unsigned long currByte = sramBase; currByte < (sramBase + (sramSize / flashramType)); currByte += offset) {
|
||||||
// Set the address
|
// Set the address
|
||||||
|
Loading…
Reference in New Issue
Block a user