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

use stdint types

This commit is contained in:
Stephen Crane 2018-08-13 14:41:23 +01:00
parent 42bd04d46f
commit a769683bc6
16 changed files with 769 additions and 771 deletions

52
acia.h
View File

@ -3,38 +3,38 @@
struct acia {
// status bits returned by operator byte
// status bits
//
static const byte rdrf = 1 << 0;
static const byte tdre = 1 << 1;
static const byte dcd = 1 << 2;
static const byte cts = 1 << 3;
static const byte fe = 1 << 4;
static const byte ovrn = 1 << 5;
static const byte pc = 1 << 6;
static const byte irq = 1 << 7;
static const uint8_t rdrf = 1 << 0;
static const uint8_t tdre = 1 << 1;
static const uint8_t dcd = 1 << 2;
static const uint8_t cts = 1 << 3;
static const uint8_t fe = 1 << 4;
static const uint8_t ovrn = 1 << 5;
static const uint8_t pc = 1 << 6;
static const uint8_t irq = 1 << 7;
// control operations (four combinable groups)
//
static const byte cd1 = 0x00; // divide by 1
static const byte cd16 = 0x01; // divide by 16
static const byte cd64 = 0x02; // divide by 64
static const byte reset = 0x03; // master reset
static const uint8_t cd1 = 0x00; // divide by 1
static const uint8_t cd16 = 0x01; // divide by 16
static const uint8_t cd64 = 0x02; // divide by 64
static const uint8_t reset = 0x03; // master reset
static const byte ws7e2 = 0 << 2; // parity
static const byte ws7o2 = 1 << 2;
static const byte ws7e1 = 2 << 2;
static const byte ws7o1 = 3 << 2;
static const byte ws8n2 = 4 << 2;
static const byte ws8n1 = 5 << 2;
static const byte ws8e1 = 6 << 2;
static const byte ws8o1 = 7 << 2;
static const uint8_t ws7e2 = 0 << 2; // parity
static const uint8_t ws7o2 = 1 << 2;
static const uint8_t ws7e1 = 2 << 2;
static const uint8_t ws7o1 = 3 << 2;
static const uint8_t ws8n2 = 4 << 2;
static const uint8_t ws8n1 = 5 << 2;
static const uint8_t ws8e1 = 6 << 2;
static const uint8_t ws8o1 = 7 << 2;
static const byte lrts_dti = 0 << 5; // /rts, disable trans irq
static const byte lrts_eti = 1 << 5; // /rts, enable
static const byte hrts_dti = 2 << 5; // rts, disable
static const byte lrts_dti_brk = 3 << 5; // /rts, disable, send brk
static const uint8_t lrts_dti = 0 << 5; // /rts, disable trans irq
static const uint8_t lrts_eti = 1 << 5; // /rts, enable
static const uint8_t hrts_dti = 2 << 5; // rts, disable
static const uint8_t lrts_dti_brk = 3 << 5; // /rts, disable, send brk
static const byte eri = 1 << 7; // enable receive interrupt
static const uint8_t eri = 1 << 7; // enable receive interrupt
};
#endif

View File

