From 0489df7bd44805fe966f1ecb422cac97ebaeb1e7 Mon Sep 17 00:00:00 2001 From: sanni Date: Mon, 26 Jun 2023 15:46:47 +0200 Subject: [PATCH] Revert NES CreateRAMFileInSD function to previous version --- Cart_Reader/Cart_Reader.ino | 2 ++ Cart_Reader/Config.h | 2 +- Cart_Reader/NES.ino | 29 ++++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Cart_Reader/Cart_Reader.ino b/Cart_Reader/Cart_Reader.ino index 0a1ecb5..6722afd 100644 --- a/Cart_Reader/Cart_Reader.ino +++ b/Cart_Reader/Cart_Reader.ino @@ -2081,8 +2081,10 @@ void setup() { #endif #endif +#ifdef ENABLE_VSELECT // Set power to low to protect carts setVoltage(VOLTS_SET_3V3); +#endif #ifdef enable_OLED display.begin(); diff --git a/Cart_Reader/Config.h b/Cart_Reader/Config.h index 0fd78c2..c46d2b2 100644 --- a/Cart_Reader/Config.h +++ b/Cart_Reader/Config.h @@ -267,7 +267,7 @@ * other than HW5 and HW3. */ -#define ENABLE_UPDATER +//#define ENABLE_UPDATER /****/ diff --git a/Cart_Reader/NES.ino b/Cart_Reader/NES.ino index 3803b5f..cff6002 100644 --- a/Cart_Reader/NES.ino +++ b/Cart_Reader/NES.ino @@ -1178,8 +1178,35 @@ void CreateCHRFileInSD() { myFile = createNewFile("CHR", "bin"); } +//createNewFile fails to dump RAM if ROM isn't dumped first +//void CreateRAMFileInSD() { +//myFile = createNewFile("RAM", "bin"); +//} +//Temporary fix void CreateRAMFileInSD() { - myFile = createNewFile("RAM", "bin"); + char fileCount[3]; + strcpy(fileName, "RAM"); + strcat(fileName, ".bin"); + for (byte i = 0; i < 100; i++) { + if (!sd.exists(fileName)) { + myFile = sd.open(fileName, O_RDWR | O_CREAT); + break; + } + sprintf(fileCount, "%02d", i); + strcpy(fileName, "RAM."); + strcat(fileName, fileCount); + strcat(fileName, ".bin"); + } + if (!myFile) { + LED_RED_ON; + + display_Clear(); + println_Msg(F("RAM FILE FAILED!")); + display_Update(); + //print_Error(F("SD Error"), true); + + LED_RED_OFF; + } } #ifndef nointro