1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-26 14:29:31 +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 "sdtape.h"
#include "checkpoint.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 buf[32];
static char chkpt[] = { "CHKPOINT" }; static char chkpt[] = { "CHKPOINT" };
@ -10,7 +16,12 @@ static int cpid = 0;
const char *checkpoint(sdtape &tape, const char *dir) { const char *checkpoint(sdtape &tape, const char *dir) {
tape.stop(); tape.stop();
snprintf(buf, sizeof(buf), "%s%s.%03d", dir, chkpt, cpid++); 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); 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); hardware_checkpoint(file);
file.close(); file.close();
tape.start(dir); 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) { void restore(sdtape &tape, const char *dir, const char *filename) {
tape.stop(); tape.stop();
snprintf(buf, sizeof(buf), "%s%s", dir, filename); snprintf(buf, sizeof(buf), "%s%s", dir, filename);
#if defined(SD_CS)
File file = SD.open(buf, O_READ); File file = SD.open(buf, O_READ);
#elif defined(USE_SPIFFS)
File file = SPIFFS.open(buf, FILE_READ);
#endif
hardware_restore(file); hardware_restore(file);
file.close(); file.close();
int n = sscanf(buf + strlen(dir), "%[A-Z0-9].%d", chkpt, &cpid); int n = sscanf(buf + strlen(dir), "%[A-Z0-9].%d", chkpt, &cpid);

View File

@ -1,22 +1,30 @@
#include "hardware.h"
#include <SPI.h> #include <SPI.h>
#if defined(SD_CS)
#include <SD.h> #include <SD.h>
#endif
#if defined(USE_SPIFFS)
#include <SPIFFS.h>
#endif
#include <UTFT.h> #include <UTFT.h>
#if defined(SPIRAM_CS)
#include <SpiRAM.h> #include <SpiRAM.h>
#include "spiram.h"
spiram sram(SPIRAM_SIZE);
#endif
#include "ps2drv.h" #include "ps2drv.h"
#include "memory.h" #include "memory.h"
#include "spiram.h"
#include "CPU.h" #include "CPU.h"
#include "hardware.h"
Memory memory; Memory memory;
PS2Driver ps2; PS2Driver ps2;
#if defined(SPIRAM_CS)
spiram sram(SPIRAM_SIZE);
#endif
UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST); UTFT utft(TFT_MODEL, TFT_RS, TFT_WR, TFT_CS, TFT_RST);
static CPU *_cpu; static CPU *_cpu;
@ -36,6 +44,10 @@ bool hardware_reset() {
pinMode(SPI_CS, OUTPUT); // without this, the SPI-RAM isn't seen pinMode(SPI_CS, OUTPUT); // without this, the SPI-RAM isn't seen
#endif #endif
#if defined(USE_SPIFFS)
success = SPIFFS.begin();
#endif
#if defined(TFT_BACKLIGHT) #if defined(TFT_BACKLIGHT)
digitalWrite(TFT_BACKLIGHT, HIGH); digitalWrite(TFT_BACKLIGHT, HIGH);
#endif #endif

View File

@ -30,6 +30,7 @@
#define SPIRAM_SIZE 65536 #define SPIRAM_SIZE 65536
// "tape" storage... // "tape" storage...
<<<<<<< HEAD
#define SD_CS PF_3 #define SD_CS PF_3
//#define SD_CS PE_0 //#define SD_CS PE_0
#define SD_SPI 1 #define SD_SPI 1

View File

@ -1,11 +1,20 @@
#include "hardware.h"
#if defined(SD_CS)
#include <SD.h> #include <SD.h>
#define DISK SD
#elif defined(USE_SPIFFS)
#include <SPIFFS.h>
#define DISK SPIFFS
#endif
#include "sdtape.h" #include "sdtape.h"
static File file, dir; static File file, dir;
void sdtape::start(const char *programs) void sdtape::start(const char *programs)
{ {
dir = SD.open(programs); dir = DISK.open(programs);
_pos = _len = 0; _pos = _len = 0;
} }