1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-20 21:29:48 +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;
class Stream;
class Checkpointable {
public:
virtual void checkpoint(Stream &s) = 0;
virtual void restore(Stream &s) = 0;
};
class Memory {
public:
typedef unsigned short address;

View File

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

14
ram.h
View File

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

View File

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

View File

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