1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-21 12:29:51 +00:00

checkpoint, tape, etc.

This commit is contained in:
Stephen Crane 2018-08-14 06:28:03 +01:00
parent 384d14b2eb
commit 5f0e16697d
4 changed files with 47 additions and 12 deletions

View File

@ -1,9 +1,13 @@
#include <SD.h>
#include <stdint.h>
#include "hardware.h"
#include "sdtape.h"
#include "checkpoint.h"
#include "hardware.h"
#ifdef notdef
#if defined(SD_CS)
#include <SD.h>
#elif defined(USE_SPIFFS)
#include <SPIFFS.h>
#endif
static char buf[32];
static char chkpt[] = { "CHKPOINT" };
@ -12,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);
@ -22,11 +31,15 @@ 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);
cpid = (n == 1)? 0: cpid+1;
tape.start(dir);
}
#endif

View File

@ -1,22 +1,30 @@
#include "hardware.h"
#include <SPI.h>
#if defined(SD_CS)
#include <SD.h>
#endif
#if defined(USE_SPIFFS)
#include <SPIFFS.h>
#endif
#include <UTFT.h>
#if defined(SPIRAM_CS)
#include <SpiRAM.h>
#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

View File

@ -22,6 +22,7 @@
// "tape" storage...
#undef SD_CS
#define USE_SPIFFS 1
bool hardware_reset();
void hardware_init(class CPU &);

View File

@ -1,11 +1,20 @@
#include "hardware.h"
#if defined(SD_CS)
#include <SD.h>
#define DISK SD
#elif defined(USE_SPIFFS)
#include <SPIFFS.h>
#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;
}