mirror of
https://github.com/jscrane/r65emu.git
synced 2025-08-06 13:25:26 +00:00
remove cpu parameter from ports
This commit is contained in:
8
i8080.h
8
i8080.h
@@ -9,7 +9,7 @@ uint8_t parity(uint8_t);
|
|||||||
|
|
||||||
class i8080: public CPU {
|
class i8080: public CPU {
|
||||||
public:
|
public:
|
||||||
i8080(Memory &m, PortDevice<i8080> &d): CPU(m), _ports(&d) {}
|
i8080(Memory &m, PortDevice &d): CPU(m), _ports(d) {}
|
||||||
|
|
||||||
void run(unsigned);
|
void run(unsigned);
|
||||||
void reset();
|
void reset();
|
||||||
@@ -60,7 +60,7 @@ private:
|
|||||||
uint8_t SR;
|
uint8_t SR;
|
||||||
};
|
};
|
||||||
uint8_t _irq_pending;
|
uint8_t _irq_pending;
|
||||||
PortDevice<i8080> *_ports;
|
PortDevice &_ports;
|
||||||
|
|
||||||
void _op(uint8_t op);
|
void _op(uint8_t op);
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ private:
|
|||||||
inline void rnc() { _ret(!flags.C); }
|
inline void rnc() { _ret(!flags.C); }
|
||||||
inline void popd() { DE = _pop(); }
|
inline void popd() { DE = _pop(); }
|
||||||
inline void jnc() { _jmp(!flags.C); }
|
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 cnc() { _call(!flags.C); }
|
||||||
inline void pushd() { _push(DE); }
|
inline void pushd() { _push(DE); }
|
||||||
inline void sui() { _sub(_mem[PC++]); }
|
inline void sui() { _sub(_mem[PC++]); }
|
||||||
@@ -408,7 +408,7 @@ private:
|
|||||||
inline void rc() { _ret(flags.C); }
|
inline void rc() { _ret(flags.C); }
|
||||||
|
|
||||||
inline void jc() { _jmp(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 cc() { _call(flags.C); }
|
||||||
|
|
||||||
inline void sbi() { _sbc(_mem[PC++]); }
|
inline void sbi() { _sbc(_mem[PC++]); }
|
||||||
|
5
ports.h
5
ports.h
@@ -1,11 +1,10 @@
|
|||||||
#ifndef __PORTS_H__
|
#ifndef __PORTS_H__
|
||||||
#define __PORTS_H__
|
#define __PORTS_H__
|
||||||
|
|
||||||
template<class P>
|
|
||||||
class PortDevice {
|
class PortDevice {
|
||||||
public:
|
public:
|
||||||
virtual void out(uint16_t p, uint8_t v, P *cpu) =0;
|
virtual void out(uint16_t p, uint8_t v) =0;
|
||||||
virtual uint8_t in(uint16_t p, P *cpu) =0;
|
virtual uint8_t in(uint16_t p) =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
z80.h
12
z80.h
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
class z80: public CPU {
|
class z80: public CPU {
|
||||||
public:
|
public:
|
||||||
z80(Memory &m, PortDevice<z80> &ports): CPU(m), _ports(&ports) {}
|
z80(Memory &m, PortDevice &ports): CPU(m), _ports(ports) {}
|
||||||
|
|
||||||
void run(unsigned);
|
void run(unsigned);
|
||||||
void reset();
|
void reset();
|
||||||
@@ -146,7 +146,7 @@ private:
|
|||||||
unsigned long _ts;
|
unsigned long _ts;
|
||||||
|
|
||||||
uint8_t _irq_pending;
|
uint8_t _irq_pending;
|
||||||
PortDevice<z80> *_ports;
|
PortDevice &_ports;
|
||||||
|
|
||||||
uint8_t parity(uint8_t);
|
uint8_t parity(uint8_t);
|
||||||
|
|
||||||
@@ -712,7 +712,7 @@ private:
|
|||||||
uint8_t b = _rb(PC++);
|
uint8_t b = _rb(PC++);
|
||||||
uint16_t p = b + (A << 8);
|
uint16_t p = b + (A << 8);
|
||||||
MPH = A; MPL = b+1;
|
MPH = A; MPL = b+1;
|
||||||
_ports->out(p, A, this);
|
_ports.out(p, A);
|
||||||
}
|
}
|
||||||
inline void callnc() { _call(!flags.C); }
|
inline void callnc() { _call(!flags.C); }
|
||||||
inline void pushde() { _mc(IR, 1); _push(DE); }
|
inline void pushde() { _mc(IR, 1); _push(DE); }
|
||||||
@@ -726,7 +726,7 @@ private:
|
|||||||
inline void ina() {
|
inline void ina() {
|
||||||
uint8_t b = _rb(PC++);
|
uint8_t b = _rb(PC++);
|
||||||
uint16_t p = b + (A << 8);
|
uint16_t p = b + (A << 8);
|
||||||
A = _ports->in(p, this);
|
A = _ports.in(p);
|
||||||
MPH = A; MPL = b+1;
|
MPH = A; MPL = b+1;
|
||||||
}
|
}
|
||||||
inline void callc() { _call(flags.C); }
|
inline void callc() { _call(flags.C); }
|
||||||
@@ -747,14 +747,14 @@ private:
|
|||||||
// 0xe8
|
// 0xe8
|
||||||
inline uint8_t _inr() {
|
inline uint8_t _inr() {
|
||||||
_memptr = BC+1;
|
_memptr = BC+1;
|
||||||
uint8_t b = _ports->in(BC, this);
|
uint8_t b = _ports.in(BC);
|
||||||
_szp35(b);
|
_szp35(b);
|
||||||
flags.N = flags.H = 0;
|
flags.N = flags.H = 0;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
inline void _outr(uint8_t b) {
|
inline void _outr(uint8_t b) {
|
||||||
_memptr = BC+1;
|
_memptr = BC+1;
|
||||||
_ports->out(BC, b, this);
|
_ports.out(BC, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void retpe() { _ret(flags.P); }
|
inline void retpe() { _ret(flags.P); }
|
||||||
|
Reference in New Issue
Block a user