From d9daadb1f982d447459439bda5766038adea503e Mon Sep 17 00:00:00 2001 From: Vincent Pelletier Date: Fri, 28 Oct 2022 13:03:01 +0000 Subject: [PATCH] N64.ino: Build eeprom path and file name with snprintf_P So the format string is stored in flash rather than in ram. The gain from doing just one like this is not much, to be done in more places. --- Cart_Reader/N64.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Cart_Reader/N64.ino b/Cart_Reader/N64.ino index cfad566..912c781 100644 --- a/Cart_Reader/N64.ino +++ b/Cart_Reader/N64.ino @@ -50,6 +50,9 @@ String CRC1 = ""; String CRC2 = ""; #endif +static const char N64_EEP_FILENAME_FMT[] PROGMEM = "%s.eep"; +static const char N64_SAVE_DIRNAME_FMT[] PROGMEM = "N64/SAVE/%s/%d"; + /****************************************** Menu *****************************************/ @@ -2687,12 +2690,11 @@ void writeEeprom() { void readEeprom() { if ((saveType == 5) || (saveType == 6)) { // Get name, add extension and convert to char array for sd lib - strcpy(fileName, romName); - strcat(fileName, ".eep"); + snprintf_P(fileName, sizeof(fileName), N64_EEP_FILENAME_FMT, romName); // create a new folder for the save file EEPROM_readAnything(0, foldern); - sprintf(folder, "N64/SAVE/%s/%d", romName, foldern); + snprintf_P(folder, sizeof(folder), N64_SAVE_DIRNAME_FMT, romName, foldern); sd.mkdir(folder, true); sd.chdir(folder);