3 /* Multi-Z80 32 Bit emulator */
5 /* Copyright 1996-2000 Neil Bradley, All rights reserved
9 * (MZ80 Refers to both the assembly code emitted by makeZ80.c and makeZ80.c
12 * MZ80 May be distributed in unmodified form to any medium.
14 * MZ80 May not be sold, or sold as a part of a commercial package without
15 * the express written permission of Neil Bradley (neil@synthcom.com). This
18 * Modified versions of MZ80 may not be publicly redistributed without author
19 * approval (neil@synthcom.com). This includes distributing via a publicly
20 * accessible LAN. You may make your own source modifications and distribute
21 * MZ80 in source or object form, but if you make modifications to MZ80
22 * then it should be noted in the top as a comment in makeZ80.c.
24 * MZ80 Licensing for commercial applications is available. Please email
25 * neil@synthcom.com for details.
27 * Synthcom Systems, Inc, and Neil Bradley will not be held responsible for
28 * any damage done by the use of MZ80. It is purely "as-is".
30 * If you use MZ80 in a freeware application, credit in the following text:
32 * "Multi-Z80 CPU emulator by Neil Bradley (neil@synthcom.com)"
34 * must accompany the freeware application within the application itself or
35 * in the documentation.
39 * If you find problems with MZ80, please email the author so they can get
40 * resolved. If you find a bug and fix it, please also email the author so
41 * that those bug fixes can be propogated to the installed base of MZ80
42 * users. If you find performance improvements or problems with MZ80, please
43 * email the author with your changes/suggestions and they will be rolled in
44 * with subsequent releases of MZ80.
46 * The whole idea of this emulator is to have the fastest available 32 bit
47 * Multi-Z80 emulator for the PC, giving maximum performance.
58 /* Modular global variables go here*/
60 static CONTEXTMZ80 cpu; /* CPU Context */
61 static UINT8 *pbPC; /* Program counter normalized */
62 static UINT8 *pbSP; /* Stack pointer normalized */
63 static struct MemoryReadByte *psMemRead; /* Read memory structure */
64 static struct MemoryWriteByte *psMemWrite; /* Write memory structure */
65 static struct z80PortRead *psIoRead; /* Read I/O structure */
66 static struct z80PortWrite *psIoWrite; /* Write memory structure */
67 static INT32 sdwCyclesRemaining; /* Used as a countdown */
68 static UINT32 dwReturnCode; /* Return code from exec() */
69 static UINT32 dwOriginalCycles; /* How many cycles did we start with? */
70 static UINT32 dwElapsedTicks; /* How many ticks did we elapse? */
71 static INT32 sdwAddr; /* Temporary address storage */
72 static UINT32 dwAddr; /* Temporary stack address */
73 static UINT8 *pbAddAdcTable; /* Pointer to add/adc flag table */
74 static UINT8 *pbSubSbcTable; /* Pointer to sub/sbc flag table */
75 static UINT32 dwTemp; /* Temporary value */
77 static UINT8 bTemp; /* Temporary value */
79 static UINT8 bTemp2; /* Temporary value */
81 /* Precomputed flag tables */
83 static UINT8 bPostIncFlags[0x100] =
85 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
86 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
87 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
88 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
89 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
90 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
91 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
92 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,
93 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
94 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
95 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
96 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
97 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
98 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
99 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
100 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x50
103 static UINT8 bPostDecFlags[0x100] =
105 0x92,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
106 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
107 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
108 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
109 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
110 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
111 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
112 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
113 0x16,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
114 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
115 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
116 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
117 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
118 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
119 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
120 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82
123 static UINT8 bPostORFlags[0x100] =
125 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
126 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
127 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
128 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
129 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
130 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
131 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
132 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
133 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
134 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
135 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
136 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
137 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
138 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
139 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
140 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84
143 static UINT8 bPostANDFlags[0x100] =
145 0x54,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
146 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
147 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
148 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
149 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
150 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
151 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
152 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
153 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
154 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
155 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
156 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
157 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
158 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
159 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
160 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94
163 static UINT16 wDAATable[0x800] =
165 0x5400,0x1001,0x1002,0x1403,0x1004,0x1405,0x1406,0x1007,
166 0x1008,0x1409,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,
167 0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,0x1016,0x1417,
168 0x1418,0x1019,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,
169 0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,0x1026,0x1427,
170 0x1428,0x1029,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,
171 0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,0x1436,0x1037,
172 0x1038,0x1439,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,
173 0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,0x1046,0x1447,
174 0x1448,0x1049,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,
175 0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,0x1456,0x1057,
176 0x1058,0x1459,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,
177 0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,0x1466,0x1067,
178 0x1068,0x1469,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,
179 0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,0x1076,0x1477,
180 0x1478,0x1079,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,
181 0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,0x9086,0x9487,
182 0x9488,0x9089,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,
183 0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,0x9496,0x9097,
184 0x9098,0x9499,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
185 0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107,
186 0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
187 0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517,
188 0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
189 0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527,
190 0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
191 0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137,
192 0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
193 0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547,
194 0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
195 0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157,
196 0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
197 0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,0x1566,0x1167,
198 0x1168,0x1569,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,
199 0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,0x1176,0x1577,
200 0x1578,0x1179,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,
201 0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,0x9186,0x9587,
202 0x9588,0x9189,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,
203 0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,0x9596,0x9197,
204 0x9198,0x9599,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,
205 0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,0x95a6,0x91a7,
206 0x91a8,0x95a9,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,
207 0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,0x91b6,0x95b7,
208 0x95b8,0x91b9,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,
209 0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,0x95c6,0x91c7,
210 0x91c8,0x95c9,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,
211 0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,0x91d6,0x95d7,
212 0x95d8,0x91d9,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,
213 0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,0x91e6,0x95e7,
214 0x95e8,0x91e9,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,
215 0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,0x95f6,0x91f7,
216 0x91f8,0x95f9,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
217 0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107,
218 0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
219 0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517,
220 0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
221 0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527,
222 0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
223 0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137,
224 0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
225 0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547,
226 0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
227 0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157,
228 0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
229 0x1406,0x1007,0x1008,0x1409,0x140a,0x100b,0x140c,0x100d,
230 0x100e,0x140f,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,
231 0x1016,0x1417,0x1418,0x1019,0x101a,0x141b,0x101c,0x141d,
232 0x141e,0x101f,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,
233 0x1026,0x1427,0x1428,0x1029,0x102a,0x142b,0x102c,0x142d,
234 0x142e,0x102f,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,
235 0x1436,0x1037,0x1038,0x1439,0x143a,0x103b,0x143c,0x103d,
236 0x103e,0x143f,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,
237 0x1046,0x1447,0x1448,0x1049,0x104a,0x144b,0x104c,0x144d,
238 0x144e,0x104f,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,
239 0x1456,0x1057,0x1058,0x1459,0x145a,0x105b,0x145c,0x105d,
240 0x105e,0x145f,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,
241 0x1466,0x1067,0x1068,0x1469,0x146a,0x106b,0x146c,0x106d,
242 0x106e,0x146f,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,
243 0x1076,0x1477,0x1478,0x1079,0x107a,0x147b,0x107c,0x147d,
244 0x147e,0x107f,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,
245 0x9086,0x9487,0x9488,0x9089,0x908a,0x948b,0x908c,0x948d,
246 0x948e,0x908f,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,
247 0x9496,0x9097,0x9098,0x9499,0x949a,0x909b,0x949c,0x909d,
248 0x909e,0x949f,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
249 0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d,
250 0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
251 0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d,
252 0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
253 0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d,
254 0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
255 0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d,
256 0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
257 0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d,
258 0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
259 0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d,
260 0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
261 0x1566,0x1167,0x1168,0x1569,0x156a,0x116b,0x156c,0x116d,
262 0x116e,0x156f,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,
263 0x1176,0x1577,0x1578,0x1179,0x117a,0x157b,0x117c,0x157d,
264 0x157e,0x117f,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,
265 0x9186,0x9587,0x9588,0x9189,0x918a,0x958b,0x918c,0x958d,
266 0x958e,0x918f,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,
267 0x9596,0x9197,0x9198,0x9599,0x959a,0x919b,0x959c,0x919d,
268 0x919e,0x959f,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,
269 0x95a6,0x91a7,0x91a8,0x95a9,0x95aa,0x91ab,0x95ac,0x91ad,
270 0x91ae,0x95af,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,
271 0x91b6,0x95b7,0x95b8,0x91b9,0x91ba,0x95bb,0x91bc,0x95bd,
272 0x95be,0x91bf,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,
273 0x95c6,0x91c7,0x91c8,0x95c9,0x95ca,0x91cb,0x95cc,0x91cd,
274 0x91ce,0x95cf,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,
275 0x91d6,0x95d7,0x95d8,0x91d9,0x91da,0x95db,0x91dc,0x95dd,
276 0x95de,0x91df,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,
277 0x91e6,0x95e7,0x95e8,0x91e9,0x91ea,0x95eb,0x91ec,0x95ed,
278 0x95ee,0x91ef,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,
279 0x95f6,0x91f7,0x91f8,0x95f9,0x95fa,0x91fb,0x95fc,0x91fd,
280 0x91fe,0x95ff,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
281 0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d,
282 0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
283 0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d,
284 0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
285 0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d,
286 0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
287 0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d,
288 0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
289 0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d,
290 0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
291 0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d,
292 0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
293 0x5600,0x1201,0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,
294 0x1208,0x1609,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609,
295 0x1210,0x1611,0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,
296 0x1618,0x1219,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219,
297 0x1220,0x1621,0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,
298 0x1628,0x1229,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229,
299 0x1630,0x1231,0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,
300 0x1238,0x1639,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639,
301 0x1240,0x1641,0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,
302 0x1648,0x1249,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249,
303 0x1650,0x1251,0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,
304 0x1258,0x1659,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659,
305 0x1660,0x1261,0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,
306 0x1268,0x1669,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669,
307 0x1270,0x1671,0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,
308 0x1678,0x1279,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279,
309 0x9280,0x9681,0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,
310 0x9688,0x9289,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289,
311 0x9690,0x9291,0x9292,0x9693,0x9294,0x9695,0x9696,0x9297,
312 0x9298,0x9699,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
313 0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,
314 0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
315 0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,
316 0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
317 0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,
318 0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
319 0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,
320 0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
321 0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,
322 0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
323 0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,
324 0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
325 0x97a0,0x93a1,0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,
326 0x93a8,0x97a9,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9,
327 0x93b0,0x97b1,0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,
328 0x97b8,0x93b9,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9,
329 0x97c0,0x93c1,0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,
330 0x93c8,0x97c9,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9,
331 0x93d0,0x97d1,0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,
332 0x97d8,0x93d9,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9,
333 0x93e0,0x97e1,0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,
334 0x97e8,0x93e9,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9,
335 0x97f0,0x93f1,0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,
336 0x93f8,0x97f9,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9,
337 0x5700,0x1301,0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,
338 0x1308,0x1709,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709,
339 0x1310,0x1711,0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,
340 0x1718,0x1319,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319,
341 0x1320,0x1721,0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,
342 0x1728,0x1329,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329,
343 0x1730,0x1331,0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,
344 0x1338,0x1739,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
345 0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,
346 0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
347 0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,
348 0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
349 0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,
350 0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
351 0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,
352 0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
353 0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,
354 0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
355 0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,
356 0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
357 0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5600,0x1201,
358 0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609,
359 0x160a,0x120b,0x160c,0x120d,0x120e,0x160f,0x1210,0x1611,
360 0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219,
361 0x121a,0x161b,0x121c,0x161d,0x161e,0x121f,0x1220,0x1621,
362 0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229,
363 0x122a,0x162b,0x122c,0x162d,0x162e,0x122f,0x1630,0x1231,
364 0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639,
365 0x163a,0x123b,0x163c,0x123d,0x123e,0x163f,0x1240,0x1641,
366 0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249,
367 0x124a,0x164b,0x124c,0x164d,0x164e,0x124f,0x1650,0x1251,
368 0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659,
369 0x165a,0x125b,0x165c,0x125d,0x125e,0x165f,0x1660,0x1261,
370 0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669,
371 0x166a,0x126b,0x166c,0x126d,0x126e,0x166f,0x1270,0x1671,
372 0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279,
373 0x127a,0x167b,0x127c,0x167d,0x167e,0x127f,0x9280,0x9681,
374 0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289,
375 0x928a,0x968b,0x928c,0x968d,0x968e,0x928f,0x9690,0x9291,
376 0x9292,0x9693,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
377 0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741,
378 0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
379 0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351,
380 0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
381 0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361,
382 0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
383 0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771,
384 0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
385 0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781,
386 0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
387 0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391,
388 0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
389 0x979a,0x939b,0x979c,0x939d,0x939e,0x979f,0x97a0,0x93a1,
390 0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9,
391 0x97aa,0x93ab,0x97ac,0x93ad,0x93ae,0x97af,0x93b0,0x97b1,
392 0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9,
393 0x93ba,0x97bb,0x93bc,0x97bd,0x97be,0x93bf,0x97c0,0x93c1,
394 0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9,
395 0x97ca,0x93cb,0x97cc,0x93cd,0x93ce,0x97cf,0x93d0,0x97d1,
396 0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9,
397 0x93da,0x97db,0x93dc,0x97dd,0x97de,0x93df,0x93e0,0x97e1,
398 0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9,
399 0x93ea,0x97eb,0x93ec,0x97ed,0x97ee,0x93ef,0x97f0,0x93f1,
400 0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9,
401 0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5700,0x1301,
402 0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709,
403 0x170a,0x130b,0x170c,0x130d,0x130e,0x170f,0x1310,0x1711,
404 0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319,
405 0x131a,0x171b,0x131c,0x171d,0x171e,0x131f,0x1320,0x1721,
406 0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329,
407 0x132a,0x172b,0x132c,0x172d,0x172e,0x132f,0x1730,0x1331,
408 0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
409 0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741,
410 0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
411 0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351,
412 0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
413 0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361,
414 0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
415 0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771,
416 0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
417 0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781,
418 0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
419 0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391,
420 0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799
423 void DDFDCBHandler(UINT32 dwWhich);
426 static void InvalidInstruction(UINT32 dwCount)
428 pbPC -= dwCount; /* Invalid instruction - back up */
429 dwReturnCode = (UINT32) pbPC - (UINT32) cpu.z80Base;
430 dwOriginalCycles -= sdwCyclesRemaining;
431 sdwCyclesRemaining = 0;
440 sdwCyclesRemaining -= 8;
441 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
442 bTemp2 = (cpu.z80B >> 7);
443 cpu.z80B = (cpu.z80B << 1) | bTemp2;
444 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80B];
449 sdwCyclesRemaining -= 8;
450 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
451 bTemp2 = (cpu.z80C >> 7);
452 cpu.z80C = (cpu.z80C << 1) | bTemp2;
453 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80C];
458 sdwCyclesRemaining -= 8;
459 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
460 bTemp2 = (cpu.z80D >> 7);
461 cpu.z80D = (cpu.z80D << 1) | bTemp2;
462 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80D];
467 sdwCyclesRemaining -= 8;
468 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
469 bTemp2 = (cpu.z80E >> 7);
470 cpu.z80E = (cpu.z80E << 1) | bTemp2;
471 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80E];
476 sdwCyclesRemaining -= 8;
477 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
478 bTemp2 = (cpu.z80H >> 7);
479 cpu.z80H = (cpu.z80H << 1) | bTemp2;
480 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80H];
485 sdwCyclesRemaining -= 8;
486 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
487 bTemp2 = (cpu.z80L >> 7);
488 cpu.z80L = (cpu.z80L << 1) | bTemp2;
489 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80L];
494 sdwCyclesRemaining -= 15;
495 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
496 while (psMemRead->lowAddr != 0xffffffff)
498 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
500 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
501 if (psMemRead->memoryCall)
503 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
507 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
517 bTemp = cpu.z80Base[cpu.z80HL];
520 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
521 bTemp2 = (bTemp >> 7);
522 bTemp = (bTemp << 1) | bTemp2;
523 cpu.z80F |= bTemp2 | bPostORFlags[bTemp];
524 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
525 while (psMemWrite->lowAddr != 0xffffffff)
527 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
529 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
530 if (psMemWrite->memoryCall)
532 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
536 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
546 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
553 sdwCyclesRemaining -= 8;
554 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
555 bTemp2 = (cpu.z80A >> 7);
556 cpu.z80A = (cpu.z80A << 1) | bTemp2;
557 cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80A];
562 sdwCyclesRemaining -= 8;
563 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
564 cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
565 cpu.z80B = (cpu.z80B >> 1) | (cpu.z80B << 7);
566 cpu.z80F |= bPostORFlags[cpu.z80B];
571 sdwCyclesRemaining -= 8;
572 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
573 cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
574 cpu.z80C = (cpu.z80C >> 1) | (cpu.z80C << 7);
575 cpu.z80F |= bPostORFlags[cpu.z80C];
580 sdwCyclesRemaining -= 8;
581 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
582 cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
583 cpu.z80D = (cpu.z80D >> 1) | (cpu.z80D << 7);
584 cpu.z80F |= bPostORFlags[cpu.z80D];
589 sdwCyclesRemaining -= 8;
590 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
591 cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
592 cpu.z80E = (cpu.z80E >> 1) | (cpu.z80E << 7);
593 cpu.z80F |= bPostORFlags[cpu.z80E];
598 sdwCyclesRemaining -= 8;
599 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
600 cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
601 cpu.z80H = (cpu.z80H >> 1) | (cpu.z80H << 7);
602 cpu.z80F |= bPostORFlags[cpu.z80H];
607 sdwCyclesRemaining -= 8;
608 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
609 cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
610 cpu.z80L = (cpu.z80L >> 1) | (cpu.z80L << 7);
611 cpu.z80F |= bPostORFlags[cpu.z80L];
616 sdwCyclesRemaining -= 15;
617 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
618 while (psMemRead->lowAddr != 0xffffffff)
620 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
622 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
623 if (psMemRead->memoryCall)
625 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
629 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
639 bTemp = cpu.z80Base[cpu.z80HL];
642 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
643 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
644 bTemp = (bTemp >> 1) | (bTemp << 7);
645 cpu.z80F |= bPostORFlags[bTemp];
646 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
647 while (psMemWrite->lowAddr != 0xffffffff)
649 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
651 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
652 if (psMemWrite->memoryCall)
654 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
658 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
668 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
675 sdwCyclesRemaining -= 8;
676 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
677 cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
678 cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A << 7);
679 cpu.z80F |= bPostORFlags[cpu.z80A];
684 sdwCyclesRemaining -= 8;
685 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
686 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
687 cpu.z80F |= (cpu.z80B >> 7);
688 cpu.z80B = (cpu.z80B << 1) | bTemp2;
689 cpu.z80F |= bPostORFlags[cpu.z80B];
694 sdwCyclesRemaining -= 8;
695 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
696 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
697 cpu.z80F |= (cpu.z80C >> 7);
698 cpu.z80C = (cpu.z80C << 1) | bTemp2;
699 cpu.z80F |= bPostORFlags[cpu.z80C];
704 sdwCyclesRemaining -= 8;
705 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
706 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
707 cpu.z80F |= (cpu.z80D >> 7);
708 cpu.z80D = (cpu.z80D << 1) | bTemp2;
709 cpu.z80F |= bPostORFlags[cpu.z80D];
714 sdwCyclesRemaining -= 8;
715 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
716 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
717 cpu.z80F |= (cpu.z80E >> 7);
718 cpu.z80E = (cpu.z80E << 1) | bTemp2;
719 cpu.z80F |= bPostORFlags[cpu.z80E];
724 sdwCyclesRemaining -= 8;
725 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
726 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
727 cpu.z80F |= (cpu.z80H >> 7);
728 cpu.z80H = (cpu.z80H << 1) | bTemp2;
729 cpu.z80F |= bPostORFlags[cpu.z80H];
734 sdwCyclesRemaining -= 8;
735 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
736 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
737 cpu.z80F |= (cpu.z80L >> 7);
738 cpu.z80L = (cpu.z80L << 1) | bTemp2;
739 cpu.z80F |= bPostORFlags[cpu.z80L];
744 sdwCyclesRemaining -= 15;
745 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
746 while (psMemRead->lowAddr != 0xffffffff)
748 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
750 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
751 if (psMemRead->memoryCall)
753 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
757 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
767 bTemp = cpu.z80Base[cpu.z80HL];
770 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
771 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
772 cpu.z80F |= (bTemp >> 7);
773 bTemp = (bTemp << 1) | bTemp2;
774 cpu.z80F |= bPostORFlags[bTemp];
775 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
776 while (psMemWrite->lowAddr != 0xffffffff)
778 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
780 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
781 if (psMemWrite->memoryCall)
783 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
787 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
797 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
804 sdwCyclesRemaining -= 8;
805 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
806 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
807 cpu.z80F |= (cpu.z80A >> 7);
808 cpu.z80A = (cpu.z80A << 1) | bTemp2;
809 cpu.z80F |= bPostORFlags[cpu.z80A];
814 sdwCyclesRemaining -= 8;
815 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
816 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
817 cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
818 cpu.z80B = (cpu.z80B >> 1) | bTemp2;
819 cpu.z80F |= bPostORFlags[cpu.z80B];
824 sdwCyclesRemaining -= 8;
825 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
826 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
827 cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
828 cpu.z80C = (cpu.z80C >> 1) | bTemp2;
829 cpu.z80F |= bPostORFlags[cpu.z80C];
834 sdwCyclesRemaining -= 8;
835 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
836 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
837 cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
838 cpu.z80D = (cpu.z80D >> 1) | bTemp2;
839 cpu.z80F |= bPostORFlags[cpu.z80D];
844 sdwCyclesRemaining -= 8;
845 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
846 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
847 cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
848 cpu.z80E = (cpu.z80E >> 1) | bTemp2;
849 cpu.z80F |= bPostORFlags[cpu.z80E];
854 sdwCyclesRemaining -= 8;
855 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
856 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
857 cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
858 cpu.z80H = (cpu.z80H >> 1) | bTemp2;
859 cpu.z80F |= bPostORFlags[cpu.z80H];
864 sdwCyclesRemaining -= 8;
865 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
866 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
867 cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
868 cpu.z80L = (cpu.z80L >> 1) | bTemp2;
869 cpu.z80F |= bPostORFlags[cpu.z80L];
874 sdwCyclesRemaining -= 15;
875 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
876 while (psMemRead->lowAddr != 0xffffffff)
878 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
880 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
881 if (psMemRead->memoryCall)
883 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
887 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
897 bTemp = cpu.z80Base[cpu.z80HL];
900 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
901 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
902 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
903 bTemp = (bTemp >> 1) | bTemp2;
904 cpu.z80F |= bPostORFlags[bTemp];
905 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
906 while (psMemWrite->lowAddr != 0xffffffff)
908 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
910 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
911 if (psMemWrite->memoryCall)
913 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
917 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
927 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
934 sdwCyclesRemaining -= 8;
935 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
936 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
937 cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
938 cpu.z80A = (cpu.z80A >> 1) | bTemp2;
939 cpu.z80F |= bPostORFlags[cpu.z80A];
944 sdwCyclesRemaining -= 8;
945 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
946 cpu.z80F |= (cpu.z80B >> 7);
947 cpu.z80B = (cpu.z80B << 1);
948 cpu.z80F |= bPostORFlags[cpu.z80B];
953 sdwCyclesRemaining -= 8;
954 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
955 cpu.z80F |= (cpu.z80C >> 7);
956 cpu.z80C = (cpu.z80C << 1);
957 cpu.z80F |= bPostORFlags[cpu.z80C];
962 sdwCyclesRemaining -= 8;
963 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
964 cpu.z80F |= (cpu.z80D >> 7);
965 cpu.z80D = (cpu.z80D << 1);
966 cpu.z80F |= bPostORFlags[cpu.z80D];
971 sdwCyclesRemaining -= 8;
972 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
973 cpu.z80F |= (cpu.z80E >> 7);
974 cpu.z80E = (cpu.z80E << 1);
975 cpu.z80F |= bPostORFlags[cpu.z80E];
980 sdwCyclesRemaining -= 8;
981 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
982 cpu.z80F |= (cpu.z80H >> 7);
983 cpu.z80H = (cpu.z80H << 1);
984 cpu.z80F |= bPostORFlags[cpu.z80H];
989 sdwCyclesRemaining -= 8;
990 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
991 cpu.z80F |= (cpu.z80L >> 7);
992 cpu.z80L = (cpu.z80L << 1);
993 cpu.z80F |= bPostORFlags[cpu.z80L];
998 sdwCyclesRemaining -= 15;
999 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1000 while (psMemRead->lowAddr != 0xffffffff)
1002 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1004 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1005 if (psMemRead->memoryCall)
1007 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1011 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1021 bTemp = cpu.z80Base[cpu.z80HL];
1024 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1025 cpu.z80F |= (bTemp >> 7);
1026 bTemp = (bTemp << 1);
1027 cpu.z80F |= bPostORFlags[bTemp];
1028 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
1029 while (psMemWrite->lowAddr != 0xffffffff)
1031 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
1033 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1034 if (psMemWrite->memoryCall)
1036 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
1040 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
1050 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
1057 sdwCyclesRemaining -= 8;
1058 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1059 cpu.z80F |= (cpu.z80A >> 7);
1060 cpu.z80A = (cpu.z80A << 1);
1061 cpu.z80F |= bPostORFlags[cpu.z80A];
1066 sdwCyclesRemaining -= 8;
1067 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1068 cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
1069 cpu.z80B = (cpu.z80B >> 1) | (cpu.z80B & 0x80);
1070 cpu.z80F |= bPostORFlags[cpu.z80B];
1075 sdwCyclesRemaining -= 8;
1076 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1077 cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
1078 cpu.z80C = (cpu.z80C >> 1) | (cpu.z80C & 0x80);
1079 cpu.z80F |= bPostORFlags[cpu.z80C];
1084 sdwCyclesRemaining -= 8;
1085 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1086 cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
1087 cpu.z80D = (cpu.z80D >> 1) | (cpu.z80D & 0x80);
1088 cpu.z80F |= bPostORFlags[cpu.z80D];
1093 sdwCyclesRemaining -= 8;
1094 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1095 cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
1096 cpu.z80E = (cpu.z80E >> 1) | (cpu.z80E & 0x80);
1097 cpu.z80F |= bPostORFlags[cpu.z80E];
1102 sdwCyclesRemaining -= 8;
1103 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1104 cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
1105 cpu.z80H = (cpu.z80H >> 1) | (cpu.z80H & 0x80);
1106 cpu.z80F |= bPostORFlags[cpu.z80H];
1111 sdwCyclesRemaining -= 8;
1112 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1113 cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
1114 cpu.z80L = (cpu.z80L >> 1) | (cpu.z80L & 0x80);
1115 cpu.z80F |= bPostORFlags[cpu.z80L];
1120 sdwCyclesRemaining -= 15;
1121 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1122 while (psMemRead->lowAddr != 0xffffffff)
1124 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1126 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1127 if (psMemRead->memoryCall)
1129 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1133 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1143 bTemp = cpu.z80Base[cpu.z80HL];
1146 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1147 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
1148 bTemp = (bTemp >> 1) | (bTemp & 0x80);
1149 cpu.z80F |= bPostORFlags[bTemp];
1150 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
1151 while (psMemWrite->lowAddr != 0xffffffff)
1153 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
1155 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1156 if (psMemWrite->memoryCall)
1158 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
1162 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
1172 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
1179 sdwCyclesRemaining -= 8;
1180 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1181 cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
1182 cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A & 0x80);
1183 cpu.z80F |= bPostORFlags[cpu.z80A];
1188 sdwCyclesRemaining -= 8;
1189 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1190 cpu.z80F |= (cpu.z80B >> 7);
1191 cpu.z80B = (cpu.z80B << 1);
1192 cpu.z80F |= bPostORFlags[cpu.z80B];
1197 sdwCyclesRemaining -= 8;
1198 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1199 cpu.z80F |= (cpu.z80C >> 7);
1200 cpu.z80C = (cpu.z80C << 1);
1201 cpu.z80F |= bPostORFlags[cpu.z80C];
1206 sdwCyclesRemaining -= 8;
1207 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1208 cpu.z80F |= (cpu.z80D >> 7);
1209 cpu.z80D = (cpu.z80D << 1);
1210 cpu.z80F |= bPostORFlags[cpu.z80D];
1215 sdwCyclesRemaining -= 8;
1216 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1217 cpu.z80F |= (cpu.z80E >> 7);
1218 cpu.z80E = (cpu.z80E << 1);
1219 cpu.z80F |= bPostORFlags[cpu.z80E];
1224 sdwCyclesRemaining -= 8;
1225 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1226 cpu.z80F |= (cpu.z80H >> 7);
1227 cpu.z80H = (cpu.z80H << 1);
1228 cpu.z80F |= bPostORFlags[cpu.z80H];
1233 sdwCyclesRemaining -= 8;
1234 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1235 cpu.z80F |= (cpu.z80L >> 7);
1236 cpu.z80L = (cpu.z80L << 1);
1237 cpu.z80F |= bPostORFlags[cpu.z80L];
1242 sdwCyclesRemaining -= 15;
1243 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1244 while (psMemRead->lowAddr != 0xffffffff)
1246 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1248 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1249 if (psMemRead->memoryCall)
1251 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1255 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1265 bTemp = cpu.z80Base[cpu.z80HL];
1268 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1269 cpu.z80F |= (bTemp >> 7);
1270 bTemp = (bTemp << 1);
1271 cpu.z80F |= bPostORFlags[bTemp];
1272 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
1273 while (psMemWrite->lowAddr != 0xffffffff)
1275 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
1277 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1278 if (psMemWrite->memoryCall)
1280 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
1284 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
1294 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
1301 sdwCyclesRemaining -= 8;
1302 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1303 cpu.z80F |= (cpu.z80A >> 7);
1304 cpu.z80A = (cpu.z80A << 1);
1305 cpu.z80F |= bPostORFlags[cpu.z80A];
1310 sdwCyclesRemaining -= 8;
1311 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1312 cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
1313 cpu.z80B = (cpu.z80B >> 1);
1314 cpu.z80F |= bPostORFlags[cpu.z80B];
1319 sdwCyclesRemaining -= 8;
1320 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1321 cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
1322 cpu.z80C = (cpu.z80C >> 1);
1323 cpu.z80F |= bPostORFlags[cpu.z80C];
1328 sdwCyclesRemaining -= 8;
1329 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1330 cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
1331 cpu.z80D = (cpu.z80D >> 1);
1332 cpu.z80F |= bPostORFlags[cpu.z80D];
1337 sdwCyclesRemaining -= 8;
1338 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1339 cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
1340 cpu.z80E = (cpu.z80E >> 1);
1341 cpu.z80F |= bPostORFlags[cpu.z80E];
1346 sdwCyclesRemaining -= 8;
1347 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1348 cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
1349 cpu.z80H = (cpu.z80H >> 1);
1350 cpu.z80F |= bPostORFlags[cpu.z80H];
1355 sdwCyclesRemaining -= 8;
1356 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1357 cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
1358 cpu.z80L = (cpu.z80L >> 1);
1359 cpu.z80F |= bPostORFlags[cpu.z80L];
1364 sdwCyclesRemaining -= 15;
1365 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1366 while (psMemRead->lowAddr != 0xffffffff)
1368 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1370 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1371 if (psMemRead->memoryCall)
1373 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1377 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1387 bTemp = cpu.z80Base[cpu.z80HL];
1390 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1391 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
1392 bTemp = (bTemp >> 1);
1393 cpu.z80F |= bPostORFlags[bTemp];
1394 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
1395 while (psMemWrite->lowAddr != 0xffffffff)
1397 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
1399 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1400 if (psMemWrite->memoryCall)
1402 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
1406 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
1416 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
1423 sdwCyclesRemaining -= 8;
1424 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
1425 cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
1426 cpu.z80A = (cpu.z80A >> 1);
1427 cpu.z80F |= bPostORFlags[cpu.z80A];
1432 sdwCyclesRemaining -= 8;
1433 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1434 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1435 if (!(cpu.z80B & 0x01))
1437 cpu.z80F |= Z80_FLAG_ZERO;
1443 sdwCyclesRemaining -= 8;
1444 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1445 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1446 if (!(cpu.z80C & 0x01))
1448 cpu.z80F |= Z80_FLAG_ZERO;
1454 sdwCyclesRemaining -= 8;
1455 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1456 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1457 if (!(cpu.z80D & 0x01))
1459 cpu.z80F |= Z80_FLAG_ZERO;
1465 sdwCyclesRemaining -= 8;
1466 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1467 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1468 if (!(cpu.z80E & 0x01))
1470 cpu.z80F |= Z80_FLAG_ZERO;
1476 sdwCyclesRemaining -= 8;
1477 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1478 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1479 if (!(cpu.z80H & 0x01))
1481 cpu.z80F |= Z80_FLAG_ZERO;
1487 sdwCyclesRemaining -= 8;
1488 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1489 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1490 if (!(cpu.z80L & 0x01))
1492 cpu.z80F |= Z80_FLAG_ZERO;
1498 sdwCyclesRemaining -= 12;
1499 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1500 while (psMemRead->lowAddr != 0xffffffff)
1502 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1504 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1505 if (psMemRead->memoryCall)
1507 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1511 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1521 bTemp = cpu.z80Base[cpu.z80HL];
1524 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1525 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1526 if (!(bTemp & 0x01))
1528 cpu.z80F |= Z80_FLAG_ZERO;
1534 sdwCyclesRemaining -= 8;
1535 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1536 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1537 if (!(cpu.z80A & 0x01))
1539 cpu.z80F |= Z80_FLAG_ZERO;
1545 sdwCyclesRemaining -= 8;
1546 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1547 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1548 if (!(cpu.z80B & 0x02))
1550 cpu.z80F |= Z80_FLAG_ZERO;
1556 sdwCyclesRemaining -= 8;
1557 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1558 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1559 if (!(cpu.z80C & 0x02))
1561 cpu.z80F |= Z80_FLAG_ZERO;
1567 sdwCyclesRemaining -= 8;
1568 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1569 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1570 if (!(cpu.z80D & 0x02))
1572 cpu.z80F |= Z80_FLAG_ZERO;
1578 sdwCyclesRemaining -= 8;
1579 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1580 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1581 if (!(cpu.z80E & 0x02))
1583 cpu.z80F |= Z80_FLAG_ZERO;
1589 sdwCyclesRemaining -= 8;
1590 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1591 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1592 if (!(cpu.z80H & 0x02))
1594 cpu.z80F |= Z80_FLAG_ZERO;
1600 sdwCyclesRemaining -= 8;
1601 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1602 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1603 if (!(cpu.z80L & 0x02))
1605 cpu.z80F |= Z80_FLAG_ZERO;
1611 sdwCyclesRemaining -= 12;
1612 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1613 while (psMemRead->lowAddr != 0xffffffff)
1615 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1617 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1618 if (psMemRead->memoryCall)
1620 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1624 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1634 bTemp = cpu.z80Base[cpu.z80HL];
1637 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1638 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1639 if (!(bTemp & 0x02))
1641 cpu.z80F |= Z80_FLAG_ZERO;
1647 sdwCyclesRemaining -= 8;
1648 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1649 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1650 if (!(cpu.z80A & 0x02))
1652 cpu.z80F |= Z80_FLAG_ZERO;
1658 sdwCyclesRemaining -= 8;
1659 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1660 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1661 if (!(cpu.z80B & 0x04))
1663 cpu.z80F |= Z80_FLAG_ZERO;
1669 sdwCyclesRemaining -= 8;
1670 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1671 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1672 if (!(cpu.z80C & 0x04))
1674 cpu.z80F |= Z80_FLAG_ZERO;
1680 sdwCyclesRemaining -= 8;
1681 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1682 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1683 if (!(cpu.z80D & 0x04))
1685 cpu.z80F |= Z80_FLAG_ZERO;
1691 sdwCyclesRemaining -= 8;
1692 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1693 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1694 if (!(cpu.z80E & 0x04))
1696 cpu.z80F |= Z80_FLAG_ZERO;
1702 sdwCyclesRemaining -= 8;
1703 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1704 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1705 if (!(cpu.z80H & 0x04))
1707 cpu.z80F |= Z80_FLAG_ZERO;
1713 sdwCyclesRemaining -= 8;
1714 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1715 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1716 if (!(cpu.z80L & 0x04))
1718 cpu.z80F |= Z80_FLAG_ZERO;
1724 sdwCyclesRemaining -= 12;
1725 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1726 while (psMemRead->lowAddr != 0xffffffff)
1728 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1730 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1731 if (psMemRead->memoryCall)
1733 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1737 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1747 bTemp = cpu.z80Base[cpu.z80HL];
1750 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1751 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1752 if (!(bTemp & 0x04))
1754 cpu.z80F |= Z80_FLAG_ZERO;
1760 sdwCyclesRemaining -= 8;
1761 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1762 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1763 if (!(cpu.z80A & 0x04))
1765 cpu.z80F |= Z80_FLAG_ZERO;
1771 sdwCyclesRemaining -= 8;
1772 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1773 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1774 if (!(cpu.z80B & 0x08))
1776 cpu.z80F |= Z80_FLAG_ZERO;
1782 sdwCyclesRemaining -= 8;
1783 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1784 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1785 if (!(cpu.z80C & 0x08))
1787 cpu.z80F |= Z80_FLAG_ZERO;
1793 sdwCyclesRemaining -= 8;
1794 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1795 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1796 if (!(cpu.z80D & 0x08))
1798 cpu.z80F |= Z80_FLAG_ZERO;
1804 sdwCyclesRemaining -= 8;
1805 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1806 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1807 if (!(cpu.z80E & 0x08))
1809 cpu.z80F |= Z80_FLAG_ZERO;
1815 sdwCyclesRemaining -= 8;
1816 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1817 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1818 if (!(cpu.z80H & 0x08))
1820 cpu.z80F |= Z80_FLAG_ZERO;
1826 sdwCyclesRemaining -= 8;
1827 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1828 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1829 if (!(cpu.z80L & 0x08))
1831 cpu.z80F |= Z80_FLAG_ZERO;
1837 sdwCyclesRemaining -= 12;
1838 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1839 while (psMemRead->lowAddr != 0xffffffff)
1841 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1843 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1844 if (psMemRead->memoryCall)
1846 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1850 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1860 bTemp = cpu.z80Base[cpu.z80HL];
1863 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1864 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1865 if (!(bTemp & 0x08))
1867 cpu.z80F |= Z80_FLAG_ZERO;
1873 sdwCyclesRemaining -= 8;
1874 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1875 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1876 if (!(cpu.z80A & 0x08))
1878 cpu.z80F |= Z80_FLAG_ZERO;
1884 sdwCyclesRemaining -= 8;
1885 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1886 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1887 if (!(cpu.z80B & 0x10))
1889 cpu.z80F |= Z80_FLAG_ZERO;
1895 sdwCyclesRemaining -= 8;
1896 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1897 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1898 if (!(cpu.z80C & 0x10))
1900 cpu.z80F |= Z80_FLAG_ZERO;
1906 sdwCyclesRemaining -= 8;
1907 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1908 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1909 if (!(cpu.z80D & 0x10))
1911 cpu.z80F |= Z80_FLAG_ZERO;
1917 sdwCyclesRemaining -= 8;
1918 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1919 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1920 if (!(cpu.z80E & 0x10))
1922 cpu.z80F |= Z80_FLAG_ZERO;
1928 sdwCyclesRemaining -= 8;
1929 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1930 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1931 if (!(cpu.z80H & 0x10))
1933 cpu.z80F |= Z80_FLAG_ZERO;
1939 sdwCyclesRemaining -= 8;
1940 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1941 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1942 if (!(cpu.z80L & 0x10))
1944 cpu.z80F |= Z80_FLAG_ZERO;
1950 sdwCyclesRemaining -= 12;
1951 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
1952 while (psMemRead->lowAddr != 0xffffffff)
1954 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
1956 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
1957 if (psMemRead->memoryCall)
1959 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
1963 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
1973 bTemp = cpu.z80Base[cpu.z80HL];
1976 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1977 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1978 if (!(bTemp & 0x10))
1980 cpu.z80F |= Z80_FLAG_ZERO;
1986 sdwCyclesRemaining -= 8;
1987 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1988 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
1989 if (!(cpu.z80A & 0x10))
1991 cpu.z80F |= Z80_FLAG_ZERO;
1997 sdwCyclesRemaining -= 8;
1998 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
1999 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2000 if (!(cpu.z80B & 0x20))
2002 cpu.z80F |= Z80_FLAG_ZERO;
2008 sdwCyclesRemaining -= 8;
2009 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2010 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2011 if (!(cpu.z80C & 0x20))
2013 cpu.z80F |= Z80_FLAG_ZERO;
2019 sdwCyclesRemaining -= 8;
2020 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2021 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2022 if (!(cpu.z80D & 0x20))
2024 cpu.z80F |= Z80_FLAG_ZERO;
2030 sdwCyclesRemaining -= 8;
2031 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2032 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2033 if (!(cpu.z80E & 0x20))
2035 cpu.z80F |= Z80_FLAG_ZERO;
2041 sdwCyclesRemaining -= 8;
2042 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2043 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2044 if (!(cpu.z80H & 0x20))
2046 cpu.z80F |= Z80_FLAG_ZERO;
2052 sdwCyclesRemaining -= 8;
2053 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2054 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2055 if (!(cpu.z80L & 0x20))
2057 cpu.z80F |= Z80_FLAG_ZERO;
2063 sdwCyclesRemaining -= 12;
2064 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2065 while (psMemRead->lowAddr != 0xffffffff)
2067 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2069 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2070 if (psMemRead->memoryCall)
2072 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2076 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2086 bTemp = cpu.z80Base[cpu.z80HL];
2089 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2090 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2091 if (!(bTemp & 0x20))
2093 cpu.z80F |= Z80_FLAG_ZERO;
2099 sdwCyclesRemaining -= 8;
2100 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2101 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2102 if (!(cpu.z80A & 0x20))
2104 cpu.z80F |= Z80_FLAG_ZERO;
2110 sdwCyclesRemaining -= 8;
2111 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2112 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2113 if (!(cpu.z80B & 0x40))
2115 cpu.z80F |= Z80_FLAG_ZERO;
2121 sdwCyclesRemaining -= 8;
2122 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2123 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2124 if (!(cpu.z80C & 0x40))
2126 cpu.z80F |= Z80_FLAG_ZERO;
2132 sdwCyclesRemaining -= 8;
2133 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2134 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2135 if (!(cpu.z80D & 0x40))
2137 cpu.z80F |= Z80_FLAG_ZERO;
2143 sdwCyclesRemaining -= 8;
2144 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2145 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2146 if (!(cpu.z80E & 0x40))
2148 cpu.z80F |= Z80_FLAG_ZERO;
2154 sdwCyclesRemaining -= 8;
2155 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2156 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2157 if (!(cpu.z80H & 0x40))
2159 cpu.z80F |= Z80_FLAG_ZERO;
2165 sdwCyclesRemaining -= 8;
2166 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2167 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2168 if (!(cpu.z80L & 0x40))
2170 cpu.z80F |= Z80_FLAG_ZERO;
2176 sdwCyclesRemaining -= 12;
2177 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2178 while (psMemRead->lowAddr != 0xffffffff)
2180 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2182 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2183 if (psMemRead->memoryCall)
2185 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2189 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2199 bTemp = cpu.z80Base[cpu.z80HL];
2202 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2203 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2204 if (!(bTemp & 0x40))
2206 cpu.z80F |= Z80_FLAG_ZERO;
2212 sdwCyclesRemaining -= 8;
2213 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2214 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2215 if (!(cpu.z80A & 0x40))
2217 cpu.z80F |= Z80_FLAG_ZERO;
2223 sdwCyclesRemaining -= 8;
2224 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2225 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2226 if (!(cpu.z80B & 0x80))
2228 cpu.z80F |= Z80_FLAG_ZERO;
2234 sdwCyclesRemaining -= 8;
2235 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2236 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2237 if (!(cpu.z80C & 0x80))
2239 cpu.z80F |= Z80_FLAG_ZERO;
2245 sdwCyclesRemaining -= 8;
2246 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2247 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2248 if (!(cpu.z80D & 0x80))
2250 cpu.z80F |= Z80_FLAG_ZERO;
2256 sdwCyclesRemaining -= 8;
2257 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2258 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2259 if (!(cpu.z80E & 0x80))
2261 cpu.z80F |= Z80_FLAG_ZERO;
2267 sdwCyclesRemaining -= 8;
2268 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2269 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2270 if (!(cpu.z80H & 0x80))
2272 cpu.z80F |= Z80_FLAG_ZERO;
2278 sdwCyclesRemaining -= 8;
2279 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2280 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2281 if (!(cpu.z80L & 0x80))
2283 cpu.z80F |= Z80_FLAG_ZERO;
2289 sdwCyclesRemaining -= 12;
2290 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2291 while (psMemRead->lowAddr != 0xffffffff)
2293 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2295 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2296 if (psMemRead->memoryCall)
2298 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2302 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2312 bTemp = cpu.z80Base[cpu.z80HL];
2315 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2316 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2317 if (!(bTemp & 0x80))
2319 cpu.z80F |= Z80_FLAG_ZERO;
2325 sdwCyclesRemaining -= 8;
2326 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
2327 cpu.z80F |= (Z80_FLAG_HALF_CARRY);
2328 if (!(cpu.z80A & 0x80))
2330 cpu.z80F |= Z80_FLAG_ZERO;
2336 sdwCyclesRemaining -= 8;
2342 sdwCyclesRemaining -= 8;
2348 sdwCyclesRemaining -= 8;
2354 sdwCyclesRemaining -= 8;
2360 sdwCyclesRemaining -= 8;
2366 sdwCyclesRemaining -= 8;
2372 sdwCyclesRemaining -= 15;
2373 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2374 while (psMemRead->lowAddr != 0xffffffff)
2376 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2378 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2379 if (psMemRead->memoryCall)
2381 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2385 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2395 bTemp = cpu.z80Base[cpu.z80HL];
2399 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2400 while (psMemWrite->lowAddr != 0xffffffff)
2402 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2404 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2405 if (psMemWrite->memoryCall)
2407 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2411 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
2421 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
2428 sdwCyclesRemaining -= 8;
2434 sdwCyclesRemaining -= 8;
2440 sdwCyclesRemaining -= 8;
2446 sdwCyclesRemaining -= 8;
2452 sdwCyclesRemaining -= 8;
2458 sdwCyclesRemaining -= 8;
2464 sdwCyclesRemaining -= 8;
2470 sdwCyclesRemaining -= 15;
2471 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2472 while (psMemRead->lowAddr != 0xffffffff)
2474 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2476 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2477 if (psMemRead->memoryCall)
2479 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2483 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2493 bTemp = cpu.z80Base[cpu.z80HL];
2497 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2498 while (psMemWrite->lowAddr != 0xffffffff)
2500 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2502 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2503 if (psMemWrite->memoryCall)
2505 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2509 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
2519 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
2526 sdwCyclesRemaining -= 8;
2532 sdwCyclesRemaining -= 8;
2538 sdwCyclesRemaining -= 8;
2544 sdwCyclesRemaining -= 8;
2550 sdwCyclesRemaining -= 8;
2556 sdwCyclesRemaining -= 8;
2562 sdwCyclesRemaining -= 8;
2568 sdwCyclesRemaining -= 15;
2569 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2570 while (psMemRead->lowAddr != 0xffffffff)
2572 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2574 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2575 if (psMemRead->memoryCall)
2577 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2581 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2591 bTemp = cpu.z80Base[cpu.z80HL];
2595 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2596 while (psMemWrite->lowAddr != 0xffffffff)
2598 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2600 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2601 if (psMemWrite->memoryCall)
2603 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2607 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
2617 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
2624 sdwCyclesRemaining -= 8;
2630 sdwCyclesRemaining -= 8;
2636 sdwCyclesRemaining -= 8;
2642 sdwCyclesRemaining -= 8;
2648 sdwCyclesRemaining -= 8;
2654 sdwCyclesRemaining -= 8;
2660 sdwCyclesRemaining -= 8;
2666 sdwCyclesRemaining -= 15;
2667 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2668 while (psMemRead->lowAddr != 0xffffffff)
2670 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2672 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2673 if (psMemRead->memoryCall)
2675 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2679 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2689 bTemp = cpu.z80Base[cpu.z80HL];
2693 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2694 while (psMemWrite->lowAddr != 0xffffffff)
2696 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2698 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2699 if (psMemWrite->memoryCall)
2701 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2705 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
2715 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
2722 sdwCyclesRemaining -= 8;
2728 sdwCyclesRemaining -= 8;
2734 sdwCyclesRemaining -= 8;
2740 sdwCyclesRemaining -= 8;
2746 sdwCyclesRemaining -= 8;
2752 sdwCyclesRemaining -= 8;
2758 sdwCyclesRemaining -= 8;
2764 sdwCyclesRemaining -= 15;
2765 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2766 while (psMemRead->lowAddr != 0xffffffff)
2768 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2770 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2771 if (psMemRead->memoryCall)
2773 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2777 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2787 bTemp = cpu.z80Base[cpu.z80HL];
2791 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2792 while (psMemWrite->lowAddr != 0xffffffff)
2794 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2796 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2797 if (psMemWrite->memoryCall)
2799 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2803 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
2813 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
2820 sdwCyclesRemaining -= 8;
2826 sdwCyclesRemaining -= 8;
2832 sdwCyclesRemaining -= 8;
2838 sdwCyclesRemaining -= 8;
2844 sdwCyclesRemaining -= 8;
2850 sdwCyclesRemaining -= 8;
2856 sdwCyclesRemaining -= 8;
2862 sdwCyclesRemaining -= 15;
2863 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2864 while (psMemRead->lowAddr != 0xffffffff)
2866 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2868 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2869 if (psMemRead->memoryCall)
2871 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2875 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2885 bTemp = cpu.z80Base[cpu.z80HL];
2889 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2890 while (psMemWrite->lowAddr != 0xffffffff)
2892 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2894 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2895 if (psMemWrite->memoryCall)
2897 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2901 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
2911 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
2918 sdwCyclesRemaining -= 8;
2924 sdwCyclesRemaining -= 8;
2930 sdwCyclesRemaining -= 8;
2936 sdwCyclesRemaining -= 8;
2942 sdwCyclesRemaining -= 8;
2948 sdwCyclesRemaining -= 8;
2954 sdwCyclesRemaining -= 8;
2960 sdwCyclesRemaining -= 15;
2961 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
2962 while (psMemRead->lowAddr != 0xffffffff)
2964 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
2966 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2967 if (psMemRead->memoryCall)
2969 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
2973 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
2983 bTemp = cpu.z80Base[cpu.z80HL];
2987 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
2988 while (psMemWrite->lowAddr != 0xffffffff)
2990 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
2992 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
2993 if (psMemWrite->memoryCall)
2995 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
2999 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3009 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3016 sdwCyclesRemaining -= 8;
3022 sdwCyclesRemaining -= 8;
3028 sdwCyclesRemaining -= 8;
3034 sdwCyclesRemaining -= 8;
3040 sdwCyclesRemaining -= 8;
3046 sdwCyclesRemaining -= 8;
3052 sdwCyclesRemaining -= 8;
3058 sdwCyclesRemaining -= 15;
3059 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3060 while (psMemRead->lowAddr != 0xffffffff)
3062 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3064 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3065 if (psMemRead->memoryCall)
3067 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3071 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3081 bTemp = cpu.z80Base[cpu.z80HL];
3085 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3086 while (psMemWrite->lowAddr != 0xffffffff)
3088 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3090 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3091 if (psMemWrite->memoryCall)
3093 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3097 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3107 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3114 sdwCyclesRemaining -= 8;
3120 sdwCyclesRemaining -= 8;
3126 sdwCyclesRemaining -= 8;
3132 sdwCyclesRemaining -= 8;
3138 sdwCyclesRemaining -= 8;
3144 sdwCyclesRemaining -= 8;
3150 sdwCyclesRemaining -= 8;
3156 sdwCyclesRemaining -= 15;
3157 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3158 while (psMemRead->lowAddr != 0xffffffff)
3160 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3162 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3163 if (psMemRead->memoryCall)
3165 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3169 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3179 bTemp = cpu.z80Base[cpu.z80HL];
3183 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3184 while (psMemWrite->lowAddr != 0xffffffff)
3186 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3188 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3189 if (psMemWrite->memoryCall)
3191 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3195 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3205 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3212 sdwCyclesRemaining -= 8;
3218 sdwCyclesRemaining -= 8;
3224 sdwCyclesRemaining -= 8;
3230 sdwCyclesRemaining -= 8;
3236 sdwCyclesRemaining -= 8;
3242 sdwCyclesRemaining -= 8;
3248 sdwCyclesRemaining -= 8;
3254 sdwCyclesRemaining -= 15;
3255 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3256 while (psMemRead->lowAddr != 0xffffffff)
3258 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3260 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3261 if (psMemRead->memoryCall)
3263 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3267 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3277 bTemp = cpu.z80Base[cpu.z80HL];
3281 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3282 while (psMemWrite->lowAddr != 0xffffffff)
3284 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3286 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3287 if (psMemWrite->memoryCall)
3289 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3293 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3303 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3310 sdwCyclesRemaining -= 8;
3316 sdwCyclesRemaining -= 8;
3322 sdwCyclesRemaining -= 8;
3328 sdwCyclesRemaining -= 8;
3334 sdwCyclesRemaining -= 8;
3340 sdwCyclesRemaining -= 8;
3346 sdwCyclesRemaining -= 8;
3352 sdwCyclesRemaining -= 15;
3353 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3354 while (psMemRead->lowAddr != 0xffffffff)
3356 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3358 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3359 if (psMemRead->memoryCall)
3361 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3365 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3375 bTemp = cpu.z80Base[cpu.z80HL];
3379 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3380 while (psMemWrite->lowAddr != 0xffffffff)
3382 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3384 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3385 if (psMemWrite->memoryCall)
3387 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3391 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3401 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3408 sdwCyclesRemaining -= 8;
3414 sdwCyclesRemaining -= 8;
3420 sdwCyclesRemaining -= 8;
3426 sdwCyclesRemaining -= 8;
3432 sdwCyclesRemaining -= 8;
3438 sdwCyclesRemaining -= 8;
3444 sdwCyclesRemaining -= 8;
3450 sdwCyclesRemaining -= 15;
3451 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3452 while (psMemRead->lowAddr != 0xffffffff)
3454 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3456 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3457 if (psMemRead->memoryCall)
3459 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3463 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3473 bTemp = cpu.z80Base[cpu.z80HL];
3477 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3478 while (psMemWrite->lowAddr != 0xffffffff)
3480 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3482 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3483 if (psMemWrite->memoryCall)
3485 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3489 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3499 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3506 sdwCyclesRemaining -= 8;
3512 sdwCyclesRemaining -= 8;
3518 sdwCyclesRemaining -= 8;
3524 sdwCyclesRemaining -= 8;
3530 sdwCyclesRemaining -= 8;
3536 sdwCyclesRemaining -= 8;
3542 sdwCyclesRemaining -= 8;
3548 sdwCyclesRemaining -= 15;
3549 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3550 while (psMemRead->lowAddr != 0xffffffff)
3552 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3554 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3555 if (psMemRead->memoryCall)
3557 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3561 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3571 bTemp = cpu.z80Base[cpu.z80HL];
3575 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3576 while (psMemWrite->lowAddr != 0xffffffff)
3578 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3580 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3581 if (psMemWrite->memoryCall)
3583 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3587 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3597 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3604 sdwCyclesRemaining -= 8;
3610 sdwCyclesRemaining -= 8;
3616 sdwCyclesRemaining -= 8;
3622 sdwCyclesRemaining -= 8;
3628 sdwCyclesRemaining -= 8;
3634 sdwCyclesRemaining -= 8;
3640 sdwCyclesRemaining -= 8;
3646 sdwCyclesRemaining -= 15;
3647 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3648 while (psMemRead->lowAddr != 0xffffffff)
3650 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3652 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3653 if (psMemRead->memoryCall)
3655 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3659 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3669 bTemp = cpu.z80Base[cpu.z80HL];
3673 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3674 while (psMemWrite->lowAddr != 0xffffffff)
3676 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3678 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3679 if (psMemWrite->memoryCall)
3681 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3685 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3695 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3702 sdwCyclesRemaining -= 8;
3708 sdwCyclesRemaining -= 8;
3714 sdwCyclesRemaining -= 8;
3720 sdwCyclesRemaining -= 8;
3726 sdwCyclesRemaining -= 8;
3732 sdwCyclesRemaining -= 8;
3738 sdwCyclesRemaining -= 8;
3744 sdwCyclesRemaining -= 15;
3745 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3746 while (psMemRead->lowAddr != 0xffffffff)
3748 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3750 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3751 if (psMemRead->memoryCall)
3753 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3757 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3767 bTemp = cpu.z80Base[cpu.z80HL];
3771 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3772 while (psMemWrite->lowAddr != 0xffffffff)
3774 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3776 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3777 if (psMemWrite->memoryCall)
3779 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3783 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3793 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3800 sdwCyclesRemaining -= 8;
3806 sdwCyclesRemaining -= 8;
3812 sdwCyclesRemaining -= 8;
3818 sdwCyclesRemaining -= 8;
3824 sdwCyclesRemaining -= 8;
3830 sdwCyclesRemaining -= 8;
3836 sdwCyclesRemaining -= 8;
3842 sdwCyclesRemaining -= 15;
3843 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
3844 while (psMemRead->lowAddr != 0xffffffff)
3846 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
3848 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3849 if (psMemRead->memoryCall)
3851 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
3855 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
3865 bTemp = cpu.z80Base[cpu.z80HL];
3869 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
3870 while (psMemWrite->lowAddr != 0xffffffff)
3872 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
3874 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
3875 if (psMemWrite->memoryCall)
3877 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
3881 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
3891 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
3898 sdwCyclesRemaining -= 8;
3904 void EDHandler(void)
3910 InvalidInstruction(2);
3915 InvalidInstruction(2);
3920 InvalidInstruction(2);
3925 InvalidInstruction(2);
3930 InvalidInstruction(2);
3935 InvalidInstruction(2);
3940 InvalidInstruction(2);
3945 InvalidInstruction(2);
3950 InvalidInstruction(2);
3955 InvalidInstruction(2);
3960 InvalidInstruction(2);
3965 InvalidInstruction(2);
3970 InvalidInstruction(2);
3975 InvalidInstruction(2);
3980 InvalidInstruction(2);
3985 InvalidInstruction(2);
3990 InvalidInstruction(2);
3995 InvalidInstruction(2);
4000 InvalidInstruction(2);
4005 InvalidInstruction(2);
4010 InvalidInstruction(2);
4015 InvalidInstruction(2);
4020 InvalidInstruction(2);
4025 InvalidInstruction(2);
4030 InvalidInstruction(2);
4035 InvalidInstruction(2);
4040 InvalidInstruction(2);
4045 InvalidInstruction(2);
4050 InvalidInstruction(2);
4055 InvalidInstruction(2);
4060 InvalidInstruction(2);
4065 InvalidInstruction(2);
4070 InvalidInstruction(2);
4075 InvalidInstruction(2);
4080 InvalidInstruction(2);
4085 InvalidInstruction(2);
4090 InvalidInstruction(2);
4095 InvalidInstruction(2);
4100 InvalidInstruction(2);
4105 InvalidInstruction(2);
4110 InvalidInstruction(2);
4115 InvalidInstruction(2);
4120 InvalidInstruction(2);
4125 InvalidInstruction(2);
4130 InvalidInstruction(2);
4135 InvalidInstruction(2);
4140 InvalidInstruction(2);
4145 InvalidInstruction(2);
4150 InvalidInstruction(2);
4155 InvalidInstruction(2);
4160 InvalidInstruction(2);
4165 InvalidInstruction(2);
4170 InvalidInstruction(2);
4175 InvalidInstruction(2);
4180 InvalidInstruction(2);
4185 InvalidInstruction(2);
4190 InvalidInstruction(2);
4195 InvalidInstruction(2);
4200 InvalidInstruction(2);
4205 InvalidInstruction(2);
4210 InvalidInstruction(2);
4215 InvalidInstruction(2);
4220 InvalidInstruction(2);
4225 InvalidInstruction(2);
4230 sdwCyclesRemaining -= 12;
4232 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
4233 while (psIoRead->lowIoAddr != 0xffff)
4235 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
4237 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4238 cpu.z80B = psIoRead->IOCall(dwAddr, psIoRead);
4247 cpu.z80B = 0xff; /* Unclaimed I/O read */
4250 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4251 cpu.z80F |= bPostORFlags[cpu.z80B];
4256 sdwCyclesRemaining -= 12;
4258 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
4259 while (psIoWrite->lowIoAddr != 0xffff)
4261 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
4263 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4264 psIoWrite->IOCall(dwAddr, cpu.z80B, psIoWrite);
4275 sdwCyclesRemaining -= 15;
4276 dwTemp = cpu.z80HL - cpu.z80BC - (cpu.z80F & Z80_FLAG_CARRY);
4277 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4278 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
4279 if (0 == (dwTemp & 0xffff))
4281 cpu.z80F |= Z80_FLAG_ZERO;
4283 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
4284 cpu.z80F |= ((((cpu.z80BC ^ cpu.z80HL) & (cpu.z80BC ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
4285 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
4286 cpu.z80HL = dwTemp & 0xffff;
4291 sdwCyclesRemaining -= 20;
4293 dwTemp |= ((UINT32) *pbPC++ << 8);
4294 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
4295 while (psMemWrite->lowAddr != 0xffffffff)
4297 if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
4299 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4300 if (psMemWrite->memoryCall)
4302 psMemWrite->memoryCall(dwTemp, (cpu.z80BC & 0xff), psMemWrite);
4303 psMemWrite->memoryCall(dwTemp + 1, (cpu.z80BC >> 8), psMemWrite);
4307 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80BC;
4308 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80BC >> 8;
4318 cpu.z80Base[dwTemp] = (UINT8) cpu.z80BC;
4319 cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80BC >> 8);
4326 sdwCyclesRemaining -= 8;
4327 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
4328 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
4329 pbSubSbcTable[((UINT32) 0 << 8) | cpu.z80A];
4330 cpu.z80A = 0 - cpu.z80A;
4335 sdwCyclesRemaining -= 14;
4336 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
4337 dwAddr = *pbSP++; /* Pop LSB */
4338 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
4339 cpu.z80sp += 2; /* Pop the word off */
4340 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
4341 cpu.z80iff &= ~(IFF1); /* Keep IFF2 around */
4342 cpu.z80iff |= ((cpu.z80iff >> 1) & IFF1); /* IFF2->IFF1 */
4347 sdwCyclesRemaining -= 8;
4348 cpu.z80interruptMode = 0;
4353 sdwCyclesRemaining -= 9;
4354 cpu.z80i = cpu.z80A;
4359 sdwCyclesRemaining -= 12;
4361 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
4362 while (psIoRead->lowIoAddr != 0xffff)
4364 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
4366 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4367 cpu.z80C = psIoRead->IOCall(dwAddr, psIoRead);
4376 cpu.z80C = 0xff; /* Unclaimed I/O read */
4379 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4380 cpu.z80F |= bPostORFlags[cpu.z80C];
4385 sdwCyclesRemaining -= 12;
4387 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
4388 while (psIoWrite->lowIoAddr != 0xffff)
4390 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
4392 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4393 psIoWrite->IOCall(dwAddr, cpu.z80C, psIoWrite);
4404 sdwCyclesRemaining -= 15;
4405 dwTemp = cpu.z80HL + cpu.z80BC + (cpu.z80F & Z80_FLAG_CARRY);
4406 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4407 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
4408 if (0 == (dwTemp & 0xffff))
4410 cpu.z80F |= Z80_FLAG_ZERO;
4412 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
4413 cpu.z80F |= ((((cpu.z80BC ^ cpu.z80HL ^ 0x8000) & (cpu.z80BC ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
4414 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
4415 cpu.z80HL = dwTemp & 0xffff;
4420 sdwCyclesRemaining -= 20;
4422 dwTemp |= ((UINT32) *pbPC++ << 8);
4423 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
4424 while (psMemRead->lowAddr != 0xffffffff)
4426 if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
4428 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4429 if (psMemRead->memoryCall)
4431 cpu.z80BC = psMemRead->memoryCall(dwTemp, psMemRead);
4432 cpu.z80BC |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8);
4436 cpu.z80BC = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
4437 cpu.z80BC |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8);
4447 cpu.z80BC = cpu.z80Base[dwTemp];
4448 cpu.z80BC |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8);
4455 sdwCyclesRemaining -= 8;
4456 InvalidInstruction(2);
4461 sdwCyclesRemaining -= 14;
4462 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
4463 dwAddr = *pbSP++; /* Pop LSB */
4464 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
4465 cpu.z80sp += 2; /* Pop the word off */
4466 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
4471 sdwCyclesRemaining -= 8;
4472 InvalidInstruction(2);
4477 sdwCyclesRemaining -= 9;
4478 cpu.z80r = cpu.z80A;
4483 sdwCyclesRemaining -= 12;
4485 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
4486 while (psIoRead->lowIoAddr != 0xffff)
4488 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
4490 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4491 cpu.z80D = psIoRead->IOCall(dwAddr, psIoRead);
4500 cpu.z80D = 0xff; /* Unclaimed I/O read */
4503 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4504 cpu.z80F |= bPostORFlags[cpu.z80D];
4509 sdwCyclesRemaining -= 12;
4511 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
4512 while (psIoWrite->lowIoAddr != 0xffff)
4514 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
4516 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4517 psIoWrite->IOCall(dwAddr, cpu.z80D, psIoWrite);
4528 sdwCyclesRemaining -= 15;
4529 dwTemp = cpu.z80HL - cpu.z80DE - (cpu.z80F & Z80_FLAG_CARRY);
4530 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4531 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
4532 if (0 == (dwTemp & 0xffff))
4534 cpu.z80F |= Z80_FLAG_ZERO;
4536 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
4537 cpu.z80F |= ((((cpu.z80DE ^ cpu.z80HL) & (cpu.z80DE ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
4538 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
4539 cpu.z80HL = dwTemp & 0xffff;
4544 sdwCyclesRemaining -= 20;
4546 dwTemp |= ((UINT32) *pbPC++ << 8);
4547 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
4548 while (psMemWrite->lowAddr != 0xffffffff)
4550 if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
4552 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4553 if (psMemWrite->memoryCall)
4555 psMemWrite->memoryCall(dwTemp, (cpu.z80DE & 0xff), psMemWrite);
4556 psMemWrite->memoryCall(dwTemp + 1, (cpu.z80DE >> 8), psMemWrite);
4560 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80DE;
4561 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80DE >> 8;
4571 cpu.z80Base[dwTemp] = (UINT8) cpu.z80DE;
4572 cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80DE >> 8);
4579 sdwCyclesRemaining -= 8;
4580 InvalidInstruction(2);
4585 sdwCyclesRemaining -= 8;
4586 InvalidInstruction(2);
4591 sdwCyclesRemaining -= 8;
4592 cpu.z80interruptMode = 1;
4593 cpu.z80intAddr = 0x38;
4598 sdwCyclesRemaining -= 9;
4599 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4600 cpu.z80F |= ((cpu.z80iff & IFF2) << 1);
4601 cpu.z80A = cpu.z80i;
4602 cpu.z80F |= bPostORFlags[cpu.z80A];
4607 sdwCyclesRemaining -= 12;
4609 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
4610 while (psIoRead->lowIoAddr != 0xffff)
4612 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
4614 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4615 cpu.z80E = psIoRead->IOCall(dwAddr, psIoRead);
4624 cpu.z80E = 0xff; /* Unclaimed I/O read */
4627 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4628 cpu.z80F |= bPostORFlags[cpu.z80E];
4633 sdwCyclesRemaining -= 12;
4635 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
4636 while (psIoWrite->lowIoAddr != 0xffff)
4638 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
4640 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4641 psIoWrite->IOCall(dwAddr, cpu.z80E, psIoWrite);
4652 sdwCyclesRemaining -= 15;
4653 dwTemp = cpu.z80HL + cpu.z80DE + (cpu.z80F & Z80_FLAG_CARRY);
4654 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4655 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
4656 if (0 == (dwTemp & 0xffff))
4658 cpu.z80F |= Z80_FLAG_ZERO;
4660 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
4661 cpu.z80F |= ((((cpu.z80DE ^ cpu.z80HL ^ 0x8000) & (cpu.z80DE ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
4662 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
4663 cpu.z80HL = dwTemp & 0xffff;
4668 sdwCyclesRemaining -= 20;
4670 dwTemp |= ((UINT32) *pbPC++ << 8);
4671 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
4672 while (psMemRead->lowAddr != 0xffffffff)
4674 if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
4676 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4677 if (psMemRead->memoryCall)
4679 cpu.z80DE = psMemRead->memoryCall(dwTemp, psMemRead);
4680 cpu.z80DE |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8);
4684 cpu.z80DE = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
4685 cpu.z80DE |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8);
4695 cpu.z80DE = cpu.z80Base[dwTemp];
4696 cpu.z80DE |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8);
4703 sdwCyclesRemaining -= 8;
4704 InvalidInstruction(2);
4709 sdwCyclesRemaining -= 8;
4710 InvalidInstruction(2);
4715 sdwCyclesRemaining -= 8;
4716 cpu.z80interruptMode = 2;
4721 sdwCyclesRemaining -= 9;
4722 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4723 cpu.z80F |= bPostORFlags[cpu.z80r];
4724 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_OVERFLOW_PARITY)) | ((cpu.z80iff & IFF2) << 1);
4725 cpu.z80A = cpu.z80r;
4726 bTemp = (cpu.z80r + (cpu.z80B + sdwCyclesRemaining + 1 + cpu.z80H)) ^ cpu.z80A;
4727 cpu.z80r = (cpu.z80r & 0x80) | (bTemp & 0x7f);
4732 sdwCyclesRemaining -= 12;
4734 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
4735 while (psIoRead->lowIoAddr != 0xffff)
4737 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
4739 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4740 cpu.z80H = psIoRead->IOCall(dwAddr, psIoRead);
4749 cpu.z80H = 0xff; /* Unclaimed I/O read */
4752 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4753 cpu.z80F |= bPostORFlags[cpu.z80H];
4758 sdwCyclesRemaining -= 12;
4760 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
4761 while (psIoWrite->lowIoAddr != 0xffff)
4763 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
4765 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4766 psIoWrite->IOCall(dwAddr, cpu.z80H, psIoWrite);
4777 sdwCyclesRemaining -= 15;
4778 dwTemp = cpu.z80HL - cpu.z80HL - (cpu.z80F & Z80_FLAG_CARRY);
4779 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4780 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
4781 if (0 == (dwTemp & 0xffff))
4783 cpu.z80F |= Z80_FLAG_ZERO;
4785 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
4786 cpu.z80F |= ((((cpu.z80HL ^ cpu.z80HL) & (cpu.z80HL ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
4787 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
4788 cpu.z80HL = dwTemp & 0xffff;
4793 sdwCyclesRemaining -= 20;
4795 dwTemp |= ((UINT32) *pbPC++ << 8);
4796 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
4797 while (psMemWrite->lowAddr != 0xffffffff)
4799 if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
4801 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4802 if (psMemWrite->memoryCall)
4804 psMemWrite->memoryCall(dwTemp, (cpu.z80HL & 0xff), psMemWrite);
4805 psMemWrite->memoryCall(dwTemp + 1, (cpu.z80HL >> 8), psMemWrite);
4809 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80HL;
4810 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
4820 cpu.z80Base[dwTemp] = (UINT8) cpu.z80HL;
4821 cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
4828 sdwCyclesRemaining -= 8;
4829 InvalidInstruction(2);
4834 sdwCyclesRemaining -= 8;
4835 InvalidInstruction(2);
4840 sdwCyclesRemaining -= 8;
4841 InvalidInstruction(2);
4846 sdwCyclesRemaining -= 18;
4847 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
4848 while (psMemRead->lowAddr != 0xffffffff)
4850 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
4852 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4853 if (psMemRead->memoryCall)
4855 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
4859 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
4869 bTemp = cpu.z80Base[cpu.z80HL];
4872 bTemp2 = (cpu.z80A & 0x0f) << 4;
4873 cpu.z80A = (cpu.z80A & 0xf0) | (bTemp & 0x0f);
4874 bTemp = (bTemp >> 4) | bTemp2;
4875 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
4876 while (psMemWrite->lowAddr != 0xffffffff)
4878 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
4880 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4881 if (psMemWrite->memoryCall)
4883 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
4887 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
4897 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
4900 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4901 cpu.z80F |= bPostORFlags[cpu.z80A];
4906 sdwCyclesRemaining -= 12;
4908 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
4909 while (psIoRead->lowIoAddr != 0xffff)
4911 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
4913 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4914 cpu.z80L = psIoRead->IOCall(dwAddr, psIoRead);
4923 cpu.z80L = 0xff; /* Unclaimed I/O read */
4926 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
4927 cpu.z80F |= bPostORFlags[cpu.z80L];
4932 sdwCyclesRemaining -= 12;
4934 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
4935 while (psIoWrite->lowIoAddr != 0xffff)
4937 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
4939 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4940 psIoWrite->IOCall(dwAddr, cpu.z80L, psIoWrite);
4951 sdwCyclesRemaining -= 15;
4952 dwTemp = cpu.z80HL + cpu.z80HL + (cpu.z80F & Z80_FLAG_CARRY);
4953 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
4954 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
4955 if (0 == (dwTemp & 0xffff))
4957 cpu.z80F |= Z80_FLAG_ZERO;
4959 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
4960 cpu.z80F |= ((((cpu.z80HL ^ cpu.z80HL ^ 0x8000) & (cpu.z80HL ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
4961 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
4962 cpu.z80HL = dwTemp & 0xffff;
4967 sdwCyclesRemaining -= 20;
4968 InvalidInstruction(2);
4973 sdwCyclesRemaining -= 8;
4974 InvalidInstruction(2);
4979 sdwCyclesRemaining -= 8;
4980 InvalidInstruction(2);
4985 sdwCyclesRemaining -= 8;
4986 InvalidInstruction(2);
4991 sdwCyclesRemaining -= 18;
4992 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
4993 while (psMemRead->lowAddr != 0xffffffff)
4995 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
4997 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
4998 if (psMemRead->memoryCall)
5000 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5004 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5014 bTemp = cpu.z80Base[cpu.z80HL];
5017 bTemp2 = (cpu.z80A & 0x0f);
5018 cpu.z80A = (cpu.z80A & 0xf0) | (bTemp >> 4);
5019 bTemp = (bTemp << 4) | bTemp2;
5020 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5021 while (psMemWrite->lowAddr != 0xffffffff)
5023 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
5025 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5026 if (psMemWrite->memoryCall)
5028 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
5032 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
5042 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
5045 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5046 cpu.z80F |= bPostORFlags[cpu.z80A];
5051 sdwCyclesRemaining -= 12;
5052 InvalidInstruction(2);
5057 sdwCyclesRemaining -= 12;
5058 InvalidInstruction(2);
5063 sdwCyclesRemaining -= 15;
5064 dwTemp = cpu.z80HL - cpu.z80sp - (cpu.z80F & Z80_FLAG_CARRY);
5065 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
5066 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
5067 if (0 == (dwTemp & 0xffff))
5069 cpu.z80F |= Z80_FLAG_ZERO;
5071 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
5072 cpu.z80F |= ((((cpu.z80sp ^ cpu.z80HL) & (cpu.z80sp ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
5073 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
5074 cpu.z80HL = dwTemp & 0xffff;
5079 sdwCyclesRemaining -= 20;
5081 dwTemp |= ((UINT32) *pbPC++ << 8);
5082 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5083 while (psMemWrite->lowAddr != 0xffffffff)
5085 if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
5087 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5088 if (psMemWrite->memoryCall)
5090 psMemWrite->memoryCall(dwTemp, (cpu.z80sp & 0xff), psMemWrite);
5091 psMemWrite->memoryCall(dwTemp + 1, (cpu.z80sp >> 8), psMemWrite);
5095 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80sp;
5096 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80sp >> 8;
5106 cpu.z80Base[dwTemp] = (UINT8) cpu.z80sp;
5107 cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80sp >> 8);
5114 sdwCyclesRemaining -= 8;
5115 InvalidInstruction(2);
5120 sdwCyclesRemaining -= 8;
5121 InvalidInstruction(2);
5126 sdwCyclesRemaining -= 8;
5127 InvalidInstruction(2);
5132 InvalidInstruction(2);
5137 sdwCyclesRemaining -= 12;
5139 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
5140 while (psIoRead->lowIoAddr != 0xffff)
5142 if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
5144 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5145 cpu.z80A = psIoRead->IOCall(dwAddr, psIoRead);
5154 cpu.z80A = 0xff; /* Unclaimed I/O read */
5157 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5158 cpu.z80F |= bPostORFlags[cpu.z80A];
5163 sdwCyclesRemaining -= 12;
5165 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
5166 while (psIoWrite->lowIoAddr != 0xffff)
5168 if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
5170 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5171 psIoWrite->IOCall(dwAddr, cpu.z80A, psIoWrite);
5182 sdwCyclesRemaining -= 15;
5183 dwTemp = cpu.z80HL + cpu.z80sp + (cpu.z80F & Z80_FLAG_CARRY);
5184 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
5185 cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
5186 if (0 == (dwTemp & 0xffff))
5188 cpu.z80F |= Z80_FLAG_ZERO;
5190 cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
5191 cpu.z80F |= ((((cpu.z80sp ^ cpu.z80HL ^ 0x8000) & (cpu.z80sp ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
5192 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
5193 cpu.z80HL = dwTemp & 0xffff;
5198 sdwCyclesRemaining -= 20;
5200 dwTemp |= ((UINT32) *pbPC++ << 8);
5201 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5202 while (psMemRead->lowAddr != 0xffffffff)
5204 if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
5206 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5207 if (psMemRead->memoryCall)
5209 cpu.z80sp = psMemRead->memoryCall(dwTemp, psMemRead);
5210 cpu.z80sp |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8);
5214 cpu.z80sp = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
5215 cpu.z80sp |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8);
5225 cpu.z80sp = cpu.z80Base[dwTemp];
5226 cpu.z80sp |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8);
5233 sdwCyclesRemaining -= 8;
5234 InvalidInstruction(2);
5239 sdwCyclesRemaining -= 8;
5240 InvalidInstruction(2);
5245 sdwCyclesRemaining -= 8;
5246 InvalidInstruction(2);
5251 InvalidInstruction(2);
5256 InvalidInstruction(2);
5261 InvalidInstruction(2);
5266 InvalidInstruction(2);
5271 InvalidInstruction(2);
5276 InvalidInstruction(2);
5281 InvalidInstruction(2);
5286 InvalidInstruction(2);
5291 InvalidInstruction(2);
5296 InvalidInstruction(2);
5301 InvalidInstruction(2);
5306 InvalidInstruction(2);
5311 InvalidInstruction(2);
5316 InvalidInstruction(2);
5321 InvalidInstruction(2);
5326 InvalidInstruction(2);
5331 InvalidInstruction(2);
5336 InvalidInstruction(2);
5341 InvalidInstruction(2);
5346 InvalidInstruction(2);
5351 InvalidInstruction(2);
5356 InvalidInstruction(2);
5361 InvalidInstruction(2);
5366 InvalidInstruction(2);
5371 InvalidInstruction(2);
5376 InvalidInstruction(2);
5381 InvalidInstruction(2);
5386 InvalidInstruction(2);
5391 InvalidInstruction(2);
5396 InvalidInstruction(2);
5401 InvalidInstruction(2);
5406 InvalidInstruction(2);
5411 InvalidInstruction(2);
5416 sdwCyclesRemaining -= 16;
5417 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5418 while (psMemRead->lowAddr != 0xffffffff)
5420 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5422 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5423 if (psMemRead->memoryCall)
5425 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5429 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5439 bTemp = cpu.z80Base[cpu.z80HL];
5442 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5443 while (psMemWrite->lowAddr != 0xffffffff)
5445 if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
5447 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5448 if (psMemWrite->memoryCall)
5450 psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
5454 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
5464 cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
5470 cpu.z80HL &= 0xffff;
5471 cpu.z80DE &= 0xffff;
5472 cpu.z80BC &= 0xffff;
5473 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
5476 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5482 sdwCyclesRemaining -= 16;
5484 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5485 while (psMemRead->lowAddr != 0xffffffff)
5487 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5489 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5490 if (psMemRead->memoryCall)
5492 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5496 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5506 bTemp = cpu.z80Base[cpu.z80HL];
5510 cpu.z80HL &= 0xffff;
5512 cpu.z80BC &= 0xffff;
5514 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5515 cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
5518 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5524 sdwCyclesRemaining -= 16;
5526 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
5527 while (psIoRead->lowIoAddr != 0xffff)
5529 if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
5531 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5532 bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
5541 bTemp = 0xff; /* Unclaimed I/O read */
5544 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5545 while (psMemWrite->lowAddr != 0xffffffff)
5547 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
5549 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5550 if (psMemWrite->memoryCall)
5552 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
5556 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
5566 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
5570 cpu.z80HL &= 0xffff;
5571 sdwCyclesRemaining -= 16;
5574 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5575 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
5578 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5585 sdwCyclesRemaining -= 16;
5587 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5588 while (psMemRead->lowAddr != 0xffffffff)
5590 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5592 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5593 if (psMemRead->memoryCall)
5595 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5599 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5609 bTemp = cpu.z80Base[cpu.z80HL];
5612 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
5613 while (psIoWrite->lowIoAddr != 0xffff)
5615 if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
5617 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5618 psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
5626 cpu.z80HL &= 0xffff;
5627 sdwCyclesRemaining -= 16;
5630 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5631 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
5634 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5640 InvalidInstruction(2);
5645 InvalidInstruction(2);
5650 InvalidInstruction(2);
5655 InvalidInstruction(2);
5660 sdwCyclesRemaining -= 16;
5661 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5662 while (psMemRead->lowAddr != 0xffffffff)
5664 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5666 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5667 if (psMemRead->memoryCall)
5669 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5673 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5683 bTemp = cpu.z80Base[cpu.z80HL];
5686 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5687 while (psMemWrite->lowAddr != 0xffffffff)
5689 if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
5691 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5692 if (psMemWrite->memoryCall)
5694 psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
5698 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
5708 cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
5714 cpu.z80HL &= 0xffff;
5715 cpu.z80DE &= 0xffff;
5716 cpu.z80BC &= 0xffff;
5717 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
5720 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5726 sdwCyclesRemaining -= 16;
5728 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5729 while (psMemRead->lowAddr != 0xffffffff)
5731 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5733 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5734 if (psMemRead->memoryCall)
5736 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5740 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5750 bTemp = cpu.z80Base[cpu.z80HL];
5754 cpu.z80HL &= 0xffff;
5756 cpu.z80BC &= 0xffff;
5758 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5759 cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
5762 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5768 sdwCyclesRemaining -= 16;
5770 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
5771 while (psIoRead->lowIoAddr != 0xffff)
5773 if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
5775 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5776 bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
5785 bTemp = 0xff; /* Unclaimed I/O read */
5788 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5789 while (psMemWrite->lowAddr != 0xffffffff)
5791 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
5793 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5794 if (psMemWrite->memoryCall)
5796 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
5800 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
5810 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
5814 cpu.z80HL &= 0xffff;
5815 sdwCyclesRemaining -= 16;
5818 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5819 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
5822 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5829 sdwCyclesRemaining -= 16;
5831 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5832 while (psMemRead->lowAddr != 0xffffffff)
5834 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5836 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5837 if (psMemRead->memoryCall)
5839 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5843 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5853 bTemp = cpu.z80Base[cpu.z80HL];
5856 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
5857 while (psIoWrite->lowIoAddr != 0xffff)
5859 if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
5861 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5862 psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
5870 cpu.z80HL &= 0xffff;
5871 sdwCyclesRemaining -= 16;
5874 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
5875 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
5878 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5884 InvalidInstruction(2);
5889 InvalidInstruction(2);
5894 InvalidInstruction(2);
5899 InvalidInstruction(2);
5904 sdwCyclesRemaining -= 16;
5905 while ((sdwCyclesRemaining > 0) && (cpu.z80BC))
5907 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5908 while (psMemRead->lowAddr != 0xffffffff)
5910 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5912 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5913 if (psMemRead->memoryCall)
5915 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5919 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
5929 bTemp = cpu.z80Base[cpu.z80HL];
5932 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
5933 while (psMemWrite->lowAddr != 0xffffffff)
5935 if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
5937 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5938 if (psMemWrite->memoryCall)
5940 psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
5944 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
5954 cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
5960 cpu.z80HL &= 0xffff;
5961 cpu.z80DE &= 0xffff;
5962 cpu.z80BC &= 0xffff;
5963 sdwCyclesRemaining -= 21;
5965 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
5968 pbPC -= 2; /* Back up so we hit this instruction again */
5969 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
5971 sdwCyclesRemaining -= 16;
5976 sdwCyclesRemaining -= 16;
5977 while ((sdwCyclesRemaining >= 0) && (cpu.z80BC))
5979 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
5980 while (psMemRead->lowAddr != 0xffffffff)
5982 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
5984 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
5985 if (psMemRead->memoryCall)
5987 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
5991 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
6001 bTemp = cpu.z80Base[cpu.z80HL];
6005 cpu.z80HL &= 0xffff;
6007 cpu.z80BC &= 0xffff;
6008 sdwCyclesRemaining -= 16;
6009 if (cpu.z80A == bTemp)
6014 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6015 cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
6018 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6024 sdwCyclesRemaining -= 16;
6025 while ((sdwCyclesRemaining > 0) && (cpu.z80B))
6027 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
6028 while (psIoRead->lowIoAddr != 0xffff)
6030 if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
6032 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6033 bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
6042 bTemp = 0xff; /* Unclaimed I/O read */
6045 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
6046 while (psMemWrite->lowAddr != 0xffffffff)
6048 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
6050 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6051 if (psMemWrite->memoryCall)
6053 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
6057 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
6067 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
6071 cpu.z80HL &= 0xffff;
6072 sdwCyclesRemaining -= 16;
6075 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6076 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
6079 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6086 sdwCyclesRemaining -= 16;
6087 while ((sdwCyclesRemaining > 0) && (cpu.z80B))
6089 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
6090 while (psMemRead->lowAddr != 0xffffffff)
6092 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
6094 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6095 if (psMemRead->memoryCall)
6097 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
6101 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
6111 bTemp = cpu.z80Base[cpu.z80HL];
6114 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
6115 while (psIoWrite->lowIoAddr != 0xffff)
6117 if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
6119 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6120 psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
6128 cpu.z80HL &= 0xffff;
6129 sdwCyclesRemaining -= 16;
6132 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6133 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
6136 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6142 InvalidInstruction(2);
6147 InvalidInstruction(2);
6152 InvalidInstruction(2);
6157 InvalidInstruction(2);
6162 sdwCyclesRemaining -= 16;
6163 while ((sdwCyclesRemaining > 0) && (cpu.z80BC))
6165 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
6166 while (psMemRead->lowAddr != 0xffffffff)
6168 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
6170 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6171 if (psMemRead->memoryCall)
6173 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
6177 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
6187 bTemp = cpu.z80Base[cpu.z80HL];
6190 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
6191 while (psMemWrite->lowAddr != 0xffffffff)
6193 if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
6195 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6196 if (psMemWrite->memoryCall)
6198 psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
6202 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
6212 cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
6218 cpu.z80HL &= 0xffff;
6219 cpu.z80DE &= 0xffff;
6220 cpu.z80BC &= 0xffff;
6221 sdwCyclesRemaining -= 21;
6223 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
6226 pbPC -= 2; /* Back up so we hit this instruction again */
6227 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6229 sdwCyclesRemaining -= 16;
6234 sdwCyclesRemaining -= 16;
6235 while ((sdwCyclesRemaining >= 0) && (cpu.z80BC))
6237 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
6238 while (psMemRead->lowAddr != 0xffffffff)
6240 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
6242 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6243 if (psMemRead->memoryCall)
6245 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
6249 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
6259 bTemp = cpu.z80Base[cpu.z80HL];
6263 cpu.z80HL &= 0xffff;
6265 cpu.z80BC &= 0xffff;
6266 sdwCyclesRemaining -= 16;
6267 if (cpu.z80A == bTemp)
6272 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6273 cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
6276 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6282 sdwCyclesRemaining -= 16;
6283 while ((sdwCyclesRemaining > 0) && (cpu.z80B))
6285 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
6286 while (psIoRead->lowIoAddr != 0xffff)
6288 if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
6290 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6291 bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
6300 bTemp = 0xff; /* Unclaimed I/O read */
6303 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
6304 while (psMemWrite->lowAddr != 0xffffffff)
6306 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
6308 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6309 if (psMemWrite->memoryCall)
6311 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
6315 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
6325 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
6329 cpu.z80HL &= 0xffff;
6330 sdwCyclesRemaining -= 16;
6333 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6334 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
6337 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6344 sdwCyclesRemaining -= 16;
6345 while ((sdwCyclesRemaining > 0) && (cpu.z80B))
6347 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
6348 while (psMemRead->lowAddr != 0xffffffff)
6350 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
6352 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6353 if (psMemRead->memoryCall)
6355 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
6359 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
6369 bTemp = cpu.z80Base[cpu.z80HL];
6372 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
6373 while (psIoWrite->lowIoAddr != 0xffff)
6375 if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
6377 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6378 psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
6386 cpu.z80HL &= 0xffff;
6387 sdwCyclesRemaining -= 16;
6390 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6391 cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
6394 cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
6400 InvalidInstruction(2);
6405 InvalidInstruction(2);
6410 InvalidInstruction(2);
6415 InvalidInstruction(2);
6420 InvalidInstruction(2);
6425 InvalidInstruction(2);
6430 InvalidInstruction(2);
6435 InvalidInstruction(2);
6440 InvalidInstruction(2);
6445 InvalidInstruction(2);
6450 InvalidInstruction(2);
6455 InvalidInstruction(2);
6460 InvalidInstruction(2);
6465 InvalidInstruction(2);
6470 InvalidInstruction(2);
6475 InvalidInstruction(2);
6480 InvalidInstruction(2);
6485 InvalidInstruction(2);
6490 InvalidInstruction(2);
6495 InvalidInstruction(2);
6500 InvalidInstruction(2);
6505 InvalidInstruction(2);
6510 InvalidInstruction(2);
6515 InvalidInstruction(2);
6520 InvalidInstruction(2);
6525 InvalidInstruction(2);
6530 InvalidInstruction(2);
6535 InvalidInstruction(2);
6540 InvalidInstruction(2);
6545 InvalidInstruction(2);
6550 InvalidInstruction(2);
6555 InvalidInstruction(2);
6560 InvalidInstruction(2);
6565 InvalidInstruction(2);
6570 InvalidInstruction(2);
6575 InvalidInstruction(2);
6580 InvalidInstruction(2);
6585 InvalidInstruction(2);
6590 InvalidInstruction(2);
6595 InvalidInstruction(2);
6600 InvalidInstruction(2);
6605 InvalidInstruction(2);
6610 InvalidInstruction(2);
6615 InvalidInstruction(2);
6620 InvalidInstruction(2);
6625 InvalidInstruction(2);
6630 InvalidInstruction(2);
6635 InvalidInstruction(2);
6640 InvalidInstruction(2);
6645 InvalidInstruction(2);
6650 InvalidInstruction(2);
6655 InvalidInstruction(2);
6660 InvalidInstruction(2);
6665 InvalidInstruction(2);
6670 InvalidInstruction(2);
6675 InvalidInstruction(2);
6680 InvalidInstruction(2);
6685 InvalidInstruction(2);
6690 InvalidInstruction(2);
6695 InvalidInstruction(2);
6700 InvalidInstruction(2);
6705 InvalidInstruction(2);
6710 InvalidInstruction(2);
6715 InvalidInstruction(2);
6720 InvalidInstruction(2);
6725 InvalidInstruction(2);
6730 InvalidInstruction(2);
6735 InvalidInstruction(2);
6741 void DDHandler(void)
6747 InvalidInstruction(2);
6752 InvalidInstruction(2);
6757 InvalidInstruction(2);
6762 InvalidInstruction(2);
6767 InvalidInstruction(2);
6772 InvalidInstruction(2);
6777 InvalidInstruction(2);
6782 InvalidInstruction(2);
6787 InvalidInstruction(2);
6792 sdwCyclesRemaining -= 15;
6793 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
6794 dwTemp = cpu.z80IX + cpu.z80BC;
6795 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
6796 cpu.z80IX = dwTemp & 0xffff;
6801 InvalidInstruction(2);
6806 InvalidInstruction(2);
6811 InvalidInstruction(2);
6816 InvalidInstruction(2);
6821 InvalidInstruction(2);
6826 InvalidInstruction(2);
6831 InvalidInstruction(2);
6836 InvalidInstruction(2);
6841 InvalidInstruction(2);
6846 InvalidInstruction(2);
6851 InvalidInstruction(2);
6856 InvalidInstruction(2);
6861 InvalidInstruction(2);
6866 InvalidInstruction(2);
6871 InvalidInstruction(2);
6876 sdwCyclesRemaining -= 15;
6877 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
6878 dwTemp = cpu.z80IX + cpu.z80DE;
6879 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
6880 cpu.z80IX = dwTemp & 0xffff;
6885 InvalidInstruction(2);
6890 InvalidInstruction(2);
6895 InvalidInstruction(2);
6900 InvalidInstruction(2);
6905 InvalidInstruction(2);
6910 InvalidInstruction(2);
6915 InvalidInstruction(2);
6920 sdwCyclesRemaining -= 14;
6921 cpu.z80IX = *pbPC++;
6922 cpu.z80IX |= ((UINT32) *pbPC++ << 8);
6927 sdwCyclesRemaining -= 20;
6929 dwAddr |= ((UINT32) *pbPC++ << 8);
6930 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
6931 while (psMemWrite->lowAddr != 0xffffffff)
6933 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
6935 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
6936 if (psMemWrite->memoryCall)
6938 psMemWrite->memoryCall(dwAddr, (cpu.z80IX & 0xff), psMemWrite);
6939 psMemWrite->memoryCall(dwAddr + 1, (cpu.z80IX >> 8), psMemWrite);
6943 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = cpu.z80IX;
6944 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8;
6954 cpu.z80Base[dwAddr] = (UINT8) cpu.z80IX;
6955 cpu.z80Base[dwAddr + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8);
6962 sdwCyclesRemaining -= 10;
6964 cpu.z80IX &= 0xffff;
6969 sdwCyclesRemaining -= 9;
6970 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6971 cpu.z80F |= bPostIncFlags[cpu.z80XH++];
6976 sdwCyclesRemaining -= 9;
6977 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
6978 cpu.z80F |= bPostDecFlags[cpu.z80XH--];
6983 sdwCyclesRemaining -= 9;
6984 cpu.z80XH = *pbPC++;
6989 InvalidInstruction(2);
6994 InvalidInstruction(2);
6999 sdwCyclesRemaining -= 15;
7000 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
7001 dwTemp = cpu.z80IX + cpu.z80IX;
7002 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
7003 cpu.z80IX = dwTemp & 0xffff;
7008 sdwCyclesRemaining -= 20;
7010 dwAddr |= ((UINT32) *pbPC++ << 8);
7011 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7012 while (psMemRead->lowAddr != 0xffffffff)
7014 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
7016 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7017 if (psMemRead->memoryCall)
7019 cpu.z80IX = psMemRead->memoryCall(dwAddr, psMemRead);
7020 cpu.z80IX |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8);
7024 cpu.z80IX = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
7025 cpu.z80IX |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8);
7035 cpu.z80IX = cpu.z80Base[dwAddr];
7036 cpu.z80IX |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8);
7043 sdwCyclesRemaining -= 10;
7045 cpu.z80IX &= 0xffff;
7050 sdwCyclesRemaining -= 9;
7051 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
7052 cpu.z80F |= bPostIncFlags[cpu.z80XL++];
7057 sdwCyclesRemaining -= 9;
7058 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
7059 cpu.z80F |= bPostDecFlags[cpu.z80XL--];
7064 sdwCyclesRemaining -= 9;
7065 cpu.z80XL = *pbPC++;
7070 InvalidInstruction(2);
7075 InvalidInstruction(2);
7080 InvalidInstruction(2);
7085 InvalidInstruction(2);
7090 InvalidInstruction(2);
7095 sdwCyclesRemaining -= 23;
7096 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
7097 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
7098 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7099 while (psMemRead->lowAddr != 0xffffffff)
7101 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
7103 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7104 if (psMemRead->memoryCall)
7106 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
7110 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
7120 bTemp = cpu.z80Base[dwAddr];
7123 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
7124 cpu.z80F |= bPostIncFlags[bTemp++];
7125 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7126 while (psMemWrite->lowAddr != 0xffffffff)
7128 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
7130 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7131 if (psMemWrite->memoryCall)
7133 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
7137 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
7147 cpu.z80Base[dwAddr] = (UINT8) bTemp;
7154 sdwCyclesRemaining -= 23;
7155 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
7156 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
7157 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7158 while (psMemRead->lowAddr != 0xffffffff)
7160 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
7162 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7163 if (psMemRead->memoryCall)
7165 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
7169 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
7179 bTemp = cpu.z80Base[dwAddr];
7182 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
7183 cpu.z80F |= bPostDecFlags[bTemp--];
7184 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7185 while (psMemWrite->lowAddr != 0xffffffff)
7187 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
7189 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7190 if (psMemWrite->memoryCall)
7192 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
7196 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
7206 cpu.z80Base[dwAddr] = (UINT8) bTemp;
7213 sdwCyclesRemaining -= 19;
7214 sdwAddr = (INT8) *pbPC++; // Get the offset
7215 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7216 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7217 while (psMemWrite->lowAddr != 0xffffffff)
7219 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7221 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7222 if (psMemWrite->memoryCall)
7224 psMemWrite->memoryCall(sdwAddr, *pbPC++, psMemWrite);
7228 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = *pbPC++;
7238 cpu.z80Base[sdwAddr] = (UINT8) *pbPC++;
7245 InvalidInstruction(2);
7250 InvalidInstruction(2);
7255 sdwCyclesRemaining -= 15;
7256 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
7257 dwTemp = cpu.z80IX + cpu.z80sp;
7258 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
7259 cpu.z80IX = dwTemp & 0xffff;
7264 InvalidInstruction(2);
7269 InvalidInstruction(2);
7274 InvalidInstruction(2);
7279 InvalidInstruction(2);
7284 InvalidInstruction(2);
7289 InvalidInstruction(2);
7294 InvalidInstruction(2);
7299 InvalidInstruction(2);
7304 InvalidInstruction(2);
7309 InvalidInstruction(2);
7314 sdwCyclesRemaining -= 9;
7315 cpu.z80B = cpu.z80XH;
7320 sdwCyclesRemaining -= 9;
7321 cpu.z80B = cpu.z80XL;
7326 sdwCyclesRemaining -= 19;
7327 sdwAddr = (INT8) *pbPC++; // Get the offset
7328 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7329 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7330 while (psMemRead->lowAddr != 0xffffffff)
7332 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7334 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7335 if (psMemRead->memoryCall)
7337 cpu.z80B = psMemRead->memoryCall(sdwAddr, psMemRead);
7341 cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
7351 cpu.z80B = cpu.z80Base[sdwAddr];
7358 InvalidInstruction(2);
7363 InvalidInstruction(2);
7368 InvalidInstruction(2);
7373 InvalidInstruction(2);
7378 InvalidInstruction(2);
7383 sdwCyclesRemaining -= 9;
7384 cpu.z80C = cpu.z80XH;
7389 sdwCyclesRemaining -= 9;
7390 cpu.z80C = cpu.z80XL;
7395 sdwCyclesRemaining -= 19;
7396 sdwAddr = (INT8) *pbPC++; // Get the offset
7397 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7398 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7399 while (psMemRead->lowAddr != 0xffffffff)
7401 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7403 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7404 if (psMemRead->memoryCall)
7406 cpu.z80C = psMemRead->memoryCall(sdwAddr, psMemRead);
7410 cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
7420 cpu.z80C = cpu.z80Base[sdwAddr];
7427 InvalidInstruction(2);
7432 InvalidInstruction(2);
7437 InvalidInstruction(2);
7442 InvalidInstruction(2);
7447 InvalidInstruction(2);
7452 sdwCyclesRemaining -= 9;
7453 cpu.z80D = cpu.z80XH;
7458 sdwCyclesRemaining -= 9;
7459 cpu.z80D = cpu.z80XL;
7464 sdwCyclesRemaining -= 19;
7465 sdwAddr = (INT8) *pbPC++; // Get the offset
7466 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7467 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7468 while (psMemRead->lowAddr != 0xffffffff)
7470 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7472 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7473 if (psMemRead->memoryCall)
7475 cpu.z80D = psMemRead->memoryCall(sdwAddr, psMemRead);
7479 cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
7489 cpu.z80D = cpu.z80Base[sdwAddr];
7496 InvalidInstruction(2);
7501 InvalidInstruction(2);
7506 InvalidInstruction(2);
7511 InvalidInstruction(2);
7516 InvalidInstruction(2);
7521 sdwCyclesRemaining -= 9;
7522 cpu.z80E = cpu.z80XH;
7527 sdwCyclesRemaining -= 9;
7528 cpu.z80E = cpu.z80XL;
7533 sdwCyclesRemaining -= 19;
7534 sdwAddr = (INT8) *pbPC++; // Get the offset
7535 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7536 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7537 while (psMemRead->lowAddr != 0xffffffff)
7539 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7541 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7542 if (psMemRead->memoryCall)
7544 cpu.z80E = psMemRead->memoryCall(sdwAddr, psMemRead);
7548 cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
7558 cpu.z80E = cpu.z80Base[sdwAddr];
7565 InvalidInstruction(2);
7570 sdwCyclesRemaining -= 9;
7571 cpu.z80XH = cpu.z80B;
7576 sdwCyclesRemaining -= 9;
7577 cpu.z80XH = cpu.z80C;
7582 sdwCyclesRemaining -= 9;
7583 cpu.z80XH = cpu.z80D;
7588 sdwCyclesRemaining -= 9;
7589 cpu.z80XH = cpu.z80E;
7594 sdwCyclesRemaining -= 9;
7599 sdwCyclesRemaining -= 9;
7600 cpu.z80XH = cpu.z80XL;
7605 sdwCyclesRemaining -= 19;
7606 sdwAddr = (INT8) *pbPC++; // Get the offset
7607 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7608 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7609 while (psMemRead->lowAddr != 0xffffffff)
7611 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7613 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7614 if (psMemRead->memoryCall)
7616 cpu.z80H = psMemRead->memoryCall(sdwAddr, psMemRead);
7620 cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
7630 cpu.z80H = cpu.z80Base[sdwAddr];
7637 sdwCyclesRemaining -= 9;
7638 cpu.z80XH = cpu.z80A;
7643 sdwCyclesRemaining -= 9;
7644 cpu.z80XL = cpu.z80B;
7649 sdwCyclesRemaining -= 9;
7650 cpu.z80XL = cpu.z80C;
7655 sdwCyclesRemaining -= 9;
7656 cpu.z80XL = cpu.z80D;
7661 sdwCyclesRemaining -= 9;
7662 cpu.z80XL = cpu.z80E;
7667 sdwCyclesRemaining -= 9;
7668 cpu.z80XL = cpu.z80XH;
7673 sdwCyclesRemaining -= 9;
7678 sdwCyclesRemaining -= 19;
7679 sdwAddr = (INT8) *pbPC++; // Get the offset
7680 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7681 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7682 while (psMemRead->lowAddr != 0xffffffff)
7684 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7686 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7687 if (psMemRead->memoryCall)
7689 cpu.z80L = psMemRead->memoryCall(sdwAddr, psMemRead);
7693 cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
7703 cpu.z80L = cpu.z80Base[sdwAddr];
7710 sdwCyclesRemaining -= 9;
7711 cpu.z80XL = cpu.z80A;
7716 sdwCyclesRemaining -= 19;
7717 sdwAddr = (INT8) *pbPC++; // Get the offset
7718 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7719 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7720 while (psMemWrite->lowAddr != 0xffffffff)
7722 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7724 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7725 if (psMemWrite->memoryCall)
7727 psMemWrite->memoryCall(sdwAddr, cpu.z80B, psMemWrite);
7731 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80B;
7741 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80B;
7748 sdwCyclesRemaining -= 19;
7749 sdwAddr = (INT8) *pbPC++; // Get the offset
7750 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7751 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7752 while (psMemWrite->lowAddr != 0xffffffff)
7754 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7756 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7757 if (psMemWrite->memoryCall)
7759 psMemWrite->memoryCall(sdwAddr, cpu.z80C, psMemWrite);
7763 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80C;
7773 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80C;
7780 sdwCyclesRemaining -= 19;
7781 sdwAddr = (INT8) *pbPC++; // Get the offset
7782 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7783 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7784 while (psMemWrite->lowAddr != 0xffffffff)
7786 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7788 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7789 if (psMemWrite->memoryCall)
7791 psMemWrite->memoryCall(sdwAddr, cpu.z80D, psMemWrite);
7795 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80D;
7805 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80D;
7812 sdwCyclesRemaining -= 19;
7813 sdwAddr = (INT8) *pbPC++; // Get the offset
7814 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7815 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7816 while (psMemWrite->lowAddr != 0xffffffff)
7818 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7820 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7821 if (psMemWrite->memoryCall)
7823 psMemWrite->memoryCall(sdwAddr, cpu.z80E, psMemWrite);
7827 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80E;
7837 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80E;
7844 sdwCyclesRemaining -= 19;
7845 sdwAddr = (INT8) *pbPC++; // Get the offset
7846 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7847 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7848 while (psMemWrite->lowAddr != 0xffffffff)
7850 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7852 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7853 if (psMemWrite->memoryCall)
7855 psMemWrite->memoryCall(sdwAddr, cpu.z80H, psMemWrite);
7859 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80H;
7869 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80H;
7876 sdwCyclesRemaining -= 19;
7877 sdwAddr = (INT8) *pbPC++; // Get the offset
7878 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7879 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7880 while (psMemWrite->lowAddr != 0xffffffff)
7882 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7884 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7885 if (psMemWrite->memoryCall)
7887 psMemWrite->memoryCall(sdwAddr, cpu.z80L, psMemWrite);
7891 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80L;
7901 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80L;
7908 sdwCyclesRemaining -= 19;
7909 InvalidInstruction(2);
7914 sdwCyclesRemaining -= 19;
7915 sdwAddr = (INT8) *pbPC++; // Get the offset
7916 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7917 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
7918 while (psMemWrite->lowAddr != 0xffffffff)
7920 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
7922 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7923 if (psMemWrite->memoryCall)
7925 psMemWrite->memoryCall(sdwAddr, cpu.z80A, psMemWrite);
7929 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80A;
7939 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80A;
7946 InvalidInstruction(2);
7951 InvalidInstruction(2);
7956 InvalidInstruction(2);
7961 InvalidInstruction(2);
7966 sdwCyclesRemaining -= 9;
7967 cpu.z80A = cpu.z80XH;
7972 sdwCyclesRemaining -= 9;
7973 cpu.z80A = cpu.z80XL;
7978 sdwCyclesRemaining -= 19;
7979 sdwAddr = (INT8) *pbPC++; // Get the offset
7980 sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
7981 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
7982 while (psMemRead->lowAddr != 0xffffffff)
7984 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
7986 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
7987 if (psMemRead->memoryCall)
7989 cpu.z80A = psMemRead->memoryCall(sdwAddr, psMemRead);
7993 cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
8003 cpu.z80A = cpu.z80Base[sdwAddr];
8010 InvalidInstruction(2);
8015 InvalidInstruction(2);
8020 InvalidInstruction(2);
8025 InvalidInstruction(2);
8030 InvalidInstruction(2);
8035 sdwCyclesRemaining -= 9;
8036 bTemp2 = cpu.z80A + cpu.z80XH;
8037 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8038 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8039 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH];
8040 InvalidInstruction(2);
8045 sdwCyclesRemaining -= 9;
8046 bTemp2 = cpu.z80A + cpu.z80XL;
8047 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8048 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8049 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL];
8050 InvalidInstruction(2);
8055 sdwCyclesRemaining -= 19;
8056 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8057 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8058 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8059 while (psMemRead->lowAddr != 0xffffffff)
8061 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8063 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8064 if (psMemRead->memoryCall)
8066 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8070 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8080 bTemp = cpu.z80Base[dwAddr];
8083 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8084 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8085 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
8091 InvalidInstruction(2);
8096 InvalidInstruction(2);
8101 InvalidInstruction(2);
8106 InvalidInstruction(2);
8111 InvalidInstruction(2);
8116 sdwCyclesRemaining -= 9;
8117 bTemp2 = cpu.z80A + cpu.z80XH + (cpu.z80F & Z80_FLAG_CARRY);
8118 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8119 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8120 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
8121 InvalidInstruction(2);
8126 sdwCyclesRemaining -= 9;
8127 bTemp2 = cpu.z80A + cpu.z80XL + (cpu.z80F & Z80_FLAG_CARRY);
8128 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8129 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8130 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
8131 InvalidInstruction(2);
8136 sdwCyclesRemaining -= 19;
8137 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8138 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8139 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8140 while (psMemRead->lowAddr != 0xffffffff)
8142 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8144 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8145 if (psMemRead->memoryCall)
8147 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8151 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8161 bTemp = cpu.z80Base[dwAddr];
8164 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY);
8165 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8166 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8167 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
8168 cpu.z80A += bTemp + bTemp2;
8173 InvalidInstruction(2);
8178 InvalidInstruction(2);
8183 InvalidInstruction(2);
8188 InvalidInstruction(2);
8193 InvalidInstruction(2);
8198 sdwCyclesRemaining -= 9;
8199 bTemp2 = cpu.z80A - cpu.z80XH;
8200 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8201 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8202 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH];
8203 InvalidInstruction(2);
8208 sdwCyclesRemaining -= 9;
8209 bTemp2 = cpu.z80A - cpu.z80XL;
8210 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8211 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8212 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL];
8213 InvalidInstruction(2);
8218 sdwCyclesRemaining -= 19;
8219 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8220 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8221 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8222 while (psMemRead->lowAddr != 0xffffffff)
8224 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8226 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8227 if (psMemRead->memoryCall)
8229 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8233 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8243 bTemp = cpu.z80Base[dwAddr];
8246 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8247 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8248 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
8254 InvalidInstruction(2);
8259 InvalidInstruction(2);
8264 InvalidInstruction(2);
8269 InvalidInstruction(2);
8274 InvalidInstruction(2);
8279 sdwCyclesRemaining -= 9;
8280 bTemp2 = cpu.z80A - cpu.z80XH - (cpu.z80F & Z80_FLAG_CARRY);
8281 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8282 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8283 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
8284 InvalidInstruction(2);
8289 sdwCyclesRemaining -= 9;
8290 bTemp2 = cpu.z80A - cpu.z80XL - (cpu.z80F & Z80_FLAG_CARRY);
8291 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8292 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8293 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
8294 InvalidInstruction(2);
8299 sdwCyclesRemaining -= 19;
8300 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8301 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8302 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8303 while (psMemRead->lowAddr != 0xffffffff)
8305 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8307 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8308 if (psMemRead->memoryCall)
8310 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8314 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8324 bTemp = cpu.z80Base[dwAddr];
8328 cpu.z80A = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY);
8329 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8330 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8331 pbSubSbcTable[((UINT32) bTemp2 << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
8336 InvalidInstruction(2);
8341 InvalidInstruction(2);
8346 InvalidInstruction(2);
8351 InvalidInstruction(2);
8356 InvalidInstruction(2);
8361 sdwCyclesRemaining -= 9;
8362 cpu.z80A &= cpu.z80XH;
8363 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8364 cpu.z80F |= bPostANDFlags[cpu.z80A];
8366 InvalidInstruction(2);
8371 sdwCyclesRemaining -= 9;
8372 cpu.z80A &= cpu.z80XL;
8373 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8374 cpu.z80F |= bPostANDFlags[cpu.z80A];
8376 InvalidInstruction(2);
8381 sdwCyclesRemaining -= 19;
8382 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8383 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8384 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8385 while (psMemRead->lowAddr != 0xffffffff)
8387 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8389 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8390 if (psMemRead->memoryCall)
8392 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8396 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8406 bTemp = cpu.z80Base[dwAddr];
8410 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8411 cpu.z80F |= bPostANDFlags[cpu.z80A];
8417 InvalidInstruction(2);
8422 InvalidInstruction(2);
8427 InvalidInstruction(2);
8432 InvalidInstruction(2);
8437 InvalidInstruction(2);
8442 sdwCyclesRemaining -= 9;
8443 cpu.z80A ^= cpu.z80XH;
8444 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8445 cpu.z80F |= bPostORFlags[cpu.z80A];
8447 InvalidInstruction(2);
8452 sdwCyclesRemaining -= 9;
8453 cpu.z80A ^= cpu.z80XL;
8454 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8455 cpu.z80F |= bPostORFlags[cpu.z80A];
8457 InvalidInstruction(2);
8462 sdwCyclesRemaining -= 19;
8463 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8464 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8465 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8466 while (psMemRead->lowAddr != 0xffffffff)
8468 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8470 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8471 if (psMemRead->memoryCall)
8473 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8477 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8487 bTemp = cpu.z80Base[dwAddr];
8491 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8492 cpu.z80F |= bPostORFlags[cpu.z80A];
8498 InvalidInstruction(2);
8503 InvalidInstruction(2);
8508 InvalidInstruction(2);
8513 InvalidInstruction(2);
8518 InvalidInstruction(2);
8523 sdwCyclesRemaining -= 9;
8524 cpu.z80A |= cpu.z80XH;
8525 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8526 cpu.z80F |= bPostORFlags[cpu.z80A];
8528 InvalidInstruction(2);
8533 sdwCyclesRemaining -= 9;
8534 cpu.z80A |= cpu.z80XL;
8535 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8536 cpu.z80F |= bPostORFlags[cpu.z80A];
8538 InvalidInstruction(2);
8543 sdwCyclesRemaining -= 19;
8544 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8545 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8546 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8547 while (psMemRead->lowAddr != 0xffffffff)
8549 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8551 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8552 if (psMemRead->memoryCall)
8554 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8558 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8568 bTemp = cpu.z80Base[dwAddr];
8572 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8573 cpu.z80F |= bPostORFlags[cpu.z80A];
8579 InvalidInstruction(2);
8584 InvalidInstruction(2);
8589 InvalidInstruction(2);
8594 InvalidInstruction(2);
8599 InvalidInstruction(2);
8604 sdwCyclesRemaining -= 9;
8605 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8606 cpu.z80F |= bPostORFlags[cpu.z80A];
8608 InvalidInstruction(2);
8613 sdwCyclesRemaining -= 9;
8614 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
8615 cpu.z80F |= bPostORFlags[cpu.z80A];
8617 InvalidInstruction(2);
8622 sdwCyclesRemaining -= 19;
8623 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
8624 dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
8625 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8626 while (psMemRead->lowAddr != 0xffffffff)
8628 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
8630 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8631 if (psMemRead->memoryCall)
8633 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
8637 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
8647 bTemp = cpu.z80Base[dwAddr];
8650 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
8651 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
8652 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
8657 InvalidInstruction(2);
8662 InvalidInstruction(2);
8667 InvalidInstruction(2);
8672 InvalidInstruction(2);
8677 InvalidInstruction(2);
8682 InvalidInstruction(2);
8687 InvalidInstruction(2);
8692 InvalidInstruction(2);
8697 InvalidInstruction(2);
8702 InvalidInstruction(2);
8707 InvalidInstruction(2);
8712 InvalidInstruction(2);
8722 InvalidInstruction(2);
8727 InvalidInstruction(2);
8732 InvalidInstruction(2);
8737 InvalidInstruction(2);
8742 InvalidInstruction(2);
8747 InvalidInstruction(2);
8752 InvalidInstruction(2);
8757 InvalidInstruction(2);
8762 InvalidInstruction(2);
8767 InvalidInstruction(2);
8772 InvalidInstruction(2);
8777 InvalidInstruction(2);
8782 InvalidInstruction(2);
8787 InvalidInstruction(2);
8792 InvalidInstruction(2);
8797 InvalidInstruction(2);
8802 InvalidInstruction(2);
8807 InvalidInstruction(2);
8812 InvalidInstruction(2);
8817 InvalidInstruction(2);
8822 InvalidInstruction(2);
8827 sdwCyclesRemaining -= 14;
8828 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8829 while (psMemRead->lowAddr != 0xffffffff)
8831 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
8833 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8834 if (psMemRead->memoryCall)
8836 cpu.z80IX = psMemRead->memoryCall(cpu.z80sp, psMemRead);
8837 cpu.z80IX |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
8841 cpu.z80IX = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
8842 cpu.z80IX |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
8852 cpu.z80IX = cpu.z80Base[cpu.z80sp];
8853 cpu.z80IX |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
8857 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
8862 InvalidInstruction(2);
8867 sdwCyclesRemaining -= 23;
8868 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
8869 while (psMemRead->lowAddr != 0xffffffff)
8871 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
8873 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8874 if (psMemRead->memoryCall)
8876 dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead);
8877 dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
8881 dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
8882 dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
8892 dwAddr = cpu.z80Base[cpu.z80sp];
8893 dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
8896 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
8897 while (psMemWrite->lowAddr != 0xffffffff)
8899 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
8901 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8902 if (psMemWrite->memoryCall)
8904 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IX & 0xff), psMemWrite);
8905 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IX >> 8), psMemWrite);
8909 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IX;
8910 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8;
8920 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IX;
8921 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8);
8929 InvalidInstruction(2);
8934 sdwCyclesRemaining -= 15;
8936 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
8937 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
8938 while (psMemWrite->lowAddr != 0xffffffff)
8940 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
8942 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
8943 if (psMemWrite->memoryCall)
8945 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IX & 0xff), psMemWrite);
8946 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IX >> 8), psMemWrite);
8950 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IX;
8951 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8;
8961 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IX;
8962 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8);
8969 InvalidInstruction(2);
8974 InvalidInstruction(2);
8979 InvalidInstruction(2);
8984 sdwCyclesRemaining -= 8;
8985 pbPC = cpu.z80Base + cpu.z80IX;
8990 InvalidInstruction(2);
8995 InvalidInstruction(2);
9000 InvalidInstruction(2);
9005 InvalidInstruction(2);
9010 InvalidInstruction(2);
9015 InvalidInstruction(2);
9020 InvalidInstruction(2);
9025 InvalidInstruction(2);
9030 InvalidInstruction(2);
9035 InvalidInstruction(2);
9040 InvalidInstruction(2);
9045 InvalidInstruction(2);
9050 InvalidInstruction(2);
9055 InvalidInstruction(2);
9060 InvalidInstruction(2);
9065 sdwCyclesRemaining -= 10;
9066 cpu.z80sp = cpu.z80IX;
9071 InvalidInstruction(2);
9076 InvalidInstruction(2);
9081 InvalidInstruction(2);
9086 InvalidInstruction(2);
9091 InvalidInstruction(2);
9096 InvalidInstruction(2);
9101 void DDFDCBHandler(UINT32 dwWhich)
9105 dwAddr = (UINT32) ((INT32) cpu.z80IY + ((INT32) *pbPC++)) & 0xffff;
9109 dwAddr = (UINT32) ((INT32) cpu.z80IX + ((INT32) *pbPC++)) & 0xffff;
9112 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
9113 while (psMemRead->lowAddr != 0xffffffff)
9115 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
9117 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9118 if (psMemRead->memoryCall)
9120 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
9124 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
9134 bTemp = cpu.z80Base[dwAddr];
9141 InvalidInstruction(4);
9146 InvalidInstruction(4);
9151 InvalidInstruction(4);
9156 InvalidInstruction(4);
9161 InvalidInstruction(4);
9166 InvalidInstruction(4);
9171 sdwCyclesRemaining -= 23;
9172 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9173 bTemp2 = (bTemp >> 7);
9174 bTemp = (bTemp << 1) | bTemp2;
9175 cpu.z80F |= bTemp2 | bPostORFlags[bTemp];
9176 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9177 while (psMemWrite->lowAddr != 0xffffffff)
9179 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9181 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9182 if (psMemWrite->memoryCall)
9184 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9188 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9198 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9205 InvalidInstruction(4);
9210 InvalidInstruction(4);
9215 InvalidInstruction(4);
9220 InvalidInstruction(4);
9225 InvalidInstruction(4);
9230 InvalidInstruction(4);
9235 InvalidInstruction(4);
9240 sdwCyclesRemaining -= 23;
9241 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9242 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
9243 bTemp = (bTemp >> 1) | (bTemp << 7);
9244 cpu.z80F |= bPostORFlags[bTemp];
9245 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9246 while (psMemWrite->lowAddr != 0xffffffff)
9248 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9250 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9251 if (psMemWrite->memoryCall)
9253 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9257 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9267 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9274 InvalidInstruction(4);
9279 InvalidInstruction(4);
9284 InvalidInstruction(4);
9289 InvalidInstruction(4);
9294 InvalidInstruction(4);
9299 InvalidInstruction(4);
9304 InvalidInstruction(4);
9309 sdwCyclesRemaining -= 23;
9310 bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
9311 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9312 cpu.z80F |= (bTemp >> 7);
9313 bTemp = (bTemp << 1) | bTemp2;
9314 cpu.z80F |= bPostORFlags[bTemp];
9315 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9316 while (psMemWrite->lowAddr != 0xffffffff)
9318 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9320 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9321 if (psMemWrite->memoryCall)
9323 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9327 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9337 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9344 InvalidInstruction(4);
9349 InvalidInstruction(4);
9354 InvalidInstruction(4);
9359 InvalidInstruction(4);
9364 InvalidInstruction(4);
9369 InvalidInstruction(4);
9374 InvalidInstruction(4);
9379 sdwCyclesRemaining -= 23;
9380 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
9381 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9382 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
9383 bTemp = (bTemp >> 1) | bTemp2;
9384 cpu.z80F |= bPostORFlags[bTemp];
9385 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9386 while (psMemWrite->lowAddr != 0xffffffff)
9388 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9390 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9391 if (psMemWrite->memoryCall)
9393 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9397 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9407 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9414 InvalidInstruction(4);
9419 InvalidInstruction(4);
9424 InvalidInstruction(4);
9429 InvalidInstruction(4);
9434 InvalidInstruction(4);
9439 InvalidInstruction(4);
9444 InvalidInstruction(4);
9449 sdwCyclesRemaining -= 23;
9450 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9451 cpu.z80F |= (bTemp >> 7);
9452 bTemp = (bTemp << 1);
9453 cpu.z80F |= bPostORFlags[bTemp];
9454 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9455 while (psMemWrite->lowAddr != 0xffffffff)
9457 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9459 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9460 if (psMemWrite->memoryCall)
9462 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9466 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9476 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9483 InvalidInstruction(4);
9488 InvalidInstruction(4);
9493 InvalidInstruction(4);
9498 InvalidInstruction(4);
9503 InvalidInstruction(4);
9508 InvalidInstruction(4);
9513 InvalidInstruction(4);
9518 sdwCyclesRemaining -= 23;
9519 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9520 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
9521 bTemp = (bTemp >> 1) | (bTemp & 0x80);
9522 cpu.z80F |= bPostORFlags[bTemp];
9523 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9524 while (psMemWrite->lowAddr != 0xffffffff)
9526 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9528 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9529 if (psMemWrite->memoryCall)
9531 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9535 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9545 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9552 InvalidInstruction(4);
9557 InvalidInstruction(4);
9562 InvalidInstruction(4);
9567 InvalidInstruction(4);
9572 InvalidInstruction(4);
9577 InvalidInstruction(4);
9582 InvalidInstruction(4);
9587 sdwCyclesRemaining -= 23;
9588 InvalidInstruction(4);
9593 InvalidInstruction(4);
9598 InvalidInstruction(4);
9603 InvalidInstruction(4);
9608 InvalidInstruction(4);
9613 InvalidInstruction(4);
9618 InvalidInstruction(4);
9623 InvalidInstruction(4);
9628 sdwCyclesRemaining -= 23;
9629 cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
9630 cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
9631 bTemp = (bTemp >> 1);
9632 cpu.z80F |= bPostORFlags[bTemp];
9633 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
9634 while (psMemWrite->lowAddr != 0xffffffff)
9636 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
9638 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
9639 if (psMemWrite->memoryCall)
9641 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
9645 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
9655 cpu.z80Base[dwAddr] = (UINT8) bTemp;
9662 InvalidInstruction(4);
9667 sdwCyclesRemaining -= 20;
9668 InvalidInstruction(4);
9673 sdwCyclesRemaining -= 20;
9674 InvalidInstruction(4);
9679 sdwCyclesRemaining -= 20;
9680 InvalidInstruction(4);
9685 sdwCyclesRemaining -= 20;
9686 InvalidInstruction(4);
9691 sdwCyclesRemaining -= 20;
9692 InvalidInstruction(4);
9697 sdwCyclesRemaining -= 20;
9698 InvalidInstruction(4);
9703 sdwCyclesRemaining -= 20;
9704 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
9705 if (!(bTemp & 0x01))
9707 cpu.z80F |= Z80_FLAG_ZERO;
9713 sdwCyclesRemaining -= 20;
9714 InvalidInstruction(4);
9719 sdwCyclesRemaining -= 20;
9720 InvalidInstruction(4);
9725 sdwCyclesRemaining -= 20;
9726 InvalidInstruction(4);
9731 sdwCyclesRemaining -= 20;
9732 InvalidInstruction(4);
9737 sdwCyclesRemaining -= 20;
9738 InvalidInstruction(4);
9743 sdwCyclesRemaining -= 20;
9744 InvalidInstruction(4);
9749 sdwCyclesRemaining -= 20;
9750 InvalidInstruction(4);
9755 sdwCyclesRemaining -= 20;
9756 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
9757 if (!(bTemp & 0x02))
9759 cpu.z80F |= Z80_FLAG_ZERO;
9765 sdwCyclesRemaining -= 20;
9766 InvalidInstruction(4);
9771 sdwCyclesRemaining -= 20;
9772 InvalidInstruction(4);
9777 sdwCyclesRemaining -= 20;
9778 InvalidInstruction(4);
9783 sdwCyclesRemaining -= 20;
9784 InvalidInstruction(4);
9789 sdwCyclesRemaining -= 20;
9790 InvalidInstruction(4);
9795 sdwCyclesRemaining -= 20;
9796 InvalidInstruction(4);
9801 sdwCyclesRemaining -= 20;
9802 InvalidInstruction(4);
9807 sdwCyclesRemaining -= 20;
9808 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
9809 if (!(bTemp & 0x04))
9811 cpu.z80F |= Z80_FLAG_ZERO;
9817 sdwCyclesRemaining -= 20;
9818 InvalidInstruction(4);
9823 sdwCyclesRemaining -= 20;
9824 InvalidInstruction(4);
9829 sdwCyclesRemaining -= 20;
9830 InvalidInstruction(4);
9835 sdwCyclesRemaining -= 20;
9836 InvalidInstruction(4);
9841 sdwCyclesRemaining -= 20;
9842 InvalidInstruction(4);
9847 sdwCyclesRemaining -= 20;
9848 InvalidInstruction(4);
9853 sdwCyclesRemaining -= 20;
9854 InvalidInstruction(4);
9859 sdwCyclesRemaining -= 20;
9860 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
9861 if (!(bTemp & 0x08))
9863 cpu.z80F |= Z80_FLAG_ZERO;
9869 sdwCyclesRemaining -= 20;
9870 InvalidInstruction(4);
9875 sdwCyclesRemaining -= 20;
9876 InvalidInstruction(4);
9881 sdwCyclesRemaining -= 20;
9882 InvalidInstruction(4);
9887 sdwCyclesRemaining -= 20;
9888 InvalidInstruction(4);
9893 sdwCyclesRemaining -= 20;
9894 InvalidInstruction(4);
9899 sdwCyclesRemaining -= 20;
9900 InvalidInstruction(4);
9905 sdwCyclesRemaining -= 20;
9906 InvalidInstruction(4);
9911 sdwCyclesRemaining -= 20;
9912 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
9913 if (!(bTemp & 0x10))
9915 cpu.z80F |= Z80_FLAG_ZERO;
9921 sdwCyclesRemaining -= 20;
9922 InvalidInstruction(4);
9927 sdwCyclesRemaining -= 20;
9928 InvalidInstruction(4);
9933 sdwCyclesRemaining -= 20;
9934 InvalidInstruction(4);
9939 sdwCyclesRemaining -= 20;
9940 InvalidInstruction(4);
9945 sdwCyclesRemaining -= 20;
9946 InvalidInstruction(4);
9951 sdwCyclesRemaining -= 20;
9952 InvalidInstruction(4);
9957 sdwCyclesRemaining -= 20;
9958 InvalidInstruction(4);
9963 sdwCyclesRemaining -= 20;
9964 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
9965 if (!(bTemp & 0x20))
9967 cpu.z80F |= Z80_FLAG_ZERO;
9973 sdwCyclesRemaining -= 20;
9974 InvalidInstruction(4);
9979 sdwCyclesRemaining -= 20;
9980 InvalidInstruction(4);
9985 sdwCyclesRemaining -= 20;
9986 InvalidInstruction(4);
9991 sdwCyclesRemaining -= 20;
9992 InvalidInstruction(4);
9997 sdwCyclesRemaining -= 20;
9998 InvalidInstruction(4);
10003 sdwCyclesRemaining -= 20;
10004 InvalidInstruction(4);
10009 sdwCyclesRemaining -= 20;
10010 InvalidInstruction(4);
10015 sdwCyclesRemaining -= 20;
10016 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
10017 if (!(bTemp & 0x40))
10019 cpu.z80F |= Z80_FLAG_ZERO;
10025 sdwCyclesRemaining -= 20;
10026 InvalidInstruction(4);
10031 sdwCyclesRemaining -= 20;
10032 InvalidInstruction(4);
10037 sdwCyclesRemaining -= 20;
10038 InvalidInstruction(4);
10043 sdwCyclesRemaining -= 20;
10044 InvalidInstruction(4);
10049 sdwCyclesRemaining -= 20;
10050 InvalidInstruction(4);
10055 sdwCyclesRemaining -= 20;
10056 InvalidInstruction(4);
10061 sdwCyclesRemaining -= 20;
10062 InvalidInstruction(4);
10067 sdwCyclesRemaining -= 20;
10068 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
10069 if (!(bTemp & 0x80))
10071 cpu.z80F |= Z80_FLAG_ZERO;
10077 sdwCyclesRemaining -= 20;
10078 InvalidInstruction(4);
10083 InvalidInstruction(4);
10088 InvalidInstruction(4);
10093 InvalidInstruction(4);
10098 InvalidInstruction(4);
10103 InvalidInstruction(4);
10108 InvalidInstruction(4);
10113 sdwCyclesRemaining -= 23;
10115 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10116 while (psMemWrite->lowAddr != 0xffffffff)
10118 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10120 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10121 if (psMemWrite->memoryCall)
10123 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10127 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10137 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10144 InvalidInstruction(4);
10149 InvalidInstruction(4);
10154 InvalidInstruction(4);
10159 InvalidInstruction(4);
10164 InvalidInstruction(4);
10169 InvalidInstruction(4);
10174 InvalidInstruction(4);
10179 sdwCyclesRemaining -= 23;
10181 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10182 while (psMemWrite->lowAddr != 0xffffffff)
10184 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10186 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10187 if (psMemWrite->memoryCall)
10189 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10193 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10203 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10210 InvalidInstruction(4);
10215 InvalidInstruction(4);
10220 InvalidInstruction(4);
10225 InvalidInstruction(4);
10230 InvalidInstruction(4);
10235 InvalidInstruction(4);
10240 InvalidInstruction(4);
10245 sdwCyclesRemaining -= 23;
10247 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10248 while (psMemWrite->lowAddr != 0xffffffff)
10250 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10252 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10253 if (psMemWrite->memoryCall)
10255 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10259 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10269 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10276 InvalidInstruction(4);
10281 InvalidInstruction(4);
10286 InvalidInstruction(4);
10291 InvalidInstruction(4);
10296 InvalidInstruction(4);
10301 InvalidInstruction(4);
10306 InvalidInstruction(4);
10311 sdwCyclesRemaining -= 23;
10313 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10314 while (psMemWrite->lowAddr != 0xffffffff)
10316 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10318 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10319 if (psMemWrite->memoryCall)
10321 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10325 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10335 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10342 InvalidInstruction(4);
10347 InvalidInstruction(4);
10352 InvalidInstruction(4);
10357 InvalidInstruction(4);
10362 InvalidInstruction(4);
10367 InvalidInstruction(4);
10372 InvalidInstruction(4);
10377 sdwCyclesRemaining -= 23;
10379 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10380 while (psMemWrite->lowAddr != 0xffffffff)
10382 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10384 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10385 if (psMemWrite->memoryCall)
10387 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10391 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10401 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10408 InvalidInstruction(4);
10413 InvalidInstruction(4);
10418 InvalidInstruction(4);
10423 InvalidInstruction(4);
10428 InvalidInstruction(4);
10433 InvalidInstruction(4);
10438 InvalidInstruction(4);
10443 sdwCyclesRemaining -= 23;
10445 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10446 while (psMemWrite->lowAddr != 0xffffffff)
10448 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10450 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10451 if (psMemWrite->memoryCall)
10453 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10457 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10467 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10474 InvalidInstruction(4);
10479 InvalidInstruction(4);
10484 InvalidInstruction(4);
10489 InvalidInstruction(4);
10494 InvalidInstruction(4);
10499 InvalidInstruction(4);
10504 InvalidInstruction(4);
10509 sdwCyclesRemaining -= 23;
10511 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10512 while (psMemWrite->lowAddr != 0xffffffff)
10514 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10516 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10517 if (psMemWrite->memoryCall)
10519 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10523 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10533 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10540 InvalidInstruction(4);
10545 InvalidInstruction(4);
10550 InvalidInstruction(4);
10555 InvalidInstruction(4);
10560 InvalidInstruction(4);
10565 InvalidInstruction(4);
10570 InvalidInstruction(4);
10575 sdwCyclesRemaining -= 23;
10577 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10578 while (psMemWrite->lowAddr != 0xffffffff)
10580 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10582 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10583 if (psMemWrite->memoryCall)
10585 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10589 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10599 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10606 InvalidInstruction(4);
10611 InvalidInstruction(4);
10616 InvalidInstruction(4);
10621 InvalidInstruction(4);
10626 InvalidInstruction(4);
10631 InvalidInstruction(4);
10636 InvalidInstruction(4);
10641 sdwCyclesRemaining -= 23;
10643 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10644 while (psMemWrite->lowAddr != 0xffffffff)
10646 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10648 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10649 if (psMemWrite->memoryCall)
10651 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10655 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10665 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10672 InvalidInstruction(4);
10677 InvalidInstruction(4);
10682 InvalidInstruction(4);
10687 InvalidInstruction(4);
10692 InvalidInstruction(4);
10697 InvalidInstruction(4);
10702 InvalidInstruction(4);
10707 sdwCyclesRemaining -= 23;
10709 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10710 while (psMemWrite->lowAddr != 0xffffffff)
10712 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10714 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10715 if (psMemWrite->memoryCall)
10717 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10721 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10731 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10738 InvalidInstruction(4);
10743 InvalidInstruction(4);
10748 InvalidInstruction(4);
10753 InvalidInstruction(4);
10758 InvalidInstruction(4);
10763 InvalidInstruction(4);
10768 InvalidInstruction(4);
10773 sdwCyclesRemaining -= 23;
10775 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10776 while (psMemWrite->lowAddr != 0xffffffff)
10778 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10780 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10781 if (psMemWrite->memoryCall)
10783 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10787 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10797 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10804 InvalidInstruction(4);
10809 InvalidInstruction(4);
10814 InvalidInstruction(4);
10819 InvalidInstruction(4);
10824 InvalidInstruction(4);
10829 InvalidInstruction(4);
10834 InvalidInstruction(4);
10839 sdwCyclesRemaining -= 23;
10841 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10842 while (psMemWrite->lowAddr != 0xffffffff)
10844 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10846 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10847 if (psMemWrite->memoryCall)
10849 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10853 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10863 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10870 InvalidInstruction(4);
10875 InvalidInstruction(4);
10880 InvalidInstruction(4);
10885 InvalidInstruction(4);
10890 InvalidInstruction(4);
10895 InvalidInstruction(4);
10900 InvalidInstruction(4);
10905 sdwCyclesRemaining -= 23;
10907 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10908 while (psMemWrite->lowAddr != 0xffffffff)
10910 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10912 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10913 if (psMemWrite->memoryCall)
10915 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10919 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10929 cpu.z80Base[dwAddr] = (UINT8) bTemp;
10936 InvalidInstruction(4);
10941 InvalidInstruction(4);
10946 InvalidInstruction(4);
10951 InvalidInstruction(4);
10956 InvalidInstruction(4);
10961 InvalidInstruction(4);
10966 InvalidInstruction(4);
10971 sdwCyclesRemaining -= 23;
10973 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
10974 while (psMemWrite->lowAddr != 0xffffffff)
10976 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
10978 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
10979 if (psMemWrite->memoryCall)
10981 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
10985 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
10995 cpu.z80Base[dwAddr] = (UINT8) bTemp;
11002 InvalidInstruction(4);
11007 InvalidInstruction(4);
11012 InvalidInstruction(4);
11017 InvalidInstruction(4);
11022 InvalidInstruction(4);
11027 InvalidInstruction(4);
11032 InvalidInstruction(4);
11037 sdwCyclesRemaining -= 23;
11039 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
11040 while (psMemWrite->lowAddr != 0xffffffff)
11042 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
11044 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11045 if (psMemWrite->memoryCall)
11047 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
11051 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
11061 cpu.z80Base[dwAddr] = (UINT8) bTemp;
11068 InvalidInstruction(4);
11073 InvalidInstruction(4);
11078 InvalidInstruction(4);
11083 InvalidInstruction(4);
11088 InvalidInstruction(4);
11093 InvalidInstruction(4);
11098 InvalidInstruction(4);
11103 sdwCyclesRemaining -= 23;
11105 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
11106 while (psMemWrite->lowAddr != 0xffffffff)
11108 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
11110 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11111 if (psMemWrite->memoryCall)
11113 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
11117 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
11127 cpu.z80Base[dwAddr] = (UINT8) bTemp;
11134 InvalidInstruction(4);
11139 void FDHandler(void)
11145 InvalidInstruction(2);
11150 InvalidInstruction(2);
11155 InvalidInstruction(2);
11160 InvalidInstruction(2);
11165 InvalidInstruction(2);
11170 InvalidInstruction(2);
11175 InvalidInstruction(2);
11180 InvalidInstruction(2);
11185 InvalidInstruction(2);
11190 sdwCyclesRemaining -= 15;
11191 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
11192 dwTemp = cpu.z80IY + cpu.z80BC;
11193 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
11194 cpu.z80IY = dwTemp & 0xffff;
11199 InvalidInstruction(2);
11204 InvalidInstruction(2);
11209 InvalidInstruction(2);
11214 InvalidInstruction(2);
11219 InvalidInstruction(2);
11224 InvalidInstruction(2);
11229 InvalidInstruction(2);
11234 InvalidInstruction(2);
11239 InvalidInstruction(2);
11244 InvalidInstruction(2);
11249 InvalidInstruction(2);
11254 InvalidInstruction(2);
11259 InvalidInstruction(2);
11264 InvalidInstruction(2);
11269 InvalidInstruction(2);
11274 sdwCyclesRemaining -= 15;
11275 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
11276 dwTemp = cpu.z80IY + cpu.z80DE;
11277 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
11278 cpu.z80IY = dwTemp & 0xffff;
11283 InvalidInstruction(2);
11288 InvalidInstruction(2);
11293 InvalidInstruction(2);
11298 InvalidInstruction(2);
11303 InvalidInstruction(2);
11308 InvalidInstruction(2);
11313 InvalidInstruction(2);
11318 sdwCyclesRemaining -= 14;
11319 cpu.z80IY = *pbPC++;
11320 cpu.z80IY |= ((UINT32) *pbPC++ << 8);
11325 sdwCyclesRemaining -= 20;
11327 dwAddr |= ((UINT32) *pbPC++ << 8);
11328 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
11329 while (psMemWrite->lowAddr != 0xffffffff)
11331 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
11333 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11334 if (psMemWrite->memoryCall)
11336 psMemWrite->memoryCall(dwAddr, (cpu.z80IY & 0xff), psMemWrite);
11337 psMemWrite->memoryCall(dwAddr + 1, (cpu.z80IY >> 8), psMemWrite);
11341 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = cpu.z80IY;
11342 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8;
11352 cpu.z80Base[dwAddr] = (UINT8) cpu.z80IY;
11353 cpu.z80Base[dwAddr + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8);
11360 sdwCyclesRemaining -= 10;
11362 cpu.z80IY &= 0xffff;
11367 sdwCyclesRemaining -= 9;
11368 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
11369 cpu.z80F |= bPostIncFlags[cpu.z80YH++];
11374 sdwCyclesRemaining -= 9;
11375 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
11376 cpu.z80F |= bPostDecFlags[cpu.z80YH--];
11381 sdwCyclesRemaining -= 9;
11382 cpu.z80YH = *pbPC++;
11387 InvalidInstruction(2);
11392 InvalidInstruction(2);
11397 sdwCyclesRemaining -= 15;
11398 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
11399 dwTemp = cpu.z80IY + cpu.z80IY;
11400 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
11401 cpu.z80IY = dwTemp & 0xffff;
11406 sdwCyclesRemaining -= 20;
11408 dwAddr |= ((UINT32) *pbPC++ << 8);
11409 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11410 while (psMemRead->lowAddr != 0xffffffff)
11412 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
11414 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11415 if (psMemRead->memoryCall)
11417 cpu.z80IY = psMemRead->memoryCall(dwAddr, psMemRead);
11418 cpu.z80IY |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8);
11422 cpu.z80IY = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
11423 cpu.z80IY |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8);
11433 cpu.z80IY = cpu.z80Base[dwAddr];
11434 cpu.z80IY |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8);
11441 sdwCyclesRemaining -= 10;
11443 cpu.z80IY &= 0xffff;
11448 sdwCyclesRemaining -= 9;
11449 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
11450 cpu.z80F |= bPostIncFlags[cpu.z80YL++];
11455 sdwCyclesRemaining -= 9;
11456 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
11457 cpu.z80F |= bPostDecFlags[cpu.z80YL--];
11462 sdwCyclesRemaining -= 9;
11463 cpu.z80YL = *pbPC++;
11468 InvalidInstruction(2);
11473 InvalidInstruction(2);
11478 InvalidInstruction(2);
11483 InvalidInstruction(2);
11488 InvalidInstruction(2);
11493 sdwCyclesRemaining -= 23;
11494 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
11495 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
11496 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11497 while (psMemRead->lowAddr != 0xffffffff)
11499 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
11501 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11502 if (psMemRead->memoryCall)
11504 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
11508 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
11518 bTemp = cpu.z80Base[dwAddr];
11521 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
11522 cpu.z80F |= bPostIncFlags[bTemp++];
11523 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
11524 while (psMemWrite->lowAddr != 0xffffffff)
11526 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
11528 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11529 if (psMemWrite->memoryCall)
11531 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
11535 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
11545 cpu.z80Base[dwAddr] = (UINT8) bTemp;
11552 sdwCyclesRemaining -= 23;
11553 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
11554 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
11555 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11556 while (psMemRead->lowAddr != 0xffffffff)
11558 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
11560 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11561 if (psMemRead->memoryCall)
11563 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
11567 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
11577 bTemp = cpu.z80Base[dwAddr];
11580 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
11581 cpu.z80F |= bPostDecFlags[bTemp--];
11582 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
11583 while (psMemWrite->lowAddr != 0xffffffff)
11585 if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
11587 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11588 if (psMemWrite->memoryCall)
11590 psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
11594 *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
11604 cpu.z80Base[dwAddr] = (UINT8) bTemp;
11611 sdwCyclesRemaining -= 19;
11612 sdwAddr = (INT8) *pbPC++; // Get the offset
11613 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
11614 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
11615 while (psMemWrite->lowAddr != 0xffffffff)
11617 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
11619 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11620 if (psMemWrite->memoryCall)
11622 psMemWrite->memoryCall(sdwAddr, *pbPC++, psMemWrite);
11626 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = *pbPC++;
11636 cpu.z80Base[sdwAddr] = (UINT8) *pbPC++;
11643 InvalidInstruction(2);
11648 InvalidInstruction(2);
11653 sdwCyclesRemaining -= 15;
11654 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
11655 dwTemp = cpu.z80IY + cpu.z80sp;
11656 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
11657 cpu.z80IY = dwTemp & 0xffff;
11662 InvalidInstruction(2);
11667 InvalidInstruction(2);
11672 InvalidInstruction(2);
11677 InvalidInstruction(2);
11682 InvalidInstruction(2);
11687 InvalidInstruction(2);
11692 InvalidInstruction(2);
11697 InvalidInstruction(2);
11702 InvalidInstruction(2);
11707 InvalidInstruction(2);
11712 sdwCyclesRemaining -= 9;
11713 cpu.z80B = cpu.z80YH;
11718 sdwCyclesRemaining -= 9;
11719 cpu.z80B = cpu.z80YL;
11724 sdwCyclesRemaining -= 19;
11725 sdwAddr = (INT8) *pbPC++; // Get the offset
11726 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
11727 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11728 while (psMemRead->lowAddr != 0xffffffff)
11730 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
11732 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11733 if (psMemRead->memoryCall)
11735 cpu.z80B = psMemRead->memoryCall(sdwAddr, psMemRead);
11739 cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
11749 cpu.z80B = cpu.z80Base[sdwAddr];
11756 InvalidInstruction(2);
11761 InvalidInstruction(2);
11766 InvalidInstruction(2);
11771 InvalidInstruction(2);
11776 InvalidInstruction(2);
11781 sdwCyclesRemaining -= 9;
11782 cpu.z80C = cpu.z80YH;
11787 sdwCyclesRemaining -= 9;
11788 cpu.z80C = cpu.z80YL;
11793 sdwCyclesRemaining -= 19;
11794 sdwAddr = (INT8) *pbPC++; // Get the offset
11795 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
11796 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11797 while (psMemRead->lowAddr != 0xffffffff)
11799 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
11801 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11802 if (psMemRead->memoryCall)
11804 cpu.z80C = psMemRead->memoryCall(sdwAddr, psMemRead);
11808 cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
11818 cpu.z80C = cpu.z80Base[sdwAddr];
11825 InvalidInstruction(2);
11830 InvalidInstruction(2);
11835 InvalidInstruction(2);
11840 InvalidInstruction(2);
11845 InvalidInstruction(2);
11850 sdwCyclesRemaining -= 9;
11851 cpu.z80D = cpu.z80YH;
11856 sdwCyclesRemaining -= 9;
11857 cpu.z80D = cpu.z80YL;
11862 sdwCyclesRemaining -= 19;
11863 sdwAddr = (INT8) *pbPC++; // Get the offset
11864 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
11865 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11866 while (psMemRead->lowAddr != 0xffffffff)
11868 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
11870 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11871 if (psMemRead->memoryCall)
11873 cpu.z80D = psMemRead->memoryCall(sdwAddr, psMemRead);
11877 cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
11887 cpu.z80D = cpu.z80Base[sdwAddr];
11894 InvalidInstruction(2);
11899 InvalidInstruction(2);
11904 InvalidInstruction(2);
11909 InvalidInstruction(2);
11914 InvalidInstruction(2);
11919 sdwCyclesRemaining -= 9;
11920 cpu.z80E = cpu.z80YH;
11925 sdwCyclesRemaining -= 9;
11926 cpu.z80E = cpu.z80YL;
11931 sdwCyclesRemaining -= 19;
11932 sdwAddr = (INT8) *pbPC++; // Get the offset
11933 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
11934 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
11935 while (psMemRead->lowAddr != 0xffffffff)
11937 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
11939 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
11940 if (psMemRead->memoryCall)
11942 cpu.z80E = psMemRead->memoryCall(sdwAddr, psMemRead);
11946 cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
11956 cpu.z80E = cpu.z80Base[sdwAddr];
11963 InvalidInstruction(2);
11968 sdwCyclesRemaining -= 9;
11969 cpu.z80YH = cpu.z80B;
11974 sdwCyclesRemaining -= 9;
11975 cpu.z80YH = cpu.z80C;
11980 sdwCyclesRemaining -= 9;
11981 cpu.z80YH = cpu.z80D;
11986 sdwCyclesRemaining -= 9;
11987 cpu.z80YH = cpu.z80E;
11992 sdwCyclesRemaining -= 9;
11997 sdwCyclesRemaining -= 9;
11998 cpu.z80YH = cpu.z80YL;
12003 sdwCyclesRemaining -= 19;
12004 sdwAddr = (INT8) *pbPC++; // Get the offset
12005 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12006 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12007 while (psMemRead->lowAddr != 0xffffffff)
12009 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
12011 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12012 if (psMemRead->memoryCall)
12014 cpu.z80H = psMemRead->memoryCall(sdwAddr, psMemRead);
12018 cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
12028 cpu.z80H = cpu.z80Base[sdwAddr];
12035 sdwCyclesRemaining -= 9;
12036 cpu.z80YH = cpu.z80A;
12041 sdwCyclesRemaining -= 9;
12042 cpu.z80YL = cpu.z80B;
12047 sdwCyclesRemaining -= 9;
12048 cpu.z80YL = cpu.z80C;
12053 sdwCyclesRemaining -= 9;
12054 cpu.z80YL = cpu.z80D;
12059 sdwCyclesRemaining -= 9;
12060 cpu.z80YL = cpu.z80E;
12065 sdwCyclesRemaining -= 9;
12066 cpu.z80YL = cpu.z80YH;
12071 sdwCyclesRemaining -= 9;
12076 sdwCyclesRemaining -= 19;
12077 sdwAddr = (INT8) *pbPC++; // Get the offset
12078 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12079 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12080 while (psMemRead->lowAddr != 0xffffffff)
12082 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
12084 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12085 if (psMemRead->memoryCall)
12087 cpu.z80L = psMemRead->memoryCall(sdwAddr, psMemRead);
12091 cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
12101 cpu.z80L = cpu.z80Base[sdwAddr];
12108 sdwCyclesRemaining -= 9;
12109 cpu.z80YL = cpu.z80A;
12114 sdwCyclesRemaining -= 19;
12115 sdwAddr = (INT8) *pbPC++; // Get the offset
12116 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12117 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12118 while (psMemWrite->lowAddr != 0xffffffff)
12120 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12122 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12123 if (psMemWrite->memoryCall)
12125 psMemWrite->memoryCall(sdwAddr, cpu.z80B, psMemWrite);
12129 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80B;
12139 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80B;
12146 sdwCyclesRemaining -= 19;
12147 sdwAddr = (INT8) *pbPC++; // Get the offset
12148 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12149 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12150 while (psMemWrite->lowAddr != 0xffffffff)
12152 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12154 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12155 if (psMemWrite->memoryCall)
12157 psMemWrite->memoryCall(sdwAddr, cpu.z80C, psMemWrite);
12161 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80C;
12171 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80C;
12178 sdwCyclesRemaining -= 19;
12179 sdwAddr = (INT8) *pbPC++; // Get the offset
12180 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12181 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12182 while (psMemWrite->lowAddr != 0xffffffff)
12184 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12186 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12187 if (psMemWrite->memoryCall)
12189 psMemWrite->memoryCall(sdwAddr, cpu.z80D, psMemWrite);
12193 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80D;
12203 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80D;
12210 sdwCyclesRemaining -= 19;
12211 sdwAddr = (INT8) *pbPC++; // Get the offset
12212 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12213 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12214 while (psMemWrite->lowAddr != 0xffffffff)
12216 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12218 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12219 if (psMemWrite->memoryCall)
12221 psMemWrite->memoryCall(sdwAddr, cpu.z80E, psMemWrite);
12225 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80E;
12235 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80E;
12242 sdwCyclesRemaining -= 19;
12243 sdwAddr = (INT8) *pbPC++; // Get the offset
12244 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12245 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12246 while (psMemWrite->lowAddr != 0xffffffff)
12248 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12250 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12251 if (psMemWrite->memoryCall)
12253 psMemWrite->memoryCall(sdwAddr, cpu.z80H, psMemWrite);
12257 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80H;
12267 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80H;
12274 sdwCyclesRemaining -= 19;
12275 sdwAddr = (INT8) *pbPC++; // Get the offset
12276 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12277 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12278 while (psMemWrite->lowAddr != 0xffffffff)
12280 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12282 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12283 if (psMemWrite->memoryCall)
12285 psMemWrite->memoryCall(sdwAddr, cpu.z80L, psMemWrite);
12289 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80L;
12299 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80L;
12306 sdwCyclesRemaining -= 19;
12307 InvalidInstruction(2);
12312 sdwCyclesRemaining -= 19;
12313 sdwAddr = (INT8) *pbPC++; // Get the offset
12314 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12315 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
12316 while (psMemWrite->lowAddr != 0xffffffff)
12318 if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
12320 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12321 if (psMemWrite->memoryCall)
12323 psMemWrite->memoryCall(sdwAddr, cpu.z80A, psMemWrite);
12327 *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80A;
12337 cpu.z80Base[sdwAddr] = (UINT8) cpu.z80A;
12344 InvalidInstruction(2);
12349 InvalidInstruction(2);
12354 InvalidInstruction(2);
12359 InvalidInstruction(2);
12364 sdwCyclesRemaining -= 9;
12365 cpu.z80A = cpu.z80YH;
12370 sdwCyclesRemaining -= 9;
12371 cpu.z80A = cpu.z80YL;
12376 sdwCyclesRemaining -= 19;
12377 sdwAddr = (INT8) *pbPC++; // Get the offset
12378 sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
12379 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12380 while (psMemRead->lowAddr != 0xffffffff)
12382 if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
12384 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12385 if (psMemRead->memoryCall)
12387 cpu.z80A = psMemRead->memoryCall(sdwAddr, psMemRead);
12391 cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
12401 cpu.z80A = cpu.z80Base[sdwAddr];
12408 InvalidInstruction(2);
12413 InvalidInstruction(2);
12418 InvalidInstruction(2);
12423 InvalidInstruction(2);
12428 InvalidInstruction(2);
12433 sdwCyclesRemaining -= 9;
12434 bTemp2 = cpu.z80A + cpu.z80YH;
12435 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12436 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12437 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH];
12438 InvalidInstruction(2);
12443 sdwCyclesRemaining -= 9;
12444 bTemp2 = cpu.z80A + cpu.z80YL;
12445 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12446 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12447 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL];
12448 InvalidInstruction(2);
12453 sdwCyclesRemaining -= 19;
12454 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12455 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12456 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12457 while (psMemRead->lowAddr != 0xffffffff)
12459 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12461 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12462 if (psMemRead->memoryCall)
12464 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12468 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12478 bTemp = cpu.z80Base[dwAddr];
12481 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12482 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12483 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
12489 InvalidInstruction(2);
12494 InvalidInstruction(2);
12499 InvalidInstruction(2);
12504 InvalidInstruction(2);
12509 InvalidInstruction(2);
12514 sdwCyclesRemaining -= 9;
12515 bTemp2 = cpu.z80A + cpu.z80YH + (cpu.z80F & Z80_FLAG_CARRY);
12516 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12517 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12518 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
12519 InvalidInstruction(2);
12524 sdwCyclesRemaining -= 9;
12525 bTemp2 = cpu.z80A + cpu.z80YL + (cpu.z80F & Z80_FLAG_CARRY);
12526 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12527 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12528 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
12529 InvalidInstruction(2);
12534 sdwCyclesRemaining -= 19;
12535 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12536 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12537 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12538 while (psMemRead->lowAddr != 0xffffffff)
12540 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12542 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12543 if (psMemRead->memoryCall)
12545 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12549 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12559 bTemp = cpu.z80Base[dwAddr];
12562 bTemp2 = (cpu.z80F & Z80_FLAG_CARRY);
12563 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12564 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12565 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
12566 cpu.z80A += bTemp + bTemp2;
12571 InvalidInstruction(2);
12576 InvalidInstruction(2);
12581 InvalidInstruction(2);
12586 InvalidInstruction(2);
12591 InvalidInstruction(2);
12596 sdwCyclesRemaining -= 9;
12597 bTemp2 = cpu.z80A - cpu.z80YH;
12598 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12599 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12600 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH];
12601 InvalidInstruction(2);
12606 sdwCyclesRemaining -= 9;
12607 bTemp2 = cpu.z80A - cpu.z80YL;
12608 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12609 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12610 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL];
12611 InvalidInstruction(2);
12616 sdwCyclesRemaining -= 19;
12617 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12618 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12619 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12620 while (psMemRead->lowAddr != 0xffffffff)
12622 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12624 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12625 if (psMemRead->memoryCall)
12627 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12631 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12641 bTemp = cpu.z80Base[dwAddr];
12644 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12645 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12646 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
12652 InvalidInstruction(2);
12657 InvalidInstruction(2);
12662 InvalidInstruction(2);
12667 InvalidInstruction(2);
12672 InvalidInstruction(2);
12677 sdwCyclesRemaining -= 9;
12678 bTemp2 = cpu.z80A - cpu.z80YH - (cpu.z80F & Z80_FLAG_CARRY);
12679 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12680 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12681 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
12682 InvalidInstruction(2);
12687 sdwCyclesRemaining -= 9;
12688 bTemp2 = cpu.z80A - cpu.z80YL - (cpu.z80F & Z80_FLAG_CARRY);
12689 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12690 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12691 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
12692 InvalidInstruction(2);
12697 sdwCyclesRemaining -= 19;
12698 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12699 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12700 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12701 while (psMemRead->lowAddr != 0xffffffff)
12703 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12705 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12706 if (psMemRead->memoryCall)
12708 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12712 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12722 bTemp = cpu.z80Base[dwAddr];
12726 cpu.z80A = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY);
12727 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
12728 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
12729 pbSubSbcTable[((UINT32) bTemp2 << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
12734 InvalidInstruction(2);
12739 InvalidInstruction(2);
12744 InvalidInstruction(2);
12749 InvalidInstruction(2);
12754 InvalidInstruction(2);
12759 sdwCyclesRemaining -= 9;
12760 cpu.z80A &= cpu.z80YH;
12761 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12762 cpu.z80F |= bPostANDFlags[cpu.z80A];
12764 InvalidInstruction(2);
12769 sdwCyclesRemaining -= 9;
12770 cpu.z80A &= cpu.z80YL;
12771 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12772 cpu.z80F |= bPostANDFlags[cpu.z80A];
12774 InvalidInstruction(2);
12779 sdwCyclesRemaining -= 19;
12780 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12781 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12782 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12783 while (psMemRead->lowAddr != 0xffffffff)
12785 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12787 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12788 if (psMemRead->memoryCall)
12790 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12794 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12804 bTemp = cpu.z80Base[dwAddr];
12808 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12809 cpu.z80F |= bPostANDFlags[cpu.z80A];
12815 InvalidInstruction(2);
12820 InvalidInstruction(2);
12825 InvalidInstruction(2);
12830 InvalidInstruction(2);
12835 InvalidInstruction(2);
12840 sdwCyclesRemaining -= 9;
12841 cpu.z80A ^= cpu.z80YH;
12842 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12843 cpu.z80F |= bPostORFlags[cpu.z80A];
12845 InvalidInstruction(2);
12850 sdwCyclesRemaining -= 9;
12851 cpu.z80A ^= cpu.z80YL;
12852 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12853 cpu.z80F |= bPostORFlags[cpu.z80A];
12855 InvalidInstruction(2);
12860 sdwCyclesRemaining -= 19;
12861 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12862 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12863 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12864 while (psMemRead->lowAddr != 0xffffffff)
12866 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12868 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12869 if (psMemRead->memoryCall)
12871 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12875 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12885 bTemp = cpu.z80Base[dwAddr];
12889 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12890 cpu.z80F |= bPostORFlags[cpu.z80A];
12896 InvalidInstruction(2);
12901 InvalidInstruction(2);
12906 InvalidInstruction(2);
12911 InvalidInstruction(2);
12916 InvalidInstruction(2);
12921 sdwCyclesRemaining -= 9;
12922 cpu.z80A |= cpu.z80YH;
12923 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12924 cpu.z80F |= bPostORFlags[cpu.z80A];
12926 InvalidInstruction(2);
12931 sdwCyclesRemaining -= 9;
12932 cpu.z80A |= cpu.z80YL;
12933 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12934 cpu.z80F |= bPostORFlags[cpu.z80A];
12936 InvalidInstruction(2);
12941 sdwCyclesRemaining -= 19;
12942 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
12943 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
12944 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
12945 while (psMemRead->lowAddr != 0xffffffff)
12947 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
12949 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
12950 if (psMemRead->memoryCall)
12952 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
12956 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
12966 bTemp = cpu.z80Base[dwAddr];
12970 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
12971 cpu.z80F |= bPostORFlags[cpu.z80A];
12977 InvalidInstruction(2);
12982 InvalidInstruction(2);
12987 InvalidInstruction(2);
12992 InvalidInstruction(2);
12997 InvalidInstruction(2);
13002 sdwCyclesRemaining -= 9;
13003 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
13004 cpu.z80F |= bPostORFlags[cpu.z80A];
13006 InvalidInstruction(2);
13011 sdwCyclesRemaining -= 9;
13012 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
13013 cpu.z80F |= bPostORFlags[cpu.z80A];
13015 InvalidInstruction(2);
13020 sdwCyclesRemaining -= 19;
13021 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
13022 dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
13023 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
13024 while (psMemRead->lowAddr != 0xffffffff)
13026 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
13028 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13029 if (psMemRead->memoryCall)
13031 bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
13035 bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
13045 bTemp = cpu.z80Base[dwAddr];
13048 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
13049 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
13050 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
13055 InvalidInstruction(2);
13060 InvalidInstruction(2);
13065 InvalidInstruction(2);
13070 InvalidInstruction(2);
13075 InvalidInstruction(2);
13080 InvalidInstruction(2);
13085 InvalidInstruction(2);
13090 InvalidInstruction(2);
13095 InvalidInstruction(2);
13100 InvalidInstruction(2);
13105 InvalidInstruction(2);
13110 InvalidInstruction(2);
13120 InvalidInstruction(2);
13125 InvalidInstruction(2);
13130 InvalidInstruction(2);
13135 InvalidInstruction(2);
13140 InvalidInstruction(2);
13145 InvalidInstruction(2);
13150 InvalidInstruction(2);
13155 InvalidInstruction(2);
13160 InvalidInstruction(2);
13165 InvalidInstruction(2);
13170 InvalidInstruction(2);
13175 InvalidInstruction(2);
13180 InvalidInstruction(2);
13185 InvalidInstruction(2);
13190 InvalidInstruction(2);
13195 InvalidInstruction(2);
13200 InvalidInstruction(2);
13205 InvalidInstruction(2);
13210 InvalidInstruction(2);
13215 InvalidInstruction(2);
13220 InvalidInstruction(2);
13225 sdwCyclesRemaining -= 14;
13226 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
13227 while (psMemRead->lowAddr != 0xffffffff)
13229 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
13231 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13232 if (psMemRead->memoryCall)
13234 cpu.z80IY = psMemRead->memoryCall(cpu.z80sp, psMemRead);
13235 cpu.z80IY |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
13239 cpu.z80IY = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
13240 cpu.z80IY |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
13250 cpu.z80IY = cpu.z80Base[cpu.z80sp];
13251 cpu.z80IY |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
13255 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
13260 InvalidInstruction(2);
13265 sdwCyclesRemaining -= 23;
13266 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
13267 while (psMemRead->lowAddr != 0xffffffff)
13269 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
13271 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13272 if (psMemRead->memoryCall)
13274 dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead);
13275 dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
13279 dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
13280 dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
13290 dwAddr = cpu.z80Base[cpu.z80sp];
13291 dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
13294 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
13295 while (psMemWrite->lowAddr != 0xffffffff)
13297 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
13299 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13300 if (psMemWrite->memoryCall)
13302 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IY & 0xff), psMemWrite);
13303 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IY >> 8), psMemWrite);
13307 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IY;
13308 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8;
13318 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IY;
13319 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8);
13322 cpu.z80IY = dwAddr;
13327 InvalidInstruction(2);
13332 sdwCyclesRemaining -= 15;
13334 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
13335 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
13336 while (psMemWrite->lowAddr != 0xffffffff)
13338 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
13340 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13341 if (psMemWrite->memoryCall)
13343 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IY & 0xff), psMemWrite);
13344 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IY >> 8), psMemWrite);
13348 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IY;
13349 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8;
13359 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IY;
13360 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8);
13367 InvalidInstruction(2);
13372 InvalidInstruction(2);
13377 InvalidInstruction(2);
13382 sdwCyclesRemaining -= 8;
13383 pbPC = cpu.z80Base + cpu.z80IY;
13388 InvalidInstruction(2);
13393 InvalidInstruction(2);
13398 InvalidInstruction(2);
13403 InvalidInstruction(2);
13408 InvalidInstruction(2);
13413 InvalidInstruction(2);
13418 InvalidInstruction(2);
13423 InvalidInstruction(2);
13428 InvalidInstruction(2);
13433 InvalidInstruction(2);
13438 InvalidInstruction(2);
13443 InvalidInstruction(2);
13448 InvalidInstruction(2);
13453 InvalidInstruction(2);
13458 InvalidInstruction(2);
13463 sdwCyclesRemaining -= 10;
13464 cpu.z80sp = cpu.z80IY;
13469 InvalidInstruction(2);
13474 InvalidInstruction(2);
13479 InvalidInstruction(2);
13484 InvalidInstruction(2);
13489 InvalidInstruction(2);
13494 InvalidInstruction(2);
13499 /* Main execution entry point */
13501 UINT32 mz80exec(UINT32 dwCycles)
13505 dwReturnCode = 0x80000000; /* Assume it'll work */
13506 sdwCyclesRemaining = dwCycles;
13507 dwOriginalCycles = dwCycles;
13510 dwElapsedTicks += dwCycles;
13511 return(0x80000000);
13514 pbPC = cpu.z80Base + cpu.z80pc;
13516 while (sdwCyclesRemaining > 0)
13523 sdwCyclesRemaining -= 4;
13524 /* Intentionally not doing anything - NOP! */
13529 sdwCyclesRemaining -= 10;
13530 cpu.z80BC = *pbPC++; /* LSB First */
13531 cpu.z80BC |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
13536 sdwCyclesRemaining -= 7;
13537 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
13538 while (psMemWrite->lowAddr != 0xffffffff)
13540 if ((cpu.z80BC >= psMemWrite->lowAddr) && (cpu.z80BC <= psMemWrite->highAddr))
13542 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13543 if (psMemWrite->memoryCall)
13545 psMemWrite->memoryCall(cpu.z80BC, cpu.z80A, psMemWrite);
13549 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80BC - psMemWrite->lowAddr)) = cpu.z80A;
13559 cpu.z80Base[cpu.z80BC] = (UINT8) cpu.z80A;
13566 sdwCyclesRemaining -= 6;
13568 cpu.z80BC &= 0xffff;
13573 sdwCyclesRemaining -= 4;
13574 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
13575 cpu.z80F |= bPostIncFlags[cpu.z80B++];
13580 sdwCyclesRemaining -= 4;
13581 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
13582 cpu.z80F |= bPostDecFlags[cpu.z80B--];
13587 sdwCyclesRemaining -= 7;
13588 cpu.z80B = *pbPC++; /* Get immediate byte into register */
13593 sdwCyclesRemaining -= 4;
13594 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
13595 cpu.z80F |= (cpu.z80A >> 7);
13596 cpu.z80A = (cpu.z80A << 1) | (cpu.z80A >> 7);
13601 sdwCyclesRemaining -= 4;
13602 dwAddr = (UINT32) cpu.z80AF;
13603 cpu.z80AF = cpu.z80afprime;
13604 cpu.z80afprime = dwAddr;
13609 sdwCyclesRemaining -= 11;
13610 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
13611 dwTemp = cpu.z80HL + cpu.z80BC;
13612 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
13613 cpu.z80HL = dwTemp & 0xffff;
13618 sdwCyclesRemaining -= 7;
13619 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
13620 while (psMemRead->lowAddr != 0xffffffff)
13622 if ((cpu.z80BC >= psMemRead->lowAddr) && (cpu.z80BC <= psMemRead->highAddr))
13624 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13625 if (psMemRead->memoryCall)
13627 cpu.z80A = psMemRead->memoryCall(cpu.z80BC, psMemRead);
13631 cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80BC - psMemRead->lowAddr));
13641 cpu.z80A = cpu.z80Base[cpu.z80BC];
13648 sdwCyclesRemaining -= 6;
13650 cpu.z80BC &= 0xffff;
13655 sdwCyclesRemaining -= 4;
13656 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
13657 cpu.z80F |= bPostIncFlags[cpu.z80C++];
13662 sdwCyclesRemaining -= 4;
13663 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
13664 cpu.z80F |= bPostDecFlags[cpu.z80C--];
13669 sdwCyclesRemaining -= 7;
13670 cpu.z80C = *pbPC++; /* Get immediate byte into register */
13675 sdwCyclesRemaining -= 4;
13676 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
13677 cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
13678 cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A << 7);
13683 sdwCyclesRemaining -= 8;
13684 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
13687 dwElapsedTicks += 5; /* 5 More for jump taken */
13688 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13689 sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
13690 pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */
13696 sdwCyclesRemaining -= 10;
13697 cpu.z80DE = *pbPC++; /* LSB First */
13698 cpu.z80DE |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
13703 sdwCyclesRemaining -= 7;
13704 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
13705 while (psMemWrite->lowAddr != 0xffffffff)
13707 if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
13709 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13710 if (psMemWrite->memoryCall)
13712 psMemWrite->memoryCall(cpu.z80DE, cpu.z80A, psMemWrite);
13716 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = cpu.z80A;
13726 cpu.z80Base[cpu.z80DE] = (UINT8) cpu.z80A;
13733 sdwCyclesRemaining -= 6;
13735 cpu.z80DE &= 0xffff;
13740 sdwCyclesRemaining -= 4;
13741 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
13742 cpu.z80F |= bPostIncFlags[cpu.z80D++];
13747 sdwCyclesRemaining -= 4;
13748 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
13749 cpu.z80F |= bPostDecFlags[cpu.z80D--];
13754 sdwCyclesRemaining -= 7;
13755 cpu.z80D = *pbPC++; /* Get immediate byte into register */
13760 sdwCyclesRemaining -= 4;
13761 bTemp = cpu.z80A >> 7;
13762 cpu.z80A = (cpu.z80A << 1) | (cpu.z80F & Z80_FLAG_CARRY);
13763 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY)) | bTemp;
13768 sdwCyclesRemaining -= 12;
13769 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
13770 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13771 sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
13773 sdwCyclesRemaining -= 5;
13774 pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */
13780 sdwCyclesRemaining -= 11;
13781 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
13782 dwTemp = cpu.z80HL + cpu.z80DE;
13783 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
13784 cpu.z80HL = dwTemp & 0xffff;
13789 sdwCyclesRemaining -= 7;
13790 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
13791 while (psMemRead->lowAddr != 0xffffffff)
13793 if ((cpu.z80DE >= psMemRead->lowAddr) && (cpu.z80DE <= psMemRead->highAddr))
13795 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13796 if (psMemRead->memoryCall)
13798 cpu.z80A = psMemRead->memoryCall(cpu.z80DE, psMemRead);
13802 cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80DE - psMemRead->lowAddr));
13812 cpu.z80A = cpu.z80Base[cpu.z80DE];
13819 sdwCyclesRemaining -= 6;
13821 cpu.z80DE &= 0xffff;
13826 sdwCyclesRemaining -= 4;
13827 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
13828 cpu.z80F |= bPostIncFlags[cpu.z80E++];
13833 sdwCyclesRemaining -= 4;
13834 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
13835 cpu.z80F |= bPostDecFlags[cpu.z80E--];
13840 sdwCyclesRemaining -= 7;
13841 cpu.z80E = *pbPC++; /* Get immediate byte into register */
13846 sdwCyclesRemaining -= 4;
13847 bTemp = (cpu.z80F & Z80_FLAG_CARRY) << 7;
13848 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY)) | (cpu.z80A & Z80_FLAG_CARRY);
13849 cpu.z80A = ((cpu.z80A >> 1) | bTemp);
13854 sdwCyclesRemaining -= 7;
13855 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
13856 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13857 sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
13858 if (!(cpu.z80F & Z80_FLAG_ZERO))
13860 sdwCyclesRemaining -= 5;
13861 pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */
13867 sdwCyclesRemaining -= 10;
13868 cpu.z80HL = *pbPC++; /* LSB First */
13869 cpu.z80HL |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
13874 sdwCyclesRemaining -= 16;
13876 dwTemp |= ((UINT32) *pbPC++ << 8);
13877 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
13878 while (psMemWrite->lowAddr != 0xffffffff)
13880 if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
13882 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13883 if (psMemWrite->memoryCall)
13885 psMemWrite->memoryCall(dwTemp, (cpu.z80HL & 0xff), psMemWrite);
13886 psMemWrite->memoryCall(dwTemp + 1, (cpu.z80HL >> 8), psMemWrite);
13890 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80HL;
13891 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
13901 cpu.z80Base[dwTemp] = (UINT8) cpu.z80HL;
13902 cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
13909 sdwCyclesRemaining -= 6;
13911 cpu.z80HL &= 0xffff;
13916 sdwCyclesRemaining -= 4;
13917 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
13918 cpu.z80F |= bPostIncFlags[cpu.z80H++];
13923 sdwCyclesRemaining -= 4;
13924 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
13925 cpu.z80F |= bPostDecFlags[cpu.z80H--];
13930 sdwCyclesRemaining -= 7;
13931 cpu.z80H = *pbPC++; /* Get immediate byte into register */
13936 sdwCyclesRemaining -= 4;
13937 dwAddr = (((cpu.z80F & Z80_FLAG_CARRY) |
13938 ((cpu.z80F & Z80_FLAG_HALF_CARRY) >> 3) |
13939 ((cpu.z80F & Z80_FLAG_NEGATIVE) << 1)) << 8) | cpu.z80A;
13940 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
13941 cpu.z80F |= (wDAATable[dwAddr] >> 8);
13942 cpu.z80A = wDAATable[dwAddr] & 0xff;
13947 sdwCyclesRemaining -= 7;
13948 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
13949 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13950 sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
13951 if (cpu.z80F & Z80_FLAG_ZERO)
13953 sdwCyclesRemaining -= 5;
13954 pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */
13960 sdwCyclesRemaining -= 11;
13961 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
13962 dwTemp = cpu.z80HL + cpu.z80HL;
13963 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
13964 cpu.z80HL = dwTemp & 0xffff;
13969 sdwCyclesRemaining -= 16;
13971 dwAddr |= ((UINT32) *pbPC++ << 8);
13972 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
13973 while (psMemRead->lowAddr != 0xffffffff)
13975 if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
13977 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
13978 if (psMemRead->memoryCall)
13980 cpu.z80HL = psMemRead->memoryCall(dwAddr, psMemRead);
13981 cpu.z80HL |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8);
13985 cpu.z80HL = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
13986 cpu.z80HL |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8);
13996 cpu.z80HL = cpu.z80Base[dwAddr];
13997 cpu.z80HL |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8);
14004 sdwCyclesRemaining -= 6;
14006 cpu.z80HL &= 0xffff;
14011 sdwCyclesRemaining -= 4;
14012 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
14013 cpu.z80F |= bPostIncFlags[cpu.z80L++];
14018 sdwCyclesRemaining -= 4;
14019 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
14020 cpu.z80F |= bPostDecFlags[cpu.z80L--];
14025 sdwCyclesRemaining -= 7;
14026 cpu.z80L = *pbPC++; /* Get immediate byte into register */
14031 sdwCyclesRemaining -= 4;
14033 cpu.z80F |= (Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
14038 sdwCyclesRemaining -= 7;
14039 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
14040 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14041 sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
14042 if (!(cpu.z80F & Z80_FLAG_CARRY))
14044 sdwCyclesRemaining -= 5;
14045 pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */
14051 sdwCyclesRemaining -= 10;
14052 cpu.z80sp = *pbPC++; /* LSB First */
14053 cpu.z80sp |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
14058 sdwCyclesRemaining -= 13;
14060 dwTemp |= ((UINT32) *pbPC++ << 8);
14061 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14062 while (psMemWrite->lowAddr != 0xffffffff)
14064 if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
14066 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14067 if (psMemWrite->memoryCall)
14069 psMemWrite->memoryCall(dwTemp, cpu.z80A, psMemWrite);
14073 *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80A;
14083 cpu.z80Base[dwTemp] = (UINT8) cpu.z80A;
14090 sdwCyclesRemaining -= 6;
14092 cpu.z80sp &= 0xffff;
14097 sdwCyclesRemaining -= 11;
14098 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14099 while (psMemRead->lowAddr != 0xffffffff)
14101 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14103 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14104 if (psMemRead->memoryCall)
14106 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14110 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14120 bTemp = cpu.z80Base[cpu.z80HL];
14123 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
14124 cpu.z80F |= bPostIncFlags[bTemp];
14126 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14127 while (psMemWrite->lowAddr != 0xffffffff)
14129 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14131 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14132 if (psMemWrite->memoryCall)
14134 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
14138 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
14148 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
14155 sdwCyclesRemaining -= 11;
14156 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14157 while (psMemRead->lowAddr != 0xffffffff)
14159 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14161 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14162 if (psMemRead->memoryCall)
14164 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14168 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14178 bTemp = cpu.z80Base[cpu.z80HL];
14181 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
14182 cpu.z80F |= bPostDecFlags[bTemp];
14184 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14185 while (psMemWrite->lowAddr != 0xffffffff)
14187 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14189 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14190 if (psMemWrite->memoryCall)
14192 psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
14196 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
14206 cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
14213 sdwCyclesRemaining -= 10;
14214 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14215 while (psMemWrite->lowAddr != 0xffffffff)
14217 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14219 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14220 if (psMemWrite->memoryCall)
14222 psMemWrite->memoryCall(cpu.z80HL, *pbPC++, psMemWrite);
14226 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = *pbPC++;
14236 cpu.z80Base[cpu.z80HL] = (UINT8) *pbPC++;
14243 sdwCyclesRemaining -= 4;
14244 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE);
14245 cpu.z80F |= Z80_FLAG_CARRY;
14250 sdwCyclesRemaining -= 7;
14251 sdwAddr = (INT8) *pbPC++; /* Get LSB first */
14252 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14253 sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
14254 if (cpu.z80F & Z80_FLAG_CARRY)
14256 sdwCyclesRemaining -= 5;
14257 pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */
14263 sdwCyclesRemaining -= 11;
14264 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
14265 dwTemp = cpu.z80HL + cpu.z80sp;
14266 cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
14267 cpu.z80HL = dwTemp & 0xffff;
14272 sdwCyclesRemaining -= 13;
14274 dwTemp |= (((UINT32) *pbPC++) << 8);
14275 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14276 while (psMemRead->lowAddr != 0xffffffff)
14278 if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
14280 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14281 if (psMemRead->memoryCall)
14283 cpu.z80A = psMemRead->memoryCall(dwTemp, psMemRead);
14287 cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
14297 cpu.z80A = cpu.z80Base[dwTemp];
14304 sdwCyclesRemaining -= 6;
14306 cpu.z80sp &= 0xffff;
14311 sdwCyclesRemaining -= 4;
14312 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
14313 cpu.z80F |= bPostIncFlags[cpu.z80A++];
14318 sdwCyclesRemaining -= 4;
14319 cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
14320 cpu.z80F |= bPostDecFlags[cpu.z80A--];
14325 sdwCyclesRemaining -= 7;
14326 cpu.z80A = *pbPC++; /* Get immediate byte into register */
14331 sdwCyclesRemaining -= 4;
14332 bTemp = (cpu.z80F & Z80_FLAG_CARRY) << 4;
14333 cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE);
14334 cpu.z80F ^= Z80_FLAG_CARRY;
14339 sdwCyclesRemaining -= 4;
14344 sdwCyclesRemaining -= 4;
14345 cpu.z80B = cpu.z80C;
14350 sdwCyclesRemaining -= 4;
14351 cpu.z80B = cpu.z80D;
14356 sdwCyclesRemaining -= 4;
14357 cpu.z80B = cpu.z80E;
14362 sdwCyclesRemaining -= 4;
14363 cpu.z80B = cpu.z80H;
14368 sdwCyclesRemaining -= 4;
14369 cpu.z80B = cpu.z80L;
14374 sdwCyclesRemaining -= 7;
14375 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14376 while (psMemRead->lowAddr != 0xffffffff)
14378 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14380 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14381 if (psMemRead->memoryCall)
14383 cpu.z80B = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14387 cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14397 cpu.z80B = cpu.z80Base[cpu.z80HL];
14404 sdwCyclesRemaining -= 4;
14405 cpu.z80B = cpu.z80A;
14410 sdwCyclesRemaining -= 4;
14411 cpu.z80C = cpu.z80B;
14416 sdwCyclesRemaining -= 4;
14421 sdwCyclesRemaining -= 4;
14422 cpu.z80C = cpu.z80D;
14427 sdwCyclesRemaining -= 4;
14428 cpu.z80C = cpu.z80E;
14433 sdwCyclesRemaining -= 4;
14434 cpu.z80C = cpu.z80H;
14439 sdwCyclesRemaining -= 4;
14440 cpu.z80C = cpu.z80L;
14445 sdwCyclesRemaining -= 7;
14446 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14447 while (psMemRead->lowAddr != 0xffffffff)
14449 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14451 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14452 if (psMemRead->memoryCall)
14454 cpu.z80C = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14458 cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14468 cpu.z80C = cpu.z80Base[cpu.z80HL];
14475 sdwCyclesRemaining -= 4;
14476 cpu.z80C = cpu.z80A;
14481 sdwCyclesRemaining -= 4;
14482 cpu.z80D = cpu.z80B;
14487 sdwCyclesRemaining -= 4;
14488 cpu.z80D = cpu.z80C;
14493 sdwCyclesRemaining -= 4;
14498 sdwCyclesRemaining -= 4;
14499 cpu.z80D = cpu.z80E;
14504 sdwCyclesRemaining -= 4;
14505 cpu.z80D = cpu.z80H;
14510 sdwCyclesRemaining -= 4;
14511 cpu.z80D = cpu.z80L;
14516 sdwCyclesRemaining -= 7;
14517 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14518 while (psMemRead->lowAddr != 0xffffffff)
14520 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14522 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14523 if (psMemRead->memoryCall)
14525 cpu.z80D = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14529 cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14539 cpu.z80D = cpu.z80Base[cpu.z80HL];
14546 sdwCyclesRemaining -= 4;
14547 cpu.z80D = cpu.z80A;
14552 sdwCyclesRemaining -= 4;
14553 cpu.z80E = cpu.z80B;
14558 sdwCyclesRemaining -= 4;
14559 cpu.z80E = cpu.z80C;
14564 sdwCyclesRemaining -= 4;
14565 cpu.z80E = cpu.z80D;
14570 sdwCyclesRemaining -= 4;
14575 sdwCyclesRemaining -= 4;
14576 cpu.z80E = cpu.z80H;
14581 sdwCyclesRemaining -= 4;
14582 cpu.z80E = cpu.z80L;
14587 sdwCyclesRemaining -= 7;
14588 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14589 while (psMemRead->lowAddr != 0xffffffff)
14591 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14593 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14594 if (psMemRead->memoryCall)
14596 cpu.z80E = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14600 cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14610 cpu.z80E = cpu.z80Base[cpu.z80HL];
14617 sdwCyclesRemaining -= 4;
14618 cpu.z80E = cpu.z80A;
14623 sdwCyclesRemaining -= 4;
14624 cpu.z80H = cpu.z80B;
14629 sdwCyclesRemaining -= 4;
14630 cpu.z80H = cpu.z80C;
14635 sdwCyclesRemaining -= 4;
14636 cpu.z80H = cpu.z80D;
14641 sdwCyclesRemaining -= 4;
14642 cpu.z80H = cpu.z80E;
14647 sdwCyclesRemaining -= 4;
14652 sdwCyclesRemaining -= 4;
14653 cpu.z80H = cpu.z80L;
14658 sdwCyclesRemaining -= 7;
14659 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14660 while (psMemRead->lowAddr != 0xffffffff)
14662 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14664 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14665 if (psMemRead->memoryCall)
14667 cpu.z80H = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14671 cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14681 cpu.z80H = cpu.z80Base[cpu.z80HL];
14688 sdwCyclesRemaining -= 4;
14689 cpu.z80H = cpu.z80A;
14694 sdwCyclesRemaining -= 4;
14695 cpu.z80L = cpu.z80B;
14700 sdwCyclesRemaining -= 4;
14701 cpu.z80L = cpu.z80C;
14706 sdwCyclesRemaining -= 4;
14707 cpu.z80L = cpu.z80D;
14712 sdwCyclesRemaining -= 4;
14713 cpu.z80L = cpu.z80E;
14718 sdwCyclesRemaining -= 4;
14719 cpu.z80L = cpu.z80H;
14724 sdwCyclesRemaining -= 4;
14729 sdwCyclesRemaining -= 7;
14730 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
14731 while (psMemRead->lowAddr != 0xffffffff)
14733 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
14735 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14736 if (psMemRead->memoryCall)
14738 cpu.z80L = psMemRead->memoryCall(cpu.z80HL, psMemRead);
14742 cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
14752 cpu.z80L = cpu.z80Base[cpu.z80HL];
14759 sdwCyclesRemaining -= 4;
14760 cpu.z80L = cpu.z80A;
14765 sdwCyclesRemaining -= 7;
14766 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14767 while (psMemWrite->lowAddr != 0xffffffff)
14769 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14771 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14772 if (psMemWrite->memoryCall)
14774 psMemWrite->memoryCall(cpu.z80HL, cpu.z80B, psMemWrite);
14778 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80B;
14788 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80B;
14795 sdwCyclesRemaining -= 7;
14796 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14797 while (psMemWrite->lowAddr != 0xffffffff)
14799 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14801 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14802 if (psMemWrite->memoryCall)
14804 psMemWrite->memoryCall(cpu.z80HL, cpu.z80C, psMemWrite);
14808 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80C;
14818 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80C;
14825 sdwCyclesRemaining -= 7;
14826 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14827 while (psMemWrite->lowAddr != 0xffffffff)
14829 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14831 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14832 if (psMemWrite->memoryCall)
14834 psMemWrite->memoryCall(cpu.z80HL, cpu.z80D, psMemWrite);
14838 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80D;
14848 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80D;
14855 sdwCyclesRemaining -= 7;
14856 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14857 while (psMemWrite->lowAddr != 0xffffffff)
14859 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14861 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14862 if (psMemWrite->memoryCall)
14864 psMemWrite->memoryCall(cpu.z80HL, cpu.z80E, psMemWrite);
14868 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80E;
14878 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80E;
14885 sdwCyclesRemaining -= 7;
14886 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14887 while (psMemWrite->lowAddr != 0xffffffff)
14889 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14891 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14892 if (psMemWrite->memoryCall)
14894 psMemWrite->memoryCall(cpu.z80HL, cpu.z80H, psMemWrite);
14898 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80H;
14908 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80H;
14915 sdwCyclesRemaining -= 7;
14916 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14917 while (psMemWrite->lowAddr != 0xffffffff)
14919 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14921 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14922 if (psMemWrite->memoryCall)
14924 psMemWrite->memoryCall(cpu.z80HL, cpu.z80L, psMemWrite);
14928 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80L;
14938 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80L;
14945 sdwCyclesRemaining -= 4;
14947 dwElapsedTicks += sdwCyclesRemaining;
14948 sdwCyclesRemaining = 0;
14953 sdwCyclesRemaining -= 7;
14954 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
14955 while (psMemWrite->lowAddr != 0xffffffff)
14957 if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
14959 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
14960 if (psMemWrite->memoryCall)
14962 psMemWrite->memoryCall(cpu.z80HL, cpu.z80A, psMemWrite);
14966 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80A;
14976 cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80A;
14983 sdwCyclesRemaining -= 4;
14984 cpu.z80A = cpu.z80B;
14989 sdwCyclesRemaining -= 4;
14990 cpu.z80A = cpu.z80C;
14995 sdwCyclesRemaining -= 4;
14996 cpu.z80A = cpu.z80D;
15001 sdwCyclesRemaining -= 4;
15002 cpu.z80A = cpu.z80E;
15007 sdwCyclesRemaining -= 4;
15008 cpu.z80A = cpu.z80H;
15013 sdwCyclesRemaining -= 4;
15014 cpu.z80A = cpu.z80L;
15019 sdwCyclesRemaining -= 7;
15020 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15021 while (psMemRead->lowAddr != 0xffffffff)
15023 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15025 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15026 if (psMemRead->memoryCall)
15028 cpu.z80A = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15032 cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15042 cpu.z80A = cpu.z80Base[cpu.z80HL];
15049 sdwCyclesRemaining -= 4;
15054 sdwCyclesRemaining -= 4;
15055 bTemp2 = cpu.z80A + cpu.z80B;
15056 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15057 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15058 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80B];
15064 sdwCyclesRemaining -= 4;
15065 bTemp2 = cpu.z80A + cpu.z80C;
15066 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15067 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15068 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80C];
15074 sdwCyclesRemaining -= 4;
15075 bTemp2 = cpu.z80A + cpu.z80D;
15076 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15077 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15078 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80D];
15084 sdwCyclesRemaining -= 4;
15085 bTemp2 = cpu.z80A + cpu.z80E;
15086 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15087 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15088 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80E];
15094 sdwCyclesRemaining -= 4;
15095 bTemp2 = cpu.z80A + cpu.z80H;
15096 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15097 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15098 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80H];
15104 sdwCyclesRemaining -= 4;
15105 bTemp2 = cpu.z80A + cpu.z80L;
15106 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15107 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15108 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80L];
15114 sdwCyclesRemaining -= 7;
15115 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15116 while (psMemRead->lowAddr != 0xffffffff)
15118 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15120 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15121 if (psMemRead->memoryCall)
15123 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15127 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15137 bTemp = cpu.z80Base[cpu.z80HL];
15140 bTemp2 = cpu.z80A + bTemp;
15141 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15142 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15143 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
15149 sdwCyclesRemaining -= 4;
15150 bTemp2 = cpu.z80A + cpu.z80A;
15151 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15152 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15153 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80A];
15159 sdwCyclesRemaining -= 4;
15160 bTemp2 = cpu.z80A + cpu.z80B + (cpu.z80F & Z80_FLAG_CARRY);
15161 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15162 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15163 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80B | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15169 sdwCyclesRemaining -= 4;
15170 bTemp2 = cpu.z80A + cpu.z80C + (cpu.z80F & Z80_FLAG_CARRY);
15171 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15172 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15173 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80C | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15179 sdwCyclesRemaining -= 4;
15180 bTemp2 = cpu.z80A + cpu.z80D + (cpu.z80F & Z80_FLAG_CARRY);
15181 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15182 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15183 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80D | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15189 sdwCyclesRemaining -= 4;
15190 bTemp2 = cpu.z80A + cpu.z80E + (cpu.z80F & Z80_FLAG_CARRY);
15191 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15192 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15193 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80E | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15199 sdwCyclesRemaining -= 4;
15200 bTemp2 = cpu.z80A + cpu.z80H + (cpu.z80F & Z80_FLAG_CARRY);
15201 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15202 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15203 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80H | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15209 sdwCyclesRemaining -= 4;
15210 bTemp2 = cpu.z80A + cpu.z80L + (cpu.z80F & Z80_FLAG_CARRY);
15211 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15212 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15213 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80L | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15219 sdwCyclesRemaining -= 7;
15220 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15221 while (psMemRead->lowAddr != 0xffffffff)
15223 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15225 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15226 if (psMemRead->memoryCall)
15228 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15232 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15242 bTemp = cpu.z80Base[cpu.z80HL];
15245 bTemp2 = cpu.z80A + bTemp + (cpu.z80F & Z80_FLAG_CARRY);
15246 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15247 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15248 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15254 sdwCyclesRemaining -= 4;
15255 bTemp2 = cpu.z80A + cpu.z80A + (cpu.z80F & Z80_FLAG_CARRY);
15256 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15257 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15258 pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80A | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15264 sdwCyclesRemaining -= 4;
15265 bTemp2 = cpu.z80A - cpu.z80B;
15266 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15267 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15268 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B];
15274 sdwCyclesRemaining -= 4;
15275 bTemp2 = cpu.z80A - cpu.z80C;
15276 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15277 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15278 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C];
15284 sdwCyclesRemaining -= 4;
15285 bTemp2 = cpu.z80A - cpu.z80D;
15286 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15287 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15288 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D];
15294 sdwCyclesRemaining -= 4;
15295 bTemp2 = cpu.z80A - cpu.z80E;
15296 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15297 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15298 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E];
15304 sdwCyclesRemaining -= 4;
15305 bTemp2 = cpu.z80A - cpu.z80H;
15306 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15307 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15308 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H];
15314 sdwCyclesRemaining -= 4;
15315 bTemp2 = cpu.z80A - cpu.z80L;
15316 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15317 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15318 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L];
15324 sdwCyclesRemaining -= 7;
15325 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15326 while (psMemRead->lowAddr != 0xffffffff)
15328 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15330 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15331 if (psMemRead->memoryCall)
15333 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15337 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15347 bTemp = cpu.z80Base[cpu.z80HL];
15350 bTemp2 = cpu.z80A - bTemp;
15351 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15352 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15353 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
15359 sdwCyclesRemaining -= 4;
15360 bTemp2 = cpu.z80A - cpu.z80A;
15361 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15362 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15363 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A];
15369 sdwCyclesRemaining -= 4;
15370 bTemp2 = cpu.z80A - cpu.z80B - (cpu.z80F & Z80_FLAG_CARRY);
15371 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15372 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15373 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15379 sdwCyclesRemaining -= 4;
15380 bTemp2 = cpu.z80A - cpu.z80C - (cpu.z80F & Z80_FLAG_CARRY);
15381 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15382 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15383 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15389 sdwCyclesRemaining -= 4;
15390 bTemp2 = cpu.z80A - cpu.z80D - (cpu.z80F & Z80_FLAG_CARRY);
15391 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15392 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15393 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15399 sdwCyclesRemaining -= 4;
15400 bTemp2 = cpu.z80A - cpu.z80E - (cpu.z80F & Z80_FLAG_CARRY);
15401 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15402 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15403 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15409 sdwCyclesRemaining -= 4;
15410 bTemp2 = cpu.z80A - cpu.z80H - (cpu.z80F & Z80_FLAG_CARRY);
15411 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15412 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15413 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15419 sdwCyclesRemaining -= 4;
15420 bTemp2 = cpu.z80A - cpu.z80L - (cpu.z80F & Z80_FLAG_CARRY);
15421 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15422 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15423 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15429 sdwCyclesRemaining -= 7;
15430 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15431 while (psMemRead->lowAddr != 0xffffffff)
15433 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15435 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15436 if (psMemRead->memoryCall)
15438 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15442 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15452 bTemp = cpu.z80Base[cpu.z80HL];
15455 bTemp2 = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY);
15456 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15457 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15458 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15464 sdwCyclesRemaining -= 4;
15465 bTemp2 = cpu.z80A - cpu.z80A - (cpu.z80F & Z80_FLAG_CARRY);
15466 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15467 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15468 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
15474 sdwCyclesRemaining -= 4;
15475 cpu.z80A &= cpu.z80B;
15476 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15477 cpu.z80F |= bPostANDFlags[cpu.z80A];
15483 sdwCyclesRemaining -= 4;
15484 cpu.z80A &= cpu.z80C;
15485 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15486 cpu.z80F |= bPostANDFlags[cpu.z80A];
15492 sdwCyclesRemaining -= 4;
15493 cpu.z80A &= cpu.z80D;
15494 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15495 cpu.z80F |= bPostANDFlags[cpu.z80A];
15501 sdwCyclesRemaining -= 4;
15502 cpu.z80A &= cpu.z80E;
15503 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15504 cpu.z80F |= bPostANDFlags[cpu.z80A];
15510 sdwCyclesRemaining -= 4;
15511 cpu.z80A &= cpu.z80H;
15512 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15513 cpu.z80F |= bPostANDFlags[cpu.z80A];
15519 sdwCyclesRemaining -= 4;
15520 cpu.z80A &= cpu.z80L;
15521 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15522 cpu.z80F |= bPostANDFlags[cpu.z80A];
15528 sdwCyclesRemaining -= 7;
15529 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15530 while (psMemRead->lowAddr != 0xffffffff)
15532 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15534 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15535 if (psMemRead->memoryCall)
15537 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15541 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15551 bTemp = cpu.z80Base[cpu.z80HL];
15555 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15556 cpu.z80F |= bPostANDFlags[cpu.z80A];
15562 sdwCyclesRemaining -= 4;
15563 cpu.z80A &= cpu.z80A;
15564 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15565 cpu.z80F |= bPostANDFlags[cpu.z80A];
15571 sdwCyclesRemaining -= 4;
15572 cpu.z80A ^= cpu.z80B;
15573 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15574 cpu.z80F |= bPostORFlags[cpu.z80A];
15580 sdwCyclesRemaining -= 4;
15581 cpu.z80A ^= cpu.z80C;
15582 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15583 cpu.z80F |= bPostORFlags[cpu.z80A];
15589 sdwCyclesRemaining -= 4;
15590 cpu.z80A ^= cpu.z80D;
15591 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15592 cpu.z80F |= bPostORFlags[cpu.z80A];
15598 sdwCyclesRemaining -= 4;
15599 cpu.z80A ^= cpu.z80E;
15600 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15601 cpu.z80F |= bPostORFlags[cpu.z80A];
15607 sdwCyclesRemaining -= 4;
15608 cpu.z80A ^= cpu.z80H;
15609 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15610 cpu.z80F |= bPostORFlags[cpu.z80A];
15616 sdwCyclesRemaining -= 4;
15617 cpu.z80A ^= cpu.z80L;
15618 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15619 cpu.z80F |= bPostORFlags[cpu.z80A];
15625 sdwCyclesRemaining -= 7;
15626 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15627 while (psMemRead->lowAddr != 0xffffffff)
15629 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15631 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15632 if (psMemRead->memoryCall)
15634 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15638 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15648 bTemp = cpu.z80Base[cpu.z80HL];
15652 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15653 cpu.z80F |= bPostORFlags[cpu.z80A];
15659 sdwCyclesRemaining -= 4;
15660 cpu.z80A ^= cpu.z80A;
15661 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15662 cpu.z80F |= bPostORFlags[cpu.z80A];
15668 sdwCyclesRemaining -= 4;
15669 cpu.z80A |= cpu.z80B;
15670 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15671 cpu.z80F |= bPostORFlags[cpu.z80A];
15677 sdwCyclesRemaining -= 4;
15678 cpu.z80A |= cpu.z80C;
15679 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15680 cpu.z80F |= bPostORFlags[cpu.z80A];
15686 sdwCyclesRemaining -= 4;
15687 cpu.z80A |= cpu.z80D;
15688 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15689 cpu.z80F |= bPostORFlags[cpu.z80A];
15695 sdwCyclesRemaining -= 4;
15696 cpu.z80A |= cpu.z80E;
15697 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15698 cpu.z80F |= bPostORFlags[cpu.z80A];
15704 sdwCyclesRemaining -= 4;
15705 cpu.z80A |= cpu.z80H;
15706 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15707 cpu.z80F |= bPostORFlags[cpu.z80A];
15713 sdwCyclesRemaining -= 4;
15714 cpu.z80A |= cpu.z80L;
15715 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15716 cpu.z80F |= bPostORFlags[cpu.z80A];
15722 sdwCyclesRemaining -= 7;
15723 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15724 while (psMemRead->lowAddr != 0xffffffff)
15726 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15728 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15729 if (psMemRead->memoryCall)
15731 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15735 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15745 bTemp = cpu.z80Base[cpu.z80HL];
15749 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15750 cpu.z80F |= bPostORFlags[cpu.z80A];
15756 sdwCyclesRemaining -= 4;
15757 cpu.z80A |= cpu.z80A;
15758 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
15759 cpu.z80F |= bPostORFlags[cpu.z80A];
15765 sdwCyclesRemaining -= 4;
15766 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15767 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15768 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B];
15773 sdwCyclesRemaining -= 4;
15774 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15775 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15776 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C];
15781 sdwCyclesRemaining -= 4;
15782 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15783 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15784 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D];
15789 sdwCyclesRemaining -= 4;
15790 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15791 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15792 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E];
15797 sdwCyclesRemaining -= 4;
15798 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15799 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15800 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H];
15805 sdwCyclesRemaining -= 4;
15806 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15807 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15808 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L];
15813 sdwCyclesRemaining -= 7;
15814 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15815 while (psMemRead->lowAddr != 0xffffffff)
15817 if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
15819 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15820 if (psMemRead->memoryCall)
15822 bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
15826 bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
15836 bTemp = cpu.z80Base[cpu.z80HL];
15839 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15840 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15841 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
15846 sdwCyclesRemaining -= 4;
15847 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15848 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15849 pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A];
15854 sdwCyclesRemaining -= 5;
15855 if (!(cpu.z80F & Z80_FLAG_ZERO))
15857 dwElapsedTicks += 6;
15858 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
15859 dwAddr = *pbSP++; /* Pop LSB */
15860 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
15861 cpu.z80sp += 2; /* Pop the word off */
15862 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
15868 sdwCyclesRemaining -= 10;
15869 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
15870 while (psMemRead->lowAddr != 0xffffffff)
15872 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
15874 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15875 if (psMemRead->memoryCall)
15877 cpu.z80BC = psMemRead->memoryCall(cpu.z80sp, psMemRead);
15878 cpu.z80BC |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
15882 cpu.z80BC = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
15883 cpu.z80BC |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
15893 cpu.z80BC = cpu.z80Base[cpu.z80sp];
15894 cpu.z80BC |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
15898 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
15903 sdwCyclesRemaining -= 10;
15904 dwAddr = *pbPC++; /* Get LSB first */
15905 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
15906 if (!(cpu.z80F & Z80_FLAG_ZERO))
15908 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
15914 sdwCyclesRemaining -= 10;
15915 dwAddr = *pbPC++; /* Get LSB first */
15916 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
15917 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
15922 sdwCyclesRemaining -= 10;
15923 dwAddr = *pbPC++; /* Get LSB first */
15924 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
15925 if (!(cpu.z80F & Z80_FLAG_ZERO))
15927 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15928 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
15929 *pbSP-- = cpu.z80pc >> 8; /* MSB */
15930 *pbSP = (UINT8) cpu.z80pc; /* LSB */
15931 cpu.z80sp -= 2; /* Back our stack up */
15932 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
15938 sdwCyclesRemaining -= 11;
15940 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
15941 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
15942 while (psMemWrite->lowAddr != 0xffffffff)
15944 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
15946 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15947 if (psMemWrite->memoryCall)
15949 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80BC & 0xff), psMemWrite);
15950 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80BC >> 8), psMemWrite);
15954 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80BC;
15955 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80BC >> 8;
15965 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80BC;
15966 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80BC >> 8);
15973 sdwCyclesRemaining -= 7;
15975 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
15976 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
15977 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
15983 sdwCyclesRemaining -= 11;
15984 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
15985 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
15986 *pbSP-- = cpu.z80pc >> 8; /* LSB */
15987 *pbSP = (UINT8) cpu.z80pc; /* MSB */
15988 cpu.z80sp -= 2; /* Back our stack up */
15989 pbPC = cpu.z80Base + 0x00; /* Normalize the address */
15994 sdwCyclesRemaining -= 5;
15995 if (cpu.z80F & Z80_FLAG_ZERO)
15997 dwElapsedTicks += 6;
15998 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
15999 dwAddr = *pbSP++; /* Pop LSB */
16000 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16001 cpu.z80sp += 2; /* Pop the word off */
16002 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16008 sdwCyclesRemaining -= 10;
16009 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16010 dwAddr = *pbSP++; /* Pop LSB */
16011 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16012 cpu.z80sp += 2; /* Pop the word off */
16013 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16018 sdwCyclesRemaining -= 10;
16019 dwAddr = *pbPC++; /* Get LSB first */
16020 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16021 if (cpu.z80F & Z80_FLAG_ZERO)
16023 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16034 sdwCyclesRemaining -= 10;
16035 dwAddr = *pbPC++; /* Get LSB first */
16036 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16037 if (cpu.z80F & Z80_FLAG_ZERO)
16039 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16040 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16041 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16042 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16043 cpu.z80sp -= 2; /* Back our stack up */
16044 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16050 sdwCyclesRemaining -= 17;
16051 dwAddr = *pbPC++; /* Get LSB first */
16052 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16053 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16054 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16055 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16056 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16057 cpu.z80sp -= 2; /* Back our stack up */
16058 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16063 sdwCyclesRemaining -= 7;
16064 bTemp = *pbPC++ + (cpu.z80F & Z80_FLAG_CARRY);
16065 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
16066 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
16067 pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
16073 sdwCyclesRemaining -= 11;
16074 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16075 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16076 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16077 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16078 cpu.z80sp -= 2; /* Back our stack up */
16079 pbPC = cpu.z80Base + 0x08; /* Normalize the address */
16084 sdwCyclesRemaining -= 5;
16085 if (!(cpu.z80F & Z80_FLAG_CARRY))
16087 dwElapsedTicks += 6;
16088 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16089 dwAddr = *pbSP++; /* Pop LSB */
16090 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16091 cpu.z80sp += 2; /* Pop the word off */
16092 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16098 sdwCyclesRemaining -= 10;
16099 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
16100 while (psMemRead->lowAddr != 0xffffffff)
16102 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
16104 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16105 if (psMemRead->memoryCall)
16107 cpu.z80DE = psMemRead->memoryCall(cpu.z80sp, psMemRead);
16108 cpu.z80DE |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
16112 cpu.z80DE = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
16113 cpu.z80DE |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
16123 cpu.z80DE = cpu.z80Base[cpu.z80sp];
16124 cpu.z80DE |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
16128 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
16133 sdwCyclesRemaining -= 10;
16134 dwAddr = *pbPC++; /* Get LSB first */
16135 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16136 if (!(cpu.z80F & Z80_FLAG_CARRY))
16138 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16144 sdwCyclesRemaining -= 11;
16146 psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */
16147 while (psIoWrite->lowIoAddr != 0xffff)
16149 if ((dwTemp >= psIoWrite->lowIoAddr) && (dwTemp <= psIoWrite->highIoAddr))
16151 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16152 psIoWrite->IOCall(dwTemp, cpu.z80A, psIoWrite);
16163 sdwCyclesRemaining -= 10;
16164 dwAddr = *pbPC++; /* Get LSB first */
16165 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16166 if (!(cpu.z80F & Z80_FLAG_CARRY))
16168 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16169 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16170 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16171 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16172 cpu.z80sp -= 2; /* Back our stack up */
16173 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16179 sdwCyclesRemaining -= 11;
16181 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
16182 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
16183 while (psMemWrite->lowAddr != 0xffffffff)
16185 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
16187 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16188 if (psMemWrite->memoryCall)
16190 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80DE & 0xff), psMemWrite);
16191 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80DE >> 8), psMemWrite);
16195 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80DE;
16196 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80DE >> 8;
16206 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80DE;
16207 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80DE >> 8);
16214 sdwCyclesRemaining -= 7;
16216 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
16217 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
16218 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
16224 sdwCyclesRemaining -= 11;
16225 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16226 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16227 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16228 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16229 cpu.z80sp -= 2; /* Back our stack up */
16230 pbPC = cpu.z80Base + 0x10; /* Normalize the address */
16235 sdwCyclesRemaining -= 5;
16236 if (cpu.z80F & Z80_FLAG_CARRY)
16238 dwElapsedTicks += 6;
16239 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16240 dwAddr = *pbSP++; /* Pop LSB */
16241 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16242 cpu.z80sp += 2; /* Pop the word off */
16243 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16249 sdwCyclesRemaining -= 4;
16250 dwTemp = cpu.z80DE;
16251 cpu.z80DE = cpu.z80deprime;
16252 cpu.z80deprime = dwTemp;
16253 dwTemp = cpu.z80BC;
16254 cpu.z80BC = cpu.z80bcprime;
16255 cpu.z80bcprime = dwTemp;
16256 dwTemp = cpu.z80HL;
16257 cpu.z80HL = cpu.z80hlprime;
16258 cpu.z80hlprime = dwTemp;
16263 sdwCyclesRemaining -= 10;
16264 dwAddr = *pbPC++; /* Get LSB first */
16265 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16266 if (cpu.z80F & Z80_FLAG_CARRY)
16268 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16274 sdwCyclesRemaining -= 11;
16276 psIoRead = cpu.z80IoRead; /* Beginning of our handler */
16277 while (psIoRead->lowIoAddr != 0xffff)
16279 if ((dwTemp >= psIoRead->lowIoAddr) && (dwTemp <= psIoRead->highIoAddr))
16281 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16282 cpu.z80A = psIoRead->IOCall(dwTemp, psIoRead);
16291 cpu.z80A = 0xff; /* Unclaimed I/O read */
16298 sdwCyclesRemaining -= 10;
16299 dwAddr = *pbPC++; /* Get LSB first */
16300 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16301 if (cpu.z80F & Z80_FLAG_CARRY)
16303 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16304 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16305 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16306 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16307 cpu.z80sp -= 2; /* Back our stack up */
16308 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16319 sdwCyclesRemaining -= 7;
16320 bTemp = *pbPC++ + (cpu.z80F & Z80_FLAG_CARRY);
16321 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
16322 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
16323 pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
16324 cpu.z80A = cpu.z80A - bTemp;
16329 sdwCyclesRemaining -= 11;
16330 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16331 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16332 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16333 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16334 cpu.z80sp -= 2; /* Back our stack up */
16335 pbPC = cpu.z80Base + 0x18; /* Normalize the address */
16340 sdwCyclesRemaining -= 5;
16341 if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY))
16343 dwElapsedTicks += 6;
16344 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16345 dwAddr = *pbSP++; /* Pop LSB */
16346 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16347 cpu.z80sp += 2; /* Pop the word off */
16348 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16354 sdwCyclesRemaining -= 10;
16355 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
16356 while (psMemRead->lowAddr != 0xffffffff)
16358 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
16360 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16361 if (psMemRead->memoryCall)
16363 cpu.z80HL = psMemRead->memoryCall(cpu.z80sp, psMemRead);
16364 cpu.z80HL |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
16368 cpu.z80HL = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
16369 cpu.z80HL |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
16379 cpu.z80HL = cpu.z80Base[cpu.z80sp];
16380 cpu.z80HL |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
16384 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
16389 sdwCyclesRemaining -= 10;
16390 dwAddr = *pbPC++; /* Get LSB first */
16391 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16392 if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY))
16394 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16400 sdwCyclesRemaining -= 19;
16401 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
16402 while (psMemRead->lowAddr != 0xffffffff)
16404 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
16406 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16407 if (psMemRead->memoryCall)
16409 dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead);
16410 dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
16414 dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
16415 dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
16425 dwAddr = cpu.z80Base[cpu.z80sp];
16426 dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
16429 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
16430 while (psMemWrite->lowAddr != 0xffffffff)
16432 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
16434 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16435 if (psMemWrite->memoryCall)
16437 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80HL & 0xff), psMemWrite);
16438 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80HL >> 8), psMemWrite);
16442 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80HL;
16443 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
16453 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80HL;
16454 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
16457 cpu.z80HL = dwAddr;
16462 sdwCyclesRemaining -= 10;
16463 dwAddr = *pbPC++; /* Get LSB first */
16464 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16465 if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY))
16467 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16468 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16469 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16470 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16471 cpu.z80sp -= 2; /* Back our stack up */
16472 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16478 sdwCyclesRemaining -= 11;
16480 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
16481 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
16482 while (psMemWrite->lowAddr != 0xffffffff)
16484 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
16486 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16487 if (psMemWrite->memoryCall)
16489 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80HL & 0xff), psMemWrite);
16490 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80HL >> 8), psMemWrite);
16494 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80HL;
16495 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
16505 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80HL;
16506 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
16513 sdwCyclesRemaining -= 7;
16514 cpu.z80A &= *pbPC++;
16515 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
16516 cpu.z80F |= bPostANDFlags[cpu.z80A];
16522 sdwCyclesRemaining -= 11;
16523 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16524 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16525 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16526 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16527 cpu.z80sp -= 2; /* Back our stack up */
16528 pbPC = cpu.z80Base + 0x20; /* Normalize the address */
16533 sdwCyclesRemaining -= 5;
16534 if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)
16536 dwElapsedTicks += 6;
16537 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16538 dwAddr = *pbSP++; /* Pop LSB */
16539 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16540 cpu.z80sp += 2; /* Pop the word off */
16541 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16547 sdwCyclesRemaining -= 4;
16548 pbPC = cpu.z80Base + cpu.z80HL;
16553 sdwCyclesRemaining -= 10;
16554 dwAddr = *pbPC++; /* Get LSB first */
16555 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16556 if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)
16558 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16564 sdwCyclesRemaining -= 4;
16565 dwAddr = cpu.z80DE;
16566 cpu.z80DE = cpu.z80HL;
16567 cpu.z80HL = dwAddr;
16572 sdwCyclesRemaining -= 10;
16573 dwAddr = *pbPC++; /* Get LSB first */
16574 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16575 if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)
16577 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16578 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16579 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16580 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16581 cpu.z80sp -= 2; /* Back our stack up */
16582 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16593 sdwCyclesRemaining -= 7;
16594 cpu.z80A ^= *pbPC++;
16595 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
16596 cpu.z80F |= bPostORFlags[cpu.z80A];
16602 sdwCyclesRemaining -= 11;
16603 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16604 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16605 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16606 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16607 cpu.z80sp -= 2; /* Back our stack up */
16608 pbPC = cpu.z80Base + 0x28; /* Normalize the address */
16613 sdwCyclesRemaining -= 5;
16614 if (!(cpu.z80F & Z80_FLAG_SIGN))
16616 dwElapsedTicks += 6;
16617 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16618 dwAddr = *pbSP++; /* Pop LSB */
16619 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16620 cpu.z80sp += 2; /* Pop the word off */
16621 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16627 sdwCyclesRemaining -= 10;
16628 psMemRead = cpu.z80MemRead; /* Beginning of our handler */
16629 while (psMemRead->lowAddr != 0xffffffff)
16631 if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
16633 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16634 if (psMemRead->memoryCall)
16636 cpu.z80AF = psMemRead->memoryCall(cpu.z80sp, psMemRead);
16637 cpu.z80AF |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
16641 cpu.z80AF = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
16642 cpu.z80AF |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
16652 cpu.z80AF = cpu.z80Base[cpu.z80sp];
16653 cpu.z80AF |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
16657 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
16662 sdwCyclesRemaining -= 10;
16663 dwAddr = *pbPC++; /* Get LSB first */
16664 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16665 if (!(cpu.z80F & Z80_FLAG_SIGN))
16667 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16673 sdwCyclesRemaining -= 4;
16674 cpu.z80iff &= (~IFF1);
16679 sdwCyclesRemaining -= 10;
16680 dwAddr = *pbPC++; /* Get LSB first */
16681 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16682 if (!(cpu.z80F & Z80_FLAG_SIGN))
16684 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16685 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16686 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16687 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16688 cpu.z80sp -= 2; /* Back our stack up */
16689 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16695 sdwCyclesRemaining -= 11;
16697 pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */
16698 psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */
16699 while (psMemWrite->lowAddr != 0xffffffff)
16701 if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
16703 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16704 if (psMemWrite->memoryCall)
16706 psMemWrite->memoryCall(cpu.z80sp, (cpu.z80AF & 0xff), psMemWrite);
16707 psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80AF >> 8), psMemWrite);
16711 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80AF;
16712 *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80AF >> 8;
16722 cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80AF;
16723 cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80AF >> 8);
16730 sdwCyclesRemaining -= 7;
16731 cpu.z80A |= *pbPC++;
16732 cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
16733 cpu.z80F |= bPostORFlags[cpu.z80A];
16739 sdwCyclesRemaining -= 11;
16740 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16741 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16742 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16743 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16744 cpu.z80sp -= 2; /* Back our stack up */
16745 pbPC = cpu.z80Base + 0x30; /* Normalize the address */
16750 sdwCyclesRemaining -= 5;
16751 if (cpu.z80F & Z80_FLAG_SIGN)
16753 dwElapsedTicks += 6;
16754 pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
16755 dwAddr = *pbSP++; /* Pop LSB */
16756 dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */
16757 cpu.z80sp += 2; /* Pop the word off */
16758 pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */
16764 sdwCyclesRemaining -= 6;
16765 cpu.z80sp = cpu.z80HL;
16770 sdwCyclesRemaining -= 10;
16771 dwAddr = *pbPC++; /* Get LSB first */
16772 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16773 if (cpu.z80F & Z80_FLAG_SIGN)
16775 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16781 sdwCyclesRemaining -= 4;
16782 cpu.z80iff |= IFF1;
16787 sdwCyclesRemaining -= 10;
16788 dwAddr = *pbPC++; /* Get LSB first */
16789 dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
16790 if (cpu.z80F & Z80_FLAG_SIGN)
16792 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16793 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16794 *pbSP-- = cpu.z80pc >> 8; /* MSB */
16795 *pbSP = (UINT8) cpu.z80pc; /* LSB */
16796 cpu.z80sp -= 2; /* Back our stack up */
16797 pbPC = cpu.z80Base + dwAddr; /* Normalize the address */
16808 sdwCyclesRemaining -= 7;
16809 cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY |
16810 Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
16811 pbSubSbcTable[((UINT32) cpu.z80A << 8) | *pbPC++];
16816 sdwCyclesRemaining -= 11;
16817 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16818 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16819 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16820 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16821 cpu.z80sp -= 2; /* Back our stack up */
16822 pbPC = cpu.z80Base + 0x38; /* Normalize the address */
16828 dwElapsedTicks += (dwOriginalCycles - sdwCyclesRemaining);
16830 cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
16831 return(dwReturnCode); /* Indicate success */
16834 /* Get mz80's context */
16836 void mz80GetContext(void *pData)
16838 memcpy(pData, &cpu, sizeof(CONTEXTMZ80));
16841 /* Set mz80's context */
16843 void mz80SetContext(void *pData)
16845 memcpy(&cpu, pData, sizeof(CONTEXTMZ80));
16848 /* Get mz80's context size */
16850 UINT32 mz80GetContextSize(void)
16852 return(sizeof(CONTEXTMZ80));
16855 /* This will return the elapsed ticks */
16857 UINT32 mz80GetElapsedTicks(UINT32 dwClear)
16859 UINT32 dwTemp = dwElapsedTicks;
16863 dwElapsedTicks = 0;
16869 /* Releases mz80 from its current timeslice */
16871 void mz80ReleaseTimeslice(void)
16873 dwOriginalCycles -= sdwCyclesRemaining;
16874 sdwCyclesRemaining = 0;
16877 /* This routine is mz80's reset handler */
16879 void mz80reset(void)
16883 cpu.z80F = Z80_FLAG_ZERO;
16887 cpu.z80afprime = 0;
16888 cpu.z80bcprime = 0;
16889 cpu.z80deprime = 0;
16890 cpu.z80hlprime = 0;
16893 cpu.z80IX = 0xffff; /* Yes, this is intentional */
16894 cpu.z80IY = 0xffff; /* Yes, this is intentional */
16897 cpu.z80interruptMode = 0;
16898 cpu.z80intAddr = 0x38;
16899 cpu.z80nmiAddr = 0x66;
16902 /* Interrupt handler */
16904 UINT32 mz80int(UINT32 dwLowAddr)
16907 if (0 == (cpu.z80iff & IFF1))
16908 return(0xffffffff);
16909 cpu.z80iff &= ~(IFF1 | IFF2);
16910 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16911 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16912 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16913 cpu.z80sp -= 2; /* Back our stack up */
16914 if (2 == cpu.z80interruptMode)
16916 cpu.z80pc = ((UINT16) cpu.z80i << 8) | (dwLowAddr & 0xff);
16917 cpu.z80pc = ((UINT16) cpu.z80Base[cpu.z80pc + 1] << 8) | (cpu.z80Base[cpu.z80pc]);
16921 cpu.z80pc = cpu.z80intAddr;
16923 pbPC = cpu.z80Base + cpu.z80pc; /* Normalize the address */
16929 UINT32 mz80nmi(void)
16932 pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */
16933 *pbSP-- = cpu.z80pc >> 8; /* LSB */
16934 *pbSP = (UINT8) cpu.z80pc; /* MSB */
16935 cpu.z80sp -= 2; /* Back our stack up */
16936 cpu.z80pc = cpu.z80nmiAddr; /* Our NMI */
16940 /* Initialize MZ80 for action */
16942 void mz80init(void)
16954 if (NULL == pbAddAdcTable)
16956 pbAddAdcTable = malloc(256*256*2);
16958 if (NULL == pbAddAdcTable)
16963 pbTempPtr = pbAddAdcTable;
16965 pbSubSbcTable = malloc(256*256*2);
16967 if (NULL == pbSubSbcTable)
16972 pbTempPtr2 = pbSubSbcTable;
16974 for (dwLoop = 0; dwLoop < (256*256*2); dwLoop++)
16976 bLow = dwLoop & 0xff;
16977 bHigh = (dwLoop >> 8) & 0xff;
16978 bCarry = (dwLoop >> 16);
16981 bNewAdd = bHigh + bLow + bCarry;
16985 bFlag |= Z80_FLAG_ZERO;
16989 bFlag = bNewAdd & 0x80; /* Sign flag */
16992 if (((UINT32) bLow + (UINT32) bHigh + (UINT32) bCarry) >= 0x100)
16994 bFlag |= Z80_FLAG_CARRY;
16997 if ( ((bLow ^ bHigh ^ 0x80) & (bLow ^ (bNewAdd & 0x80))) & 0x80)
16999 bFlag |= Z80_FLAG_OVERFLOW_PARITY;
17002 if (((bLow & 0x0f) + (bHigh & 0x0f) + bCarry) >= 0x10)
17004 bFlag |= Z80_FLAG_HALF_CARRY;
17007 *pbTempPtr++ = bFlag; /* Store our new flag */
17009 // Now do subtract - Zero
17011 bFlag = Z80_FLAG_NEGATIVE;
17012 bNewSub = bHigh - bLow - bCarry;
17016 bFlag |= Z80_FLAG_ZERO;
17020 bFlag |= bNewSub & 0x80; /* Sign flag */
17023 if ( ((INT32) bHigh - (INT32) bLow - (INT32) bCarry) < 0)
17025 bFlag |= Z80_FLAG_CARRY;
17028 if ( ((INT32) (bHigh & 0xf) - (INT32) (bLow & 0x0f) - (INT32) bCarry) < 0)
17030 bFlag |= Z80_FLAG_HALF_CARRY;
17033 if ( ((bLow ^ bHigh) & (bHigh ^ bNewSub) & 0x80) )
17035 bFlag |= Z80_FLAG_OVERFLOW_PARITY;
17038 *pbTempPtr2++ = bFlag; /* Store our sub flag */
17043 /* Shut down MZ80 */
17045 void mz80shutdown(void)
17047 // notaz: why weren't these here?
17048 free(pbAddAdcTable);
17050 free(pbSubSbcTable);