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:
parent
270af3b930
commit
0744c03f88
11
keyboard.h
Normal file
11
keyboard.h
Normal 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
|
8
memory.h
8
memory.h
@ -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;
|
||||
|
1
r65emu.h
1
r65emu.h
@ -9,6 +9,7 @@
|
||||
#include "prom.h"
|
||||
#include "ps2drv.h"
|
||||
#include "utftdisplay.h"
|
||||
#include "keyboard.h"
|
||||
#include "hardware.h"
|
||||
|
||||
#endif
|
||||
|
14
ram.h
14
ram.h
@ -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
|
||||
|
14
spiram.h
14
spiram.h
@ -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
|
||||
|
@ -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) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user