diff --git a/checkpoint.cpp b/checkpoint.cpp index 11f211f..889a0a9 100644 --- a/checkpoint.cpp +++ b/checkpoint.cpp @@ -1,7 +1,13 @@ -#include +#include +#include "hardware.h" #include "sdtape.h" #include "checkpoint.h" -#include "hardware.h" + +#if defined(SD_CS) +#include +#elif defined(USE_SPIFFS) +#include +#endif static char buf[32]; static char chkpt[] = { "CHKPOINT" }; @@ -10,7 +16,12 @@ static int cpid = 0; const char *checkpoint(sdtape &tape, const char *dir) { tape.stop(); snprintf(buf, sizeof(buf), "%s%s.%03d", dir, chkpt, cpid++); + +#if defined(SD_CS) File file = SD.open(buf, O_WRITE | O_CREAT | O_TRUNC); +#elif defined(USE_SPIFFS) + File file = SPIFFS.open(buf, FILE_WRITE); +#endif hardware_checkpoint(file); file.close(); tape.start(dir); @@ -20,7 +31,12 @@ const char *checkpoint(sdtape &tape, const char *dir) { void restore(sdtape &tape, const char *dir, const char *filename) { tape.stop(); snprintf(buf, sizeof(buf), "%s%s", dir, filename); + +#if defined(SD_CS) File file = SD.open(buf, O_READ); +#elif defined(USE_SPIFFS) + File file = SPIFFS.open(buf, FILE_READ); +#endif hardware_restore(file); file.close(); int n = sscanf(buf + strlen(dir), "%[A-Z0-9].%d", chkpt, &cpid); diff --git a/hardware.cpp b/hardware.cpp index 63cc151..d0421d7 100644 --- a/hardware.cpp +++ b/hardware.cpp @@ -1,22 +1,30 @@ +#include "hardware.h" + #include + +#if defined(SD_CS) #include +#endif + +#if defined(USE_SPIFFS) +#include +#endif + #include + +#if defined(SPIRAM_CS) #include +#include "spiram.h" +spiram sram(SPIRAM_SIZE); +#endif #include "ps2drv.h" #include "memory.h" -#include "spiram.h" - #include "CPU.h" -#include "hardware.h" Memory memory; PS2Driver ps2; -#if defined(SPIRAM_CS) -spiram sram(SPIRAM_SIZE); -#endif - UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST); static CPU *_cpu; @@ -36,6 +44,10 @@ bool hardware_reset() { pinMode(SPI_CS, OUTPUT); // without this, the SPI-RAM isn't seen #endif +#if defined(USE_SPIFFS) + success = SPIFFS.begin(); +#endif + #if defined(TFT_BACKLIGHT) digitalWrite(TFT_BACKLIGHT, HIGH); #endif diff --git a/hardware.h b/hardware.h index 3549505..1ac43e7 100644 --- a/hardware.h +++ b/hardware.h @@ -30,6 +30,7 @@ #define SPIRAM_SIZE 65536 // "tape" storage... +<<<<<<< HEAD #define SD_CS PF_3 //#define SD_CS PE_0 #define SD_SPI 1 diff --git a/sdtape.cpp b/sdtape.cpp index d5524e1..1564d5a 100644 --- a/sdtape.cpp +++ b/sdtape.cpp @@ -1,11 +1,20 @@ +#include "hardware.h" + +#if defined(SD_CS) #include +#define DISK SD +#elif defined(USE_SPIFFS) +#include +#define DISK SPIFFS +#endif + #include "sdtape.h" static File file, dir; void sdtape::start(const char *programs) { - dir = SD.open(programs); + dir = DISK.open(programs); _pos = _len = 0; }