2 * Copyright (C) 1996-1998 Szeredi Miklos
3 * Email: mszeredi@inf.bme.hu
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. See the file COPYING.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #define OPDEF(name, num) z80t z80op_ ## name (z80t z80p)
28 #define ENDOP() return z80p
30 #define DANM(x) z80p->x
32 #define TAB(t) DANM(t)
33 #define PORT(t) DANM(t)
34 #define SPECP(t) DANM(t)
40 #define OPDEF(name, num) void z80op_ ## name (z80t)
43 #define TAB(t) z80c_ ## t
44 #define PORT(t) PRNM(t)
45 #define SPECP(t) SPNM(t)
50 typedef z80t (*op_f
)(z80t
);
51 extern op_f z80c_op_tab
[];
52 extern op_f z80c_op_tab_cb
[];
53 extern op_f z80c_op_tab_dd
[];
54 extern op_f z80c_op_tab_ed
[];
55 extern op_f z80c_op_tab_fd
[];
57 #define TIME(x) DANM(tc) -= (x)
59 #define ENTIME(x) { TIME(x); ENDOP(); }
61 #define READ(addr) (DANM(mem)[addr])
62 #define WRITE(addr, val) PUTMEM(addr, DANM(mem) + (dbyte) (addr), val)
64 #define DREAD(addr) (DANM(mem)[addr] | (DANM(mem)[(dbyte)(addr+1)] << 8))
65 #define DWRITE(addr, x) WRITE(addr, (byte) x); \
66 WRITE((dbyte) (addr+1), (byte) (x >> 8))
68 #define IPCS ((sbyte) *PCP)
71 #define MODMEM(func) \
76 PUTMEM(HL, HLP, bdef); \
79 #define MODMEMADDR(func, addr) \
87 #define IXDGET(ixy, addr) addr = ((dbyte) (ixy + IPCS)), PC++
91 register dbyte ddef; \
99 register dbyte ddef; \
107 register dbyte ddef, dval; \
110 DWRITE(ddef, dval); \
118 #define PUTMEM(addr, ptr, val) *(ptr) = (val)
119 #define IN(porth, portl, dest) dest = PORT(inports)[portl]
120 #define OUT(porth, portl, source) PORT(outports)[portl] = (source)
135 #define ALLF (SF | ZF | HF | PVF | NF | CF)
136 #define BUTCF (SF | ZF | HF | PVF | NF)
141 #define SETFLAGS(mask, val) (RF = (RF & ~(mask)) | (val))
142 #define SET_FL(x) (RF |= (x))
143 #define CLR_FL(x) (RF &= ~(x))
146 #define TESTZF (RF & ZF)
147 #define TESTCF (RF & CF)
148 #define TESTSF (RF & SF)
149 #define TESTPF (RF & PVF)
150 #define TESTHF (RF & HF)
151 #define TESTNF (RF & NF)
154 #define IDXCALC(v1, v2, res) \
155 ((res & 0xA8) | ((v1 & 0x88) >> 1) | ((v2 & 0x88) >> 3))
157 #define DIDXCALC(v1, v2, res) \
158 (((res & 0x8800) >> 8) | ((v1 & 0x8800) >> 9) | ((v2 & 0x8800) >> 11))
161 extern byte z80c_incf_tbl
[];
162 extern byte z80c_decf_tbl
[];
163 extern byte z80c_addf_tbl
[];
164 extern byte z80c_subf_tbl
[];
165 extern byte z80c_orf_tbl
[];