From 397f580addf88da3bbdcb6dcfc9e8dc37b27febe Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Sun, 10 Feb 2019 13:58:52 +0000 Subject: [PATCH] renaming --- acia.h | 6 +++--- checkpoint.cpp | 14 +++++++------- checkpoint.h | 4 ++-- sdtape.cpp => filer.cpp | 12 ++++++------ filer.h | 28 ++++++++++++++++++++++++++++ r65emu.h | 2 +- sdtape.h | 19 ------------------- 7 files changed, 47 insertions(+), 38 deletions(-) rename sdtape.cpp => filer.cpp (88%) create mode 100644 filer.h delete mode 100644 sdtape.h diff --git a/acia.h b/acia.h index 9347b8a..c4fe24e 100644 --- a/acia.h +++ b/acia.h @@ -7,7 +7,7 @@ enum parity { odd, }; -class SerialDevice { +class serialio { public: virtual void reset() {} virtual void framing(unsigned data_bits, unsigned stop_bits, parity p) {} @@ -23,7 +23,7 @@ public: void operator= (uint8_t); operator uint8_t(); - acia(SerialDevice *d): Memory::Device(256), _device(d) {} + acia(serialio &d): Memory::Device(256), _device(&d) {} // status bits // @@ -63,6 +63,6 @@ public: static const uint8_t eri = 1 << 7; // enable receive interrupt private: - SerialDevice *_device; + serialio *_device; }; #endif diff --git a/checkpoint.cpp b/checkpoint.cpp index 938aee0..481fb2e 100644 --- a/checkpoint.cpp +++ b/checkpoint.cpp @@ -2,7 +2,7 @@ #include #include #include "hardware.h" -#include "sdtape.h" +#include "filer.h" #include "checkpoint.h" #if defined(USE_SD) @@ -17,9 +17,9 @@ static char buf[32]; static char chkpt[] = { "CHKPOINT" }; static int cpid = 0; -const char *checkpoint(sdtape &tape, const char *dir) { +const char *checkpoint(filer &f, const char *dir) { #if defined(USE_SD) || defined(USE_SPIFFS) || defined(ESP8266) - tape.stop(); + f.stop(); snprintf(buf, sizeof(buf), "%s%s.%03d", dir, chkpt, cpid++); #if defined(USE_SD) @@ -31,14 +31,14 @@ const char *checkpoint(sdtape &tape, const char *dir) { #endif hardware_checkpoint(file); file.close(); - tape.start(dir); + f.start(dir); #endif return buf; } -void restore(sdtape &tape, const char *dir, const char *filename) { +void restore(filer &f, const char *dir, const char *filename) { #if defined(USE_SD) || defined(USE_SPIFFS) || defined(ESP8266) - tape.stop(); + f.stop(); snprintf(buf, sizeof(buf), "%s%s", dir, filename); #if defined(USE_SD) @@ -53,5 +53,5 @@ void restore(sdtape &tape, const char *dir, const char *filename) { int n = sscanf(buf + strlen(dir), "%[A-Z0-9].%d", chkpt, &cpid); cpid = (n == 1)? 0: cpid+1; #endif - tape.start(dir); + f.start(dir); } diff --git a/checkpoint.h b/checkpoint.h index 7297ae9..2e95576 100644 --- a/checkpoint.h +++ b/checkpoint.h @@ -2,7 +2,7 @@ #define __CHECKPOINT_H__ // utility checkpoint functions -const char *checkpoint(sdtape &tape, const char *dir); -void restore(sdtape &tape, const char *dir, const char *filename); +const char *checkpoint(filer &f, const char *dir); +void restore(filer &f, const char *dir, const char *filename); #endif diff --git a/sdtape.cpp b/filer.cpp similarity index 88% rename from sdtape.cpp rename to filer.cpp index bcd9bef..b6c7223 100644 --- a/sdtape.cpp +++ b/filer.cpp @@ -11,7 +11,7 @@ #include #endif -#include "sdtape.h" +#include "filer.h" #if defined(DISK) static File file, dir; @@ -23,7 +23,7 @@ static const char *programs; #define STORAGE defined(USE_SD) || defined(USE_SPIFFS) || defined(USE_FS) -bool sdtape::start(const char *programs) +bool flash_filer::start(const char *programs) { #if defined(USE_FS) ::programs = programs; @@ -38,14 +38,14 @@ bool sdtape::start(const char *programs) return true; } -void sdtape::stop() +void flash_filer::stop() { #if STORAGE file.close(); #endif } -bool sdtape::more() +bool flash_filer::more() { if (_pos >= _len) { _pos = 0; @@ -58,7 +58,7 @@ bool sdtape::more() return true; } -const char *sdtape::advance() { +const char *flash_filer::advance() { #if STORAGE bool rewound = false; file.close(); @@ -94,7 +94,7 @@ const char *sdtape::advance() { #endif } -const char *sdtape::rewind() { +const char *flash_filer::rewind() { #if defined(DISK) dir.rewindDirectory(); #endif diff --git a/filer.h b/filer.h new file mode 100644 index 0000000..406b45a --- /dev/null +++ b/filer.h @@ -0,0 +1,28 @@ +#ifndef __FILER_H__ +#define __FILER_H__ + +class filer { +public: + virtual const char *advance() =0; + virtual const char *rewind() =0; + + virtual bool start(const char *) =0; + virtual void stop() =0; +}; + +class flash_filer: public filer { +public: + const char *advance(); + const char *rewind(); + + bool start(const char *); + void stop(); + + uint8_t read() { return _buf[_pos++]; } + bool more(); + +private: + unsigned _pos, _len; + uint8_t _buf[128]; +}; +#endif diff --git a/r65emu.h b/r65emu.h index 15d65c9..d269d79 100644 --- a/r65emu.h +++ b/r65emu.h @@ -9,7 +9,7 @@ #include "ps2drv.h" #include "tftdisplay.h" #include "keyboard.h" -#include "sdtape.h" +#include "filer.h" #include "timed.h" #include "hardware.h" #include "checkpoint.h" diff --git a/sdtape.h b/sdtape.h deleted file mode 100644 index 5ba9aa0..0000000 --- a/sdtape.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __SDTAPE_H__ -#define __SDTAPE_H__ - -class sdtape { -public: - const char *advance(); - const char *rewind(); - - bool start(const char *); - void stop(); - - uint8_t read() { return _buf[_pos++]; } - bool more(); - -private: - unsigned _pos, _len; - uint8_t _buf[128]; -}; -#endif