Skip to content

Commit

Permalink
replace custom folder creation function with common
Browse files Browse the repository at this point in the history
  • Loading branch information
smesgr9000 committed May 26, 2024
1 parent 41182a7 commit 78bf146
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 54 deletions.
35 changes: 4 additions & 31 deletions Cart_Reader/N64.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4194,22 +4194,8 @@ void resetGameshark_N64() {

// Read rom and save to the SD card
void backupGameshark_N64() {
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(fileName, "GS%d", foldern);
strcat(fileName, ".z64");
sd.mkdir("N64/ROM/Gameshark", true);
sd.chdir("N64/ROM/Gameshark");

display_Clear();
print_Msg(F("Saving "));
print_Msg(fileName);
println_Msg(F("..."));
display_Update();

// write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
createFolder("N64", "ROM", "GameShark", "z64");
printAndIncrementFolder(true);

// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down Expand Up @@ -4577,21 +4563,8 @@ void resetXplorer_N64() {
// Read rom and save to the SD card
void backupXplorer_N64() {
// create a new folder
EEPROM_readAnything(0, foldern);
sprintf(fileName, "XP64-%d", foldern);
strcat(fileName, ".z64");
sd.mkdir("N64/ROM/XPLORER64", true);
sd.chdir("N64/ROM/XPLORER64");

display_Clear();
print_Msg(F("Saving "));
print_Msg(fileName);
println_Msg(F("..."));
display_Update();

// write new folder number back to eeprom
foldern = foldern + 1;
EEPROM_writeAnything(0, foldern);
createFolder("N64", "ROM", "XPLORER64", "z64");
printAndIncrementFolder(true);

// Open file on sd card
if (!myFile.open(fileName, O_RDWR | O_CREAT)) {
Expand Down
29 changes: 6 additions & 23 deletions Cart_Reader/SUPRACAN.ino
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,10 @@ void suprAcanMenu() {
static void readROM_Acan() {
uint32_t crc32 = 0xffffffff;

EEPROM_readAnything(0, foldern);
snprintf(folder, FILEPATH_LENGTH, "/ACAN/ROM/%d", foldern);

createFolder("/ACAN", "ROM", "rom", "bin");
printAndIncrementFolder(true);

sd.mkdir(folder, true);
sd.chdir(folder);

if (!myFile.open("rom.bin", O_RDWR | O_CREAT))
if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR);

draw_progressbar(0, cartSize);
Expand Down Expand Up @@ -185,16 +180,10 @@ static void readROM_Acan() {
}

static void readSRAM_Acan() {
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
snprintf(folder, FILEPATH_LENGTH, "/ACAN/SAVE/%d", foldern);

createFolder("/ACAN", "SAVE", "save", "bin");
printAndIncrementFolder(true);

sd.mkdir(folder, true);
sd.chdir(folder);

if (!myFile.open("save.bin", O_RDWR | O_CREAT))
if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR);

dataIn_MD();
Expand Down Expand Up @@ -276,16 +265,10 @@ static void verifySRAM_Acan() {
}

static void readUM6650() {
// create a new folder for storing rom file
EEPROM_readAnything(0, foldern);
snprintf(folder, sizeof(folder), "/ACAN/UM6650/%d", foldern);

createFolder("/ACAN", "UM6650", "UM6650", "bin");
printAndIncrementFolder(true);

sd.mkdir(folder, true);
sd.chdir(folder);

if (!myFile.open("UM6650.bin", O_RDWR | O_CREAT))
if (!myFile.open(fileName, O_RDWR | O_CREAT))
print_FatalError(create_file_STR);

for (uint16_t i = 0; i < 256; i++) {
Expand Down

0 comments on commit 78bf146

Please sign in to comment.