1 /* Multi-Z80 32 Bit emulator */
3 /* Copyright 1996-2000 Neil Bradley, All rights reserved
7 * (MZ80 Refers to both the assembly code emitted by makeZ80.c and makeZ80.c
10 * MZ80 May be distributed in unmodified form to any medium.
12 * MZ80 May not be sold, or sold as a part of a commercial package without
13 * the express written permission of Neil Bradley (neil@synthcom.com). This
16 * Modified versions of MZ80 may not be publicly redistributed without author
17 * approval (neil@synthcom.com). This includes distributing via a publicly
18 * accessible LAN. You may make your own source modifications and distribute
19 * MZ80 in source or object form, but if you make modifications to MZ80
20 * then it should be noted in the top as a comment in makeZ80.c.
22 * MZ80 Licensing for commercial applications is available. Please email
23 * neil@synthcom.com for details.
25 * Synthcom Systems, Inc, and Neil Bradley will not be held responsible for
26 * any damage done by the use of MZ80. It is purely "as-is".
28 * If you use MZ80 in a freeware application, credit in the following text:
30 * "Multi-Z80 CPU emulator by Neil Bradley (neil@synthcom.com)"
32 * must accompany the freeware application within the application itself or
33 * in the documentation.
37 * If you find problems with MZ80, please email the author so they can get
38 * resolved. If you find a bug and fix it, please also email the author so
39 * that those bug fixes can be propogated to the installed base of MZ80
40 * users. If you find performance improvements or problems with MZ80, please
41 * email the author with your changes/suggestions and they will be rolled in
42 * with subsequent releases of MZ80.
44 * The whole idea of this emulator is to have the fastest available 32 bit
45 * Multi-Z80 emulator for the PC, giving maximum performance.
56 /* Modular global variables go here*/
58 static CONTEXTMZ80 cpu
; /* CPU Context */
59 static UINT8
*pbPC
; /* Program counter normalized */
60 static UINT8
*pbSP
; /* Stack pointer normalized */
61 static struct MemoryReadByte
*psMemRead
; /* Read memory structure */
62 static struct MemoryWriteByte
*psMemWrite
; /* Write memory structure */
63 static struct z80PortRead
*psIoRead
; /* Read I/O structure */
64 static struct z80PortWrite
*psIoWrite
; /* Write memory structure */
65 static INT32 sdwCyclesRemaining
; /* Used as a countdown */
66 static UINT32 dwReturnCode
; /* Return code from exec() */
67 static UINT32 dwOriginalCycles
; /* How many cycles did we start with? */
68 static UINT32 dwElapsedTicks
; /* How many ticks did we elapse? */
69 static INT32 sdwAddr
; /* Temporary address storage */
70 static UINT32 dwAddr
; /* Temporary stack address */
71 static UINT8
*pbAddAdcTable
; /* Pointer to add/adc flag table */
72 static UINT8
*pbSubSbcTable
; /* Pointer to sub/sbc flag table */
73 static UINT32 dwTemp
; /* Temporary value */
75 static UINT8 bTemp
; /* Temporary value */
77 static UINT8 bTemp2
; /* Temporary value */
79 /* Precomputed flag tables */
81 static UINT8 bPostIncFlags
[0x100] =
83 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
84 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
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,0x94,
91 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
92 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
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,0x50
101 static UINT8 bPostDecFlags
[0x100] =
103 0x92,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
104 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
105 0x12,0x02,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 0x16,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
112 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
113 0x92,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
121 static UINT8 bPostORFlags
[0x100] =
123 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
124 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
125 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
126 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
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 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
130 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
131 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
132 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
133 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
134 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
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 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
138 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84
141 static UINT8 bPostANDFlags
[0x100] =
143 0x54,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
144 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
145 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
146 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
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 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
150 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
151 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
152 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
153 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
154 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
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 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
158 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94
161 static UINT16 wDAATable
[0x800] =
163 0x5400,0x1001,0x1002,0x1403,0x1004,0x1405,0x1406,0x1007,
164 0x1008,0x1409,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,
165 0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,0x1016,0x1417,
166 0x1418,0x1019,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,
167 0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,0x1026,0x1427,
168 0x1428,0x1029,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,
169 0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,0x1436,0x1037,
170 0x1038,0x1439,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,
171 0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,0x1046,0x1447,
172 0x1448,0x1049,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,
173 0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,0x1456,0x1057,
174 0x1058,0x1459,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,
175 0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,0x1466,0x1067,
176 0x1068,0x1469,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,
177 0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,0x1076,0x1477,
178 0x1478,0x1079,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,
179 0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,0x9086,0x9487,
180 0x9488,0x9089,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,
181 0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,0x9496,0x9097,
182 0x9098,0x9499,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
183 0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107,
184 0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
185 0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517,
186 0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
187 0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527,
188 0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
189 0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137,
190 0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
191 0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547,
192 0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
193 0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157,
194 0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
195 0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,0x1566,0x1167,
196 0x1168,0x1569,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,
197 0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,0x1176,0x1577,
198 0x1578,0x1179,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,
199 0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,0x9186,0x9587,
200 0x9588,0x9189,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,
201 0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,0x9596,0x9197,
202 0x9198,0x9599,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,
203 0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,0x95a6,0x91a7,
204 0x91a8,0x95a9,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,
205 0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,0x91b6,0x95b7,
206 0x95b8,0x91b9,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,
207 0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,0x95c6,0x91c7,
208 0x91c8,0x95c9,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,
209 0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,0x91d6,0x95d7,
210 0x95d8,0x91d9,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,
211 0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,0x91e6,0x95e7,
212 0x95e8,0x91e9,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,
213 0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,0x95f6,0x91f7,
214 0x91f8,0x95f9,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
215 0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107,
216 0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
217 0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517,
218 0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
219 0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527,
220 0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
221 0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137,
222 0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
223 0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547,
224 0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
225 0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157,
226 0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
227 0x1406,0x1007,0x1008,0x1409,0x140a,0x100b,0x140c,0x100d,
228 0x100e,0x140f,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,
229 0x1016,0x1417,0x1418,0x1019,0x101a,0x141b,0x101c,0x141d,
230 0x141e,0x101f,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,
231 0x1026,0x1427,0x1428,0x1029,0x102a,0x142b,0x102c,0x142d,
232 0x142e,0x102f,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,
233 0x1436,0x1037,0x1038,0x1439,0x143a,0x103b,0x143c,0x103d,
234 0x103e,0x143f,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,
235 0x1046,0x1447,0x1448,0x1049,0x104a,0x144b,0x104c,0x144d,
236 0x144e,0x104f,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,
237 0x1456,0x1057,0x1058,0x1459,0x145a,0x105b,0x145c,0x105d,
238 0x105e,0x145f,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,
239 0x1466,0x1067,0x1068,0x1469,0x146a,0x106b,0x146c,0x106d,
240 0x106e,0x146f,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,
241 0x1076,0x1477,0x1478,0x1079,0x107a,0x147b,0x107c,0x147d,
242 0x147e,0x107f,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,
243 0x9086,0x9487,0x9488,0x9089,0x908a,0x948b,0x908c,0x948d,
244 0x948e,0x908f,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,
245 0x9496,0x9097,0x9098,0x9499,0x949a,0x909b,0x949c,0x909d,
246 0x909e,0x949f,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
247 0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d,
248 0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
249 0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d,
250 0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
251 0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d,
252 0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
253 0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d,
254 0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
255 0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d,
256 0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
257 0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d,
258 0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
259 0x1566,0x1167,0x1168,0x1569,0x156a,0x116b,0x156c,0x116d,
260 0x116e,0x156f,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,
261 0x1176,0x1577,0x1578,0x1179,0x117a,0x157b,0x117c,0x157d,
262 0x157e,0x117f,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,
263 0x9186,0x9587,0x9588,0x9189,0x918a,0x958b,0x918c,0x958d,
264 0x958e,0x918f,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,
265 0x9596,0x9197,0x9198,0x9599,0x959a,0x919b,0x959c,0x919d,
266 0x919e,0x959f,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,
267 0x95a6,0x91a7,0x91a8,0x95a9,0x95aa,0x91ab,0x95ac,0x91ad,
268 0x91ae,0x95af,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,
269 0x91b6,0x95b7,0x95b8,0x91b9,0x91ba,0x95bb,0x91bc,0x95bd,
270 0x95be,0x91bf,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,
271 0x95c6,0x91c7,0x91c8,0x95c9,0x95ca,0x91cb,0x95cc,0x91cd,
272 0x91ce,0x95cf,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,
273 0x91d6,0x95d7,0x95d8,0x91d9,0x91da,0x95db,0x91dc,0x95dd,
274 0x95de,0x91df,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,
275 0x91e6,0x95e7,0x95e8,0x91e9,0x91ea,0x95eb,0x91ec,0x95ed,
276 0x95ee,0x91ef,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,
277 0x95f6,0x91f7,0x91f8,0x95f9,0x95fa,0x91fb,0x95fc,0x91fd,
278 0x91fe,0x95ff,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
279 0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d,
280 0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
281 0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d,
282 0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
283 0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d,
284 0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
285 0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d,
286 0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
287 0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d,
288 0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
289 0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d,
290 0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
291 0x5600,0x1201,0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,
292 0x1208,0x1609,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609,
293 0x1210,0x1611,0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,
294 0x1618,0x1219,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219,
295 0x1220,0x1621,0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,
296 0x1628,0x1229,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229,
297 0x1630,0x1231,0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,
298 0x1238,0x1639,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639,
299 0x1240,0x1641,0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,
300 0x1648,0x1249,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249,
301 0x1650,0x1251,0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,
302 0x1258,0x1659,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659,
303 0x1660,0x1261,0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,
304 0x1268,0x1669,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669,
305 0x1270,0x1671,0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,
306 0x1678,0x1279,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279,
307 0x9280,0x9681,0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,
308 0x9688,0x9289,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289,
309 0x9690,0x9291,0x9292,0x9693,0x9294,0x9695,0x9696,0x9297,
310 0x9298,0x9699,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
311 0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,
312 0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
313 0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,
314 0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
315 0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,
316 0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
317 0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,
318 0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
319 0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,
320 0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
321 0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,
322 0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
323 0x97a0,0x93a1,0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,
324 0x93a8,0x97a9,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9,
325 0x93b0,0x97b1,0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,
326 0x97b8,0x93b9,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9,
327 0x97c0,0x93c1,0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,
328 0x93c8,0x97c9,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9,
329 0x93d0,0x97d1,0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,
330 0x97d8,0x93d9,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9,
331 0x93e0,0x97e1,0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,
332 0x97e8,0x93e9,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9,
333 0x97f0,0x93f1,0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,
334 0x93f8,0x97f9,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9,
335 0x5700,0x1301,0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,
336 0x1308,0x1709,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709,
337 0x1310,0x1711,0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,
338 0x1718,0x1319,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319,
339 0x1320,0x1721,0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,
340 0x1728,0x1329,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329,
341 0x1730,0x1331,0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,
342 0x1338,0x1739,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
343 0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,
344 0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
345 0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,
346 0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
347 0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,
348 0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
349 0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,
350 0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
351 0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,
352 0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
353 0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,
354 0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
355 0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5600,0x1201,
356 0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609,
357 0x160a,0x120b,0x160c,0x120d,0x120e,0x160f,0x1210,0x1611,
358 0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219,
359 0x121a,0x161b,0x121c,0x161d,0x161e,0x121f,0x1220,0x1621,
360 0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229,
361 0x122a,0x162b,0x122c,0x162d,0x162e,0x122f,0x1630,0x1231,
362 0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639,
363 0x163a,0x123b,0x163c,0x123d,0x123e,0x163f,0x1240,0x1641,
364 0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249,
365 0x124a,0x164b,0x124c,0x164d,0x164e,0x124f,0x1650,0x1251,
366 0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659,
367 0x165a,0x125b,0x165c,0x125d,0x125e,0x165f,0x1660,0x1261,
368 0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669,
369 0x166a,0x126b,0x166c,0x126d,0x126e,0x166f,0x1270,0x1671,
370 0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279,
371 0x127a,0x167b,0x127c,0x167d,0x167e,0x127f,0x9280,0x9681,
372 0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289,
373 0x928a,0x968b,0x928c,0x968d,0x968e,0x928f,0x9690,0x9291,
374 0x9292,0x9693,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
375 0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741,
376 0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
377 0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351,
378 0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
379 0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361,
380 0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
381 0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771,
382 0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
383 0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781,
384 0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
385 0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391,
386 0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
387 0x979a,0x939b,0x979c,0x939d,0x939e,0x979f,0x97a0,0x93a1,
388 0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9,
389 0x97aa,0x93ab,0x97ac,0x93ad,0x93ae,0x97af,0x93b0,0x97b1,
390 0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9,
391 0x93ba,0x97bb,0x93bc,0x97bd,0x97be,0x93bf,0x97c0,0x93c1,
392 0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9,
393 0x97ca,0x93cb,0x97cc,0x93cd,0x93ce,0x97cf,0x93d0,0x97d1,
394 0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9,
395 0x93da,0x97db,0x93dc,0x97dd,0x97de,0x93df,0x93e0,0x97e1,
396 0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9,
397 0x93ea,0x97eb,0x93ec,0x97ed,0x97ee,0x93ef,0x97f0,0x93f1,
398 0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9,
399 0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5700,0x1301,
400 0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709,
401 0x170a,0x130b,0x170c,0x130d,0x130e,0x170f,0x1310,0x1711,
402 0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319,
403 0x131a,0x171b,0x131c,0x171d,0x171e,0x131f,0x1320,0x1721,
404 0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329,
405 0x132a,0x172b,0x132c,0x172d,0x172e,0x132f,0x1730,0x1331,
406 0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
407 0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741,
408 0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
409 0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351,
410 0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
411 0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361,
412 0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
413 0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771,
414 0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
415 0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781,
416 0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
417 0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391,
418 0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799
421 void DDFDCBHandler(UINT32 dwWhich
);
424 static void InvalidInstruction(UINT32 dwCount
)
426 pbPC
-= dwCount
; /* Invalid instruction - back up */
427 dwReturnCode
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
428 dwOriginalCycles
-= sdwCyclesRemaining
;
429 sdwCyclesRemaining
= 0;
438 sdwCyclesRemaining
-= 8;
439 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
440 bTemp2
= (cpu
.z80B
>> 7);
441 cpu
.z80B
= (cpu
.z80B
<< 1) | bTemp2
;
442 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80B
];
447 sdwCyclesRemaining
-= 8;
448 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
449 bTemp2
= (cpu
.z80C
>> 7);
450 cpu
.z80C
= (cpu
.z80C
<< 1) | bTemp2
;
451 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80C
];
456 sdwCyclesRemaining
-= 8;
457 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
458 bTemp2
= (cpu
.z80D
>> 7);
459 cpu
.z80D
= (cpu
.z80D
<< 1) | bTemp2
;
460 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80D
];
465 sdwCyclesRemaining
-= 8;
466 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
467 bTemp2
= (cpu
.z80E
>> 7);
468 cpu
.z80E
= (cpu
.z80E
<< 1) | bTemp2
;
469 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80E
];
474 sdwCyclesRemaining
-= 8;
475 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
476 bTemp2
= (cpu
.z80H
>> 7);
477 cpu
.z80H
= (cpu
.z80H
<< 1) | bTemp2
;
478 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80H
];
483 sdwCyclesRemaining
-= 8;
484 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
485 bTemp2
= (cpu
.z80L
>> 7);
486 cpu
.z80L
= (cpu
.z80L
<< 1) | bTemp2
;
487 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80L
];
492 sdwCyclesRemaining
-= 15;
493 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
494 while (psMemRead
->lowAddr
!= 0xffffffff)
496 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
498 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
499 if (psMemRead
->memoryCall
)
501 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
505 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
515 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
518 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
519 bTemp2
= (bTemp
>> 7);
520 bTemp
= (bTemp
<< 1) | bTemp2
;
521 cpu
.z80F
|= bTemp2
| bPostORFlags
[bTemp
];
522 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
523 while (psMemWrite
->lowAddr
!= 0xffffffff)
525 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
527 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
528 if (psMemWrite
->memoryCall
)
530 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
534 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
544 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
551 sdwCyclesRemaining
-= 8;
552 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
553 bTemp2
= (cpu
.z80A
>> 7);
554 cpu
.z80A
= (cpu
.z80A
<< 1) | bTemp2
;
555 cpu
.z80F
|= bTemp2
| bPostORFlags
[cpu
.z80A
];
560 sdwCyclesRemaining
-= 8;
561 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
562 cpu
.z80F
|= (cpu
.z80B
& Z80_FLAG_CARRY
);
563 cpu
.z80B
= (cpu
.z80B
>> 1) | (cpu
.z80B
<< 7);
564 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
569 sdwCyclesRemaining
-= 8;
570 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
571 cpu
.z80F
|= (cpu
.z80C
& Z80_FLAG_CARRY
);
572 cpu
.z80C
= (cpu
.z80C
>> 1) | (cpu
.z80C
<< 7);
573 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
578 sdwCyclesRemaining
-= 8;
579 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
580 cpu
.z80F
|= (cpu
.z80D
& Z80_FLAG_CARRY
);
581 cpu
.z80D
= (cpu
.z80D
>> 1) | (cpu
.z80D
<< 7);
582 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
587 sdwCyclesRemaining
-= 8;
588 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
589 cpu
.z80F
|= (cpu
.z80E
& Z80_FLAG_CARRY
);
590 cpu
.z80E
= (cpu
.z80E
>> 1) | (cpu
.z80E
<< 7);
591 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
596 sdwCyclesRemaining
-= 8;
597 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
598 cpu
.z80F
|= (cpu
.z80H
& Z80_FLAG_CARRY
);
599 cpu
.z80H
= (cpu
.z80H
>> 1) | (cpu
.z80H
<< 7);
600 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
605 sdwCyclesRemaining
-= 8;
606 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
607 cpu
.z80F
|= (cpu
.z80L
& Z80_FLAG_CARRY
);
608 cpu
.z80L
= (cpu
.z80L
>> 1) | (cpu
.z80L
<< 7);
609 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
614 sdwCyclesRemaining
-= 15;
615 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
616 while (psMemRead
->lowAddr
!= 0xffffffff)
618 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
620 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
621 if (psMemRead
->memoryCall
)
623 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
627 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
637 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
640 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
641 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
642 bTemp
= (bTemp
>> 1) | (bTemp
<< 7);
643 cpu
.z80F
|= bPostORFlags
[bTemp
];
644 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
645 while (psMemWrite
->lowAddr
!= 0xffffffff)
647 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
649 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
650 if (psMemWrite
->memoryCall
)
652 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
656 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
666 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
673 sdwCyclesRemaining
-= 8;
674 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
675 cpu
.z80F
|= (cpu
.z80A
& Z80_FLAG_CARRY
);
676 cpu
.z80A
= (cpu
.z80A
>> 1) | (cpu
.z80A
<< 7);
677 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
682 sdwCyclesRemaining
-= 8;
683 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
684 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
685 cpu
.z80F
|= (cpu
.z80B
>> 7);
686 cpu
.z80B
= (cpu
.z80B
<< 1) | bTemp2
;
687 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
692 sdwCyclesRemaining
-= 8;
693 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
694 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
695 cpu
.z80F
|= (cpu
.z80C
>> 7);
696 cpu
.z80C
= (cpu
.z80C
<< 1) | bTemp2
;
697 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
702 sdwCyclesRemaining
-= 8;
703 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
704 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
705 cpu
.z80F
|= (cpu
.z80D
>> 7);
706 cpu
.z80D
= (cpu
.z80D
<< 1) | bTemp2
;
707 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
712 sdwCyclesRemaining
-= 8;
713 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
714 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
715 cpu
.z80F
|= (cpu
.z80E
>> 7);
716 cpu
.z80E
= (cpu
.z80E
<< 1) | bTemp2
;
717 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
722 sdwCyclesRemaining
-= 8;
723 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
724 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
725 cpu
.z80F
|= (cpu
.z80H
>> 7);
726 cpu
.z80H
= (cpu
.z80H
<< 1) | bTemp2
;
727 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
732 sdwCyclesRemaining
-= 8;
733 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
734 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
735 cpu
.z80F
|= (cpu
.z80L
>> 7);
736 cpu
.z80L
= (cpu
.z80L
<< 1) | bTemp2
;
737 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
742 sdwCyclesRemaining
-= 15;
743 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
744 while (psMemRead
->lowAddr
!= 0xffffffff)
746 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
748 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
749 if (psMemRead
->memoryCall
)
751 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
755 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
765 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
768 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
769 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
770 cpu
.z80F
|= (bTemp
>> 7);
771 bTemp
= (bTemp
<< 1) | bTemp2
;
772 cpu
.z80F
|= bPostORFlags
[bTemp
];
773 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
774 while (psMemWrite
->lowAddr
!= 0xffffffff)
776 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
778 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
779 if (psMemWrite
->memoryCall
)
781 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
785 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
795 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
802 sdwCyclesRemaining
-= 8;
803 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
804 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
805 cpu
.z80F
|= (cpu
.z80A
>> 7);
806 cpu
.z80A
= (cpu
.z80A
<< 1) | bTemp2
;
807 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
812 sdwCyclesRemaining
-= 8;
813 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
814 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
815 cpu
.z80F
|= (cpu
.z80B
& Z80_FLAG_CARRY
);
816 cpu
.z80B
= (cpu
.z80B
>> 1) | bTemp2
;
817 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
822 sdwCyclesRemaining
-= 8;
823 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
824 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
825 cpu
.z80F
|= (cpu
.z80C
& Z80_FLAG_CARRY
);
826 cpu
.z80C
= (cpu
.z80C
>> 1) | bTemp2
;
827 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
832 sdwCyclesRemaining
-= 8;
833 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
834 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
835 cpu
.z80F
|= (cpu
.z80D
& Z80_FLAG_CARRY
);
836 cpu
.z80D
= (cpu
.z80D
>> 1) | bTemp2
;
837 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
842 sdwCyclesRemaining
-= 8;
843 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
844 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
845 cpu
.z80F
|= (cpu
.z80E
& Z80_FLAG_CARRY
);
846 cpu
.z80E
= (cpu
.z80E
>> 1) | bTemp2
;
847 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
852 sdwCyclesRemaining
-= 8;
853 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
854 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
855 cpu
.z80F
|= (cpu
.z80H
& Z80_FLAG_CARRY
);
856 cpu
.z80H
= (cpu
.z80H
>> 1) | bTemp2
;
857 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
862 sdwCyclesRemaining
-= 8;
863 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
864 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
865 cpu
.z80F
|= (cpu
.z80L
& Z80_FLAG_CARRY
);
866 cpu
.z80L
= (cpu
.z80L
>> 1) | bTemp2
;
867 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
872 sdwCyclesRemaining
-= 15;
873 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
874 while (psMemRead
->lowAddr
!= 0xffffffff)
876 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
878 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
879 if (psMemRead
->memoryCall
)
881 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
885 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
895 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
898 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
899 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
900 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
901 bTemp
= (bTemp
>> 1) | bTemp2
;
902 cpu
.z80F
|= bPostORFlags
[bTemp
];
903 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
904 while (psMemWrite
->lowAddr
!= 0xffffffff)
906 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
908 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
909 if (psMemWrite
->memoryCall
)
911 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
915 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
925 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
932 sdwCyclesRemaining
-= 8;
933 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
934 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
935 cpu
.z80F
|= (cpu
.z80A
& Z80_FLAG_CARRY
);
936 cpu
.z80A
= (cpu
.z80A
>> 1) | bTemp2
;
937 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
942 sdwCyclesRemaining
-= 8;
943 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
944 cpu
.z80F
|= (cpu
.z80B
>> 7);
945 cpu
.z80B
= (cpu
.z80B
<< 1);
946 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
951 sdwCyclesRemaining
-= 8;
952 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
953 cpu
.z80F
|= (cpu
.z80C
>> 7);
954 cpu
.z80C
= (cpu
.z80C
<< 1);
955 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
960 sdwCyclesRemaining
-= 8;
961 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
962 cpu
.z80F
|= (cpu
.z80D
>> 7);
963 cpu
.z80D
= (cpu
.z80D
<< 1);
964 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
969 sdwCyclesRemaining
-= 8;
970 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
971 cpu
.z80F
|= (cpu
.z80E
>> 7);
972 cpu
.z80E
= (cpu
.z80E
<< 1);
973 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
978 sdwCyclesRemaining
-= 8;
979 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
980 cpu
.z80F
|= (cpu
.z80H
>> 7);
981 cpu
.z80H
= (cpu
.z80H
<< 1);
982 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
987 sdwCyclesRemaining
-= 8;
988 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
989 cpu
.z80F
|= (cpu
.z80L
>> 7);
990 cpu
.z80L
= (cpu
.z80L
<< 1);
991 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
996 sdwCyclesRemaining
-= 15;
997 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
998 while (psMemRead
->lowAddr
!= 0xffffffff)
1000 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1002 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1003 if (psMemRead
->memoryCall
)
1005 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1009 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1019 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1022 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1023 cpu
.z80F
|= (bTemp
>> 7);
1024 bTemp
= (bTemp
<< 1);
1025 cpu
.z80F
|= bPostORFlags
[bTemp
];
1026 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
1027 while (psMemWrite
->lowAddr
!= 0xffffffff)
1029 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
1031 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1032 if (psMemWrite
->memoryCall
)
1034 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
1038 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
1048 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
1055 sdwCyclesRemaining
-= 8;
1056 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1057 cpu
.z80F
|= (cpu
.z80A
>> 7);
1058 cpu
.z80A
= (cpu
.z80A
<< 1);
1059 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
1064 sdwCyclesRemaining
-= 8;
1065 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1066 cpu
.z80F
|= (cpu
.z80B
& Z80_FLAG_CARRY
);
1067 cpu
.z80B
= (cpu
.z80B
>> 1) | (cpu
.z80B
& 0x80);
1068 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
1073 sdwCyclesRemaining
-= 8;
1074 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1075 cpu
.z80F
|= (cpu
.z80C
& Z80_FLAG_CARRY
);
1076 cpu
.z80C
= (cpu
.z80C
>> 1) | (cpu
.z80C
& 0x80);
1077 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
1082 sdwCyclesRemaining
-= 8;
1083 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1084 cpu
.z80F
|= (cpu
.z80D
& Z80_FLAG_CARRY
);
1085 cpu
.z80D
= (cpu
.z80D
>> 1) | (cpu
.z80D
& 0x80);
1086 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
1091 sdwCyclesRemaining
-= 8;
1092 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1093 cpu
.z80F
|= (cpu
.z80E
& Z80_FLAG_CARRY
);
1094 cpu
.z80E
= (cpu
.z80E
>> 1) | (cpu
.z80E
& 0x80);
1095 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
1100 sdwCyclesRemaining
-= 8;
1101 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1102 cpu
.z80F
|= (cpu
.z80H
& Z80_FLAG_CARRY
);
1103 cpu
.z80H
= (cpu
.z80H
>> 1) | (cpu
.z80H
& 0x80);
1104 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
1109 sdwCyclesRemaining
-= 8;
1110 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1111 cpu
.z80F
|= (cpu
.z80L
& Z80_FLAG_CARRY
);
1112 cpu
.z80L
= (cpu
.z80L
>> 1) | (cpu
.z80L
& 0x80);
1113 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
1118 sdwCyclesRemaining
-= 15;
1119 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1120 while (psMemRead
->lowAddr
!= 0xffffffff)
1122 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1124 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1125 if (psMemRead
->memoryCall
)
1127 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1131 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1141 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1144 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1145 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
1146 bTemp
= (bTemp
>> 1) | (bTemp
& 0x80);
1147 cpu
.z80F
|= bPostORFlags
[bTemp
];
1148 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
1149 while (psMemWrite
->lowAddr
!= 0xffffffff)
1151 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
1153 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1154 if (psMemWrite
->memoryCall
)
1156 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
1160 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
1170 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
1177 sdwCyclesRemaining
-= 8;
1178 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1179 cpu
.z80F
|= (cpu
.z80A
& Z80_FLAG_CARRY
);
1180 cpu
.z80A
= (cpu
.z80A
>> 1) | (cpu
.z80A
& 0x80);
1181 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
1186 sdwCyclesRemaining
-= 8;
1187 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1188 cpu
.z80F
|= (cpu
.z80B
>> 7);
1189 cpu
.z80B
= (cpu
.z80B
<< 1);
1190 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
1195 sdwCyclesRemaining
-= 8;
1196 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1197 cpu
.z80F
|= (cpu
.z80C
>> 7);
1198 cpu
.z80C
= (cpu
.z80C
<< 1);
1199 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
1204 sdwCyclesRemaining
-= 8;
1205 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1206 cpu
.z80F
|= (cpu
.z80D
>> 7);
1207 cpu
.z80D
= (cpu
.z80D
<< 1);
1208 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
1213 sdwCyclesRemaining
-= 8;
1214 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1215 cpu
.z80F
|= (cpu
.z80E
>> 7);
1216 cpu
.z80E
= (cpu
.z80E
<< 1);
1217 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
1222 sdwCyclesRemaining
-= 8;
1223 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1224 cpu
.z80F
|= (cpu
.z80H
>> 7);
1225 cpu
.z80H
= (cpu
.z80H
<< 1);
1226 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
1231 sdwCyclesRemaining
-= 8;
1232 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1233 cpu
.z80F
|= (cpu
.z80L
>> 7);
1234 cpu
.z80L
= (cpu
.z80L
<< 1);
1235 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
1240 sdwCyclesRemaining
-= 15;
1241 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1242 while (psMemRead
->lowAddr
!= 0xffffffff)
1244 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1246 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1247 if (psMemRead
->memoryCall
)
1249 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1253 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1263 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1266 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1267 cpu
.z80F
|= (bTemp
>> 7);
1268 bTemp
= (bTemp
<< 1);
1269 cpu
.z80F
|= bPostORFlags
[bTemp
];
1270 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
1271 while (psMemWrite
->lowAddr
!= 0xffffffff)
1273 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
1275 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1276 if (psMemWrite
->memoryCall
)
1278 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
1282 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
1292 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
1299 sdwCyclesRemaining
-= 8;
1300 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1301 cpu
.z80F
|= (cpu
.z80A
>> 7);
1302 cpu
.z80A
= (cpu
.z80A
<< 1);
1303 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
1308 sdwCyclesRemaining
-= 8;
1309 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1310 cpu
.z80F
|= (cpu
.z80B
& Z80_FLAG_CARRY
);
1311 cpu
.z80B
= (cpu
.z80B
>> 1);
1312 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
1317 sdwCyclesRemaining
-= 8;
1318 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1319 cpu
.z80F
|= (cpu
.z80C
& Z80_FLAG_CARRY
);
1320 cpu
.z80C
= (cpu
.z80C
>> 1);
1321 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
1326 sdwCyclesRemaining
-= 8;
1327 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1328 cpu
.z80F
|= (cpu
.z80D
& Z80_FLAG_CARRY
);
1329 cpu
.z80D
= (cpu
.z80D
>> 1);
1330 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
1335 sdwCyclesRemaining
-= 8;
1336 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1337 cpu
.z80F
|= (cpu
.z80E
& Z80_FLAG_CARRY
);
1338 cpu
.z80E
= (cpu
.z80E
>> 1);
1339 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
1344 sdwCyclesRemaining
-= 8;
1345 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1346 cpu
.z80F
|= (cpu
.z80H
& Z80_FLAG_CARRY
);
1347 cpu
.z80H
= (cpu
.z80H
>> 1);
1348 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
1353 sdwCyclesRemaining
-= 8;
1354 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1355 cpu
.z80F
|= (cpu
.z80L
& Z80_FLAG_CARRY
);
1356 cpu
.z80L
= (cpu
.z80L
>> 1);
1357 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
1362 sdwCyclesRemaining
-= 15;
1363 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1364 while (psMemRead
->lowAddr
!= 0xffffffff)
1366 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1368 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1369 if (psMemRead
->memoryCall
)
1371 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1375 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1385 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1388 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1389 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
1390 bTemp
= (bTemp
>> 1);
1391 cpu
.z80F
|= bPostORFlags
[bTemp
];
1392 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
1393 while (psMemWrite
->lowAddr
!= 0xffffffff)
1395 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
1397 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1398 if (psMemWrite
->memoryCall
)
1400 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
1404 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
1414 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
1421 sdwCyclesRemaining
-= 8;
1422 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
1423 cpu
.z80F
|= (cpu
.z80A
& Z80_FLAG_CARRY
);
1424 cpu
.z80A
= (cpu
.z80A
>> 1);
1425 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
1430 sdwCyclesRemaining
-= 8;
1431 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1432 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1433 if (!(cpu
.z80B
& 0x01))
1435 cpu
.z80F
|= Z80_FLAG_ZERO
;
1441 sdwCyclesRemaining
-= 8;
1442 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1443 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1444 if (!(cpu
.z80C
& 0x01))
1446 cpu
.z80F
|= Z80_FLAG_ZERO
;
1452 sdwCyclesRemaining
-= 8;
1453 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1454 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1455 if (!(cpu
.z80D
& 0x01))
1457 cpu
.z80F
|= Z80_FLAG_ZERO
;
1463 sdwCyclesRemaining
-= 8;
1464 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1465 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1466 if (!(cpu
.z80E
& 0x01))
1468 cpu
.z80F
|= Z80_FLAG_ZERO
;
1474 sdwCyclesRemaining
-= 8;
1475 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1476 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1477 if (!(cpu
.z80H
& 0x01))
1479 cpu
.z80F
|= Z80_FLAG_ZERO
;
1485 sdwCyclesRemaining
-= 8;
1486 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1487 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1488 if (!(cpu
.z80L
& 0x01))
1490 cpu
.z80F
|= Z80_FLAG_ZERO
;
1496 sdwCyclesRemaining
-= 12;
1497 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1498 while (psMemRead
->lowAddr
!= 0xffffffff)
1500 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1502 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1503 if (psMemRead
->memoryCall
)
1505 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1509 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1519 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1522 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1523 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1524 if (!(bTemp
& 0x01))
1526 cpu
.z80F
|= Z80_FLAG_ZERO
;
1532 sdwCyclesRemaining
-= 8;
1533 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1534 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1535 if (!(cpu
.z80A
& 0x01))
1537 cpu
.z80F
|= Z80_FLAG_ZERO
;
1543 sdwCyclesRemaining
-= 8;
1544 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1545 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1546 if (!(cpu
.z80B
& 0x02))
1548 cpu
.z80F
|= Z80_FLAG_ZERO
;
1554 sdwCyclesRemaining
-= 8;
1555 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1556 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1557 if (!(cpu
.z80C
& 0x02))
1559 cpu
.z80F
|= Z80_FLAG_ZERO
;
1565 sdwCyclesRemaining
-= 8;
1566 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1567 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1568 if (!(cpu
.z80D
& 0x02))
1570 cpu
.z80F
|= Z80_FLAG_ZERO
;
1576 sdwCyclesRemaining
-= 8;
1577 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1578 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1579 if (!(cpu
.z80E
& 0x02))
1581 cpu
.z80F
|= Z80_FLAG_ZERO
;
1587 sdwCyclesRemaining
-= 8;
1588 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1589 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1590 if (!(cpu
.z80H
& 0x02))
1592 cpu
.z80F
|= Z80_FLAG_ZERO
;
1598 sdwCyclesRemaining
-= 8;
1599 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1600 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1601 if (!(cpu
.z80L
& 0x02))
1603 cpu
.z80F
|= Z80_FLAG_ZERO
;
1609 sdwCyclesRemaining
-= 12;
1610 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1611 while (psMemRead
->lowAddr
!= 0xffffffff)
1613 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1615 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1616 if (psMemRead
->memoryCall
)
1618 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1622 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1632 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1635 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1636 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1637 if (!(bTemp
& 0x02))
1639 cpu
.z80F
|= Z80_FLAG_ZERO
;
1645 sdwCyclesRemaining
-= 8;
1646 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1647 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1648 if (!(cpu
.z80A
& 0x02))
1650 cpu
.z80F
|= Z80_FLAG_ZERO
;
1656 sdwCyclesRemaining
-= 8;
1657 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1658 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1659 if (!(cpu
.z80B
& 0x04))
1661 cpu
.z80F
|= Z80_FLAG_ZERO
;
1667 sdwCyclesRemaining
-= 8;
1668 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1669 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1670 if (!(cpu
.z80C
& 0x04))
1672 cpu
.z80F
|= Z80_FLAG_ZERO
;
1678 sdwCyclesRemaining
-= 8;
1679 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1680 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1681 if (!(cpu
.z80D
& 0x04))
1683 cpu
.z80F
|= Z80_FLAG_ZERO
;
1689 sdwCyclesRemaining
-= 8;
1690 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1691 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1692 if (!(cpu
.z80E
& 0x04))
1694 cpu
.z80F
|= Z80_FLAG_ZERO
;
1700 sdwCyclesRemaining
-= 8;
1701 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1702 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1703 if (!(cpu
.z80H
& 0x04))
1705 cpu
.z80F
|= Z80_FLAG_ZERO
;
1711 sdwCyclesRemaining
-= 8;
1712 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1713 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1714 if (!(cpu
.z80L
& 0x04))
1716 cpu
.z80F
|= Z80_FLAG_ZERO
;
1722 sdwCyclesRemaining
-= 12;
1723 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1724 while (psMemRead
->lowAddr
!= 0xffffffff)
1726 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1728 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1729 if (psMemRead
->memoryCall
)
1731 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1735 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1745 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1748 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1749 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1750 if (!(bTemp
& 0x04))
1752 cpu
.z80F
|= Z80_FLAG_ZERO
;
1758 sdwCyclesRemaining
-= 8;
1759 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1760 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1761 if (!(cpu
.z80A
& 0x04))
1763 cpu
.z80F
|= Z80_FLAG_ZERO
;
1769 sdwCyclesRemaining
-= 8;
1770 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1771 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1772 if (!(cpu
.z80B
& 0x08))
1774 cpu
.z80F
|= Z80_FLAG_ZERO
;
1780 sdwCyclesRemaining
-= 8;
1781 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1782 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1783 if (!(cpu
.z80C
& 0x08))
1785 cpu
.z80F
|= Z80_FLAG_ZERO
;
1791 sdwCyclesRemaining
-= 8;
1792 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1793 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1794 if (!(cpu
.z80D
& 0x08))
1796 cpu
.z80F
|= Z80_FLAG_ZERO
;
1802 sdwCyclesRemaining
-= 8;
1803 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1804 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1805 if (!(cpu
.z80E
& 0x08))
1807 cpu
.z80F
|= Z80_FLAG_ZERO
;
1813 sdwCyclesRemaining
-= 8;
1814 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1815 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1816 if (!(cpu
.z80H
& 0x08))
1818 cpu
.z80F
|= Z80_FLAG_ZERO
;
1824 sdwCyclesRemaining
-= 8;
1825 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1826 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1827 if (!(cpu
.z80L
& 0x08))
1829 cpu
.z80F
|= Z80_FLAG_ZERO
;
1835 sdwCyclesRemaining
-= 12;
1836 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1837 while (psMemRead
->lowAddr
!= 0xffffffff)
1839 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1841 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1842 if (psMemRead
->memoryCall
)
1844 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1848 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1858 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1861 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1862 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1863 if (!(bTemp
& 0x08))
1865 cpu
.z80F
|= Z80_FLAG_ZERO
;
1871 sdwCyclesRemaining
-= 8;
1872 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1873 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1874 if (!(cpu
.z80A
& 0x08))
1876 cpu
.z80F
|= Z80_FLAG_ZERO
;
1882 sdwCyclesRemaining
-= 8;
1883 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1884 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1885 if (!(cpu
.z80B
& 0x10))
1887 cpu
.z80F
|= Z80_FLAG_ZERO
;
1893 sdwCyclesRemaining
-= 8;
1894 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1895 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1896 if (!(cpu
.z80C
& 0x10))
1898 cpu
.z80F
|= Z80_FLAG_ZERO
;
1904 sdwCyclesRemaining
-= 8;
1905 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1906 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1907 if (!(cpu
.z80D
& 0x10))
1909 cpu
.z80F
|= Z80_FLAG_ZERO
;
1915 sdwCyclesRemaining
-= 8;
1916 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1917 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1918 if (!(cpu
.z80E
& 0x10))
1920 cpu
.z80F
|= Z80_FLAG_ZERO
;
1926 sdwCyclesRemaining
-= 8;
1927 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1928 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1929 if (!(cpu
.z80H
& 0x10))
1931 cpu
.z80F
|= Z80_FLAG_ZERO
;
1937 sdwCyclesRemaining
-= 8;
1938 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1939 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1940 if (!(cpu
.z80L
& 0x10))
1942 cpu
.z80F
|= Z80_FLAG_ZERO
;
1948 sdwCyclesRemaining
-= 12;
1949 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
1950 while (psMemRead
->lowAddr
!= 0xffffffff)
1952 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
1954 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
1955 if (psMemRead
->memoryCall
)
1957 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
1961 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
1971 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
1974 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1975 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1976 if (!(bTemp
& 0x10))
1978 cpu
.z80F
|= Z80_FLAG_ZERO
;
1984 sdwCyclesRemaining
-= 8;
1985 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1986 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1987 if (!(cpu
.z80A
& 0x10))
1989 cpu
.z80F
|= Z80_FLAG_ZERO
;
1995 sdwCyclesRemaining
-= 8;
1996 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
1997 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
1998 if (!(cpu
.z80B
& 0x20))
2000 cpu
.z80F
|= Z80_FLAG_ZERO
;
2006 sdwCyclesRemaining
-= 8;
2007 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2008 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2009 if (!(cpu
.z80C
& 0x20))
2011 cpu
.z80F
|= Z80_FLAG_ZERO
;
2017 sdwCyclesRemaining
-= 8;
2018 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2019 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2020 if (!(cpu
.z80D
& 0x20))
2022 cpu
.z80F
|= Z80_FLAG_ZERO
;
2028 sdwCyclesRemaining
-= 8;
2029 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2030 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2031 if (!(cpu
.z80E
& 0x20))
2033 cpu
.z80F
|= Z80_FLAG_ZERO
;
2039 sdwCyclesRemaining
-= 8;
2040 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2041 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2042 if (!(cpu
.z80H
& 0x20))
2044 cpu
.z80F
|= Z80_FLAG_ZERO
;
2050 sdwCyclesRemaining
-= 8;
2051 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2052 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2053 if (!(cpu
.z80L
& 0x20))
2055 cpu
.z80F
|= Z80_FLAG_ZERO
;
2061 sdwCyclesRemaining
-= 12;
2062 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2063 while (psMemRead
->lowAddr
!= 0xffffffff)
2065 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2067 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2068 if (psMemRead
->memoryCall
)
2070 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2074 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2084 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2087 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2088 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2089 if (!(bTemp
& 0x20))
2091 cpu
.z80F
|= Z80_FLAG_ZERO
;
2097 sdwCyclesRemaining
-= 8;
2098 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2099 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2100 if (!(cpu
.z80A
& 0x20))
2102 cpu
.z80F
|= Z80_FLAG_ZERO
;
2108 sdwCyclesRemaining
-= 8;
2109 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2110 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2111 if (!(cpu
.z80B
& 0x40))
2113 cpu
.z80F
|= Z80_FLAG_ZERO
;
2119 sdwCyclesRemaining
-= 8;
2120 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2121 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2122 if (!(cpu
.z80C
& 0x40))
2124 cpu
.z80F
|= Z80_FLAG_ZERO
;
2130 sdwCyclesRemaining
-= 8;
2131 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2132 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2133 if (!(cpu
.z80D
& 0x40))
2135 cpu
.z80F
|= Z80_FLAG_ZERO
;
2141 sdwCyclesRemaining
-= 8;
2142 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2143 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2144 if (!(cpu
.z80E
& 0x40))
2146 cpu
.z80F
|= Z80_FLAG_ZERO
;
2152 sdwCyclesRemaining
-= 8;
2153 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2154 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2155 if (!(cpu
.z80H
& 0x40))
2157 cpu
.z80F
|= Z80_FLAG_ZERO
;
2163 sdwCyclesRemaining
-= 8;
2164 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2165 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2166 if (!(cpu
.z80L
& 0x40))
2168 cpu
.z80F
|= Z80_FLAG_ZERO
;
2174 sdwCyclesRemaining
-= 12;
2175 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2176 while (psMemRead
->lowAddr
!= 0xffffffff)
2178 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2180 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2181 if (psMemRead
->memoryCall
)
2183 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2187 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2197 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2200 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2201 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2202 if (!(bTemp
& 0x40))
2204 cpu
.z80F
|= Z80_FLAG_ZERO
;
2210 sdwCyclesRemaining
-= 8;
2211 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2212 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2213 if (!(cpu
.z80A
& 0x40))
2215 cpu
.z80F
|= Z80_FLAG_ZERO
;
2221 sdwCyclesRemaining
-= 8;
2222 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2223 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2224 if (!(cpu
.z80B
& 0x80))
2226 cpu
.z80F
|= Z80_FLAG_ZERO
;
2232 sdwCyclesRemaining
-= 8;
2233 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2234 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2235 if (!(cpu
.z80C
& 0x80))
2237 cpu
.z80F
|= Z80_FLAG_ZERO
;
2243 sdwCyclesRemaining
-= 8;
2244 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2245 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2246 if (!(cpu
.z80D
& 0x80))
2248 cpu
.z80F
|= Z80_FLAG_ZERO
;
2254 sdwCyclesRemaining
-= 8;
2255 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2256 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2257 if (!(cpu
.z80E
& 0x80))
2259 cpu
.z80F
|= Z80_FLAG_ZERO
;
2265 sdwCyclesRemaining
-= 8;
2266 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2267 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2268 if (!(cpu
.z80H
& 0x80))
2270 cpu
.z80F
|= Z80_FLAG_ZERO
;
2276 sdwCyclesRemaining
-= 8;
2277 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2278 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2279 if (!(cpu
.z80L
& 0x80))
2281 cpu
.z80F
|= Z80_FLAG_ZERO
;
2287 sdwCyclesRemaining
-= 12;
2288 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2289 while (psMemRead
->lowAddr
!= 0xffffffff)
2291 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2293 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2294 if (psMemRead
->memoryCall
)
2296 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2300 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2310 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2313 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2314 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2315 if (!(bTemp
& 0x80))
2317 cpu
.z80F
|= Z80_FLAG_ZERO
;
2323 sdwCyclesRemaining
-= 8;
2324 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
);
2325 cpu
.z80F
|= (Z80_FLAG_HALF_CARRY
);
2326 if (!(cpu
.z80A
& 0x80))
2328 cpu
.z80F
|= Z80_FLAG_ZERO
;
2334 sdwCyclesRemaining
-= 8;
2340 sdwCyclesRemaining
-= 8;
2346 sdwCyclesRemaining
-= 8;
2352 sdwCyclesRemaining
-= 8;
2358 sdwCyclesRemaining
-= 8;
2364 sdwCyclesRemaining
-= 8;
2370 sdwCyclesRemaining
-= 15;
2371 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2372 while (psMemRead
->lowAddr
!= 0xffffffff)
2374 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2376 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2377 if (psMemRead
->memoryCall
)
2379 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2383 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2393 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2397 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2398 while (psMemWrite
->lowAddr
!= 0xffffffff)
2400 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2402 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2403 if (psMemWrite
->memoryCall
)
2405 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2409 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
2419 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
2426 sdwCyclesRemaining
-= 8;
2432 sdwCyclesRemaining
-= 8;
2438 sdwCyclesRemaining
-= 8;
2444 sdwCyclesRemaining
-= 8;
2450 sdwCyclesRemaining
-= 8;
2456 sdwCyclesRemaining
-= 8;
2462 sdwCyclesRemaining
-= 8;
2468 sdwCyclesRemaining
-= 15;
2469 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2470 while (psMemRead
->lowAddr
!= 0xffffffff)
2472 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2474 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2475 if (psMemRead
->memoryCall
)
2477 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2481 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2491 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2495 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2496 while (psMemWrite
->lowAddr
!= 0xffffffff)
2498 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2500 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2501 if (psMemWrite
->memoryCall
)
2503 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2507 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
2517 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
2524 sdwCyclesRemaining
-= 8;
2530 sdwCyclesRemaining
-= 8;
2536 sdwCyclesRemaining
-= 8;
2542 sdwCyclesRemaining
-= 8;
2548 sdwCyclesRemaining
-= 8;
2554 sdwCyclesRemaining
-= 8;
2560 sdwCyclesRemaining
-= 8;
2566 sdwCyclesRemaining
-= 15;
2567 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2568 while (psMemRead
->lowAddr
!= 0xffffffff)
2570 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2572 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2573 if (psMemRead
->memoryCall
)
2575 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2579 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2589 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2593 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2594 while (psMemWrite
->lowAddr
!= 0xffffffff)
2596 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2598 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2599 if (psMemWrite
->memoryCall
)
2601 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2605 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
2615 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
2622 sdwCyclesRemaining
-= 8;
2628 sdwCyclesRemaining
-= 8;
2634 sdwCyclesRemaining
-= 8;
2640 sdwCyclesRemaining
-= 8;
2646 sdwCyclesRemaining
-= 8;
2652 sdwCyclesRemaining
-= 8;
2658 sdwCyclesRemaining
-= 8;
2664 sdwCyclesRemaining
-= 15;
2665 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2666 while (psMemRead
->lowAddr
!= 0xffffffff)
2668 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2670 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2671 if (psMemRead
->memoryCall
)
2673 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2677 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2687 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2691 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2692 while (psMemWrite
->lowAddr
!= 0xffffffff)
2694 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2696 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2697 if (psMemWrite
->memoryCall
)
2699 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2703 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
2713 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
2720 sdwCyclesRemaining
-= 8;
2726 sdwCyclesRemaining
-= 8;
2732 sdwCyclesRemaining
-= 8;
2738 sdwCyclesRemaining
-= 8;
2744 sdwCyclesRemaining
-= 8;
2750 sdwCyclesRemaining
-= 8;
2756 sdwCyclesRemaining
-= 8;
2762 sdwCyclesRemaining
-= 15;
2763 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2764 while (psMemRead
->lowAddr
!= 0xffffffff)
2766 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2768 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2769 if (psMemRead
->memoryCall
)
2771 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2775 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2785 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2789 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2790 while (psMemWrite
->lowAddr
!= 0xffffffff)
2792 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2794 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2795 if (psMemWrite
->memoryCall
)
2797 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2801 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
2811 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
2818 sdwCyclesRemaining
-= 8;
2824 sdwCyclesRemaining
-= 8;
2830 sdwCyclesRemaining
-= 8;
2836 sdwCyclesRemaining
-= 8;
2842 sdwCyclesRemaining
-= 8;
2848 sdwCyclesRemaining
-= 8;
2854 sdwCyclesRemaining
-= 8;
2860 sdwCyclesRemaining
-= 15;
2861 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2862 while (psMemRead
->lowAddr
!= 0xffffffff)
2864 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2866 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2867 if (psMemRead
->memoryCall
)
2869 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2873 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2883 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2887 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2888 while (psMemWrite
->lowAddr
!= 0xffffffff)
2890 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2892 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2893 if (psMemWrite
->memoryCall
)
2895 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2899 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
2909 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
2916 sdwCyclesRemaining
-= 8;
2922 sdwCyclesRemaining
-= 8;
2928 sdwCyclesRemaining
-= 8;
2934 sdwCyclesRemaining
-= 8;
2940 sdwCyclesRemaining
-= 8;
2946 sdwCyclesRemaining
-= 8;
2952 sdwCyclesRemaining
-= 8;
2958 sdwCyclesRemaining
-= 15;
2959 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
2960 while (psMemRead
->lowAddr
!= 0xffffffff)
2962 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
2964 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2965 if (psMemRead
->memoryCall
)
2967 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
2971 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
2981 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
2985 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
2986 while (psMemWrite
->lowAddr
!= 0xffffffff)
2988 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
2990 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
2991 if (psMemWrite
->memoryCall
)
2993 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
2997 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3007 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3014 sdwCyclesRemaining
-= 8;
3020 sdwCyclesRemaining
-= 8;
3026 sdwCyclesRemaining
-= 8;
3032 sdwCyclesRemaining
-= 8;
3038 sdwCyclesRemaining
-= 8;
3044 sdwCyclesRemaining
-= 8;
3050 sdwCyclesRemaining
-= 8;
3056 sdwCyclesRemaining
-= 15;
3057 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3058 while (psMemRead
->lowAddr
!= 0xffffffff)
3060 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3062 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3063 if (psMemRead
->memoryCall
)
3065 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3069 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3079 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3083 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3084 while (psMemWrite
->lowAddr
!= 0xffffffff)
3086 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3088 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3089 if (psMemWrite
->memoryCall
)
3091 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3095 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3105 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3112 sdwCyclesRemaining
-= 8;
3118 sdwCyclesRemaining
-= 8;
3124 sdwCyclesRemaining
-= 8;
3130 sdwCyclesRemaining
-= 8;
3136 sdwCyclesRemaining
-= 8;
3142 sdwCyclesRemaining
-= 8;
3148 sdwCyclesRemaining
-= 8;
3154 sdwCyclesRemaining
-= 15;
3155 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3156 while (psMemRead
->lowAddr
!= 0xffffffff)
3158 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3160 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3161 if (psMemRead
->memoryCall
)
3163 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3167 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3177 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3181 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3182 while (psMemWrite
->lowAddr
!= 0xffffffff)
3184 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3186 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3187 if (psMemWrite
->memoryCall
)
3189 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3193 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3203 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3210 sdwCyclesRemaining
-= 8;
3216 sdwCyclesRemaining
-= 8;
3222 sdwCyclesRemaining
-= 8;
3228 sdwCyclesRemaining
-= 8;
3234 sdwCyclesRemaining
-= 8;
3240 sdwCyclesRemaining
-= 8;
3246 sdwCyclesRemaining
-= 8;
3252 sdwCyclesRemaining
-= 15;
3253 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3254 while (psMemRead
->lowAddr
!= 0xffffffff)
3256 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3258 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3259 if (psMemRead
->memoryCall
)
3261 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3265 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3275 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3279 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3280 while (psMemWrite
->lowAddr
!= 0xffffffff)
3282 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3284 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3285 if (psMemWrite
->memoryCall
)
3287 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3291 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3301 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3308 sdwCyclesRemaining
-= 8;
3314 sdwCyclesRemaining
-= 8;
3320 sdwCyclesRemaining
-= 8;
3326 sdwCyclesRemaining
-= 8;
3332 sdwCyclesRemaining
-= 8;
3338 sdwCyclesRemaining
-= 8;
3344 sdwCyclesRemaining
-= 8;
3350 sdwCyclesRemaining
-= 15;
3351 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3352 while (psMemRead
->lowAddr
!= 0xffffffff)
3354 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3356 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3357 if (psMemRead
->memoryCall
)
3359 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3363 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3373 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3377 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3378 while (psMemWrite
->lowAddr
!= 0xffffffff)
3380 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3382 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3383 if (psMemWrite
->memoryCall
)
3385 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3389 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3399 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3406 sdwCyclesRemaining
-= 8;
3412 sdwCyclesRemaining
-= 8;
3418 sdwCyclesRemaining
-= 8;
3424 sdwCyclesRemaining
-= 8;
3430 sdwCyclesRemaining
-= 8;
3436 sdwCyclesRemaining
-= 8;
3442 sdwCyclesRemaining
-= 8;
3448 sdwCyclesRemaining
-= 15;
3449 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3450 while (psMemRead
->lowAddr
!= 0xffffffff)
3452 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3454 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3455 if (psMemRead
->memoryCall
)
3457 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3461 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3471 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3475 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3476 while (psMemWrite
->lowAddr
!= 0xffffffff)
3478 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3480 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3481 if (psMemWrite
->memoryCall
)
3483 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3487 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3497 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3504 sdwCyclesRemaining
-= 8;
3510 sdwCyclesRemaining
-= 8;
3516 sdwCyclesRemaining
-= 8;
3522 sdwCyclesRemaining
-= 8;
3528 sdwCyclesRemaining
-= 8;
3534 sdwCyclesRemaining
-= 8;
3540 sdwCyclesRemaining
-= 8;
3546 sdwCyclesRemaining
-= 15;
3547 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3548 while (psMemRead
->lowAddr
!= 0xffffffff)
3550 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3552 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3553 if (psMemRead
->memoryCall
)
3555 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3559 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3569 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3573 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3574 while (psMemWrite
->lowAddr
!= 0xffffffff)
3576 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3578 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3579 if (psMemWrite
->memoryCall
)
3581 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3585 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3595 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3602 sdwCyclesRemaining
-= 8;
3608 sdwCyclesRemaining
-= 8;
3614 sdwCyclesRemaining
-= 8;
3620 sdwCyclesRemaining
-= 8;
3626 sdwCyclesRemaining
-= 8;
3632 sdwCyclesRemaining
-= 8;
3638 sdwCyclesRemaining
-= 8;
3644 sdwCyclesRemaining
-= 15;
3645 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3646 while (psMemRead
->lowAddr
!= 0xffffffff)
3648 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3650 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3651 if (psMemRead
->memoryCall
)
3653 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3657 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3667 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3671 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3672 while (psMemWrite
->lowAddr
!= 0xffffffff)
3674 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3676 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3677 if (psMemWrite
->memoryCall
)
3679 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3683 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3693 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3700 sdwCyclesRemaining
-= 8;
3706 sdwCyclesRemaining
-= 8;
3712 sdwCyclesRemaining
-= 8;
3718 sdwCyclesRemaining
-= 8;
3724 sdwCyclesRemaining
-= 8;
3730 sdwCyclesRemaining
-= 8;
3736 sdwCyclesRemaining
-= 8;
3742 sdwCyclesRemaining
-= 15;
3743 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3744 while (psMemRead
->lowAddr
!= 0xffffffff)
3746 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3748 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3749 if (psMemRead
->memoryCall
)
3751 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3755 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3765 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3769 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3770 while (psMemWrite
->lowAddr
!= 0xffffffff)
3772 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3774 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3775 if (psMemWrite
->memoryCall
)
3777 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3781 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3791 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3798 sdwCyclesRemaining
-= 8;
3804 sdwCyclesRemaining
-= 8;
3810 sdwCyclesRemaining
-= 8;
3816 sdwCyclesRemaining
-= 8;
3822 sdwCyclesRemaining
-= 8;
3828 sdwCyclesRemaining
-= 8;
3834 sdwCyclesRemaining
-= 8;
3840 sdwCyclesRemaining
-= 15;
3841 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
3842 while (psMemRead
->lowAddr
!= 0xffffffff)
3844 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
3846 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3847 if (psMemRead
->memoryCall
)
3849 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
3853 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
3863 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
3867 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
3868 while (psMemWrite
->lowAddr
!= 0xffffffff)
3870 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
3872 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
3873 if (psMemWrite
->memoryCall
)
3875 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
3879 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
3889 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
3896 sdwCyclesRemaining
-= 8;
3902 void EDHandler(void)
3908 InvalidInstruction(2);
3913 InvalidInstruction(2);
3918 InvalidInstruction(2);
3923 InvalidInstruction(2);
3928 InvalidInstruction(2);
3933 InvalidInstruction(2);
3938 InvalidInstruction(2);
3943 InvalidInstruction(2);
3948 InvalidInstruction(2);
3953 InvalidInstruction(2);
3958 InvalidInstruction(2);
3963 InvalidInstruction(2);
3968 InvalidInstruction(2);
3973 InvalidInstruction(2);
3978 InvalidInstruction(2);
3983 InvalidInstruction(2);
3988 InvalidInstruction(2);
3993 InvalidInstruction(2);
3998 InvalidInstruction(2);
4003 InvalidInstruction(2);
4008 InvalidInstruction(2);
4013 InvalidInstruction(2);
4018 InvalidInstruction(2);
4023 InvalidInstruction(2);
4028 InvalidInstruction(2);
4033 InvalidInstruction(2);
4038 InvalidInstruction(2);
4043 InvalidInstruction(2);
4048 InvalidInstruction(2);
4053 InvalidInstruction(2);
4058 InvalidInstruction(2);
4063 InvalidInstruction(2);
4068 InvalidInstruction(2);
4073 InvalidInstruction(2);
4078 InvalidInstruction(2);
4083 InvalidInstruction(2);
4088 InvalidInstruction(2);
4093 InvalidInstruction(2);
4098 InvalidInstruction(2);
4103 InvalidInstruction(2);
4108 InvalidInstruction(2);
4113 InvalidInstruction(2);
4118 InvalidInstruction(2);
4123 InvalidInstruction(2);
4128 InvalidInstruction(2);
4133 InvalidInstruction(2);
4138 InvalidInstruction(2);
4143 InvalidInstruction(2);
4148 InvalidInstruction(2);
4153 InvalidInstruction(2);
4158 InvalidInstruction(2);
4163 InvalidInstruction(2);
4168 InvalidInstruction(2);
4173 InvalidInstruction(2);
4178 InvalidInstruction(2);
4183 InvalidInstruction(2);
4188 InvalidInstruction(2);
4193 InvalidInstruction(2);
4198 InvalidInstruction(2);
4203 InvalidInstruction(2);
4208 InvalidInstruction(2);
4213 InvalidInstruction(2);
4218 InvalidInstruction(2);
4223 InvalidInstruction(2);
4228 sdwCyclesRemaining
-= 12;
4230 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
4231 while (psIoRead
->lowIoAddr
!= 0xffff)
4233 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
4235 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4236 cpu
.z80B
= psIoRead
->IOCall(dwAddr
, psIoRead
);
4245 cpu
.z80B
= 0xff; /* Unclaimed I/O read */
4248 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4249 cpu
.z80F
|= bPostORFlags
[cpu
.z80B
];
4254 sdwCyclesRemaining
-= 12;
4256 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
4257 while (psIoWrite
->lowIoAddr
!= 0xffff)
4259 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
4261 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4262 psIoWrite
->IOCall(dwAddr
, cpu
.z80B
, psIoWrite
);
4273 sdwCyclesRemaining
-= 15;
4274 dwTemp
= cpu
.z80HL
- cpu
.z80BC
- (cpu
.z80F
& Z80_FLAG_CARRY
);
4275 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4276 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
4277 if (0 == (dwTemp
& 0xffff))
4279 cpu
.z80F
|= Z80_FLAG_ZERO
;
4281 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80BC
) >> 8) & Z80_FLAG_HALF_CARRY
);
4282 cpu
.z80F
|= ((((cpu
.z80BC
^ cpu
.z80HL
) & (cpu
.z80BC
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
4283 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
4284 cpu
.z80HL
= dwTemp
& 0xffff;
4289 sdwCyclesRemaining
-= 20;
4291 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
4292 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
4293 while (psMemWrite
->lowAddr
!= 0xffffffff)
4295 if ((dwTemp
>= psMemWrite
->lowAddr
) && (dwTemp
<= psMemWrite
->highAddr
))
4297 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4298 if (psMemWrite
->memoryCall
)
4300 psMemWrite
->memoryCall(dwTemp
, (cpu
.z80BC
& 0xff), psMemWrite
);
4301 psMemWrite
->memoryCall(dwTemp
+ 1, (cpu
.z80BC
>> 8), psMemWrite
);
4305 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
)) = cpu
.z80BC
;
4306 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80BC
>> 8;
4316 cpu
.z80Base
[dwTemp
] = (UINT8
) cpu
.z80BC
;
4317 cpu
.z80Base
[dwTemp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80BC
>> 8);
4324 sdwCyclesRemaining
-= 8;
4325 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
4326 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
4327 pbSubSbcTable
[((UINT32
) 0 << 8) | cpu
.z80A
];
4328 cpu
.z80A
= 0 - cpu
.z80A
;
4333 sdwCyclesRemaining
-= 14;
4334 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
4335 dwAddr
= *pbSP
++; /* Pop LSB */
4336 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
4337 cpu
.z80sp
+= 2; /* Pop the word off */
4338 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
4339 cpu
.z80iff
&= ~(IFF1
); /* Keep IFF2 around */
4340 cpu
.z80iff
|= ((cpu
.z80iff
>> 1) & IFF1
); /* IFF2->IFF1 */
4345 sdwCyclesRemaining
-= 8;
4346 cpu
.z80interruptMode
= 0;
4351 sdwCyclesRemaining
-= 9;
4352 cpu
.z80i
= cpu
.z80A
;
4357 sdwCyclesRemaining
-= 12;
4359 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
4360 while (psIoRead
->lowIoAddr
!= 0xffff)
4362 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
4364 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4365 cpu
.z80C
= psIoRead
->IOCall(dwAddr
, psIoRead
);
4374 cpu
.z80C
= 0xff; /* Unclaimed I/O read */
4377 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4378 cpu
.z80F
|= bPostORFlags
[cpu
.z80C
];
4383 sdwCyclesRemaining
-= 12;
4385 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
4386 while (psIoWrite
->lowIoAddr
!= 0xffff)
4388 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
4390 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4391 psIoWrite
->IOCall(dwAddr
, cpu
.z80C
, psIoWrite
);
4402 sdwCyclesRemaining
-= 15;
4403 dwTemp
= cpu
.z80HL
+ cpu
.z80BC
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
4404 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4405 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
4406 if (0 == (dwTemp
& 0xffff))
4408 cpu
.z80F
|= Z80_FLAG_ZERO
;
4410 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80BC
) >> 8) & Z80_FLAG_HALF_CARRY
);
4411 cpu
.z80F
|= ((((cpu
.z80BC
^ cpu
.z80HL
^ 0x8000) & (cpu
.z80BC
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
4412 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
4413 cpu
.z80HL
= dwTemp
& 0xffff;
4418 sdwCyclesRemaining
-= 20;
4420 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
4421 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
4422 while (psMemRead
->lowAddr
!= 0xffffffff)
4424 if ((dwTemp
>= psMemRead
->lowAddr
) && (dwTemp
<= psMemRead
->highAddr
))
4426 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4427 if (psMemRead
->memoryCall
)
4429 cpu
.z80BC
= psMemRead
->memoryCall(dwTemp
, psMemRead
);
4430 cpu
.z80BC
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(dwTemp
+ 1, psMemRead
) << 8);
4434 cpu
.z80BC
= *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
));
4435 cpu
.z80BC
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
+ 1)) << 8);
4445 cpu
.z80BC
= cpu
.z80Base
[dwTemp
];
4446 cpu
.z80BC
|= (UINT32
) ((UINT32
) cpu
.z80Base
[dwTemp
+ 1] << 8);
4453 sdwCyclesRemaining
-= 8;
4454 InvalidInstruction(2);
4459 sdwCyclesRemaining
-= 14;
4460 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
4461 dwAddr
= *pbSP
++; /* Pop LSB */
4462 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
4463 cpu
.z80sp
+= 2; /* Pop the word off */
4464 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
4469 sdwCyclesRemaining
-= 8;
4470 InvalidInstruction(2);
4475 sdwCyclesRemaining
-= 9;
4476 cpu
.z80r
= cpu
.z80A
;
4481 sdwCyclesRemaining
-= 12;
4483 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
4484 while (psIoRead
->lowIoAddr
!= 0xffff)
4486 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
4488 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4489 cpu
.z80D
= psIoRead
->IOCall(dwAddr
, psIoRead
);
4498 cpu
.z80D
= 0xff; /* Unclaimed I/O read */
4501 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4502 cpu
.z80F
|= bPostORFlags
[cpu
.z80D
];
4507 sdwCyclesRemaining
-= 12;
4509 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
4510 while (psIoWrite
->lowIoAddr
!= 0xffff)
4512 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
4514 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4515 psIoWrite
->IOCall(dwAddr
, cpu
.z80D
, psIoWrite
);
4526 sdwCyclesRemaining
-= 15;
4527 dwTemp
= cpu
.z80HL
- cpu
.z80DE
- (cpu
.z80F
& Z80_FLAG_CARRY
);
4528 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4529 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
4530 if (0 == (dwTemp
& 0xffff))
4532 cpu
.z80F
|= Z80_FLAG_ZERO
;
4534 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80DE
) >> 8) & Z80_FLAG_HALF_CARRY
);
4535 cpu
.z80F
|= ((((cpu
.z80DE
^ cpu
.z80HL
) & (cpu
.z80DE
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
4536 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
4537 cpu
.z80HL
= dwTemp
& 0xffff;
4542 sdwCyclesRemaining
-= 20;
4544 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
4545 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
4546 while (psMemWrite
->lowAddr
!= 0xffffffff)
4548 if ((dwTemp
>= psMemWrite
->lowAddr
) && (dwTemp
<= psMemWrite
->highAddr
))
4550 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4551 if (psMemWrite
->memoryCall
)
4553 psMemWrite
->memoryCall(dwTemp
, (cpu
.z80DE
& 0xff), psMemWrite
);
4554 psMemWrite
->memoryCall(dwTemp
+ 1, (cpu
.z80DE
>> 8), psMemWrite
);
4558 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
)) = cpu
.z80DE
;
4559 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80DE
>> 8;
4569 cpu
.z80Base
[dwTemp
] = (UINT8
) cpu
.z80DE
;
4570 cpu
.z80Base
[dwTemp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80DE
>> 8);
4577 sdwCyclesRemaining
-= 8;
4578 InvalidInstruction(2);
4583 sdwCyclesRemaining
-= 8;
4584 InvalidInstruction(2);
4589 sdwCyclesRemaining
-= 8;
4590 cpu
.z80interruptMode
= 1;
4591 cpu
.z80intAddr
= 0x38;
4596 sdwCyclesRemaining
-= 9;
4597 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4598 cpu
.z80F
|= ((cpu
.z80iff
& IFF2
) << 1);
4599 cpu
.z80A
= cpu
.z80i
;
4600 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
4605 sdwCyclesRemaining
-= 12;
4607 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
4608 while (psIoRead
->lowIoAddr
!= 0xffff)
4610 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
4612 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4613 cpu
.z80E
= psIoRead
->IOCall(dwAddr
, psIoRead
);
4622 cpu
.z80E
= 0xff; /* Unclaimed I/O read */
4625 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4626 cpu
.z80F
|= bPostORFlags
[cpu
.z80E
];
4631 sdwCyclesRemaining
-= 12;
4633 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
4634 while (psIoWrite
->lowIoAddr
!= 0xffff)
4636 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
4638 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4639 psIoWrite
->IOCall(dwAddr
, cpu
.z80E
, psIoWrite
);
4650 sdwCyclesRemaining
-= 15;
4651 dwTemp
= cpu
.z80HL
+ cpu
.z80DE
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
4652 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4653 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
4654 if (0 == (dwTemp
& 0xffff))
4656 cpu
.z80F
|= Z80_FLAG_ZERO
;
4658 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80DE
) >> 8) & Z80_FLAG_HALF_CARRY
);
4659 cpu
.z80F
|= ((((cpu
.z80DE
^ cpu
.z80HL
^ 0x8000) & (cpu
.z80DE
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
4660 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
4661 cpu
.z80HL
= dwTemp
& 0xffff;
4666 sdwCyclesRemaining
-= 20;
4668 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
4669 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
4670 while (psMemRead
->lowAddr
!= 0xffffffff)
4672 if ((dwTemp
>= psMemRead
->lowAddr
) && (dwTemp
<= psMemRead
->highAddr
))
4674 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4675 if (psMemRead
->memoryCall
)
4677 cpu
.z80DE
= psMemRead
->memoryCall(dwTemp
, psMemRead
);
4678 cpu
.z80DE
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(dwTemp
+ 1, psMemRead
) << 8);
4682 cpu
.z80DE
= *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
));
4683 cpu
.z80DE
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
+ 1)) << 8);
4693 cpu
.z80DE
= cpu
.z80Base
[dwTemp
];
4694 cpu
.z80DE
|= (UINT32
) ((UINT32
) cpu
.z80Base
[dwTemp
+ 1] << 8);
4701 sdwCyclesRemaining
-= 8;
4702 InvalidInstruction(2);
4707 sdwCyclesRemaining
-= 8;
4708 InvalidInstruction(2);
4713 sdwCyclesRemaining
-= 8;
4714 cpu
.z80interruptMode
= 2;
4719 sdwCyclesRemaining
-= 9;
4720 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4721 cpu
.z80F
|= bPostORFlags
[cpu
.z80r
];
4722 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_OVERFLOW_PARITY
)) | ((cpu
.z80iff
& IFF2
) << 1);
4723 cpu
.z80A
= cpu
.z80r
;
4724 bTemp
= (cpu
.z80r
+ (cpu
.z80B
+ sdwCyclesRemaining
+ 1 + cpu
.z80H
)) ^ cpu
.z80A
;
4725 cpu
.z80r
= (cpu
.z80r
& 0x80) | (bTemp
& 0x7f);
4730 sdwCyclesRemaining
-= 12;
4732 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
4733 while (psIoRead
->lowIoAddr
!= 0xffff)
4735 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
4737 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4738 cpu
.z80H
= psIoRead
->IOCall(dwAddr
, psIoRead
);
4747 cpu
.z80H
= 0xff; /* Unclaimed I/O read */
4750 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4751 cpu
.z80F
|= bPostORFlags
[cpu
.z80H
];
4756 sdwCyclesRemaining
-= 12;
4758 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
4759 while (psIoWrite
->lowIoAddr
!= 0xffff)
4761 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
4763 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4764 psIoWrite
->IOCall(dwAddr
, cpu
.z80H
, psIoWrite
);
4775 sdwCyclesRemaining
-= 15;
4776 dwTemp
= cpu
.z80HL
- cpu
.z80HL
- (cpu
.z80F
& Z80_FLAG_CARRY
);
4777 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4778 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
4779 if (0 == (dwTemp
& 0xffff))
4781 cpu
.z80F
|= Z80_FLAG_ZERO
;
4783 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80HL
) >> 8) & Z80_FLAG_HALF_CARRY
);
4784 cpu
.z80F
|= ((((cpu
.z80HL
^ cpu
.z80HL
) & (cpu
.z80HL
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
4785 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
4786 cpu
.z80HL
= dwTemp
& 0xffff;
4791 sdwCyclesRemaining
-= 20;
4793 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
4794 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
4795 while (psMemWrite
->lowAddr
!= 0xffffffff)
4797 if ((dwTemp
>= psMemWrite
->lowAddr
) && (dwTemp
<= psMemWrite
->highAddr
))
4799 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4800 if (psMemWrite
->memoryCall
)
4802 psMemWrite
->memoryCall(dwTemp
, (cpu
.z80HL
& 0xff), psMemWrite
);
4803 psMemWrite
->memoryCall(dwTemp
+ 1, (cpu
.z80HL
>> 8), psMemWrite
);
4807 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
)) = cpu
.z80HL
;
4808 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80HL
>> 8;
4818 cpu
.z80Base
[dwTemp
] = (UINT8
) cpu
.z80HL
;
4819 cpu
.z80Base
[dwTemp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80HL
>> 8);
4826 sdwCyclesRemaining
-= 8;
4827 InvalidInstruction(2);
4832 sdwCyclesRemaining
-= 8;
4833 InvalidInstruction(2);
4838 sdwCyclesRemaining
-= 8;
4839 InvalidInstruction(2);
4844 sdwCyclesRemaining
-= 18;
4845 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
4846 while (psMemRead
->lowAddr
!= 0xffffffff)
4848 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
4850 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4851 if (psMemRead
->memoryCall
)
4853 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
4857 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
4867 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
4870 bTemp2
= (cpu
.z80A
& 0x0f) << 4;
4871 cpu
.z80A
= (cpu
.z80A
& 0xf0) | (bTemp
& 0x0f);
4872 bTemp
= (bTemp
>> 4) | bTemp2
;
4873 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
4874 while (psMemWrite
->lowAddr
!= 0xffffffff)
4876 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
4878 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4879 if (psMemWrite
->memoryCall
)
4881 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
4885 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
4895 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
4898 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4899 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
4904 sdwCyclesRemaining
-= 12;
4906 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
4907 while (psIoRead
->lowIoAddr
!= 0xffff)
4909 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
4911 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4912 cpu
.z80L
= psIoRead
->IOCall(dwAddr
, psIoRead
);
4921 cpu
.z80L
= 0xff; /* Unclaimed I/O read */
4924 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
4925 cpu
.z80F
|= bPostORFlags
[cpu
.z80L
];
4930 sdwCyclesRemaining
-= 12;
4932 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
4933 while (psIoWrite
->lowIoAddr
!= 0xffff)
4935 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
4937 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4938 psIoWrite
->IOCall(dwAddr
, cpu
.z80L
, psIoWrite
);
4949 sdwCyclesRemaining
-= 15;
4950 dwTemp
= cpu
.z80HL
+ cpu
.z80HL
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
4951 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
4952 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
4953 if (0 == (dwTemp
& 0xffff))
4955 cpu
.z80F
|= Z80_FLAG_ZERO
;
4957 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80HL
) >> 8) & Z80_FLAG_HALF_CARRY
);
4958 cpu
.z80F
|= ((((cpu
.z80HL
^ cpu
.z80HL
^ 0x8000) & (cpu
.z80HL
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
4959 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
4960 cpu
.z80HL
= dwTemp
& 0xffff;
4965 sdwCyclesRemaining
-= 20;
4966 InvalidInstruction(2);
4971 sdwCyclesRemaining
-= 8;
4972 InvalidInstruction(2);
4977 sdwCyclesRemaining
-= 8;
4978 InvalidInstruction(2);
4983 sdwCyclesRemaining
-= 8;
4984 InvalidInstruction(2);
4989 sdwCyclesRemaining
-= 18;
4990 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
4991 while (psMemRead
->lowAddr
!= 0xffffffff)
4993 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
4995 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
4996 if (psMemRead
->memoryCall
)
4998 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5002 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5012 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5015 bTemp2
= (cpu
.z80A
& 0x0f);
5016 cpu
.z80A
= (cpu
.z80A
& 0xf0) | (bTemp
>> 4);
5017 bTemp
= (bTemp
<< 4) | bTemp2
;
5018 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5019 while (psMemWrite
->lowAddr
!= 0xffffffff)
5021 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
5023 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5024 if (psMemWrite
->memoryCall
)
5026 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
5030 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
5040 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
5043 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5044 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
5049 sdwCyclesRemaining
-= 12;
5050 InvalidInstruction(2);
5055 sdwCyclesRemaining
-= 12;
5056 InvalidInstruction(2);
5061 sdwCyclesRemaining
-= 15;
5062 dwTemp
= cpu
.z80HL
- cpu
.z80sp
- (cpu
.z80F
& Z80_FLAG_CARRY
);
5063 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
5064 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
5065 if (0 == (dwTemp
& 0xffff))
5067 cpu
.z80F
|= Z80_FLAG_ZERO
;
5069 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80sp
) >> 8) & Z80_FLAG_HALF_CARRY
);
5070 cpu
.z80F
|= ((((cpu
.z80sp
^ cpu
.z80HL
) & (cpu
.z80sp
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
5071 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
5072 cpu
.z80HL
= dwTemp
& 0xffff;
5077 sdwCyclesRemaining
-= 20;
5079 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
5080 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5081 while (psMemWrite
->lowAddr
!= 0xffffffff)
5083 if ((dwTemp
>= psMemWrite
->lowAddr
) && (dwTemp
<= psMemWrite
->highAddr
))
5085 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5086 if (psMemWrite
->memoryCall
)
5088 psMemWrite
->memoryCall(dwTemp
, (cpu
.z80sp
& 0xff), psMemWrite
);
5089 psMemWrite
->memoryCall(dwTemp
+ 1, (cpu
.z80sp
>> 8), psMemWrite
);
5093 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
)) = cpu
.z80sp
;
5094 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80sp
>> 8;
5104 cpu
.z80Base
[dwTemp
] = (UINT8
) cpu
.z80sp
;
5105 cpu
.z80Base
[dwTemp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80sp
>> 8);
5112 sdwCyclesRemaining
-= 8;
5113 InvalidInstruction(2);
5118 sdwCyclesRemaining
-= 8;
5119 InvalidInstruction(2);
5124 sdwCyclesRemaining
-= 8;
5125 InvalidInstruction(2);
5130 InvalidInstruction(2);
5135 sdwCyclesRemaining
-= 12;
5137 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
5138 while (psIoRead
->lowIoAddr
!= 0xffff)
5140 if ((dwAddr
>= psIoRead
->lowIoAddr
) && (dwAddr
<= psIoRead
->highIoAddr
))
5142 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5143 cpu
.z80A
= psIoRead
->IOCall(dwAddr
, psIoRead
);
5152 cpu
.z80A
= 0xff; /* Unclaimed I/O read */
5155 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5156 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
5161 sdwCyclesRemaining
-= 12;
5163 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
5164 while (psIoWrite
->lowIoAddr
!= 0xffff)
5166 if ((dwAddr
>= psIoWrite
->lowIoAddr
) && (dwAddr
<= psIoWrite
->highIoAddr
))
5168 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5169 psIoWrite
->IOCall(dwAddr
, cpu
.z80A
, psIoWrite
);
5180 sdwCyclesRemaining
-= 15;
5181 dwTemp
= cpu
.z80HL
+ cpu
.z80sp
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
5182 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
5183 cpu
.z80F
|= ((dwTemp
>> 8) & Z80_FLAG_SIGN
);
5184 if (0 == (dwTemp
& 0xffff))
5186 cpu
.z80F
|= Z80_FLAG_ZERO
;
5188 cpu
.z80F
|= (((cpu
.z80HL
^ dwTemp
^ cpu
.z80sp
) >> 8) & Z80_FLAG_HALF_CARRY
);
5189 cpu
.z80F
|= ((((cpu
.z80sp
^ cpu
.z80HL
^ 0x8000) & (cpu
.z80sp
^ dwTemp
)) >> 13) & Z80_FLAG_OVERFLOW_PARITY
);
5190 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
);
5191 cpu
.z80HL
= dwTemp
& 0xffff;
5196 sdwCyclesRemaining
-= 20;
5198 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
5199 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5200 while (psMemRead
->lowAddr
!= 0xffffffff)
5202 if ((dwTemp
>= psMemRead
->lowAddr
) && (dwTemp
<= psMemRead
->highAddr
))
5204 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5205 if (psMemRead
->memoryCall
)
5207 cpu
.z80sp
= psMemRead
->memoryCall(dwTemp
, psMemRead
);
5208 cpu
.z80sp
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(dwTemp
+ 1, psMemRead
) << 8);
5212 cpu
.z80sp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
));
5213 cpu
.z80sp
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
+ 1)) << 8);
5223 cpu
.z80sp
= cpu
.z80Base
[dwTemp
];
5224 cpu
.z80sp
|= (UINT32
) ((UINT32
) cpu
.z80Base
[dwTemp
+ 1] << 8);
5231 sdwCyclesRemaining
-= 8;
5232 InvalidInstruction(2);
5237 sdwCyclesRemaining
-= 8;
5238 InvalidInstruction(2);
5243 sdwCyclesRemaining
-= 8;
5244 InvalidInstruction(2);
5249 InvalidInstruction(2);
5254 InvalidInstruction(2);
5259 InvalidInstruction(2);
5264 InvalidInstruction(2);
5269 InvalidInstruction(2);
5274 InvalidInstruction(2);
5279 InvalidInstruction(2);
5284 InvalidInstruction(2);
5289 InvalidInstruction(2);
5294 InvalidInstruction(2);
5299 InvalidInstruction(2);
5304 InvalidInstruction(2);
5309 InvalidInstruction(2);
5314 InvalidInstruction(2);
5319 InvalidInstruction(2);
5324 InvalidInstruction(2);
5329 InvalidInstruction(2);
5334 InvalidInstruction(2);
5339 InvalidInstruction(2);
5344 InvalidInstruction(2);
5349 InvalidInstruction(2);
5354 InvalidInstruction(2);
5359 InvalidInstruction(2);
5364 InvalidInstruction(2);
5369 InvalidInstruction(2);
5374 InvalidInstruction(2);
5379 InvalidInstruction(2);
5384 InvalidInstruction(2);
5389 InvalidInstruction(2);
5394 InvalidInstruction(2);
5399 InvalidInstruction(2);
5404 InvalidInstruction(2);
5409 InvalidInstruction(2);
5414 sdwCyclesRemaining
-= 16;
5415 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5416 while (psMemRead
->lowAddr
!= 0xffffffff)
5418 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5420 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5421 if (psMemRead
->memoryCall
)
5423 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5427 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5437 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5440 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5441 while (psMemWrite
->lowAddr
!= 0xffffffff)
5443 if ((cpu
.z80DE
>= psMemWrite
->lowAddr
) && (cpu
.z80DE
<= psMemWrite
->highAddr
))
5445 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5446 if (psMemWrite
->memoryCall
)
5448 psMemWrite
->memoryCall(cpu
.z80DE
, bTemp
, psMemWrite
);
5452 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80DE
- psMemWrite
->lowAddr
)) = bTemp
;
5462 cpu
.z80Base
[cpu
.z80DE
] = (UINT8
) bTemp
;
5468 cpu
.z80HL
&= 0xffff;
5469 cpu
.z80DE
&= 0xffff;
5470 cpu
.z80BC
&= 0xffff;
5471 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
);
5474 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5480 sdwCyclesRemaining
-= 16;
5482 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5483 while (psMemRead
->lowAddr
!= 0xffffffff)
5485 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5487 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5488 if (psMemRead
->memoryCall
)
5490 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5494 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5504 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5508 cpu
.z80HL
&= 0xffff;
5510 cpu
.z80BC
&= 0xffff;
5512 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5513 cpu
.z80F
|= (pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
));
5516 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5522 sdwCyclesRemaining
-= 16;
5524 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
5525 while (psIoRead
->lowIoAddr
!= 0xffff)
5527 if ((cpu
.z80B
>= psIoRead
->lowIoAddr
) && (cpu
.z80B
<= psIoRead
->highIoAddr
))
5529 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5530 bTemp
= psIoRead
->IOCall(cpu
.z80B
, psIoRead
);
5539 bTemp
= 0xff; /* Unclaimed I/O read */
5542 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5543 while (psMemWrite
->lowAddr
!= 0xffffffff)
5545 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
5547 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5548 if (psMemWrite
->memoryCall
)
5550 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
5554 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
5564 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
5568 cpu
.z80HL
&= 0xffff;
5569 sdwCyclesRemaining
-= 16;
5572 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5573 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
5576 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5583 sdwCyclesRemaining
-= 16;
5585 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5586 while (psMemRead
->lowAddr
!= 0xffffffff)
5588 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5590 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5591 if (psMemRead
->memoryCall
)
5593 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5597 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5607 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5610 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
5611 while (psIoWrite
->lowIoAddr
!= 0xffff)
5613 if ((cpu
.z80BC
>= psIoWrite
->lowIoAddr
) && (cpu
.z80BC
<= psIoWrite
->highIoAddr
))
5615 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5616 psIoWrite
->IOCall(cpu
.z80BC
, bTemp
, psIoWrite
);
5624 cpu
.z80HL
&= 0xffff;
5625 sdwCyclesRemaining
-= 16;
5628 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5629 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
5632 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5638 InvalidInstruction(2);
5643 InvalidInstruction(2);
5648 InvalidInstruction(2);
5653 InvalidInstruction(2);
5658 sdwCyclesRemaining
-= 16;
5659 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5660 while (psMemRead
->lowAddr
!= 0xffffffff)
5662 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5664 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5665 if (psMemRead
->memoryCall
)
5667 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5671 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5681 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5684 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5685 while (psMemWrite
->lowAddr
!= 0xffffffff)
5687 if ((cpu
.z80DE
>= psMemWrite
->lowAddr
) && (cpu
.z80DE
<= psMemWrite
->highAddr
))
5689 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5690 if (psMemWrite
->memoryCall
)
5692 psMemWrite
->memoryCall(cpu
.z80DE
, bTemp
, psMemWrite
);
5696 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80DE
- psMemWrite
->lowAddr
)) = bTemp
;
5706 cpu
.z80Base
[cpu
.z80DE
] = (UINT8
) bTemp
;
5712 cpu
.z80HL
&= 0xffff;
5713 cpu
.z80DE
&= 0xffff;
5714 cpu
.z80BC
&= 0xffff;
5715 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
);
5718 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5724 sdwCyclesRemaining
-= 16;
5726 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5727 while (psMemRead
->lowAddr
!= 0xffffffff)
5729 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5731 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5732 if (psMemRead
->memoryCall
)
5734 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5738 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5748 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5752 cpu
.z80HL
&= 0xffff;
5754 cpu
.z80BC
&= 0xffff;
5756 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5757 cpu
.z80F
|= (pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
));
5760 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5766 sdwCyclesRemaining
-= 16;
5768 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
5769 while (psIoRead
->lowIoAddr
!= 0xffff)
5771 if ((cpu
.z80B
>= psIoRead
->lowIoAddr
) && (cpu
.z80B
<= psIoRead
->highIoAddr
))
5773 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5774 bTemp
= psIoRead
->IOCall(cpu
.z80B
, psIoRead
);
5783 bTemp
= 0xff; /* Unclaimed I/O read */
5786 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5787 while (psMemWrite
->lowAddr
!= 0xffffffff)
5789 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
5791 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5792 if (psMemWrite
->memoryCall
)
5794 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
5798 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
5808 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
5812 cpu
.z80HL
&= 0xffff;
5813 sdwCyclesRemaining
-= 16;
5816 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5817 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
5820 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5827 sdwCyclesRemaining
-= 16;
5829 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5830 while (psMemRead
->lowAddr
!= 0xffffffff)
5832 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5834 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5835 if (psMemRead
->memoryCall
)
5837 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5841 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5851 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5854 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
5855 while (psIoWrite
->lowIoAddr
!= 0xffff)
5857 if ((cpu
.z80BC
>= psIoWrite
->lowIoAddr
) && (cpu
.z80BC
<= psIoWrite
->highIoAddr
))
5859 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5860 psIoWrite
->IOCall(cpu
.z80BC
, bTemp
, psIoWrite
);
5868 cpu
.z80HL
&= 0xffff;
5869 sdwCyclesRemaining
-= 16;
5872 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
5873 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
5876 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5882 InvalidInstruction(2);
5887 InvalidInstruction(2);
5892 InvalidInstruction(2);
5897 InvalidInstruction(2);
5902 sdwCyclesRemaining
-= 16;
5903 while ((sdwCyclesRemaining
> 0) && (cpu
.z80BC
))
5905 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5906 while (psMemRead
->lowAddr
!= 0xffffffff)
5908 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5910 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5911 if (psMemRead
->memoryCall
)
5913 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5917 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5927 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
5930 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
5931 while (psMemWrite
->lowAddr
!= 0xffffffff)
5933 if ((cpu
.z80DE
>= psMemWrite
->lowAddr
) && (cpu
.z80DE
<= psMemWrite
->highAddr
))
5935 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5936 if (psMemWrite
->memoryCall
)
5938 psMemWrite
->memoryCall(cpu
.z80DE
, bTemp
, psMemWrite
);
5942 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80DE
- psMemWrite
->lowAddr
)) = bTemp
;
5952 cpu
.z80Base
[cpu
.z80DE
] = (UINT8
) bTemp
;
5958 cpu
.z80HL
&= 0xffff;
5959 cpu
.z80DE
&= 0xffff;
5960 cpu
.z80BC
&= 0xffff;
5961 sdwCyclesRemaining
-= 21;
5963 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
);
5966 pbPC
-= 2; /* Back up so we hit this instruction again */
5967 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
5969 sdwCyclesRemaining
-= 16;
5974 sdwCyclesRemaining
-= 16;
5975 while ((sdwCyclesRemaining
>= 0) && (cpu
.z80BC
))
5977 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
5978 while (psMemRead
->lowAddr
!= 0xffffffff)
5980 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
5982 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
5983 if (psMemRead
->memoryCall
)
5985 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
5989 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
5999 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
6003 cpu
.z80HL
&= 0xffff;
6005 cpu
.z80BC
&= 0xffff;
6006 sdwCyclesRemaining
-= 16;
6007 if (cpu
.z80A
== bTemp
)
6012 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6013 cpu
.z80F
|= (pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
));
6016 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6022 sdwCyclesRemaining
-= 16;
6023 while ((sdwCyclesRemaining
> 0) && (cpu
.z80B
))
6025 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
6026 while (psIoRead
->lowIoAddr
!= 0xffff)
6028 if ((cpu
.z80B
>= psIoRead
->lowIoAddr
) && (cpu
.z80B
<= psIoRead
->highIoAddr
))
6030 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6031 bTemp
= psIoRead
->IOCall(cpu
.z80B
, psIoRead
);
6040 bTemp
= 0xff; /* Unclaimed I/O read */
6043 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
6044 while (psMemWrite
->lowAddr
!= 0xffffffff)
6046 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
6048 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6049 if (psMemWrite
->memoryCall
)
6051 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
6055 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
6065 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
6069 cpu
.z80HL
&= 0xffff;
6070 sdwCyclesRemaining
-= 16;
6073 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6074 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
6077 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6084 sdwCyclesRemaining
-= 16;
6085 while ((sdwCyclesRemaining
> 0) && (cpu
.z80B
))
6087 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
6088 while (psMemRead
->lowAddr
!= 0xffffffff)
6090 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
6092 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6093 if (psMemRead
->memoryCall
)
6095 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
6099 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
6109 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
6112 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
6113 while (psIoWrite
->lowIoAddr
!= 0xffff)
6115 if ((cpu
.z80BC
>= psIoWrite
->lowIoAddr
) && (cpu
.z80BC
<= psIoWrite
->highIoAddr
))
6117 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6118 psIoWrite
->IOCall(cpu
.z80BC
, bTemp
, psIoWrite
);
6126 cpu
.z80HL
&= 0xffff;
6127 sdwCyclesRemaining
-= 16;
6130 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6131 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
6134 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6140 InvalidInstruction(2);
6145 InvalidInstruction(2);
6150 InvalidInstruction(2);
6155 InvalidInstruction(2);
6160 sdwCyclesRemaining
-= 16;
6161 while ((sdwCyclesRemaining
> 0) && (cpu
.z80BC
))
6163 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
6164 while (psMemRead
->lowAddr
!= 0xffffffff)
6166 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
6168 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6169 if (psMemRead
->memoryCall
)
6171 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
6175 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
6185 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
6188 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
6189 while (psMemWrite
->lowAddr
!= 0xffffffff)
6191 if ((cpu
.z80DE
>= psMemWrite
->lowAddr
) && (cpu
.z80DE
<= psMemWrite
->highAddr
))
6193 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6194 if (psMemWrite
->memoryCall
)
6196 psMemWrite
->memoryCall(cpu
.z80DE
, bTemp
, psMemWrite
);
6200 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80DE
- psMemWrite
->lowAddr
)) = bTemp
;
6210 cpu
.z80Base
[cpu
.z80DE
] = (UINT8
) bTemp
;
6216 cpu
.z80HL
&= 0xffff;
6217 cpu
.z80DE
&= 0xffff;
6218 cpu
.z80BC
&= 0xffff;
6219 sdwCyclesRemaining
-= 21;
6221 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
);
6224 pbPC
-= 2; /* Back up so we hit this instruction again */
6225 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6227 sdwCyclesRemaining
-= 16;
6232 sdwCyclesRemaining
-= 16;
6233 while ((sdwCyclesRemaining
>= 0) && (cpu
.z80BC
))
6235 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
6236 while (psMemRead
->lowAddr
!= 0xffffffff)
6238 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
6240 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6241 if (psMemRead
->memoryCall
)
6243 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
6247 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
6257 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
6261 cpu
.z80HL
&= 0xffff;
6263 cpu
.z80BC
&= 0xffff;
6264 sdwCyclesRemaining
-= 16;
6265 if (cpu
.z80A
== bTemp
)
6270 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6271 cpu
.z80F
|= (pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_ZERO
));
6274 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6280 sdwCyclesRemaining
-= 16;
6281 while ((sdwCyclesRemaining
> 0) && (cpu
.z80B
))
6283 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
6284 while (psIoRead
->lowIoAddr
!= 0xffff)
6286 if ((cpu
.z80B
>= psIoRead
->lowIoAddr
) && (cpu
.z80B
<= psIoRead
->highIoAddr
))
6288 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6289 bTemp
= psIoRead
->IOCall(cpu
.z80B
, psIoRead
);
6298 bTemp
= 0xff; /* Unclaimed I/O read */
6301 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
6302 while (psMemWrite
->lowAddr
!= 0xffffffff)
6304 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
6306 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6307 if (psMemWrite
->memoryCall
)
6309 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
6313 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
6323 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
6327 cpu
.z80HL
&= 0xffff;
6328 sdwCyclesRemaining
-= 16;
6331 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6332 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
6335 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6342 sdwCyclesRemaining
-= 16;
6343 while ((sdwCyclesRemaining
> 0) && (cpu
.z80B
))
6345 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
6346 while (psMemRead
->lowAddr
!= 0xffffffff)
6348 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
6350 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6351 if (psMemRead
->memoryCall
)
6353 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
6357 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
6367 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
6370 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
6371 while (psIoWrite
->lowIoAddr
!= 0xffff)
6373 if ((cpu
.z80BC
>= psIoWrite
->lowIoAddr
) && (cpu
.z80BC
<= psIoWrite
->highIoAddr
))
6375 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6376 psIoWrite
->IOCall(cpu
.z80BC
, bTemp
, psIoWrite
);
6384 cpu
.z80HL
&= 0xffff;
6385 sdwCyclesRemaining
-= 16;
6388 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6389 cpu
.z80F
|= (bPostORFlags
[bTemp
] & (Z80_FLAG_SIGN
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
));
6392 cpu
.z80F
|= Z80_FLAG_OVERFLOW_PARITY
;
6398 InvalidInstruction(2);
6403 InvalidInstruction(2);
6408 InvalidInstruction(2);
6413 InvalidInstruction(2);
6418 InvalidInstruction(2);
6423 InvalidInstruction(2);
6428 InvalidInstruction(2);
6433 InvalidInstruction(2);
6438 InvalidInstruction(2);
6443 InvalidInstruction(2);
6448 InvalidInstruction(2);
6453 InvalidInstruction(2);
6458 InvalidInstruction(2);
6463 InvalidInstruction(2);
6468 InvalidInstruction(2);
6473 InvalidInstruction(2);
6478 InvalidInstruction(2);
6483 InvalidInstruction(2);
6488 InvalidInstruction(2);
6493 InvalidInstruction(2);
6498 InvalidInstruction(2);
6503 InvalidInstruction(2);
6508 InvalidInstruction(2);
6513 InvalidInstruction(2);
6518 InvalidInstruction(2);
6523 InvalidInstruction(2);
6528 InvalidInstruction(2);
6533 InvalidInstruction(2);
6538 InvalidInstruction(2);
6543 InvalidInstruction(2);
6548 InvalidInstruction(2);
6553 InvalidInstruction(2);
6558 InvalidInstruction(2);
6563 InvalidInstruction(2);
6568 InvalidInstruction(2);
6573 InvalidInstruction(2);
6578 InvalidInstruction(2);
6583 InvalidInstruction(2);
6588 InvalidInstruction(2);
6593 InvalidInstruction(2);
6598 InvalidInstruction(2);
6603 InvalidInstruction(2);
6608 InvalidInstruction(2);
6613 InvalidInstruction(2);
6618 InvalidInstruction(2);
6623 InvalidInstruction(2);
6628 InvalidInstruction(2);
6633 InvalidInstruction(2);
6638 InvalidInstruction(2);
6643 InvalidInstruction(2);
6648 InvalidInstruction(2);
6653 InvalidInstruction(2);
6658 InvalidInstruction(2);
6663 InvalidInstruction(2);
6668 InvalidInstruction(2);
6673 InvalidInstruction(2);
6678 InvalidInstruction(2);
6683 InvalidInstruction(2);
6688 InvalidInstruction(2);
6693 InvalidInstruction(2);
6698 InvalidInstruction(2);
6703 InvalidInstruction(2);
6708 InvalidInstruction(2);
6713 InvalidInstruction(2);
6718 InvalidInstruction(2);
6723 InvalidInstruction(2);
6728 InvalidInstruction(2);
6733 InvalidInstruction(2);
6739 void DDHandler(void)
6745 InvalidInstruction(2);
6750 InvalidInstruction(2);
6755 InvalidInstruction(2);
6760 InvalidInstruction(2);
6765 InvalidInstruction(2);
6770 InvalidInstruction(2);
6775 InvalidInstruction(2);
6780 InvalidInstruction(2);
6785 InvalidInstruction(2);
6790 sdwCyclesRemaining
-= 15;
6791 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
6792 dwTemp
= cpu
.z80IX
+ cpu
.z80BC
;
6793 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IX
^ dwTemp
^ cpu
.z80BC
) >> 8) & Z80_FLAG_HALF_CARRY
);
6794 cpu
.z80IX
= dwTemp
& 0xffff;
6799 InvalidInstruction(2);
6804 InvalidInstruction(2);
6809 InvalidInstruction(2);
6814 InvalidInstruction(2);
6819 InvalidInstruction(2);
6824 InvalidInstruction(2);
6829 InvalidInstruction(2);
6834 InvalidInstruction(2);
6839 InvalidInstruction(2);
6844 InvalidInstruction(2);
6849 InvalidInstruction(2);
6854 InvalidInstruction(2);
6859 InvalidInstruction(2);
6864 InvalidInstruction(2);
6869 InvalidInstruction(2);
6874 sdwCyclesRemaining
-= 15;
6875 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
6876 dwTemp
= cpu
.z80IX
+ cpu
.z80DE
;
6877 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IX
^ dwTemp
^ cpu
.z80DE
) >> 8) & Z80_FLAG_HALF_CARRY
);
6878 cpu
.z80IX
= dwTemp
& 0xffff;
6883 InvalidInstruction(2);
6888 InvalidInstruction(2);
6893 InvalidInstruction(2);
6898 InvalidInstruction(2);
6903 InvalidInstruction(2);
6908 InvalidInstruction(2);
6913 InvalidInstruction(2);
6918 sdwCyclesRemaining
-= 14;
6919 cpu
.z80IX
= *pbPC
++;
6920 cpu
.z80IX
|= ((UINT32
) *pbPC
++ << 8);
6925 sdwCyclesRemaining
-= 20;
6927 dwAddr
|= ((UINT32
) *pbPC
++ << 8);
6928 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
6929 while (psMemWrite
->lowAddr
!= 0xffffffff)
6931 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
6933 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
6934 if (psMemWrite
->memoryCall
)
6936 psMemWrite
->memoryCall(dwAddr
, (cpu
.z80IX
& 0xff), psMemWrite
);
6937 psMemWrite
->memoryCall(dwAddr
+ 1, (cpu
.z80IX
>> 8), psMemWrite
);
6941 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80IX
;
6942 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
) + 1) = cpu
.z80IX
>> 8;
6952 cpu
.z80Base
[dwAddr
] = (UINT8
) cpu
.z80IX
;
6953 cpu
.z80Base
[dwAddr
+ 1] = (UINT8
) ((UINT32
) cpu
.z80IX
>> 8);
6960 sdwCyclesRemaining
-= 10;
6962 cpu
.z80IX
&= 0xffff;
6967 sdwCyclesRemaining
-= 9;
6968 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6969 cpu
.z80F
|= bPostIncFlags
[cpu
.z80XH
++];
6974 sdwCyclesRemaining
-= 9;
6975 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
6976 cpu
.z80F
|= bPostDecFlags
[cpu
.z80XH
--];
6981 sdwCyclesRemaining
-= 9;
6982 cpu
.z80XH
= *pbPC
++;
6987 InvalidInstruction(2);
6992 InvalidInstruction(2);
6997 sdwCyclesRemaining
-= 15;
6998 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
6999 dwTemp
= cpu
.z80IX
+ cpu
.z80IX
;
7000 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IX
^ dwTemp
^ cpu
.z80HL
) >> 8) & Z80_FLAG_HALF_CARRY
);
7001 cpu
.z80IX
= dwTemp
& 0xffff;
7006 sdwCyclesRemaining
-= 20;
7008 dwAddr
|= ((UINT32
) *pbPC
++ << 8);
7009 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7010 while (psMemRead
->lowAddr
!= 0xffffffff)
7012 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
7014 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7015 if (psMemRead
->memoryCall
)
7017 cpu
.z80IX
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
7018 cpu
.z80IX
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(dwAddr
+ 1, psMemRead
) << 8);
7022 cpu
.z80IX
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
7023 cpu
.z80IX
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
+ 1)) << 8);
7033 cpu
.z80IX
= cpu
.z80Base
[dwAddr
];
7034 cpu
.z80IX
|= (UINT32
) ((UINT32
) cpu
.z80Base
[dwAddr
+ 1] << 8);
7041 sdwCyclesRemaining
-= 10;
7043 cpu
.z80IX
&= 0xffff;
7048 sdwCyclesRemaining
-= 9;
7049 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
7050 cpu
.z80F
|= bPostIncFlags
[cpu
.z80XL
++];
7055 sdwCyclesRemaining
-= 9;
7056 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
7057 cpu
.z80F
|= bPostDecFlags
[cpu
.z80XL
--];
7062 sdwCyclesRemaining
-= 9;
7063 cpu
.z80XL
= *pbPC
++;
7068 InvalidInstruction(2);
7073 InvalidInstruction(2);
7078 InvalidInstruction(2);
7083 InvalidInstruction(2);
7088 InvalidInstruction(2);
7093 sdwCyclesRemaining
-= 23;
7094 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
7095 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
7096 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7097 while (psMemRead
->lowAddr
!= 0xffffffff)
7099 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
7101 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7102 if (psMemRead
->memoryCall
)
7104 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
7108 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
7118 bTemp
= cpu
.z80Base
[dwAddr
];
7121 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
7122 cpu
.z80F
|= bPostIncFlags
[bTemp
++];
7123 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7124 while (psMemWrite
->lowAddr
!= 0xffffffff)
7126 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
7128 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7129 if (psMemWrite
->memoryCall
)
7131 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
7135 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
7145 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
7152 sdwCyclesRemaining
-= 23;
7153 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
7154 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
7155 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7156 while (psMemRead
->lowAddr
!= 0xffffffff)
7158 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
7160 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7161 if (psMemRead
->memoryCall
)
7163 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
7167 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
7177 bTemp
= cpu
.z80Base
[dwAddr
];
7180 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
7181 cpu
.z80F
|= bPostDecFlags
[bTemp
--];
7182 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7183 while (psMemWrite
->lowAddr
!= 0xffffffff)
7185 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
7187 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7188 if (psMemWrite
->memoryCall
)
7190 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
7194 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
7204 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
7211 sdwCyclesRemaining
-= 19;
7212 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7213 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7214 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7215 while (psMemWrite
->lowAddr
!= 0xffffffff)
7217 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7219 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7220 if (psMemWrite
->memoryCall
)
7222 psMemWrite
->memoryCall(sdwAddr
, *pbPC
++, psMemWrite
);
7226 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = *pbPC
++;
7236 cpu
.z80Base
[sdwAddr
] = (UINT8
) *pbPC
++;
7243 InvalidInstruction(2);
7248 InvalidInstruction(2);
7253 sdwCyclesRemaining
-= 15;
7254 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
7255 dwTemp
= cpu
.z80IX
+ cpu
.z80sp
;
7256 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IX
^ dwTemp
^ cpu
.z80sp
) >> 8) & Z80_FLAG_HALF_CARRY
);
7257 cpu
.z80IX
= dwTemp
& 0xffff;
7262 InvalidInstruction(2);
7267 InvalidInstruction(2);
7272 InvalidInstruction(2);
7277 InvalidInstruction(2);
7282 InvalidInstruction(2);
7287 InvalidInstruction(2);
7292 InvalidInstruction(2);
7297 InvalidInstruction(2);
7302 InvalidInstruction(2);
7307 InvalidInstruction(2);
7312 sdwCyclesRemaining
-= 9;
7313 cpu
.z80B
= cpu
.z80XH
;
7318 sdwCyclesRemaining
-= 9;
7319 cpu
.z80B
= cpu
.z80XL
;
7324 sdwCyclesRemaining
-= 19;
7325 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7326 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7327 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7328 while (psMemRead
->lowAddr
!= 0xffffffff)
7330 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7332 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7333 if (psMemRead
->memoryCall
)
7335 cpu
.z80B
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7339 cpu
.z80B
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
7349 cpu
.z80B
= cpu
.z80Base
[sdwAddr
];
7356 InvalidInstruction(2);
7361 InvalidInstruction(2);
7366 InvalidInstruction(2);
7371 InvalidInstruction(2);
7376 InvalidInstruction(2);
7381 sdwCyclesRemaining
-= 9;
7382 cpu
.z80C
= cpu
.z80XH
;
7387 sdwCyclesRemaining
-= 9;
7388 cpu
.z80C
= cpu
.z80XL
;
7393 sdwCyclesRemaining
-= 19;
7394 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7395 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7396 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7397 while (psMemRead
->lowAddr
!= 0xffffffff)
7399 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7401 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7402 if (psMemRead
->memoryCall
)
7404 cpu
.z80C
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7408 cpu
.z80C
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
7418 cpu
.z80C
= cpu
.z80Base
[sdwAddr
];
7425 InvalidInstruction(2);
7430 InvalidInstruction(2);
7435 InvalidInstruction(2);
7440 InvalidInstruction(2);
7445 InvalidInstruction(2);
7450 sdwCyclesRemaining
-= 9;
7451 cpu
.z80D
= cpu
.z80XH
;
7456 sdwCyclesRemaining
-= 9;
7457 cpu
.z80D
= cpu
.z80XL
;
7462 sdwCyclesRemaining
-= 19;
7463 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7464 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7465 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7466 while (psMemRead
->lowAddr
!= 0xffffffff)
7468 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7470 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7471 if (psMemRead
->memoryCall
)
7473 cpu
.z80D
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7477 cpu
.z80D
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
7487 cpu
.z80D
= cpu
.z80Base
[sdwAddr
];
7494 InvalidInstruction(2);
7499 InvalidInstruction(2);
7504 InvalidInstruction(2);
7509 InvalidInstruction(2);
7514 InvalidInstruction(2);
7519 sdwCyclesRemaining
-= 9;
7520 cpu
.z80E
= cpu
.z80XH
;
7525 sdwCyclesRemaining
-= 9;
7526 cpu
.z80E
= cpu
.z80XL
;
7531 sdwCyclesRemaining
-= 19;
7532 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7533 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7534 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7535 while (psMemRead
->lowAddr
!= 0xffffffff)
7537 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7539 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7540 if (psMemRead
->memoryCall
)
7542 cpu
.z80E
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7546 cpu
.z80E
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
7556 cpu
.z80E
= cpu
.z80Base
[sdwAddr
];
7563 InvalidInstruction(2);
7568 sdwCyclesRemaining
-= 9;
7569 cpu
.z80XH
= cpu
.z80B
;
7574 sdwCyclesRemaining
-= 9;
7575 cpu
.z80XH
= cpu
.z80C
;
7580 sdwCyclesRemaining
-= 9;
7581 cpu
.z80XH
= cpu
.z80D
;
7586 sdwCyclesRemaining
-= 9;
7587 cpu
.z80XH
= cpu
.z80E
;
7592 sdwCyclesRemaining
-= 9;
7597 sdwCyclesRemaining
-= 9;
7598 cpu
.z80XH
= cpu
.z80XL
;
7603 sdwCyclesRemaining
-= 19;
7604 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7605 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7606 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7607 while (psMemRead
->lowAddr
!= 0xffffffff)
7609 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7611 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7612 if (psMemRead
->memoryCall
)
7614 cpu
.z80H
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7618 cpu
.z80H
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
7628 cpu
.z80H
= cpu
.z80Base
[sdwAddr
];
7635 sdwCyclesRemaining
-= 9;
7636 cpu
.z80XH
= cpu
.z80A
;
7641 sdwCyclesRemaining
-= 9;
7642 cpu
.z80XL
= cpu
.z80B
;
7647 sdwCyclesRemaining
-= 9;
7648 cpu
.z80XL
= cpu
.z80C
;
7653 sdwCyclesRemaining
-= 9;
7654 cpu
.z80XL
= cpu
.z80D
;
7659 sdwCyclesRemaining
-= 9;
7660 cpu
.z80XL
= cpu
.z80E
;
7665 sdwCyclesRemaining
-= 9;
7666 cpu
.z80XL
= cpu
.z80XH
;
7671 sdwCyclesRemaining
-= 9;
7676 sdwCyclesRemaining
-= 19;
7677 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7678 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7679 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7680 while (psMemRead
->lowAddr
!= 0xffffffff)
7682 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7684 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7685 if (psMemRead
->memoryCall
)
7687 cpu
.z80L
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7691 cpu
.z80L
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
7701 cpu
.z80L
= cpu
.z80Base
[sdwAddr
];
7708 sdwCyclesRemaining
-= 9;
7709 cpu
.z80XL
= cpu
.z80A
;
7714 sdwCyclesRemaining
-= 19;
7715 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7716 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7717 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7718 while (psMemWrite
->lowAddr
!= 0xffffffff)
7720 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7722 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7723 if (psMemWrite
->memoryCall
)
7725 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80B
, psMemWrite
);
7729 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80B
;
7739 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80B
;
7746 sdwCyclesRemaining
-= 19;
7747 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7748 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7749 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7750 while (psMemWrite
->lowAddr
!= 0xffffffff)
7752 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7754 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7755 if (psMemWrite
->memoryCall
)
7757 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80C
, psMemWrite
);
7761 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80C
;
7771 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80C
;
7778 sdwCyclesRemaining
-= 19;
7779 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7780 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7781 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7782 while (psMemWrite
->lowAddr
!= 0xffffffff)
7784 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7786 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7787 if (psMemWrite
->memoryCall
)
7789 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80D
, psMemWrite
);
7793 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80D
;
7803 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80D
;
7810 sdwCyclesRemaining
-= 19;
7811 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7812 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7813 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7814 while (psMemWrite
->lowAddr
!= 0xffffffff)
7816 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7818 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7819 if (psMemWrite
->memoryCall
)
7821 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80E
, psMemWrite
);
7825 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80E
;
7835 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80E
;
7842 sdwCyclesRemaining
-= 19;
7843 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7844 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7845 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7846 while (psMemWrite
->lowAddr
!= 0xffffffff)
7848 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7850 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7851 if (psMemWrite
->memoryCall
)
7853 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80H
, psMemWrite
);
7857 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80H
;
7867 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80H
;
7874 sdwCyclesRemaining
-= 19;
7875 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7876 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7877 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7878 while (psMemWrite
->lowAddr
!= 0xffffffff)
7880 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7882 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7883 if (psMemWrite
->memoryCall
)
7885 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80L
, psMemWrite
);
7889 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80L
;
7899 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80L
;
7906 sdwCyclesRemaining
-= 19;
7907 InvalidInstruction(2);
7912 sdwCyclesRemaining
-= 19;
7913 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7914 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7915 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
7916 while (psMemWrite
->lowAddr
!= 0xffffffff)
7918 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
7920 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7921 if (psMemWrite
->memoryCall
)
7923 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80A
, psMemWrite
);
7927 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80A
;
7937 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80A
;
7944 InvalidInstruction(2);
7949 InvalidInstruction(2);
7954 InvalidInstruction(2);
7959 InvalidInstruction(2);
7964 sdwCyclesRemaining
-= 9;
7965 cpu
.z80A
= cpu
.z80XH
;
7970 sdwCyclesRemaining
-= 9;
7971 cpu
.z80A
= cpu
.z80XL
;
7976 sdwCyclesRemaining
-= 19;
7977 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
7978 sdwAddr
= ((INT32
) cpu
.z80IX
+ sdwAddr
) & 0xffff;
7979 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
7980 while (psMemRead
->lowAddr
!= 0xffffffff)
7982 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
7984 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
7985 if (psMemRead
->memoryCall
)
7987 cpu
.z80A
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
7991 cpu
.z80A
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
8001 cpu
.z80A
= cpu
.z80Base
[sdwAddr
];
8008 InvalidInstruction(2);
8013 InvalidInstruction(2);
8018 InvalidInstruction(2);
8023 InvalidInstruction(2);
8028 InvalidInstruction(2);
8033 sdwCyclesRemaining
-= 9;
8034 bTemp2
= cpu
.z80A
+ cpu
.z80XH
;
8035 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8036 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8037 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XH
];
8038 InvalidInstruction(2);
8043 sdwCyclesRemaining
-= 9;
8044 bTemp2
= cpu
.z80A
+ cpu
.z80XL
;
8045 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8046 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8047 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XL
];
8048 InvalidInstruction(2);
8053 sdwCyclesRemaining
-= 19;
8054 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8055 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8056 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8057 while (psMemRead
->lowAddr
!= 0xffffffff)
8059 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8061 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8062 if (psMemRead
->memoryCall
)
8064 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8068 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8078 bTemp
= cpu
.z80Base
[dwAddr
];
8081 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8082 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8083 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
8089 InvalidInstruction(2);
8094 InvalidInstruction(2);
8099 InvalidInstruction(2);
8104 InvalidInstruction(2);
8109 InvalidInstruction(2);
8114 sdwCyclesRemaining
-= 9;
8115 bTemp2
= cpu
.z80A
+ cpu
.z80XH
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
8116 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8117 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8118 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XH
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
8119 InvalidInstruction(2);
8124 sdwCyclesRemaining
-= 9;
8125 bTemp2
= cpu
.z80A
+ cpu
.z80XL
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
8126 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8127 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8128 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XL
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
8129 InvalidInstruction(2);
8134 sdwCyclesRemaining
-= 19;
8135 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8136 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8137 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8138 while (psMemRead
->lowAddr
!= 0xffffffff)
8140 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8142 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8143 if (psMemRead
->memoryCall
)
8145 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8149 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8159 bTemp
= cpu
.z80Base
[dwAddr
];
8162 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
);
8163 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8164 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8165 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
8166 cpu
.z80A
+= bTemp
+ bTemp2
;
8171 InvalidInstruction(2);
8176 InvalidInstruction(2);
8181 InvalidInstruction(2);
8186 InvalidInstruction(2);
8191 InvalidInstruction(2);
8196 sdwCyclesRemaining
-= 9;
8197 bTemp2
= cpu
.z80A
- cpu
.z80XH
;
8198 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8199 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8200 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XH
];
8201 InvalidInstruction(2);
8206 sdwCyclesRemaining
-= 9;
8207 bTemp2
= cpu
.z80A
- cpu
.z80XL
;
8208 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8209 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8210 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XL
];
8211 InvalidInstruction(2);
8216 sdwCyclesRemaining
-= 19;
8217 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8218 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8219 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8220 while (psMemRead
->lowAddr
!= 0xffffffff)
8222 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8224 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8225 if (psMemRead
->memoryCall
)
8227 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8231 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8241 bTemp
= cpu
.z80Base
[dwAddr
];
8244 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8245 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8246 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
8252 InvalidInstruction(2);
8257 InvalidInstruction(2);
8262 InvalidInstruction(2);
8267 InvalidInstruction(2);
8272 InvalidInstruction(2);
8277 sdwCyclesRemaining
-= 9;
8278 bTemp2
= cpu
.z80A
- cpu
.z80XH
- (cpu
.z80F
& Z80_FLAG_CARRY
);
8279 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8280 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8281 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XH
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
8282 InvalidInstruction(2);
8287 sdwCyclesRemaining
-= 9;
8288 bTemp2
= cpu
.z80A
- cpu
.z80XL
- (cpu
.z80F
& Z80_FLAG_CARRY
);
8289 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8290 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8291 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80XL
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
8292 InvalidInstruction(2);
8297 sdwCyclesRemaining
-= 19;
8298 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8299 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8300 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8301 while (psMemRead
->lowAddr
!= 0xffffffff)
8303 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8305 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8306 if (psMemRead
->memoryCall
)
8308 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8312 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8322 bTemp
= cpu
.z80Base
[dwAddr
];
8326 cpu
.z80A
= cpu
.z80A
- bTemp
- (cpu
.z80F
& Z80_FLAG_CARRY
);
8327 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8328 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8329 pbSubSbcTable
[((UINT32
) bTemp2
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
8334 InvalidInstruction(2);
8339 InvalidInstruction(2);
8344 InvalidInstruction(2);
8349 InvalidInstruction(2);
8354 InvalidInstruction(2);
8359 sdwCyclesRemaining
-= 9;
8360 cpu
.z80A
&= cpu
.z80XH
;
8361 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8362 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
8364 InvalidInstruction(2);
8369 sdwCyclesRemaining
-= 9;
8370 cpu
.z80A
&= cpu
.z80XL
;
8371 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8372 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
8374 InvalidInstruction(2);
8379 sdwCyclesRemaining
-= 19;
8380 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8381 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8382 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8383 while (psMemRead
->lowAddr
!= 0xffffffff)
8385 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8387 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8388 if (psMemRead
->memoryCall
)
8390 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8394 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8404 bTemp
= cpu
.z80Base
[dwAddr
];
8408 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8409 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
8415 InvalidInstruction(2);
8420 InvalidInstruction(2);
8425 InvalidInstruction(2);
8430 InvalidInstruction(2);
8435 InvalidInstruction(2);
8440 sdwCyclesRemaining
-= 9;
8441 cpu
.z80A
^= cpu
.z80XH
;
8442 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8443 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8445 InvalidInstruction(2);
8450 sdwCyclesRemaining
-= 9;
8451 cpu
.z80A
^= cpu
.z80XL
;
8452 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8453 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8455 InvalidInstruction(2);
8460 sdwCyclesRemaining
-= 19;
8461 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8462 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8463 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8464 while (psMemRead
->lowAddr
!= 0xffffffff)
8466 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8468 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8469 if (psMemRead
->memoryCall
)
8471 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8475 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8485 bTemp
= cpu
.z80Base
[dwAddr
];
8489 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8490 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8496 InvalidInstruction(2);
8501 InvalidInstruction(2);
8506 InvalidInstruction(2);
8511 InvalidInstruction(2);
8516 InvalidInstruction(2);
8521 sdwCyclesRemaining
-= 9;
8522 cpu
.z80A
|= cpu
.z80XH
;
8523 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8524 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8526 InvalidInstruction(2);
8531 sdwCyclesRemaining
-= 9;
8532 cpu
.z80A
|= cpu
.z80XL
;
8533 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8534 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8536 InvalidInstruction(2);
8541 sdwCyclesRemaining
-= 19;
8542 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8543 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8544 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8545 while (psMemRead
->lowAddr
!= 0xffffffff)
8547 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8549 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8550 if (psMemRead
->memoryCall
)
8552 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8556 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8566 bTemp
= cpu
.z80Base
[dwAddr
];
8570 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8571 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8577 InvalidInstruction(2);
8582 InvalidInstruction(2);
8587 InvalidInstruction(2);
8592 InvalidInstruction(2);
8597 InvalidInstruction(2);
8602 sdwCyclesRemaining
-= 9;
8603 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8604 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8606 InvalidInstruction(2);
8611 sdwCyclesRemaining
-= 9;
8612 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
8613 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
8615 InvalidInstruction(2);
8620 sdwCyclesRemaining
-= 19;
8621 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
8622 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IX
) & 0xffff;
8623 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8624 while (psMemRead
->lowAddr
!= 0xffffffff)
8626 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
8628 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8629 if (psMemRead
->memoryCall
)
8631 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
8635 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
8645 bTemp
= cpu
.z80Base
[dwAddr
];
8648 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
8649 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
8650 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
8655 InvalidInstruction(2);
8660 InvalidInstruction(2);
8665 InvalidInstruction(2);
8670 InvalidInstruction(2);
8675 InvalidInstruction(2);
8680 InvalidInstruction(2);
8685 InvalidInstruction(2);
8690 InvalidInstruction(2);
8695 InvalidInstruction(2);
8700 InvalidInstruction(2);
8705 InvalidInstruction(2);
8710 InvalidInstruction(2);
8720 InvalidInstruction(2);
8725 InvalidInstruction(2);
8730 InvalidInstruction(2);
8735 InvalidInstruction(2);
8740 InvalidInstruction(2);
8745 InvalidInstruction(2);
8750 InvalidInstruction(2);
8755 InvalidInstruction(2);
8760 InvalidInstruction(2);
8765 InvalidInstruction(2);
8770 InvalidInstruction(2);
8775 InvalidInstruction(2);
8780 InvalidInstruction(2);
8785 InvalidInstruction(2);
8790 InvalidInstruction(2);
8795 InvalidInstruction(2);
8800 InvalidInstruction(2);
8805 InvalidInstruction(2);
8810 InvalidInstruction(2);
8815 InvalidInstruction(2);
8820 InvalidInstruction(2);
8825 sdwCyclesRemaining
-= 14;
8826 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8827 while (psMemRead
->lowAddr
!= 0xffffffff)
8829 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
8831 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8832 if (psMemRead
->memoryCall
)
8834 cpu
.z80IX
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
8835 cpu
.z80IX
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
8839 cpu
.z80IX
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
8840 cpu
.z80IX
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
8850 cpu
.z80IX
= cpu
.z80Base
[cpu
.z80sp
];
8851 cpu
.z80IX
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
8855 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
8860 InvalidInstruction(2);
8865 sdwCyclesRemaining
-= 23;
8866 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
8867 while (psMemRead
->lowAddr
!= 0xffffffff)
8869 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
8871 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8872 if (psMemRead
->memoryCall
)
8874 dwAddr
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
8875 dwAddr
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
8879 dwAddr
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
8880 dwAddr
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
8890 dwAddr
= cpu
.z80Base
[cpu
.z80sp
];
8891 dwAddr
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
8894 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
8895 while (psMemWrite
->lowAddr
!= 0xffffffff)
8897 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
8899 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8900 if (psMemWrite
->memoryCall
)
8902 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80IX
& 0xff), psMemWrite
);
8903 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80IX
>> 8), psMemWrite
);
8907 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80IX
;
8908 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80IX
>> 8;
8918 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80IX
;
8919 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80IX
>> 8);
8927 InvalidInstruction(2);
8932 sdwCyclesRemaining
-= 15;
8934 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
8935 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
8936 while (psMemWrite
->lowAddr
!= 0xffffffff)
8938 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
8940 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
8941 if (psMemWrite
->memoryCall
)
8943 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80IX
& 0xff), psMemWrite
);
8944 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80IX
>> 8), psMemWrite
);
8948 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80IX
;
8949 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80IX
>> 8;
8959 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80IX
;
8960 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80IX
>> 8);
8967 InvalidInstruction(2);
8972 InvalidInstruction(2);
8977 InvalidInstruction(2);
8982 sdwCyclesRemaining
-= 8;
8983 pbPC
= cpu
.z80Base
+ cpu
.z80IX
;
8988 InvalidInstruction(2);
8993 InvalidInstruction(2);
8998 InvalidInstruction(2);
9003 InvalidInstruction(2);
9008 InvalidInstruction(2);
9013 InvalidInstruction(2);
9018 InvalidInstruction(2);
9023 InvalidInstruction(2);
9028 InvalidInstruction(2);
9033 InvalidInstruction(2);
9038 InvalidInstruction(2);
9043 InvalidInstruction(2);
9048 InvalidInstruction(2);
9053 InvalidInstruction(2);
9058 InvalidInstruction(2);
9063 sdwCyclesRemaining
-= 10;
9064 cpu
.z80sp
= cpu
.z80IX
;
9069 InvalidInstruction(2);
9074 InvalidInstruction(2);
9079 InvalidInstruction(2);
9084 InvalidInstruction(2);
9089 InvalidInstruction(2);
9094 InvalidInstruction(2);
9099 void DDFDCBHandler(UINT32 dwWhich
)
9103 dwAddr
= (UINT32
) ((INT32
) cpu
.z80IY
+ ((INT32
) *pbPC
++)) & 0xffff;
9107 dwAddr
= (UINT32
) ((INT32
) cpu
.z80IX
+ ((INT32
) *pbPC
++)) & 0xffff;
9110 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
9111 while (psMemRead
->lowAddr
!= 0xffffffff)
9113 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
9115 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9116 if (psMemRead
->memoryCall
)
9118 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
9122 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
9132 bTemp
= cpu
.z80Base
[dwAddr
];
9139 InvalidInstruction(4);
9144 InvalidInstruction(4);
9149 InvalidInstruction(4);
9154 InvalidInstruction(4);
9159 InvalidInstruction(4);
9164 InvalidInstruction(4);
9169 sdwCyclesRemaining
-= 23;
9170 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9171 bTemp2
= (bTemp
>> 7);
9172 bTemp
= (bTemp
<< 1) | bTemp2
;
9173 cpu
.z80F
|= bTemp2
| bPostORFlags
[bTemp
];
9174 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9175 while (psMemWrite
->lowAddr
!= 0xffffffff)
9177 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9179 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9180 if (psMemWrite
->memoryCall
)
9182 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9186 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9196 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9203 InvalidInstruction(4);
9208 InvalidInstruction(4);
9213 InvalidInstruction(4);
9218 InvalidInstruction(4);
9223 InvalidInstruction(4);
9228 InvalidInstruction(4);
9233 InvalidInstruction(4);
9238 sdwCyclesRemaining
-= 23;
9239 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9240 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
9241 bTemp
= (bTemp
>> 1) | (bTemp
<< 7);
9242 cpu
.z80F
|= bPostORFlags
[bTemp
];
9243 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9244 while (psMemWrite
->lowAddr
!= 0xffffffff)
9246 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9248 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9249 if (psMemWrite
->memoryCall
)
9251 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9255 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9265 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9272 InvalidInstruction(4);
9277 InvalidInstruction(4);
9282 InvalidInstruction(4);
9287 InvalidInstruction(4);
9292 InvalidInstruction(4);
9297 InvalidInstruction(4);
9302 InvalidInstruction(4);
9307 sdwCyclesRemaining
-= 23;
9308 bTemp2
= cpu
.z80F
& Z80_FLAG_CARRY
;
9309 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9310 cpu
.z80F
|= (bTemp
>> 7);
9311 bTemp
= (bTemp
<< 1) | bTemp2
;
9312 cpu
.z80F
|= bPostORFlags
[bTemp
];
9313 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9314 while (psMemWrite
->lowAddr
!= 0xffffffff)
9316 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9318 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9319 if (psMemWrite
->memoryCall
)
9321 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9325 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9335 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9342 InvalidInstruction(4);
9347 InvalidInstruction(4);
9352 InvalidInstruction(4);
9357 InvalidInstruction(4);
9362 InvalidInstruction(4);
9367 InvalidInstruction(4);
9372 InvalidInstruction(4);
9377 sdwCyclesRemaining
-= 23;
9378 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
9379 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9380 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
9381 bTemp
= (bTemp
>> 1) | bTemp2
;
9382 cpu
.z80F
|= bPostORFlags
[bTemp
];
9383 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9384 while (psMemWrite
->lowAddr
!= 0xffffffff)
9386 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9388 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9389 if (psMemWrite
->memoryCall
)
9391 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9395 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9405 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9412 InvalidInstruction(4);
9417 InvalidInstruction(4);
9422 InvalidInstruction(4);
9427 InvalidInstruction(4);
9432 InvalidInstruction(4);
9437 InvalidInstruction(4);
9442 InvalidInstruction(4);
9447 sdwCyclesRemaining
-= 23;
9448 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9449 cpu
.z80F
|= (bTemp
>> 7);
9450 bTemp
= (bTemp
<< 1);
9451 cpu
.z80F
|= bPostORFlags
[bTemp
];
9452 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9453 while (psMemWrite
->lowAddr
!= 0xffffffff)
9455 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9457 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9458 if (psMemWrite
->memoryCall
)
9460 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9464 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9474 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9481 InvalidInstruction(4);
9486 InvalidInstruction(4);
9491 InvalidInstruction(4);
9496 InvalidInstruction(4);
9501 InvalidInstruction(4);
9506 InvalidInstruction(4);
9511 InvalidInstruction(4);
9516 sdwCyclesRemaining
-= 23;
9517 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9518 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
9519 bTemp
= (bTemp
>> 1) | (bTemp
& 0x80);
9520 cpu
.z80F
|= bPostORFlags
[bTemp
];
9521 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9522 while (psMemWrite
->lowAddr
!= 0xffffffff)
9524 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9526 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9527 if (psMemWrite
->memoryCall
)
9529 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9533 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9543 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9550 InvalidInstruction(4);
9555 InvalidInstruction(4);
9560 InvalidInstruction(4);
9565 InvalidInstruction(4);
9570 InvalidInstruction(4);
9575 InvalidInstruction(4);
9580 InvalidInstruction(4);
9585 sdwCyclesRemaining
-= 23;
9586 InvalidInstruction(4);
9591 InvalidInstruction(4);
9596 InvalidInstruction(4);
9601 InvalidInstruction(4);
9606 InvalidInstruction(4);
9611 InvalidInstruction(4);
9616 InvalidInstruction(4);
9621 InvalidInstruction(4);
9626 sdwCyclesRemaining
-= 23;
9627 cpu
.z80F
&= ~(Z80_FLAG_ZERO
| Z80_FLAG_SIGN
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_CARRY
);
9628 cpu
.z80F
|= (bTemp
& Z80_FLAG_CARRY
);
9629 bTemp
= (bTemp
>> 1);
9630 cpu
.z80F
|= bPostORFlags
[bTemp
];
9631 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
9632 while (psMemWrite
->lowAddr
!= 0xffffffff)
9634 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
9636 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
9637 if (psMemWrite
->memoryCall
)
9639 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
9643 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
9653 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
9660 InvalidInstruction(4);
9665 sdwCyclesRemaining
-= 20;
9666 InvalidInstruction(4);
9671 sdwCyclesRemaining
-= 20;
9672 InvalidInstruction(4);
9677 sdwCyclesRemaining
-= 20;
9678 InvalidInstruction(4);
9683 sdwCyclesRemaining
-= 20;
9684 InvalidInstruction(4);
9689 sdwCyclesRemaining
-= 20;
9690 InvalidInstruction(4);
9695 sdwCyclesRemaining
-= 20;
9696 InvalidInstruction(4);
9701 sdwCyclesRemaining
-= 20;
9702 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
9703 if (!(bTemp
& 0x01))
9705 cpu
.z80F
|= Z80_FLAG_ZERO
;
9711 sdwCyclesRemaining
-= 20;
9712 InvalidInstruction(4);
9717 sdwCyclesRemaining
-= 20;
9718 InvalidInstruction(4);
9723 sdwCyclesRemaining
-= 20;
9724 InvalidInstruction(4);
9729 sdwCyclesRemaining
-= 20;
9730 InvalidInstruction(4);
9735 sdwCyclesRemaining
-= 20;
9736 InvalidInstruction(4);
9741 sdwCyclesRemaining
-= 20;
9742 InvalidInstruction(4);
9747 sdwCyclesRemaining
-= 20;
9748 InvalidInstruction(4);
9753 sdwCyclesRemaining
-= 20;
9754 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
9755 if (!(bTemp
& 0x02))
9757 cpu
.z80F
|= Z80_FLAG_ZERO
;
9763 sdwCyclesRemaining
-= 20;
9764 InvalidInstruction(4);
9769 sdwCyclesRemaining
-= 20;
9770 InvalidInstruction(4);
9775 sdwCyclesRemaining
-= 20;
9776 InvalidInstruction(4);
9781 sdwCyclesRemaining
-= 20;
9782 InvalidInstruction(4);
9787 sdwCyclesRemaining
-= 20;
9788 InvalidInstruction(4);
9793 sdwCyclesRemaining
-= 20;
9794 InvalidInstruction(4);
9799 sdwCyclesRemaining
-= 20;
9800 InvalidInstruction(4);
9805 sdwCyclesRemaining
-= 20;
9806 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
9807 if (!(bTemp
& 0x04))
9809 cpu
.z80F
|= Z80_FLAG_ZERO
;
9815 sdwCyclesRemaining
-= 20;
9816 InvalidInstruction(4);
9821 sdwCyclesRemaining
-= 20;
9822 InvalidInstruction(4);
9827 sdwCyclesRemaining
-= 20;
9828 InvalidInstruction(4);
9833 sdwCyclesRemaining
-= 20;
9834 InvalidInstruction(4);
9839 sdwCyclesRemaining
-= 20;
9840 InvalidInstruction(4);
9845 sdwCyclesRemaining
-= 20;
9846 InvalidInstruction(4);
9851 sdwCyclesRemaining
-= 20;
9852 InvalidInstruction(4);
9857 sdwCyclesRemaining
-= 20;
9858 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
9859 if (!(bTemp
& 0x08))
9861 cpu
.z80F
|= Z80_FLAG_ZERO
;
9867 sdwCyclesRemaining
-= 20;
9868 InvalidInstruction(4);
9873 sdwCyclesRemaining
-= 20;
9874 InvalidInstruction(4);
9879 sdwCyclesRemaining
-= 20;
9880 InvalidInstruction(4);
9885 sdwCyclesRemaining
-= 20;
9886 InvalidInstruction(4);
9891 sdwCyclesRemaining
-= 20;
9892 InvalidInstruction(4);
9897 sdwCyclesRemaining
-= 20;
9898 InvalidInstruction(4);
9903 sdwCyclesRemaining
-= 20;
9904 InvalidInstruction(4);
9909 sdwCyclesRemaining
-= 20;
9910 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
9911 if (!(bTemp
& 0x10))
9913 cpu
.z80F
|= Z80_FLAG_ZERO
;
9919 sdwCyclesRemaining
-= 20;
9920 InvalidInstruction(4);
9925 sdwCyclesRemaining
-= 20;
9926 InvalidInstruction(4);
9931 sdwCyclesRemaining
-= 20;
9932 InvalidInstruction(4);
9937 sdwCyclesRemaining
-= 20;
9938 InvalidInstruction(4);
9943 sdwCyclesRemaining
-= 20;
9944 InvalidInstruction(4);
9949 sdwCyclesRemaining
-= 20;
9950 InvalidInstruction(4);
9955 sdwCyclesRemaining
-= 20;
9956 InvalidInstruction(4);
9961 sdwCyclesRemaining
-= 20;
9962 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
9963 if (!(bTemp
& 0x20))
9965 cpu
.z80F
|= Z80_FLAG_ZERO
;
9971 sdwCyclesRemaining
-= 20;
9972 InvalidInstruction(4);
9977 sdwCyclesRemaining
-= 20;
9978 InvalidInstruction(4);
9983 sdwCyclesRemaining
-= 20;
9984 InvalidInstruction(4);
9989 sdwCyclesRemaining
-= 20;
9990 InvalidInstruction(4);
9995 sdwCyclesRemaining
-= 20;
9996 InvalidInstruction(4);
10001 sdwCyclesRemaining
-= 20;
10002 InvalidInstruction(4);
10007 sdwCyclesRemaining
-= 20;
10008 InvalidInstruction(4);
10013 sdwCyclesRemaining
-= 20;
10014 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
10015 if (!(bTemp
& 0x40))
10017 cpu
.z80F
|= Z80_FLAG_ZERO
;
10023 sdwCyclesRemaining
-= 20;
10024 InvalidInstruction(4);
10029 sdwCyclesRemaining
-= 20;
10030 InvalidInstruction(4);
10035 sdwCyclesRemaining
-= 20;
10036 InvalidInstruction(4);
10041 sdwCyclesRemaining
-= 20;
10042 InvalidInstruction(4);
10047 sdwCyclesRemaining
-= 20;
10048 InvalidInstruction(4);
10053 sdwCyclesRemaining
-= 20;
10054 InvalidInstruction(4);
10059 sdwCyclesRemaining
-= 20;
10060 InvalidInstruction(4);
10065 sdwCyclesRemaining
-= 20;
10066 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_ZERO
| Z80_FLAG_NEGATIVE
)) | Z80_FLAG_HALF_CARRY
;
10067 if (!(bTemp
& 0x80))
10069 cpu
.z80F
|= Z80_FLAG_ZERO
;
10075 sdwCyclesRemaining
-= 20;
10076 InvalidInstruction(4);
10081 InvalidInstruction(4);
10086 InvalidInstruction(4);
10091 InvalidInstruction(4);
10096 InvalidInstruction(4);
10101 InvalidInstruction(4);
10106 InvalidInstruction(4);
10111 sdwCyclesRemaining
-= 23;
10113 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10114 while (psMemWrite
->lowAddr
!= 0xffffffff)
10116 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10118 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10119 if (psMemWrite
->memoryCall
)
10121 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10125 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10135 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10142 InvalidInstruction(4);
10147 InvalidInstruction(4);
10152 InvalidInstruction(4);
10157 InvalidInstruction(4);
10162 InvalidInstruction(4);
10167 InvalidInstruction(4);
10172 InvalidInstruction(4);
10177 sdwCyclesRemaining
-= 23;
10179 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10180 while (psMemWrite
->lowAddr
!= 0xffffffff)
10182 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10184 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10185 if (psMemWrite
->memoryCall
)
10187 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10191 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10201 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10208 InvalidInstruction(4);
10213 InvalidInstruction(4);
10218 InvalidInstruction(4);
10223 InvalidInstruction(4);
10228 InvalidInstruction(4);
10233 InvalidInstruction(4);
10238 InvalidInstruction(4);
10243 sdwCyclesRemaining
-= 23;
10245 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10246 while (psMemWrite
->lowAddr
!= 0xffffffff)
10248 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10250 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10251 if (psMemWrite
->memoryCall
)
10253 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10257 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10267 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10274 InvalidInstruction(4);
10279 InvalidInstruction(4);
10284 InvalidInstruction(4);
10289 InvalidInstruction(4);
10294 InvalidInstruction(4);
10299 InvalidInstruction(4);
10304 InvalidInstruction(4);
10309 sdwCyclesRemaining
-= 23;
10311 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10312 while (psMemWrite
->lowAddr
!= 0xffffffff)
10314 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10316 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10317 if (psMemWrite
->memoryCall
)
10319 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10323 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10333 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10340 InvalidInstruction(4);
10345 InvalidInstruction(4);
10350 InvalidInstruction(4);
10355 InvalidInstruction(4);
10360 InvalidInstruction(4);
10365 InvalidInstruction(4);
10370 InvalidInstruction(4);
10375 sdwCyclesRemaining
-= 23;
10377 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10378 while (psMemWrite
->lowAddr
!= 0xffffffff)
10380 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10382 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10383 if (psMemWrite
->memoryCall
)
10385 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10389 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10399 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10406 InvalidInstruction(4);
10411 InvalidInstruction(4);
10416 InvalidInstruction(4);
10421 InvalidInstruction(4);
10426 InvalidInstruction(4);
10431 InvalidInstruction(4);
10436 InvalidInstruction(4);
10441 sdwCyclesRemaining
-= 23;
10443 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10444 while (psMemWrite
->lowAddr
!= 0xffffffff)
10446 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10448 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10449 if (psMemWrite
->memoryCall
)
10451 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10455 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10465 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10472 InvalidInstruction(4);
10477 InvalidInstruction(4);
10482 InvalidInstruction(4);
10487 InvalidInstruction(4);
10492 InvalidInstruction(4);
10497 InvalidInstruction(4);
10502 InvalidInstruction(4);
10507 sdwCyclesRemaining
-= 23;
10509 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10510 while (psMemWrite
->lowAddr
!= 0xffffffff)
10512 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10514 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10515 if (psMemWrite
->memoryCall
)
10517 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10521 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10531 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10538 InvalidInstruction(4);
10543 InvalidInstruction(4);
10548 InvalidInstruction(4);
10553 InvalidInstruction(4);
10558 InvalidInstruction(4);
10563 InvalidInstruction(4);
10568 InvalidInstruction(4);
10573 sdwCyclesRemaining
-= 23;
10575 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10576 while (psMemWrite
->lowAddr
!= 0xffffffff)
10578 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10580 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10581 if (psMemWrite
->memoryCall
)
10583 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10587 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10597 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10604 InvalidInstruction(4);
10609 InvalidInstruction(4);
10614 InvalidInstruction(4);
10619 InvalidInstruction(4);
10624 InvalidInstruction(4);
10629 InvalidInstruction(4);
10634 InvalidInstruction(4);
10639 sdwCyclesRemaining
-= 23;
10641 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10642 while (psMemWrite
->lowAddr
!= 0xffffffff)
10644 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10646 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10647 if (psMemWrite
->memoryCall
)
10649 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10653 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10663 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10670 InvalidInstruction(4);
10675 InvalidInstruction(4);
10680 InvalidInstruction(4);
10685 InvalidInstruction(4);
10690 InvalidInstruction(4);
10695 InvalidInstruction(4);
10700 InvalidInstruction(4);
10705 sdwCyclesRemaining
-= 23;
10707 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10708 while (psMemWrite
->lowAddr
!= 0xffffffff)
10710 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10712 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10713 if (psMemWrite
->memoryCall
)
10715 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10719 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10729 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10736 InvalidInstruction(4);
10741 InvalidInstruction(4);
10746 InvalidInstruction(4);
10751 InvalidInstruction(4);
10756 InvalidInstruction(4);
10761 InvalidInstruction(4);
10766 InvalidInstruction(4);
10771 sdwCyclesRemaining
-= 23;
10773 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10774 while (psMemWrite
->lowAddr
!= 0xffffffff)
10776 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10778 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10779 if (psMemWrite
->memoryCall
)
10781 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10785 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10795 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10802 InvalidInstruction(4);
10807 InvalidInstruction(4);
10812 InvalidInstruction(4);
10817 InvalidInstruction(4);
10822 InvalidInstruction(4);
10827 InvalidInstruction(4);
10832 InvalidInstruction(4);
10837 sdwCyclesRemaining
-= 23;
10839 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10840 while (psMemWrite
->lowAddr
!= 0xffffffff)
10842 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10844 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10845 if (psMemWrite
->memoryCall
)
10847 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10851 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10861 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10868 InvalidInstruction(4);
10873 InvalidInstruction(4);
10878 InvalidInstruction(4);
10883 InvalidInstruction(4);
10888 InvalidInstruction(4);
10893 InvalidInstruction(4);
10898 InvalidInstruction(4);
10903 sdwCyclesRemaining
-= 23;
10905 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10906 while (psMemWrite
->lowAddr
!= 0xffffffff)
10908 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10910 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10911 if (psMemWrite
->memoryCall
)
10913 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10917 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10927 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
10934 InvalidInstruction(4);
10939 InvalidInstruction(4);
10944 InvalidInstruction(4);
10949 InvalidInstruction(4);
10954 InvalidInstruction(4);
10959 InvalidInstruction(4);
10964 InvalidInstruction(4);
10969 sdwCyclesRemaining
-= 23;
10971 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
10972 while (psMemWrite
->lowAddr
!= 0xffffffff)
10974 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
10976 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
10977 if (psMemWrite
->memoryCall
)
10979 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
10983 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
10993 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
11000 InvalidInstruction(4);
11005 InvalidInstruction(4);
11010 InvalidInstruction(4);
11015 InvalidInstruction(4);
11020 InvalidInstruction(4);
11025 InvalidInstruction(4);
11030 InvalidInstruction(4);
11035 sdwCyclesRemaining
-= 23;
11037 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
11038 while (psMemWrite
->lowAddr
!= 0xffffffff)
11040 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
11042 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11043 if (psMemWrite
->memoryCall
)
11045 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
11049 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
11059 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
11066 InvalidInstruction(4);
11071 InvalidInstruction(4);
11076 InvalidInstruction(4);
11081 InvalidInstruction(4);
11086 InvalidInstruction(4);
11091 InvalidInstruction(4);
11096 InvalidInstruction(4);
11101 sdwCyclesRemaining
-= 23;
11103 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
11104 while (psMemWrite
->lowAddr
!= 0xffffffff)
11106 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
11108 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11109 if (psMemWrite
->memoryCall
)
11111 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
11115 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
11125 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
11132 InvalidInstruction(4);
11137 void FDHandler(void)
11143 InvalidInstruction(2);
11148 InvalidInstruction(2);
11153 InvalidInstruction(2);
11158 InvalidInstruction(2);
11163 InvalidInstruction(2);
11168 InvalidInstruction(2);
11173 InvalidInstruction(2);
11178 InvalidInstruction(2);
11183 InvalidInstruction(2);
11188 sdwCyclesRemaining
-= 15;
11189 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
11190 dwTemp
= cpu
.z80IY
+ cpu
.z80BC
;
11191 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IY
^ dwTemp
^ cpu
.z80BC
) >> 8) & Z80_FLAG_HALF_CARRY
);
11192 cpu
.z80IY
= dwTemp
& 0xffff;
11197 InvalidInstruction(2);
11202 InvalidInstruction(2);
11207 InvalidInstruction(2);
11212 InvalidInstruction(2);
11217 InvalidInstruction(2);
11222 InvalidInstruction(2);
11227 InvalidInstruction(2);
11232 InvalidInstruction(2);
11237 InvalidInstruction(2);
11242 InvalidInstruction(2);
11247 InvalidInstruction(2);
11252 InvalidInstruction(2);
11257 InvalidInstruction(2);
11262 InvalidInstruction(2);
11267 InvalidInstruction(2);
11272 sdwCyclesRemaining
-= 15;
11273 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
11274 dwTemp
= cpu
.z80IY
+ cpu
.z80DE
;
11275 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IY
^ dwTemp
^ cpu
.z80DE
) >> 8) & Z80_FLAG_HALF_CARRY
);
11276 cpu
.z80IY
= dwTemp
& 0xffff;
11281 InvalidInstruction(2);
11286 InvalidInstruction(2);
11291 InvalidInstruction(2);
11296 InvalidInstruction(2);
11301 InvalidInstruction(2);
11306 InvalidInstruction(2);
11311 InvalidInstruction(2);
11316 sdwCyclesRemaining
-= 14;
11317 cpu
.z80IY
= *pbPC
++;
11318 cpu
.z80IY
|= ((UINT32
) *pbPC
++ << 8);
11323 sdwCyclesRemaining
-= 20;
11325 dwAddr
|= ((UINT32
) *pbPC
++ << 8);
11326 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
11327 while (psMemWrite
->lowAddr
!= 0xffffffff)
11329 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
11331 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11332 if (psMemWrite
->memoryCall
)
11334 psMemWrite
->memoryCall(dwAddr
, (cpu
.z80IY
& 0xff), psMemWrite
);
11335 psMemWrite
->memoryCall(dwAddr
+ 1, (cpu
.z80IY
>> 8), psMemWrite
);
11339 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80IY
;
11340 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
) + 1) = cpu
.z80IY
>> 8;
11350 cpu
.z80Base
[dwAddr
] = (UINT8
) cpu
.z80IY
;
11351 cpu
.z80Base
[dwAddr
+ 1] = (UINT8
) ((UINT32
) cpu
.z80IY
>> 8);
11358 sdwCyclesRemaining
-= 10;
11360 cpu
.z80IY
&= 0xffff;
11365 sdwCyclesRemaining
-= 9;
11366 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
11367 cpu
.z80F
|= bPostIncFlags
[cpu
.z80YH
++];
11372 sdwCyclesRemaining
-= 9;
11373 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
11374 cpu
.z80F
|= bPostDecFlags
[cpu
.z80YH
--];
11379 sdwCyclesRemaining
-= 9;
11380 cpu
.z80YH
= *pbPC
++;
11385 InvalidInstruction(2);
11390 InvalidInstruction(2);
11395 sdwCyclesRemaining
-= 15;
11396 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
11397 dwTemp
= cpu
.z80IY
+ cpu
.z80IY
;
11398 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IY
^ dwTemp
^ cpu
.z80HL
) >> 8) & Z80_FLAG_HALF_CARRY
);
11399 cpu
.z80IY
= dwTemp
& 0xffff;
11404 sdwCyclesRemaining
-= 20;
11406 dwAddr
|= ((UINT32
) *pbPC
++ << 8);
11407 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11408 while (psMemRead
->lowAddr
!= 0xffffffff)
11410 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
11412 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11413 if (psMemRead
->memoryCall
)
11415 cpu
.z80IY
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
11416 cpu
.z80IY
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(dwAddr
+ 1, psMemRead
) << 8);
11420 cpu
.z80IY
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
11421 cpu
.z80IY
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
+ 1)) << 8);
11431 cpu
.z80IY
= cpu
.z80Base
[dwAddr
];
11432 cpu
.z80IY
|= (UINT32
) ((UINT32
) cpu
.z80Base
[dwAddr
+ 1] << 8);
11439 sdwCyclesRemaining
-= 10;
11441 cpu
.z80IY
&= 0xffff;
11446 sdwCyclesRemaining
-= 9;
11447 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
11448 cpu
.z80F
|= bPostIncFlags
[cpu
.z80YL
++];
11453 sdwCyclesRemaining
-= 9;
11454 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
11455 cpu
.z80F
|= bPostDecFlags
[cpu
.z80YL
--];
11460 sdwCyclesRemaining
-= 9;
11461 cpu
.z80YL
= *pbPC
++;
11466 InvalidInstruction(2);
11471 InvalidInstruction(2);
11476 InvalidInstruction(2);
11481 InvalidInstruction(2);
11486 InvalidInstruction(2);
11491 sdwCyclesRemaining
-= 23;
11492 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
11493 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
11494 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11495 while (psMemRead
->lowAddr
!= 0xffffffff)
11497 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
11499 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11500 if (psMemRead
->memoryCall
)
11502 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
11506 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
11516 bTemp
= cpu
.z80Base
[dwAddr
];
11519 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
11520 cpu
.z80F
|= bPostIncFlags
[bTemp
++];
11521 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
11522 while (psMemWrite
->lowAddr
!= 0xffffffff)
11524 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
11526 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11527 if (psMemWrite
->memoryCall
)
11529 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
11533 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
11543 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
11550 sdwCyclesRemaining
-= 23;
11551 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
11552 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
11553 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11554 while (psMemRead
->lowAddr
!= 0xffffffff)
11556 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
11558 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11559 if (psMemRead
->memoryCall
)
11561 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
11565 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
11575 bTemp
= cpu
.z80Base
[dwAddr
];
11578 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
11579 cpu
.z80F
|= bPostDecFlags
[bTemp
--];
11580 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
11581 while (psMemWrite
->lowAddr
!= 0xffffffff)
11583 if ((dwAddr
>= psMemWrite
->lowAddr
) && (dwAddr
<= psMemWrite
->highAddr
))
11585 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11586 if (psMemWrite
->memoryCall
)
11588 psMemWrite
->memoryCall(dwAddr
, bTemp
, psMemWrite
);
11592 *((UINT8
*) psMemWrite
->pUserArea
+ (dwAddr
- psMemWrite
->lowAddr
)) = bTemp
;
11602 cpu
.z80Base
[dwAddr
] = (UINT8
) bTemp
;
11609 sdwCyclesRemaining
-= 19;
11610 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
11611 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
11612 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
11613 while (psMemWrite
->lowAddr
!= 0xffffffff)
11615 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
11617 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11618 if (psMemWrite
->memoryCall
)
11620 psMemWrite
->memoryCall(sdwAddr
, *pbPC
++, psMemWrite
);
11624 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = *pbPC
++;
11634 cpu
.z80Base
[sdwAddr
] = (UINT8
) *pbPC
++;
11641 InvalidInstruction(2);
11646 InvalidInstruction(2);
11651 sdwCyclesRemaining
-= 15;
11652 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
11653 dwTemp
= cpu
.z80IY
+ cpu
.z80sp
;
11654 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80IY
^ dwTemp
^ cpu
.z80sp
) >> 8) & Z80_FLAG_HALF_CARRY
);
11655 cpu
.z80IY
= dwTemp
& 0xffff;
11660 InvalidInstruction(2);
11665 InvalidInstruction(2);
11670 InvalidInstruction(2);
11675 InvalidInstruction(2);
11680 InvalidInstruction(2);
11685 InvalidInstruction(2);
11690 InvalidInstruction(2);
11695 InvalidInstruction(2);
11700 InvalidInstruction(2);
11705 InvalidInstruction(2);
11710 sdwCyclesRemaining
-= 9;
11711 cpu
.z80B
= cpu
.z80YH
;
11716 sdwCyclesRemaining
-= 9;
11717 cpu
.z80B
= cpu
.z80YL
;
11722 sdwCyclesRemaining
-= 19;
11723 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
11724 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
11725 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11726 while (psMemRead
->lowAddr
!= 0xffffffff)
11728 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
11730 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11731 if (psMemRead
->memoryCall
)
11733 cpu
.z80B
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
11737 cpu
.z80B
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
11747 cpu
.z80B
= cpu
.z80Base
[sdwAddr
];
11754 InvalidInstruction(2);
11759 InvalidInstruction(2);
11764 InvalidInstruction(2);
11769 InvalidInstruction(2);
11774 InvalidInstruction(2);
11779 sdwCyclesRemaining
-= 9;
11780 cpu
.z80C
= cpu
.z80YH
;
11785 sdwCyclesRemaining
-= 9;
11786 cpu
.z80C
= cpu
.z80YL
;
11791 sdwCyclesRemaining
-= 19;
11792 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
11793 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
11794 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11795 while (psMemRead
->lowAddr
!= 0xffffffff)
11797 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
11799 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11800 if (psMemRead
->memoryCall
)
11802 cpu
.z80C
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
11806 cpu
.z80C
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
11816 cpu
.z80C
= cpu
.z80Base
[sdwAddr
];
11823 InvalidInstruction(2);
11828 InvalidInstruction(2);
11833 InvalidInstruction(2);
11838 InvalidInstruction(2);
11843 InvalidInstruction(2);
11848 sdwCyclesRemaining
-= 9;
11849 cpu
.z80D
= cpu
.z80YH
;
11854 sdwCyclesRemaining
-= 9;
11855 cpu
.z80D
= cpu
.z80YL
;
11860 sdwCyclesRemaining
-= 19;
11861 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
11862 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
11863 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11864 while (psMemRead
->lowAddr
!= 0xffffffff)
11866 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
11868 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11869 if (psMemRead
->memoryCall
)
11871 cpu
.z80D
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
11875 cpu
.z80D
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
11885 cpu
.z80D
= cpu
.z80Base
[sdwAddr
];
11892 InvalidInstruction(2);
11897 InvalidInstruction(2);
11902 InvalidInstruction(2);
11907 InvalidInstruction(2);
11912 InvalidInstruction(2);
11917 sdwCyclesRemaining
-= 9;
11918 cpu
.z80E
= cpu
.z80YH
;
11923 sdwCyclesRemaining
-= 9;
11924 cpu
.z80E
= cpu
.z80YL
;
11929 sdwCyclesRemaining
-= 19;
11930 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
11931 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
11932 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
11933 while (psMemRead
->lowAddr
!= 0xffffffff)
11935 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
11937 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
11938 if (psMemRead
->memoryCall
)
11940 cpu
.z80E
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
11944 cpu
.z80E
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
11954 cpu
.z80E
= cpu
.z80Base
[sdwAddr
];
11961 InvalidInstruction(2);
11966 sdwCyclesRemaining
-= 9;
11967 cpu
.z80YH
= cpu
.z80B
;
11972 sdwCyclesRemaining
-= 9;
11973 cpu
.z80YH
= cpu
.z80C
;
11978 sdwCyclesRemaining
-= 9;
11979 cpu
.z80YH
= cpu
.z80D
;
11984 sdwCyclesRemaining
-= 9;
11985 cpu
.z80YH
= cpu
.z80E
;
11990 sdwCyclesRemaining
-= 9;
11995 sdwCyclesRemaining
-= 9;
11996 cpu
.z80YH
= cpu
.z80YL
;
12001 sdwCyclesRemaining
-= 19;
12002 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12003 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12004 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12005 while (psMemRead
->lowAddr
!= 0xffffffff)
12007 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
12009 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12010 if (psMemRead
->memoryCall
)
12012 cpu
.z80H
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
12016 cpu
.z80H
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
12026 cpu
.z80H
= cpu
.z80Base
[sdwAddr
];
12033 sdwCyclesRemaining
-= 9;
12034 cpu
.z80YH
= cpu
.z80A
;
12039 sdwCyclesRemaining
-= 9;
12040 cpu
.z80YL
= cpu
.z80B
;
12045 sdwCyclesRemaining
-= 9;
12046 cpu
.z80YL
= cpu
.z80C
;
12051 sdwCyclesRemaining
-= 9;
12052 cpu
.z80YL
= cpu
.z80D
;
12057 sdwCyclesRemaining
-= 9;
12058 cpu
.z80YL
= cpu
.z80E
;
12063 sdwCyclesRemaining
-= 9;
12064 cpu
.z80YL
= cpu
.z80YH
;
12069 sdwCyclesRemaining
-= 9;
12074 sdwCyclesRemaining
-= 19;
12075 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12076 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12077 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12078 while (psMemRead
->lowAddr
!= 0xffffffff)
12080 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
12082 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12083 if (psMemRead
->memoryCall
)
12085 cpu
.z80L
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
12089 cpu
.z80L
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
12099 cpu
.z80L
= cpu
.z80Base
[sdwAddr
];
12106 sdwCyclesRemaining
-= 9;
12107 cpu
.z80YL
= cpu
.z80A
;
12112 sdwCyclesRemaining
-= 19;
12113 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12114 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12115 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12116 while (psMemWrite
->lowAddr
!= 0xffffffff)
12118 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12120 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12121 if (psMemWrite
->memoryCall
)
12123 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80B
, psMemWrite
);
12127 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80B
;
12137 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80B
;
12144 sdwCyclesRemaining
-= 19;
12145 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12146 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12147 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12148 while (psMemWrite
->lowAddr
!= 0xffffffff)
12150 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12152 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12153 if (psMemWrite
->memoryCall
)
12155 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80C
, psMemWrite
);
12159 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80C
;
12169 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80C
;
12176 sdwCyclesRemaining
-= 19;
12177 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12178 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12179 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12180 while (psMemWrite
->lowAddr
!= 0xffffffff)
12182 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12184 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12185 if (psMemWrite
->memoryCall
)
12187 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80D
, psMemWrite
);
12191 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80D
;
12201 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80D
;
12208 sdwCyclesRemaining
-= 19;
12209 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12210 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12211 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12212 while (psMemWrite
->lowAddr
!= 0xffffffff)
12214 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12216 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12217 if (psMemWrite
->memoryCall
)
12219 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80E
, psMemWrite
);
12223 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80E
;
12233 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80E
;
12240 sdwCyclesRemaining
-= 19;
12241 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12242 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12243 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12244 while (psMemWrite
->lowAddr
!= 0xffffffff)
12246 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12248 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12249 if (psMemWrite
->memoryCall
)
12251 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80H
, psMemWrite
);
12255 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80H
;
12265 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80H
;
12272 sdwCyclesRemaining
-= 19;
12273 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12274 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12275 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12276 while (psMemWrite
->lowAddr
!= 0xffffffff)
12278 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12280 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12281 if (psMemWrite
->memoryCall
)
12283 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80L
, psMemWrite
);
12287 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80L
;
12297 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80L
;
12304 sdwCyclesRemaining
-= 19;
12305 InvalidInstruction(2);
12310 sdwCyclesRemaining
-= 19;
12311 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12312 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12313 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
12314 while (psMemWrite
->lowAddr
!= 0xffffffff)
12316 if ((sdwAddr
>= psMemWrite
->lowAddr
) && (sdwAddr
<= psMemWrite
->highAddr
))
12318 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12319 if (psMemWrite
->memoryCall
)
12321 psMemWrite
->memoryCall(sdwAddr
, cpu
.z80A
, psMemWrite
);
12325 *((UINT8
*) psMemWrite
->pUserArea
+ (sdwAddr
- psMemWrite
->lowAddr
)) = cpu
.z80A
;
12335 cpu
.z80Base
[sdwAddr
] = (UINT8
) cpu
.z80A
;
12342 InvalidInstruction(2);
12347 InvalidInstruction(2);
12352 InvalidInstruction(2);
12357 InvalidInstruction(2);
12362 sdwCyclesRemaining
-= 9;
12363 cpu
.z80A
= cpu
.z80YH
;
12368 sdwCyclesRemaining
-= 9;
12369 cpu
.z80A
= cpu
.z80YL
;
12374 sdwCyclesRemaining
-= 19;
12375 sdwAddr
= (INT8
) *pbPC
++; // Get the offset
12376 sdwAddr
= ((INT32
) cpu
.z80IY
+ sdwAddr
) & 0xffff;
12377 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12378 while (psMemRead
->lowAddr
!= 0xffffffff)
12380 if ((sdwAddr
>= psMemRead
->lowAddr
) && (sdwAddr
<= psMemRead
->highAddr
))
12382 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12383 if (psMemRead
->memoryCall
)
12385 cpu
.z80A
= psMemRead
->memoryCall(sdwAddr
, psMemRead
);
12389 cpu
.z80A
= *((UINT8
*) psMemRead
->pUserArea
+ (sdwAddr
- psMemRead
->lowAddr
));
12399 cpu
.z80A
= cpu
.z80Base
[sdwAddr
];
12406 InvalidInstruction(2);
12411 InvalidInstruction(2);
12416 InvalidInstruction(2);
12421 InvalidInstruction(2);
12426 InvalidInstruction(2);
12431 sdwCyclesRemaining
-= 9;
12432 bTemp2
= cpu
.z80A
+ cpu
.z80YH
;
12433 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12434 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12435 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YH
];
12436 InvalidInstruction(2);
12441 sdwCyclesRemaining
-= 9;
12442 bTemp2
= cpu
.z80A
+ cpu
.z80YL
;
12443 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12444 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12445 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YL
];
12446 InvalidInstruction(2);
12451 sdwCyclesRemaining
-= 19;
12452 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12453 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12454 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12455 while (psMemRead
->lowAddr
!= 0xffffffff)
12457 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12459 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12460 if (psMemRead
->memoryCall
)
12462 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12466 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12476 bTemp
= cpu
.z80Base
[dwAddr
];
12479 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12480 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12481 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
12487 InvalidInstruction(2);
12492 InvalidInstruction(2);
12497 InvalidInstruction(2);
12502 InvalidInstruction(2);
12507 InvalidInstruction(2);
12512 sdwCyclesRemaining
-= 9;
12513 bTemp2
= cpu
.z80A
+ cpu
.z80YH
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
12514 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12515 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12516 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YH
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
12517 InvalidInstruction(2);
12522 sdwCyclesRemaining
-= 9;
12523 bTemp2
= cpu
.z80A
+ cpu
.z80YL
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
12524 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12525 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12526 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YL
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
12527 InvalidInstruction(2);
12532 sdwCyclesRemaining
-= 19;
12533 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12534 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12535 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12536 while (psMemRead
->lowAddr
!= 0xffffffff)
12538 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12540 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12541 if (psMemRead
->memoryCall
)
12543 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12547 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12557 bTemp
= cpu
.z80Base
[dwAddr
];
12560 bTemp2
= (cpu
.z80F
& Z80_FLAG_CARRY
);
12561 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12562 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12563 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
12564 cpu
.z80A
+= bTemp
+ bTemp2
;
12569 InvalidInstruction(2);
12574 InvalidInstruction(2);
12579 InvalidInstruction(2);
12584 InvalidInstruction(2);
12589 InvalidInstruction(2);
12594 sdwCyclesRemaining
-= 9;
12595 bTemp2
= cpu
.z80A
- cpu
.z80YH
;
12596 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12597 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12598 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YH
];
12599 InvalidInstruction(2);
12604 sdwCyclesRemaining
-= 9;
12605 bTemp2
= cpu
.z80A
- cpu
.z80YL
;
12606 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12607 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12608 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YL
];
12609 InvalidInstruction(2);
12614 sdwCyclesRemaining
-= 19;
12615 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12616 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12617 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12618 while (psMemRead
->lowAddr
!= 0xffffffff)
12620 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12622 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12623 if (psMemRead
->memoryCall
)
12625 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12629 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12639 bTemp
= cpu
.z80Base
[dwAddr
];
12642 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12643 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12644 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
12650 InvalidInstruction(2);
12655 InvalidInstruction(2);
12660 InvalidInstruction(2);
12665 InvalidInstruction(2);
12670 InvalidInstruction(2);
12675 sdwCyclesRemaining
-= 9;
12676 bTemp2
= cpu
.z80A
- cpu
.z80YH
- (cpu
.z80F
& Z80_FLAG_CARRY
);
12677 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12678 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12679 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YH
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
12680 InvalidInstruction(2);
12685 sdwCyclesRemaining
-= 9;
12686 bTemp2
= cpu
.z80A
- cpu
.z80YL
- (cpu
.z80F
& Z80_FLAG_CARRY
);
12687 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12688 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12689 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80YL
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
12690 InvalidInstruction(2);
12695 sdwCyclesRemaining
-= 19;
12696 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12697 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12698 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12699 while (psMemRead
->lowAddr
!= 0xffffffff)
12701 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12703 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12704 if (psMemRead
->memoryCall
)
12706 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12710 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12720 bTemp
= cpu
.z80Base
[dwAddr
];
12724 cpu
.z80A
= cpu
.z80A
- bTemp
- (cpu
.z80F
& Z80_FLAG_CARRY
);
12725 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
12726 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
12727 pbSubSbcTable
[((UINT32
) bTemp2
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
12732 InvalidInstruction(2);
12737 InvalidInstruction(2);
12742 InvalidInstruction(2);
12747 InvalidInstruction(2);
12752 InvalidInstruction(2);
12757 sdwCyclesRemaining
-= 9;
12758 cpu
.z80A
&= cpu
.z80YH
;
12759 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12760 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
12762 InvalidInstruction(2);
12767 sdwCyclesRemaining
-= 9;
12768 cpu
.z80A
&= cpu
.z80YL
;
12769 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12770 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
12772 InvalidInstruction(2);
12777 sdwCyclesRemaining
-= 19;
12778 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12779 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12780 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12781 while (psMemRead
->lowAddr
!= 0xffffffff)
12783 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12785 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12786 if (psMemRead
->memoryCall
)
12788 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12792 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12802 bTemp
= cpu
.z80Base
[dwAddr
];
12806 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12807 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
12813 InvalidInstruction(2);
12818 InvalidInstruction(2);
12823 InvalidInstruction(2);
12828 InvalidInstruction(2);
12833 InvalidInstruction(2);
12838 sdwCyclesRemaining
-= 9;
12839 cpu
.z80A
^= cpu
.z80YH
;
12840 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12841 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
12843 InvalidInstruction(2);
12848 sdwCyclesRemaining
-= 9;
12849 cpu
.z80A
^= cpu
.z80YL
;
12850 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12851 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
12853 InvalidInstruction(2);
12858 sdwCyclesRemaining
-= 19;
12859 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12860 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12861 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12862 while (psMemRead
->lowAddr
!= 0xffffffff)
12864 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12866 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12867 if (psMemRead
->memoryCall
)
12869 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12873 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12883 bTemp
= cpu
.z80Base
[dwAddr
];
12887 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12888 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
12894 InvalidInstruction(2);
12899 InvalidInstruction(2);
12904 InvalidInstruction(2);
12909 InvalidInstruction(2);
12914 InvalidInstruction(2);
12919 sdwCyclesRemaining
-= 9;
12920 cpu
.z80A
|= cpu
.z80YH
;
12921 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12922 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
12924 InvalidInstruction(2);
12929 sdwCyclesRemaining
-= 9;
12930 cpu
.z80A
|= cpu
.z80YL
;
12931 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12932 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
12934 InvalidInstruction(2);
12939 sdwCyclesRemaining
-= 19;
12940 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
12941 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
12942 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
12943 while (psMemRead
->lowAddr
!= 0xffffffff)
12945 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
12947 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
12948 if (psMemRead
->memoryCall
)
12950 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
12954 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
12964 bTemp
= cpu
.z80Base
[dwAddr
];
12968 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
12969 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
12975 InvalidInstruction(2);
12980 InvalidInstruction(2);
12985 InvalidInstruction(2);
12990 InvalidInstruction(2);
12995 InvalidInstruction(2);
13000 sdwCyclesRemaining
-= 9;
13001 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
13002 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
13004 InvalidInstruction(2);
13009 sdwCyclesRemaining
-= 9;
13010 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
13011 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
13013 InvalidInstruction(2);
13018 sdwCyclesRemaining
-= 19;
13019 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
13020 dwAddr
= (sdwAddr
+ (INT32
) cpu
.z80IY
) & 0xffff;
13021 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
13022 while (psMemRead
->lowAddr
!= 0xffffffff)
13024 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
13026 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13027 if (psMemRead
->memoryCall
)
13029 bTemp
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
13033 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
13043 bTemp
= cpu
.z80Base
[dwAddr
];
13046 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
13047 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
13048 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
13053 InvalidInstruction(2);
13058 InvalidInstruction(2);
13063 InvalidInstruction(2);
13068 InvalidInstruction(2);
13073 InvalidInstruction(2);
13078 InvalidInstruction(2);
13083 InvalidInstruction(2);
13088 InvalidInstruction(2);
13093 InvalidInstruction(2);
13098 InvalidInstruction(2);
13103 InvalidInstruction(2);
13108 InvalidInstruction(2);
13118 InvalidInstruction(2);
13123 InvalidInstruction(2);
13128 InvalidInstruction(2);
13133 InvalidInstruction(2);
13138 InvalidInstruction(2);
13143 InvalidInstruction(2);
13148 InvalidInstruction(2);
13153 InvalidInstruction(2);
13158 InvalidInstruction(2);
13163 InvalidInstruction(2);
13168 InvalidInstruction(2);
13173 InvalidInstruction(2);
13178 InvalidInstruction(2);
13183 InvalidInstruction(2);
13188 InvalidInstruction(2);
13193 InvalidInstruction(2);
13198 InvalidInstruction(2);
13203 InvalidInstruction(2);
13208 InvalidInstruction(2);
13213 InvalidInstruction(2);
13218 InvalidInstruction(2);
13223 sdwCyclesRemaining
-= 14;
13224 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
13225 while (psMemRead
->lowAddr
!= 0xffffffff)
13227 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
13229 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13230 if (psMemRead
->memoryCall
)
13232 cpu
.z80IY
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
13233 cpu
.z80IY
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
13237 cpu
.z80IY
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
13238 cpu
.z80IY
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
13248 cpu
.z80IY
= cpu
.z80Base
[cpu
.z80sp
];
13249 cpu
.z80IY
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
13253 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
13258 InvalidInstruction(2);
13263 sdwCyclesRemaining
-= 23;
13264 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
13265 while (psMemRead
->lowAddr
!= 0xffffffff)
13267 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
13269 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13270 if (psMemRead
->memoryCall
)
13272 dwAddr
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
13273 dwAddr
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
13277 dwAddr
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
13278 dwAddr
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
13288 dwAddr
= cpu
.z80Base
[cpu
.z80sp
];
13289 dwAddr
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
13292 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
13293 while (psMemWrite
->lowAddr
!= 0xffffffff)
13295 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
13297 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13298 if (psMemWrite
->memoryCall
)
13300 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80IY
& 0xff), psMemWrite
);
13301 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80IY
>> 8), psMemWrite
);
13305 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80IY
;
13306 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80IY
>> 8;
13316 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80IY
;
13317 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80IY
>> 8);
13320 cpu
.z80IY
= dwAddr
;
13325 InvalidInstruction(2);
13330 sdwCyclesRemaining
-= 15;
13332 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
13333 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
13334 while (psMemWrite
->lowAddr
!= 0xffffffff)
13336 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
13338 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13339 if (psMemWrite
->memoryCall
)
13341 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80IY
& 0xff), psMemWrite
);
13342 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80IY
>> 8), psMemWrite
);
13346 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80IY
;
13347 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80IY
>> 8;
13357 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80IY
;
13358 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80IY
>> 8);
13365 InvalidInstruction(2);
13370 InvalidInstruction(2);
13375 InvalidInstruction(2);
13380 sdwCyclesRemaining
-= 8;
13381 pbPC
= cpu
.z80Base
+ cpu
.z80IY
;
13386 InvalidInstruction(2);
13391 InvalidInstruction(2);
13396 InvalidInstruction(2);
13401 InvalidInstruction(2);
13406 InvalidInstruction(2);
13411 InvalidInstruction(2);
13416 InvalidInstruction(2);
13421 InvalidInstruction(2);
13426 InvalidInstruction(2);
13431 InvalidInstruction(2);
13436 InvalidInstruction(2);
13441 InvalidInstruction(2);
13446 InvalidInstruction(2);
13451 InvalidInstruction(2);
13456 InvalidInstruction(2);
13461 sdwCyclesRemaining
-= 10;
13462 cpu
.z80sp
= cpu
.z80IY
;
13467 InvalidInstruction(2);
13472 InvalidInstruction(2);
13477 InvalidInstruction(2);
13482 InvalidInstruction(2);
13487 InvalidInstruction(2);
13492 InvalidInstruction(2);
13497 /* Main execution entry point */
13499 UINT32
mz80exec(UINT32 dwCycles
)
13503 dwReturnCode
= 0x80000000; /* Assume it'll work */
13504 sdwCyclesRemaining
= dwCycles
;
13505 dwOriginalCycles
= dwCycles
;
13508 dwElapsedTicks
+= dwCycles
;
13509 return(0x80000000);
13512 pbPC
= cpu
.z80Base
+ cpu
.z80pc
;
13514 while (sdwCyclesRemaining
> 0)
13521 sdwCyclesRemaining
-= 4;
13522 /* Intentionally not doing anything - NOP! */
13527 sdwCyclesRemaining
-= 10;
13528 cpu
.z80BC
= *pbPC
++; /* LSB First */
13529 cpu
.z80BC
|= (((UINT32
) *pbPC
++ << 8)); /* Now the MSB */
13534 sdwCyclesRemaining
-= 7;
13535 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
13536 while (psMemWrite
->lowAddr
!= 0xffffffff)
13538 if ((cpu
.z80BC
>= psMemWrite
->lowAddr
) && (cpu
.z80BC
<= psMemWrite
->highAddr
))
13540 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13541 if (psMemWrite
->memoryCall
)
13543 psMemWrite
->memoryCall(cpu
.z80BC
, cpu
.z80A
, psMemWrite
);
13547 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80BC
- psMemWrite
->lowAddr
)) = cpu
.z80A
;
13557 cpu
.z80Base
[cpu
.z80BC
] = (UINT8
) cpu
.z80A
;
13564 sdwCyclesRemaining
-= 6;
13566 cpu
.z80BC
&= 0xffff;
13571 sdwCyclesRemaining
-= 4;
13572 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
13573 cpu
.z80F
|= bPostIncFlags
[cpu
.z80B
++];
13578 sdwCyclesRemaining
-= 4;
13579 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
13580 cpu
.z80F
|= bPostDecFlags
[cpu
.z80B
--];
13585 sdwCyclesRemaining
-= 7;
13586 cpu
.z80B
= *pbPC
++; /* Get immediate byte into register */
13591 sdwCyclesRemaining
-= 4;
13592 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
13593 cpu
.z80F
|= (cpu
.z80A
>> 7);
13594 cpu
.z80A
= (cpu
.z80A
<< 1) | (cpu
.z80A
>> 7);
13599 sdwCyclesRemaining
-= 4;
13600 dwAddr
= (UINT32
) cpu
.z80AF
;
13601 cpu
.z80AF
= cpu
.z80afprime
;
13602 cpu
.z80afprime
= dwAddr
;
13607 sdwCyclesRemaining
-= 11;
13608 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
13609 dwTemp
= cpu
.z80HL
+ cpu
.z80BC
;
13610 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80HL
^ dwTemp
^ cpu
.z80BC
) >> 8) & Z80_FLAG_HALF_CARRY
);
13611 cpu
.z80HL
= dwTemp
& 0xffff;
13616 sdwCyclesRemaining
-= 7;
13617 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
13618 while (psMemRead
->lowAddr
!= 0xffffffff)
13620 if ((cpu
.z80BC
>= psMemRead
->lowAddr
) && (cpu
.z80BC
<= psMemRead
->highAddr
))
13622 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13623 if (psMemRead
->memoryCall
)
13625 cpu
.z80A
= psMemRead
->memoryCall(cpu
.z80BC
, psMemRead
);
13629 cpu
.z80A
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80BC
- psMemRead
->lowAddr
));
13639 cpu
.z80A
= cpu
.z80Base
[cpu
.z80BC
];
13646 sdwCyclesRemaining
-= 6;
13648 cpu
.z80BC
&= 0xffff;
13653 sdwCyclesRemaining
-= 4;
13654 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
13655 cpu
.z80F
|= bPostIncFlags
[cpu
.z80C
++];
13660 sdwCyclesRemaining
-= 4;
13661 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
13662 cpu
.z80F
|= bPostDecFlags
[cpu
.z80C
--];
13667 sdwCyclesRemaining
-= 7;
13668 cpu
.z80C
= *pbPC
++; /* Get immediate byte into register */
13673 sdwCyclesRemaining
-= 4;
13674 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
13675 cpu
.z80F
|= (cpu
.z80A
& Z80_FLAG_CARRY
);
13676 cpu
.z80A
= (cpu
.z80A
>> 1) | (cpu
.z80A
<< 7);
13681 sdwCyclesRemaining
-= 8;
13682 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
13685 dwElapsedTicks
+= 5; /* 5 More for jump taken */
13686 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13687 sdwAddr
= (sdwAddr
+ (INT32
) cpu
.z80pc
) & 0xffff;
13688 pbPC
= cpu
.z80Base
+ sdwAddr
; /* Normalize the address */
13694 sdwCyclesRemaining
-= 10;
13695 cpu
.z80DE
= *pbPC
++; /* LSB First */
13696 cpu
.z80DE
|= (((UINT32
) *pbPC
++ << 8)); /* Now the MSB */
13701 sdwCyclesRemaining
-= 7;
13702 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
13703 while (psMemWrite
->lowAddr
!= 0xffffffff)
13705 if ((cpu
.z80DE
>= psMemWrite
->lowAddr
) && (cpu
.z80DE
<= psMemWrite
->highAddr
))
13707 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13708 if (psMemWrite
->memoryCall
)
13710 psMemWrite
->memoryCall(cpu
.z80DE
, cpu
.z80A
, psMemWrite
);
13714 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80DE
- psMemWrite
->lowAddr
)) = cpu
.z80A
;
13724 cpu
.z80Base
[cpu
.z80DE
] = (UINT8
) cpu
.z80A
;
13731 sdwCyclesRemaining
-= 6;
13733 cpu
.z80DE
&= 0xffff;
13738 sdwCyclesRemaining
-= 4;
13739 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
13740 cpu
.z80F
|= bPostIncFlags
[cpu
.z80D
++];
13745 sdwCyclesRemaining
-= 4;
13746 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
13747 cpu
.z80F
|= bPostDecFlags
[cpu
.z80D
--];
13752 sdwCyclesRemaining
-= 7;
13753 cpu
.z80D
= *pbPC
++; /* Get immediate byte into register */
13758 sdwCyclesRemaining
-= 4;
13759 bTemp
= cpu
.z80A
>> 7;
13760 cpu
.z80A
= (cpu
.z80A
<< 1) | (cpu
.z80F
& Z80_FLAG_CARRY
);
13761 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
)) | bTemp
;
13766 sdwCyclesRemaining
-= 12;
13767 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
13768 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13769 sdwAddr
= (sdwAddr
+ (INT32
) cpu
.z80pc
) & 0xffff;
13771 sdwCyclesRemaining
-= 5;
13772 pbPC
= cpu
.z80Base
+ sdwAddr
; /* Normalize the address */
13778 sdwCyclesRemaining
-= 11;
13779 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
13780 dwTemp
= cpu
.z80HL
+ cpu
.z80DE
;
13781 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80HL
^ dwTemp
^ cpu
.z80DE
) >> 8) & Z80_FLAG_HALF_CARRY
);
13782 cpu
.z80HL
= dwTemp
& 0xffff;
13787 sdwCyclesRemaining
-= 7;
13788 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
13789 while (psMemRead
->lowAddr
!= 0xffffffff)
13791 if ((cpu
.z80DE
>= psMemRead
->lowAddr
) && (cpu
.z80DE
<= psMemRead
->highAddr
))
13793 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13794 if (psMemRead
->memoryCall
)
13796 cpu
.z80A
= psMemRead
->memoryCall(cpu
.z80DE
, psMemRead
);
13800 cpu
.z80A
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80DE
- psMemRead
->lowAddr
));
13810 cpu
.z80A
= cpu
.z80Base
[cpu
.z80DE
];
13817 sdwCyclesRemaining
-= 6;
13819 cpu
.z80DE
&= 0xffff;
13824 sdwCyclesRemaining
-= 4;
13825 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
13826 cpu
.z80F
|= bPostIncFlags
[cpu
.z80E
++];
13831 sdwCyclesRemaining
-= 4;
13832 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
13833 cpu
.z80F
|= bPostDecFlags
[cpu
.z80E
--];
13838 sdwCyclesRemaining
-= 7;
13839 cpu
.z80E
= *pbPC
++; /* Get immediate byte into register */
13844 sdwCyclesRemaining
-= 4;
13845 bTemp
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 7;
13846 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
)) | (cpu
.z80A
& Z80_FLAG_CARRY
);
13847 cpu
.z80A
= ((cpu
.z80A
>> 1) | bTemp
);
13852 sdwCyclesRemaining
-= 7;
13853 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
13854 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13855 sdwAddr
= (sdwAddr
+ (INT32
) cpu
.z80pc
) & 0xffff;
13856 if (!(cpu
.z80F
& Z80_FLAG_ZERO
))
13858 sdwCyclesRemaining
-= 5;
13859 pbPC
= cpu
.z80Base
+ sdwAddr
; /* Normalize the address */
13865 sdwCyclesRemaining
-= 10;
13866 cpu
.z80HL
= *pbPC
++; /* LSB First */
13867 cpu
.z80HL
|= (((UINT32
) *pbPC
++ << 8)); /* Now the MSB */
13872 sdwCyclesRemaining
-= 16;
13874 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
13875 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
13876 while (psMemWrite
->lowAddr
!= 0xffffffff)
13878 if ((dwTemp
>= psMemWrite
->lowAddr
) && (dwTemp
<= psMemWrite
->highAddr
))
13880 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13881 if (psMemWrite
->memoryCall
)
13883 psMemWrite
->memoryCall(dwTemp
, (cpu
.z80HL
& 0xff), psMemWrite
);
13884 psMemWrite
->memoryCall(dwTemp
+ 1, (cpu
.z80HL
>> 8), psMemWrite
);
13888 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
)) = cpu
.z80HL
;
13889 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80HL
>> 8;
13899 cpu
.z80Base
[dwTemp
] = (UINT8
) cpu
.z80HL
;
13900 cpu
.z80Base
[dwTemp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80HL
>> 8);
13907 sdwCyclesRemaining
-= 6;
13909 cpu
.z80HL
&= 0xffff;
13914 sdwCyclesRemaining
-= 4;
13915 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
13916 cpu
.z80F
|= bPostIncFlags
[cpu
.z80H
++];
13921 sdwCyclesRemaining
-= 4;
13922 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
13923 cpu
.z80F
|= bPostDecFlags
[cpu
.z80H
--];
13928 sdwCyclesRemaining
-= 7;
13929 cpu
.z80H
= *pbPC
++; /* Get immediate byte into register */
13934 sdwCyclesRemaining
-= 4;
13935 dwAddr
= (((cpu
.z80F
& Z80_FLAG_CARRY
) |
13936 ((cpu
.z80F
& Z80_FLAG_HALF_CARRY
) >> 3) |
13937 ((cpu
.z80F
& Z80_FLAG_NEGATIVE
) << 1)) << 8) | cpu
.z80A
;
13938 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
13939 cpu
.z80F
|= (wDAATable
[dwAddr
] >> 8);
13940 cpu
.z80A
= wDAATable
[dwAddr
] & 0xff;
13945 sdwCyclesRemaining
-= 7;
13946 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
13947 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13948 sdwAddr
= (sdwAddr
+ (INT32
) cpu
.z80pc
) & 0xffff;
13949 if (cpu
.z80F
& Z80_FLAG_ZERO
)
13951 sdwCyclesRemaining
-= 5;
13952 pbPC
= cpu
.z80Base
+ sdwAddr
; /* Normalize the address */
13958 sdwCyclesRemaining
-= 11;
13959 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
13960 dwTemp
= cpu
.z80HL
+ cpu
.z80HL
;
13961 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80HL
^ dwTemp
^ cpu
.z80HL
) >> 8) & Z80_FLAG_HALF_CARRY
);
13962 cpu
.z80HL
= dwTemp
& 0xffff;
13967 sdwCyclesRemaining
-= 16;
13969 dwAddr
|= ((UINT32
) *pbPC
++ << 8);
13970 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
13971 while (psMemRead
->lowAddr
!= 0xffffffff)
13973 if ((dwAddr
>= psMemRead
->lowAddr
) && (dwAddr
<= psMemRead
->highAddr
))
13975 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
13976 if (psMemRead
->memoryCall
)
13978 cpu
.z80HL
= psMemRead
->memoryCall(dwAddr
, psMemRead
);
13979 cpu
.z80HL
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(dwAddr
+ 1, psMemRead
) << 8);
13983 cpu
.z80HL
= *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
));
13984 cpu
.z80HL
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (dwAddr
- psMemRead
->lowAddr
+ 1)) << 8);
13994 cpu
.z80HL
= cpu
.z80Base
[dwAddr
];
13995 cpu
.z80HL
|= (UINT32
) ((UINT32
) cpu
.z80Base
[dwAddr
+ 1] << 8);
14002 sdwCyclesRemaining
-= 6;
14004 cpu
.z80HL
&= 0xffff;
14009 sdwCyclesRemaining
-= 4;
14010 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
14011 cpu
.z80F
|= bPostIncFlags
[cpu
.z80L
++];
14016 sdwCyclesRemaining
-= 4;
14017 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
14018 cpu
.z80F
|= bPostDecFlags
[cpu
.z80L
--];
14023 sdwCyclesRemaining
-= 7;
14024 cpu
.z80L
= *pbPC
++; /* Get immediate byte into register */
14029 sdwCyclesRemaining
-= 4;
14031 cpu
.z80F
|= (Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
14036 sdwCyclesRemaining
-= 7;
14037 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
14038 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14039 sdwAddr
= (sdwAddr
+ (INT32
) cpu
.z80pc
) & 0xffff;
14040 if (!(cpu
.z80F
& Z80_FLAG_CARRY
))
14042 sdwCyclesRemaining
-= 5;
14043 pbPC
= cpu
.z80Base
+ sdwAddr
; /* Normalize the address */
14049 sdwCyclesRemaining
-= 10;
14050 cpu
.z80sp
= *pbPC
++; /* LSB First */
14051 cpu
.z80sp
|= (((UINT32
) *pbPC
++ << 8)); /* Now the MSB */
14056 sdwCyclesRemaining
-= 13;
14058 dwTemp
|= ((UINT32
) *pbPC
++ << 8);
14059 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14060 while (psMemWrite
->lowAddr
!= 0xffffffff)
14062 if ((dwTemp
>= psMemWrite
->lowAddr
) && (dwTemp
<= psMemWrite
->highAddr
))
14064 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14065 if (psMemWrite
->memoryCall
)
14067 psMemWrite
->memoryCall(dwTemp
, cpu
.z80A
, psMemWrite
);
14071 *((UINT8
*) psMemWrite
->pUserArea
+ (dwTemp
- psMemWrite
->lowAddr
)) = cpu
.z80A
;
14081 cpu
.z80Base
[dwTemp
] = (UINT8
) cpu
.z80A
;
14088 sdwCyclesRemaining
-= 6;
14090 cpu
.z80sp
&= 0xffff;
14095 sdwCyclesRemaining
-= 11;
14096 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14097 while (psMemRead
->lowAddr
!= 0xffffffff)
14099 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14101 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14102 if (psMemRead
->memoryCall
)
14104 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14108 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14118 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
14121 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
14122 cpu
.z80F
|= bPostIncFlags
[bTemp
];
14124 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14125 while (psMemWrite
->lowAddr
!= 0xffffffff)
14127 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14129 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14130 if (psMemWrite
->memoryCall
)
14132 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
14136 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
14146 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
14153 sdwCyclesRemaining
-= 11;
14154 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14155 while (psMemRead
->lowAddr
!= 0xffffffff)
14157 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14159 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14160 if (psMemRead
->memoryCall
)
14162 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14166 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14176 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
14179 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
14180 cpu
.z80F
|= bPostDecFlags
[bTemp
];
14182 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14183 while (psMemWrite
->lowAddr
!= 0xffffffff)
14185 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14187 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14188 if (psMemWrite
->memoryCall
)
14190 psMemWrite
->memoryCall(cpu
.z80HL
, bTemp
, psMemWrite
);
14194 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = bTemp
;
14204 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) bTemp
;
14211 sdwCyclesRemaining
-= 10;
14212 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14213 while (psMemWrite
->lowAddr
!= 0xffffffff)
14215 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14217 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14218 if (psMemWrite
->memoryCall
)
14220 psMemWrite
->memoryCall(cpu
.z80HL
, *pbPC
++, psMemWrite
);
14224 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = *pbPC
++;
14234 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) *pbPC
++;
14241 sdwCyclesRemaining
-= 4;
14242 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
);
14243 cpu
.z80F
|= Z80_FLAG_CARRY
;
14248 sdwCyclesRemaining
-= 7;
14249 sdwAddr
= (INT8
) *pbPC
++; /* Get LSB first */
14250 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14251 sdwAddr
= (sdwAddr
+ (INT32
) cpu
.z80pc
) & 0xffff;
14252 if (cpu
.z80F
& Z80_FLAG_CARRY
)
14254 sdwCyclesRemaining
-= 5;
14255 pbPC
= cpu
.z80Base
+ sdwAddr
; /* Normalize the address */
14261 sdwCyclesRemaining
-= 11;
14262 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_HALF_CARRY
);
14263 dwTemp
= cpu
.z80HL
+ cpu
.z80sp
;
14264 cpu
.z80F
|= ((dwTemp
>> 16) & Z80_FLAG_CARRY
) | (((cpu
.z80HL
^ dwTemp
^ cpu
.z80sp
) >> 8) & Z80_FLAG_HALF_CARRY
);
14265 cpu
.z80HL
= dwTemp
& 0xffff;
14270 sdwCyclesRemaining
-= 13;
14272 dwTemp
|= (((UINT32
) *pbPC
++) << 8);
14273 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14274 while (psMemRead
->lowAddr
!= 0xffffffff)
14276 if ((dwTemp
>= psMemRead
->lowAddr
) && (dwTemp
<= psMemRead
->highAddr
))
14278 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14279 if (psMemRead
->memoryCall
)
14281 cpu
.z80A
= psMemRead
->memoryCall(dwTemp
, psMemRead
);
14285 cpu
.z80A
= *((UINT8
*) psMemRead
->pUserArea
+ (dwTemp
- psMemRead
->lowAddr
));
14295 cpu
.z80A
= cpu
.z80Base
[dwTemp
];
14302 sdwCyclesRemaining
-= 6;
14304 cpu
.z80sp
&= 0xffff;
14309 sdwCyclesRemaining
-= 4;
14310 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_NEGATIVE
);
14311 cpu
.z80F
|= bPostIncFlags
[cpu
.z80A
++];
14316 sdwCyclesRemaining
-= 4;
14317 cpu
.z80F
&= ~(Z80_FLAG_SIGN
| Z80_FLAG_ZERO
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_OVERFLOW_PARITY
);
14318 cpu
.z80F
|= bPostDecFlags
[cpu
.z80A
--];
14323 sdwCyclesRemaining
-= 7;
14324 cpu
.z80A
= *pbPC
++; /* Get immediate byte into register */
14329 sdwCyclesRemaining
-= 4;
14330 bTemp
= (cpu
.z80F
& Z80_FLAG_CARRY
) << 4;
14331 cpu
.z80F
&= ~(Z80_FLAG_HALF_CARRY
| Z80_FLAG_NEGATIVE
);
14332 cpu
.z80F
^= Z80_FLAG_CARRY
;
14337 sdwCyclesRemaining
-= 4;
14342 sdwCyclesRemaining
-= 4;
14343 cpu
.z80B
= cpu
.z80C
;
14348 sdwCyclesRemaining
-= 4;
14349 cpu
.z80B
= cpu
.z80D
;
14354 sdwCyclesRemaining
-= 4;
14355 cpu
.z80B
= cpu
.z80E
;
14360 sdwCyclesRemaining
-= 4;
14361 cpu
.z80B
= cpu
.z80H
;
14366 sdwCyclesRemaining
-= 4;
14367 cpu
.z80B
= cpu
.z80L
;
14372 sdwCyclesRemaining
-= 7;
14373 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14374 while (psMemRead
->lowAddr
!= 0xffffffff)
14376 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14378 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14379 if (psMemRead
->memoryCall
)
14381 cpu
.z80B
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14385 cpu
.z80B
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14395 cpu
.z80B
= cpu
.z80Base
[cpu
.z80HL
];
14402 sdwCyclesRemaining
-= 4;
14403 cpu
.z80B
= cpu
.z80A
;
14408 sdwCyclesRemaining
-= 4;
14409 cpu
.z80C
= cpu
.z80B
;
14414 sdwCyclesRemaining
-= 4;
14419 sdwCyclesRemaining
-= 4;
14420 cpu
.z80C
= cpu
.z80D
;
14425 sdwCyclesRemaining
-= 4;
14426 cpu
.z80C
= cpu
.z80E
;
14431 sdwCyclesRemaining
-= 4;
14432 cpu
.z80C
= cpu
.z80H
;
14437 sdwCyclesRemaining
-= 4;
14438 cpu
.z80C
= cpu
.z80L
;
14443 sdwCyclesRemaining
-= 7;
14444 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14445 while (psMemRead
->lowAddr
!= 0xffffffff)
14447 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14449 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14450 if (psMemRead
->memoryCall
)
14452 cpu
.z80C
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14456 cpu
.z80C
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14466 cpu
.z80C
= cpu
.z80Base
[cpu
.z80HL
];
14473 sdwCyclesRemaining
-= 4;
14474 cpu
.z80C
= cpu
.z80A
;
14479 sdwCyclesRemaining
-= 4;
14480 cpu
.z80D
= cpu
.z80B
;
14485 sdwCyclesRemaining
-= 4;
14486 cpu
.z80D
= cpu
.z80C
;
14491 sdwCyclesRemaining
-= 4;
14496 sdwCyclesRemaining
-= 4;
14497 cpu
.z80D
= cpu
.z80E
;
14502 sdwCyclesRemaining
-= 4;
14503 cpu
.z80D
= cpu
.z80H
;
14508 sdwCyclesRemaining
-= 4;
14509 cpu
.z80D
= cpu
.z80L
;
14514 sdwCyclesRemaining
-= 7;
14515 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14516 while (psMemRead
->lowAddr
!= 0xffffffff)
14518 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14520 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14521 if (psMemRead
->memoryCall
)
14523 cpu
.z80D
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14527 cpu
.z80D
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14537 cpu
.z80D
= cpu
.z80Base
[cpu
.z80HL
];
14544 sdwCyclesRemaining
-= 4;
14545 cpu
.z80D
= cpu
.z80A
;
14550 sdwCyclesRemaining
-= 4;
14551 cpu
.z80E
= cpu
.z80B
;
14556 sdwCyclesRemaining
-= 4;
14557 cpu
.z80E
= cpu
.z80C
;
14562 sdwCyclesRemaining
-= 4;
14563 cpu
.z80E
= cpu
.z80D
;
14568 sdwCyclesRemaining
-= 4;
14573 sdwCyclesRemaining
-= 4;
14574 cpu
.z80E
= cpu
.z80H
;
14579 sdwCyclesRemaining
-= 4;
14580 cpu
.z80E
= cpu
.z80L
;
14585 sdwCyclesRemaining
-= 7;
14586 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14587 while (psMemRead
->lowAddr
!= 0xffffffff)
14589 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14591 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14592 if (psMemRead
->memoryCall
)
14594 cpu
.z80E
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14598 cpu
.z80E
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14608 cpu
.z80E
= cpu
.z80Base
[cpu
.z80HL
];
14615 sdwCyclesRemaining
-= 4;
14616 cpu
.z80E
= cpu
.z80A
;
14621 sdwCyclesRemaining
-= 4;
14622 cpu
.z80H
= cpu
.z80B
;
14627 sdwCyclesRemaining
-= 4;
14628 cpu
.z80H
= cpu
.z80C
;
14633 sdwCyclesRemaining
-= 4;
14634 cpu
.z80H
= cpu
.z80D
;
14639 sdwCyclesRemaining
-= 4;
14640 cpu
.z80H
= cpu
.z80E
;
14645 sdwCyclesRemaining
-= 4;
14650 sdwCyclesRemaining
-= 4;
14651 cpu
.z80H
= cpu
.z80L
;
14656 sdwCyclesRemaining
-= 7;
14657 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14658 while (psMemRead
->lowAddr
!= 0xffffffff)
14660 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14662 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14663 if (psMemRead
->memoryCall
)
14665 cpu
.z80H
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14669 cpu
.z80H
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14679 cpu
.z80H
= cpu
.z80Base
[cpu
.z80HL
];
14686 sdwCyclesRemaining
-= 4;
14687 cpu
.z80H
= cpu
.z80A
;
14692 sdwCyclesRemaining
-= 4;
14693 cpu
.z80L
= cpu
.z80B
;
14698 sdwCyclesRemaining
-= 4;
14699 cpu
.z80L
= cpu
.z80C
;
14704 sdwCyclesRemaining
-= 4;
14705 cpu
.z80L
= cpu
.z80D
;
14710 sdwCyclesRemaining
-= 4;
14711 cpu
.z80L
= cpu
.z80E
;
14716 sdwCyclesRemaining
-= 4;
14717 cpu
.z80L
= cpu
.z80H
;
14722 sdwCyclesRemaining
-= 4;
14727 sdwCyclesRemaining
-= 7;
14728 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
14729 while (psMemRead
->lowAddr
!= 0xffffffff)
14731 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
14733 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14734 if (psMemRead
->memoryCall
)
14736 cpu
.z80L
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
14740 cpu
.z80L
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
14750 cpu
.z80L
= cpu
.z80Base
[cpu
.z80HL
];
14757 sdwCyclesRemaining
-= 4;
14758 cpu
.z80L
= cpu
.z80A
;
14763 sdwCyclesRemaining
-= 7;
14764 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14765 while (psMemWrite
->lowAddr
!= 0xffffffff)
14767 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14769 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14770 if (psMemWrite
->memoryCall
)
14772 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80B
, psMemWrite
);
14776 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80B
;
14786 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80B
;
14793 sdwCyclesRemaining
-= 7;
14794 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14795 while (psMemWrite
->lowAddr
!= 0xffffffff)
14797 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14799 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14800 if (psMemWrite
->memoryCall
)
14802 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80C
, psMemWrite
);
14806 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80C
;
14816 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80C
;
14823 sdwCyclesRemaining
-= 7;
14824 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14825 while (psMemWrite
->lowAddr
!= 0xffffffff)
14827 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14829 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14830 if (psMemWrite
->memoryCall
)
14832 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80D
, psMemWrite
);
14836 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80D
;
14846 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80D
;
14853 sdwCyclesRemaining
-= 7;
14854 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14855 while (psMemWrite
->lowAddr
!= 0xffffffff)
14857 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14859 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14860 if (psMemWrite
->memoryCall
)
14862 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80E
, psMemWrite
);
14866 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80E
;
14876 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80E
;
14883 sdwCyclesRemaining
-= 7;
14884 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14885 while (psMemWrite
->lowAddr
!= 0xffffffff)
14887 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14889 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14890 if (psMemWrite
->memoryCall
)
14892 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80H
, psMemWrite
);
14896 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80H
;
14906 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80H
;
14913 sdwCyclesRemaining
-= 7;
14914 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14915 while (psMemWrite
->lowAddr
!= 0xffffffff)
14917 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14919 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14920 if (psMemWrite
->memoryCall
)
14922 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80L
, psMemWrite
);
14926 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80L
;
14936 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80L
;
14943 sdwCyclesRemaining
-= 4;
14945 dwElapsedTicks
+= sdwCyclesRemaining
;
14946 sdwCyclesRemaining
= 0;
14951 sdwCyclesRemaining
-= 7;
14952 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
14953 while (psMemWrite
->lowAddr
!= 0xffffffff)
14955 if ((cpu
.z80HL
>= psMemWrite
->lowAddr
) && (cpu
.z80HL
<= psMemWrite
->highAddr
))
14957 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
14958 if (psMemWrite
->memoryCall
)
14960 psMemWrite
->memoryCall(cpu
.z80HL
, cpu
.z80A
, psMemWrite
);
14964 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80HL
- psMemWrite
->lowAddr
)) = cpu
.z80A
;
14974 cpu
.z80Base
[cpu
.z80HL
] = (UINT8
) cpu
.z80A
;
14981 sdwCyclesRemaining
-= 4;
14982 cpu
.z80A
= cpu
.z80B
;
14987 sdwCyclesRemaining
-= 4;
14988 cpu
.z80A
= cpu
.z80C
;
14993 sdwCyclesRemaining
-= 4;
14994 cpu
.z80A
= cpu
.z80D
;
14999 sdwCyclesRemaining
-= 4;
15000 cpu
.z80A
= cpu
.z80E
;
15005 sdwCyclesRemaining
-= 4;
15006 cpu
.z80A
= cpu
.z80H
;
15011 sdwCyclesRemaining
-= 4;
15012 cpu
.z80A
= cpu
.z80L
;
15017 sdwCyclesRemaining
-= 7;
15018 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15019 while (psMemRead
->lowAddr
!= 0xffffffff)
15021 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15023 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15024 if (psMemRead
->memoryCall
)
15026 cpu
.z80A
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15030 cpu
.z80A
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15040 cpu
.z80A
= cpu
.z80Base
[cpu
.z80HL
];
15047 sdwCyclesRemaining
-= 4;
15052 sdwCyclesRemaining
-= 4;
15053 bTemp2
= cpu
.z80A
+ cpu
.z80B
;
15054 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15055 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15056 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80B
];
15062 sdwCyclesRemaining
-= 4;
15063 bTemp2
= cpu
.z80A
+ cpu
.z80C
;
15064 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15065 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15066 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80C
];
15072 sdwCyclesRemaining
-= 4;
15073 bTemp2
= cpu
.z80A
+ cpu
.z80D
;
15074 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15075 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15076 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80D
];
15082 sdwCyclesRemaining
-= 4;
15083 bTemp2
= cpu
.z80A
+ cpu
.z80E
;
15084 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15085 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15086 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80E
];
15092 sdwCyclesRemaining
-= 4;
15093 bTemp2
= cpu
.z80A
+ cpu
.z80H
;
15094 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15095 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15096 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80H
];
15102 sdwCyclesRemaining
-= 4;
15103 bTemp2
= cpu
.z80A
+ cpu
.z80L
;
15104 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15105 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15106 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80L
];
15112 sdwCyclesRemaining
-= 7;
15113 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15114 while (psMemRead
->lowAddr
!= 0xffffffff)
15116 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15118 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15119 if (psMemRead
->memoryCall
)
15121 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15125 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15135 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15138 bTemp2
= cpu
.z80A
+ bTemp
;
15139 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15140 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15141 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
15147 sdwCyclesRemaining
-= 4;
15148 bTemp2
= cpu
.z80A
+ cpu
.z80A
;
15149 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15150 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15151 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80A
];
15157 sdwCyclesRemaining
-= 4;
15158 bTemp2
= cpu
.z80A
+ cpu
.z80B
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15159 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15160 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15161 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80B
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15167 sdwCyclesRemaining
-= 4;
15168 bTemp2
= cpu
.z80A
+ cpu
.z80C
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15169 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15170 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15171 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80C
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15177 sdwCyclesRemaining
-= 4;
15178 bTemp2
= cpu
.z80A
+ cpu
.z80D
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15179 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15180 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15181 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80D
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15187 sdwCyclesRemaining
-= 4;
15188 bTemp2
= cpu
.z80A
+ cpu
.z80E
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15189 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15190 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15191 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80E
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15197 sdwCyclesRemaining
-= 4;
15198 bTemp2
= cpu
.z80A
+ cpu
.z80H
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15199 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15200 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15201 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80H
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15207 sdwCyclesRemaining
-= 4;
15208 bTemp2
= cpu
.z80A
+ cpu
.z80L
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15209 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15210 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15211 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80L
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15217 sdwCyclesRemaining
-= 7;
15218 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15219 while (psMemRead
->lowAddr
!= 0xffffffff)
15221 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15223 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15224 if (psMemRead
->memoryCall
)
15226 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15230 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15240 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15243 bTemp2
= cpu
.z80A
+ bTemp
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15244 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15245 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15246 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15252 sdwCyclesRemaining
-= 4;
15253 bTemp2
= cpu
.z80A
+ cpu
.z80A
+ (cpu
.z80F
& Z80_FLAG_CARRY
);
15254 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15255 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15256 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80A
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15262 sdwCyclesRemaining
-= 4;
15263 bTemp2
= cpu
.z80A
- cpu
.z80B
;
15264 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15265 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15266 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80B
];
15272 sdwCyclesRemaining
-= 4;
15273 bTemp2
= cpu
.z80A
- cpu
.z80C
;
15274 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15275 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15276 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80C
];
15282 sdwCyclesRemaining
-= 4;
15283 bTemp2
= cpu
.z80A
- cpu
.z80D
;
15284 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15285 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15286 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80D
];
15292 sdwCyclesRemaining
-= 4;
15293 bTemp2
= cpu
.z80A
- cpu
.z80E
;
15294 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15295 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15296 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80E
];
15302 sdwCyclesRemaining
-= 4;
15303 bTemp2
= cpu
.z80A
- cpu
.z80H
;
15304 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15305 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15306 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80H
];
15312 sdwCyclesRemaining
-= 4;
15313 bTemp2
= cpu
.z80A
- cpu
.z80L
;
15314 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15315 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15316 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80L
];
15322 sdwCyclesRemaining
-= 7;
15323 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15324 while (psMemRead
->lowAddr
!= 0xffffffff)
15326 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15328 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15329 if (psMemRead
->memoryCall
)
15331 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15335 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15345 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15348 bTemp2
= cpu
.z80A
- bTemp
;
15349 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15350 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15351 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
15357 sdwCyclesRemaining
-= 4;
15358 bTemp2
= cpu
.z80A
- cpu
.z80A
;
15359 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15360 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15361 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80A
];
15367 sdwCyclesRemaining
-= 4;
15368 bTemp2
= cpu
.z80A
- cpu
.z80B
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15369 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15370 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15371 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80B
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15377 sdwCyclesRemaining
-= 4;
15378 bTemp2
= cpu
.z80A
- cpu
.z80C
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15379 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15380 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15381 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80C
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15387 sdwCyclesRemaining
-= 4;
15388 bTemp2
= cpu
.z80A
- cpu
.z80D
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15389 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15390 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15391 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80D
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15397 sdwCyclesRemaining
-= 4;
15398 bTemp2
= cpu
.z80A
- cpu
.z80E
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15399 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15400 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15401 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80E
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15407 sdwCyclesRemaining
-= 4;
15408 bTemp2
= cpu
.z80A
- cpu
.z80H
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15409 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15410 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15411 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80H
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15417 sdwCyclesRemaining
-= 4;
15418 bTemp2
= cpu
.z80A
- cpu
.z80L
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15419 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15420 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15421 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80L
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15427 sdwCyclesRemaining
-= 7;
15428 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15429 while (psMemRead
->lowAddr
!= 0xffffffff)
15431 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15433 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15434 if (psMemRead
->memoryCall
)
15436 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15440 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15450 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15453 bTemp2
= cpu
.z80A
- bTemp
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15454 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15455 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15456 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15462 sdwCyclesRemaining
-= 4;
15463 bTemp2
= cpu
.z80A
- cpu
.z80A
- (cpu
.z80F
& Z80_FLAG_CARRY
);
15464 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15465 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15466 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80A
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
15472 sdwCyclesRemaining
-= 4;
15473 cpu
.z80A
&= cpu
.z80B
;
15474 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15475 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15481 sdwCyclesRemaining
-= 4;
15482 cpu
.z80A
&= cpu
.z80C
;
15483 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15484 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15490 sdwCyclesRemaining
-= 4;
15491 cpu
.z80A
&= cpu
.z80D
;
15492 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15493 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15499 sdwCyclesRemaining
-= 4;
15500 cpu
.z80A
&= cpu
.z80E
;
15501 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15502 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15508 sdwCyclesRemaining
-= 4;
15509 cpu
.z80A
&= cpu
.z80H
;
15510 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15511 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15517 sdwCyclesRemaining
-= 4;
15518 cpu
.z80A
&= cpu
.z80L
;
15519 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15520 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15526 sdwCyclesRemaining
-= 7;
15527 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15528 while (psMemRead
->lowAddr
!= 0xffffffff)
15530 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15532 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15533 if (psMemRead
->memoryCall
)
15535 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15539 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15549 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15553 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15554 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15560 sdwCyclesRemaining
-= 4;
15561 cpu
.z80A
&= cpu
.z80A
;
15562 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15563 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
15569 sdwCyclesRemaining
-= 4;
15570 cpu
.z80A
^= cpu
.z80B
;
15571 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15572 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15578 sdwCyclesRemaining
-= 4;
15579 cpu
.z80A
^= cpu
.z80C
;
15580 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15581 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15587 sdwCyclesRemaining
-= 4;
15588 cpu
.z80A
^= cpu
.z80D
;
15589 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15590 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15596 sdwCyclesRemaining
-= 4;
15597 cpu
.z80A
^= cpu
.z80E
;
15598 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15599 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15605 sdwCyclesRemaining
-= 4;
15606 cpu
.z80A
^= cpu
.z80H
;
15607 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15608 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15614 sdwCyclesRemaining
-= 4;
15615 cpu
.z80A
^= cpu
.z80L
;
15616 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15617 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15623 sdwCyclesRemaining
-= 7;
15624 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15625 while (psMemRead
->lowAddr
!= 0xffffffff)
15627 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15629 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15630 if (psMemRead
->memoryCall
)
15632 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15636 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15646 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15650 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15651 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15657 sdwCyclesRemaining
-= 4;
15658 cpu
.z80A
^= cpu
.z80A
;
15659 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15660 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15666 sdwCyclesRemaining
-= 4;
15667 cpu
.z80A
|= cpu
.z80B
;
15668 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15669 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15675 sdwCyclesRemaining
-= 4;
15676 cpu
.z80A
|= cpu
.z80C
;
15677 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15678 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15684 sdwCyclesRemaining
-= 4;
15685 cpu
.z80A
|= cpu
.z80D
;
15686 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15687 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15693 sdwCyclesRemaining
-= 4;
15694 cpu
.z80A
|= cpu
.z80E
;
15695 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15696 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15702 sdwCyclesRemaining
-= 4;
15703 cpu
.z80A
|= cpu
.z80H
;
15704 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15705 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15711 sdwCyclesRemaining
-= 4;
15712 cpu
.z80A
|= cpu
.z80L
;
15713 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15714 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15720 sdwCyclesRemaining
-= 7;
15721 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15722 while (psMemRead
->lowAddr
!= 0xffffffff)
15724 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15726 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15727 if (psMemRead
->memoryCall
)
15729 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15733 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15743 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15747 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15748 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15754 sdwCyclesRemaining
-= 4;
15755 cpu
.z80A
|= cpu
.z80A
;
15756 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
15757 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
15763 sdwCyclesRemaining
-= 4;
15764 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15765 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15766 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80B
];
15771 sdwCyclesRemaining
-= 4;
15772 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15773 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15774 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80C
];
15779 sdwCyclesRemaining
-= 4;
15780 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15781 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15782 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80D
];
15787 sdwCyclesRemaining
-= 4;
15788 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15789 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15790 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80E
];
15795 sdwCyclesRemaining
-= 4;
15796 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15797 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15798 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80H
];
15803 sdwCyclesRemaining
-= 4;
15804 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15805 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15806 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80L
];
15811 sdwCyclesRemaining
-= 7;
15812 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15813 while (psMemRead
->lowAddr
!= 0xffffffff)
15815 if ((cpu
.z80HL
>= psMemRead
->lowAddr
) && (cpu
.z80HL
<= psMemRead
->highAddr
))
15817 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15818 if (psMemRead
->memoryCall
)
15820 bTemp
= psMemRead
->memoryCall(cpu
.z80HL
, psMemRead
);
15824 bTemp
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80HL
- psMemRead
->lowAddr
));
15834 bTemp
= cpu
.z80Base
[cpu
.z80HL
];
15837 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15838 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15839 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
15844 sdwCyclesRemaining
-= 4;
15845 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15846 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15847 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | cpu
.z80A
];
15852 sdwCyclesRemaining
-= 5;
15853 if (!(cpu
.z80F
& Z80_FLAG_ZERO
))
15855 dwElapsedTicks
+= 6;
15856 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
15857 dwAddr
= *pbSP
++; /* Pop LSB */
15858 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
15859 cpu
.z80sp
+= 2; /* Pop the word off */
15860 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
15866 sdwCyclesRemaining
-= 10;
15867 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
15868 while (psMemRead
->lowAddr
!= 0xffffffff)
15870 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
15872 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15873 if (psMemRead
->memoryCall
)
15875 cpu
.z80BC
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
15876 cpu
.z80BC
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
15880 cpu
.z80BC
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
15881 cpu
.z80BC
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
15891 cpu
.z80BC
= cpu
.z80Base
[cpu
.z80sp
];
15892 cpu
.z80BC
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
15896 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
15901 sdwCyclesRemaining
-= 10;
15902 dwAddr
= *pbPC
++; /* Get LSB first */
15903 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
15904 if (!(cpu
.z80F
& Z80_FLAG_ZERO
))
15906 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
15912 sdwCyclesRemaining
-= 10;
15913 dwAddr
= *pbPC
++; /* Get LSB first */
15914 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
15915 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
15920 sdwCyclesRemaining
-= 10;
15921 dwAddr
= *pbPC
++; /* Get LSB first */
15922 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
15923 if (!(cpu
.z80F
& Z80_FLAG_ZERO
))
15925 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15926 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
15927 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
15928 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
15929 cpu
.z80sp
-= 2; /* Back our stack up */
15930 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
15936 sdwCyclesRemaining
-= 11;
15938 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
15939 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
15940 while (psMemWrite
->lowAddr
!= 0xffffffff)
15942 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
15944 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15945 if (psMemWrite
->memoryCall
)
15947 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80BC
& 0xff), psMemWrite
);
15948 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80BC
>> 8), psMemWrite
);
15952 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80BC
;
15953 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80BC
>> 8;
15963 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80BC
;
15964 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80BC
>> 8);
15971 sdwCyclesRemaining
-= 7;
15973 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
15974 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
15975 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
15981 sdwCyclesRemaining
-= 11;
15982 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
15983 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
15984 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
15985 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
15986 cpu
.z80sp
-= 2; /* Back our stack up */
15987 pbPC
= cpu
.z80Base
+ 0x00; /* Normalize the address */
15992 sdwCyclesRemaining
-= 5;
15993 if (cpu
.z80F
& Z80_FLAG_ZERO
)
15995 dwElapsedTicks
+= 6;
15996 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
15997 dwAddr
= *pbSP
++; /* Pop LSB */
15998 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
15999 cpu
.z80sp
+= 2; /* Pop the word off */
16000 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16006 sdwCyclesRemaining
-= 10;
16007 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16008 dwAddr
= *pbSP
++; /* Pop LSB */
16009 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16010 cpu
.z80sp
+= 2; /* Pop the word off */
16011 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16016 sdwCyclesRemaining
-= 10;
16017 dwAddr
= *pbPC
++; /* Get LSB first */
16018 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16019 if (cpu
.z80F
& Z80_FLAG_ZERO
)
16021 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16032 sdwCyclesRemaining
-= 10;
16033 dwAddr
= *pbPC
++; /* Get LSB first */
16034 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16035 if (cpu
.z80F
& Z80_FLAG_ZERO
)
16037 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16038 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16039 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16040 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16041 cpu
.z80sp
-= 2; /* Back our stack up */
16042 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16048 sdwCyclesRemaining
-= 17;
16049 dwAddr
= *pbPC
++; /* Get LSB first */
16050 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16051 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16052 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16053 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16054 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16055 cpu
.z80sp
-= 2; /* Back our stack up */
16056 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16061 sdwCyclesRemaining
-= 7;
16062 bTemp
= *pbPC
++ + (cpu
.z80F
& Z80_FLAG_CARRY
);
16063 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
16064 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
16065 pbAddAdcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
16071 sdwCyclesRemaining
-= 11;
16072 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16073 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16074 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16075 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16076 cpu
.z80sp
-= 2; /* Back our stack up */
16077 pbPC
= cpu
.z80Base
+ 0x08; /* Normalize the address */
16082 sdwCyclesRemaining
-= 5;
16083 if (!(cpu
.z80F
& Z80_FLAG_CARRY
))
16085 dwElapsedTicks
+= 6;
16086 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16087 dwAddr
= *pbSP
++; /* Pop LSB */
16088 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16089 cpu
.z80sp
+= 2; /* Pop the word off */
16090 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16096 sdwCyclesRemaining
-= 10;
16097 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
16098 while (psMemRead
->lowAddr
!= 0xffffffff)
16100 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
16102 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16103 if (psMemRead
->memoryCall
)
16105 cpu
.z80DE
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
16106 cpu
.z80DE
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
16110 cpu
.z80DE
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
16111 cpu
.z80DE
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
16121 cpu
.z80DE
= cpu
.z80Base
[cpu
.z80sp
];
16122 cpu
.z80DE
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
16126 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
16131 sdwCyclesRemaining
-= 10;
16132 dwAddr
= *pbPC
++; /* Get LSB first */
16133 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16134 if (!(cpu
.z80F
& Z80_FLAG_CARRY
))
16136 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16142 sdwCyclesRemaining
-= 11;
16144 psIoWrite
= cpu
.z80IoWrite
; /* Beginning of our handler */
16145 while (psIoWrite
->lowIoAddr
!= 0xffff)
16147 if ((dwTemp
>= psIoWrite
->lowIoAddr
) && (dwTemp
<= psIoWrite
->highIoAddr
))
16149 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16150 psIoWrite
->IOCall(dwTemp
, cpu
.z80A
, psIoWrite
);
16161 sdwCyclesRemaining
-= 10;
16162 dwAddr
= *pbPC
++; /* Get LSB first */
16163 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16164 if (!(cpu
.z80F
& Z80_FLAG_CARRY
))
16166 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16167 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16168 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16169 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16170 cpu
.z80sp
-= 2; /* Back our stack up */
16171 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16177 sdwCyclesRemaining
-= 11;
16179 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
16180 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
16181 while (psMemWrite
->lowAddr
!= 0xffffffff)
16183 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
16185 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16186 if (psMemWrite
->memoryCall
)
16188 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80DE
& 0xff), psMemWrite
);
16189 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80DE
>> 8), psMemWrite
);
16193 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80DE
;
16194 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80DE
>> 8;
16204 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80DE
;
16205 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80DE
>> 8);
16212 sdwCyclesRemaining
-= 7;
16214 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
16215 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
16216 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
];
16222 sdwCyclesRemaining
-= 11;
16223 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16224 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16225 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16226 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16227 cpu
.z80sp
-= 2; /* Back our stack up */
16228 pbPC
= cpu
.z80Base
+ 0x10; /* Normalize the address */
16233 sdwCyclesRemaining
-= 5;
16234 if (cpu
.z80F
& Z80_FLAG_CARRY
)
16236 dwElapsedTicks
+= 6;
16237 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16238 dwAddr
= *pbSP
++; /* Pop LSB */
16239 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16240 cpu
.z80sp
+= 2; /* Pop the word off */
16241 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16247 sdwCyclesRemaining
-= 4;
16248 dwTemp
= cpu
.z80DE
;
16249 cpu
.z80DE
= cpu
.z80deprime
;
16250 cpu
.z80deprime
= dwTemp
;
16251 dwTemp
= cpu
.z80BC
;
16252 cpu
.z80BC
= cpu
.z80bcprime
;
16253 cpu
.z80bcprime
= dwTemp
;
16254 dwTemp
= cpu
.z80HL
;
16255 cpu
.z80HL
= cpu
.z80hlprime
;
16256 cpu
.z80hlprime
= dwTemp
;
16261 sdwCyclesRemaining
-= 10;
16262 dwAddr
= *pbPC
++; /* Get LSB first */
16263 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16264 if (cpu
.z80F
& Z80_FLAG_CARRY
)
16266 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16272 sdwCyclesRemaining
-= 11;
16274 psIoRead
= cpu
.z80IoRead
; /* Beginning of our handler */
16275 while (psIoRead
->lowIoAddr
!= 0xffff)
16277 if ((dwTemp
>= psIoRead
->lowIoAddr
) && (dwTemp
<= psIoRead
->highIoAddr
))
16279 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16280 cpu
.z80A
= psIoRead
->IOCall(dwTemp
, psIoRead
);
16289 cpu
.z80A
= 0xff; /* Unclaimed I/O read */
16296 sdwCyclesRemaining
-= 10;
16297 dwAddr
= *pbPC
++; /* Get LSB first */
16298 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16299 if (cpu
.z80F
& Z80_FLAG_CARRY
)
16301 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16302 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16303 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16304 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16305 cpu
.z80sp
-= 2; /* Back our stack up */
16306 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16317 sdwCyclesRemaining
-= 7;
16318 bTemp
= *pbPC
++ + (cpu
.z80F
& Z80_FLAG_CARRY
);
16319 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
16320 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
16321 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | bTemp
| (((UINT32
) cpu
.z80F
& Z80_FLAG_CARRY
) << 16)];
16322 cpu
.z80A
= cpu
.z80A
- bTemp
;
16327 sdwCyclesRemaining
-= 11;
16328 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16329 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16330 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16331 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16332 cpu
.z80sp
-= 2; /* Back our stack up */
16333 pbPC
= cpu
.z80Base
+ 0x18; /* Normalize the address */
16338 sdwCyclesRemaining
-= 5;
16339 if (!(cpu
.z80F
& Z80_FLAG_OVERFLOW_PARITY
))
16341 dwElapsedTicks
+= 6;
16342 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16343 dwAddr
= *pbSP
++; /* Pop LSB */
16344 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16345 cpu
.z80sp
+= 2; /* Pop the word off */
16346 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16352 sdwCyclesRemaining
-= 10;
16353 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
16354 while (psMemRead
->lowAddr
!= 0xffffffff)
16356 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
16358 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16359 if (psMemRead
->memoryCall
)
16361 cpu
.z80HL
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
16362 cpu
.z80HL
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
16366 cpu
.z80HL
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
16367 cpu
.z80HL
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
16377 cpu
.z80HL
= cpu
.z80Base
[cpu
.z80sp
];
16378 cpu
.z80HL
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
16382 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
16387 sdwCyclesRemaining
-= 10;
16388 dwAddr
= *pbPC
++; /* Get LSB first */
16389 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16390 if (!(cpu
.z80F
& Z80_FLAG_OVERFLOW_PARITY
))
16392 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16398 sdwCyclesRemaining
-= 19;
16399 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
16400 while (psMemRead
->lowAddr
!= 0xffffffff)
16402 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
16404 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16405 if (psMemRead
->memoryCall
)
16407 dwAddr
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
16408 dwAddr
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
16412 dwAddr
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
16413 dwAddr
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
16423 dwAddr
= cpu
.z80Base
[cpu
.z80sp
];
16424 dwAddr
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
16427 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
16428 while (psMemWrite
->lowAddr
!= 0xffffffff)
16430 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
16432 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16433 if (psMemWrite
->memoryCall
)
16435 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80HL
& 0xff), psMemWrite
);
16436 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80HL
>> 8), psMemWrite
);
16440 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80HL
;
16441 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80HL
>> 8;
16451 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80HL
;
16452 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80HL
>> 8);
16455 cpu
.z80HL
= dwAddr
;
16460 sdwCyclesRemaining
-= 10;
16461 dwAddr
= *pbPC
++; /* Get LSB first */
16462 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16463 if (!(cpu
.z80F
& Z80_FLAG_OVERFLOW_PARITY
))
16465 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16466 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16467 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16468 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16469 cpu
.z80sp
-= 2; /* Back our stack up */
16470 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16476 sdwCyclesRemaining
-= 11;
16478 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
16479 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
16480 while (psMemWrite
->lowAddr
!= 0xffffffff)
16482 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
16484 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16485 if (psMemWrite
->memoryCall
)
16487 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80HL
& 0xff), psMemWrite
);
16488 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80HL
>> 8), psMemWrite
);
16492 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80HL
;
16493 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80HL
>> 8;
16503 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80HL
;
16504 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80HL
>> 8);
16511 sdwCyclesRemaining
-= 7;
16512 cpu
.z80A
&= *pbPC
++;
16513 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
16514 cpu
.z80F
|= bPostANDFlags
[cpu
.z80A
];
16520 sdwCyclesRemaining
-= 11;
16521 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16522 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16523 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16524 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16525 cpu
.z80sp
-= 2; /* Back our stack up */
16526 pbPC
= cpu
.z80Base
+ 0x20; /* Normalize the address */
16531 sdwCyclesRemaining
-= 5;
16532 if (cpu
.z80F
& Z80_FLAG_OVERFLOW_PARITY
)
16534 dwElapsedTicks
+= 6;
16535 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16536 dwAddr
= *pbSP
++; /* Pop LSB */
16537 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16538 cpu
.z80sp
+= 2; /* Pop the word off */
16539 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16545 sdwCyclesRemaining
-= 4;
16546 pbPC
= cpu
.z80Base
+ cpu
.z80HL
;
16551 sdwCyclesRemaining
-= 10;
16552 dwAddr
= *pbPC
++; /* Get LSB first */
16553 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16554 if (cpu
.z80F
& Z80_FLAG_OVERFLOW_PARITY
)
16556 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16562 sdwCyclesRemaining
-= 4;
16563 dwAddr
= cpu
.z80DE
;
16564 cpu
.z80DE
= cpu
.z80HL
;
16565 cpu
.z80HL
= dwAddr
;
16570 sdwCyclesRemaining
-= 10;
16571 dwAddr
= *pbPC
++; /* Get LSB first */
16572 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16573 if (cpu
.z80F
& Z80_FLAG_OVERFLOW_PARITY
)
16575 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16576 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16577 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16578 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16579 cpu
.z80sp
-= 2; /* Back our stack up */
16580 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16591 sdwCyclesRemaining
-= 7;
16592 cpu
.z80A
^= *pbPC
++;
16593 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
16594 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
16600 sdwCyclesRemaining
-= 11;
16601 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16602 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16603 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16604 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16605 cpu
.z80sp
-= 2; /* Back our stack up */
16606 pbPC
= cpu
.z80Base
+ 0x28; /* Normalize the address */
16611 sdwCyclesRemaining
-= 5;
16612 if (!(cpu
.z80F
& Z80_FLAG_SIGN
))
16614 dwElapsedTicks
+= 6;
16615 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16616 dwAddr
= *pbSP
++; /* Pop LSB */
16617 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16618 cpu
.z80sp
+= 2; /* Pop the word off */
16619 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16625 sdwCyclesRemaining
-= 10;
16626 psMemRead
= cpu
.z80MemRead
; /* Beginning of our handler */
16627 while (psMemRead
->lowAddr
!= 0xffffffff)
16629 if ((cpu
.z80sp
>= psMemRead
->lowAddr
) && (cpu
.z80sp
<= psMemRead
->highAddr
))
16631 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16632 if (psMemRead
->memoryCall
)
16634 cpu
.z80AF
= psMemRead
->memoryCall(cpu
.z80sp
, psMemRead
);
16635 cpu
.z80AF
|= (UINT32
) ((UINT32
) psMemRead
->memoryCall(cpu
.z80sp
+ 1, psMemRead
) << 8);
16639 cpu
.z80AF
= *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
));
16640 cpu
.z80AF
|= (UINT32
) ((UINT32
) *((UINT8
*) psMemRead
->pUserArea
+ (cpu
.z80sp
- psMemRead
->lowAddr
+ 1)) << 8);
16650 cpu
.z80AF
= cpu
.z80Base
[cpu
.z80sp
];
16651 cpu
.z80AF
|= (UINT32
) ((UINT32
) cpu
.z80Base
[cpu
.z80sp
+ 1] << 8);
16655 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
16660 sdwCyclesRemaining
-= 10;
16661 dwAddr
= *pbPC
++; /* Get LSB first */
16662 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16663 if (!(cpu
.z80F
& Z80_FLAG_SIGN
))
16665 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16671 sdwCyclesRemaining
-= 4;
16672 cpu
.z80iff
&= (~IFF1
);
16677 sdwCyclesRemaining
-= 10;
16678 dwAddr
= *pbPC
++; /* Get LSB first */
16679 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16680 if (!(cpu
.z80F
& Z80_FLAG_SIGN
))
16682 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16683 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16684 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16685 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16686 cpu
.z80sp
-= 2; /* Back our stack up */
16687 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16693 sdwCyclesRemaining
-= 11;
16695 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
); /* Normalize the stack pointer */
16696 psMemWrite
= cpu
.z80MemWrite
; /* Beginning of our handler */
16697 while (psMemWrite
->lowAddr
!= 0xffffffff)
16699 if ((cpu
.z80sp
>= psMemWrite
->lowAddr
) && (cpu
.z80sp
<= psMemWrite
->highAddr
))
16701 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16702 if (psMemWrite
->memoryCall
)
16704 psMemWrite
->memoryCall(cpu
.z80sp
, (cpu
.z80AF
& 0xff), psMemWrite
);
16705 psMemWrite
->memoryCall(cpu
.z80sp
+ 1, (cpu
.z80AF
>> 8), psMemWrite
);
16709 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
)) = cpu
.z80AF
;
16710 *((UINT8
*) psMemWrite
->pUserArea
+ (cpu
.z80sp
- psMemWrite
->lowAddr
) + 1) = cpu
.z80AF
>> 8;
16720 cpu
.z80Base
[cpu
.z80sp
] = (UINT8
) cpu
.z80AF
;
16721 cpu
.z80Base
[cpu
.z80sp
+ 1] = (UINT8
) ((UINT32
) cpu
.z80AF
>> 8);
16728 sdwCyclesRemaining
-= 7;
16729 cpu
.z80A
|= *pbPC
++;
16730 cpu
.z80F
&= ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
| Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
);
16731 cpu
.z80F
|= bPostORFlags
[cpu
.z80A
];
16737 sdwCyclesRemaining
-= 11;
16738 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16739 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16740 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16741 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16742 cpu
.z80sp
-= 2; /* Back our stack up */
16743 pbPC
= cpu
.z80Base
+ 0x30; /* Normalize the address */
16748 sdwCyclesRemaining
-= 5;
16749 if (cpu
.z80F
& Z80_FLAG_SIGN
)
16751 dwElapsedTicks
+= 6;
16752 pbSP
= cpu
.z80Base
+ cpu
.z80sp
; /* Normalize our stack PTR */
16753 dwAddr
= *pbSP
++; /* Pop LSB */
16754 dwAddr
|= ((UINT32
) *pbSP
<< 8); /* Pop MSB */
16755 cpu
.z80sp
+= 2; /* Pop the word off */
16756 pbPC
= (cpu
.z80Base
+ dwAddr
); /* Point PC to our return address */
16762 sdwCyclesRemaining
-= 6;
16763 cpu
.z80sp
= cpu
.z80HL
;
16768 sdwCyclesRemaining
-= 10;
16769 dwAddr
= *pbPC
++; /* Get LSB first */
16770 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16771 if (cpu
.z80F
& Z80_FLAG_SIGN
)
16773 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16779 sdwCyclesRemaining
-= 4;
16780 cpu
.z80iff
|= IFF1
;
16785 sdwCyclesRemaining
-= 10;
16786 dwAddr
= *pbPC
++; /* Get LSB first */
16787 dwAddr
|= ((UINT32
) *pbPC
++ << 8); /* Get MSB last */
16788 if (cpu
.z80F
& Z80_FLAG_SIGN
)
16790 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16791 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16792 *pbSP
-- = cpu
.z80pc
>> 8; /* MSB */
16793 *pbSP
= (UINT8
) cpu
.z80pc
; /* LSB */
16794 cpu
.z80sp
-= 2; /* Back our stack up */
16795 pbPC
= cpu
.z80Base
+ dwAddr
; /* Normalize the address */
16806 sdwCyclesRemaining
-= 7;
16807 cpu
.z80F
= (cpu
.z80F
& ~(Z80_FLAG_CARRY
| Z80_FLAG_NEGATIVE
| Z80_FLAG_OVERFLOW_PARITY
|
16808 Z80_FLAG_HALF_CARRY
| Z80_FLAG_ZERO
| Z80_FLAG_SIGN
)) |
16809 pbSubSbcTable
[((UINT32
) cpu
.z80A
<< 8) | *pbPC
++];
16814 sdwCyclesRemaining
-= 11;
16815 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16816 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16817 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16818 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16819 cpu
.z80sp
-= 2; /* Back our stack up */
16820 pbPC
= cpu
.z80Base
+ 0x38; /* Normalize the address */
16826 dwElapsedTicks
+= (dwOriginalCycles
- sdwCyclesRemaining
);
16828 cpu
.z80pc
= (UINT32
) pbPC
- (UINT32
) cpu
.z80Base
;
16829 return(dwReturnCode
); /* Indicate success */
16832 /* Get mz80's context */
16834 void mz80GetContext(void *pData
)
16836 memcpy(pData
, &cpu
, sizeof(CONTEXTMZ80
));
16839 /* Set mz80's context */
16841 void mz80SetContext(void *pData
)
16843 memcpy(&cpu
, pData
, sizeof(CONTEXTMZ80
));
16846 /* Get mz80's context size */
16848 UINT32
mz80GetContextSize(void)
16850 return(sizeof(CONTEXTMZ80
));
16853 /* This will return the elapsed ticks */
16855 UINT32
mz80GetElapsedTicks(UINT32 dwClear
)
16857 UINT32 dwTemp
= dwElapsedTicks
;
16861 dwElapsedTicks
= 0;
16867 /* Releases mz80 from its current timeslice */
16869 void mz80ReleaseTimeslice(void)
16871 dwOriginalCycles
-= sdwCyclesRemaining
;
16872 sdwCyclesRemaining
= 0;
16875 /* This routine is mz80's reset handler */
16877 void mz80reset(void)
16881 cpu
.z80F
= Z80_FLAG_ZERO
;
16885 cpu
.z80afprime
= 0;
16886 cpu
.z80bcprime
= 0;
16887 cpu
.z80deprime
= 0;
16888 cpu
.z80hlprime
= 0;
16891 cpu
.z80IX
= 0xffff; /* Yes, this is intentional */
16892 cpu
.z80IY
= 0xffff; /* Yes, this is intentional */
16895 cpu
.z80interruptMode
= 0;
16896 cpu
.z80intAddr
= 0x38;
16897 cpu
.z80nmiAddr
= 0x66;
16900 /* Interrupt handler */
16902 UINT32
mz80int(UINT32 dwLowAddr
)
16905 if (0 == (cpu
.z80iff
& IFF1
))
16906 return(0xffffffff);
16907 cpu
.z80iff
&= ~(IFF1
| IFF2
);
16908 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16909 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16910 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16911 cpu
.z80sp
-= 2; /* Back our stack up */
16912 if (2 == cpu
.z80interruptMode
)
16914 cpu
.z80pc
= ((UINT16
) cpu
.z80i
<< 8) | (dwLowAddr
& 0xff);
16915 cpu
.z80pc
= ((UINT16
) cpu
.z80Base
[cpu
.z80pc
+ 1] << 8) | (cpu
.z80Base
[cpu
.z80pc
]);
16919 cpu
.z80pc
= cpu
.z80intAddr
;
16921 pbPC
= cpu
.z80Base
+ cpu
.z80pc
; /* Normalize the address */
16927 UINT32
mz80nmi(void)
16930 pbSP
= (cpu
.z80Base
+ cpu
.z80sp
- 1); /* Normalize the stack pointer */
16931 *pbSP
-- = cpu
.z80pc
>> 8; /* LSB */
16932 *pbSP
= (UINT8
) cpu
.z80pc
; /* MSB */
16933 cpu
.z80sp
-= 2; /* Back our stack up */
16934 cpu
.z80pc
= cpu
.z80nmiAddr
; /* Our NMI */
16938 /* Initialize MZ80 for action */
16940 void mz80init(void)
16952 if (NULL
== pbAddAdcTable
)
16954 pbAddAdcTable
= malloc(256*256*2);
16956 if (NULL
== pbAddAdcTable
)
16961 pbTempPtr
= pbAddAdcTable
;
16963 pbSubSbcTable
= malloc(256*256*2);
16965 if (NULL
== pbSubSbcTable
)
16970 pbTempPtr2
= pbSubSbcTable
;
16972 for (dwLoop
= 0; dwLoop
< (256*256*2); dwLoop
++)
16974 bLow
= dwLoop
& 0xff;
16975 bHigh
= (dwLoop
>> 8) & 0xff;
16976 bCarry
= (dwLoop
>> 16);
16979 bNewAdd
= bHigh
+ bLow
+ bCarry
;
16983 bFlag
|= Z80_FLAG_ZERO
;
16987 bFlag
= bNewAdd
& 0x80; /* Sign flag */
16990 if (((UINT32
) bLow
+ (UINT32
) bHigh
+ (UINT32
) bCarry
) >= 0x100)
16992 bFlag
|= Z80_FLAG_CARRY
;
16995 if ( ((bLow
^ bHigh
^ 0x80) & (bLow
^ (bNewAdd
& 0x80))) & 0x80)
16997 bFlag
|= Z80_FLAG_OVERFLOW_PARITY
;
17000 if (((bLow
& 0x0f) + (bHigh
& 0x0f) + bCarry
) >= 0x10)
17002 bFlag
|= Z80_FLAG_HALF_CARRY
;
17005 *pbTempPtr
++ = bFlag
; /* Store our new flag */
17007 // Now do subtract - Zero
17009 bFlag
= Z80_FLAG_NEGATIVE
;
17010 bNewSub
= bHigh
- bLow
- bCarry
;
17014 bFlag
|= Z80_FLAG_ZERO
;
17018 bFlag
|= bNewSub
& 0x80; /* Sign flag */
17021 if ( ((INT32
) bHigh
- (INT32
) bLow
- (INT32
) bCarry
) < 0)
17023 bFlag
|= Z80_FLAG_CARRY
;
17026 if ( ((INT32
) (bHigh
& 0xf) - (INT32
) (bLow
& 0x0f) - (INT32
) bCarry
) < 0)
17028 bFlag
|= Z80_FLAG_HALF_CARRY
;
17031 if ( ((bLow
^ bHigh
) & (bHigh
^ bNewSub
) & 0x80) )
17033 bFlag
|= Z80_FLAG_OVERFLOW_PARITY
;
17036 *pbTempPtr2
++ = bFlag
; /* Store our sub flag */
17041 /* Shut down MZ80 */
17043 void mz80shutdown(void)