@ -8,7 +8,7 @@
void i8080::run(unsigned clocks) {
while (clocks--) {
byte op = _mem[PC];
uint8_t op = _mem[PC];
PC++;
(this->*_ops[op])();
if (_halted)
@ -41,7 +41,7 @@ void i8080::ei() {
}
char *i8080::status(char *buf, size_t n, bool hdr) {
byte op = _mem[PC];
uint8_t op = _mem[PC];
snprintf(buf, n,
"%s%04x %02x %02x %04x %04x %04x %04x %d%d%d%d%d%d%d%d",
hdr? "_pc_ op aa _bc_ _de_ _hl_ _sp_ szih_p_c\r": "",
@ -73,7 +73,7 @@ void i8080::restore(Stream &s) {
}
void i8080::daa() {
byte c = flags.C, a = 0, hi = (A & 0xf0) >> 4, lo = A & 0x0f;
uint8_t c = flags.C, a = 0, hi = (A & 0xf0) >> 4, lo = A & 0x0f;
if (flags.H || lo > 9)
a = 0x06;
if (flags.C || hi > 0x9 || (hi >= 0x9 && lo > 9)) {

124
i8080.h
View File

@ -16,31 +16,31 @@ public:
void checkpoint(Stream &);
void restore(Stream &);
inline byte a() { return A; }
inline byte b() { return B; }
inline byte c() { return C; }
inline byte d() { return D; }
inline byte e() { return E; }
inline byte h() { return H; }
inline byte l() { return L; }
inline word bc() { return BC; }
inline word de() { return DE; }
inline word hl() { return HL; }
inline byte sr() { return SR; }
inline uint8_t a() { return A; }
inline uint8_t b() { return B; }
inline uint8_t c() { return C; }
inline uint8_t d() { return D; }
inline uint8_t e() { return E; }
inline uint8_t h() { return H; }
inline uint8_t l() { return L; }
inline uint16_t bc() { return BC; }
inline uint16_t de() { return DE; }
inline uint16_t hl() { return HL; }
inline uint8_t sr() { return SR; }
private:
byte A;
uint8_t A;
union {
struct { byte C, B; };
word BC;
struct { uint8_t C, B; };
uint16_t BC;
};
union {
struct { byte E, D; };
word DE;
struct { uint8_t E, D; };
uint16_t DE;
};
union {
struct { byte L, H; };
word HL;
struct { uint8_t L, H; };
uint16_t HL;
};
Memory::address SP;
union {
@ -54,7 +54,7 @@ private:
unsigned Z:1;
unsigned S:1;
} flags;
byte SR;
uint8_t SR;
};
int _irq_pending;
PortDevice<i8080> *_ports;
@ -64,42 +64,42 @@ private:
static int parity_table[256];
inline word _rw(Memory::address a) {
inline uint16_t _rw(Memory::address a) {
return _mem[a] + (_mem[a+1] << 8);
}
inline void _sw(Memory::address a, word w) {
inline void _sw(Memory::address a, uint16_t w) {
_mem[a] = (w & 0xff);
_mem[a+1] = (w >> 8);
}
inline void _szp(byte r) {
inline void _szp(uint8_t r) {
flags.S = ((r & 0x80) != 0);
flags.Z = (r == 0);
flags.P = parity_table[r];
}
inline void _szhp(byte b, byte r) {
inline void _szhp(uint8_t b, uint8_t r) {
_szp(r);
flags.H = ((b & 0x0f) > (r & 0x0f));
}
inline void _inc(byte &b) {
word w = b + 1;
byte r = w & 0xff;
inline void _inc(uint8_t &b) {
uint16_t w = b + 1;
uint8_t r = w & 0xff;
_szhp(b, r);
b = r;
}
inline void _dec(byte &b) {
word w = b - 1;
byte r = w & 0xff;
inline void _dec(uint8_t &b) {
uint16_t w = b - 1;
uint8_t r = w & 0xff;
_szhp(b, r);
b = r;
}
inline void _sr(byte b) { SR = b; flags._ = 0; flags.__ = 1; }
inline void _sr(uint8_t b) { SR = b; flags._ = 0; flags.__ = 1; }
inline void _dad(word w) {
inline void _dad(uint16_t w) {
unsigned long r = HL + w;
HL = (r & 0xffff);
flags.C = (r > 0xffff);
@ -129,7 +129,7 @@ private:
void dcrd() { _dec(D); }
void mvid() { D = _mem[PC++]; }
void ral() {
byte b = (A << 1) | flags.C;
uint8_t b = (A << 1) | flags.C;
flags.C = (A & 0x80) >> 7;
A = b;
}
@ -141,7 +141,7 @@ private:
void dcre() { _dec(E); }
void mvie() { E = _mem[PC++]; }
void rar() {
byte b = (A >> 1) | (flags.C << 7);
uint8_t b = (A >> 1) | (flags.C << 7);
flags.C = (A & 1);
A = b;
}
@ -164,9 +164,9 @@ private:
void lxisp() { SP = _rw(PC); PC += 2; }
void sta() { _mem[_rw(PC)] = A; PC += 2; }
void inxsp() { SP++; }
void inrm() { byte b = _mem[HL]; _inc(b); _mem[HL] = b; }
void dcrm() { byte b = _mem[HL]; _dec(b); _mem[HL] = b; }
void mvim() { byte b = _mem[PC++]; _mem[HL] = b; }
void inrm() { uint8_t b = _mem[HL]; _inc(b); _mem[HL] = b; }
void dcrm() { uint8_t b = _mem[HL]; _dec(b); _mem[HL] = b; }
void mvim() { uint8_t b = _mem[PC++]; _mem[HL] = b; }
void stc() { flags.C = 1; }
void dadsp() { _dad(SP); }
@ -242,9 +242,9 @@ private:
void movam() { A = _mem[HL]; }
void movaa() {}
inline void _add(byte x) {
word w = A + x;
byte b = A;
inline void _add(uint8_t x) {
uint16_t w = A + x;
uint8_t b = A;
A = w & 0xff;
_szhp(b, A);
flags.C = w > 0xff;
@ -259,9 +259,9 @@ private:
void addm() { _add(_mem[HL]); }
void adda() { _add(A); }
inline void _adc(byte x) {
word w = A + x + flags.C;
byte b = A;
inline void _adc(uint8_t x) {
uint16_t w = A + x + flags.C;
uint8_t b = A;
A = w & 0xff;
_szhp(b, A);
flags.C = w > 0xff;
@ -276,9 +276,9 @@ private:
void adcm() { _adc(_mem[HL]); }
void adca() { _adc(A); }
inline void _sub(byte x) {
word w = A - x;
byte b = A;
inline void _sub(uint8_t x) {
uint16_t w = A - x;
uint8_t b = A;
A = w & 0xff;
_szhp(b, A);
flags.C = w > 0xff;
@ -293,9 +293,9 @@ private:
void subm() { _sub(_mem[HL]); }
void suba() { _sub(A); }
inline void _sbc(byte x) {
word w = A - x - flags.C;
byte b = A;
inline void _sbc(uint8_t x) {
uint16_t w = A - x - flags.C;
uint8_t b = A;
A = w & 0xff;
_szhp(b, A);
flags.C = w > 0xff;
@ -310,7 +310,7 @@ private:
void sbbm() { _sbc(_mem[HL]); }
void sbba() { _sbc(A); }
inline void _and(byte b) {
inline void _and(uint8_t b) {
A = A & b;
_szp(A);
flags.C = 0;
@ -326,7 +326,7 @@ private:
void anam() { _and(_mem[HL]); }
void anaa() { _and(A); }
inline void _xor(byte b) {
inline void _xor(uint8_t b) {
A = A ^ b;
_szp(A);
flags.C = flags.H = 0;
@ -341,7 +341,7 @@ private:
void xram() { _xor(_mem[HL]); }
void xraa() { _xor(A); }
inline void _or(byte b) {
inline void _or(uint8_t b) {
A = A | b;
_szp(A);
flags.C = flags.H = 0;
@ -356,8 +356,8 @@ private:
void oram() { _or(_mem[HL]); }
void oraa() { _or(A); }
inline void _cmp(byte b) {
word w = A - b;
inline void _cmp(uint8_t b) {
uint16_t w = A - b;
_szhp(b, w & 0xff);
flags.C = w > 0xff;
}
@ -371,14 +371,14 @@ private:
void cmpm() { _cmp(_mem[HL]); }
void cmpa() { _cmp(A); }
inline byte _popb() { return _mem[SP++]; }
inline void _pushb(byte b) { _mem[--SP] = b; }
inline word _pop() { word w = _rw(SP); SP += 2; return w; }
inline void _push(word w) { SP -= 2; _sw(SP, w); }
inline uint8_t _popb() { return _mem[SP++]; }
inline void _pushb(uint8_t b) { _mem[--SP] = b; }
inline uint16_t _pop() { uint16_t w = _rw(SP); SP += 2; return w; }
inline void _push(uint16_t w) { SP -= 2; _sw(SP, w); }
inline void _jmp(byte c) { if (c) jmp(); else PC += 2; }
inline void _ret(byte c) { if (c) ret(); }
inline void _call(byte c) { if (c) call(); else PC += 2; }
inline void _jmp(uint8_t c) { if (c) jmp(); else PC += 2; }
inline void _ret(uint8_t c) { if (c) ret(); }
inline void _call(uint8_t c) { if (c) call(); else PC += 2; }
void rnz() { _ret(!flags.Z); }
void popb() { BC = _pop(); }
@ -415,7 +415,7 @@ private:
void rpo() { _ret(!flags.P); }
void poph() { HL = _pop(); }
void jpo() { _jmp(!flags.P); }
void xthl() { word w = _pop(); _push(HL); HL = w; }
void xthl() { uint16_t w = _pop(); _push(HL); HL = w; }
void cpo() { _call(!flags.P); }
void pushh() { _push(HL); }
void ani() { _and(_mem[PC++]); }
@ -423,7 +423,7 @@ private:
void rpe() { _ret(flags.P); }
void pchl() { PC = HL; }
void jpe() { _jmp(flags.P); }
void xchg() { word w = DE; DE = HL; HL = w; }
void xchg() { uint16_t w = DE; DE = HL; HL = w; }
void cpe() { _call(flags.P); }
void xri() { _xor(_mem[PC++]); }

View File

@ -3,14 +3,14 @@
class Keyboard {
public:
virtual void up(byte) = 0;
virtual void down(byte) = 0;
virtual void up(uint8_t) = 0;
virtual void down(uint8_t) = 0;
virtual void reset() = 0;
static inline bool isshift(byte scan) {
static inline bool isshift(uint8_t scan) {
return scan == 0x12 || scan == 0x59;
}
static inline bool isctrl(byte scan) {
static inline bool isctrl(uint8_t scan) {
return scan == 0x14;
}
};

View File

@ -1,3 +1,4 @@
#include <stdint.h>
#include "memory.h"
void Memory::put (Device &dev, address b) {
@ -13,8 +14,8 @@ void Memory::put (Device &dev, address b) {
class NullDevice: public Memory::Device {
public:
NullDevice(): Memory::Device(65536) {}
void operator= (byte b) {}
operator byte() { return 0; }
void operator= (uint8_t b) {}
operator uint8_t() { return 0; }
} nd;
void Memory::begin() {

View File

@ -1,9 +1,6 @@
#ifndef __MEMORY_H__
#define __MEMORY_H__
typedef unsigned char byte;
typedef unsigned int word;
class Stream;
class Checkpointable {
@ -14,12 +11,12 @@ public:
class Memory {
public:
typedef unsigned short address;
typedef uint16_t address;
static const unsigned page_size = 256;
class Device: public Checkpointable {
public:
Device (unsigned bytes): _pages(bytes/page_size) {}
Device (unsigned uint8_ts): _pages(uint8_ts/page_size) {}
virtual ~Device () {}
unsigned pages () const { return _pages; }
@ -27,8 +24,8 @@ public:
void base (address a) { _base=a; }
address base () const { return _base; }
virtual void operator= (byte) =0;
virtual operator byte () =0;
virtual void operator= (uint8_t) =0;
virtual operator uint8_t () =0;
virtual void checkpoint(Stream &s) {};
virtual void restore(Stream &s) {};

View File

@ -4,8 +4,8 @@
template<class P>
class PortDevice {
public:
virtual void out(word p, byte v, P *cpu) =0;
virtual byte in(word p, P *cpu) =0;
virtual void out(uint16_t p, uint8_t v, P *cpu) =0;
virtual uint8_t in(uint16_t p, P *cpu) =0;
};
#endif

8
prom.h
View File

@ -3,13 +3,13 @@
class prom: public Memory::Device {
public:
virtual void operator= (byte) {}
virtual operator byte () { return _mem[_acc]; }
virtual void operator= (uint8_t) {}
virtual operator uint8_t () { return _mem[_acc]; }
prom(const byte *mem, int bytes): Memory::Device(bytes), _mem(mem) {}
prom(const uint8_t *mem, int uint8_ts): Memory::Device(uint8_ts), _mem(mem) {}
private:
const byte *_mem;
const uint8_t *_mem;
};
#endif

View File

@ -7,7 +7,7 @@
void r6502::run(unsigned clocks) {
while (clocks--) {
byte op = _mem[PC];
uint8_t op = _mem[PC];
PC++;
(this->*_ops[op])();
if (_halted)
@ -15,7 +15,7 @@ void r6502::run(unsigned clocks) {
}
}
byte r6502::flags() {
uint8_t r6502::flags() {
P.bits.N = ((N & 0x80) != 0);
P.bits.V = V;
P.bits.Z = !Z;
@ -54,7 +54,7 @@ void r6502::checkpoint(Stream &s)
void r6502::restore(Stream &s)
{
byte hi = s.read(), lo = s.read();
uint8_t hi = s.read(), lo = s.read();
PC = hi * 0xff + lo;
S = s.read();
A = s.read();
@ -142,7 +142,7 @@ void r6502::jsr() {
PC = vector(PC);
}
void r6502::_adc(byte d) {
void r6502::_adc(uint8_t d) {
if (P.bits.D) {
int r = _fromBCD[A] + _fromBCD[d] + C;
C = (r > 99);
@ -159,7 +159,7 @@ void r6502::_adc(byte d) {
Z = A;
}
void r6502::sbcd(byte d) {
void r6502::sbcd(uint8_t d) {
int r = _fromBCD[A] - _fromBCD[d] - !C;
C = (r >= 0);
if (r < 0) r += 100;

52
r6502.h
View File

@ -16,8 +16,8 @@ public:
r6502(Memory &);
private:
/* registers */
byte S, A, X, Y;
byte N, V, B, D, I, Z, C;
uint8_t S, A, X, Y;
uint8_t N, V, B, D, I, Z, C;
union {
struct {
unsigned C:1;
@ -29,14 +29,14 @@ private:
unsigned V:1;
unsigned N:1;
} bits;
byte flags;
uint8_t flags;
} P;
byte _toBCD[256], _fromBCD[256]; // BCD maps
uint8_t _toBCD[256], _fromBCD[256]; // BCD maps
bool _irq; // interrupt pending?
void irq();
void nmi();
byte flags();
uint8_t flags();
/* stack */
inline void pusha(Memory::address ret) {
@ -44,16 +44,16 @@ private:
_mem[0x0100+S--] = ret & 0xff;
}
inline void pushb(byte b) {
inline void pushb(uint8_t b) {
_mem[0x0100+S--] = b;
}
inline byte popb() {
inline uint8_t popb() {
return _mem[++S+0x0100];
}
inline Memory::address popa() {
byte b = popb();
uint8_t b = popb();
return (popb() << 8) | b;
}
@ -66,15 +66,15 @@ private:
}
/* operators */
inline void _cmp(byte a) { Z=N=A-a; C=(A>=a); }
inline void _cpx(byte a) { Z=N=X-a; C=(X>=a); }
inline void _cpy(byte a) { Z=N=Y-a; C=(Y>=a); }
inline void _and(byte a) { Z=N=A&=a; }
inline void _eor(byte a) { Z=N=A^=a; }
inline void _ora(byte a) { Z=N=A|=a; }
inline void _lda(byte a) { Z=N=A=a; }
inline void _ldx(byte a) { Z=N=X=a; }
inline void _ldy(byte a) { Z=N=Y=a; }
inline void _cmp(uint8_t a) { Z=N=A-a; C=(A>=a); }
inline void _cpx(uint8_t a) { Z=N=X-a; C=(X>=a); }
inline void _cpy(uint8_t a) { Z=N=Y-a; C=(Y>=a); }
inline void _and(uint8_t a) { Z=N=A&=a; }
inline void _eor(uint8_t a) { Z=N=A^=a; }
inline void _ora(uint8_t a) { Z=N=A|=a; }
inline void _lda(uint8_t a) { Z=N=A=a; }
inline void _ldx(uint8_t a) { Z=N=X=a; }
inline void _ldy(uint8_t a) { Z=N=Y=a; }
/* modes */
inline Memory::address _a() {
@ -92,27 +92,27 @@ private:
inline Memory::address _ix() { return _i(_zx()); }
inline Memory::address _iy() { return _i(_mem[PC++])+Y; }
void _adc(byte a);
void _sbc(byte a) { if (P.bits.D) sbcd(a); else _adc(~a); }
void sbcd(byte a);
void _adc(uint8_t a);
void _sbc(uint8_t a) { if (P.bits.D) sbcd(a); else _adc(~a); }
void sbcd(uint8_t a);
inline byte __ror(byte b) {
inline uint8_t __ror(uint8_t b) {
N=b>>1; if (C) N|=0x80; C=b&1; return Z=N;
}
inline void _ror(Memory::address a) {
_mem[a] = __ror(_mem[a]);
}
inline byte __rol(byte b) {
inline uint8_t __rol(uint8_t b) {
N=b<<1; if (C) N|=1; C=(b&0x80)!=0; return Z=N;
}
inline void _rol(Memory::address a) {
_mem[a] = __rol(_mem[a]);
}
inline byte __asl(byte b) { C=(b&0x80)!=0; return Z=N=b<<1; }
inline uint8_t __asl(uint8_t b) { C=(b&0x80)!=0; return Z=N=b<<1; }
inline void _asl(Memory::address a) {
_mem[a] = __asl(_mem[a]);
}
inline byte __lsr(byte b) { C=b&1; Z=b>>1; N=0; return Z; }
inline uint8_t __lsr(uint8_t b) { C=b&1; Z=b>>1; N=0; return Z; }
inline void _lsr(Memory::address a) {
_mem[a] = __lsr(_mem[a]);
}
@ -122,9 +122,9 @@ private:
inline void _dec(Memory::address a) {
Z=N=_mem[a]-1; _mem[a]=Z;
}
inline void _bit(byte z) { V=((z & 0x40)!=0); N=(z & 0x80); Z=(A & z); }
inline void _bit(uint8_t z) { V=((z & 0x40)!=0); N=(z & 0x80); Z=(A & z); }
inline void _bra() {
byte b = _mem[PC];
uint8_t b = _mem[PC];
PC += b;
if (b > 127) PC -= 0x0100;
}

6
ram.h
View File

@ -3,8 +3,8 @@
class ram: public Memory::Device {
public:
virtual void operator= (byte c) { _mem[_acc] = c; }
virtual operator byte () { return _mem[_acc]; }
virtual void operator= (uint8_t c) { _mem[_acc] = c; }
virtual operator uint8_t () { return _mem[_acc]; }
virtual void checkpoint(Stream &s) { s.write(_mem, sizeof(_mem)); }
virtual void restore(Stream &s) { s.readBytes((char *)_mem, sizeof(_mem)); }
@ -12,6 +12,6 @@ public:
ram (): Memory::Device(sizeof(_mem)) {}
private:
byte _mem[1024];
uint8_t _mem[1024];
};
#endif

View File

@ -11,11 +11,11 @@ public:
sdtape(): _pos(0), _len(0) {}
byte read() { return _buf[_pos++]; }
uint8_t read() { return _buf[_pos++]; }
bool more();
private:
unsigned int _pos, _len;
byte _buf[128];
uint8_t _buf[128];
};
#endif

View File

@ -10,19 +10,19 @@ extern SPIClass SPIRAM_DEV;
SpiRAM spiRam(SPIRAM_DEV, SPIRAM_CS);
void spiram::operator=(byte b)
void spiram::operator=(uint8_t b)
{
spiRam.write_byte(_acc, b);
spiRam.write_uint8_t(_acc, b);
}
spiram::operator byte()
spiram::operator uint8_t()
{
return spiRam.read_byte(_acc);
return spiRam.read_uint8_t(_acc);
}
void spiram::checkpoint(Stream &s)
{
byte buf[Memory::page_size];
uint8_t buf[Memory::page_size];
for (unsigned i = 0; i < pages(); i++) {
spiRam.read_stream(i * 256, buf, sizeof(buf));
s.write(buf, sizeof(buf));
@ -31,7 +31,7 @@ void spiram::checkpoint(Stream &s)
void spiram::restore(Stream &s)
{
byte buf[Memory::page_size];
uint8_t buf[Memory::page_size];
for (unsigned i = 0; i < pages(); i++) {
s.readBytes((char *)buf, sizeof(buf));
spiRam.write_stream(i * 256, buf, sizeof(buf));

View File

@ -3,14 +3,14 @@
class spiram: public Memory::Device {
public:
virtual void operator= (byte c);
virtual operator byte ();
virtual void operator= (uint8_t c);
virtual operator uint8_t ();
virtual void checkpoint(Stream &s);
virtual void restore(Stream &s);
spiram(int bytes): Memory::Device(bytes) {}
void begin(byte cs, int module);
void begin(uint8_t cs, int module);
};
#endif

16
z80.cpp
View File

@ -7,7 +7,7 @@
#include "z80.h"
char *z80::status(char *buf, size_t n, bool hdr) {
byte op = _mem[PC];
uint8_t op = _mem[PC];
snprintf(buf, n,
"%s%04x %02x %04x %04x %04x %04x %04x %04x %04x %04x %04x %d%d%d "
"%04x %d%d%d%d%d%d%d%d",
@ -61,9 +61,9 @@ void z80::restore(Stream &s) {
_irq_pending = s.read();
}
byte z80::_fetch_op() {
uint8_t z80::_fetch_op() {
_mc(PC, 4);
byte op = _mem[PC];
uint8_t op = _mem[PC];
#if defined(CPU_DEBUG)
printf("%5ld MR %04x %02x\n", _ts, PC, op);
#endif
@ -118,7 +118,7 @@ void z80::_handle_interrupt() {
}
void z80::daa() {
byte c = flags.C, a = 0, lo = A & 0x0f;
uint8_t c = flags.C, a = 0, lo = A & 0x0f;
if (flags.H || lo > 9)
a = 0x06;
if (c || A > 0x99) {
@ -136,14 +136,14 @@ void z80::daa() {
void z80::_step_idx(OP_IDX ops[]) {
_mc(PC, 3);
byte off = _mem[PC];
uint8_t off = _mem[PC];
#if defined(CPU_DEBUG)
printf("%5ld MR %04x %02x\n", _ts, PC, off);
#endif
PC++;
_mc(PC, 3);
byte op = _mem[PC];
uint8_t op = _mem[PC];
#if defined(CPU_DEBUG)
printf("%5ld MR %04x %02x\n", _ts, PC, op);
#endif
@ -153,7 +153,7 @@ void z80::_step_idx(OP_IDX ops[]) {
(this->*ops[op])(off);
}
void z80::_ddfd(word &ix, byte &ixL, byte &ixH, OP_IDX ops[]) {
void z80::_ddfd(uint16_t &ix, uint8_t &ixL, uint8_t &ixH, OP_IDX ops[]) {
switch (_fetch_op()) {
case 0x09:
_add16(ix, BC);
@ -419,7 +419,7 @@ void z80::_ddfd(word &ix, byte &ixL, byte &ixH, OP_IDX ops[]) {
}
void z80::ed() {
byte b, c, f;
uint8_t b, c, f;
switch (_fetch_op()) {
case 0x40:
B = _inr(BC);

1216
z80.h

File diff suppressed because it is too large Load Diff