59 inline byte getA2()
const {
return AF2 >> 8; }
60 inline byte getF2()
const {
return AF2 & 255; }
61 inline byte getB2()
const {
return BC2 >> 8; }
62 inline byte getC2()
const {
return BC2 & 255; }
63 inline byte getD2()
const {
return DE2 >> 8; }
64 inline byte getE2()
const {
return DE2 & 255; }
65 inline byte getH2()
const {
return HL2 >> 8; }
66 inline byte getL2()
const {
return HL2 & 255; }
72 inline byte getPCl()
const {
return PC & 255; }
88 inline byte getI()
const {
return I; }
89 inline byte getR()
const {
return (
R & 0x7F) | (R2 & 0x80); }
90 inline bool getIFF1()
const {
return IFF1; }
91 inline bool getIFF2()
const {
return IFF2; }
92 inline bool getHALT()
const {
return HALT; }
94 inline void setA(
byte x) {
AF = (
AF & 0x00FF) | (x << 8); }
96 inline void setB(
byte x) {
BC = (
BC & 0x00FF) | (x << 8); }
98 inline void setD(
byte x) {
DE = (
DE & 0x00FF) | (x << 8); }
100 inline void setH(
byte x) {
HL = (
HL & 0x00FF) | (x << 8); }
102 inline void setA2(
byte x) { AF2 = (AF2 & 0x00FF) | (x << 8); }
103 inline void setF2(
byte x) { AF2 = (AF2 & 0xFF00) | x; }
104 inline void setB2(
byte x) { BC2 = (BC2 & 0x00FF) | (x << 8); }
105 inline void setC2(
byte x) { BC2 = (BC2 & 0xFF00) | x; }
106 inline void setD2(
byte x) { DE2 = (DE2 & 0x00FF) | (x << 8); }
107 inline void setE2(
byte x) { DE2 = (DE2 & 0xFF00) | x; }
108 inline void setH2(
byte x) { HL2 = (HL2 & 0x00FF) | (x << 8); }
109 inline void setL2(
byte x) { HL2 = (HL2 & 0xFF00) | x; }
114 inline void setPCh(
byte x) { PC = (PC & 0x00FF) | (x << 8); }
115 inline void setPCl(
byte x) { PC = (PC & 0xFF00) | x; }
132 inline void setR(
byte x) {
R = x; R2 = x; }
133 inline void setIFF1(
bool x) { IFF1 = x; }
134 inline void setIFF2(
bool x) { IFF2 = x; }
135 inline void setHALT(
bool x) { HALT = x; }
141 word AF2, BC2, DE2, HL2;
143 bool IFF1, IFF2, HALT;
148 enum Reg8 {
A,
F,
B,
C,
D,
E,
H,
L,
IXH,
IXL,
IYH,
IYL,
REG_I,
REG_R,
DUMMY };
152 CPURegs(
bool r800) : HALT_(0), Rmask(r800 ? 0xff : 0x7f) {}
178 if (R8 ==
A) {
return getA(); }
179 else if (R8 ==
F) {
return getF(); }
180 else if (R8 ==
B) {
return getB(); }
181 else if (R8 ==
C) {
return getC(); }
182 else if (R8 ==
D) {
return getD(); }
183 else if (R8 ==
E) {
return getE(); }
184 else if (R8 ==
H) {
return getH(); }
185 else if (R8 ==
L) {
return getL(); }
192 else if (R8 ==
DUMMY) {
return 0; }
196 inline unsigned getAF()
const {
return AF_.
w; }
197 inline unsigned getBC()
const {
return BC_.
w; }
198 inline unsigned getDE()
const {
return DE_.
w; }
199 inline unsigned getHL()
const {
return HL_.
w; }
200 inline unsigned getAF2()
const {
return AF2_.
w; }
201 inline unsigned getBC2()
const {
return BC2_.
w; }
202 inline unsigned getDE2()
const {
return DE2_.
w; }
203 inline unsigned getHL2()
const {
return HL2_.
w; }
204 inline unsigned getIX()
const {
return IX_.
w; }
205 inline unsigned getIY()
const {
return IY_.
w; }
206 inline unsigned getPC()
const {
return PC_.
w; }
207 inline unsigned getSP()
const {
return SP_.
w; }
208 template <Reg16 R16>
inline unsigned get16()
const {
209 if (R16 ==
AF) {
return getAF(); }
210 else if (R16 ==
BC) {
return getBC(); }
211 else if (R16 ==
DE) {
return getDE(); }
212 else if (R16 ==
HL) {
return getHL(); }
213 else if (R16 ==
IX) {
return getIX(); }
214 else if (R16 ==
IY) {
return getIY(); }
215 else if (R16 ==
SP) {
return getSP(); }
221 inline byte getR()
const {
return (R_ & Rmask) | (R2_ & ~Rmask); }
251 if (R8 ==
A) {
setA(x); }
252 else if (R8 ==
F) {
setF(x); }
253 else if (R8 ==
B) {
setB(x); }
254 else if (R8 ==
C) {
setC(x); }
255 else if (R8 ==
D) {
setD(x); }
256 else if (R8 ==
E) {
setE(x); }
257 else if (R8 ==
H) {
setH(x); }
258 else if (R8 ==
L) {
setL(x); }
265 else if (R8 ==
DUMMY) { }
269 inline void setAF(
unsigned x) { AF_.
w = x; }
270 inline void setBC(
unsigned x) { BC_.
w = x; }
271 inline void setDE(
unsigned x) { DE_.
w = x; }
272 inline void setHL(
unsigned x) { HL_.
w = x; }
273 inline void setAF2(
unsigned x) { AF2_.
w = x; }
274 inline void setBC2(
unsigned x) { BC2_.
w = x; }
275 inline void setDE2(
unsigned x) { DE2_.
w = x; }
276 inline void setHL2(
unsigned x) { HL2_.
w = x; }
277 inline void setIX(
unsigned x) { IX_.
w = x; }
278 inline void setIY(
unsigned x) { IY_.
w = x; }
279 inline void setPC(
unsigned x) { PC_.
w = x; }
280 inline void setSP(
unsigned x) { SP_.
w = x; }
281 template <Reg16 R16>
inline void set16(
unsigned x) {
283 else if (R16 ==
BC) {
setBC(x); }
284 else if (R16 ==
DE) {
setDE(x); }
285 else if (R16 ==
HL) {
setHL(x); }
286 else if (R16 ==
IX) {
setIX(x); }
287 else if (R16 ==
IY) {
setIY(x); }
288 else if (R16 ==
SP) {
setSP(x); }
297 inline void setHALT(
bool x) { HALT_ = (HALT_ & ~1) | (x ? 1 : 0); }
298 inline void setExtHALT(
bool x) { HALT_ = (HALT_ & ~2) | (x ? 2 : 0); }
316 return after_ == afterNext_;
320 return (after_ & 0x01) != 0;
324 return (after_ & 0x02) != 0;
328 return (after_ & 0x01) != 0;
339 return afterNext_ == 0;
346 afterNext_ = after_ = 0x01;
351 afterNext_ = after_ = 0x02;
365 template<
typename Archive>
366 void serialize(Archive& ar,
unsigned version);
373 byte after_, afterNext_;
384 virtual void execute(
bool fastForward) = 0;
432 virtual bool isM1Cycle(
unsigned address)
const = 0;
436 virtual void disasmCommand(
const std::vector<TclObject>& tokens,