Rename variables sectorbuf and verbose to avoid clashes in rbutil. Cleanup exports...
[Rockbox.git] / apps / plugins / zxbox / z80.h
blob996ea9d29461db6630e96b8ec37fa9481a302e29
1 /*
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.
21 #ifndef Z80_H
22 #define Z80_H
24 #include "zxconfig.h"
25 #include "config.h"
27 #ifdef ROCKBOX_BIG_ENDIAN
28 #define WORDS_BIGENDIAN
29 #endif
31 #ifndef COMPARISON
32 #define PRNM(x) z80_ ## x
33 #else
34 #define PRNM(x) z80x_ ## x
35 #endif
37 #define DANM(x) PRNM(proc).x
39 #include "z80_type.h"
42 #ifndef WORDS_BIGENDIAN
43 union dregp {
44 struct { byte l, h, _b2, _b3; } s;
45 struct { dbyte d, _d1; } d;
46 byte* p;
48 #else
49 union dregp {
50 struct { byte _b3, _b2, h, l; } s;
51 struct { dbyte _d1, d; } d;
52 byte* p;
54 #endif
56 #define NUMDREGS 9
57 #define BACKDREGS 4
59 #define PORTNUM 256
61 /* Do NOT change the order! */
62 typedef struct {
63 union dregp nr[NUMDREGS];
64 union dregp br[BACKDREGS];
66 int haltstate;
67 int it_mode;
68 int iff1, iff2;
70 byte *mem;
72 int tc;
73 int rl7;
75 #ifdef SPECT_MEM /* WARNING: Do NOT change the order!!! */
76 int next_scri;
77 int inport_mask;
78 int ula_inport;
79 int ula_outport;
80 int sound_sam;
81 int sound_change;
82 int imp_change;
83 #endif
85 #ifdef Z80C
86 dbyte cbaddr;
88 #ifdef PROCP
89 byte *incf_tbl;
90 byte *decf_tbl;
91 byte *addf_tbl;
92 byte *subf_tbl;
93 byte *orf_tbl;
95 byte *inports;
96 byte *outports;
97 #ifdef SPECT_MEM
98 byte *fe_inport_high;
99 #endif
100 #endif
101 #endif
103 } Z80;
106 extern Z80 PRNM(proc);
108 extern byte PRNM(inports)[];
109 extern byte PRNM(outports)[];
111 #define ZI_BC 0
112 #define ZI_DE 1
113 #define ZI_HL 2
114 #define ZI_AF 3
115 #define ZI_IR 4
116 #define ZI_IX 5
117 #define ZI_IY 6
118 #define ZI_PC 7
119 #define ZI_SP 8
122 #define BC (DANM(nr)[ZI_BC].d.d)
123 #define DE (DANM(nr)[ZI_DE].d.d)
124 #define HL (DANM(nr)[ZI_HL].d.d)
125 #define AF (DANM(nr)[ZI_AF].d.d)
126 #define IR (DANM(nr)[ZI_IR].d.d)
127 #define IX (DANM(nr)[ZI_IX].d.d)
128 #define IY (DANM(nr)[ZI_IY].d.d)
129 #define PC (DANM(nr)[ZI_PC].d.d)
130 #define SP (DANM(nr)[ZI_SP].d.d)
132 #define BCP (DANM(nr)[ZI_BC].p)
133 #define DEP (DANM(nr)[ZI_DE].p)
134 #define HLP (DANM(nr)[ZI_HL].p)
135 #define PCP (DANM(nr)[ZI_PC].p)
136 #define SPP (DANM(nr)[ZI_SP].p)
137 #define IXP (DANM(nr)[ZI_IX].p)
138 #define IYP (DANM(nr)[ZI_IY].p)
141 #define RB (DANM(nr)[ZI_BC].s.h)
142 #define RC (DANM(nr)[ZI_BC].s.l)
143 #define RD (DANM(nr)[ZI_DE].s.h)
144 #define RE (DANM(nr)[ZI_DE].s.l)
145 #define RH (DANM(nr)[ZI_HL].s.h)
146 #define RL (DANM(nr)[ZI_HL].s.l)
147 #define RA (DANM(nr)[ZI_AF].s.h)
148 #define RF (DANM(nr)[ZI_AF].s.l)
149 #define RI (DANM(nr)[ZI_IR].s.h)
150 #define RR (DANM(nr)[ZI_IR].s.l)
151 #define XH (DANM(nr)[ZI_IX].s.h)
152 #define XL (DANM(nr)[ZI_IX].s.l)
153 #define YH (DANM(nr)[ZI_IY].s.h)
154 #define YL (DANM(nr)[ZI_IY].s.l)
155 #define PCH (DANM(nr)[ZI_PC].s.h)
156 #define PCL (DANM(nr)[ZI_PC].s.l)
157 #define SPH (DANM(nr)[ZI_SP].s.h)
158 #define SPL (DANM(nr)[ZI_SP].s.l)
160 #define BCBK (DANM(br)[ZI_BC].d.d)
161 #define DEBK (DANM(br)[ZI_DE].d.d)
162 #define HLBK (DANM(br)[ZI_HL].d.d)
163 #define AFBK (DANM(br)[ZI_AF].d.d)
165 #define BBK (DANM(br)[ZI_BC].s.h)
166 #define CBK (DANM(br)[ZI_BC].s.l)
167 #define DBK (DANM(br)[ZI_DE].s.h)
168 #define EBK (DANM(br)[ZI_DE].s.l)
169 #define HBK (DANM(br)[ZI_HL].s.h)
170 #define LBK (DANM(br)[ZI_HL].s.l)
171 #define ABK (DANM(br)[ZI_AF].s.h)
172 #define FBK (DANM(br)[ZI_AF].s.l)
174 #ifdef __cplusplus
175 extern "C" {
176 #endif
178 extern void PRNM(init)(void);
179 extern int PRNM(step)(int ticknum);
181 extern void PRNM(interrupt)(int data);
182 extern void PRNM(nmi)(void);
183 extern void PRNM(reset)(void);
185 extern void PRNM(pushpc)(void);
186 extern void PRNM(local_init)(void);
188 #ifdef __cplusplus
190 #endif
193 #endif /* Z80_H */