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

add Keyboard and Checkpointable abstractions

This commit is contained in:
Stephen Crane 2014-10-20 19:19:02 +01:00
parent 270af3b930
commit 0744c03f88
6 changed files with 38 additions and 15 deletions

11
keyboard.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef _KEYBOARD_H
#define _KEYBOARD_H
class Keyboard {
public:
virtual void up(byte) = 0;
virtual void down(byte) = 0;
virtual void reset() = 0;
};
#endif

View File

@ -6,6 +6,14 @@
typedef unsigned char byte; typedef unsigned char byte;
class Stream;
class Checkpointable {
public:
virtual void checkpoint(Stream &s) = 0;
virtual void restore(Stream &s) = 0;
};
class Memory { class Memory {
public: public:
typedef unsigned short address; typedef unsigned short address;

View File

@ -9,6 +9,7 @@
#include "prom.h" #include "prom.h"
#include "ps2drv.h" #include "ps2drv.h"
#include "utftdisplay.h" #include "utftdisplay.h"
#include "keyboard.h"
#include "hardware.h" #include "hardware.h"
#endif #endif

6
ram.h
View File

@ -1,13 +1,13 @@
#ifndef _RAM_H #ifndef _RAM_H
#define _RAM_H #define _RAM_H
class ram: public Memory::Device { class ram: public Memory::Device, public Checkpointable {
public: public:
virtual void operator= (byte c) { _mem[_acc] = c; } virtual void operator= (byte c) { _mem[_acc] = c; }
virtual operator byte () { return _mem[_acc]; } virtual operator byte () { return _mem[_acc]; }
void checkpoint(Stream &s) { s.write(_mem, sizeof(_mem)); } virtual void checkpoint(Stream &s) { s.write(_mem, sizeof(_mem)); }
void restore(Stream &s) { s.readBytes((char *)_mem, sizeof(_mem)); } virtual void restore(Stream &s) { s.readBytes((char *)_mem, sizeof(_mem)); }
ram (): Memory::Device(sizeof(_mem)) {} ram (): Memory::Device(sizeof(_mem)) {}

View File

@ -1,13 +1,13 @@
#ifndef __SPIRAM_H__ #ifndef __SPIRAM_H__
#define __SPIRAM_H__ #define __SPIRAM_H__
class spiram: public Memory::Device { class spiram: public Memory::Device, public Checkpointable {
public: public:
virtual void operator= (byte c); virtual void operator= (byte c);
virtual operator byte (); virtual operator byte ();
void checkpoint(Stream &s); virtual void checkpoint(Stream &s);
void restore(Stream &s); virtual void restore(Stream &s);
spiram(int bytes): Memory::Device(bytes) {} spiram(int bytes): Memory::Device(bytes) {}
void begin(byte cs, int module); void begin(byte cs, int module);

View File

@ -3,13 +3,16 @@
class Stream; class Stream;
class UTFTDisplay: public Memory::Device { class UTFTDisplay: public Memory::Device, public Checkpointable {
public: public:
void begin(unsigned bg, unsigned fg); void begin(unsigned bg, unsigned fg);
void clear(); void clear();
void error(char *); void error(char *);
void status(const char *); void status(const char *);
virtual void checkpoint(Stream &s) = 0;
virtual void restore(Stream &s) = 0;
protected: protected:
UTFTDisplay(unsigned size): Memory::Device(size) {} UTFTDisplay(unsigned size): Memory::Device(size) {}