mirror of
https://github.com/jscrane/r65emu.git
synced 2024-12-10 14:49:19 +00:00
minor updates
This commit is contained in:
parent
9d092f4e8b
commit
6856eac8a6
3
cpu.h
3
cpu.h
@ -5,6 +5,8 @@
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#undef PC
|
||||
|
||||
class CPU: public Checkpointable {
|
||||
public:
|
||||
virtual void run(unsigned instructions) =0;
|
||||
@ -22,6 +24,7 @@ public:
|
||||
protected:
|
||||
CPU (Memory &mem, jmp_buf &e, statfn s): _mem(mem), _err(e), _status(s), _debug(false) {}
|
||||
Memory &_mem;
|
||||
Memory::address PC;
|
||||
jmp_buf &_err;
|
||||
statfn _status;
|
||||
bool _debug;
|
||||
|
@ -27,7 +27,7 @@
|
||||
//#define SPIRAM_CS PF_3
|
||||
#define SPIRAM_SPI 1
|
||||
#define SPIRAM_DEV SPI_for_SD
|
||||
#define SPIRAM_SIZE 32768
|
||||
#define SPIRAM_SIZE 65536
|
||||
|
||||
// "tape" storage...
|
||||
#define SD_CS PF_3
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "memory.h"
|
||||
#include "cpu.h"
|
||||
#include "ports.h"
|
||||
#include "i8080.h"
|
||||
|
||||
#define CPU_STATE_FMT "%04x %02x %02x %04x %04x %04x %04x %d%d%d%d%d%d%d%d\r",\
|
||||
@ -117,7 +118,7 @@ int i8080::parity_table[] = {
|
||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||
};
|
||||
|
||||
i8080::i8080(Memory &m, jmp_buf &jb, CPU::statfn s, Ports &d): CPU(m, jb, s)
|
||||
i8080::i8080(Memory &m, jmp_buf &jb, CPU::statfn s, PortDevice<i8080> &d): CPU(m, jb, s)
|
||||
{
|
||||
_ports = &d;
|
||||
|
||||
|
16
i8080.h
16
i8080.h
@ -6,14 +6,7 @@
|
||||
|
||||
class i8080: public CPU {
|
||||
public:
|
||||
|
||||
class Ports {
|
||||
public:
|
||||
virtual void out(byte p, byte v, i8080 *cpu) =0;
|
||||
virtual byte in(byte p, i8080 *cpu) =0;
|
||||
};
|
||||
|
||||
i8080(Memory &, jmp_buf &, CPU::statfn, Ports &);
|
||||
i8080(Memory &, jmp_buf &, CPU::statfn, PortDevice<i8080> &);
|
||||
|
||||
void run(unsigned);
|
||||
void reset();
|
||||
@ -51,7 +44,7 @@ private:
|
||||
struct { byte L, H; };
|
||||
word HL;
|
||||
};
|
||||
Memory::address PC, SP;
|
||||
Memory::address SP;
|
||||
union {
|
||||
struct {
|
||||
unsigned C:1;
|
||||
@ -66,7 +59,7 @@ private:
|
||||
byte SR;
|
||||
};
|
||||
int _irq_pending;
|
||||
Ports *_ports;
|
||||
PortDevice<i8080> *_ports;
|
||||
|
||||
typedef void (i8080::*OP)();
|
||||
OP _ops[256];
|
||||
@ -322,7 +315,8 @@ private:
|
||||
inline void _and(byte b) {
|
||||
A = A & b;
|
||||
_szp(A);
|
||||
flags.C = flags.H = 0;
|
||||
flags.C = 0;
|
||||
flags.H = 1;
|
||||
}
|
||||
|
||||
void anab() { _and(B); }
|
||||
|
11
ports.h
Normal file
11
ports.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __PORTS_H__
|
||||
#define __PORTS_H__
|
||||
|
||||
template<class P>
|
||||
class PortDevice {
|
||||
public:
|
||||
virtual void out(word p, byte v, P *cpu) =0;
|
||||
virtual byte in(word p, P *cpu) =0;
|
||||
};
|
||||
|
||||
#endif
|
1
r6502.h
1
r6502.h
@ -16,7 +16,6 @@ public:
|
||||
r6502 (Memory &, jmp_buf &, CPU::statfn);
|
||||
private:
|
||||
/* registers */
|
||||
Memory::address PC;
|
||||
byte S, A, X, Y;
|
||||
byte N, V, B, D, I, Z, C;
|
||||
union {
|
||||
|
@ -21,7 +21,7 @@ spiram::operator byte()
|
||||
void spiram::checkpoint(Stream &s)
|
||||
{
|
||||
byte buf[Memory::page_size];
|
||||
for (int i = 0; i < pages(); i++) {
|
||||
for (unsigned i = 0; i < pages(); i++) {
|
||||
spiRam.read_stream(i * 256, buf, sizeof(buf));
|
||||
s.write(buf, sizeof(buf));
|
||||
}
|
||||
@ -30,7 +30,7 @@ void spiram::checkpoint(Stream &s)
|
||||
void spiram::restore(Stream &s)
|
||||
{
|
||||
byte buf[Memory::page_size];
|
||||
for (int i = 0; i < pages(); i++) {
|
||||
for (unsigned i = 0; i < pages(); i++) {
|
||||
s.readBytes((char *)buf, sizeof(buf));
|
||||
spiRam.write_stream(i * 256, buf, sizeof(buf));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user