From 7f8a15d22a645ad1663cf941450117d0f8afd040 Mon Sep 17 00:00:00 2001 From: Stephen Crane Date: Mon, 13 Aug 2018 14:41:23 +0100 Subject: [PATCH] use stdint types --- acia.h | 52 +-- i8080.cpp | 6 +- i8080.h | 124 +++--- keyboard.h | 8 +- memory.cpp | 5 +- memory.h | 11 +- ports.h | 4 +- prom.h | 8 +- r6502.cpp | 10 +- r6502.h | 52 +-- ram.h | 6 +- sdtape.h | 4 +- spiram.cpp | 12 +- spiram.h | 6 +- z80.cpp | 16 +- z80.h | 1216 ++++++++++++++++++++++++++-------------------------- 16 files changed, 769 insertions(+), 771 deletions(-) diff --git a/acia.h b/acia.h index 4cf1bd1..b4624b5 100644 --- a/acia.h +++ b/acia.h @@ -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 diff --git a/i8080.cpp b/i8080.cpp index f4ecfd5..e5e2fc2 100644 --- a/i8080.cpp +++ b/i8080.cpp @@ -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)) { diff --git a/i8080.h b/i8080.h index 7357ad5..960a1ee 100644 --- a/i8080.h +++ b/i8080.h @@ -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 *_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++]); } diff --git a/keyboard.h b/keyboard.h index c7e74fa..f7ab9ed 100644 --- a/keyboard.h +++ b/keyboard.h @@ -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; } }; diff --git a/memory.cpp b/memory.cpp index 57f24ed..88e97d7 100644 --- a/memory.cpp +++ b/memory.cpp @@ -1,3 +1,4 @@ +#include #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() { diff --git a/memory.h b/memory.h index 96ea87f..5c64bc0 100644 --- a/memory.h +++ b/memory.h @@ -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) {}; diff --git a/ports.h b/ports.h index 127a352..1e81d3e 100644 --- a/ports.h +++ b/ports.h @@ -4,8 +4,8 @@ template 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 diff --git a/prom.h b/prom.h index d47fde5..31b4eea 100644 --- a/prom.h +++ b/prom.h @@ -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 diff --git a/r6502.cpp b/r6502.cpp index 6c74d05..3635016 100644 --- a/r6502.cpp +++ b/r6502.cpp @@ -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; diff --git a/r6502.h b/r6502.h index 3b443ef..cd25b02 100644 --- a/r6502.h +++ b/r6502.h @@ -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; } diff --git a/ram.h b/ram.h index 4bd55b3..2c4547b 100644 --- a/ram.h +++ b/ram.h @@ -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 diff --git a/sdtape.h b/sdtape.h index 11036e1..b8794b5 100644 --- a/sdtape.h +++ b/sdtape.h @@ -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 diff --git a/spiram.cpp b/spiram.cpp index 670250c..3647ea4 100644 --- a/spiram.cpp +++ b/spiram.cpp @@ -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)); diff --git a/spiram.h b/spiram.h index 4314bca..344c53c 100644 --- a/spiram.h +++ b/spiram.h @@ -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 diff --git a/z80.cpp b/z80.cpp index a96405c..fe472ca 100644 --- a/z80.cpp +++ b/z80.cpp @@ -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); diff --git a/z80.h b/z80.h index 0e527ad..452525b 100644 --- a/z80.h +++ b/z80.h @@ -16,50 +16,50 @@ 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 af() { return AF; } - inline word bc() { return BC; } - inline word de() { return DE; } - inline word hl() { return HL; } - inline byte sr() { return F; } - inline byte i() { return I; } - inline byte r() { return R; } - inline word af_() { return AF_; } - inline word bc_() { return BC_; } - inline word de_() { return DE_; } - inline word hl_() { return HL_; } - inline word ix() { return IX; } - inline word iy() { return IY; } - inline word sp() { return SP; } - inline word pc() { return PC; } + 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 af() { return AF; } + inline uint16_t bc() { return BC; } + inline uint16_t de() { return DE; } + inline uint16_t hl() { return HL; } + inline uint8_t sr() { return F; } + inline uint8_t i() { return I; } + inline uint8_t r() { return R; } + inline uint16_t af_() { return AF_; } + inline uint16_t bc_() { return BC_; } + inline uint16_t de_() { return DE_; } + inline uint16_t hl_() { return HL_; } + inline uint16_t ix() { return IX; } + inline uint16_t iy() { return IY; } + inline uint16_t sp() { return SP; } + inline uint16_t pc() { return PC; } inline bool iff1() { return _iff1; } inline bool iff2() { return _iff2; } - inline byte im() { return _im; } + inline uint8_t im() { return _im; } - inline void af(word w) { AF = w; } - inline void bc(word w) { BC = w; } - inline void de(word w) { DE = w; } - inline void hl(word w) { HL = w; } - inline void pc(word w) { PC = w; } - inline void sp(word w) { SP = w; } - inline void ix(word w) { IX = w; } - inline void iy(word w) { IY = w; } - inline void af_(word w) { AF_ = w; } - inline void bc_(word w) { BC_ = w; } - inline void de_(word w) { DE_ = w; } - inline void hl_(word w) { HL_ = w; } + inline void af(uint16_t w) { AF = w; } + inline void bc(uint16_t w) { BC = w; } + inline void de(uint16_t w) { DE = w; } + inline void hl(uint16_t w) { HL = w; } + inline void pc(uint16_t w) { PC = w; } + inline void sp(uint16_t w) { SP = w; } + inline void ix(uint16_t w) { IX = w; } + inline void iy(uint16_t w) { IY = w; } + inline void af_(uint16_t w) { AF_ = w; } + inline void bc_(uint16_t w) { BC_ = w; } + inline void de_(uint16_t w) { DE_ = w; } + inline void hl_(uint16_t w) { HL_ = w; } - inline void i(byte i) { I = i; } - inline void r(byte r) { R = r; } - inline void iff1(byte iff1) { _iff1 = iff1 != 0; } - inline void iff2(byte iff2) { _iff2 = iff2 != 0; } - inline void im(byte im) { _im = im; } + inline void i(uint8_t i) { I = i; } + inline void r(uint8_t r) { R = r; } + inline void iff1(uint8_t iff1) { _iff1 = iff1 != 0; } + inline void iff2(uint8_t iff2) { _iff2 = iff2 != 0; } + inline void im(uint8_t im) { _im = im; } inline unsigned long ts() { return _ts; } inline void ts(int t) { _ts += t; } @@ -71,14 +71,14 @@ private: typedef void (z80::*OP)(); void _step(OP ops[]); - byte _fetch_op(); + uint8_t _fetch_op(); inline void step() { (this->*_ops[_fetch_op()])(); } - typedef void (z80::*OP_IDX)(byte); + typedef void (z80::*OP_IDX)(uint8_t); void _step_idx(OP_IDX ops[]); - void _ddfd(word &ix, byte &ixL, byte &ixH, OP_IDX ops[]); + void _ddfd(uint16_t &ix, uint8_t &ixL, uint8_t &ixH, OP_IDX ops[]); union { struct { @@ -93,46 +93,46 @@ private: unsigned Z:1; unsigned S:1; } flags; - byte F; + uint8_t F; }; - byte A; + uint8_t A; }; - word AF; + uint16_t AF; }; 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; - word AF_, BC_, DE_, HL_; + uint16_t AF_, BC_, DE_, HL_; union { - struct { byte IXL, IXH; }; - word IX; + struct { uint8_t IXL, IXH; }; + uint16_t IX; }; union { - struct { byte IYL, IYH; }; - word IY; + struct { uint8_t IYL, IYH; }; + uint16_t IY; }; union { - struct { byte R, I; }; - word IR; + struct { uint8_t R, I; }; + uint16_t IR; }; - byte _im; + uint8_t _im; bool _iff1, _iff2; unsigned long _ts; @@ -145,18 +145,18 @@ private: static int parity_table[256]; - inline byte _rb(Memory::address a) { + inline uint8_t _rb(Memory::address a) { #if defined(CPU_DEBUG) printf("%5ld MC %04x\n", _ts, a); #endif ts(3); #if defined(CPU_DEBUG) - printf("%5ld MR %04x %02x\n", _ts, a, (byte)_mem[a]); + printf("%5ld MR %04x %02x\n", _ts, a, (uint8_t)_mem[a]); #endif return _mem[a]; } - inline void _sb(Memory::address a, byte b) { + inline void _sb(Memory::address a, uint8_t b) { #if defined(CPU_DEBUG) printf("%5ld MC %04x\n", _ts, a); #endif @@ -174,48 +174,48 @@ private: ts(i); } - inline word _rw(Memory::address a) { + inline uint16_t _rw(Memory::address a) { return _rb(a) + (_rb(a+1) << 8); } - inline void _sw(Memory::address a, word w) { + inline void _sw(Memory::address a, uint16_t w) { _sb(a+1, w >> 8); _sb(a, w & 0xff); } - inline word _rwpc() { - word w = _rw(PC); + inline uint16_t _rwpc() { + uint16_t w = _rw(PC); PC += 2; return w; } - inline void _swPC(word w) { _sw(_rw(PC), w); PC += 2; } + inline void _swPC(uint16_t w) { _sw(_rw(PC), w); PC += 2; } - inline word _rwPC() { - word w = _rw(_rw(PC)); + inline uint16_t _rwPC() { + uint16_t w = _rw(_rw(PC)); PC += 2; return w; } - inline void _35(byte r) { + inline void _35(uint8_t r) { flags._3 = ((r & 0x08) != 0); flags._5 = ((r & 0x20) != 0); } - inline void _sz35(byte r) { + inline void _sz35(uint8_t r) { flags.S = ((r & 0x80) != 0); flags.Z = (r == 0); _35(r); } - inline void _szp35(byte r) { + inline void _szp35(uint8_t r) { _sz35(r); flags.P = parity_table[r]; } - 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; _sz35(r); flags.P = r == 0x80; flags.N = 0; @@ -223,9 +223,9 @@ private: 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; _sz35(r); flags.P = r == 0x7f; flags.N = 1; @@ -233,60 +233,60 @@ private: b = r; } - 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; _sz35(A); flags.C = w > 0xff; flags.N = 0; - byte v = b ^ A ^ x; + uint8_t v = b ^ A ^ x; flags.P = (v >> 7) ^ flags.C; flags.H = (v >> 4) & 1; } - 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; _sz35(A); flags.C = w > 0xff; flags.N = 0; - byte v = b ^ A ^ x; + uint8_t v = b ^ A ^ x; flags.P = (v >> 7) ^ flags.C; flags.H = (v >> 4) & 1; } - inline void _adc16(word w) { + inline void _adc16(uint16_t w) { _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); unsigned long r = HL + w + flags.C; - byte h = H; + uint8_t h = H; HL = (r & 0xffff); _sz35(H); flags.Z = (HL == 0); flags.C = (r > 0xffff); flags.N = 0; - byte v = h ^ H ^ (w >> 8); + uint8_t v = h ^ H ^ (w >> 8); flags.P = (v >> 7) ^ flags.C; flags.H = (v >> 4) & 1; } - inline void _add16(word ®, word w) { + inline void _add16(uint16_t ®, uint16_t w) { _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); _mc(IR, 1); unsigned long r = reg + w; - byte o = reg >> 8; + uint8_t o = reg >> 8; reg = (r & 0xffff); - byte h = reg >> 8; + uint8_t h = reg >> 8; _35(h); flags.C = (r > 0xffff); flags.N = 0; - byte v = o ^ h ^ (w >> 8); + uint8_t v = o ^ h ^ (w >> 8); flags.H = (v >> 4) & 1; } - inline void _sub(byte x) { + inline void _sub(uint8_t x) { flags.C = 1; _adc(~x); flags.C = !flags.C; @@ -294,7 +294,7 @@ private: flags.N = 1; } - inline void _sbc(byte x) { + inline void _sbc(uint8_t x) { flags.C = !flags.C; _adc(~x); flags.C = !flags.C; @@ -302,7 +302,7 @@ private: flags.N = 1; } - inline void _sbc16(word w) { + inline void _sbc16(uint16_t w) { flags.C = !flags.C; _adc16(~w); flags.C = !flags.C; @@ -310,76 +310,76 @@ private: flags.N = 1; } - inline word _ads(word a, byte b) { - word w = a + b; + inline uint16_t _ads(uint16_t a, uint8_t b) { + uint16_t w = a + b; if (b > 127) w -= 0x100; return w; } inline void _incO(Memory::address a) { - byte o = _rb(PC); + uint8_t o = _rb(PC); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); PC++; - word w = _ads(a, o); - byte b = _rb(w); + uint16_t w = _ads(a, o); + uint8_t b = _rb(w); _mc(w, 1); _inc(b); _sb(w, b); } inline void _decO(Memory::address a) { - byte o = _rb(PC); + uint8_t o = _rb(PC); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); PC++; - word w = _ads(a, o); - byte b = _rb(w); + uint16_t w = _ads(a, o); + uint8_t b = _rb(w); _mc(w, 1); _dec(b); _sb(w, b); } inline void _sbO(Memory::address a) { - byte o = _rb(PC++); - byte b = _rb(PC); + uint8_t o = _rb(PC++); + uint8_t b = _rb(PC); _mc(PC, 1); _mc(PC, 1); PC++; _sb(_ads(a, o), b); } - inline byte _rbO(Memory::address a) { - byte o = _rb(PC); + inline uint8_t _rbO(Memory::address a) { + uint8_t o = _rb(PC); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); PC++; return _rb(_ads(a, o)); } - inline void _sbO(Memory::address a, byte b) { - byte o = _rb(PC); + inline void _sbO(Memory::address a, uint8_t b) { + uint8_t o = _rb(PC); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); PC++; _sb(_ads(a, o), b); } - inline void _exSP(word ®) { - word w = _pop(); + inline void _exSP(uint16_t ®) { + uint16_t w = _pop(); _mc(SP, 1); _push(reg); reg = w; _mc(SP, 1); _mc(SP, 1); } - inline void _exch(word &a, word &b) { word t = b; b = a; a = t; } + inline void _exch(uint16_t &a, uint16_t &b) { uint16_t t = b; b = a; a = t; } - inline word _pop() { word w = _rw(SP); SP += 2; return w; } - inline void _push(word w) { SP -= 2; _sw(SP, w); } + 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) jp(); else { _mc(PC, 3); _mc(PC+1, 3); PC += 2; } } - inline void _ret(byte c) { _mc(IR, 1); if (c) ret(); } - inline void _call(byte c) { if (c) call(); else { _mc(PC, 3); _mc(PC+1, 3); PC += 2; } } - inline void _jr(byte c) { if (c) jr(); else { _mc(PC, 3); PC++; } } + inline void _jmp(uint8_t c) { if (c) jp(); else { _mc(PC, 3); _mc(PC+1, 3); PC += 2; } } + inline void _ret(uint8_t c) { _mc(IR, 1); if (c) ret(); } + inline void _call(uint8_t c) { if (c) call(); else { _mc(PC, 3); _mc(PC+1, 3); PC += 2; } } + inline void _jr(uint8_t c) { if (c) jr(); else { _mc(PC, 3); PC++; } } // 0x00 void nop() {} @@ -415,14 +415,14 @@ private: void decd() { _dec(D); } void ldd() { D = _rb(PC++); } void rla() { - byte b = (A << 1) | flags.C; + uint8_t b = (A << 1) | flags.C; flags.C = (A & 0x80) >> 7; A = b; } // 0x18 void jr() { - byte b = _rb(PC); + uint8_t b = _rb(PC); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); _mc(PC, 1); PC = _ads(PC, b+1); } @@ -433,7 +433,7 @@ private: void dece() { _dec(E); } void lde() { E = _rb(PC++); } void rra() { - byte b = (A >> 1) | (flags.C << 7); + uint8_t b = (A >> 1) | (flags.C << 7); flags.C = (A & 1); A = b; } @@ -463,8 +463,8 @@ private: void ldsppc() { SP = _rwpc(); } void ldPCa() { _sb(_rw(PC), A); PC += 2; } void incsp() { SP++; _mc(IR, 1); _mc(IR, 1); } - void incHL() { byte b = _rb(HL); _mc(HL, 1); _inc(b); _sb(HL, b); } - void decHL() { byte b = _rb(HL); _mc(HL, 1); _dec(b); _sb(HL, b); } + void incHL() { uint8_t b = _rb(HL); _mc(HL, 1); _inc(b); _sb(HL, b); } + void decHL() { uint8_t b = _rb(HL); _mc(HL, 1); _dec(b); _sb(HL, b); } void ldHL() { _sb(HL, _rb(PC++)); } void scf() { flags.C = 1; flags.N = flags.H = 0; _35(A); } @@ -599,7 +599,7 @@ private: void sbcaa() { _sbc(A); } // 0xa0 - inline void _and(byte b) { + inline void _and(uint8_t b) { A &= b; _szp35(A); flags.C = flags.N = 0; @@ -615,7 +615,7 @@ private: void anda() { _and(A); } // 0xa8 - inline void _xor(byte b) { + inline void _xor(uint8_t b) { A ^= b; _szp35(A); flags.C = flags.N = flags.H = 0; @@ -630,7 +630,7 @@ private: void xora() { _xor(A); } // 0xb0 - inline void _or(byte b) { + inline void _or(uint8_t b) { A |= b; _szp35(A); flags.C = flags.N = flags.H = 0; @@ -645,8 +645,8 @@ private: void ora() { _or(A); } // 0xb8 - inline void _cmp(byte b) { - byte a = A; + inline void _cmp(uint8_t b) { + uint8_t a = A; _sub(b); _35(b); A = a; @@ -676,7 +676,7 @@ private: void jpz() { _jmp(flags.Z); } void cb() { (this->*_cb[_fetch_op()])(); } void callz() { _call(flags.Z); } - void call() { word pc = _rw(PC); _mc(PC+1, 1); _push(PC+2); PC = pc; } + void call() { uint16_t pc = _rw(PC); _mc(PC+1, 1); _push(PC+2); PC = pc; } void adca() { _adc(_rb(PC++)); } void rst08() { _mc(IR, 11); _push(PC); PC = 0x08; } @@ -685,7 +685,7 @@ private: void popde() { DE = _pop(); } void jpnc() { _jmp(!flags.C); } void outa() { - word p = _rb(PC++) + (A << 8); + uint16_t p = _rb(PC++) + (A << 8); _ports->out(p, A, this); } void callnc() { _call(!flags.C); } @@ -698,7 +698,7 @@ private: void exx() { _exch(BC, BC_); _exch(DE, DE_); _exch(HL, HL_); } void jpc() { _jmp(flags.C); } void ina() { - word p = _rb(PC++) + (A << 8); + uint16_t p = _rb(PC++) + (A << 8); A = _ports->in(p, this); } void callc() { _call(flags.C); } @@ -717,13 +717,13 @@ private: void rst20() { _mc(IR, 11); _push(PC); PC = 0x20; } // 0xe8 - inline byte _inr(word p) { - byte b = _ports->in(p, this); + inline uint8_t _inr(uint16_t p) { + uint8_t b = _ports->in(p, this); _szp35(b); flags.N = flags.H = 0; return b; } - inline void _outr(word p, byte b) { + inline void _outr(uint16_t p, uint8_t b) { _ports->out(p, b, this); } @@ -759,7 +759,7 @@ private: // 0xCB extended instructions // 0x00 - inline void _rlc(byte &b) { + inline void _rlc(uint8_t &b) { b = (b << 1) | (b >> 7); flags.C = b & 0x01; _szp35(b); @@ -772,11 +772,11 @@ private: void rlcE() { _rlc(E); } void rlcH() { _rlc(H); } void rlcL() { _rlc(L); } - void rlcHL() { byte b = _rb(HL); _mc(HL, 1); _rlc(b); _sb(HL, b); } + void rlcHL() { uint8_t b = _rb(HL); _mc(HL, 1); _rlc(b); _sb(HL, b); } void rlcA() { _rlc(A); } // 0x08 - inline void _rrc(byte &b) { + inline void _rrc(uint8_t &b) { flags.C = b & 0x01; b = (b >> 1) | (b << 7); _szp35(b); @@ -789,12 +789,12 @@ private: void rrcE() { _rrc(E); } void rrcH() { _rrc(H); } void rrcL() { _rrc(L); } - void rrcHL() { byte b = _rb(HL); _mc(HL, 1); _rrc(b); _sb(HL, b); } + void rrcHL() { uint8_t b = _rb(HL); _mc(HL, 1); _rrc(b); _sb(HL, b); } void rrcA() { _rrc(A); } // 0x10 - inline void _rl(byte &b) { - byte a = b; + inline void _rl(uint8_t &b) { + uint8_t a = b; b = (b << 1) | flags.C; flags.C = (a >> 7); _szp35(b); @@ -807,12 +807,12 @@ private: void rlE() { _rl(E); } void rlH() { _rl(H); } void rlL() { _rl(L); } - void rlHL() { byte b = _rb(HL); _mc(HL, 1); _rl(b); _sb(HL, b); } + void rlHL() { uint8_t b = _rb(HL); _mc(HL, 1); _rl(b); _sb(HL, b); } void rlA() { _rl(A); } // 0x18 - inline void _rr(byte &b) { - byte a = b; + inline void _rr(uint8_t &b) { + uint8_t a = b; b >>= 1; if (flags.C) b |= 0x80; flags.C = a & 0x01; @@ -826,11 +826,11 @@ private: void rrE() { _rr(E); } void rrH() { _rr(H); } void rrL() { _rr(L); } - void rrHL() { byte b = _rb(HL); _mc(HL, 1); _rr(b); _sb(HL, b); } + void rrHL() { uint8_t b = _rb(HL); _mc(HL, 1); _rr(b); _sb(HL, b); } void rrA() { _rr(A); } // 0x20 - inline void _sla(byte &b) { + inline void _sla(uint8_t &b) { flags.C = (b & 0x80) != 0; b <<= 1; _szp35(b); @@ -843,11 +843,11 @@ private: void slae() { _sla(E); } void slah() { _sla(H); } void slal() { _sla(L); } - void slaHL() { byte b = _rb(HL); _mc(HL, 1); _sla(b); _sb(HL, b); } + void slaHL() { uint8_t b = _rb(HL); _mc(HL, 1); _sla(b); _sb(HL, b); } void slaa() { _sla(A); } // 0x28 - inline void _sra(byte &b) { + inline void _sra(uint8_t &b) { flags.C = b & 0x01; b = (b & 0x80) | (b >> 1); _szp35(b); @@ -860,11 +860,11 @@ private: void srae() { _sra(E); } void srah() { _sra(H); } void sral() { _sra(L); } - void sraHL() { byte b = _rb(HL); _mc(HL, 1); _sra(b); _sb(HL, b); } + void sraHL() { uint8_t b = _rb(HL); _mc(HL, 1); _sra(b); _sb(HL, b); } void sraa() { _sra(A); } // 0x30 - inline void _sll(byte &b) { + inline void _sll(uint8_t &b) { flags.C = (b & 0x80) != 0; b = (b << 1) | 0x01; _szp35(b); @@ -877,11 +877,11 @@ private: void slle() { _sll(E); } void sllh() { _sll(H); } void slll() { _sll(L); } - void sllHL() { byte b = _rb(HL); _mc(HL, 1); _sll(b); _sb(HL, b); } + void sllHL() { uint8_t b = _rb(HL); _mc(HL, 1); _sll(b); _sb(HL, b); } void slla() { _sll(A); } // 0x38 - inline void _srl(byte &b) { + inline void _srl(uint8_t &b) { flags.C = b & 0x01; b >>= 1; _szp35(b); @@ -894,11 +894,11 @@ private: void srle() { _srl(E); } void srlh() { _srl(H); } void srll() { _srl(L); } - void srlHL() { byte b = _rb(HL); _mc(HL, 1); _srl(b); _sb(HL, b); } + void srlHL() { uint8_t b = _rb(HL); _mc(HL, 1); _srl(b); _sb(HL, b); } void srla() { _srl(A); } // 0x40 - inline void _bit(int i, byte b) { + inline void _bit(int i, uint8_t b) { flags.P = flags.Z = !(b & (1 << i)); flags.S = (i == 7 && (b & 0x80)); flags.H = 1; @@ -907,7 +907,7 @@ private: } inline void _bitHL(int i) { - byte b = _rb(HL); _mc(HL, 1); _bit(i, b); + uint8_t b = _rb(HL); _mc(HL, 1); _bit(i, b); } void bit0b() { _bit(0, B); } @@ -990,8 +990,8 @@ private: void bit7a() { _bit(7, A); } // 0x80 - inline void _resHL(byte m) { - byte b = _rb(HL); + inline void _resHL(uint8_t m) { + uint8_t b = _rb(HL); _mc(HL, 1); _sb(HL, b & m); } @@ -1076,8 +1076,8 @@ private: void res7a() { A &= 0x7f; } // 0xc0 - inline void _setHL(byte m) { - byte b = _rb(HL); + inline void _setHL(uint8_t m) { + uint8_t b = _rb(HL); _mc(HL, 1); _sb(HL, b | m); } @@ -1161,8 +1161,8 @@ private: void set7HL() { _setHL(0x80); } void set7a() { A |= 0x80; } - inline void _bitI(int i, word a) { - byte b = _rb(a); + inline void _bitI(int i, uint16_t a) { + uint8_t b = _rb(a); _mc(a, 1); _bit(i, b); _35(a >> 8); @@ -1170,625 +1170,625 @@ private: // 0xDDCB extended instructions - inline word _rbIX(byte &b, byte o) { - word a = _ads(IX, o); + inline uint16_t _rbIX(uint8_t &b, uint8_t o) { + uint16_t a = _ads(IX, o); b = _rb(a); _mc(a, 1); return a; } // 0x00 - inline void _rlcIX(byte &b, byte o) { - word a = _rbIX(b, o); _rlc(b); _sb(a, b); + inline void _rlcIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _rlc(b); _sb(a, b); } - void rlcIXB(byte o) { _rlcIX(B, o); } - void rlcIXC(byte o) { _rlcIX(C, o); } - void rlcIXD(byte o) { _rlcIX(D, o); } - void rlcIXE(byte o) { _rlcIX(E, o); } - void rlcIXH(byte o) { _rlcIX(H, o); } - void rlcIXL(byte o) { _rlcIX(L, o); } - void rlcIX(byte o) { byte b; _rlcIX(b, o); } - void rlcIXA(byte o) { _rlcIX(A, o); } + void rlcIXB(uint8_t o) { _rlcIX(B, o); } + void rlcIXC(uint8_t o) { _rlcIX(C, o); } + void rlcIXD(uint8_t o) { _rlcIX(D, o); } + void rlcIXE(uint8_t o) { _rlcIX(E, o); } + void rlcIXH(uint8_t o) { _rlcIX(H, o); } + void rlcIXL(uint8_t o) { _rlcIX(L, o); } + void rlcIX(uint8_t o) { uint8_t b; _rlcIX(b, o); } + void rlcIXA(uint8_t o) { _rlcIX(A, o); } // 0x08 - inline void _rrcIX(byte &b, byte o) { - word a = _rbIX(b, o); _rrc(b); _sb(a, b); + inline void _rrcIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _rrc(b); _sb(a, b); } - void rrcIXB(byte o) { _rrcIX(B, o); } - void rrcIXC(byte o) { _rrcIX(C, o); } - void rrcIXD(byte o) { _rrcIX(D, o); } - void rrcIXE(byte o) { _rrcIX(E, o); } - void rrcIXH(byte o) { _rrcIX(H, o); } - void rrcIXL(byte o) { _rrcIX(L, o); } - void rrcIX(byte o) { byte b; _rrcIX(b, o); } - void rrcIXA(byte o) { _rrcIX(A, o); } + void rrcIXB(uint8_t o) { _rrcIX(B, o); } + void rrcIXC(uint8_t o) { _rrcIX(C, o); } + void rrcIXD(uint8_t o) { _rrcIX(D, o); } + void rrcIXE(uint8_t o) { _rrcIX(E, o); } + void rrcIXH(uint8_t o) { _rrcIX(H, o); } + void rrcIXL(uint8_t o) { _rrcIX(L, o); } + void rrcIX(uint8_t o) { uint8_t b; _rrcIX(b, o); } + void rrcIXA(uint8_t o) { _rrcIX(A, o); } // 0x10 - inline void _rlIX(byte &b, byte o) { - word a = _rbIX(b, o); _rl(b); _sb(a, b); + inline void _rlIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _rl(b); _sb(a, b); } - void rlIXB(byte o) { _rlIX(B, o); } - void rlIXC(byte o) { _rlIX(C, o); } - void rlIXD(byte o) { _rlIX(D, o); } - void rlIXE(byte o) { _rlIX(E, o); } - void rlIXH(byte o) { _rlIX(H, o); } - void rlIXL(byte o) { _rlIX(L, o); } - void rlIX(byte o) { byte b; _rlIX(b, o); } - void rlIXA(byte o) { _rlIX(A, o); } + void rlIXB(uint8_t o) { _rlIX(B, o); } + void rlIXC(uint8_t o) { _rlIX(C, o); } + void rlIXD(uint8_t o) { _rlIX(D, o); } + void rlIXE(uint8_t o) { _rlIX(E, o); } + void rlIXH(uint8_t o) { _rlIX(H, o); } + void rlIXL(uint8_t o) { _rlIX(L, o); } + void rlIX(uint8_t o) { uint8_t b; _rlIX(b, o); } + void rlIXA(uint8_t o) { _rlIX(A, o); } // 0x18 - inline void _rrIX(byte &b, byte o) { - word a = _rbIX(b, o); _rr(b); _sb(a, b); + inline void _rrIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _rr(b); _sb(a, b); } - void rrIXB(byte o) { _rrIX(B, o); } - void rrIXC(byte o) { _rrIX(C, o); } - void rrIXD(byte o) { _rrIX(D, o); } - void rrIXE(byte o) { _rrIX(E, o); } - void rrIXH(byte o) { _rrIX(H, o); } - void rrIXL(byte o) { _rrIX(L, o); } - void rrIX(byte o) { byte b; _rrIX(b, o); } - void rrIXA(byte o) { _rrIX(A, o); } + void rrIXB(uint8_t o) { _rrIX(B, o); } + void rrIXC(uint8_t o) { _rrIX(C, o); } + void rrIXD(uint8_t o) { _rrIX(D, o); } + void rrIXE(uint8_t o) { _rrIX(E, o); } + void rrIXH(uint8_t o) { _rrIX(H, o); } + void rrIXL(uint8_t o) { _rrIX(L, o); } + void rrIX(uint8_t o) { uint8_t b; _rrIX(b, o); } + void rrIXA(uint8_t o) { _rrIX(A, o); } // 0x20 - inline void _slaIX(byte &b, byte o) { - word a = _rbIX(b, o); _sla(b); _sb(a, b); + inline void _slaIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _sla(b); _sb(a, b); } - void slaIXB(byte o) { _slaIX(B, o); } - void slaIXC(byte o) { _slaIX(C, o); } - void slaIXD(byte o) { _slaIX(D, o); } - void slaIXE(byte o) { _slaIX(E, o); } - void slaIXH(byte o) { _slaIX(H, o); } - void slaIXL(byte o) { _slaIX(L, o); } - void slaIX(byte o) { byte b; _slaIX(b, o); } - void slaIXA(byte o) { _slaIX(A, o); } + void slaIXB(uint8_t o) { _slaIX(B, o); } + void slaIXC(uint8_t o) { _slaIX(C, o); } + void slaIXD(uint8_t o) { _slaIX(D, o); } + void slaIXE(uint8_t o) { _slaIX(E, o); } + void slaIXH(uint8_t o) { _slaIX(H, o); } + void slaIXL(uint8_t o) { _slaIX(L, o); } + void slaIX(uint8_t o) { uint8_t b; _slaIX(b, o); } + void slaIXA(uint8_t o) { _slaIX(A, o); } // 0x28 - inline void _sraIX(byte &b, byte o) { - word a = _rbIX(b, o); _sra(b); _sb(a, b); + inline void _sraIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _sra(b); _sb(a, b); } - void sraIXB(byte o) { _sraIX(B, o); } - void sraIXC(byte o) { _sraIX(C, o); } - void sraIXD(byte o) { _sraIX(D, o); } - void sraIXE(byte o) { _sraIX(E, o); } - void sraIXH(byte o) { _sraIX(H, o); } - void sraIXL(byte o) { _sraIX(L, o); } - void sraIX(byte o) { byte b; _sraIX(b, o); } - void sraIXA(byte o) { _sraIX(A, o); } + void sraIXB(uint8_t o) { _sraIX(B, o); } + void sraIXC(uint8_t o) { _sraIX(C, o); } + void sraIXD(uint8_t o) { _sraIX(D, o); } + void sraIXE(uint8_t o) { _sraIX(E, o); } + void sraIXH(uint8_t o) { _sraIX(H, o); } + void sraIXL(uint8_t o) { _sraIX(L, o); } + void sraIX(uint8_t o) { uint8_t b; _sraIX(b, o); } + void sraIXA(uint8_t o) { _sraIX(A, o); } // 0x30 - inline void _sllIX(byte &b, byte o) { - word a = _rbIX(b, o); _sll(b); _sb(a, b); + inline void _sllIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _sll(b); _sb(a, b); } - void sllIXB(byte o) { _sllIX(B, o); } - void sllIXC(byte o) { _sllIX(C, o); } - void sllIXD(byte o) { _sllIX(D, o); } - void sllIXE(byte o) { _sllIX(E, o); } - void sllIXH(byte o) { _sllIX(H, o); } - void sllIXL(byte o) { _sllIX(L, o); } - void sllIX(byte o) { byte b; _sllIX(b, o); } - void sllIXA(byte o) { _sllIX(A, o); } + void sllIXB(uint8_t o) { _sllIX(B, o); } + void sllIXC(uint8_t o) { _sllIX(C, o); } + void sllIXD(uint8_t o) { _sllIX(D, o); } + void sllIXE(uint8_t o) { _sllIX(E, o); } + void sllIXH(uint8_t o) { _sllIX(H, o); } + void sllIXL(uint8_t o) { _sllIX(L, o); } + void sllIX(uint8_t o) { uint8_t b; _sllIX(b, o); } + void sllIXA(uint8_t o) { _sllIX(A, o); } // 0x38 - inline void _srlIX(byte &b, byte o) { - word a = _rbIX(b, o); _srl(b); _sb(a, b); + inline void _srlIX(uint8_t &b, uint8_t o) { + uint16_t a = _rbIX(b, o); _srl(b); _sb(a, b); } - void srlIXB(byte o) { _srlIX(B, o); } - void srlIXC(byte o) { _srlIX(C, o); } - void srlIXD(byte o) { _srlIX(D, o); } - void srlIXE(byte o) { _srlIX(E, o); } - void srlIXH(byte o) { _srlIX(H, o); } - void srlIXL(byte o) { _srlIX(L, o); } - void srlIX(byte o) { byte b; _srlIX(b, o); } - void srlIXA(byte o) { _srlIX(A, o); } + void srlIXB(uint8_t o) { _srlIX(B, o); } + void srlIXC(uint8_t o) { _srlIX(C, o); } + void srlIXD(uint8_t o) { _srlIX(D, o); } + void srlIXE(uint8_t o) { _srlIX(E, o); } + void srlIXH(uint8_t o) { _srlIX(H, o); } + void srlIXL(uint8_t o) { _srlIX(L, o); } + void srlIX(uint8_t o) { uint8_t b; _srlIX(b, o); } + void srlIXA(uint8_t o) { _srlIX(A, o); } // 0x40 - inline void _bitIX(int i, byte o) { _bitI(i, _ads(IX, o)); } + inline void _bitIX(int i, uint8_t o) { _bitI(i, _ads(IX, o)); } - void bit0IX(byte o) { _bitIX(0, o); } + void bit0IX(uint8_t o) { _bitIX(0, o); } // 0x48 - void bit1IX(byte o) { _bitIX(1, o); } + void bit1IX(uint8_t o) { _bitIX(1, o); } // 0x50 - void bit2IX(byte o) { _bitIX(2, o); } + void bit2IX(uint8_t o) { _bitIX(2, o); } // 0x58 - void bit3IX(byte o) { _bitIX(3, o); } + void bit3IX(uint8_t o) { _bitIX(3, o); } // 0x60 - void bit4IX(byte o) { _bitIX(4, o); } + void bit4IX(uint8_t o) { _bitIX(4, o); } // 0x68 - void bit5IX(byte o) { _bitIX(5, o); } + void bit5IX(uint8_t o) { _bitIX(5, o); } // 0x70 - void bit6IX(byte o) { _bitIX(6, o); } + void bit6IX(uint8_t o) { _bitIX(6, o); } // 0x78 - void bit7IX(byte o) { _bitIX(7, o); } + void bit7IX(uint8_t o) { _bitIX(7, o); } // 0x80 - void _resIX(byte &b, byte o, byte m) { - word a = _ads(IX, o); + void _resIX(uint8_t &b, uint8_t o, uint8_t m) { + uint16_t a = _ads(IX, o); b = _rb(a) & m; _mc(a, 1); _sb(a, b); } - void res0IXB(byte o) { _resIX(B, o, 0xfe); } - void res0IXC(byte o) { _resIX(C, o, 0xfe); } - void res0IXD(byte o) { _resIX(D, o, 0xfe); } - void res0IXE(byte o) { _resIX(E, o, 0xfe); } - void res0IXH(byte o) { _resIX(H, o, 0xfe); } - void res0IXL(byte o) { _resIX(L, o, 0xfe); } - void res0IX(byte o) { byte b; _resIX(b, o, 0xfe); } - void res0IXA(byte o) { _resIX(A, o, 0xfe); } + void res0IXB(uint8_t o) { _resIX(B, o, 0xfe); } + void res0IXC(uint8_t o) { _resIX(C, o, 0xfe); } + void res0IXD(uint8_t o) { _resIX(D, o, 0xfe); } + void res0IXE(uint8_t o) { _resIX(E, o, 0xfe); } + void res0IXH(uint8_t o) { _resIX(H, o, 0xfe); } + void res0IXL(uint8_t o) { _resIX(L, o, 0xfe); } + void res0IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xfe); } + void res0IXA(uint8_t o) { _resIX(A, o, 0xfe); } // 0x88 - void res1IXB(byte o) { _resIX(B, o, 0xfd); } - void res1IXC(byte o) { _resIX(C, o, 0xfd); } - void res1IXD(byte o) { _resIX(D, o, 0xfd); } - void res1IXE(byte o) { _resIX(E, o, 0xfd); } - void res1IXH(byte o) { _resIX(H, o, 0xfd); } - void res1IXL(byte o) { _resIX(L, o, 0xfd); } - void res1IX(byte o) { byte b; _resIX(b, o, 0xfd); } - void res1IXA(byte o) { _resIX(A, o, 0xfd); } + void res1IXB(uint8_t o) { _resIX(B, o, 0xfd); } + void res1IXC(uint8_t o) { _resIX(C, o, 0xfd); } + void res1IXD(uint8_t o) { _resIX(D, o, 0xfd); } + void res1IXE(uint8_t o) { _resIX(E, o, 0xfd); } + void res1IXH(uint8_t o) { _resIX(H, o, 0xfd); } + void res1IXL(uint8_t o) { _resIX(L, o, 0xfd); } + void res1IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xfd); } + void res1IXA(uint8_t o) { _resIX(A, o, 0xfd); } // 0x90 - void res2IXB(byte o) { _resIX(B, o, 0xfb); } - void res2IXC(byte o) { _resIX(C, o, 0xfb); } - void res2IXD(byte o) { _resIX(D, o, 0xfb); } - void res2IXE(byte o) { _resIX(E, o, 0xfb); } - void res2IXH(byte o) { _resIX(H, o, 0xfb); } - void res2IXL(byte o) { _resIX(L, o, 0xfb); } - void res2IX(byte o) { byte b; _resIX(b, o, 0xfb); } - void res2IXA(byte o) { _resIX(A, o, 0xfb); } + void res2IXB(uint8_t o) { _resIX(B, o, 0xfb); } + void res2IXC(uint8_t o) { _resIX(C, o, 0xfb); } + void res2IXD(uint8_t o) { _resIX(D, o, 0xfb); } + void res2IXE(uint8_t o) { _resIX(E, o, 0xfb); } + void res2IXH(uint8_t o) { _resIX(H, o, 0xfb); } + void res2IXL(uint8_t o) { _resIX(L, o, 0xfb); } + void res2IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xfb); } + void res2IXA(uint8_t o) { _resIX(A, o, 0xfb); } // 0x98 - void res3IXB(byte o) { _resIX(B, o, 0xf7); } - void res3IXC(byte o) { _resIX(C, o, 0xf7); } - void res3IXD(byte o) { _resIX(D, o, 0xf7); } - void res3IXE(byte o) { _resIX(E, o, 0xf7); } - void res3IXH(byte o) { _resIX(H, o, 0xf7); } - void res3IXL(byte o) { _resIX(L, o, 0xf7); } - void res3IX(byte o) { byte b; _resIX(b, o, 0xf7); } - void res3IXA(byte o) { _resIX(A, o, 0xf7); } + void res3IXB(uint8_t o) { _resIX(B, o, 0xf7); } + void res3IXC(uint8_t o) { _resIX(C, o, 0xf7); } + void res3IXD(uint8_t o) { _resIX(D, o, 0xf7); } + void res3IXE(uint8_t o) { _resIX(E, o, 0xf7); } + void res3IXH(uint8_t o) { _resIX(H, o, 0xf7); } + void res3IXL(uint8_t o) { _resIX(L, o, 0xf7); } + void res3IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xf7); } + void res3IXA(uint8_t o) { _resIX(A, o, 0xf7); } // 0xa0 - void res4IXB(byte o) { _resIX(B, o, 0xef); } - void res4IXC(byte o) { _resIX(C, o, 0xef); } - void res4IXD(byte o) { _resIX(D, o, 0xef); } - void res4IXE(byte o) { _resIX(E, o, 0xef); } - void res4IXH(byte o) { _resIX(H, o, 0xef); } - void res4IXL(byte o) { _resIX(L, o, 0xef); } - void res4IX(byte o) { byte b; _resIX(b, o, 0xef); } - void res4IXA(byte o) { _resIX(A, o, 0xef); } + void res4IXB(uint8_t o) { _resIX(B, o, 0xef); } + void res4IXC(uint8_t o) { _resIX(C, o, 0xef); } + void res4IXD(uint8_t o) { _resIX(D, o, 0xef); } + void res4IXE(uint8_t o) { _resIX(E, o, 0xef); } + void res4IXH(uint8_t o) { _resIX(H, o, 0xef); } + void res4IXL(uint8_t o) { _resIX(L, o, 0xef); } + void res4IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xef); } + void res4IXA(uint8_t o) { _resIX(A, o, 0xef); } // 0xa8 - void res5IXB(byte o) { _resIX(B, o, 0xdf); } - void res5IXC(byte o) { _resIX(C, o, 0xdf); } - void res5IXD(byte o) { _resIX(D, o, 0xdf); } - void res5IXE(byte o) { _resIX(E, o, 0xdf); } - void res5IXH(byte o) { _resIX(H, o, 0xdf); } - void res5IXL(byte o) { _resIX(L, o, 0xdf); } - void res5IX(byte o) { byte b; _resIX(b, o, 0xdf); } - void res5IXA(byte o) { _resIX(A, o, 0xdf); } + void res5IXB(uint8_t o) { _resIX(B, o, 0xdf); } + void res5IXC(uint8_t o) { _resIX(C, o, 0xdf); } + void res5IXD(uint8_t o) { _resIX(D, o, 0xdf); } + void res5IXE(uint8_t o) { _resIX(E, o, 0xdf); } + void res5IXH(uint8_t o) { _resIX(H, o, 0xdf); } + void res5IXL(uint8_t o) { _resIX(L, o, 0xdf); } + void res5IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xdf); } + void res5IXA(uint8_t o) { _resIX(A, o, 0xdf); } // 0xb0 - void res6IXB(byte o) { _resIX(B, o, 0xbf); } - void res6IXC(byte o) { _resIX(C, o, 0xbf); } - void res6IXD(byte o) { _resIX(D, o, 0xbf); } - void res6IXE(byte o) { _resIX(E, o, 0xbf); } - void res6IXH(byte o) { _resIX(H, o, 0xbf); } - void res6IXL(byte o) { _resIX(L, o, 0xbf); } - void res6IX(byte o) { byte b; _resIX(b, o, 0xbf); } - void res6IXA(byte o) { _resIX(A, o, 0xbf); } + void res6IXB(uint8_t o) { _resIX(B, o, 0xbf); } + void res6IXC(uint8_t o) { _resIX(C, o, 0xbf); } + void res6IXD(uint8_t o) { _resIX(D, o, 0xbf); } + void res6IXE(uint8_t o) { _resIX(E, o, 0xbf); } + void res6IXH(uint8_t o) { _resIX(H, o, 0xbf); } + void res6IXL(uint8_t o) { _resIX(L, o, 0xbf); } + void res6IX(uint8_t o) { uint8_t b; _resIX(b, o, 0xbf); } + void res6IXA(uint8_t o) { _resIX(A, o, 0xbf); } // 0xb8 - void res7IXB(byte o) { _resIX(B, o, 0x7f); } - void res7IXC(byte o) { _resIX(C, o, 0x7f); } - void res7IXD(byte o) { _resIX(D, o, 0x7f); } - void res7IXE(byte o) { _resIX(E, o, 0x7f); } - void res7IXH(byte o) { _resIX(H, o, 0x7f); } - void res7IXL(byte o) { _resIX(L, o, 0x7f); } - void res7IX(byte o) { byte b; _resIX(b, o, 0x7f); } - void res7IXA(byte o) { _resIX(A, o, 0x7f); } + void res7IXB(uint8_t o) { _resIX(B, o, 0x7f); } + void res7IXC(uint8_t o) { _resIX(C, o, 0x7f); } + void res7IXD(uint8_t o) { _resIX(D, o, 0x7f); } + void res7IXE(uint8_t o) { _resIX(E, o, 0x7f); } + void res7IXH(uint8_t o) { _resIX(H, o, 0x7f); } + void res7IXL(uint8_t o) { _resIX(L, o, 0x7f); } + void res7IX(uint8_t o) { uint8_t b; _resIX(b, o, 0x7f); } + void res7IXA(uint8_t o) { _resIX(A, o, 0x7f); } // 0xc0 - void _setIX(byte &b, byte o, byte m) { - word a = _ads(IX, o); + void _setIX(uint8_t &b, uint8_t o, uint8_t m) { + uint16_t a = _ads(IX, o); b = _rb(a) | m; _mc(a, 1); _sb(a, b); } - void set0IXB(byte o) { _setIX(B, o, 0x01); } - void set0IXC(byte o) { _setIX(C, o, 0x01); } - void set0IXD(byte o) { _setIX(D, o, 0x01); } - void set0IXE(byte o) { _setIX(E, o, 0x01); } - void set0IXH(byte o) { _setIX(H, o, 0x01); } - void set0IXL(byte o) { _setIX(L, o, 0x01); } - void set0IX(byte o) { byte b; _setIX(b, o, 0x01); } - void set0IXA(byte o) { _setIX(A, o, 0x01); } + void set0IXB(uint8_t o) { _setIX(B, o, 0x01); } + void set0IXC(uint8_t o) { _setIX(C, o, 0x01); } + void set0IXD(uint8_t o) { _setIX(D, o, 0x01); } + void set0IXE(uint8_t o) { _setIX(E, o, 0x01); } + void set0IXH(uint8_t o) { _setIX(H, o, 0x01); } + void set0IXL(uint8_t o) { _setIX(L, o, 0x01); } + void set0IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x01); } + void set0IXA(uint8_t o) { _setIX(A, o, 0x01); } // 0xc8 - void set1IXB(byte o) { _setIX(B, o, 0x02); } - void set1IXC(byte o) { _setIX(C, o, 0x02); } - void set1IXD(byte o) { _setIX(D, o, 0x02); } - void set1IXE(byte o) { _setIX(E, o, 0x02); } - void set1IXH(byte o) { _setIX(H, o, 0x02); } - void set1IXL(byte o) { _setIX(L, o, 0x02); } - void set1IX(byte o) { byte b; _setIX(b, o, 0x02); } - void set1IXA(byte o) { _setIX(A, o, 0x02); } + void set1IXB(uint8_t o) { _setIX(B, o, 0x02); } + void set1IXC(uint8_t o) { _setIX(C, o, 0x02); } + void set1IXD(uint8_t o) { _setIX(D, o, 0x02); } + void set1IXE(uint8_t o) { _setIX(E, o, 0x02); } + void set1IXH(uint8_t o) { _setIX(H, o, 0x02); } + void set1IXL(uint8_t o) { _setIX(L, o, 0x02); } + void set1IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x02); } + void set1IXA(uint8_t o) { _setIX(A, o, 0x02); } // 0xd0 - void set2IXB(byte o) { _setIX(B, o, 0x04); } - void set2IXC(byte o) { _setIX(C, o, 0x04); } - void set2IXD(byte o) { _setIX(D, o, 0x04); } - void set2IXE(byte o) { _setIX(E, o, 0x04); } - void set2IXH(byte o) { _setIX(H, o, 0x04); } - void set2IXL(byte o) { _setIX(L, o, 0x04); } - void set2IX(byte o) { byte b; _setIX(b, o, 0x04); } - void set2IXA(byte o) { _setIX(A, o, 0x04); } + void set2IXB(uint8_t o) { _setIX(B, o, 0x04); } + void set2IXC(uint8_t o) { _setIX(C, o, 0x04); } + void set2IXD(uint8_t o) { _setIX(D, o, 0x04); } + void set2IXE(uint8_t o) { _setIX(E, o, 0x04); } + void set2IXH(uint8_t o) { _setIX(H, o, 0x04); } + void set2IXL(uint8_t o) { _setIX(L, o, 0x04); } + void set2IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x04); } + void set2IXA(uint8_t o) { _setIX(A, o, 0x04); } // 0xd8 - void set3IXB(byte o) { _setIX(B, o, 0x08); } - void set3IXC(byte o) { _setIX(C, o, 0x08); } - void set3IXD(byte o) { _setIX(D, o, 0x08); } - void set3IXE(byte o) { _setIX(E, o, 0x08); } - void set3IXH(byte o) { _setIX(H, o, 0x08); } - void set3IXL(byte o) { _setIX(L, o, 0x08); } - void set3IX(byte o) { byte b; _setIX(b, o, 0x08); } - void set3IXA(byte o) { _setIX(A, o, 0x08); } + void set3IXB(uint8_t o) { _setIX(B, o, 0x08); } + void set3IXC(uint8_t o) { _setIX(C, o, 0x08); } + void set3IXD(uint8_t o) { _setIX(D, o, 0x08); } + void set3IXE(uint8_t o) { _setIX(E, o, 0x08); } + void set3IXH(uint8_t o) { _setIX(H, o, 0x08); } + void set3IXL(uint8_t o) { _setIX(L, o, 0x08); } + void set3IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x08); } + void set3IXA(uint8_t o) { _setIX(A, o, 0x08); } // 0xe0 - void set4IXB(byte o) { _setIX(B, o, 0x10); } - void set4IXC(byte o) { _setIX(C, o, 0x10); } - void set4IXD(byte o) { _setIX(D, o, 0x10); } - void set4IXE(byte o) { _setIX(E, o, 0x10); } - void set4IXH(byte o) { _setIX(H, o, 0x10); } - void set4IXL(byte o) { _setIX(L, o, 0x10); } - void set4IX(byte o) { byte b; _setIX(b, o, 0x10); } - void set4IXA(byte o) { _setIX(A, o, 0x10); } + void set4IXB(uint8_t o) { _setIX(B, o, 0x10); } + void set4IXC(uint8_t o) { _setIX(C, o, 0x10); } + void set4IXD(uint8_t o) { _setIX(D, o, 0x10); } + void set4IXE(uint8_t o) { _setIX(E, o, 0x10); } + void set4IXH(uint8_t o) { _setIX(H, o, 0x10); } + void set4IXL(uint8_t o) { _setIX(L, o, 0x10); } + void set4IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x10); } + void set4IXA(uint8_t o) { _setIX(A, o, 0x10); } // 0xe8 - void set5IXB(byte o) { _setIX(B, o, 0x20); } - void set5IXC(byte o) { _setIX(C, o, 0x20); } - void set5IXD(byte o) { _setIX(D, o, 0x20); } - void set5IXE(byte o) { _setIX(E, o, 0x20); } - void set5IXH(byte o) { _setIX(H, o, 0x20); } - void set5IXL(byte o) { _setIX(L, o, 0x20); } - void set5IX(byte o) { byte b; _setIX(b, o, 0x20); } - void set5IXA(byte o) { _setIX(A, o, 0x20); } + void set5IXB(uint8_t o) { _setIX(B, o, 0x20); } + void set5IXC(uint8_t o) { _setIX(C, o, 0x20); } + void set5IXD(uint8_t o) { _setIX(D, o, 0x20); } + void set5IXE(uint8_t o) { _setIX(E, o, 0x20); } + void set5IXH(uint8_t o) { _setIX(H, o, 0x20); } + void set5IXL(uint8_t o) { _setIX(L, o, 0x20); } + void set5IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x20); } + void set5IXA(uint8_t o) { _setIX(A, o, 0x20); } // 0xf0 - void set6IXB(byte o) { _setIX(B, o, 0x40); } - void set6IXC(byte o) { _setIX(C, o, 0x40); } - void set6IXD(byte o) { _setIX(D, o, 0x40); } - void set6IXE(byte o) { _setIX(E, o, 0x40); } - void set6IXH(byte o) { _setIX(H, o, 0x40); } - void set6IXL(byte o) { _setIX(L, o, 0x40); } - void set6IX(byte o) { byte b; _setIX(b, o, 0x40); } - void set6IXA(byte o) { _setIX(A, o, 0x40); } + void set6IXB(uint8_t o) { _setIX(B, o, 0x40); } + void set6IXC(uint8_t o) { _setIX(C, o, 0x40); } + void set6IXD(uint8_t o) { _setIX(D, o, 0x40); } + void set6IXE(uint8_t o) { _setIX(E, o, 0x40); } + void set6IXH(uint8_t o) { _setIX(H, o, 0x40); } + void set6IXL(uint8_t o) { _setIX(L, o, 0x40); } + void set6IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x40); } + void set6IXA(uint8_t o) { _setIX(A, o, 0x40); } // 0xf8 - void set7IXB(byte o) { _setIX(B, o, 0x80); } - void set7IXC(byte o) { _setIX(C, o, 0x80); } - void set7IXD(byte o) { _setIX(D, o, 0x80); } - void set7IXE(byte o) { _setIX(E, o, 0x80); } - void set7IXH(byte o) { _setIX(H, o, 0x80); } - void set7IXL(byte o) { _setIX(L, o, 0x80); } - void set7IX(byte o) { byte b; _setIX(b, o, 0x80); } - void set7IXA(byte o) { _setIX(A, o, 0x80); } + void set7IXB(uint8_t o) { _setIX(B, o, 0x80); } + void set7IXC(uint8_t o) { _setIX(C, o, 0x80); } + void set7IXD(uint8_t o) { _setIX(D, o, 0x80); } + void set7IXE(uint8_t o) { _setIX(E, o, 0x80); } + void set7IXH(uint8_t o) { _setIX(H, o, 0x80); } + void set7IXL(uint8_t o) { _setIX(L, o, 0x80); } + void set7IX(uint8_t o) { uint8_t b; _setIX(b, o, 0x80); } + void set7IXA(uint8_t o) { _setIX(A, o, 0x80); } // 0xFDCB extended instructions - inline word _rbIY(byte &b, byte o) { - word a = _ads(IY, o); + inline uint16_t _rbIY(uint8_t &b, uint8_t o) { + uint16_t a = _ads(IY, o); b = _rb(a); _mc(a, 1); return a; } // 0x00 - inline void _rlcIY(byte &b, byte o) { - word a = _rbIY(b, o); _rlc(b); _sb(a, b); + inline void _rlcIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _rlc(b); _sb(a, b); } - void rlcIYB(byte o) { _rlcIY(B, o); } - void rlcIYC(byte o) { _rlcIY(C, o); } - void rlcIYD(byte o) { _rlcIY(D, o); } - void rlcIYE(byte o) { _rlcIY(E, o); } - void rlcIYH(byte o) { _rlcIY(H, o); } - void rlcIYL(byte o) { _rlcIY(L, o); } - void rlcIY(byte o) { byte b; _rlcIY(b, o); } - void rlcIYA(byte o) { _rlcIY(A, o); } + void rlcIYB(uint8_t o) { _rlcIY(B, o); } + void rlcIYC(uint8_t o) { _rlcIY(C, o); } + void rlcIYD(uint8_t o) { _rlcIY(D, o); } + void rlcIYE(uint8_t o) { _rlcIY(E, o); } + void rlcIYH(uint8_t o) { _rlcIY(H, o); } + void rlcIYL(uint8_t o) { _rlcIY(L, o); } + void rlcIY(uint8_t o) { uint8_t b; _rlcIY(b, o); } + void rlcIYA(uint8_t o) { _rlcIY(A, o); } // 0x08 - inline void _rrcIY(byte &b, byte o) { - word a = _rbIY(b, o); _rrc(b); _sb(a, b); + inline void _rrcIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _rrc(b); _sb(a, b); } - void rrcIYB(byte o) { _rrcIY(B, o); } - void rrcIYC(byte o) { _rrcIY(C, o); } - void rrcIYD(byte o) { _rrcIY(D, o); } - void rrcIYE(byte o) { _rrcIY(E, o); } - void rrcIYH(byte o) { _rrcIY(H, o); } - void rrcIYL(byte o) { _rrcIY(L, o); } - void rrcIY(byte o) { byte b; _rrcIY(b, o); } - void rrcIYA(byte o) { _rrcIY(A, o); } + void rrcIYB(uint8_t o) { _rrcIY(B, o); } + void rrcIYC(uint8_t o) { _rrcIY(C, o); } + void rrcIYD(uint8_t o) { _rrcIY(D, o); } + void rrcIYE(uint8_t o) { _rrcIY(E, o); } + void rrcIYH(uint8_t o) { _rrcIY(H, o); } + void rrcIYL(uint8_t o) { _rrcIY(L, o); } + void rrcIY(uint8_t o) { uint8_t b; _rrcIY(b, o); } + void rrcIYA(uint8_t o) { _rrcIY(A, o); } // 0x10 - inline void _rlIY(byte &b, byte o) { - word a = _rbIY(b, o); _rl(b); _sb(a, b); + inline void _rlIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _rl(b); _sb(a, b); } - void rlIYB(byte o) { _rlIY(B, o); } - void rlIYC(byte o) { _rlIY(C, o); } - void rlIYD(byte o) { _rlIY(D, o); } - void rlIYE(byte o) { _rlIY(E, o); } - void rlIYH(byte o) { _rlIY(H, o); } - void rlIYL(byte o) { _rlIY(L, o); } - void rlIY(byte o) { byte b; _rlIY(b, o); } - void rlIYA(byte o) { _rlIY(A, o); } + void rlIYB(uint8_t o) { _rlIY(B, o); } + void rlIYC(uint8_t o) { _rlIY(C, o); } + void rlIYD(uint8_t o) { _rlIY(D, o); } + void rlIYE(uint8_t o) { _rlIY(E, o); } + void rlIYH(uint8_t o) { _rlIY(H, o); } + void rlIYL(uint8_t o) { _rlIY(L, o); } + void rlIY(uint8_t o) { uint8_t b; _rlIY(b, o); } + void rlIYA(uint8_t o) { _rlIY(A, o); } // 0x18 - inline void _rrIY(byte &b, byte o) { - word a = _rbIY(b, o); _rr(b); _sb(a, b); + inline void _rrIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _rr(b); _sb(a, b); } - void rrIYB(byte o) { _rrIY(B, o); } - void rrIYC(byte o) { _rrIY(C, o); } - void rrIYD(byte o) { _rrIY(D, o); } - void rrIYE(byte o) { _rrIY(E, o); } - void rrIYH(byte o) { _rrIY(H, o); } - void rrIYL(byte o) { _rrIY(L, o); } - void rrIY(byte o) { byte b; _rrIY(b, o); } - void rrIYA(byte o) { _rrIY(A, o); } + void rrIYB(uint8_t o) { _rrIY(B, o); } + void rrIYC(uint8_t o) { _rrIY(C, o); } + void rrIYD(uint8_t o) { _rrIY(D, o); } + void rrIYE(uint8_t o) { _rrIY(E, o); } + void rrIYH(uint8_t o) { _rrIY(H, o); } + void rrIYL(uint8_t o) { _rrIY(L, o); } + void rrIY(uint8_t o) { uint8_t b; _rrIY(b, o); } + void rrIYA(uint8_t o) { _rrIY(A, o); } // 0x20 - inline void _slaIY(byte &b, byte o) { - word a = _rbIY(b, o); _sla(b); _sb(a, b); + inline void _slaIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _sla(b); _sb(a, b); } - void slaIYB(byte o) { _slaIY(B, o); } - void slaIYC(byte o) { _slaIY(C, o); } - void slaIYD(byte o) { _slaIY(D, o); } - void slaIYE(byte o) { _slaIY(E, o); } - void slaIYH(byte o) { _slaIY(H, o); } - void slaIYL(byte o) { _slaIY(L, o); } - void slaIY(byte o) { byte b; _slaIY(b, o); } - void slaIYA(byte o) { _slaIY(A, o); } + void slaIYB(uint8_t o) { _slaIY(B, o); } + void slaIYC(uint8_t o) { _slaIY(C, o); } + void slaIYD(uint8_t o) { _slaIY(D, o); } + void slaIYE(uint8_t o) { _slaIY(E, o); } + void slaIYH(uint8_t o) { _slaIY(H, o); } + void slaIYL(uint8_t o) { _slaIY(L, o); } + void slaIY(uint8_t o) { uint8_t b; _slaIY(b, o); } + void slaIYA(uint8_t o) { _slaIY(A, o); } // 0x28 - inline void _sraIY(byte &b, byte o) { - word a = _rbIY(b, o); _sra(b); _sb(a, b); + inline void _sraIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _sra(b); _sb(a, b); } - void sraIYB(byte o) { _sraIY(B, o); } - void sraIYC(byte o) { _sraIY(C, o); } - void sraIYD(byte o) { _sraIY(D, o); } - void sraIYE(byte o) { _sraIY(E, o); } - void sraIYH(byte o) { _sraIY(H, o); } - void sraIYL(byte o) { _sraIY(L, o); } - void sraIY(byte o) { byte b; _sraIY(b, o); } - void sraIYA(byte o) { _sraIY(A, o); } + void sraIYB(uint8_t o) { _sraIY(B, o); } + void sraIYC(uint8_t o) { _sraIY(C, o); } + void sraIYD(uint8_t o) { _sraIY(D, o); } + void sraIYE(uint8_t o) { _sraIY(E, o); } + void sraIYH(uint8_t o) { _sraIY(H, o); } + void sraIYL(uint8_t o) { _sraIY(L, o); } + void sraIY(uint8_t o) { uint8_t b; _sraIY(b, o); } + void sraIYA(uint8_t o) { _sraIY(A, o); } // 0x30 - inline void _sllIY(byte &b, byte o) { - word a = _rbIY(b, o); _sll(b); _sb(a, b); + inline void _sllIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _sll(b); _sb(a, b); } - void sllIYB(byte o) { _sllIY(B, o); } - void sllIYC(byte o) { _sllIY(C, o); } - void sllIYD(byte o) { _sllIY(D, o); } - void sllIYE(byte o) { _sllIY(E, o); } - void sllIYH(byte o) { _sllIY(H, o); } - void sllIYL(byte o) { _sllIY(L, o); } - void sllIY(byte o) { byte b; _sllIY(b, o); } - void sllIYA(byte o) { _sllIY(A, o); } + void sllIYB(uint8_t o) { _sllIY(B, o); } + void sllIYC(uint8_t o) { _sllIY(C, o); } + void sllIYD(uint8_t o) { _sllIY(D, o); } + void sllIYE(uint8_t o) { _sllIY(E, o); } + void sllIYH(uint8_t o) { _sllIY(H, o); } + void sllIYL(uint8_t o) { _sllIY(L, o); } + void sllIY(uint8_t o) { uint8_t b; _sllIY(b, o); } + void sllIYA(uint8_t o) { _sllIY(A, o); } // 0x38 - inline void _srlIY(byte &b, byte o) { - word a = _rbIY(b, o); _srl(b); _sb(a, b); + inline void _srlIY(uint8_t &b, uint8_t o) { + uint16_t a = _rbIY(b, o); _srl(b); _sb(a, b); } - void srlIYB(byte o) { _srlIY(B, o); } - void srlIYC(byte o) { _srlIY(C, o); } - void srlIYD(byte o) { _srlIY(D, o); } - void srlIYE(byte o) { _srlIY(E, o); } - void srlIYH(byte o) { _srlIY(H, o); } - void srlIYL(byte o) { _srlIY(L, o); } - void srlIY(byte o) { byte b; _srlIY(b, o); } - void srlIYA(byte o) { _srlIY(A, o); } + void srlIYB(uint8_t o) { _srlIY(B, o); } + void srlIYC(uint8_t o) { _srlIY(C, o); } + void srlIYD(uint8_t o) { _srlIY(D, o); } + void srlIYE(uint8_t o) { _srlIY(E, o); } + void srlIYH(uint8_t o) { _srlIY(H, o); } + void srlIYL(uint8_t o) { _srlIY(L, o); } + void srlIY(uint8_t o) { uint8_t b; _srlIY(b, o); } + void srlIYA(uint8_t o) { _srlIY(A, o); } // 0x40 - inline void _bitIY(int i, byte o) { _bitI(i, _ads(IY, o)); } + inline void _bitIY(int i, uint8_t o) { _bitI(i, _ads(IY, o)); } - void bit0IY(byte o) { _bitIY(0, o); } + void bit0IY(uint8_t o) { _bitIY(0, o); } // 0x48 - void bit1IY(byte o) { _bitIY(1, o); } + void bit1IY(uint8_t o) { _bitIY(1, o); } // 0x50 - void bit2IY(byte o) { _bitIY(2, o); } + void bit2IY(uint8_t o) { _bitIY(2, o); } // 0x58 - void bit3IY(byte o) { _bitIY(3, o); } + void bit3IY(uint8_t o) { _bitIY(3, o); } // 0x60 - void bit4IY(byte o) { _bitIY(4, o); } + void bit4IY(uint8_t o) { _bitIY(4, o); } // 0x68 - void bit5IY(byte o) { _bitIY(5, o); } + void bit5IY(uint8_t o) { _bitIY(5, o); } // 0x70 - void bit6IY(byte o) { _bitIY(6, o); } + void bit6IY(uint8_t o) { _bitIY(6, o); } // 0x78 - void bit7IY(byte o) { _bitIY(7, o); } + void bit7IY(uint8_t o) { _bitIY(7, o); } // 0x80 - void _resIY(byte &b, byte o, byte m) { - word a = _ads(IY, o); + void _resIY(uint8_t &b, uint8_t o, uint8_t m) { + uint16_t a = _ads(IY, o); b = _rb(a) & m; _mc(a, 1); _sb(a, b); } - void res0IYB(byte o) { _resIY(B, o, 0xfe); } - void res0IYC(byte o) { _resIY(C, o, 0xfe); } - void res0IYD(byte o) { _resIY(D, o, 0xfe); } - void res0IYE(byte o) { _resIY(E, o, 0xfe); } - void res0IYH(byte o) { _resIY(H, o, 0xfe); } - void res0IYL(byte o) { _resIY(L, o, 0xfe); } - void res0IY(byte o) { byte b; _resIY(b, o, 0xfe); } - void res0IYA(byte o) { _resIY(A, o, 0xfe); } + void res0IYB(uint8_t o) { _resIY(B, o, 0xfe); } + void res0IYC(uint8_t o) { _resIY(C, o, 0xfe); } + void res0IYD(uint8_t o) { _resIY(D, o, 0xfe); } + void res0IYE(uint8_t o) { _resIY(E, o, 0xfe); } + void res0IYH(uint8_t o) { _resIY(H, o, 0xfe); } + void res0IYL(uint8_t o) { _resIY(L, o, 0xfe); } + void res0IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xfe); } + void res0IYA(uint8_t o) { _resIY(A, o, 0xfe); } // 0x88 - void res1IYB(byte o) { _resIY(B, o, 0xfd); } - void res1IYC(byte o) { _resIY(C, o, 0xfd); } - void res1IYD(byte o) { _resIY(D, o, 0xfd); } - void res1IYE(byte o) { _resIY(E, o, 0xfd); } - void res1IYH(byte o) { _resIY(H, o, 0xfd); } - void res1IYL(byte o) { _resIY(L, o, 0xfd); } - void res1IY(byte o) { byte b; _resIY(b, o, 0xfd); } - void res1IYA(byte o) { _resIY(A, o, 0xfd); } + void res1IYB(uint8_t o) { _resIY(B, o, 0xfd); } + void res1IYC(uint8_t o) { _resIY(C, o, 0xfd); } + void res1IYD(uint8_t o) { _resIY(D, o, 0xfd); } + void res1IYE(uint8_t o) { _resIY(E, o, 0xfd); } + void res1IYH(uint8_t o) { _resIY(H, o, 0xfd); } + void res1IYL(uint8_t o) { _resIY(L, o, 0xfd); } + void res1IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xfd); } + void res1IYA(uint8_t o) { _resIY(A, o, 0xfd); } // 0x90 - void res2IYB(byte o) { _resIY(B, o, 0xfb); } - void res2IYC(byte o) { _resIY(C, o, 0xfb); } - void res2IYD(byte o) { _resIY(D, o, 0xfb); } - void res2IYE(byte o) { _resIY(E, o, 0xfb); } - void res2IYH(byte o) { _resIY(H, o, 0xfb); } - void res2IYL(byte o) { _resIY(L, o, 0xfb); } - void res2IY(byte o) { byte b; _resIY(b, o, 0xfb); } - void res2IYA(byte o) { _resIY(A, o, 0xfb); } + void res2IYB(uint8_t o) { _resIY(B, o, 0xfb); } + void res2IYC(uint8_t o) { _resIY(C, o, 0xfb); } + void res2IYD(uint8_t o) { _resIY(D, o, 0xfb); } + void res2IYE(uint8_t o) { _resIY(E, o, 0xfb); } + void res2IYH(uint8_t o) { _resIY(H, o, 0xfb); } + void res2IYL(uint8_t o) { _resIY(L, o, 0xfb); } + void res2IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xfb); } + void res2IYA(uint8_t o) { _resIY(A, o, 0xfb); } // 0x98 - void res3IYB(byte o) { _resIY(B, o, 0xf7); } - void res3IYC(byte o) { _resIY(C, o, 0xf7); } - void res3IYD(byte o) { _resIY(D, o, 0xf7); } - void res3IYE(byte o) { _resIY(E, o, 0xf7); } - void res3IYH(byte o) { _resIY(H, o, 0xf7); } - void res3IYL(byte o) { _resIY(L, o, 0xf7); } - void res3IY(byte o) { byte b; _resIY(b, o, 0xf7); } - void res3IYA(byte o) { _resIY(A, o, 0xf7); } + void res3IYB(uint8_t o) { _resIY(B, o, 0xf7); } + void res3IYC(uint8_t o) { _resIY(C, o, 0xf7); } + void res3IYD(uint8_t o) { _resIY(D, o, 0xf7); } + void res3IYE(uint8_t o) { _resIY(E, o, 0xf7); } + void res3IYH(uint8_t o) { _resIY(H, o, 0xf7); } + void res3IYL(uint8_t o) { _resIY(L, o, 0xf7); } + void res3IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xf7); } + void res3IYA(uint8_t o) { _resIY(A, o, 0xf7); } // 0xa0 - void res4IYB(byte o) { _resIY(B, o, 0xef); } - void res4IYC(byte o) { _resIY(C, o, 0xef); } - void res4IYD(byte o) { _resIY(D, o, 0xef); } - void res4IYE(byte o) { _resIY(E, o, 0xef); } - void res4IYH(byte o) { _resIY(H, o, 0xef); } - void res4IYL(byte o) { _resIY(L, o, 0xef); } - void res4IY(byte o) { byte b; _resIY(b, o, 0xef); } - void res4IYA(byte o) { _resIY(A, o, 0xef); } + void res4IYB(uint8_t o) { _resIY(B, o, 0xef); } + void res4IYC(uint8_t o) { _resIY(C, o, 0xef); } + void res4IYD(uint8_t o) { _resIY(D, o, 0xef); } + void res4IYE(uint8_t o) { _resIY(E, o, 0xef); } + void res4IYH(uint8_t o) { _resIY(H, o, 0xef); } + void res4IYL(uint8_t o) { _resIY(L, o, 0xef); } + void res4IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xef); } + void res4IYA(uint8_t o) { _resIY(A, o, 0xef); } // 0xa8 - void res5IYB(byte o) { _resIY(B, o, 0xdf); } - void res5IYC(byte o) { _resIY(C, o, 0xdf); } - void res5IYD(byte o) { _resIY(D, o, 0xdf); } - void res5IYE(byte o) { _resIY(E, o, 0xdf); } - void res5IYH(byte o) { _resIY(H, o, 0xdf); } - void res5IYL(byte o) { _resIY(L, o, 0xdf); } - void res5IY(byte o) { byte b; _resIY(b, o, 0xdf); } - void res5IYA(byte o) { _resIY(A, o, 0xdf); } + void res5IYB(uint8_t o) { _resIY(B, o, 0xdf); } + void res5IYC(uint8_t o) { _resIY(C, o, 0xdf); } + void res5IYD(uint8_t o) { _resIY(D, o, 0xdf); } + void res5IYE(uint8_t o) { _resIY(E, o, 0xdf); } + void res5IYH(uint8_t o) { _resIY(H, o, 0xdf); } + void res5IYL(uint8_t o) { _resIY(L, o, 0xdf); } + void res5IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xdf); } + void res5IYA(uint8_t o) { _resIY(A, o, 0xdf); } // 0xb0 - void res6IYB(byte o) { _resIY(B, o, 0xbf); } - void res6IYC(byte o) { _resIY(C, o, 0xbf); } - void res6IYD(byte o) { _resIY(D, o, 0xbf); } - void res6IYE(byte o) { _resIY(E, o, 0xbf); } - void res6IYH(byte o) { _resIY(H, o, 0xbf); } - void res6IYL(byte o) { _resIY(L, o, 0xbf); } - void res6IY(byte o) { byte b; _resIY(b, o, 0xbf); } - void res6IYA(byte o) { _resIY(A, o, 0xbf); } + void res6IYB(uint8_t o) { _resIY(B, o, 0xbf); } + void res6IYC(uint8_t o) { _resIY(C, o, 0xbf); } + void res6IYD(uint8_t o) { _resIY(D, o, 0xbf); } + void res6IYE(uint8_t o) { _resIY(E, o, 0xbf); } + void res6IYH(uint8_t o) { _resIY(H, o, 0xbf); } + void res6IYL(uint8_t o) { _resIY(L, o, 0xbf); } + void res6IY(uint8_t o) { uint8_t b; _resIY(b, o, 0xbf); } + void res6IYA(uint8_t o) { _resIY(A, o, 0xbf); } // 0xb8 - void res7IYB(byte o) { _resIY(B, o, 0x7f); } - void res7IYC(byte o) { _resIY(C, o, 0x7f); } - void res7IYD(byte o) { _resIY(D, o, 0x7f); } - void res7IYE(byte o) { _resIY(E, o, 0x7f); } - void res7IYH(byte o) { _resIY(H, o, 0x7f); } - void res7IYL(byte o) { _resIY(L, o, 0x7f); } - void res7IY(byte o) { byte b; _resIY(b, o, 0x7f); } - void res7IYA(byte o) { _resIY(A, o, 0x7f); } + void res7IYB(uint8_t o) { _resIY(B, o, 0x7f); } + void res7IYC(uint8_t o) { _resIY(C, o, 0x7f); } + void res7IYD(uint8_t o) { _resIY(D, o, 0x7f); } + void res7IYE(uint8_t o) { _resIY(E, o, 0x7f); } + void res7IYH(uint8_t o) { _resIY(H, o, 0x7f); } + void res7IYL(uint8_t o) { _resIY(L, o, 0x7f); } + void res7IY(uint8_t o) { uint8_t b; _resIY(b, o, 0x7f); } + void res7IYA(uint8_t o) { _resIY(A, o, 0x7f); } // 0xc0 - void _setIY(byte &b, byte o, byte m) { - word a = _ads(IY, o); + void _setIY(uint8_t &b, uint8_t o, uint8_t m) { + uint16_t a = _ads(IY, o); b = _rb(a) | m; _mc(a, 1); _sb(a, b); } - void set0IYB(byte o) { _setIY(B, o, 0x01); } - void set0IYC(byte o) { _setIY(C, o, 0x01); } - void set0IYD(byte o) { _setIY(D, o, 0x01); } - void set0IYE(byte o) { _setIY(E, o, 0x01); } - void set0IYH(byte o) { _setIY(H, o, 0x01); } - void set0IYL(byte o) { _setIY(L, o, 0x01); } - void set0IY(byte o) { byte b; _setIY(b, o, 0x01); } - void set0IYA(byte o) { _setIY(A, o, 0x01); } + void set0IYB(uint8_t o) { _setIY(B, o, 0x01); } + void set0IYC(uint8_t o) { _setIY(C, o, 0x01); } + void set0IYD(uint8_t o) { _setIY(D, o, 0x01); } + void set0IYE(uint8_t o) { _setIY(E, o, 0x01); } + void set0IYH(uint8_t o) { _setIY(H, o, 0x01); } + void set0IYL(uint8_t o) { _setIY(L, o, 0x01); } + void set0IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x01); } + void set0IYA(uint8_t o) { _setIY(A, o, 0x01); } // 0xc8 - void set1IYB(byte o) { _setIY(B, o, 0x02); } - void set1IYC(byte o) { _setIY(C, o, 0x02); } - void set1IYD(byte o) { _setIY(D, o, 0x02); } - void set1IYE(byte o) { _setIY(E, o, 0x02); } - void set1IYH(byte o) { _setIY(H, o, 0x02); } - void set1IYL(byte o) { _setIY(L, o, 0x02); } - void set1IY(byte o) { byte b; _setIY(b, o, 0x02); } - void set1IYA(byte o) { _setIY(A, o, 0x02); } + void set1IYB(uint8_t o) { _setIY(B, o, 0x02); } + void set1IYC(uint8_t o) { _setIY(C, o, 0x02); } + void set1IYD(uint8_t o) { _setIY(D, o, 0x02); } + void set1IYE(uint8_t o) { _setIY(E, o, 0x02); } + void set1IYH(uint8_t o) { _setIY(H, o, 0x02); } + void set1IYL(uint8_t o) { _setIY(L, o, 0x02); } + void set1IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x02); } + void set1IYA(uint8_t o) { _setIY(A, o, 0x02); } // 0xd0 - void set2IYB(byte o) { _setIY(B, o, 0x04); } - void set2IYC(byte o) { _setIY(C, o, 0x04); } - void set2IYD(byte o) { _setIY(D, o, 0x04); } - void set2IYE(byte o) { _setIY(E, o, 0x04); } - void set2IYH(byte o) { _setIY(H, o, 0x04); } - void set2IYL(byte o) { _setIY(L, o, 0x04); } - void set2IY(byte o) { byte b; _setIY(b, o, 0x04); } - void set2IYA(byte o) { _setIY(A, o, 0x04); } + void set2IYB(uint8_t o) { _setIY(B, o, 0x04); } + void set2IYC(uint8_t o) { _setIY(C, o, 0x04); } + void set2IYD(uint8_t o) { _setIY(D, o, 0x04); } + void set2IYE(uint8_t o) { _setIY(E, o, 0x04); } + void set2IYH(uint8_t o) { _setIY(H, o, 0x04); } + void set2IYL(uint8_t o) { _setIY(L, o, 0x04); } + void set2IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x04); } + void set2IYA(uint8_t o) { _setIY(A, o, 0x04); } // 0xd8 - void set3IYB(byte o) { _setIY(B, o, 0x08); } - void set3IYC(byte o) { _setIY(C, o, 0x08); } - void set3IYD(byte o) { _setIY(D, o, 0x08); } - void set3IYE(byte o) { _setIY(E, o, 0x08); } - void set3IYH(byte o) { _setIY(H, o, 0x08); } - void set3IYL(byte o) { _setIY(L, o, 0x08); } - void set3IY(byte o) { byte b; _setIY(b, o, 0x08); } - void set3IYA(byte o) { _setIY(A, o, 0x08); } + void set3IYB(uint8_t o) { _setIY(B, o, 0x08); } + void set3IYC(uint8_t o) { _setIY(C, o, 0x08); } + void set3IYD(uint8_t o) { _setIY(D, o, 0x08); } + void set3IYE(uint8_t o) { _setIY(E, o, 0x08); } + void set3IYH(uint8_t o) { _setIY(H, o, 0x08); } + void set3IYL(uint8_t o) { _setIY(L, o, 0x08); } + void set3IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x08); } + void set3IYA(uint8_t o) { _setIY(A, o, 0x08); } // 0xe0 - void set4IYB(byte o) { _setIY(B, o, 0x10); } - void set4IYC(byte o) { _setIY(C, o, 0x10); } - void set4IYD(byte o) { _setIY(D, o, 0x10); } - void set4IYE(byte o) { _setIY(E, o, 0x10); } - void set4IYH(byte o) { _setIY(H, o, 0x10); } - void set4IYL(byte o) { _setIY(L, o, 0x10); } - void set4IY(byte o) { byte b; _setIY(b, o, 0x10); } - void set4IYA(byte o) { _setIY(A, o, 0x10); } + void set4IYB(uint8_t o) { _setIY(B, o, 0x10); } + void set4IYC(uint8_t o) { _setIY(C, o, 0x10); } + void set4IYD(uint8_t o) { _setIY(D, o, 0x10); } + void set4IYE(uint8_t o) { _setIY(E, o, 0x10); } + void set4IYH(uint8_t o) { _setIY(H, o, 0x10); } + void set4IYL(uint8_t o) { _setIY(L, o, 0x10); } + void set4IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x10); } + void set4IYA(uint8_t o) { _setIY(A, o, 0x10); } // 0xe8 - void set5IYB(byte o) { _setIY(B, o, 0x20); } - void set5IYC(byte o) { _setIY(C, o, 0x20); } - void set5IYD(byte o) { _setIY(D, o, 0x20); } - void set5IYE(byte o) { _setIY(E, o, 0x20); } - void set5IYH(byte o) { _setIY(H, o, 0x20); } - void set5IYL(byte o) { _setIY(L, o, 0x20); } - void set5IY(byte o) { byte b; _setIY(b, o, 0x20); } - void set5IYA(byte o) { _setIY(A, o, 0x20); } + void set5IYB(uint8_t o) { _setIY(B, o, 0x20); } + void set5IYC(uint8_t o) { _setIY(C, o, 0x20); } + void set5IYD(uint8_t o) { _setIY(D, o, 0x20); } + void set5IYE(uint8_t o) { _setIY(E, o, 0x20); } + void set5IYH(uint8_t o) { _setIY(H, o, 0x20); } + void set5IYL(uint8_t o) { _setIY(L, o, 0x20); } + void set5IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x20); } + void set5IYA(uint8_t o) { _setIY(A, o, 0x20); } // 0xf0 - void set6IYB(byte o) { _setIY(B, o, 0x40); } - void set6IYC(byte o) { _setIY(C, o, 0x40); } - void set6IYD(byte o) { _setIY(D, o, 0x40); } - void set6IYE(byte o) { _setIY(E, o, 0x40); } - void set6IYH(byte o) { _setIY(H, o, 0x40); } - void set6IYL(byte o) { _setIY(L, o, 0x40); } - void set6IY(byte o) { byte b; _setIY(b, o, 0x40); } - void set6IYA(byte o) { _setIY(A, o, 0x40); } + void set6IYB(uint8_t o) { _setIY(B, o, 0x40); } + void set6IYC(uint8_t o) { _setIY(C, o, 0x40); } + void set6IYD(uint8_t o) { _setIY(D, o, 0x40); } + void set6IYE(uint8_t o) { _setIY(E, o, 0x40); } + void set6IYH(uint8_t o) { _setIY(H, o, 0x40); } + void set6IYL(uint8_t o) { _setIY(L, o, 0x40); } + void set6IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x40); } + void set6IYA(uint8_t o) { _setIY(A, o, 0x40); } // 0xf8 - void set7IYB(byte o) { _setIY(B, o, 0x80); } - void set7IYC(byte o) { _setIY(C, o, 0x80); } - void set7IYD(byte o) { _setIY(D, o, 0x80); } - void set7IYE(byte o) { _setIY(E, o, 0x80); } - void set7IYH(byte o) { _setIY(H, o, 0x80); } - void set7IYL(byte o) { _setIY(L, o, 0x80); } - void set7IY(byte o) { byte b; _setIY(b, o, 0x80); } - void set7IYA(byte o) { _setIY(A, o, 0x80); } + void set7IYB(uint8_t o) { _setIY(B, o, 0x80); } + void set7IYC(uint8_t o) { _setIY(C, o, 0x80); } + void set7IYD(uint8_t o) { _setIY(D, o, 0x80); } + void set7IYE(uint8_t o) { _setIY(E, o, 0x80); } + void set7IYH(uint8_t o) { _setIY(H, o, 0x80); } + void set7IYL(uint8_t o) { _setIY(L, o, 0x80); } + void set7IY(uint8_t o) { uint8_t b; _setIY(b, o, 0x80); } + void set7IYA(uint8_t o) { _setIY(A, o, 0x80); } }; #endif