1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-09 08:49:18 +00:00

checkpoint, tape, etc.

Conflicts:
	checkpoint.cpp
	hardware.h
This commit is contained in:
Stephen Crane 2018-08-14 06:28:03 +01:00
parent 77399f8d43
commit 88b66effb1
4 changed files with 48 additions and 10 deletions

View File

@ -1,7 +1,13 @@
#include <SD.h>
#include <stdint.h>
#include "hardware.h"
#include "sdtape.h"
#include "checkpoint.h"
#include "hardware.h"
#if defined(SD_CS)
#include <SD.h>
#elif defined(USE_SPIFFS)
#include <SPIFFS.h>
#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);

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

@ -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

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;
}