1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-10-28 07:25:06 +00:00

remove cpu parameter from ports

This commit is contained in:
steve 2024-08-27 09:34:47 +01:00
parent 0a89a982c0
commit 23bfa71c3e
3 changed files with 12 additions and 13 deletions

View File

@ -9,7 +9,7 @@ uint8_t parity(uint8_t);
class i8080: public CPU {
public:
i8080(Memory &m, PortDevice<i8080> &d): CPU(m), _ports(&d) {}
i8080(Memory &m, PortDevice &d): CPU(m), _ports(d) {}
void run(unsigned);
void reset();
@ -60,7 +60,7 @@ private:
uint8_t SR;
};
uint8_t _irq_pending;
PortDevice<i8080> *_ports;
PortDevice &_ports;
void _op(uint8_t op);
@ -400,7 +400,7 @@ private:
inline void rnc() { _ret(!flags.C); }
inline void popd() { DE = _pop(); }
inline void jnc() { _jmp(!flags.C); }
inline void out() { _ports->out(_mem[PC++], A, this); }
inline void out() { _ports.out(_mem[PC++], A); }
inline void cnc() { _call(!flags.C); }
inline void pushd() { _push(DE); }
inline void sui() { _sub(_mem[PC++]); }
@ -408,7 +408,7 @@ private:
inline void rc() { _ret(flags.C); }
inline void jc() { _jmp(flags.C); }
inline void in() { A = _ports->in(_mem[PC++], this); }
inline void in() { A = _ports.in(_mem[PC++]); }
inline void cc() { _call(flags.C); }
inline void sbi() { _sbc(_mem[PC++]); }

View File

@ -1,11 +1,10 @@
#ifndef __PORTS_H__
#define __PORTS_H__
template<class P>
class PortDevice {
public:
virtual void out(uint16_t p, uint8_t v, P *cpu) =0;
virtual uint8_t in(uint16_t p, P *cpu) =0;
virtual void out(uint16_t p, uint8_t v) =0;
virtual uint8_t in(uint16_t p) =0;
};
#endif

12
z80.h
View File

@ -7,7 +7,7 @@
class z80: public CPU {
public:
z80(Memory &m, PortDevice<z80> &ports): CPU(m), _ports(&ports) {}
z80(Memory &m, PortDevice &ports): CPU(m), _ports(ports) {}
void run(unsigned);
void reset();
@ -146,7 +146,7 @@ private:
unsigned long _ts;
uint8_t _irq_pending;
PortDevice<z80> *_ports;
PortDevice &_ports;
uint8_t parity(uint8_t);
@ -712,7 +712,7 @@ private:
uint8_t b = _rb(PC++);
uint16_t p = b + (A << 8);
MPH = A; MPL = b+1;
_ports->out(p, A, this);
_ports.out(p, A);
}
inline void callnc() { _call(!flags.C); }
inline void pushde() { _mc(IR, 1); _push(DE); }
@ -726,7 +726,7 @@ private:
inline void ina() {
uint8_t b = _rb(PC++);
uint16_t p = b + (A << 8);
A = _ports->in(p, this);
A = _ports.in(p);
MPH = A; MPL = b+1;
}
inline void callc() { _call(flags.C); }
@ -747,14 +747,14 @@ private:
// 0xe8
inline uint8_t _inr() {
_memptr = BC+1;
uint8_t b = _ports->in(BC, this);
uint8_t b = _ports.in(BC);
_szp35(b);
flags.N = flags.H = 0;
return b;
}
inline void _outr(uint8_t b) {
_memptr = BC+1;
_ports->out(BC, b, this);
_ports.out(BC, b);
}
inline void retpe() { _ret(flags.P); }