cc68a136 |
1 | #include "driver.h" |
2 | |
3 | /* Multi-Z80 32 Bit emulator */ |
4 | |
5 | /* Copyright 1996-2000 Neil Bradley, All rights reserved |
6 | * |
7 | * License agreement: |
8 | * |
9 | * (MZ80 Refers to both the assembly code emitted by makeZ80.c and makeZ80.c |
10 | * itself) |
11 | * |
12 | * MZ80 May be distributed in unmodified form to any medium. |
13 | * |
14 | * MZ80 May not be sold, or sold as a part of a commercial package without |
15 | * the express written permission of Neil Bradley (neil@synthcom.com). This |
16 | * includes shareware. |
17 | * |
18 | * Modified versions of MZ80 may not be publicly redistributed without author |
19 | * approval (neil@synthcom.com). This includes distributing via a publicly |
20 | * accessible LAN. You may make your own source modifications and distribute |
21 | * MZ80 in source or object form, but if you make modifications to MZ80 |
22 | * then it should be noted in the top as a comment in makeZ80.c. |
23 | * |
24 | * MZ80 Licensing for commercial applications is available. Please email |
25 | * neil@synthcom.com for details. |
26 | * |
27 | * Synthcom Systems, Inc, and Neil Bradley will not be held responsible for |
28 | * any damage done by the use of MZ80. It is purely "as-is". |
29 | * |
30 | * If you use MZ80 in a freeware application, credit in the following text: |
31 | * |
32 | * "Multi-Z80 CPU emulator by Neil Bradley (neil@synthcom.com)" |
33 | * |
34 | * must accompany the freeware application within the application itself or |
35 | * in the documentation. |
36 | * |
37 | * Legal stuff aside: |
38 | * |
39 | * If you find problems with MZ80, please email the author so they can get |
40 | * resolved. If you find a bug and fix it, please also email the author so |
41 | * that those bug fixes can be propogated to the installed base of MZ80 |
42 | * users. If you find performance improvements or problems with MZ80, please |
43 | * email the author with your changes/suggestions and they will be rolled in |
44 | * with subsequent releases of MZ80. |
45 | * |
46 | * The whole idea of this emulator is to have the fastest available 32 bit |
47 | * Multi-Z80 emulator for the PC, giving maximum performance. |
48 | */ |
49 | |
50 | #include <stdio.h> |
51 | #include <stdlib.h> |
52 | #include <string.h> |
53 | #include "mz80.h" |
54 | UINT32 z80intAddr; |
55 | UINT32 z80pc; |
56 | |
57 | |
58 | /* Modular global variables go here*/ |
59 | |
60 | static CONTEXTMZ80 cpu; /* CPU Context */ |
61 | static UINT8 *pbPC; /* Program counter normalized */ |
62 | static UINT8 *pbSP; /* Stack pointer normalized */ |
63 | static struct MemoryReadByte *psMemRead; /* Read memory structure */ |
64 | static struct MemoryWriteByte *psMemWrite; /* Write memory structure */ |
65 | static struct z80PortRead *psIoRead; /* Read I/O structure */ |
66 | static struct z80PortWrite *psIoWrite; /* Write memory structure */ |
67 | static INT32 sdwCyclesRemaining; /* Used as a countdown */ |
68 | static UINT32 dwReturnCode; /* Return code from exec() */ |
69 | static UINT32 dwOriginalCycles; /* How many cycles did we start with? */ |
70 | static UINT32 dwElapsedTicks; /* How many ticks did we elapse? */ |
71 | static INT32 sdwAddr; /* Temporary address storage */ |
72 | static UINT32 dwAddr; /* Temporary stack address */ |
73 | static UINT8 *pbAddAdcTable; /* Pointer to add/adc flag table */ |
74 | static UINT8 *pbSubSbcTable; /* Pointer to sub/sbc flag table */ |
75 | static UINT32 dwTemp; /* Temporary value */ |
76 | |
77 | static UINT8 bTemp; /* Temporary value */ |
78 | |
79 | static UINT8 bTemp2; /* Temporary value */ |
80 | |
81 | /* Precomputed flag tables */ |
82 | |
83 | static UINT8 bPostIncFlags[0x100] = |
84 | { |
85 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
86 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
87 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
88 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
89 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
90 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
91 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10, |
92 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94, |
93 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
94 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
95 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
96 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
97 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
98 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
99 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90, |
100 | 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x50 |
101 | }; |
102 | |
103 | static UINT8 bPostDecFlags[0x100] = |
104 | { |
105 | 0x92,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
106 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
107 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
108 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
109 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
110 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
111 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
112 | 0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, |
113 | 0x16,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
114 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
115 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
116 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
117 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
118 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
119 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82, |
120 | 0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82 |
121 | }; |
122 | |
123 | static UINT8 bPostORFlags[0x100] = |
124 | { |
125 | 0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, |
126 | 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, |
127 | 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, |
128 | 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, |
129 | 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, |
130 | 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, |
131 | 0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04, |
132 | 0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00, |
133 | 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, |
134 | 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, |
135 | 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, |
136 | 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, |
137 | 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84, |
138 | 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, |
139 | 0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80, |
140 | 0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84 |
141 | }; |
142 | |
143 | static UINT8 bPostANDFlags[0x100] = |
144 | { |
145 | 0x54,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14, |
146 | 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10, |
147 | 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10, |
148 | 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14, |
149 | 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10, |
150 | 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14, |
151 | 0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14, |
152 | 0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10, |
153 | 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90, |
154 | 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94, |
155 | 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94, |
156 | 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90, |
157 | 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94, |
158 | 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90, |
159 | 0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90, |
160 | 0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94 |
161 | }; |
162 | |
163 | static UINT16 wDAATable[0x800] = |
164 | { |
165 | 0x5400,0x1001,0x1002,0x1403,0x1004,0x1405,0x1406,0x1007, |
166 | 0x1008,0x1409,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015, |
167 | 0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,0x1016,0x1417, |
168 | 0x1418,0x1019,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025, |
169 | 0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,0x1026,0x1427, |
170 | 0x1428,0x1029,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435, |
171 | 0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,0x1436,0x1037, |
172 | 0x1038,0x1439,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045, |
173 | 0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,0x1046,0x1447, |
174 | 0x1448,0x1049,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455, |
175 | 0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,0x1456,0x1057, |
176 | 0x1058,0x1459,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465, |
177 | 0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,0x1466,0x1067, |
178 | 0x1068,0x1469,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075, |
179 | 0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,0x1076,0x1477, |
180 | 0x1478,0x1079,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085, |
181 | 0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,0x9086,0x9487, |
182 | 0x9488,0x9089,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495, |
183 | 0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,0x9496,0x9097, |
184 | 0x9098,0x9499,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505, |
185 | 0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107, |
186 | 0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115, |
187 | 0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517, |
188 | 0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125, |
189 | 0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527, |
190 | 0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535, |
191 | 0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137, |
192 | 0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145, |
193 | 0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547, |
194 | 0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555, |
195 | 0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157, |
196 | 0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565, |
197 | 0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,0x1566,0x1167, |
198 | 0x1168,0x1569,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175, |
199 | 0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,0x1176,0x1577, |
200 | 0x1578,0x1179,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185, |
201 | 0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,0x9186,0x9587, |
202 | 0x9588,0x9189,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595, |
203 | 0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,0x9596,0x9197, |
204 | 0x9198,0x9599,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5, |
205 | 0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,0x95a6,0x91a7, |
206 | 0x91a8,0x95a9,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5, |
207 | 0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,0x91b6,0x95b7, |
208 | 0x95b8,0x91b9,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5, |
209 | 0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,0x95c6,0x91c7, |
210 | 0x91c8,0x95c9,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5, |
211 | 0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,0x91d6,0x95d7, |
212 | 0x95d8,0x91d9,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5, |
213 | 0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,0x91e6,0x95e7, |
214 | 0x95e8,0x91e9,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5, |
215 | 0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,0x95f6,0x91f7, |
216 | 0x91f8,0x95f9,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505, |
217 | 0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107, |
218 | 0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115, |
219 | 0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517, |
220 | 0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125, |
221 | 0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527, |
222 | 0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535, |
223 | 0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137, |
224 | 0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145, |
225 | 0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547, |
226 | 0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555, |
227 | 0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157, |
228 | 0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565, |
229 | 0x1406,0x1007,0x1008,0x1409,0x140a,0x100b,0x140c,0x100d, |
230 | 0x100e,0x140f,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015, |
231 | 0x1016,0x1417,0x1418,0x1019,0x101a,0x141b,0x101c,0x141d, |
232 | 0x141e,0x101f,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025, |
233 | 0x1026,0x1427,0x1428,0x1029,0x102a,0x142b,0x102c,0x142d, |
234 | 0x142e,0x102f,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435, |
235 | 0x1436,0x1037,0x1038,0x1439,0x143a,0x103b,0x143c,0x103d, |
236 | 0x103e,0x143f,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045, |
237 | 0x1046,0x1447,0x1448,0x1049,0x104a,0x144b,0x104c,0x144d, |
238 | 0x144e,0x104f,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455, |
239 | 0x1456,0x1057,0x1058,0x1459,0x145a,0x105b,0x145c,0x105d, |
240 | 0x105e,0x145f,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465, |
241 | 0x1466,0x1067,0x1068,0x1469,0x146a,0x106b,0x146c,0x106d, |
242 | 0x106e,0x146f,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075, |
243 | 0x1076,0x1477,0x1478,0x1079,0x107a,0x147b,0x107c,0x147d, |
244 | 0x147e,0x107f,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085, |
245 | 0x9086,0x9487,0x9488,0x9089,0x908a,0x948b,0x908c,0x948d, |
246 | 0x948e,0x908f,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495, |
247 | 0x9496,0x9097,0x9098,0x9499,0x949a,0x909b,0x949c,0x909d, |
248 | 0x909e,0x949f,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505, |
249 | 0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d, |
250 | 0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115, |
251 | 0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d, |
252 | 0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125, |
253 | 0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d, |
254 | 0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535, |
255 | 0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d, |
256 | 0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145, |
257 | 0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d, |
258 | 0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555, |
259 | 0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d, |
260 | 0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565, |
261 | 0x1566,0x1167,0x1168,0x1569,0x156a,0x116b,0x156c,0x116d, |
262 | 0x116e,0x156f,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175, |
263 | 0x1176,0x1577,0x1578,0x1179,0x117a,0x157b,0x117c,0x157d, |
264 | 0x157e,0x117f,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185, |
265 | 0x9186,0x9587,0x9588,0x9189,0x918a,0x958b,0x918c,0x958d, |
266 | 0x958e,0x918f,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595, |
267 | 0x9596,0x9197,0x9198,0x9599,0x959a,0x919b,0x959c,0x919d, |
268 | 0x919e,0x959f,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5, |
269 | 0x95a6,0x91a7,0x91a8,0x95a9,0x95aa,0x91ab,0x95ac,0x91ad, |
270 | 0x91ae,0x95af,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5, |
271 | 0x91b6,0x95b7,0x95b8,0x91b9,0x91ba,0x95bb,0x91bc,0x95bd, |
272 | 0x95be,0x91bf,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5, |
273 | 0x95c6,0x91c7,0x91c8,0x95c9,0x95ca,0x91cb,0x95cc,0x91cd, |
274 | 0x91ce,0x95cf,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5, |
275 | 0x91d6,0x95d7,0x95d8,0x91d9,0x91da,0x95db,0x91dc,0x95dd, |
276 | 0x95de,0x91df,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5, |
277 | 0x91e6,0x95e7,0x95e8,0x91e9,0x91ea,0x95eb,0x91ec,0x95ed, |
278 | 0x95ee,0x91ef,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5, |
279 | 0x95f6,0x91f7,0x91f8,0x95f9,0x95fa,0x91fb,0x95fc,0x91fd, |
280 | 0x91fe,0x95ff,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505, |
281 | 0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d, |
282 | 0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115, |
283 | 0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d, |
284 | 0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125, |
285 | 0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d, |
286 | 0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535, |
287 | 0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d, |
288 | 0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145, |
289 | 0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d, |
290 | 0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555, |
291 | 0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d, |
292 | 0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565, |
293 | 0x5600,0x1201,0x1202,0x1603,0x1204,0x1605,0x1606,0x1207, |
294 | 0x1208,0x1609,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609, |
295 | 0x1210,0x1611,0x1612,0x1213,0x1614,0x1215,0x1216,0x1617, |
296 | 0x1618,0x1219,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219, |
297 | 0x1220,0x1621,0x1622,0x1223,0x1624,0x1225,0x1226,0x1627, |
298 | 0x1628,0x1229,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229, |
299 | 0x1630,0x1231,0x1232,0x1633,0x1234,0x1635,0x1636,0x1237, |
300 | 0x1238,0x1639,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639, |
301 | 0x1240,0x1641,0x1642,0x1243,0x1644,0x1245,0x1246,0x1647, |
302 | 0x1648,0x1249,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249, |
303 | 0x1650,0x1251,0x1252,0x1653,0x1254,0x1655,0x1656,0x1257, |
304 | 0x1258,0x1659,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659, |
305 | 0x1660,0x1261,0x1262,0x1663,0x1264,0x1665,0x1666,0x1267, |
306 | 0x1268,0x1669,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669, |
307 | 0x1270,0x1671,0x1672,0x1273,0x1674,0x1275,0x1276,0x1677, |
308 | 0x1678,0x1279,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279, |
309 | 0x9280,0x9681,0x9682,0x9283,0x9684,0x9285,0x9286,0x9687, |
310 | 0x9688,0x9289,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289, |
311 | 0x9690,0x9291,0x9292,0x9693,0x9294,0x9695,0x9696,0x9297, |
312 | 0x9298,0x9699,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739, |
313 | 0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747, |
314 | 0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349, |
315 | 0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357, |
316 | 0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759, |
317 | 0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367, |
318 | 0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769, |
319 | 0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777, |
320 | 0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379, |
321 | 0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787, |
322 | 0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389, |
323 | 0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397, |
324 | 0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799, |
325 | 0x97a0,0x93a1,0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7, |
326 | 0x93a8,0x97a9,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9, |
327 | 0x93b0,0x97b1,0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7, |
328 | 0x97b8,0x93b9,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9, |
329 | 0x97c0,0x93c1,0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7, |
330 | 0x93c8,0x97c9,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9, |
331 | 0x93d0,0x97d1,0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7, |
332 | 0x97d8,0x93d9,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9, |
333 | 0x93e0,0x97e1,0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7, |
334 | 0x97e8,0x93e9,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9, |
335 | 0x97f0,0x93f1,0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7, |
336 | 0x93f8,0x97f9,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9, |
337 | 0x5700,0x1301,0x1302,0x1703,0x1304,0x1705,0x1706,0x1307, |
338 | 0x1308,0x1709,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709, |
339 | 0x1310,0x1711,0x1712,0x1313,0x1714,0x1315,0x1316,0x1717, |
340 | 0x1718,0x1319,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319, |
341 | 0x1320,0x1721,0x1722,0x1323,0x1724,0x1325,0x1326,0x1727, |
342 | 0x1728,0x1329,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329, |
343 | 0x1730,0x1331,0x1332,0x1733,0x1334,0x1735,0x1736,0x1337, |
344 | 0x1338,0x1739,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739, |
345 | 0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747, |
346 | 0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349, |
347 | 0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357, |
348 | 0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759, |
349 | 0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367, |
350 | 0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769, |
351 | 0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777, |
352 | 0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379, |
353 | 0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787, |
354 | 0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389, |
355 | 0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397, |
356 | 0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799, |
357 | 0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5600,0x1201, |
358 | 0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609, |
359 | 0x160a,0x120b,0x160c,0x120d,0x120e,0x160f,0x1210,0x1611, |
360 | 0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219, |
361 | 0x121a,0x161b,0x121c,0x161d,0x161e,0x121f,0x1220,0x1621, |
362 | 0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229, |
363 | 0x122a,0x162b,0x122c,0x162d,0x162e,0x122f,0x1630,0x1231, |
364 | 0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639, |
365 | 0x163a,0x123b,0x163c,0x123d,0x123e,0x163f,0x1240,0x1641, |
366 | 0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249, |
367 | 0x124a,0x164b,0x124c,0x164d,0x164e,0x124f,0x1650,0x1251, |
368 | 0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659, |
369 | 0x165a,0x125b,0x165c,0x125d,0x125e,0x165f,0x1660,0x1261, |
370 | 0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669, |
371 | 0x166a,0x126b,0x166c,0x126d,0x126e,0x166f,0x1270,0x1671, |
372 | 0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279, |
373 | 0x127a,0x167b,0x127c,0x167d,0x167e,0x127f,0x9280,0x9681, |
374 | 0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289, |
375 | 0x928a,0x968b,0x928c,0x968d,0x968e,0x928f,0x9690,0x9291, |
376 | 0x9292,0x9693,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739, |
377 | 0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741, |
378 | 0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349, |
379 | 0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351, |
380 | 0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759, |
381 | 0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361, |
382 | 0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769, |
383 | 0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771, |
384 | 0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379, |
385 | 0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781, |
386 | 0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389, |
387 | 0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391, |
388 | 0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799, |
389 | 0x979a,0x939b,0x979c,0x939d,0x939e,0x979f,0x97a0,0x93a1, |
390 | 0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9, |
391 | 0x97aa,0x93ab,0x97ac,0x93ad,0x93ae,0x97af,0x93b0,0x97b1, |
392 | 0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9, |
393 | 0x93ba,0x97bb,0x93bc,0x97bd,0x97be,0x93bf,0x97c0,0x93c1, |
394 | 0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9, |
395 | 0x97ca,0x93cb,0x97cc,0x93cd,0x93ce,0x97cf,0x93d0,0x97d1, |
396 | 0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9, |
397 | 0x93da,0x97db,0x93dc,0x97dd,0x97de,0x93df,0x93e0,0x97e1, |
398 | 0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9, |
399 | 0x93ea,0x97eb,0x93ec,0x97ed,0x97ee,0x93ef,0x97f0,0x93f1, |
400 | 0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9, |
401 | 0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5700,0x1301, |
402 | 0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709, |
403 | 0x170a,0x130b,0x170c,0x130d,0x130e,0x170f,0x1310,0x1711, |
404 | 0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319, |
405 | 0x131a,0x171b,0x131c,0x171d,0x171e,0x131f,0x1320,0x1721, |
406 | 0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329, |
407 | 0x132a,0x172b,0x132c,0x172d,0x172e,0x132f,0x1730,0x1331, |
408 | 0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739, |
409 | 0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741, |
410 | 0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349, |
411 | 0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351, |
412 | 0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759, |
413 | 0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361, |
414 | 0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769, |
415 | 0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771, |
416 | 0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379, |
417 | 0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781, |
418 | 0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389, |
419 | 0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391, |
420 | 0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799 |
421 | }; |
422 | |
423 | void DDFDCBHandler(UINT32 dwWhich); |
424 | |
425 | |
426 | static void InvalidInstruction(UINT32 dwCount) |
427 | { |
428 | pbPC -= dwCount; /* Invalid instruction - back up */ |
429 | dwReturnCode = (UINT32) pbPC - (UINT32) cpu.z80Base; |
430 | dwOriginalCycles -= sdwCyclesRemaining; |
431 | sdwCyclesRemaining = 0; |
432 | } |
433 | |
434 | void CBHandler(void) |
435 | { |
436 | switch (*pbPC++) |
437 | { |
438 | case 0x00: |
439 | { |
440 | sdwCyclesRemaining -= 8; |
441 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
442 | bTemp2 = (cpu.z80B >> 7); |
443 | cpu.z80B = (cpu.z80B << 1) | bTemp2; |
444 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80B]; |
445 | break; |
446 | } |
447 | case 0x01: |
448 | { |
449 | sdwCyclesRemaining -= 8; |
450 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
451 | bTemp2 = (cpu.z80C >> 7); |
452 | cpu.z80C = (cpu.z80C << 1) | bTemp2; |
453 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80C]; |
454 | break; |
455 | } |
456 | case 0x02: |
457 | { |
458 | sdwCyclesRemaining -= 8; |
459 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
460 | bTemp2 = (cpu.z80D >> 7); |
461 | cpu.z80D = (cpu.z80D << 1) | bTemp2; |
462 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80D]; |
463 | break; |
464 | } |
465 | case 0x03: |
466 | { |
467 | sdwCyclesRemaining -= 8; |
468 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
469 | bTemp2 = (cpu.z80E >> 7); |
470 | cpu.z80E = (cpu.z80E << 1) | bTemp2; |
471 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80E]; |
472 | break; |
473 | } |
474 | case 0x04: |
475 | { |
476 | sdwCyclesRemaining -= 8; |
477 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
478 | bTemp2 = (cpu.z80H >> 7); |
479 | cpu.z80H = (cpu.z80H << 1) | bTemp2; |
480 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80H]; |
481 | break; |
482 | } |
483 | case 0x05: |
484 | { |
485 | sdwCyclesRemaining -= 8; |
486 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
487 | bTemp2 = (cpu.z80L >> 7); |
488 | cpu.z80L = (cpu.z80L << 1) | bTemp2; |
489 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80L]; |
490 | break; |
491 | } |
492 | case 0x06: |
493 | { |
494 | sdwCyclesRemaining -= 15; |
495 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
496 | while (psMemRead->lowAddr != 0xffffffff) |
497 | { |
498 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
499 | { |
500 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
501 | if (psMemRead->memoryCall) |
502 | { |
503 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
504 | } |
505 | else |
506 | { |
507 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
508 | } |
509 | psMemRead = NULL; |
510 | break; |
511 | } |
512 | ++psMemRead; |
513 | } |
514 | |
515 | if (psMemRead) |
516 | { |
517 | bTemp = cpu.z80Base[cpu.z80HL]; |
518 | } |
519 | |
520 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
521 | bTemp2 = (bTemp >> 7); |
522 | bTemp = (bTemp << 1) | bTemp2; |
523 | cpu.z80F |= bTemp2 | bPostORFlags[bTemp]; |
524 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
525 | while (psMemWrite->lowAddr != 0xffffffff) |
526 | { |
527 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
528 | { |
529 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
530 | if (psMemWrite->memoryCall) |
531 | { |
532 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
533 | } |
534 | else |
535 | { |
536 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
537 | } |
538 | psMemWrite = NULL; |
539 | break; |
540 | } |
541 | ++psMemWrite; |
542 | } |
543 | |
544 | if (psMemWrite) |
545 | { |
546 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
547 | } |
548 | |
549 | break; |
550 | } |
551 | case 0x07: |
552 | { |
553 | sdwCyclesRemaining -= 8; |
554 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
555 | bTemp2 = (cpu.z80A >> 7); |
556 | cpu.z80A = (cpu.z80A << 1) | bTemp2; |
557 | cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80A]; |
558 | break; |
559 | } |
560 | case 0x08: |
561 | { |
562 | sdwCyclesRemaining -= 8; |
563 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
564 | cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY); |
565 | cpu.z80B = (cpu.z80B >> 1) | (cpu.z80B << 7); |
566 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
567 | break; |
568 | } |
569 | case 0x09: |
570 | { |
571 | sdwCyclesRemaining -= 8; |
572 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
573 | cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY); |
574 | cpu.z80C = (cpu.z80C >> 1) | (cpu.z80C << 7); |
575 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
576 | break; |
577 | } |
578 | case 0x0a: |
579 | { |
580 | sdwCyclesRemaining -= 8; |
581 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
582 | cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY); |
583 | cpu.z80D = (cpu.z80D >> 1) | (cpu.z80D << 7); |
584 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
585 | break; |
586 | } |
587 | case 0x0b: |
588 | { |
589 | sdwCyclesRemaining -= 8; |
590 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
591 | cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY); |
592 | cpu.z80E = (cpu.z80E >> 1) | (cpu.z80E << 7); |
593 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
594 | break; |
595 | } |
596 | case 0x0c: |
597 | { |
598 | sdwCyclesRemaining -= 8; |
599 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
600 | cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY); |
601 | cpu.z80H = (cpu.z80H >> 1) | (cpu.z80H << 7); |
602 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
603 | break; |
604 | } |
605 | case 0x0d: |
606 | { |
607 | sdwCyclesRemaining -= 8; |
608 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
609 | cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY); |
610 | cpu.z80L = (cpu.z80L >> 1) | (cpu.z80L << 7); |
611 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
612 | break; |
613 | } |
614 | case 0x0e: |
615 | { |
616 | sdwCyclesRemaining -= 15; |
617 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
618 | while (psMemRead->lowAddr != 0xffffffff) |
619 | { |
620 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
621 | { |
622 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
623 | if (psMemRead->memoryCall) |
624 | { |
625 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
626 | } |
627 | else |
628 | { |
629 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
630 | } |
631 | psMemRead = NULL; |
632 | break; |
633 | } |
634 | ++psMemRead; |
635 | } |
636 | |
637 | if (psMemRead) |
638 | { |
639 | bTemp = cpu.z80Base[cpu.z80HL]; |
640 | } |
641 | |
642 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
643 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
644 | bTemp = (bTemp >> 1) | (bTemp << 7); |
645 | cpu.z80F |= bPostORFlags[bTemp]; |
646 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
647 | while (psMemWrite->lowAddr != 0xffffffff) |
648 | { |
649 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
650 | { |
651 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
652 | if (psMemWrite->memoryCall) |
653 | { |
654 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
655 | } |
656 | else |
657 | { |
658 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
659 | } |
660 | psMemWrite = NULL; |
661 | break; |
662 | } |
663 | ++psMemWrite; |
664 | } |
665 | |
666 | if (psMemWrite) |
667 | { |
668 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
669 | } |
670 | |
671 | break; |
672 | } |
673 | case 0x0f: |
674 | { |
675 | sdwCyclesRemaining -= 8; |
676 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
677 | cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY); |
678 | cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A << 7); |
679 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
680 | break; |
681 | } |
682 | case 0x10: |
683 | { |
684 | sdwCyclesRemaining -= 8; |
685 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
686 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
687 | cpu.z80F |= (cpu.z80B >> 7); |
688 | cpu.z80B = (cpu.z80B << 1) | bTemp2; |
689 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
690 | break; |
691 | } |
692 | case 0x11: |
693 | { |
694 | sdwCyclesRemaining -= 8; |
695 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
696 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
697 | cpu.z80F |= (cpu.z80C >> 7); |
698 | cpu.z80C = (cpu.z80C << 1) | bTemp2; |
699 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
700 | break; |
701 | } |
702 | case 0x12: |
703 | { |
704 | sdwCyclesRemaining -= 8; |
705 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
706 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
707 | cpu.z80F |= (cpu.z80D >> 7); |
708 | cpu.z80D = (cpu.z80D << 1) | bTemp2; |
709 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
710 | break; |
711 | } |
712 | case 0x13: |
713 | { |
714 | sdwCyclesRemaining -= 8; |
715 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
716 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
717 | cpu.z80F |= (cpu.z80E >> 7); |
718 | cpu.z80E = (cpu.z80E << 1) | bTemp2; |
719 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
720 | break; |
721 | } |
722 | case 0x14: |
723 | { |
724 | sdwCyclesRemaining -= 8; |
725 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
726 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
727 | cpu.z80F |= (cpu.z80H >> 7); |
728 | cpu.z80H = (cpu.z80H << 1) | bTemp2; |
729 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
730 | break; |
731 | } |
732 | case 0x15: |
733 | { |
734 | sdwCyclesRemaining -= 8; |
735 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
736 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
737 | cpu.z80F |= (cpu.z80L >> 7); |
738 | cpu.z80L = (cpu.z80L << 1) | bTemp2; |
739 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
740 | break; |
741 | } |
742 | case 0x16: |
743 | { |
744 | sdwCyclesRemaining -= 15; |
745 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
746 | while (psMemRead->lowAddr != 0xffffffff) |
747 | { |
748 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
749 | { |
750 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
751 | if (psMemRead->memoryCall) |
752 | { |
753 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
754 | } |
755 | else |
756 | { |
757 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
758 | } |
759 | psMemRead = NULL; |
760 | break; |
761 | } |
762 | ++psMemRead; |
763 | } |
764 | |
765 | if (psMemRead) |
766 | { |
767 | bTemp = cpu.z80Base[cpu.z80HL]; |
768 | } |
769 | |
770 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
771 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
772 | cpu.z80F |= (bTemp >> 7); |
773 | bTemp = (bTemp << 1) | bTemp2; |
774 | cpu.z80F |= bPostORFlags[bTemp]; |
775 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
776 | while (psMemWrite->lowAddr != 0xffffffff) |
777 | { |
778 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
779 | { |
780 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
781 | if (psMemWrite->memoryCall) |
782 | { |
783 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
784 | } |
785 | else |
786 | { |
787 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
788 | } |
789 | psMemWrite = NULL; |
790 | break; |
791 | } |
792 | ++psMemWrite; |
793 | } |
794 | |
795 | if (psMemWrite) |
796 | { |
797 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
798 | } |
799 | |
800 | break; |
801 | } |
802 | case 0x17: |
803 | { |
804 | sdwCyclesRemaining -= 8; |
805 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
806 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
807 | cpu.z80F |= (cpu.z80A >> 7); |
808 | cpu.z80A = (cpu.z80A << 1) | bTemp2; |
809 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
810 | break; |
811 | } |
812 | case 0x18: |
813 | { |
814 | sdwCyclesRemaining -= 8; |
815 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
816 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
817 | cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY); |
818 | cpu.z80B = (cpu.z80B >> 1) | bTemp2; |
819 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
820 | break; |
821 | } |
822 | case 0x19: |
823 | { |
824 | sdwCyclesRemaining -= 8; |
825 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
826 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
827 | cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY); |
828 | cpu.z80C = (cpu.z80C >> 1) | bTemp2; |
829 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
830 | break; |
831 | } |
832 | case 0x1a: |
833 | { |
834 | sdwCyclesRemaining -= 8; |
835 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
836 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
837 | cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY); |
838 | cpu.z80D = (cpu.z80D >> 1) | bTemp2; |
839 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
840 | break; |
841 | } |
842 | case 0x1b: |
843 | { |
844 | sdwCyclesRemaining -= 8; |
845 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
846 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
847 | cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY); |
848 | cpu.z80E = (cpu.z80E >> 1) | bTemp2; |
849 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
850 | break; |
851 | } |
852 | case 0x1c: |
853 | { |
854 | sdwCyclesRemaining -= 8; |
855 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
856 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
857 | cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY); |
858 | cpu.z80H = (cpu.z80H >> 1) | bTemp2; |
859 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
860 | break; |
861 | } |
862 | case 0x1d: |
863 | { |
864 | sdwCyclesRemaining -= 8; |
865 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
866 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
867 | cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY); |
868 | cpu.z80L = (cpu.z80L >> 1) | bTemp2; |
869 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
870 | break; |
871 | } |
872 | case 0x1e: |
873 | { |
874 | sdwCyclesRemaining -= 15; |
875 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
876 | while (psMemRead->lowAddr != 0xffffffff) |
877 | { |
878 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
879 | { |
880 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
881 | if (psMemRead->memoryCall) |
882 | { |
883 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
884 | } |
885 | else |
886 | { |
887 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
888 | } |
889 | psMemRead = NULL; |
890 | break; |
891 | } |
892 | ++psMemRead; |
893 | } |
894 | |
895 | if (psMemRead) |
896 | { |
897 | bTemp = cpu.z80Base[cpu.z80HL]; |
898 | } |
899 | |
900 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
901 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
902 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
903 | bTemp = (bTemp >> 1) | bTemp2; |
904 | cpu.z80F |= bPostORFlags[bTemp]; |
905 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
906 | while (psMemWrite->lowAddr != 0xffffffff) |
907 | { |
908 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
909 | { |
910 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
911 | if (psMemWrite->memoryCall) |
912 | { |
913 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
914 | } |
915 | else |
916 | { |
917 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
918 | } |
919 | psMemWrite = NULL; |
920 | break; |
921 | } |
922 | ++psMemWrite; |
923 | } |
924 | |
925 | if (psMemWrite) |
926 | { |
927 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
928 | } |
929 | |
930 | break; |
931 | } |
932 | case 0x1f: |
933 | { |
934 | sdwCyclesRemaining -= 8; |
935 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
936 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
937 | cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY); |
938 | cpu.z80A = (cpu.z80A >> 1) | bTemp2; |
939 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
940 | break; |
941 | } |
942 | case 0x20: |
943 | { |
944 | sdwCyclesRemaining -= 8; |
945 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
946 | cpu.z80F |= (cpu.z80B >> 7); |
947 | cpu.z80B = (cpu.z80B << 1); |
948 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
949 | break; |
950 | } |
951 | case 0x21: |
952 | { |
953 | sdwCyclesRemaining -= 8; |
954 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
955 | cpu.z80F |= (cpu.z80C >> 7); |
956 | cpu.z80C = (cpu.z80C << 1); |
957 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
958 | break; |
959 | } |
960 | case 0x22: |
961 | { |
962 | sdwCyclesRemaining -= 8; |
963 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
964 | cpu.z80F |= (cpu.z80D >> 7); |
965 | cpu.z80D = (cpu.z80D << 1); |
966 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
967 | break; |
968 | } |
969 | case 0x23: |
970 | { |
971 | sdwCyclesRemaining -= 8; |
972 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
973 | cpu.z80F |= (cpu.z80E >> 7); |
974 | cpu.z80E = (cpu.z80E << 1); |
975 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
976 | break; |
977 | } |
978 | case 0x24: |
979 | { |
980 | sdwCyclesRemaining -= 8; |
981 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
982 | cpu.z80F |= (cpu.z80H >> 7); |
983 | cpu.z80H = (cpu.z80H << 1); |
984 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
985 | break; |
986 | } |
987 | case 0x25: |
988 | { |
989 | sdwCyclesRemaining -= 8; |
990 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
991 | cpu.z80F |= (cpu.z80L >> 7); |
992 | cpu.z80L = (cpu.z80L << 1); |
993 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
994 | break; |
995 | } |
996 | case 0x26: |
997 | { |
998 | sdwCyclesRemaining -= 15; |
999 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1000 | while (psMemRead->lowAddr != 0xffffffff) |
1001 | { |
1002 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1003 | { |
1004 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1005 | if (psMemRead->memoryCall) |
1006 | { |
1007 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1008 | } |
1009 | else |
1010 | { |
1011 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1012 | } |
1013 | psMemRead = NULL; |
1014 | break; |
1015 | } |
1016 | ++psMemRead; |
1017 | } |
1018 | |
1019 | if (psMemRead) |
1020 | { |
1021 | bTemp = cpu.z80Base[cpu.z80HL]; |
1022 | } |
1023 | |
1024 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1025 | cpu.z80F |= (bTemp >> 7); |
1026 | bTemp = (bTemp << 1); |
1027 | cpu.z80F |= bPostORFlags[bTemp]; |
1028 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
1029 | while (psMemWrite->lowAddr != 0xffffffff) |
1030 | { |
1031 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
1032 | { |
1033 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1034 | if (psMemWrite->memoryCall) |
1035 | { |
1036 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
1037 | } |
1038 | else |
1039 | { |
1040 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
1041 | } |
1042 | psMemWrite = NULL; |
1043 | break; |
1044 | } |
1045 | ++psMemWrite; |
1046 | } |
1047 | |
1048 | if (psMemWrite) |
1049 | { |
1050 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
1051 | } |
1052 | |
1053 | break; |
1054 | } |
1055 | case 0x27: |
1056 | { |
1057 | sdwCyclesRemaining -= 8; |
1058 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1059 | cpu.z80F |= (cpu.z80A >> 7); |
1060 | cpu.z80A = (cpu.z80A << 1); |
1061 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
1062 | break; |
1063 | } |
1064 | case 0x28: |
1065 | { |
1066 | sdwCyclesRemaining -= 8; |
1067 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1068 | cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY); |
1069 | cpu.z80B = (cpu.z80B >> 1) | (cpu.z80B & 0x80); |
1070 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
1071 | break; |
1072 | } |
1073 | case 0x29: |
1074 | { |
1075 | sdwCyclesRemaining -= 8; |
1076 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1077 | cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY); |
1078 | cpu.z80C = (cpu.z80C >> 1) | (cpu.z80C & 0x80); |
1079 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
1080 | break; |
1081 | } |
1082 | case 0x2a: |
1083 | { |
1084 | sdwCyclesRemaining -= 8; |
1085 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1086 | cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY); |
1087 | cpu.z80D = (cpu.z80D >> 1) | (cpu.z80D & 0x80); |
1088 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
1089 | break; |
1090 | } |
1091 | case 0x2b: |
1092 | { |
1093 | sdwCyclesRemaining -= 8; |
1094 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1095 | cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY); |
1096 | cpu.z80E = (cpu.z80E >> 1) | (cpu.z80E & 0x80); |
1097 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
1098 | break; |
1099 | } |
1100 | case 0x2c: |
1101 | { |
1102 | sdwCyclesRemaining -= 8; |
1103 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1104 | cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY); |
1105 | cpu.z80H = (cpu.z80H >> 1) | (cpu.z80H & 0x80); |
1106 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
1107 | break; |
1108 | } |
1109 | case 0x2d: |
1110 | { |
1111 | sdwCyclesRemaining -= 8; |
1112 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1113 | cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY); |
1114 | cpu.z80L = (cpu.z80L >> 1) | (cpu.z80L & 0x80); |
1115 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
1116 | break; |
1117 | } |
1118 | case 0x2e: |
1119 | { |
1120 | sdwCyclesRemaining -= 15; |
1121 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1122 | while (psMemRead->lowAddr != 0xffffffff) |
1123 | { |
1124 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1125 | { |
1126 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1127 | if (psMemRead->memoryCall) |
1128 | { |
1129 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1130 | } |
1131 | else |
1132 | { |
1133 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1134 | } |
1135 | psMemRead = NULL; |
1136 | break; |
1137 | } |
1138 | ++psMemRead; |
1139 | } |
1140 | |
1141 | if (psMemRead) |
1142 | { |
1143 | bTemp = cpu.z80Base[cpu.z80HL]; |
1144 | } |
1145 | |
1146 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1147 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
1148 | bTemp = (bTemp >> 1) | (bTemp & 0x80); |
1149 | cpu.z80F |= bPostORFlags[bTemp]; |
1150 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
1151 | while (psMemWrite->lowAddr != 0xffffffff) |
1152 | { |
1153 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
1154 | { |
1155 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1156 | if (psMemWrite->memoryCall) |
1157 | { |
1158 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
1159 | } |
1160 | else |
1161 | { |
1162 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
1163 | } |
1164 | psMemWrite = NULL; |
1165 | break; |
1166 | } |
1167 | ++psMemWrite; |
1168 | } |
1169 | |
1170 | if (psMemWrite) |
1171 | { |
1172 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
1173 | } |
1174 | |
1175 | break; |
1176 | } |
1177 | case 0x2f: |
1178 | { |
1179 | sdwCyclesRemaining -= 8; |
1180 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1181 | cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY); |
1182 | cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A & 0x80); |
1183 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
1184 | break; |
1185 | } |
1186 | case 0x30: |
1187 | { |
1188 | sdwCyclesRemaining -= 8; |
1189 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1190 | cpu.z80F |= (cpu.z80B >> 7); |
1191 | cpu.z80B = (cpu.z80B << 1); |
1192 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
1193 | break; |
1194 | } |
1195 | case 0x31: |
1196 | { |
1197 | sdwCyclesRemaining -= 8; |
1198 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1199 | cpu.z80F |= (cpu.z80C >> 7); |
1200 | cpu.z80C = (cpu.z80C << 1); |
1201 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
1202 | break; |
1203 | } |
1204 | case 0x32: |
1205 | { |
1206 | sdwCyclesRemaining -= 8; |
1207 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1208 | cpu.z80F |= (cpu.z80D >> 7); |
1209 | cpu.z80D = (cpu.z80D << 1); |
1210 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
1211 | break; |
1212 | } |
1213 | case 0x33: |
1214 | { |
1215 | sdwCyclesRemaining -= 8; |
1216 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1217 | cpu.z80F |= (cpu.z80E >> 7); |
1218 | cpu.z80E = (cpu.z80E << 1); |
1219 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
1220 | break; |
1221 | } |
1222 | case 0x34: |
1223 | { |
1224 | sdwCyclesRemaining -= 8; |
1225 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1226 | cpu.z80F |= (cpu.z80H >> 7); |
1227 | cpu.z80H = (cpu.z80H << 1); |
1228 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
1229 | break; |
1230 | } |
1231 | case 0x35: |
1232 | { |
1233 | sdwCyclesRemaining -= 8; |
1234 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1235 | cpu.z80F |= (cpu.z80L >> 7); |
1236 | cpu.z80L = (cpu.z80L << 1); |
1237 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
1238 | break; |
1239 | } |
1240 | case 0x36: |
1241 | { |
1242 | sdwCyclesRemaining -= 15; |
1243 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1244 | while (psMemRead->lowAddr != 0xffffffff) |
1245 | { |
1246 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1247 | { |
1248 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1249 | if (psMemRead->memoryCall) |
1250 | { |
1251 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1252 | } |
1253 | else |
1254 | { |
1255 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1256 | } |
1257 | psMemRead = NULL; |
1258 | break; |
1259 | } |
1260 | ++psMemRead; |
1261 | } |
1262 | |
1263 | if (psMemRead) |
1264 | { |
1265 | bTemp = cpu.z80Base[cpu.z80HL]; |
1266 | } |
1267 | |
1268 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1269 | cpu.z80F |= (bTemp >> 7); |
1270 | bTemp = (bTemp << 1); |
1271 | cpu.z80F |= bPostORFlags[bTemp]; |
1272 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
1273 | while (psMemWrite->lowAddr != 0xffffffff) |
1274 | { |
1275 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
1276 | { |
1277 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1278 | if (psMemWrite->memoryCall) |
1279 | { |
1280 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
1281 | } |
1282 | else |
1283 | { |
1284 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
1285 | } |
1286 | psMemWrite = NULL; |
1287 | break; |
1288 | } |
1289 | ++psMemWrite; |
1290 | } |
1291 | |
1292 | if (psMemWrite) |
1293 | { |
1294 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
1295 | } |
1296 | |
1297 | break; |
1298 | } |
1299 | case 0x37: |
1300 | { |
1301 | sdwCyclesRemaining -= 8; |
1302 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1303 | cpu.z80F |= (cpu.z80A >> 7); |
1304 | cpu.z80A = (cpu.z80A << 1); |
1305 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
1306 | break; |
1307 | } |
1308 | case 0x38: |
1309 | { |
1310 | sdwCyclesRemaining -= 8; |
1311 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1312 | cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY); |
1313 | cpu.z80B = (cpu.z80B >> 1); |
1314 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
1315 | break; |
1316 | } |
1317 | case 0x39: |
1318 | { |
1319 | sdwCyclesRemaining -= 8; |
1320 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1321 | cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY); |
1322 | cpu.z80C = (cpu.z80C >> 1); |
1323 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
1324 | break; |
1325 | } |
1326 | case 0x3a: |
1327 | { |
1328 | sdwCyclesRemaining -= 8; |
1329 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1330 | cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY); |
1331 | cpu.z80D = (cpu.z80D >> 1); |
1332 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
1333 | break; |
1334 | } |
1335 | case 0x3b: |
1336 | { |
1337 | sdwCyclesRemaining -= 8; |
1338 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1339 | cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY); |
1340 | cpu.z80E = (cpu.z80E >> 1); |
1341 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
1342 | break; |
1343 | } |
1344 | case 0x3c: |
1345 | { |
1346 | sdwCyclesRemaining -= 8; |
1347 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1348 | cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY); |
1349 | cpu.z80H = (cpu.z80H >> 1); |
1350 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
1351 | break; |
1352 | } |
1353 | case 0x3d: |
1354 | { |
1355 | sdwCyclesRemaining -= 8; |
1356 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1357 | cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY); |
1358 | cpu.z80L = (cpu.z80L >> 1); |
1359 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
1360 | break; |
1361 | } |
1362 | case 0x3e: |
1363 | { |
1364 | sdwCyclesRemaining -= 15; |
1365 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1366 | while (psMemRead->lowAddr != 0xffffffff) |
1367 | { |
1368 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1369 | { |
1370 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1371 | if (psMemRead->memoryCall) |
1372 | { |
1373 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1374 | } |
1375 | else |
1376 | { |
1377 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1378 | } |
1379 | psMemRead = NULL; |
1380 | break; |
1381 | } |
1382 | ++psMemRead; |
1383 | } |
1384 | |
1385 | if (psMemRead) |
1386 | { |
1387 | bTemp = cpu.z80Base[cpu.z80HL]; |
1388 | } |
1389 | |
1390 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1391 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
1392 | bTemp = (bTemp >> 1); |
1393 | cpu.z80F |= bPostORFlags[bTemp]; |
1394 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
1395 | while (psMemWrite->lowAddr != 0xffffffff) |
1396 | { |
1397 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
1398 | { |
1399 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1400 | if (psMemWrite->memoryCall) |
1401 | { |
1402 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
1403 | } |
1404 | else |
1405 | { |
1406 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
1407 | } |
1408 | psMemWrite = NULL; |
1409 | break; |
1410 | } |
1411 | ++psMemWrite; |
1412 | } |
1413 | |
1414 | if (psMemWrite) |
1415 | { |
1416 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
1417 | } |
1418 | |
1419 | break; |
1420 | } |
1421 | case 0x3f: |
1422 | { |
1423 | sdwCyclesRemaining -= 8; |
1424 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
1425 | cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY); |
1426 | cpu.z80A = (cpu.z80A >> 1); |
1427 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
1428 | break; |
1429 | } |
1430 | case 0x40: |
1431 | { |
1432 | sdwCyclesRemaining -= 8; |
1433 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1434 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1435 | if (!(cpu.z80B & 0x01)) |
1436 | { |
1437 | cpu.z80F |= Z80_FLAG_ZERO; |
1438 | } |
1439 | break; |
1440 | } |
1441 | case 0x41: |
1442 | { |
1443 | sdwCyclesRemaining -= 8; |
1444 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1445 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1446 | if (!(cpu.z80C & 0x01)) |
1447 | { |
1448 | cpu.z80F |= Z80_FLAG_ZERO; |
1449 | } |
1450 | break; |
1451 | } |
1452 | case 0x42: |
1453 | { |
1454 | sdwCyclesRemaining -= 8; |
1455 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1456 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1457 | if (!(cpu.z80D & 0x01)) |
1458 | { |
1459 | cpu.z80F |= Z80_FLAG_ZERO; |
1460 | } |
1461 | break; |
1462 | } |
1463 | case 0x43: |
1464 | { |
1465 | sdwCyclesRemaining -= 8; |
1466 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1467 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1468 | if (!(cpu.z80E & 0x01)) |
1469 | { |
1470 | cpu.z80F |= Z80_FLAG_ZERO; |
1471 | } |
1472 | break; |
1473 | } |
1474 | case 0x44: |
1475 | { |
1476 | sdwCyclesRemaining -= 8; |
1477 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1478 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1479 | if (!(cpu.z80H & 0x01)) |
1480 | { |
1481 | cpu.z80F |= Z80_FLAG_ZERO; |
1482 | } |
1483 | break; |
1484 | } |
1485 | case 0x45: |
1486 | { |
1487 | sdwCyclesRemaining -= 8; |
1488 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1489 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1490 | if (!(cpu.z80L & 0x01)) |
1491 | { |
1492 | cpu.z80F |= Z80_FLAG_ZERO; |
1493 | } |
1494 | break; |
1495 | } |
1496 | case 0x46: |
1497 | { |
1498 | sdwCyclesRemaining -= 12; |
1499 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1500 | while (psMemRead->lowAddr != 0xffffffff) |
1501 | { |
1502 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1503 | { |
1504 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1505 | if (psMemRead->memoryCall) |
1506 | { |
1507 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1508 | } |
1509 | else |
1510 | { |
1511 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1512 | } |
1513 | psMemRead = NULL; |
1514 | break; |
1515 | } |
1516 | ++psMemRead; |
1517 | } |
1518 | |
1519 | if (psMemRead) |
1520 | { |
1521 | bTemp = cpu.z80Base[cpu.z80HL]; |
1522 | } |
1523 | |
1524 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1525 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1526 | if (!(bTemp & 0x01)) |
1527 | { |
1528 | cpu.z80F |= Z80_FLAG_ZERO; |
1529 | } |
1530 | break; |
1531 | } |
1532 | case 0x47: |
1533 | { |
1534 | sdwCyclesRemaining -= 8; |
1535 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1536 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1537 | if (!(cpu.z80A & 0x01)) |
1538 | { |
1539 | cpu.z80F |= Z80_FLAG_ZERO; |
1540 | } |
1541 | break; |
1542 | } |
1543 | case 0x48: |
1544 | { |
1545 | sdwCyclesRemaining -= 8; |
1546 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1547 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1548 | if (!(cpu.z80B & 0x02)) |
1549 | { |
1550 | cpu.z80F |= Z80_FLAG_ZERO; |
1551 | } |
1552 | break; |
1553 | } |
1554 | case 0x49: |
1555 | { |
1556 | sdwCyclesRemaining -= 8; |
1557 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1558 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1559 | if (!(cpu.z80C & 0x02)) |
1560 | { |
1561 | cpu.z80F |= Z80_FLAG_ZERO; |
1562 | } |
1563 | break; |
1564 | } |
1565 | case 0x4a: |
1566 | { |
1567 | sdwCyclesRemaining -= 8; |
1568 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1569 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1570 | if (!(cpu.z80D & 0x02)) |
1571 | { |
1572 | cpu.z80F |= Z80_FLAG_ZERO; |
1573 | } |
1574 | break; |
1575 | } |
1576 | case 0x4b: |
1577 | { |
1578 | sdwCyclesRemaining -= 8; |
1579 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1580 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1581 | if (!(cpu.z80E & 0x02)) |
1582 | { |
1583 | cpu.z80F |= Z80_FLAG_ZERO; |
1584 | } |
1585 | break; |
1586 | } |
1587 | case 0x4c: |
1588 | { |
1589 | sdwCyclesRemaining -= 8; |
1590 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1591 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1592 | if (!(cpu.z80H & 0x02)) |
1593 | { |
1594 | cpu.z80F |= Z80_FLAG_ZERO; |
1595 | } |
1596 | break; |
1597 | } |
1598 | case 0x4d: |
1599 | { |
1600 | sdwCyclesRemaining -= 8; |
1601 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1602 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1603 | if (!(cpu.z80L & 0x02)) |
1604 | { |
1605 | cpu.z80F |= Z80_FLAG_ZERO; |
1606 | } |
1607 | break; |
1608 | } |
1609 | case 0x4e: |
1610 | { |
1611 | sdwCyclesRemaining -= 12; |
1612 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1613 | while (psMemRead->lowAddr != 0xffffffff) |
1614 | { |
1615 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1616 | { |
1617 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1618 | if (psMemRead->memoryCall) |
1619 | { |
1620 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1621 | } |
1622 | else |
1623 | { |
1624 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1625 | } |
1626 | psMemRead = NULL; |
1627 | break; |
1628 | } |
1629 | ++psMemRead; |
1630 | } |
1631 | |
1632 | if (psMemRead) |
1633 | { |
1634 | bTemp = cpu.z80Base[cpu.z80HL]; |
1635 | } |
1636 | |
1637 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1638 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1639 | if (!(bTemp & 0x02)) |
1640 | { |
1641 | cpu.z80F |= Z80_FLAG_ZERO; |
1642 | } |
1643 | break; |
1644 | } |
1645 | case 0x4f: |
1646 | { |
1647 | sdwCyclesRemaining -= 8; |
1648 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1649 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1650 | if (!(cpu.z80A & 0x02)) |
1651 | { |
1652 | cpu.z80F |= Z80_FLAG_ZERO; |
1653 | } |
1654 | break; |
1655 | } |
1656 | case 0x50: |
1657 | { |
1658 | sdwCyclesRemaining -= 8; |
1659 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1660 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1661 | if (!(cpu.z80B & 0x04)) |
1662 | { |
1663 | cpu.z80F |= Z80_FLAG_ZERO; |
1664 | } |
1665 | break; |
1666 | } |
1667 | case 0x51: |
1668 | { |
1669 | sdwCyclesRemaining -= 8; |
1670 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1671 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1672 | if (!(cpu.z80C & 0x04)) |
1673 | { |
1674 | cpu.z80F |= Z80_FLAG_ZERO; |
1675 | } |
1676 | break; |
1677 | } |
1678 | case 0x52: |
1679 | { |
1680 | sdwCyclesRemaining -= 8; |
1681 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1682 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1683 | if (!(cpu.z80D & 0x04)) |
1684 | { |
1685 | cpu.z80F |= Z80_FLAG_ZERO; |
1686 | } |
1687 | break; |
1688 | } |
1689 | case 0x53: |
1690 | { |
1691 | sdwCyclesRemaining -= 8; |
1692 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1693 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1694 | if (!(cpu.z80E & 0x04)) |
1695 | { |
1696 | cpu.z80F |= Z80_FLAG_ZERO; |
1697 | } |
1698 | break; |
1699 | } |
1700 | case 0x54: |
1701 | { |
1702 | sdwCyclesRemaining -= 8; |
1703 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1704 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1705 | if (!(cpu.z80H & 0x04)) |
1706 | { |
1707 | cpu.z80F |= Z80_FLAG_ZERO; |
1708 | } |
1709 | break; |
1710 | } |
1711 | case 0x55: |
1712 | { |
1713 | sdwCyclesRemaining -= 8; |
1714 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1715 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1716 | if (!(cpu.z80L & 0x04)) |
1717 | { |
1718 | cpu.z80F |= Z80_FLAG_ZERO; |
1719 | } |
1720 | break; |
1721 | } |
1722 | case 0x56: |
1723 | { |
1724 | sdwCyclesRemaining -= 12; |
1725 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1726 | while (psMemRead->lowAddr != 0xffffffff) |
1727 | { |
1728 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1729 | { |
1730 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1731 | if (psMemRead->memoryCall) |
1732 | { |
1733 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1734 | } |
1735 | else |
1736 | { |
1737 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1738 | } |
1739 | psMemRead = NULL; |
1740 | break; |
1741 | } |
1742 | ++psMemRead; |
1743 | } |
1744 | |
1745 | if (psMemRead) |
1746 | { |
1747 | bTemp = cpu.z80Base[cpu.z80HL]; |
1748 | } |
1749 | |
1750 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1751 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1752 | if (!(bTemp & 0x04)) |
1753 | { |
1754 | cpu.z80F |= Z80_FLAG_ZERO; |
1755 | } |
1756 | break; |
1757 | } |
1758 | case 0x57: |
1759 | { |
1760 | sdwCyclesRemaining -= 8; |
1761 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1762 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1763 | if (!(cpu.z80A & 0x04)) |
1764 | { |
1765 | cpu.z80F |= Z80_FLAG_ZERO; |
1766 | } |
1767 | break; |
1768 | } |
1769 | case 0x58: |
1770 | { |
1771 | sdwCyclesRemaining -= 8; |
1772 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1773 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1774 | if (!(cpu.z80B & 0x08)) |
1775 | { |
1776 | cpu.z80F |= Z80_FLAG_ZERO; |
1777 | } |
1778 | break; |
1779 | } |
1780 | case 0x59: |
1781 | { |
1782 | sdwCyclesRemaining -= 8; |
1783 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1784 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1785 | if (!(cpu.z80C & 0x08)) |
1786 | { |
1787 | cpu.z80F |= Z80_FLAG_ZERO; |
1788 | } |
1789 | break; |
1790 | } |
1791 | case 0x5a: |
1792 | { |
1793 | sdwCyclesRemaining -= 8; |
1794 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1795 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1796 | if (!(cpu.z80D & 0x08)) |
1797 | { |
1798 | cpu.z80F |= Z80_FLAG_ZERO; |
1799 | } |
1800 | break; |
1801 | } |
1802 | case 0x5b: |
1803 | { |
1804 | sdwCyclesRemaining -= 8; |
1805 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1806 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1807 | if (!(cpu.z80E & 0x08)) |
1808 | { |
1809 | cpu.z80F |= Z80_FLAG_ZERO; |
1810 | } |
1811 | break; |
1812 | } |
1813 | case 0x5c: |
1814 | { |
1815 | sdwCyclesRemaining -= 8; |
1816 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1817 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1818 | if (!(cpu.z80H & 0x08)) |
1819 | { |
1820 | cpu.z80F |= Z80_FLAG_ZERO; |
1821 | } |
1822 | break; |
1823 | } |
1824 | case 0x5d: |
1825 | { |
1826 | sdwCyclesRemaining -= 8; |
1827 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1828 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1829 | if (!(cpu.z80L & 0x08)) |
1830 | { |
1831 | cpu.z80F |= Z80_FLAG_ZERO; |
1832 | } |
1833 | break; |
1834 | } |
1835 | case 0x5e: |
1836 | { |
1837 | sdwCyclesRemaining -= 12; |
1838 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1839 | while (psMemRead->lowAddr != 0xffffffff) |
1840 | { |
1841 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1842 | { |
1843 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1844 | if (psMemRead->memoryCall) |
1845 | { |
1846 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1847 | } |
1848 | else |
1849 | { |
1850 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1851 | } |
1852 | psMemRead = NULL; |
1853 | break; |
1854 | } |
1855 | ++psMemRead; |
1856 | } |
1857 | |
1858 | if (psMemRead) |
1859 | { |
1860 | bTemp = cpu.z80Base[cpu.z80HL]; |
1861 | } |
1862 | |
1863 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1864 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1865 | if (!(bTemp & 0x08)) |
1866 | { |
1867 | cpu.z80F |= Z80_FLAG_ZERO; |
1868 | } |
1869 | break; |
1870 | } |
1871 | case 0x5f: |
1872 | { |
1873 | sdwCyclesRemaining -= 8; |
1874 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1875 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1876 | if (!(cpu.z80A & 0x08)) |
1877 | { |
1878 | cpu.z80F |= Z80_FLAG_ZERO; |
1879 | } |
1880 | break; |
1881 | } |
1882 | case 0x60: |
1883 | { |
1884 | sdwCyclesRemaining -= 8; |
1885 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1886 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1887 | if (!(cpu.z80B & 0x10)) |
1888 | { |
1889 | cpu.z80F |= Z80_FLAG_ZERO; |
1890 | } |
1891 | break; |
1892 | } |
1893 | case 0x61: |
1894 | { |
1895 | sdwCyclesRemaining -= 8; |
1896 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1897 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1898 | if (!(cpu.z80C & 0x10)) |
1899 | { |
1900 | cpu.z80F |= Z80_FLAG_ZERO; |
1901 | } |
1902 | break; |
1903 | } |
1904 | case 0x62: |
1905 | { |
1906 | sdwCyclesRemaining -= 8; |
1907 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1908 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1909 | if (!(cpu.z80D & 0x10)) |
1910 | { |
1911 | cpu.z80F |= Z80_FLAG_ZERO; |
1912 | } |
1913 | break; |
1914 | } |
1915 | case 0x63: |
1916 | { |
1917 | sdwCyclesRemaining -= 8; |
1918 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1919 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1920 | if (!(cpu.z80E & 0x10)) |
1921 | { |
1922 | cpu.z80F |= Z80_FLAG_ZERO; |
1923 | } |
1924 | break; |
1925 | } |
1926 | case 0x64: |
1927 | { |
1928 | sdwCyclesRemaining -= 8; |
1929 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1930 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1931 | if (!(cpu.z80H & 0x10)) |
1932 | { |
1933 | cpu.z80F |= Z80_FLAG_ZERO; |
1934 | } |
1935 | break; |
1936 | } |
1937 | case 0x65: |
1938 | { |
1939 | sdwCyclesRemaining -= 8; |
1940 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1941 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1942 | if (!(cpu.z80L & 0x10)) |
1943 | { |
1944 | cpu.z80F |= Z80_FLAG_ZERO; |
1945 | } |
1946 | break; |
1947 | } |
1948 | case 0x66: |
1949 | { |
1950 | sdwCyclesRemaining -= 12; |
1951 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
1952 | while (psMemRead->lowAddr != 0xffffffff) |
1953 | { |
1954 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
1955 | { |
1956 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
1957 | if (psMemRead->memoryCall) |
1958 | { |
1959 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
1960 | } |
1961 | else |
1962 | { |
1963 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
1964 | } |
1965 | psMemRead = NULL; |
1966 | break; |
1967 | } |
1968 | ++psMemRead; |
1969 | } |
1970 | |
1971 | if (psMemRead) |
1972 | { |
1973 | bTemp = cpu.z80Base[cpu.z80HL]; |
1974 | } |
1975 | |
1976 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1977 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1978 | if (!(bTemp & 0x10)) |
1979 | { |
1980 | cpu.z80F |= Z80_FLAG_ZERO; |
1981 | } |
1982 | break; |
1983 | } |
1984 | case 0x67: |
1985 | { |
1986 | sdwCyclesRemaining -= 8; |
1987 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1988 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
1989 | if (!(cpu.z80A & 0x10)) |
1990 | { |
1991 | cpu.z80F |= Z80_FLAG_ZERO; |
1992 | } |
1993 | break; |
1994 | } |
1995 | case 0x68: |
1996 | { |
1997 | sdwCyclesRemaining -= 8; |
1998 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
1999 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2000 | if (!(cpu.z80B & 0x20)) |
2001 | { |
2002 | cpu.z80F |= Z80_FLAG_ZERO; |
2003 | } |
2004 | break; |
2005 | } |
2006 | case 0x69: |
2007 | { |
2008 | sdwCyclesRemaining -= 8; |
2009 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2010 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2011 | if (!(cpu.z80C & 0x20)) |
2012 | { |
2013 | cpu.z80F |= Z80_FLAG_ZERO; |
2014 | } |
2015 | break; |
2016 | } |
2017 | case 0x6a: |
2018 | { |
2019 | sdwCyclesRemaining -= 8; |
2020 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2021 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2022 | if (!(cpu.z80D & 0x20)) |
2023 | { |
2024 | cpu.z80F |= Z80_FLAG_ZERO; |
2025 | } |
2026 | break; |
2027 | } |
2028 | case 0x6b: |
2029 | { |
2030 | sdwCyclesRemaining -= 8; |
2031 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2032 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2033 | if (!(cpu.z80E & 0x20)) |
2034 | { |
2035 | cpu.z80F |= Z80_FLAG_ZERO; |
2036 | } |
2037 | break; |
2038 | } |
2039 | case 0x6c: |
2040 | { |
2041 | sdwCyclesRemaining -= 8; |
2042 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2043 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2044 | if (!(cpu.z80H & 0x20)) |
2045 | { |
2046 | cpu.z80F |= Z80_FLAG_ZERO; |
2047 | } |
2048 | break; |
2049 | } |
2050 | case 0x6d: |
2051 | { |
2052 | sdwCyclesRemaining -= 8; |
2053 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2054 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2055 | if (!(cpu.z80L & 0x20)) |
2056 | { |
2057 | cpu.z80F |= Z80_FLAG_ZERO; |
2058 | } |
2059 | break; |
2060 | } |
2061 | case 0x6e: |
2062 | { |
2063 | sdwCyclesRemaining -= 12; |
2064 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2065 | while (psMemRead->lowAddr != 0xffffffff) |
2066 | { |
2067 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2068 | { |
2069 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2070 | if (psMemRead->memoryCall) |
2071 | { |
2072 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2073 | } |
2074 | else |
2075 | { |
2076 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2077 | } |
2078 | psMemRead = NULL; |
2079 | break; |
2080 | } |
2081 | ++psMemRead; |
2082 | } |
2083 | |
2084 | if (psMemRead) |
2085 | { |
2086 | bTemp = cpu.z80Base[cpu.z80HL]; |
2087 | } |
2088 | |
2089 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2090 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2091 | if (!(bTemp & 0x20)) |
2092 | { |
2093 | cpu.z80F |= Z80_FLAG_ZERO; |
2094 | } |
2095 | break; |
2096 | } |
2097 | case 0x6f: |
2098 | { |
2099 | sdwCyclesRemaining -= 8; |
2100 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2101 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2102 | if (!(cpu.z80A & 0x20)) |
2103 | { |
2104 | cpu.z80F |= Z80_FLAG_ZERO; |
2105 | } |
2106 | break; |
2107 | } |
2108 | case 0x70: |
2109 | { |
2110 | sdwCyclesRemaining -= 8; |
2111 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2112 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2113 | if (!(cpu.z80B & 0x40)) |
2114 | { |
2115 | cpu.z80F |= Z80_FLAG_ZERO; |
2116 | } |
2117 | break; |
2118 | } |
2119 | case 0x71: |
2120 | { |
2121 | sdwCyclesRemaining -= 8; |
2122 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2123 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2124 | if (!(cpu.z80C & 0x40)) |
2125 | { |
2126 | cpu.z80F |= Z80_FLAG_ZERO; |
2127 | } |
2128 | break; |
2129 | } |
2130 | case 0x72: |
2131 | { |
2132 | sdwCyclesRemaining -= 8; |
2133 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2134 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2135 | if (!(cpu.z80D & 0x40)) |
2136 | { |
2137 | cpu.z80F |= Z80_FLAG_ZERO; |
2138 | } |
2139 | break; |
2140 | } |
2141 | case 0x73: |
2142 | { |
2143 | sdwCyclesRemaining -= 8; |
2144 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2145 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2146 | if (!(cpu.z80E & 0x40)) |
2147 | { |
2148 | cpu.z80F |= Z80_FLAG_ZERO; |
2149 | } |
2150 | break; |
2151 | } |
2152 | case 0x74: |
2153 | { |
2154 | sdwCyclesRemaining -= 8; |
2155 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2156 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2157 | if (!(cpu.z80H & 0x40)) |
2158 | { |
2159 | cpu.z80F |= Z80_FLAG_ZERO; |
2160 | } |
2161 | break; |
2162 | } |
2163 | case 0x75: |
2164 | { |
2165 | sdwCyclesRemaining -= 8; |
2166 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2167 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2168 | if (!(cpu.z80L & 0x40)) |
2169 | { |
2170 | cpu.z80F |= Z80_FLAG_ZERO; |
2171 | } |
2172 | break; |
2173 | } |
2174 | case 0x76: |
2175 | { |
2176 | sdwCyclesRemaining -= 12; |
2177 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2178 | while (psMemRead->lowAddr != 0xffffffff) |
2179 | { |
2180 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2181 | { |
2182 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2183 | if (psMemRead->memoryCall) |
2184 | { |
2185 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2186 | } |
2187 | else |
2188 | { |
2189 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2190 | } |
2191 | psMemRead = NULL; |
2192 | break; |
2193 | } |
2194 | ++psMemRead; |
2195 | } |
2196 | |
2197 | if (psMemRead) |
2198 | { |
2199 | bTemp = cpu.z80Base[cpu.z80HL]; |
2200 | } |
2201 | |
2202 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2203 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2204 | if (!(bTemp & 0x40)) |
2205 | { |
2206 | cpu.z80F |= Z80_FLAG_ZERO; |
2207 | } |
2208 | break; |
2209 | } |
2210 | case 0x77: |
2211 | { |
2212 | sdwCyclesRemaining -= 8; |
2213 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2214 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2215 | if (!(cpu.z80A & 0x40)) |
2216 | { |
2217 | cpu.z80F |= Z80_FLAG_ZERO; |
2218 | } |
2219 | break; |
2220 | } |
2221 | case 0x78: |
2222 | { |
2223 | sdwCyclesRemaining -= 8; |
2224 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2225 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2226 | if (!(cpu.z80B & 0x80)) |
2227 | { |
2228 | cpu.z80F |= Z80_FLAG_ZERO; |
2229 | } |
2230 | break; |
2231 | } |
2232 | case 0x79: |
2233 | { |
2234 | sdwCyclesRemaining -= 8; |
2235 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2236 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2237 | if (!(cpu.z80C & 0x80)) |
2238 | { |
2239 | cpu.z80F |= Z80_FLAG_ZERO; |
2240 | } |
2241 | break; |
2242 | } |
2243 | case 0x7a: |
2244 | { |
2245 | sdwCyclesRemaining -= 8; |
2246 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2247 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2248 | if (!(cpu.z80D & 0x80)) |
2249 | { |
2250 | cpu.z80F |= Z80_FLAG_ZERO; |
2251 | } |
2252 | break; |
2253 | } |
2254 | case 0x7b: |
2255 | { |
2256 | sdwCyclesRemaining -= 8; |
2257 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2258 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2259 | if (!(cpu.z80E & 0x80)) |
2260 | { |
2261 | cpu.z80F |= Z80_FLAG_ZERO; |
2262 | } |
2263 | break; |
2264 | } |
2265 | case 0x7c: |
2266 | { |
2267 | sdwCyclesRemaining -= 8; |
2268 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2269 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2270 | if (!(cpu.z80H & 0x80)) |
2271 | { |
2272 | cpu.z80F |= Z80_FLAG_ZERO; |
2273 | } |
2274 | break; |
2275 | } |
2276 | case 0x7d: |
2277 | { |
2278 | sdwCyclesRemaining -= 8; |
2279 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2280 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2281 | if (!(cpu.z80L & 0x80)) |
2282 | { |
2283 | cpu.z80F |= Z80_FLAG_ZERO; |
2284 | } |
2285 | break; |
2286 | } |
2287 | case 0x7e: |
2288 | { |
2289 | sdwCyclesRemaining -= 12; |
2290 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2291 | while (psMemRead->lowAddr != 0xffffffff) |
2292 | { |
2293 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2294 | { |
2295 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2296 | if (psMemRead->memoryCall) |
2297 | { |
2298 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2299 | } |
2300 | else |
2301 | { |
2302 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2303 | } |
2304 | psMemRead = NULL; |
2305 | break; |
2306 | } |
2307 | ++psMemRead; |
2308 | } |
2309 | |
2310 | if (psMemRead) |
2311 | { |
2312 | bTemp = cpu.z80Base[cpu.z80HL]; |
2313 | } |
2314 | |
2315 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2316 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2317 | if (!(bTemp & 0x80)) |
2318 | { |
2319 | cpu.z80F |= Z80_FLAG_ZERO; |
2320 | } |
2321 | break; |
2322 | } |
2323 | case 0x7f: |
2324 | { |
2325 | sdwCyclesRemaining -= 8; |
2326 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO); |
2327 | cpu.z80F |= (Z80_FLAG_HALF_CARRY); |
2328 | if (!(cpu.z80A & 0x80)) |
2329 | { |
2330 | cpu.z80F |= Z80_FLAG_ZERO; |
2331 | } |
2332 | break; |
2333 | } |
2334 | case 0x80: |
2335 | { |
2336 | sdwCyclesRemaining -= 8; |
2337 | cpu.z80B &= 0xfe; |
2338 | break; |
2339 | } |
2340 | case 0x81: |
2341 | { |
2342 | sdwCyclesRemaining -= 8; |
2343 | cpu.z80C &= 0xfe; |
2344 | break; |
2345 | } |
2346 | case 0x82: |
2347 | { |
2348 | sdwCyclesRemaining -= 8; |
2349 | cpu.z80D &= 0xfe; |
2350 | break; |
2351 | } |
2352 | case 0x83: |
2353 | { |
2354 | sdwCyclesRemaining -= 8; |
2355 | cpu.z80E &= 0xfe; |
2356 | break; |
2357 | } |
2358 | case 0x84: |
2359 | { |
2360 | sdwCyclesRemaining -= 8; |
2361 | cpu.z80H &= 0xfe; |
2362 | break; |
2363 | } |
2364 | case 0x85: |
2365 | { |
2366 | sdwCyclesRemaining -= 8; |
2367 | cpu.z80L &= 0xfe; |
2368 | break; |
2369 | } |
2370 | case 0x86: |
2371 | { |
2372 | sdwCyclesRemaining -= 15; |
2373 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2374 | while (psMemRead->lowAddr != 0xffffffff) |
2375 | { |
2376 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2377 | { |
2378 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2379 | if (psMemRead->memoryCall) |
2380 | { |
2381 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2382 | } |
2383 | else |
2384 | { |
2385 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2386 | } |
2387 | psMemRead = NULL; |
2388 | break; |
2389 | } |
2390 | ++psMemRead; |
2391 | } |
2392 | |
2393 | if (psMemRead) |
2394 | { |
2395 | bTemp = cpu.z80Base[cpu.z80HL]; |
2396 | } |
2397 | |
2398 | bTemp &= 0xfe; |
2399 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2400 | while (psMemWrite->lowAddr != 0xffffffff) |
2401 | { |
2402 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2403 | { |
2404 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2405 | if (psMemWrite->memoryCall) |
2406 | { |
2407 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2408 | } |
2409 | else |
2410 | { |
2411 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
2412 | } |
2413 | psMemWrite = NULL; |
2414 | break; |
2415 | } |
2416 | ++psMemWrite; |
2417 | } |
2418 | |
2419 | if (psMemWrite) |
2420 | { |
2421 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
2422 | } |
2423 | |
2424 | break; |
2425 | } |
2426 | case 0x87: |
2427 | { |
2428 | sdwCyclesRemaining -= 8; |
2429 | cpu.z80A &= 0xfe; |
2430 | break; |
2431 | } |
2432 | case 0x88: |
2433 | { |
2434 | sdwCyclesRemaining -= 8; |
2435 | cpu.z80B &= 0xfd; |
2436 | break; |
2437 | } |
2438 | case 0x89: |
2439 | { |
2440 | sdwCyclesRemaining -= 8; |
2441 | cpu.z80C &= 0xfd; |
2442 | break; |
2443 | } |
2444 | case 0x8a: |
2445 | { |
2446 | sdwCyclesRemaining -= 8; |
2447 | cpu.z80D &= 0xfd; |
2448 | break; |
2449 | } |
2450 | case 0x8b: |
2451 | { |
2452 | sdwCyclesRemaining -= 8; |
2453 | cpu.z80E &= 0xfd; |
2454 | break; |
2455 | } |
2456 | case 0x8c: |
2457 | { |
2458 | sdwCyclesRemaining -= 8; |
2459 | cpu.z80H &= 0xfd; |
2460 | break; |
2461 | } |
2462 | case 0x8d: |
2463 | { |
2464 | sdwCyclesRemaining -= 8; |
2465 | cpu.z80L &= 0xfd; |
2466 | break; |
2467 | } |
2468 | case 0x8e: |
2469 | { |
2470 | sdwCyclesRemaining -= 15; |
2471 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2472 | while (psMemRead->lowAddr != 0xffffffff) |
2473 | { |
2474 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2475 | { |
2476 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2477 | if (psMemRead->memoryCall) |
2478 | { |
2479 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2480 | } |
2481 | else |
2482 | { |
2483 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2484 | } |
2485 | psMemRead = NULL; |
2486 | break; |
2487 | } |
2488 | ++psMemRead; |
2489 | } |
2490 | |
2491 | if (psMemRead) |
2492 | { |
2493 | bTemp = cpu.z80Base[cpu.z80HL]; |
2494 | } |
2495 | |
2496 | bTemp &= 0xfd; |
2497 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2498 | while (psMemWrite->lowAddr != 0xffffffff) |
2499 | { |
2500 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2501 | { |
2502 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2503 | if (psMemWrite->memoryCall) |
2504 | { |
2505 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2506 | } |
2507 | else |
2508 | { |
2509 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
2510 | } |
2511 | psMemWrite = NULL; |
2512 | break; |
2513 | } |
2514 | ++psMemWrite; |
2515 | } |
2516 | |
2517 | if (psMemWrite) |
2518 | { |
2519 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
2520 | } |
2521 | |
2522 | break; |
2523 | } |
2524 | case 0x8f: |
2525 | { |
2526 | sdwCyclesRemaining -= 8; |
2527 | cpu.z80A &= 0xfd; |
2528 | break; |
2529 | } |
2530 | case 0x90: |
2531 | { |
2532 | sdwCyclesRemaining -= 8; |
2533 | cpu.z80B &= 0xfb; |
2534 | break; |
2535 | } |
2536 | case 0x91: |
2537 | { |
2538 | sdwCyclesRemaining -= 8; |
2539 | cpu.z80C &= 0xfb; |
2540 | break; |
2541 | } |
2542 | case 0x92: |
2543 | { |
2544 | sdwCyclesRemaining -= 8; |
2545 | cpu.z80D &= 0xfb; |
2546 | break; |
2547 | } |
2548 | case 0x93: |
2549 | { |
2550 | sdwCyclesRemaining -= 8; |
2551 | cpu.z80E &= 0xfb; |
2552 | break; |
2553 | } |
2554 | case 0x94: |
2555 | { |
2556 | sdwCyclesRemaining -= 8; |
2557 | cpu.z80H &= 0xfb; |
2558 | break; |
2559 | } |
2560 | case 0x95: |
2561 | { |
2562 | sdwCyclesRemaining -= 8; |
2563 | cpu.z80L &= 0xfb; |
2564 | break; |
2565 | } |
2566 | case 0x96: |
2567 | { |
2568 | sdwCyclesRemaining -= 15; |
2569 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2570 | while (psMemRead->lowAddr != 0xffffffff) |
2571 | { |
2572 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2573 | { |
2574 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2575 | if (psMemRead->memoryCall) |
2576 | { |
2577 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2578 | } |
2579 | else |
2580 | { |
2581 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2582 | } |
2583 | psMemRead = NULL; |
2584 | break; |
2585 | } |
2586 | ++psMemRead; |
2587 | } |
2588 | |
2589 | if (psMemRead) |
2590 | { |
2591 | bTemp = cpu.z80Base[cpu.z80HL]; |
2592 | } |
2593 | |
2594 | bTemp &= 0xfb; |
2595 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2596 | while (psMemWrite->lowAddr != 0xffffffff) |
2597 | { |
2598 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2599 | { |
2600 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2601 | if (psMemWrite->memoryCall) |
2602 | { |
2603 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2604 | } |
2605 | else |
2606 | { |
2607 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
2608 | } |
2609 | psMemWrite = NULL; |
2610 | break; |
2611 | } |
2612 | ++psMemWrite; |
2613 | } |
2614 | |
2615 | if (psMemWrite) |
2616 | { |
2617 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
2618 | } |
2619 | |
2620 | break; |
2621 | } |
2622 | case 0x97: |
2623 | { |
2624 | sdwCyclesRemaining -= 8; |
2625 | cpu.z80A &= 0xfb; |
2626 | break; |
2627 | } |
2628 | case 0x98: |
2629 | { |
2630 | sdwCyclesRemaining -= 8; |
2631 | cpu.z80B &= 0xf7; |
2632 | break; |
2633 | } |
2634 | case 0x99: |
2635 | { |
2636 | sdwCyclesRemaining -= 8; |
2637 | cpu.z80C &= 0xf7; |
2638 | break; |
2639 | } |
2640 | case 0x9a: |
2641 | { |
2642 | sdwCyclesRemaining -= 8; |
2643 | cpu.z80D &= 0xf7; |
2644 | break; |
2645 | } |
2646 | case 0x9b: |
2647 | { |
2648 | sdwCyclesRemaining -= 8; |
2649 | cpu.z80E &= 0xf7; |
2650 | break; |
2651 | } |
2652 | case 0x9c: |
2653 | { |
2654 | sdwCyclesRemaining -= 8; |
2655 | cpu.z80H &= 0xf7; |
2656 | break; |
2657 | } |
2658 | case 0x9d: |
2659 | { |
2660 | sdwCyclesRemaining -= 8; |
2661 | cpu.z80L &= 0xf7; |
2662 | break; |
2663 | } |
2664 | case 0x9e: |
2665 | { |
2666 | sdwCyclesRemaining -= 15; |
2667 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2668 | while (psMemRead->lowAddr != 0xffffffff) |
2669 | { |
2670 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2671 | { |
2672 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2673 | if (psMemRead->memoryCall) |
2674 | { |
2675 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2676 | } |
2677 | else |
2678 | { |
2679 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2680 | } |
2681 | psMemRead = NULL; |
2682 | break; |
2683 | } |
2684 | ++psMemRead; |
2685 | } |
2686 | |
2687 | if (psMemRead) |
2688 | { |
2689 | bTemp = cpu.z80Base[cpu.z80HL]; |
2690 | } |
2691 | |
2692 | bTemp &= 0xf7; |
2693 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2694 | while (psMemWrite->lowAddr != 0xffffffff) |
2695 | { |
2696 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2697 | { |
2698 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2699 | if (psMemWrite->memoryCall) |
2700 | { |
2701 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2702 | } |
2703 | else |
2704 | { |
2705 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
2706 | } |
2707 | psMemWrite = NULL; |
2708 | break; |
2709 | } |
2710 | ++psMemWrite; |
2711 | } |
2712 | |
2713 | if (psMemWrite) |
2714 | { |
2715 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
2716 | } |
2717 | |
2718 | break; |
2719 | } |
2720 | case 0x9f: |
2721 | { |
2722 | sdwCyclesRemaining -= 8; |
2723 | cpu.z80A &= 0xf7; |
2724 | break; |
2725 | } |
2726 | case 0xa0: |
2727 | { |
2728 | sdwCyclesRemaining -= 8; |
2729 | cpu.z80B &= 0xef; |
2730 | break; |
2731 | } |
2732 | case 0xa1: |
2733 | { |
2734 | sdwCyclesRemaining -= 8; |
2735 | cpu.z80C &= 0xef; |
2736 | break; |
2737 | } |
2738 | case 0xa2: |
2739 | { |
2740 | sdwCyclesRemaining -= 8; |
2741 | cpu.z80D &= 0xef; |
2742 | break; |
2743 | } |
2744 | case 0xa3: |
2745 | { |
2746 | sdwCyclesRemaining -= 8; |
2747 | cpu.z80E &= 0xef; |
2748 | break; |
2749 | } |
2750 | case 0xa4: |
2751 | { |
2752 | sdwCyclesRemaining -= 8; |
2753 | cpu.z80H &= 0xef; |
2754 | break; |
2755 | } |
2756 | case 0xa5: |
2757 | { |
2758 | sdwCyclesRemaining -= 8; |
2759 | cpu.z80L &= 0xef; |
2760 | break; |
2761 | } |
2762 | case 0xa6: |
2763 | { |
2764 | sdwCyclesRemaining -= 15; |
2765 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2766 | while (psMemRead->lowAddr != 0xffffffff) |
2767 | { |
2768 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2769 | { |
2770 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2771 | if (psMemRead->memoryCall) |
2772 | { |
2773 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2774 | } |
2775 | else |
2776 | { |
2777 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2778 | } |
2779 | psMemRead = NULL; |
2780 | break; |
2781 | } |
2782 | ++psMemRead; |
2783 | } |
2784 | |
2785 | if (psMemRead) |
2786 | { |
2787 | bTemp = cpu.z80Base[cpu.z80HL]; |
2788 | } |
2789 | |
2790 | bTemp &= 0xef; |
2791 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2792 | while (psMemWrite->lowAddr != 0xffffffff) |
2793 | { |
2794 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2795 | { |
2796 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2797 | if (psMemWrite->memoryCall) |
2798 | { |
2799 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2800 | } |
2801 | else |
2802 | { |
2803 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
2804 | } |
2805 | psMemWrite = NULL; |
2806 | break; |
2807 | } |
2808 | ++psMemWrite; |
2809 | } |
2810 | |
2811 | if (psMemWrite) |
2812 | { |
2813 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
2814 | } |
2815 | |
2816 | break; |
2817 | } |
2818 | case 0xa7: |
2819 | { |
2820 | sdwCyclesRemaining -= 8; |
2821 | cpu.z80A &= 0xef; |
2822 | break; |
2823 | } |
2824 | case 0xa8: |
2825 | { |
2826 | sdwCyclesRemaining -= 8; |
2827 | cpu.z80B &= 0xdf; |
2828 | break; |
2829 | } |
2830 | case 0xa9: |
2831 | { |
2832 | sdwCyclesRemaining -= 8; |
2833 | cpu.z80C &= 0xdf; |
2834 | break; |
2835 | } |
2836 | case 0xaa: |
2837 | { |
2838 | sdwCyclesRemaining -= 8; |
2839 | cpu.z80D &= 0xdf; |
2840 | break; |
2841 | } |
2842 | case 0xab: |
2843 | { |
2844 | sdwCyclesRemaining -= 8; |
2845 | cpu.z80E &= 0xdf; |
2846 | break; |
2847 | } |
2848 | case 0xac: |
2849 | { |
2850 | sdwCyclesRemaining -= 8; |
2851 | cpu.z80H &= 0xdf; |
2852 | break; |
2853 | } |
2854 | case 0xad: |
2855 | { |
2856 | sdwCyclesRemaining -= 8; |
2857 | cpu.z80L &= 0xdf; |
2858 | break; |
2859 | } |
2860 | case 0xae: |
2861 | { |
2862 | sdwCyclesRemaining -= 15; |
2863 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2864 | while (psMemRead->lowAddr != 0xffffffff) |
2865 | { |
2866 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2867 | { |
2868 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2869 | if (psMemRead->memoryCall) |
2870 | { |
2871 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2872 | } |
2873 | else |
2874 | { |
2875 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2876 | } |
2877 | psMemRead = NULL; |
2878 | break; |
2879 | } |
2880 | ++psMemRead; |
2881 | } |
2882 | |
2883 | if (psMemRead) |
2884 | { |
2885 | bTemp = cpu.z80Base[cpu.z80HL]; |
2886 | } |
2887 | |
2888 | bTemp &= 0xdf; |
2889 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2890 | while (psMemWrite->lowAddr != 0xffffffff) |
2891 | { |
2892 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2893 | { |
2894 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2895 | if (psMemWrite->memoryCall) |
2896 | { |
2897 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2898 | } |
2899 | else |
2900 | { |
2901 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
2902 | } |
2903 | psMemWrite = NULL; |
2904 | break; |
2905 | } |
2906 | ++psMemWrite; |
2907 | } |
2908 | |
2909 | if (psMemWrite) |
2910 | { |
2911 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
2912 | } |
2913 | |
2914 | break; |
2915 | } |
2916 | case 0xaf: |
2917 | { |
2918 | sdwCyclesRemaining -= 8; |
2919 | cpu.z80A &= 0xdf; |
2920 | break; |
2921 | } |
2922 | case 0xb0: |
2923 | { |
2924 | sdwCyclesRemaining -= 8; |
2925 | cpu.z80B &= 0xbf; |
2926 | break; |
2927 | } |
2928 | case 0xb1: |
2929 | { |
2930 | sdwCyclesRemaining -= 8; |
2931 | cpu.z80C &= 0xbf; |
2932 | break; |
2933 | } |
2934 | case 0xb2: |
2935 | { |
2936 | sdwCyclesRemaining -= 8; |
2937 | cpu.z80D &= 0xbf; |
2938 | break; |
2939 | } |
2940 | case 0xb3: |
2941 | { |
2942 | sdwCyclesRemaining -= 8; |
2943 | cpu.z80E &= 0xbf; |
2944 | break; |
2945 | } |
2946 | case 0xb4: |
2947 | { |
2948 | sdwCyclesRemaining -= 8; |
2949 | cpu.z80H &= 0xbf; |
2950 | break; |
2951 | } |
2952 | case 0xb5: |
2953 | { |
2954 | sdwCyclesRemaining -= 8; |
2955 | cpu.z80L &= 0xbf; |
2956 | break; |
2957 | } |
2958 | case 0xb6: |
2959 | { |
2960 | sdwCyclesRemaining -= 15; |
2961 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
2962 | while (psMemRead->lowAddr != 0xffffffff) |
2963 | { |
2964 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
2965 | { |
2966 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2967 | if (psMemRead->memoryCall) |
2968 | { |
2969 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
2970 | } |
2971 | else |
2972 | { |
2973 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
2974 | } |
2975 | psMemRead = NULL; |
2976 | break; |
2977 | } |
2978 | ++psMemRead; |
2979 | } |
2980 | |
2981 | if (psMemRead) |
2982 | { |
2983 | bTemp = cpu.z80Base[cpu.z80HL]; |
2984 | } |
2985 | |
2986 | bTemp &= 0xbf; |
2987 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
2988 | while (psMemWrite->lowAddr != 0xffffffff) |
2989 | { |
2990 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
2991 | { |
2992 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
2993 | if (psMemWrite->memoryCall) |
2994 | { |
2995 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
2996 | } |
2997 | else |
2998 | { |
2999 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3000 | } |
3001 | psMemWrite = NULL; |
3002 | break; |
3003 | } |
3004 | ++psMemWrite; |
3005 | } |
3006 | |
3007 | if (psMemWrite) |
3008 | { |
3009 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3010 | } |
3011 | |
3012 | break; |
3013 | } |
3014 | case 0xb7: |
3015 | { |
3016 | sdwCyclesRemaining -= 8; |
3017 | cpu.z80A &= 0xbf; |
3018 | break; |
3019 | } |
3020 | case 0xb8: |
3021 | { |
3022 | sdwCyclesRemaining -= 8; |
3023 | cpu.z80B &= 0x7f; |
3024 | break; |
3025 | } |
3026 | case 0xb9: |
3027 | { |
3028 | sdwCyclesRemaining -= 8; |
3029 | cpu.z80C &= 0x7f; |
3030 | break; |
3031 | } |
3032 | case 0xba: |
3033 | { |
3034 | sdwCyclesRemaining -= 8; |
3035 | cpu.z80D &= 0x7f; |
3036 | break; |
3037 | } |
3038 | case 0xbb: |
3039 | { |
3040 | sdwCyclesRemaining -= 8; |
3041 | cpu.z80E &= 0x7f; |
3042 | break; |
3043 | } |
3044 | case 0xbc: |
3045 | { |
3046 | sdwCyclesRemaining -= 8; |
3047 | cpu.z80H &= 0x7f; |
3048 | break; |
3049 | } |
3050 | case 0xbd: |
3051 | { |
3052 | sdwCyclesRemaining -= 8; |
3053 | cpu.z80L &= 0x7f; |
3054 | break; |
3055 | } |
3056 | case 0xbe: |
3057 | { |
3058 | sdwCyclesRemaining -= 15; |
3059 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3060 | while (psMemRead->lowAddr != 0xffffffff) |
3061 | { |
3062 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3063 | { |
3064 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3065 | if (psMemRead->memoryCall) |
3066 | { |
3067 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3068 | } |
3069 | else |
3070 | { |
3071 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3072 | } |
3073 | psMemRead = NULL; |
3074 | break; |
3075 | } |
3076 | ++psMemRead; |
3077 | } |
3078 | |
3079 | if (psMemRead) |
3080 | { |
3081 | bTemp = cpu.z80Base[cpu.z80HL]; |
3082 | } |
3083 | |
3084 | bTemp &= 0x7f; |
3085 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3086 | while (psMemWrite->lowAddr != 0xffffffff) |
3087 | { |
3088 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3089 | { |
3090 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3091 | if (psMemWrite->memoryCall) |
3092 | { |
3093 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3094 | } |
3095 | else |
3096 | { |
3097 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3098 | } |
3099 | psMemWrite = NULL; |
3100 | break; |
3101 | } |
3102 | ++psMemWrite; |
3103 | } |
3104 | |
3105 | if (psMemWrite) |
3106 | { |
3107 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3108 | } |
3109 | |
3110 | break; |
3111 | } |
3112 | case 0xbf: |
3113 | { |
3114 | sdwCyclesRemaining -= 8; |
3115 | cpu.z80A &= 0x7f; |
3116 | break; |
3117 | } |
3118 | case 0xc0: |
3119 | { |
3120 | sdwCyclesRemaining -= 8; |
3121 | cpu.z80B |= 0x01; |
3122 | break; |
3123 | } |
3124 | case 0xc1: |
3125 | { |
3126 | sdwCyclesRemaining -= 8; |
3127 | cpu.z80C |= 0x01; |
3128 | break; |
3129 | } |
3130 | case 0xc2: |
3131 | { |
3132 | sdwCyclesRemaining -= 8; |
3133 | cpu.z80D |= 0x01; |
3134 | break; |
3135 | } |
3136 | case 0xc3: |
3137 | { |
3138 | sdwCyclesRemaining -= 8; |
3139 | cpu.z80E |= 0x01; |
3140 | break; |
3141 | } |
3142 | case 0xc4: |
3143 | { |
3144 | sdwCyclesRemaining -= 8; |
3145 | cpu.z80H |= 0x01; |
3146 | break; |
3147 | } |
3148 | case 0xc5: |
3149 | { |
3150 | sdwCyclesRemaining -= 8; |
3151 | cpu.z80L |= 0x01; |
3152 | break; |
3153 | } |
3154 | case 0xc6: |
3155 | { |
3156 | sdwCyclesRemaining -= 15; |
3157 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3158 | while (psMemRead->lowAddr != 0xffffffff) |
3159 | { |
3160 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3161 | { |
3162 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3163 | if (psMemRead->memoryCall) |
3164 | { |
3165 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3166 | } |
3167 | else |
3168 | { |
3169 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3170 | } |
3171 | psMemRead = NULL; |
3172 | break; |
3173 | } |
3174 | ++psMemRead; |
3175 | } |
3176 | |
3177 | if (psMemRead) |
3178 | { |
3179 | bTemp = cpu.z80Base[cpu.z80HL]; |
3180 | } |
3181 | |
3182 | bTemp |= 0x01; |
3183 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3184 | while (psMemWrite->lowAddr != 0xffffffff) |
3185 | { |
3186 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3187 | { |
3188 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3189 | if (psMemWrite->memoryCall) |
3190 | { |
3191 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3192 | } |
3193 | else |
3194 | { |
3195 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3196 | } |
3197 | psMemWrite = NULL; |
3198 | break; |
3199 | } |
3200 | ++psMemWrite; |
3201 | } |
3202 | |
3203 | if (psMemWrite) |
3204 | { |
3205 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3206 | } |
3207 | |
3208 | break; |
3209 | } |
3210 | case 0xc7: |
3211 | { |
3212 | sdwCyclesRemaining -= 8; |
3213 | cpu.z80A |= 0x01; |
3214 | break; |
3215 | } |
3216 | case 0xc8: |
3217 | { |
3218 | sdwCyclesRemaining -= 8; |
3219 | cpu.z80B |= 0x02; |
3220 | break; |
3221 | } |
3222 | case 0xc9: |
3223 | { |
3224 | sdwCyclesRemaining -= 8; |
3225 | cpu.z80C |= 0x02; |
3226 | break; |
3227 | } |
3228 | case 0xca: |
3229 | { |
3230 | sdwCyclesRemaining -= 8; |
3231 | cpu.z80D |= 0x02; |
3232 | break; |
3233 | } |
3234 | case 0xcb: |
3235 | { |
3236 | sdwCyclesRemaining -= 8; |
3237 | cpu.z80E |= 0x02; |
3238 | break; |
3239 | } |
3240 | case 0xcc: |
3241 | { |
3242 | sdwCyclesRemaining -= 8; |
3243 | cpu.z80H |= 0x02; |
3244 | break; |
3245 | } |
3246 | case 0xcd: |
3247 | { |
3248 | sdwCyclesRemaining -= 8; |
3249 | cpu.z80L |= 0x02; |
3250 | break; |
3251 | } |
3252 | case 0xce: |
3253 | { |
3254 | sdwCyclesRemaining -= 15; |
3255 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3256 | while (psMemRead->lowAddr != 0xffffffff) |
3257 | { |
3258 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3259 | { |
3260 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3261 | if (psMemRead->memoryCall) |
3262 | { |
3263 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3264 | } |
3265 | else |
3266 | { |
3267 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3268 | } |
3269 | psMemRead = NULL; |
3270 | break; |
3271 | } |
3272 | ++psMemRead; |
3273 | } |
3274 | |
3275 | if (psMemRead) |
3276 | { |
3277 | bTemp = cpu.z80Base[cpu.z80HL]; |
3278 | } |
3279 | |
3280 | bTemp |= 0x02; |
3281 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3282 | while (psMemWrite->lowAddr != 0xffffffff) |
3283 | { |
3284 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3285 | { |
3286 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3287 | if (psMemWrite->memoryCall) |
3288 | { |
3289 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3290 | } |
3291 | else |
3292 | { |
3293 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3294 | } |
3295 | psMemWrite = NULL; |
3296 | break; |
3297 | } |
3298 | ++psMemWrite; |
3299 | } |
3300 | |
3301 | if (psMemWrite) |
3302 | { |
3303 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3304 | } |
3305 | |
3306 | break; |
3307 | } |
3308 | case 0xcf: |
3309 | { |
3310 | sdwCyclesRemaining -= 8; |
3311 | cpu.z80A |= 0x02; |
3312 | break; |
3313 | } |
3314 | case 0xd0: |
3315 | { |
3316 | sdwCyclesRemaining -= 8; |
3317 | cpu.z80B |= 0x04; |
3318 | break; |
3319 | } |
3320 | case 0xd1: |
3321 | { |
3322 | sdwCyclesRemaining -= 8; |
3323 | cpu.z80C |= 0x04; |
3324 | break; |
3325 | } |
3326 | case 0xd2: |
3327 | { |
3328 | sdwCyclesRemaining -= 8; |
3329 | cpu.z80D |= 0x04; |
3330 | break; |
3331 | } |
3332 | case 0xd3: |
3333 | { |
3334 | sdwCyclesRemaining -= 8; |
3335 | cpu.z80E |= 0x04; |
3336 | break; |
3337 | } |
3338 | case 0xd4: |
3339 | { |
3340 | sdwCyclesRemaining -= 8; |
3341 | cpu.z80H |= 0x04; |
3342 | break; |
3343 | } |
3344 | case 0xd5: |
3345 | { |
3346 | sdwCyclesRemaining -= 8; |
3347 | cpu.z80L |= 0x04; |
3348 | break; |
3349 | } |
3350 | case 0xd6: |
3351 | { |
3352 | sdwCyclesRemaining -= 15; |
3353 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3354 | while (psMemRead->lowAddr != 0xffffffff) |
3355 | { |
3356 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3357 | { |
3358 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3359 | if (psMemRead->memoryCall) |
3360 | { |
3361 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3362 | } |
3363 | else |
3364 | { |
3365 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3366 | } |
3367 | psMemRead = NULL; |
3368 | break; |
3369 | } |
3370 | ++psMemRead; |
3371 | } |
3372 | |
3373 | if (psMemRead) |
3374 | { |
3375 | bTemp = cpu.z80Base[cpu.z80HL]; |
3376 | } |
3377 | |
3378 | bTemp |= 0x04; |
3379 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3380 | while (psMemWrite->lowAddr != 0xffffffff) |
3381 | { |
3382 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3383 | { |
3384 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3385 | if (psMemWrite->memoryCall) |
3386 | { |
3387 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3388 | } |
3389 | else |
3390 | { |
3391 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3392 | } |
3393 | psMemWrite = NULL; |
3394 | break; |
3395 | } |
3396 | ++psMemWrite; |
3397 | } |
3398 | |
3399 | if (psMemWrite) |
3400 | { |
3401 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3402 | } |
3403 | |
3404 | break; |
3405 | } |
3406 | case 0xd7: |
3407 | { |
3408 | sdwCyclesRemaining -= 8; |
3409 | cpu.z80A |= 0x04; |
3410 | break; |
3411 | } |
3412 | case 0xd8: |
3413 | { |
3414 | sdwCyclesRemaining -= 8; |
3415 | cpu.z80B |= 0x08; |
3416 | break; |
3417 | } |
3418 | case 0xd9: |
3419 | { |
3420 | sdwCyclesRemaining -= 8; |
3421 | cpu.z80C |= 0x08; |
3422 | break; |
3423 | } |
3424 | case 0xda: |
3425 | { |
3426 | sdwCyclesRemaining -= 8; |
3427 | cpu.z80D |= 0x08; |
3428 | break; |
3429 | } |
3430 | case 0xdb: |
3431 | { |
3432 | sdwCyclesRemaining -= 8; |
3433 | cpu.z80E |= 0x08; |
3434 | break; |
3435 | } |
3436 | case 0xdc: |
3437 | { |
3438 | sdwCyclesRemaining -= 8; |
3439 | cpu.z80H |= 0x08; |
3440 | break; |
3441 | } |
3442 | case 0xdd: |
3443 | { |
3444 | sdwCyclesRemaining -= 8; |
3445 | cpu.z80L |= 0x08; |
3446 | break; |
3447 | } |
3448 | case 0xde: |
3449 | { |
3450 | sdwCyclesRemaining -= 15; |
3451 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3452 | while (psMemRead->lowAddr != 0xffffffff) |
3453 | { |
3454 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3455 | { |
3456 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3457 | if (psMemRead->memoryCall) |
3458 | { |
3459 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3460 | } |
3461 | else |
3462 | { |
3463 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3464 | } |
3465 | psMemRead = NULL; |
3466 | break; |
3467 | } |
3468 | ++psMemRead; |
3469 | } |
3470 | |
3471 | if (psMemRead) |
3472 | { |
3473 | bTemp = cpu.z80Base[cpu.z80HL]; |
3474 | } |
3475 | |
3476 | bTemp |= 0x08; |
3477 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3478 | while (psMemWrite->lowAddr != 0xffffffff) |
3479 | { |
3480 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3481 | { |
3482 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3483 | if (psMemWrite->memoryCall) |
3484 | { |
3485 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3486 | } |
3487 | else |
3488 | { |
3489 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3490 | } |
3491 | psMemWrite = NULL; |
3492 | break; |
3493 | } |
3494 | ++psMemWrite; |
3495 | } |
3496 | |
3497 | if (psMemWrite) |
3498 | { |
3499 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3500 | } |
3501 | |
3502 | break; |
3503 | } |
3504 | case 0xdf: |
3505 | { |
3506 | sdwCyclesRemaining -= 8; |
3507 | cpu.z80A |= 0x08; |
3508 | break; |
3509 | } |
3510 | case 0xe0: |
3511 | { |
3512 | sdwCyclesRemaining -= 8; |
3513 | cpu.z80B |= 0x10; |
3514 | break; |
3515 | } |
3516 | case 0xe1: |
3517 | { |
3518 | sdwCyclesRemaining -= 8; |
3519 | cpu.z80C |= 0x10; |
3520 | break; |
3521 | } |
3522 | case 0xe2: |
3523 | { |
3524 | sdwCyclesRemaining -= 8; |
3525 | cpu.z80D |= 0x10; |
3526 | break; |
3527 | } |
3528 | case 0xe3: |
3529 | { |
3530 | sdwCyclesRemaining -= 8; |
3531 | cpu.z80E |= 0x10; |
3532 | break; |
3533 | } |
3534 | case 0xe4: |
3535 | { |
3536 | sdwCyclesRemaining -= 8; |
3537 | cpu.z80H |= 0x10; |
3538 | break; |
3539 | } |
3540 | case 0xe5: |
3541 | { |
3542 | sdwCyclesRemaining -= 8; |
3543 | cpu.z80L |= 0x10; |
3544 | break; |
3545 | } |
3546 | case 0xe6: |
3547 | { |
3548 | sdwCyclesRemaining -= 15; |
3549 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3550 | while (psMemRead->lowAddr != 0xffffffff) |
3551 | { |
3552 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3553 | { |
3554 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3555 | if (psMemRead->memoryCall) |
3556 | { |
3557 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3558 | } |
3559 | else |
3560 | { |
3561 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3562 | } |
3563 | psMemRead = NULL; |
3564 | break; |
3565 | } |
3566 | ++psMemRead; |
3567 | } |
3568 | |
3569 | if (psMemRead) |
3570 | { |
3571 | bTemp = cpu.z80Base[cpu.z80HL]; |
3572 | } |
3573 | |
3574 | bTemp |= 0x10; |
3575 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3576 | while (psMemWrite->lowAddr != 0xffffffff) |
3577 | { |
3578 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3579 | { |
3580 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3581 | if (psMemWrite->memoryCall) |
3582 | { |
3583 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3584 | } |
3585 | else |
3586 | { |
3587 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3588 | } |
3589 | psMemWrite = NULL; |
3590 | break; |
3591 | } |
3592 | ++psMemWrite; |
3593 | } |
3594 | |
3595 | if (psMemWrite) |
3596 | { |
3597 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3598 | } |
3599 | |
3600 | break; |
3601 | } |
3602 | case 0xe7: |
3603 | { |
3604 | sdwCyclesRemaining -= 8; |
3605 | cpu.z80A |= 0x10; |
3606 | break; |
3607 | } |
3608 | case 0xe8: |
3609 | { |
3610 | sdwCyclesRemaining -= 8; |
3611 | cpu.z80B |= 0x20; |
3612 | break; |
3613 | } |
3614 | case 0xe9: |
3615 | { |
3616 | sdwCyclesRemaining -= 8; |
3617 | cpu.z80C |= 0x20; |
3618 | break; |
3619 | } |
3620 | case 0xea: |
3621 | { |
3622 | sdwCyclesRemaining -= 8; |
3623 | cpu.z80D |= 0x20; |
3624 | break; |
3625 | } |
3626 | case 0xeb: |
3627 | { |
3628 | sdwCyclesRemaining -= 8; |
3629 | cpu.z80E |= 0x20; |
3630 | break; |
3631 | } |
3632 | case 0xec: |
3633 | { |
3634 | sdwCyclesRemaining -= 8; |
3635 | cpu.z80H |= 0x20; |
3636 | break; |
3637 | } |
3638 | case 0xed: |
3639 | { |
3640 | sdwCyclesRemaining -= 8; |
3641 | cpu.z80L |= 0x20; |
3642 | break; |
3643 | } |
3644 | case 0xee: |
3645 | { |
3646 | sdwCyclesRemaining -= 15; |
3647 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3648 | while (psMemRead->lowAddr != 0xffffffff) |
3649 | { |
3650 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3651 | { |
3652 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3653 | if (psMemRead->memoryCall) |
3654 | { |
3655 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3656 | } |
3657 | else |
3658 | { |
3659 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3660 | } |
3661 | psMemRead = NULL; |
3662 | break; |
3663 | } |
3664 | ++psMemRead; |
3665 | } |
3666 | |
3667 | if (psMemRead) |
3668 | { |
3669 | bTemp = cpu.z80Base[cpu.z80HL]; |
3670 | } |
3671 | |
3672 | bTemp |= 0x20; |
3673 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3674 | while (psMemWrite->lowAddr != 0xffffffff) |
3675 | { |
3676 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3677 | { |
3678 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3679 | if (psMemWrite->memoryCall) |
3680 | { |
3681 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3682 | } |
3683 | else |
3684 | { |
3685 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3686 | } |
3687 | psMemWrite = NULL; |
3688 | break; |
3689 | } |
3690 | ++psMemWrite; |
3691 | } |
3692 | |
3693 | if (psMemWrite) |
3694 | { |
3695 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3696 | } |
3697 | |
3698 | break; |
3699 | } |
3700 | case 0xef: |
3701 | { |
3702 | sdwCyclesRemaining -= 8; |
3703 | cpu.z80A |= 0x20; |
3704 | break; |
3705 | } |
3706 | case 0xf0: |
3707 | { |
3708 | sdwCyclesRemaining -= 8; |
3709 | cpu.z80B |= 0x40; |
3710 | break; |
3711 | } |
3712 | case 0xf1: |
3713 | { |
3714 | sdwCyclesRemaining -= 8; |
3715 | cpu.z80C |= 0x40; |
3716 | break; |
3717 | } |
3718 | case 0xf2: |
3719 | { |
3720 | sdwCyclesRemaining -= 8; |
3721 | cpu.z80D |= 0x40; |
3722 | break; |
3723 | } |
3724 | case 0xf3: |
3725 | { |
3726 | sdwCyclesRemaining -= 8; |
3727 | cpu.z80E |= 0x40; |
3728 | break; |
3729 | } |
3730 | case 0xf4: |
3731 | { |
3732 | sdwCyclesRemaining -= 8; |
3733 | cpu.z80H |= 0x40; |
3734 | break; |
3735 | } |
3736 | case 0xf5: |
3737 | { |
3738 | sdwCyclesRemaining -= 8; |
3739 | cpu.z80L |= 0x40; |
3740 | break; |
3741 | } |
3742 | case 0xf6: |
3743 | { |
3744 | sdwCyclesRemaining -= 15; |
3745 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3746 | while (psMemRead->lowAddr != 0xffffffff) |
3747 | { |
3748 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3749 | { |
3750 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3751 | if (psMemRead->memoryCall) |
3752 | { |
3753 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3754 | } |
3755 | else |
3756 | { |
3757 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3758 | } |
3759 | psMemRead = NULL; |
3760 | break; |
3761 | } |
3762 | ++psMemRead; |
3763 | } |
3764 | |
3765 | if (psMemRead) |
3766 | { |
3767 | bTemp = cpu.z80Base[cpu.z80HL]; |
3768 | } |
3769 | |
3770 | bTemp |= 0x40; |
3771 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3772 | while (psMemWrite->lowAddr != 0xffffffff) |
3773 | { |
3774 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3775 | { |
3776 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3777 | if (psMemWrite->memoryCall) |
3778 | { |
3779 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3780 | } |
3781 | else |
3782 | { |
3783 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3784 | } |
3785 | psMemWrite = NULL; |
3786 | break; |
3787 | } |
3788 | ++psMemWrite; |
3789 | } |
3790 | |
3791 | if (psMemWrite) |
3792 | { |
3793 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3794 | } |
3795 | |
3796 | break; |
3797 | } |
3798 | case 0xf7: |
3799 | { |
3800 | sdwCyclesRemaining -= 8; |
3801 | cpu.z80A |= 0x40; |
3802 | break; |
3803 | } |
3804 | case 0xf8: |
3805 | { |
3806 | sdwCyclesRemaining -= 8; |
3807 | cpu.z80B |= 0x80; |
3808 | break; |
3809 | } |
3810 | case 0xf9: |
3811 | { |
3812 | sdwCyclesRemaining -= 8; |
3813 | cpu.z80C |= 0x80; |
3814 | break; |
3815 | } |
3816 | case 0xfa: |
3817 | { |
3818 | sdwCyclesRemaining -= 8; |
3819 | cpu.z80D |= 0x80; |
3820 | break; |
3821 | } |
3822 | case 0xfb: |
3823 | { |
3824 | sdwCyclesRemaining -= 8; |
3825 | cpu.z80E |= 0x80; |
3826 | break; |
3827 | } |
3828 | case 0xfc: |
3829 | { |
3830 | sdwCyclesRemaining -= 8; |
3831 | cpu.z80H |= 0x80; |
3832 | break; |
3833 | } |
3834 | case 0xfd: |
3835 | { |
3836 | sdwCyclesRemaining -= 8; |
3837 | cpu.z80L |= 0x80; |
3838 | break; |
3839 | } |
3840 | case 0xfe: |
3841 | { |
3842 | sdwCyclesRemaining -= 15; |
3843 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
3844 | while (psMemRead->lowAddr != 0xffffffff) |
3845 | { |
3846 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
3847 | { |
3848 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3849 | if (psMemRead->memoryCall) |
3850 | { |
3851 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
3852 | } |
3853 | else |
3854 | { |
3855 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
3856 | } |
3857 | psMemRead = NULL; |
3858 | break; |
3859 | } |
3860 | ++psMemRead; |
3861 | } |
3862 | |
3863 | if (psMemRead) |
3864 | { |
3865 | bTemp = cpu.z80Base[cpu.z80HL]; |
3866 | } |
3867 | |
3868 | bTemp |= 0x80; |
3869 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
3870 | while (psMemWrite->lowAddr != 0xffffffff) |
3871 | { |
3872 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
3873 | { |
3874 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
3875 | if (psMemWrite->memoryCall) |
3876 | { |
3877 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
3878 | } |
3879 | else |
3880 | { |
3881 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
3882 | } |
3883 | psMemWrite = NULL; |
3884 | break; |
3885 | } |
3886 | ++psMemWrite; |
3887 | } |
3888 | |
3889 | if (psMemWrite) |
3890 | { |
3891 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
3892 | } |
3893 | |
3894 | break; |
3895 | } |
3896 | case 0xff: |
3897 | { |
3898 | sdwCyclesRemaining -= 8; |
3899 | cpu.z80A |= 0x80; |
3900 | break; |
3901 | } |
3902 | } |
3903 | } |
3904 | void EDHandler(void) |
3905 | { |
3906 | switch (*pbPC++) |
3907 | { |
3908 | case 0x00: |
3909 | { |
3910 | InvalidInstruction(2); |
3911 | break; |
3912 | } |
3913 | case 0x01: |
3914 | { |
3915 | InvalidInstruction(2); |
3916 | break; |
3917 | } |
3918 | case 0x02: |
3919 | { |
3920 | InvalidInstruction(2); |
3921 | break; |
3922 | } |
3923 | case 0x03: |
3924 | { |
3925 | InvalidInstruction(2); |
3926 | break; |
3927 | } |
3928 | case 0x04: |
3929 | { |
3930 | InvalidInstruction(2); |
3931 | break; |
3932 | } |
3933 | case 0x05: |
3934 | { |
3935 | InvalidInstruction(2); |
3936 | break; |
3937 | } |
3938 | case 0x06: |
3939 | { |
3940 | InvalidInstruction(2); |
3941 | break; |
3942 | } |
3943 | case 0x07: |
3944 | { |
3945 | InvalidInstruction(2); |
3946 | break; |
3947 | } |
3948 | case 0x08: |
3949 | { |
3950 | InvalidInstruction(2); |
3951 | break; |
3952 | } |
3953 | case 0x09: |
3954 | { |
3955 | InvalidInstruction(2); |
3956 | break; |
3957 | } |
3958 | case 0x0a: |
3959 | { |
3960 | InvalidInstruction(2); |
3961 | break; |
3962 | } |
3963 | case 0x0b: |
3964 | { |
3965 | InvalidInstruction(2); |
3966 | break; |
3967 | } |
3968 | case 0x0c: |
3969 | { |
3970 | InvalidInstruction(2); |
3971 | break; |
3972 | } |
3973 | case 0x0d: |
3974 | { |
3975 | InvalidInstruction(2); |
3976 | break; |
3977 | } |
3978 | case 0x0e: |
3979 | { |
3980 | InvalidInstruction(2); |
3981 | break; |
3982 | } |
3983 | case 0x0f: |
3984 | { |
3985 | InvalidInstruction(2); |
3986 | break; |
3987 | } |
3988 | case 0x10: |
3989 | { |
3990 | InvalidInstruction(2); |
3991 | break; |
3992 | } |
3993 | case 0x11: |
3994 | { |
3995 | InvalidInstruction(2); |
3996 | break; |
3997 | } |
3998 | case 0x12: |
3999 | { |
4000 | InvalidInstruction(2); |
4001 | break; |
4002 | } |
4003 | case 0x13: |
4004 | { |
4005 | InvalidInstruction(2); |
4006 | break; |
4007 | } |
4008 | case 0x14: |
4009 | { |
4010 | InvalidInstruction(2); |
4011 | break; |
4012 | } |
4013 | case 0x15: |
4014 | { |
4015 | InvalidInstruction(2); |
4016 | break; |
4017 | } |
4018 | case 0x16: |
4019 | { |
4020 | InvalidInstruction(2); |
4021 | break; |
4022 | } |
4023 | case 0x17: |
4024 | { |
4025 | InvalidInstruction(2); |
4026 | break; |
4027 | } |
4028 | case 0x18: |
4029 | { |
4030 | InvalidInstruction(2); |
4031 | break; |
4032 | } |
4033 | case 0x19: |
4034 | { |
4035 | InvalidInstruction(2); |
4036 | break; |
4037 | } |
4038 | case 0x1a: |
4039 | { |
4040 | InvalidInstruction(2); |
4041 | break; |
4042 | } |
4043 | case 0x1b: |
4044 | { |
4045 | InvalidInstruction(2); |
4046 | break; |
4047 | } |
4048 | case 0x1c: |
4049 | { |
4050 | InvalidInstruction(2); |
4051 | break; |
4052 | } |
4053 | case 0x1d: |
4054 | { |
4055 | InvalidInstruction(2); |
4056 | break; |
4057 | } |
4058 | case 0x1e: |
4059 | { |
4060 | InvalidInstruction(2); |
4061 | break; |
4062 | } |
4063 | case 0x1f: |
4064 | { |
4065 | InvalidInstruction(2); |
4066 | break; |
4067 | } |
4068 | case 0x20: |
4069 | { |
4070 | InvalidInstruction(2); |
4071 | break; |
4072 | } |
4073 | case 0x21: |
4074 | { |
4075 | InvalidInstruction(2); |
4076 | break; |
4077 | } |
4078 | case 0x22: |
4079 | { |
4080 | InvalidInstruction(2); |
4081 | break; |
4082 | } |
4083 | case 0x23: |
4084 | { |
4085 | InvalidInstruction(2); |
4086 | break; |
4087 | } |
4088 | case 0x24: |
4089 | { |
4090 | InvalidInstruction(2); |
4091 | break; |
4092 | } |
4093 | case 0x25: |
4094 | { |
4095 | InvalidInstruction(2); |
4096 | break; |
4097 | } |
4098 | case 0x26: |
4099 | { |
4100 | InvalidInstruction(2); |
4101 | break; |
4102 | } |
4103 | case 0x27: |
4104 | { |
4105 | InvalidInstruction(2); |
4106 | break; |
4107 | } |
4108 | case 0x28: |
4109 | { |
4110 | InvalidInstruction(2); |
4111 | break; |
4112 | } |
4113 | case 0x29: |
4114 | { |
4115 | InvalidInstruction(2); |
4116 | break; |
4117 | } |
4118 | case 0x2a: |
4119 | { |
4120 | InvalidInstruction(2); |
4121 | break; |
4122 | } |
4123 | case 0x2b: |
4124 | { |
4125 | InvalidInstruction(2); |
4126 | break; |
4127 | } |
4128 | case 0x2c: |
4129 | { |
4130 | InvalidInstruction(2); |
4131 | break; |
4132 | } |
4133 | case 0x2d: |
4134 | { |
4135 | InvalidInstruction(2); |
4136 | break; |
4137 | } |
4138 | case 0x2e: |
4139 | { |
4140 | InvalidInstruction(2); |
4141 | break; |
4142 | } |
4143 | case 0x2f: |
4144 | { |
4145 | InvalidInstruction(2); |
4146 | break; |
4147 | } |
4148 | case 0x30: |
4149 | { |
4150 | InvalidInstruction(2); |
4151 | break; |
4152 | } |
4153 | case 0x31: |
4154 | { |
4155 | InvalidInstruction(2); |
4156 | break; |
4157 | } |
4158 | case 0x32: |
4159 | { |
4160 | InvalidInstruction(2); |
4161 | break; |
4162 | } |
4163 | case 0x33: |
4164 | { |
4165 | InvalidInstruction(2); |
4166 | break; |
4167 | } |
4168 | case 0x34: |
4169 | { |
4170 | InvalidInstruction(2); |
4171 | break; |
4172 | } |
4173 | case 0x35: |
4174 | { |
4175 | InvalidInstruction(2); |
4176 | break; |
4177 | } |
4178 | case 0x36: |
4179 | { |
4180 | InvalidInstruction(2); |
4181 | break; |
4182 | } |
4183 | case 0x37: |
4184 | { |
4185 | InvalidInstruction(2); |
4186 | break; |
4187 | } |
4188 | case 0x38: |
4189 | { |
4190 | InvalidInstruction(2); |
4191 | break; |
4192 | } |
4193 | case 0x39: |
4194 | { |
4195 | InvalidInstruction(2); |
4196 | break; |
4197 | } |
4198 | case 0x3a: |
4199 | { |
4200 | InvalidInstruction(2); |
4201 | break; |
4202 | } |
4203 | case 0x3b: |
4204 | { |
4205 | InvalidInstruction(2); |
4206 | break; |
4207 | } |
4208 | case 0x3c: |
4209 | { |
4210 | InvalidInstruction(2); |
4211 | break; |
4212 | } |
4213 | case 0x3d: |
4214 | { |
4215 | InvalidInstruction(2); |
4216 | break; |
4217 | } |
4218 | case 0x3e: |
4219 | { |
4220 | InvalidInstruction(2); |
4221 | break; |
4222 | } |
4223 | case 0x3f: |
4224 | { |
4225 | InvalidInstruction(2); |
4226 | break; |
4227 | } |
4228 | case 0x40: |
4229 | { |
4230 | sdwCyclesRemaining -= 12; |
4231 | dwAddr = cpu.z80C; |
4232 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
4233 | while (psIoRead->lowIoAddr != 0xffff) |
4234 | { |
4235 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
4236 | { |
4237 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4238 | cpu.z80B = psIoRead->IOCall(dwAddr, psIoRead); |
4239 | psIoRead = NULL; |
4240 | break; |
4241 | } |
4242 | ++psIoRead; |
4243 | } |
4244 | |
4245 | if (psIoRead) |
4246 | { |
4247 | cpu.z80B = 0xff; /* Unclaimed I/O read */ |
4248 | } |
4249 | |
4250 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4251 | cpu.z80F |= bPostORFlags[cpu.z80B]; |
4252 | break; |
4253 | } |
4254 | case 0x41: |
4255 | { |
4256 | sdwCyclesRemaining -= 12; |
4257 | dwAddr = cpu.z80C; |
4258 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
4259 | while (psIoWrite->lowIoAddr != 0xffff) |
4260 | { |
4261 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
4262 | { |
4263 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4264 | psIoWrite->IOCall(dwAddr, cpu.z80B, psIoWrite); |
4265 | psIoWrite = NULL; |
4266 | break; |
4267 | } |
4268 | ++psIoWrite; |
4269 | } |
4270 | |
4271 | break; |
4272 | } |
4273 | case 0x42: |
4274 | { |
4275 | sdwCyclesRemaining -= 15; |
4276 | dwTemp = cpu.z80HL - cpu.z80BC - (cpu.z80F & Z80_FLAG_CARRY); |
4277 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4278 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
4279 | if (0 == (dwTemp & 0xffff)) |
4280 | { |
4281 | cpu.z80F |= Z80_FLAG_ZERO; |
4282 | } |
4283 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY); |
4284 | cpu.z80F |= ((((cpu.z80BC ^ cpu.z80HL) & (cpu.z80BC ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
4285 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
4286 | cpu.z80HL = dwTemp & 0xffff; |
4287 | break; |
4288 | } |
4289 | case 0x43: |
4290 | { |
4291 | sdwCyclesRemaining -= 20; |
4292 | dwTemp = *pbPC++; |
4293 | dwTemp |= ((UINT32) *pbPC++ << 8); |
4294 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
4295 | while (psMemWrite->lowAddr != 0xffffffff) |
4296 | { |
4297 | if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr)) |
4298 | { |
4299 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4300 | if (psMemWrite->memoryCall) |
4301 | { |
4302 | psMemWrite->memoryCall(dwTemp, (cpu.z80BC & 0xff), psMemWrite); |
4303 | psMemWrite->memoryCall(dwTemp + 1, (cpu.z80BC >> 8), psMemWrite); |
4304 | } |
4305 | else |
4306 | { |
4307 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80BC; |
4308 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80BC >> 8; |
4309 | } |
4310 | psMemWrite = NULL; |
4311 | break; |
4312 | } |
4313 | ++psMemWrite; |
4314 | } |
4315 | |
4316 | if (psMemWrite) |
4317 | { |
4318 | cpu.z80Base[dwTemp] = (UINT8) cpu.z80BC; |
4319 | cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80BC >> 8); |
4320 | } |
4321 | |
4322 | break; |
4323 | } |
4324 | case 0x44: |
4325 | { |
4326 | sdwCyclesRemaining -= 8; |
4327 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
4328 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
4329 | pbSubSbcTable[((UINT32) 0 << 8) | cpu.z80A]; |
4330 | cpu.z80A = 0 - cpu.z80A; |
4331 | break; |
4332 | } |
4333 | case 0x45: |
4334 | { |
4335 | sdwCyclesRemaining -= 14; |
4336 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
4337 | dwAddr = *pbSP++; /* Pop LSB */ |
4338 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
4339 | cpu.z80sp += 2; /* Pop the word off */ |
4340 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
4341 | cpu.z80iff &= ~(IFF1); /* Keep IFF2 around */ |
4342 | cpu.z80iff |= ((cpu.z80iff >> 1) & IFF1); /* IFF2->IFF1 */ |
4343 | break; |
4344 | } |
4345 | case 0x46: |
4346 | { |
4347 | sdwCyclesRemaining -= 8; |
4348 | cpu.z80interruptMode = 0; |
4349 | break; |
4350 | } |
4351 | case 0x47: |
4352 | { |
4353 | sdwCyclesRemaining -= 9; |
4354 | cpu.z80i = cpu.z80A; |
4355 | break; |
4356 | } |
4357 | case 0x48: |
4358 | { |
4359 | sdwCyclesRemaining -= 12; |
4360 | dwAddr = cpu.z80C; |
4361 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
4362 | while (psIoRead->lowIoAddr != 0xffff) |
4363 | { |
4364 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
4365 | { |
4366 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4367 | cpu.z80C = psIoRead->IOCall(dwAddr, psIoRead); |
4368 | psIoRead = NULL; |
4369 | break; |
4370 | } |
4371 | ++psIoRead; |
4372 | } |
4373 | |
4374 | if (psIoRead) |
4375 | { |
4376 | cpu.z80C = 0xff; /* Unclaimed I/O read */ |
4377 | } |
4378 | |
4379 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4380 | cpu.z80F |= bPostORFlags[cpu.z80C]; |
4381 | break; |
4382 | } |
4383 | case 0x49: |
4384 | { |
4385 | sdwCyclesRemaining -= 12; |
4386 | dwAddr = cpu.z80C; |
4387 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
4388 | while (psIoWrite->lowIoAddr != 0xffff) |
4389 | { |
4390 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
4391 | { |
4392 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4393 | psIoWrite->IOCall(dwAddr, cpu.z80C, psIoWrite); |
4394 | psIoWrite = NULL; |
4395 | break; |
4396 | } |
4397 | ++psIoWrite; |
4398 | } |
4399 | |
4400 | break; |
4401 | } |
4402 | case 0x4a: |
4403 | { |
4404 | sdwCyclesRemaining -= 15; |
4405 | dwTemp = cpu.z80HL + cpu.z80BC + (cpu.z80F & Z80_FLAG_CARRY); |
4406 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4407 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
4408 | if (0 == (dwTemp & 0xffff)) |
4409 | { |
4410 | cpu.z80F |= Z80_FLAG_ZERO; |
4411 | } |
4412 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY); |
4413 | cpu.z80F |= ((((cpu.z80BC ^ cpu.z80HL ^ 0x8000) & (cpu.z80BC ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
4414 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
4415 | cpu.z80HL = dwTemp & 0xffff; |
4416 | break; |
4417 | } |
4418 | case 0x4b: |
4419 | { |
4420 | sdwCyclesRemaining -= 20; |
4421 | dwTemp = *pbPC++; |
4422 | dwTemp |= ((UINT32) *pbPC++ << 8); |
4423 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
4424 | while (psMemRead->lowAddr != 0xffffffff) |
4425 | { |
4426 | if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr)) |
4427 | { |
4428 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4429 | if (psMemRead->memoryCall) |
4430 | { |
4431 | cpu.z80BC = psMemRead->memoryCall(dwTemp, psMemRead); |
4432 | cpu.z80BC |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8); |
4433 | } |
4434 | else |
4435 | { |
4436 | cpu.z80BC = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr)); |
4437 | cpu.z80BC |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8); |
4438 | } |
4439 | psMemRead = NULL; |
4440 | break; |
4441 | } |
4442 | ++psMemRead; |
4443 | } |
4444 | |
4445 | if (psMemRead) |
4446 | { |
4447 | cpu.z80BC = cpu.z80Base[dwTemp]; |
4448 | cpu.z80BC |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8); |
4449 | } |
4450 | |
4451 | break; |
4452 | } |
4453 | case 0x4c: |
4454 | { |
4455 | sdwCyclesRemaining -= 8; |
4456 | InvalidInstruction(2); |
4457 | break; |
4458 | } |
4459 | case 0x4d: |
4460 | { |
4461 | sdwCyclesRemaining -= 14; |
4462 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
4463 | dwAddr = *pbSP++; /* Pop LSB */ |
4464 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
4465 | cpu.z80sp += 2; /* Pop the word off */ |
4466 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
4467 | break; |
4468 | } |
4469 | case 0x4e: |
4470 | { |
4471 | sdwCyclesRemaining -= 8; |
4472 | InvalidInstruction(2); |
4473 | break; |
4474 | } |
4475 | case 0x4f: |
4476 | { |
4477 | sdwCyclesRemaining -= 9; |
4478 | cpu.z80r = cpu.z80A; |
4479 | break; |
4480 | } |
4481 | case 0x50: |
4482 | { |
4483 | sdwCyclesRemaining -= 12; |
4484 | dwAddr = cpu.z80C; |
4485 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
4486 | while (psIoRead->lowIoAddr != 0xffff) |
4487 | { |
4488 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
4489 | { |
4490 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4491 | cpu.z80D = psIoRead->IOCall(dwAddr, psIoRead); |
4492 | psIoRead = NULL; |
4493 | break; |
4494 | } |
4495 | ++psIoRead; |
4496 | } |
4497 | |
4498 | if (psIoRead) |
4499 | { |
4500 | cpu.z80D = 0xff; /* Unclaimed I/O read */ |
4501 | } |
4502 | |
4503 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4504 | cpu.z80F |= bPostORFlags[cpu.z80D]; |
4505 | break; |
4506 | } |
4507 | case 0x51: |
4508 | { |
4509 | sdwCyclesRemaining -= 12; |
4510 | dwAddr = cpu.z80C; |
4511 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
4512 | while (psIoWrite->lowIoAddr != 0xffff) |
4513 | { |
4514 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
4515 | { |
4516 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4517 | psIoWrite->IOCall(dwAddr, cpu.z80D, psIoWrite); |
4518 | psIoWrite = NULL; |
4519 | break; |
4520 | } |
4521 | ++psIoWrite; |
4522 | } |
4523 | |
4524 | break; |
4525 | } |
4526 | case 0x52: |
4527 | { |
4528 | sdwCyclesRemaining -= 15; |
4529 | dwTemp = cpu.z80HL - cpu.z80DE - (cpu.z80F & Z80_FLAG_CARRY); |
4530 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4531 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
4532 | if (0 == (dwTemp & 0xffff)) |
4533 | { |
4534 | cpu.z80F |= Z80_FLAG_ZERO; |
4535 | } |
4536 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY); |
4537 | cpu.z80F |= ((((cpu.z80DE ^ cpu.z80HL) & (cpu.z80DE ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
4538 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
4539 | cpu.z80HL = dwTemp & 0xffff; |
4540 | break; |
4541 | } |
4542 | case 0x53: |
4543 | { |
4544 | sdwCyclesRemaining -= 20; |
4545 | dwTemp = *pbPC++; |
4546 | dwTemp |= ((UINT32) *pbPC++ << 8); |
4547 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
4548 | while (psMemWrite->lowAddr != 0xffffffff) |
4549 | { |
4550 | if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr)) |
4551 | { |
4552 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4553 | if (psMemWrite->memoryCall) |
4554 | { |
4555 | psMemWrite->memoryCall(dwTemp, (cpu.z80DE & 0xff), psMemWrite); |
4556 | psMemWrite->memoryCall(dwTemp + 1, (cpu.z80DE >> 8), psMemWrite); |
4557 | } |
4558 | else |
4559 | { |
4560 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80DE; |
4561 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80DE >> 8; |
4562 | } |
4563 | psMemWrite = NULL; |
4564 | break; |
4565 | } |
4566 | ++psMemWrite; |
4567 | } |
4568 | |
4569 | if (psMemWrite) |
4570 | { |
4571 | cpu.z80Base[dwTemp] = (UINT8) cpu.z80DE; |
4572 | cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80DE >> 8); |
4573 | } |
4574 | |
4575 | break; |
4576 | } |
4577 | case 0x54: |
4578 | { |
4579 | sdwCyclesRemaining -= 8; |
4580 | InvalidInstruction(2); |
4581 | break; |
4582 | } |
4583 | case 0x55: |
4584 | { |
4585 | sdwCyclesRemaining -= 8; |
4586 | InvalidInstruction(2); |
4587 | break; |
4588 | } |
4589 | case 0x56: |
4590 | { |
4591 | sdwCyclesRemaining -= 8; |
4592 | cpu.z80interruptMode = 1; |
4593 | cpu.z80intAddr = 0x38; |
4594 | break; |
4595 | } |
4596 | case 0x57: |
4597 | { |
4598 | sdwCyclesRemaining -= 9; |
4599 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4600 | cpu.z80F |= ((cpu.z80iff & IFF2) << 1); |
4601 | cpu.z80A = cpu.z80i; |
4602 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
4603 | break; |
4604 | } |
4605 | case 0x58: |
4606 | { |
4607 | sdwCyclesRemaining -= 12; |
4608 | dwAddr = cpu.z80C; |
4609 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
4610 | while (psIoRead->lowIoAddr != 0xffff) |
4611 | { |
4612 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
4613 | { |
4614 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4615 | cpu.z80E = psIoRead->IOCall(dwAddr, psIoRead); |
4616 | psIoRead = NULL; |
4617 | break; |
4618 | } |
4619 | ++psIoRead; |
4620 | } |
4621 | |
4622 | if (psIoRead) |
4623 | { |
4624 | cpu.z80E = 0xff; /* Unclaimed I/O read */ |
4625 | } |
4626 | |
4627 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4628 | cpu.z80F |= bPostORFlags[cpu.z80E]; |
4629 | break; |
4630 | } |
4631 | case 0x59: |
4632 | { |
4633 | sdwCyclesRemaining -= 12; |
4634 | dwAddr = cpu.z80C; |
4635 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
4636 | while (psIoWrite->lowIoAddr != 0xffff) |
4637 | { |
4638 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
4639 | { |
4640 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4641 | psIoWrite->IOCall(dwAddr, cpu.z80E, psIoWrite); |
4642 | psIoWrite = NULL; |
4643 | break; |
4644 | } |
4645 | ++psIoWrite; |
4646 | } |
4647 | |
4648 | break; |
4649 | } |
4650 | case 0x5a: |
4651 | { |
4652 | sdwCyclesRemaining -= 15; |
4653 | dwTemp = cpu.z80HL + cpu.z80DE + (cpu.z80F & Z80_FLAG_CARRY); |
4654 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4655 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
4656 | if (0 == (dwTemp & 0xffff)) |
4657 | { |
4658 | cpu.z80F |= Z80_FLAG_ZERO; |
4659 | } |
4660 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY); |
4661 | cpu.z80F |= ((((cpu.z80DE ^ cpu.z80HL ^ 0x8000) & (cpu.z80DE ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
4662 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
4663 | cpu.z80HL = dwTemp & 0xffff; |
4664 | break; |
4665 | } |
4666 | case 0x5b: |
4667 | { |
4668 | sdwCyclesRemaining -= 20; |
4669 | dwTemp = *pbPC++; |
4670 | dwTemp |= ((UINT32) *pbPC++ << 8); |
4671 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
4672 | while (psMemRead->lowAddr != 0xffffffff) |
4673 | { |
4674 | if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr)) |
4675 | { |
4676 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4677 | if (psMemRead->memoryCall) |
4678 | { |
4679 | cpu.z80DE = psMemRead->memoryCall(dwTemp, psMemRead); |
4680 | cpu.z80DE |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8); |
4681 | } |
4682 | else |
4683 | { |
4684 | cpu.z80DE = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr)); |
4685 | cpu.z80DE |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8); |
4686 | } |
4687 | psMemRead = NULL; |
4688 | break; |
4689 | } |
4690 | ++psMemRead; |
4691 | } |
4692 | |
4693 | if (psMemRead) |
4694 | { |
4695 | cpu.z80DE = cpu.z80Base[dwTemp]; |
4696 | cpu.z80DE |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8); |
4697 | } |
4698 | |
4699 | break; |
4700 | } |
4701 | case 0x5c: |
4702 | { |
4703 | sdwCyclesRemaining -= 8; |
4704 | InvalidInstruction(2); |
4705 | break; |
4706 | } |
4707 | case 0x5d: |
4708 | { |
4709 | sdwCyclesRemaining -= 8; |
4710 | InvalidInstruction(2); |
4711 | break; |
4712 | } |
4713 | case 0x5e: |
4714 | { |
4715 | sdwCyclesRemaining -= 8; |
4716 | cpu.z80interruptMode = 2; |
4717 | break; |
4718 | } |
4719 | case 0x5f: |
4720 | { |
4721 | sdwCyclesRemaining -= 9; |
4722 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4723 | cpu.z80F |= bPostORFlags[cpu.z80r]; |
4724 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_OVERFLOW_PARITY)) | ((cpu.z80iff & IFF2) << 1); |
4725 | cpu.z80A = cpu.z80r; |
4726 | bTemp = (cpu.z80r + (cpu.z80B + sdwCyclesRemaining + 1 + cpu.z80H)) ^ cpu.z80A; |
4727 | cpu.z80r = (cpu.z80r & 0x80) | (bTemp & 0x7f); |
4728 | break; |
4729 | } |
4730 | case 0x60: |
4731 | { |
4732 | sdwCyclesRemaining -= 12; |
4733 | dwAddr = cpu.z80C; |
4734 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
4735 | while (psIoRead->lowIoAddr != 0xffff) |
4736 | { |
4737 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
4738 | { |
4739 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4740 | cpu.z80H = psIoRead->IOCall(dwAddr, psIoRead); |
4741 | psIoRead = NULL; |
4742 | break; |
4743 | } |
4744 | ++psIoRead; |
4745 | } |
4746 | |
4747 | if (psIoRead) |
4748 | { |
4749 | cpu.z80H = 0xff; /* Unclaimed I/O read */ |
4750 | } |
4751 | |
4752 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4753 | cpu.z80F |= bPostORFlags[cpu.z80H]; |
4754 | break; |
4755 | } |
4756 | case 0x61: |
4757 | { |
4758 | sdwCyclesRemaining -= 12; |
4759 | dwAddr = cpu.z80C; |
4760 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
4761 | while (psIoWrite->lowIoAddr != 0xffff) |
4762 | { |
4763 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
4764 | { |
4765 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4766 | psIoWrite->IOCall(dwAddr, cpu.z80H, psIoWrite); |
4767 | psIoWrite = NULL; |
4768 | break; |
4769 | } |
4770 | ++psIoWrite; |
4771 | } |
4772 | |
4773 | break; |
4774 | } |
4775 | case 0x62: |
4776 | { |
4777 | sdwCyclesRemaining -= 15; |
4778 | dwTemp = cpu.z80HL - cpu.z80HL - (cpu.z80F & Z80_FLAG_CARRY); |
4779 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4780 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
4781 | if (0 == (dwTemp & 0xffff)) |
4782 | { |
4783 | cpu.z80F |= Z80_FLAG_ZERO; |
4784 | } |
4785 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY); |
4786 | cpu.z80F |= ((((cpu.z80HL ^ cpu.z80HL) & (cpu.z80HL ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
4787 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
4788 | cpu.z80HL = dwTemp & 0xffff; |
4789 | break; |
4790 | } |
4791 | case 0x63: |
4792 | { |
4793 | sdwCyclesRemaining -= 20; |
4794 | dwTemp = *pbPC++; |
4795 | dwTemp |= ((UINT32) *pbPC++ << 8); |
4796 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
4797 | while (psMemWrite->lowAddr != 0xffffffff) |
4798 | { |
4799 | if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr)) |
4800 | { |
4801 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4802 | if (psMemWrite->memoryCall) |
4803 | { |
4804 | psMemWrite->memoryCall(dwTemp, (cpu.z80HL & 0xff), psMemWrite); |
4805 | psMemWrite->memoryCall(dwTemp + 1, (cpu.z80HL >> 8), psMemWrite); |
4806 | } |
4807 | else |
4808 | { |
4809 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80HL; |
4810 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8; |
4811 | } |
4812 | psMemWrite = NULL; |
4813 | break; |
4814 | } |
4815 | ++psMemWrite; |
4816 | } |
4817 | |
4818 | if (psMemWrite) |
4819 | { |
4820 | cpu.z80Base[dwTemp] = (UINT8) cpu.z80HL; |
4821 | cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8); |
4822 | } |
4823 | |
4824 | break; |
4825 | } |
4826 | case 0x64: |
4827 | { |
4828 | sdwCyclesRemaining -= 8; |
4829 | InvalidInstruction(2); |
4830 | break; |
4831 | } |
4832 | case 0x65: |
4833 | { |
4834 | sdwCyclesRemaining -= 8; |
4835 | InvalidInstruction(2); |
4836 | break; |
4837 | } |
4838 | case 0x66: |
4839 | { |
4840 | sdwCyclesRemaining -= 8; |
4841 | InvalidInstruction(2); |
4842 | break; |
4843 | } |
4844 | case 0x67: |
4845 | { |
4846 | sdwCyclesRemaining -= 18; |
4847 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
4848 | while (psMemRead->lowAddr != 0xffffffff) |
4849 | { |
4850 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
4851 | { |
4852 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4853 | if (psMemRead->memoryCall) |
4854 | { |
4855 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
4856 | } |
4857 | else |
4858 | { |
4859 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
4860 | } |
4861 | psMemRead = NULL; |
4862 | break; |
4863 | } |
4864 | ++psMemRead; |
4865 | } |
4866 | |
4867 | if (psMemRead) |
4868 | { |
4869 | bTemp = cpu.z80Base[cpu.z80HL]; |
4870 | } |
4871 | |
4872 | bTemp2 = (cpu.z80A & 0x0f) << 4; |
4873 | cpu.z80A = (cpu.z80A & 0xf0) | (bTemp & 0x0f); |
4874 | bTemp = (bTemp >> 4) | bTemp2; |
4875 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
4876 | while (psMemWrite->lowAddr != 0xffffffff) |
4877 | { |
4878 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
4879 | { |
4880 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4881 | if (psMemWrite->memoryCall) |
4882 | { |
4883 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
4884 | } |
4885 | else |
4886 | { |
4887 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
4888 | } |
4889 | psMemWrite = NULL; |
4890 | break; |
4891 | } |
4892 | ++psMemWrite; |
4893 | } |
4894 | |
4895 | if (psMemWrite) |
4896 | { |
4897 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
4898 | } |
4899 | |
4900 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4901 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
4902 | break; |
4903 | } |
4904 | case 0x68: |
4905 | { |
4906 | sdwCyclesRemaining -= 12; |
4907 | dwAddr = cpu.z80C; |
4908 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
4909 | while (psIoRead->lowIoAddr != 0xffff) |
4910 | { |
4911 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
4912 | { |
4913 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4914 | cpu.z80L = psIoRead->IOCall(dwAddr, psIoRead); |
4915 | psIoRead = NULL; |
4916 | break; |
4917 | } |
4918 | ++psIoRead; |
4919 | } |
4920 | |
4921 | if (psIoRead) |
4922 | { |
4923 | cpu.z80L = 0xff; /* Unclaimed I/O read */ |
4924 | } |
4925 | |
4926 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
4927 | cpu.z80F |= bPostORFlags[cpu.z80L]; |
4928 | break; |
4929 | } |
4930 | case 0x69: |
4931 | { |
4932 | sdwCyclesRemaining -= 12; |
4933 | dwAddr = cpu.z80C; |
4934 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
4935 | while (psIoWrite->lowIoAddr != 0xffff) |
4936 | { |
4937 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
4938 | { |
4939 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4940 | psIoWrite->IOCall(dwAddr, cpu.z80L, psIoWrite); |
4941 | psIoWrite = NULL; |
4942 | break; |
4943 | } |
4944 | ++psIoWrite; |
4945 | } |
4946 | |
4947 | break; |
4948 | } |
4949 | case 0x6a: |
4950 | { |
4951 | sdwCyclesRemaining -= 15; |
4952 | dwTemp = cpu.z80HL + cpu.z80HL + (cpu.z80F & Z80_FLAG_CARRY); |
4953 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
4954 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
4955 | if (0 == (dwTemp & 0xffff)) |
4956 | { |
4957 | cpu.z80F |= Z80_FLAG_ZERO; |
4958 | } |
4959 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY); |
4960 | cpu.z80F |= ((((cpu.z80HL ^ cpu.z80HL ^ 0x8000) & (cpu.z80HL ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
4961 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
4962 | cpu.z80HL = dwTemp & 0xffff; |
4963 | break; |
4964 | } |
4965 | case 0x6b: |
4966 | { |
4967 | sdwCyclesRemaining -= 20; |
4968 | InvalidInstruction(2); |
4969 | break; |
4970 | } |
4971 | case 0x6c: |
4972 | { |
4973 | sdwCyclesRemaining -= 8; |
4974 | InvalidInstruction(2); |
4975 | break; |
4976 | } |
4977 | case 0x6d: |
4978 | { |
4979 | sdwCyclesRemaining -= 8; |
4980 | InvalidInstruction(2); |
4981 | break; |
4982 | } |
4983 | case 0x6e: |
4984 | { |
4985 | sdwCyclesRemaining -= 8; |
4986 | InvalidInstruction(2); |
4987 | break; |
4988 | } |
4989 | case 0x6f: |
4990 | { |
4991 | sdwCyclesRemaining -= 18; |
4992 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
4993 | while (psMemRead->lowAddr != 0xffffffff) |
4994 | { |
4995 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
4996 | { |
4997 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
4998 | if (psMemRead->memoryCall) |
4999 | { |
5000 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5001 | } |
5002 | else |
5003 | { |
5004 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5005 | } |
5006 | psMemRead = NULL; |
5007 | break; |
5008 | } |
5009 | ++psMemRead; |
5010 | } |
5011 | |
5012 | if (psMemRead) |
5013 | { |
5014 | bTemp = cpu.z80Base[cpu.z80HL]; |
5015 | } |
5016 | |
5017 | bTemp2 = (cpu.z80A & 0x0f); |
5018 | cpu.z80A = (cpu.z80A & 0xf0) | (bTemp >> 4); |
5019 | bTemp = (bTemp << 4) | bTemp2; |
5020 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5021 | while (psMemWrite->lowAddr != 0xffffffff) |
5022 | { |
5023 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
5024 | { |
5025 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5026 | if (psMemWrite->memoryCall) |
5027 | { |
5028 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
5029 | } |
5030 | else |
5031 | { |
5032 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
5033 | } |
5034 | psMemWrite = NULL; |
5035 | break; |
5036 | } |
5037 | ++psMemWrite; |
5038 | } |
5039 | |
5040 | if (psMemWrite) |
5041 | { |
5042 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
5043 | } |
5044 | |
5045 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5046 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
5047 | break; |
5048 | } |
5049 | case 0x70: |
5050 | { |
5051 | sdwCyclesRemaining -= 12; |
5052 | InvalidInstruction(2); |
5053 | break; |
5054 | } |
5055 | case 0x71: |
5056 | { |
5057 | sdwCyclesRemaining -= 12; |
5058 | InvalidInstruction(2); |
5059 | break; |
5060 | } |
5061 | case 0x72: |
5062 | { |
5063 | sdwCyclesRemaining -= 15; |
5064 | dwTemp = cpu.z80HL - cpu.z80sp - (cpu.z80F & Z80_FLAG_CARRY); |
5065 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
5066 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
5067 | if (0 == (dwTemp & 0xffff)) |
5068 | { |
5069 | cpu.z80F |= Z80_FLAG_ZERO; |
5070 | } |
5071 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY); |
5072 | cpu.z80F |= ((((cpu.z80sp ^ cpu.z80HL) & (cpu.z80sp ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
5073 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
5074 | cpu.z80HL = dwTemp & 0xffff; |
5075 | break; |
5076 | } |
5077 | case 0x73: |
5078 | { |
5079 | sdwCyclesRemaining -= 20; |
5080 | dwTemp = *pbPC++; |
5081 | dwTemp |= ((UINT32) *pbPC++ << 8); |
5082 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5083 | while (psMemWrite->lowAddr != 0xffffffff) |
5084 | { |
5085 | if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr)) |
5086 | { |
5087 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5088 | if (psMemWrite->memoryCall) |
5089 | { |
5090 | psMemWrite->memoryCall(dwTemp, (cpu.z80sp & 0xff), psMemWrite); |
5091 | psMemWrite->memoryCall(dwTemp + 1, (cpu.z80sp >> 8), psMemWrite); |
5092 | } |
5093 | else |
5094 | { |
5095 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80sp; |
5096 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80sp >> 8; |
5097 | } |
5098 | psMemWrite = NULL; |
5099 | break; |
5100 | } |
5101 | ++psMemWrite; |
5102 | } |
5103 | |
5104 | if (psMemWrite) |
5105 | { |
5106 | cpu.z80Base[dwTemp] = (UINT8) cpu.z80sp; |
5107 | cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80sp >> 8); |
5108 | } |
5109 | |
5110 | break; |
5111 | } |
5112 | case 0x74: |
5113 | { |
5114 | sdwCyclesRemaining -= 8; |
5115 | InvalidInstruction(2); |
5116 | break; |
5117 | } |
5118 | case 0x75: |
5119 | { |
5120 | sdwCyclesRemaining -= 8; |
5121 | InvalidInstruction(2); |
5122 | break; |
5123 | } |
5124 | case 0x76: |
5125 | { |
5126 | sdwCyclesRemaining -= 8; |
5127 | InvalidInstruction(2); |
5128 | break; |
5129 | } |
5130 | case 0x77: |
5131 | { |
5132 | InvalidInstruction(2); |
5133 | break; |
5134 | } |
5135 | case 0x78: |
5136 | { |
5137 | sdwCyclesRemaining -= 12; |
5138 | dwAddr = cpu.z80C; |
5139 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
5140 | while (psIoRead->lowIoAddr != 0xffff) |
5141 | { |
5142 | if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr)) |
5143 | { |
5144 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5145 | cpu.z80A = psIoRead->IOCall(dwAddr, psIoRead); |
5146 | psIoRead = NULL; |
5147 | break; |
5148 | } |
5149 | ++psIoRead; |
5150 | } |
5151 | |
5152 | if (psIoRead) |
5153 | { |
5154 | cpu.z80A = 0xff; /* Unclaimed I/O read */ |
5155 | } |
5156 | |
5157 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5158 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
5159 | break; |
5160 | } |
5161 | case 0x79: |
5162 | { |
5163 | sdwCyclesRemaining -= 12; |
5164 | dwAddr = cpu.z80C; |
5165 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
5166 | while (psIoWrite->lowIoAddr != 0xffff) |
5167 | { |
5168 | if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr)) |
5169 | { |
5170 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5171 | psIoWrite->IOCall(dwAddr, cpu.z80A, psIoWrite); |
5172 | psIoWrite = NULL; |
5173 | break; |
5174 | } |
5175 | ++psIoWrite; |
5176 | } |
5177 | |
5178 | break; |
5179 | } |
5180 | case 0x7a: |
5181 | { |
5182 | sdwCyclesRemaining -= 15; |
5183 | dwTemp = cpu.z80HL + cpu.z80sp + (cpu.z80F & Z80_FLAG_CARRY); |
5184 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
5185 | cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN); |
5186 | if (0 == (dwTemp & 0xffff)) |
5187 | { |
5188 | cpu.z80F |= Z80_FLAG_ZERO; |
5189 | } |
5190 | cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY); |
5191 | cpu.z80F |= ((((cpu.z80sp ^ cpu.z80HL ^ 0x8000) & (cpu.z80sp ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY); |
5192 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY); |
5193 | cpu.z80HL = dwTemp & 0xffff; |
5194 | break; |
5195 | } |
5196 | case 0x7b: |
5197 | { |
5198 | sdwCyclesRemaining -= 20; |
5199 | dwTemp = *pbPC++; |
5200 | dwTemp |= ((UINT32) *pbPC++ << 8); |
5201 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5202 | while (psMemRead->lowAddr != 0xffffffff) |
5203 | { |
5204 | if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr)) |
5205 | { |
5206 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5207 | if (psMemRead->memoryCall) |
5208 | { |
5209 | cpu.z80sp = psMemRead->memoryCall(dwTemp, psMemRead); |
5210 | cpu.z80sp |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8); |
5211 | } |
5212 | else |
5213 | { |
5214 | cpu.z80sp = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr)); |
5215 | cpu.z80sp |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8); |
5216 | } |
5217 | psMemRead = NULL; |
5218 | break; |
5219 | } |
5220 | ++psMemRead; |
5221 | } |
5222 | |
5223 | if (psMemRead) |
5224 | { |
5225 | cpu.z80sp = cpu.z80Base[dwTemp]; |
5226 | cpu.z80sp |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8); |
5227 | } |
5228 | |
5229 | break; |
5230 | } |
5231 | case 0x7c: |
5232 | { |
5233 | sdwCyclesRemaining -= 8; |
5234 | InvalidInstruction(2); |
5235 | break; |
5236 | } |
5237 | case 0x7d: |
5238 | { |
5239 | sdwCyclesRemaining -= 8; |
5240 | InvalidInstruction(2); |
5241 | break; |
5242 | } |
5243 | case 0x7e: |
5244 | { |
5245 | sdwCyclesRemaining -= 8; |
5246 | InvalidInstruction(2); |
5247 | break; |
5248 | } |
5249 | case 0x7f: |
5250 | { |
5251 | InvalidInstruction(2); |
5252 | break; |
5253 | } |
5254 | case 0x80: |
5255 | { |
5256 | InvalidInstruction(2); |
5257 | break; |
5258 | } |
5259 | case 0x81: |
5260 | { |
5261 | InvalidInstruction(2); |
5262 | break; |
5263 | } |
5264 | case 0x82: |
5265 | { |
5266 | InvalidInstruction(2); |
5267 | break; |
5268 | } |
5269 | case 0x83: |
5270 | { |
5271 | InvalidInstruction(2); |
5272 | break; |
5273 | } |
5274 | case 0x84: |
5275 | { |
5276 | InvalidInstruction(2); |
5277 | break; |
5278 | } |
5279 | case 0x85: |
5280 | { |
5281 | InvalidInstruction(2); |
5282 | break; |
5283 | } |
5284 | case 0x86: |
5285 | { |
5286 | InvalidInstruction(2); |
5287 | break; |
5288 | } |
5289 | case 0x87: |
5290 | { |
5291 | InvalidInstruction(2); |
5292 | break; |
5293 | } |
5294 | case 0x88: |
5295 | { |
5296 | InvalidInstruction(2); |
5297 | break; |
5298 | } |
5299 | case 0x89: |
5300 | { |
5301 | InvalidInstruction(2); |
5302 | break; |
5303 | } |
5304 | case 0x8a: |
5305 | { |
5306 | InvalidInstruction(2); |
5307 | break; |
5308 | } |
5309 | case 0x8b: |
5310 | { |
5311 | InvalidInstruction(2); |
5312 | break; |
5313 | } |
5314 | case 0x8c: |
5315 | { |
5316 | InvalidInstruction(2); |
5317 | break; |
5318 | } |
5319 | case 0x8d: |
5320 | { |
5321 | InvalidInstruction(2); |
5322 | break; |
5323 | } |
5324 | case 0x8e: |
5325 | { |
5326 | InvalidInstruction(2); |
5327 | break; |
5328 | } |
5329 | case 0x8f: |
5330 | { |
5331 | InvalidInstruction(2); |
5332 | break; |
5333 | } |
5334 | case 0x90: |
5335 | { |
5336 | InvalidInstruction(2); |
5337 | break; |
5338 | } |
5339 | case 0x91: |
5340 | { |
5341 | InvalidInstruction(2); |
5342 | break; |
5343 | } |
5344 | case 0x92: |
5345 | { |
5346 | InvalidInstruction(2); |
5347 | break; |
5348 | } |
5349 | case 0x93: |
5350 | { |
5351 | InvalidInstruction(2); |
5352 | break; |
5353 | } |
5354 | case 0x94: |
5355 | { |
5356 | InvalidInstruction(2); |
5357 | break; |
5358 | } |
5359 | case 0x95: |
5360 | { |
5361 | InvalidInstruction(2); |
5362 | break; |
5363 | } |
5364 | case 0x96: |
5365 | { |
5366 | InvalidInstruction(2); |
5367 | break; |
5368 | } |
5369 | case 0x97: |
5370 | { |
5371 | InvalidInstruction(2); |
5372 | break; |
5373 | } |
5374 | case 0x98: |
5375 | { |
5376 | InvalidInstruction(2); |
5377 | break; |
5378 | } |
5379 | case 0x99: |
5380 | { |
5381 | InvalidInstruction(2); |
5382 | break; |
5383 | } |
5384 | case 0x9a: |
5385 | { |
5386 | InvalidInstruction(2); |
5387 | break; |
5388 | } |
5389 | case 0x9b: |
5390 | { |
5391 | InvalidInstruction(2); |
5392 | break; |
5393 | } |
5394 | case 0x9c: |
5395 | { |
5396 | InvalidInstruction(2); |
5397 | break; |
5398 | } |
5399 | case 0x9d: |
5400 | { |
5401 | InvalidInstruction(2); |
5402 | break; |
5403 | } |
5404 | case 0x9e: |
5405 | { |
5406 | InvalidInstruction(2); |
5407 | break; |
5408 | } |
5409 | case 0x9f: |
5410 | { |
5411 | InvalidInstruction(2); |
5412 | break; |
5413 | } |
5414 | case 0xa0: |
5415 | { |
5416 | sdwCyclesRemaining -= 16; |
5417 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5418 | while (psMemRead->lowAddr != 0xffffffff) |
5419 | { |
5420 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5421 | { |
5422 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5423 | if (psMemRead->memoryCall) |
5424 | { |
5425 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5426 | } |
5427 | else |
5428 | { |
5429 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5430 | } |
5431 | psMemRead = NULL; |
5432 | break; |
5433 | } |
5434 | ++psMemRead; |
5435 | } |
5436 | |
5437 | if (psMemRead) |
5438 | { |
5439 | bTemp = cpu.z80Base[cpu.z80HL]; |
5440 | } |
5441 | |
5442 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5443 | while (psMemWrite->lowAddr != 0xffffffff) |
5444 | { |
5445 | if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr)) |
5446 | { |
5447 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5448 | if (psMemWrite->memoryCall) |
5449 | { |
5450 | psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite); |
5451 | } |
5452 | else |
5453 | { |
5454 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp; |
5455 | } |
5456 | psMemWrite = NULL; |
5457 | break; |
5458 | } |
5459 | ++psMemWrite; |
5460 | } |
5461 | |
5462 | if (psMemWrite) |
5463 | { |
5464 | cpu.z80Base[cpu.z80DE] = (UINT8) bTemp; |
5465 | } |
5466 | |
5467 | ++cpu.z80HL; |
5468 | ++cpu.z80DE; |
5469 | --cpu.z80BC; |
5470 | cpu.z80HL &= 0xffff; |
5471 | cpu.z80DE &= 0xffff; |
5472 | cpu.z80BC &= 0xffff; |
5473 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY); |
5474 | if (cpu.z80BC) |
5475 | { |
5476 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5477 | } |
5478 | break; |
5479 | } |
5480 | case 0xa1: |
5481 | { |
5482 | sdwCyclesRemaining -= 16; |
5483 | { |
5484 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5485 | while (psMemRead->lowAddr != 0xffffffff) |
5486 | { |
5487 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5488 | { |
5489 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5490 | if (psMemRead->memoryCall) |
5491 | { |
5492 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5493 | } |
5494 | else |
5495 | { |
5496 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5497 | } |
5498 | psMemRead = NULL; |
5499 | break; |
5500 | } |
5501 | ++psMemRead; |
5502 | } |
5503 | |
5504 | if (psMemRead) |
5505 | { |
5506 | bTemp = cpu.z80Base[cpu.z80HL]; |
5507 | } |
5508 | |
5509 | cpu.z80HL++; |
5510 | cpu.z80HL &= 0xffff; |
5511 | cpu.z80BC--; |
5512 | cpu.z80BC &= 0xffff; |
5513 | } |
5514 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5515 | cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO)); |
5516 | if (cpu.z80BC) |
5517 | { |
5518 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5519 | } |
5520 | break; |
5521 | } |
5522 | case 0xa2: |
5523 | { |
5524 | sdwCyclesRemaining -= 16; |
5525 | { |
5526 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
5527 | while (psIoRead->lowIoAddr != 0xffff) |
5528 | { |
5529 | if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr)) |
5530 | { |
5531 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5532 | bTemp = psIoRead->IOCall(cpu.z80B, psIoRead); |
5533 | psIoRead = NULL; |
5534 | break; |
5535 | } |
5536 | ++psIoRead; |
5537 | } |
5538 | |
5539 | if (psIoRead) |
5540 | { |
5541 | bTemp = 0xff; /* Unclaimed I/O read */ |
5542 | } |
5543 | |
5544 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5545 | while (psMemWrite->lowAddr != 0xffffffff) |
5546 | { |
5547 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
5548 | { |
5549 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5550 | if (psMemWrite->memoryCall) |
5551 | { |
5552 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
5553 | } |
5554 | else |
5555 | { |
5556 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
5557 | } |
5558 | psMemWrite = NULL; |
5559 | break; |
5560 | } |
5561 | ++psMemWrite; |
5562 | } |
5563 | |
5564 | if (psMemWrite) |
5565 | { |
5566 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
5567 | } |
5568 | |
5569 | cpu.z80HL++; |
5570 | cpu.z80HL &= 0xffff; |
5571 | sdwCyclesRemaining -= 16; |
5572 | cpu.z80B--; |
5573 | } |
5574 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5575 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
5576 | if (cpu.z80B) |
5577 | { |
5578 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5579 | pbPC -= 2; |
5580 | } |
5581 | break; |
5582 | } |
5583 | case 0xa3: |
5584 | { |
5585 | sdwCyclesRemaining -= 16; |
5586 | { |
5587 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5588 | while (psMemRead->lowAddr != 0xffffffff) |
5589 | { |
5590 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5591 | { |
5592 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5593 | if (psMemRead->memoryCall) |
5594 | { |
5595 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5596 | } |
5597 | else |
5598 | { |
5599 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5600 | } |
5601 | psMemRead = NULL; |
5602 | break; |
5603 | } |
5604 | ++psMemRead; |
5605 | } |
5606 | |
5607 | if (psMemRead) |
5608 | { |
5609 | bTemp = cpu.z80Base[cpu.z80HL]; |
5610 | } |
5611 | |
5612 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
5613 | while (psIoWrite->lowIoAddr != 0xffff) |
5614 | { |
5615 | if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr)) |
5616 | { |
5617 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5618 | psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite); |
5619 | psIoWrite = NULL; |
5620 | break; |
5621 | } |
5622 | ++psIoWrite; |
5623 | } |
5624 | |
5625 | cpu.z80HL++; |
5626 | cpu.z80HL &= 0xffff; |
5627 | sdwCyclesRemaining -= 16; |
5628 | cpu.z80B--; |
5629 | } |
5630 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5631 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
5632 | if (cpu.z80B) |
5633 | { |
5634 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5635 | } |
5636 | break; |
5637 | } |
5638 | case 0xa4: |
5639 | { |
5640 | InvalidInstruction(2); |
5641 | break; |
5642 | } |
5643 | case 0xa5: |
5644 | { |
5645 | InvalidInstruction(2); |
5646 | break; |
5647 | } |
5648 | case 0xa6: |
5649 | { |
5650 | InvalidInstruction(2); |
5651 | break; |
5652 | } |
5653 | case 0xa7: |
5654 | { |
5655 | InvalidInstruction(2); |
5656 | break; |
5657 | } |
5658 | case 0xa8: |
5659 | { |
5660 | sdwCyclesRemaining -= 16; |
5661 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5662 | while (psMemRead->lowAddr != 0xffffffff) |
5663 | { |
5664 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5665 | { |
5666 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5667 | if (psMemRead->memoryCall) |
5668 | { |
5669 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5670 | } |
5671 | else |
5672 | { |
5673 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5674 | } |
5675 | psMemRead = NULL; |
5676 | break; |
5677 | } |
5678 | ++psMemRead; |
5679 | } |
5680 | |
5681 | if (psMemRead) |
5682 | { |
5683 | bTemp = cpu.z80Base[cpu.z80HL]; |
5684 | } |
5685 | |
5686 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5687 | while (psMemWrite->lowAddr != 0xffffffff) |
5688 | { |
5689 | if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr)) |
5690 | { |
5691 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5692 | if (psMemWrite->memoryCall) |
5693 | { |
5694 | psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite); |
5695 | } |
5696 | else |
5697 | { |
5698 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp; |
5699 | } |
5700 | psMemWrite = NULL; |
5701 | break; |
5702 | } |
5703 | ++psMemWrite; |
5704 | } |
5705 | |
5706 | if (psMemWrite) |
5707 | { |
5708 | cpu.z80Base[cpu.z80DE] = (UINT8) bTemp; |
5709 | } |
5710 | |
5711 | --cpu.z80HL; |
5712 | --cpu.z80DE; |
5713 | --cpu.z80BC; |
5714 | cpu.z80HL &= 0xffff; |
5715 | cpu.z80DE &= 0xffff; |
5716 | cpu.z80BC &= 0xffff; |
5717 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY); |
5718 | if (cpu.z80BC) |
5719 | { |
5720 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5721 | } |
5722 | break; |
5723 | } |
5724 | case 0xa9: |
5725 | { |
5726 | sdwCyclesRemaining -= 16; |
5727 | { |
5728 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5729 | while (psMemRead->lowAddr != 0xffffffff) |
5730 | { |
5731 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5732 | { |
5733 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5734 | if (psMemRead->memoryCall) |
5735 | { |
5736 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5737 | } |
5738 | else |
5739 | { |
5740 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5741 | } |
5742 | psMemRead = NULL; |
5743 | break; |
5744 | } |
5745 | ++psMemRead; |
5746 | } |
5747 | |
5748 | if (psMemRead) |
5749 | { |
5750 | bTemp = cpu.z80Base[cpu.z80HL]; |
5751 | } |
5752 | |
5753 | cpu.z80HL--; |
5754 | cpu.z80HL &= 0xffff; |
5755 | cpu.z80BC--; |
5756 | cpu.z80BC &= 0xffff; |
5757 | } |
5758 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5759 | cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO)); |
5760 | if (cpu.z80BC) |
5761 | { |
5762 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5763 | } |
5764 | break; |
5765 | } |
5766 | case 0xaa: |
5767 | { |
5768 | sdwCyclesRemaining -= 16; |
5769 | { |
5770 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
5771 | while (psIoRead->lowIoAddr != 0xffff) |
5772 | { |
5773 | if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr)) |
5774 | { |
5775 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5776 | bTemp = psIoRead->IOCall(cpu.z80B, psIoRead); |
5777 | psIoRead = NULL; |
5778 | break; |
5779 | } |
5780 | ++psIoRead; |
5781 | } |
5782 | |
5783 | if (psIoRead) |
5784 | { |
5785 | bTemp = 0xff; /* Unclaimed I/O read */ |
5786 | } |
5787 | |
5788 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5789 | while (psMemWrite->lowAddr != 0xffffffff) |
5790 | { |
5791 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
5792 | { |
5793 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5794 | if (psMemWrite->memoryCall) |
5795 | { |
5796 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
5797 | } |
5798 | else |
5799 | { |
5800 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
5801 | } |
5802 | psMemWrite = NULL; |
5803 | break; |
5804 | } |
5805 | ++psMemWrite; |
5806 | } |
5807 | |
5808 | if (psMemWrite) |
5809 | { |
5810 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
5811 | } |
5812 | |
5813 | cpu.z80HL--; |
5814 | cpu.z80HL &= 0xffff; |
5815 | sdwCyclesRemaining -= 16; |
5816 | cpu.z80B--; |
5817 | } |
5818 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5819 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
5820 | if (cpu.z80B) |
5821 | { |
5822 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5823 | pbPC -= 2; |
5824 | } |
5825 | break; |
5826 | } |
5827 | case 0xab: |
5828 | { |
5829 | sdwCyclesRemaining -= 16; |
5830 | { |
5831 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5832 | while (psMemRead->lowAddr != 0xffffffff) |
5833 | { |
5834 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5835 | { |
5836 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5837 | if (psMemRead->memoryCall) |
5838 | { |
5839 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5840 | } |
5841 | else |
5842 | { |
5843 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5844 | } |
5845 | psMemRead = NULL; |
5846 | break; |
5847 | } |
5848 | ++psMemRead; |
5849 | } |
5850 | |
5851 | if (psMemRead) |
5852 | { |
5853 | bTemp = cpu.z80Base[cpu.z80HL]; |
5854 | } |
5855 | |
5856 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
5857 | while (psIoWrite->lowIoAddr != 0xffff) |
5858 | { |
5859 | if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr)) |
5860 | { |
5861 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5862 | psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite); |
5863 | psIoWrite = NULL; |
5864 | break; |
5865 | } |
5866 | ++psIoWrite; |
5867 | } |
5868 | |
5869 | cpu.z80HL--; |
5870 | cpu.z80HL &= 0xffff; |
5871 | sdwCyclesRemaining -= 16; |
5872 | cpu.z80B--; |
5873 | } |
5874 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
5875 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
5876 | if (cpu.z80B) |
5877 | { |
5878 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5879 | } |
5880 | break; |
5881 | } |
5882 | case 0xac: |
5883 | { |
5884 | InvalidInstruction(2); |
5885 | break; |
5886 | } |
5887 | case 0xad: |
5888 | { |
5889 | InvalidInstruction(2); |
5890 | break; |
5891 | } |
5892 | case 0xae: |
5893 | { |
5894 | InvalidInstruction(2); |
5895 | break; |
5896 | } |
5897 | case 0xaf: |
5898 | { |
5899 | InvalidInstruction(2); |
5900 | break; |
5901 | } |
5902 | case 0xb0: |
5903 | { |
5904 | sdwCyclesRemaining -= 16; |
5905 | while ((sdwCyclesRemaining > 0) && (cpu.z80BC)) |
5906 | { |
5907 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5908 | while (psMemRead->lowAddr != 0xffffffff) |
5909 | { |
5910 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5911 | { |
5912 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5913 | if (psMemRead->memoryCall) |
5914 | { |
5915 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5916 | } |
5917 | else |
5918 | { |
5919 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5920 | } |
5921 | psMemRead = NULL; |
5922 | break; |
5923 | } |
5924 | ++psMemRead; |
5925 | } |
5926 | |
5927 | if (psMemRead) |
5928 | { |
5929 | bTemp = cpu.z80Base[cpu.z80HL]; |
5930 | } |
5931 | |
5932 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
5933 | while (psMemWrite->lowAddr != 0xffffffff) |
5934 | { |
5935 | if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr)) |
5936 | { |
5937 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5938 | if (psMemWrite->memoryCall) |
5939 | { |
5940 | psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite); |
5941 | } |
5942 | else |
5943 | { |
5944 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp; |
5945 | } |
5946 | psMemWrite = NULL; |
5947 | break; |
5948 | } |
5949 | ++psMemWrite; |
5950 | } |
5951 | |
5952 | if (psMemWrite) |
5953 | { |
5954 | cpu.z80Base[cpu.z80DE] = (UINT8) bTemp; |
5955 | } |
5956 | |
5957 | ++cpu.z80HL; |
5958 | ++cpu.z80DE; |
5959 | --cpu.z80BC; |
5960 | cpu.z80HL &= 0xffff; |
5961 | cpu.z80DE &= 0xffff; |
5962 | cpu.z80BC &= 0xffff; |
5963 | sdwCyclesRemaining -= 21; |
5964 | } |
5965 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY); |
5966 | if (cpu.z80BC) |
5967 | { |
5968 | pbPC -= 2; /* Back up so we hit this instruction again */ |
5969 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
5970 | } |
5971 | sdwCyclesRemaining -= 16; |
5972 | break; |
5973 | } |
5974 | case 0xb1: |
5975 | { |
5976 | sdwCyclesRemaining -= 16; |
5977 | while ((sdwCyclesRemaining >= 0) && (cpu.z80BC)) |
5978 | { |
5979 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
5980 | while (psMemRead->lowAddr != 0xffffffff) |
5981 | { |
5982 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
5983 | { |
5984 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
5985 | if (psMemRead->memoryCall) |
5986 | { |
5987 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
5988 | } |
5989 | else |
5990 | { |
5991 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
5992 | } |
5993 | psMemRead = NULL; |
5994 | break; |
5995 | } |
5996 | ++psMemRead; |
5997 | } |
5998 | |
5999 | if (psMemRead) |
6000 | { |
6001 | bTemp = cpu.z80Base[cpu.z80HL]; |
6002 | } |
6003 | |
6004 | cpu.z80HL++; |
6005 | cpu.z80HL &= 0xffff; |
6006 | cpu.z80BC--; |
6007 | cpu.z80BC &= 0xffff; |
6008 | sdwCyclesRemaining -= 16; |
6009 | if (cpu.z80A == bTemp) |
6010 | { |
6011 | break; |
6012 | } |
6013 | } |
6014 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6015 | cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO)); |
6016 | if (cpu.z80BC) |
6017 | { |
6018 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6019 | } |
6020 | break; |
6021 | } |
6022 | case 0xb2: |
6023 | { |
6024 | sdwCyclesRemaining -= 16; |
6025 | while ((sdwCyclesRemaining > 0) && (cpu.z80B)) |
6026 | { |
6027 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
6028 | while (psIoRead->lowIoAddr != 0xffff) |
6029 | { |
6030 | if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr)) |
6031 | { |
6032 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6033 | bTemp = psIoRead->IOCall(cpu.z80B, psIoRead); |
6034 | psIoRead = NULL; |
6035 | break; |
6036 | } |
6037 | ++psIoRead; |
6038 | } |
6039 | |
6040 | if (psIoRead) |
6041 | { |
6042 | bTemp = 0xff; /* Unclaimed I/O read */ |
6043 | } |
6044 | |
6045 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
6046 | while (psMemWrite->lowAddr != 0xffffffff) |
6047 | { |
6048 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
6049 | { |
6050 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6051 | if (psMemWrite->memoryCall) |
6052 | { |
6053 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
6054 | } |
6055 | else |
6056 | { |
6057 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
6058 | } |
6059 | psMemWrite = NULL; |
6060 | break; |
6061 | } |
6062 | ++psMemWrite; |
6063 | } |
6064 | |
6065 | if (psMemWrite) |
6066 | { |
6067 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
6068 | } |
6069 | |
6070 | cpu.z80HL++; |
6071 | cpu.z80HL &= 0xffff; |
6072 | sdwCyclesRemaining -= 16; |
6073 | cpu.z80B--; |
6074 | } |
6075 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6076 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
6077 | if (cpu.z80B) |
6078 | { |
6079 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6080 | pbPC -= 2; |
6081 | } |
6082 | break; |
6083 | } |
6084 | case 0xb3: |
6085 | { |
6086 | sdwCyclesRemaining -= 16; |
6087 | while ((sdwCyclesRemaining > 0) && (cpu.z80B)) |
6088 | { |
6089 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
6090 | while (psMemRead->lowAddr != 0xffffffff) |
6091 | { |
6092 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
6093 | { |
6094 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6095 | if (psMemRead->memoryCall) |
6096 | { |
6097 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
6098 | } |
6099 | else |
6100 | { |
6101 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
6102 | } |
6103 | psMemRead = NULL; |
6104 | break; |
6105 | } |
6106 | ++psMemRead; |
6107 | } |
6108 | |
6109 | if (psMemRead) |
6110 | { |
6111 | bTemp = cpu.z80Base[cpu.z80HL]; |
6112 | } |
6113 | |
6114 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
6115 | while (psIoWrite->lowIoAddr != 0xffff) |
6116 | { |
6117 | if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr)) |
6118 | { |
6119 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6120 | psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite); |
6121 | psIoWrite = NULL; |
6122 | break; |
6123 | } |
6124 | ++psIoWrite; |
6125 | } |
6126 | |
6127 | cpu.z80HL++; |
6128 | cpu.z80HL &= 0xffff; |
6129 | sdwCyclesRemaining -= 16; |
6130 | cpu.z80B--; |
6131 | } |
6132 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6133 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
6134 | if (cpu.z80B) |
6135 | { |
6136 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6137 | } |
6138 | break; |
6139 | } |
6140 | case 0xb4: |
6141 | { |
6142 | InvalidInstruction(2); |
6143 | break; |
6144 | } |
6145 | case 0xb5: |
6146 | { |
6147 | InvalidInstruction(2); |
6148 | break; |
6149 | } |
6150 | case 0xb6: |
6151 | { |
6152 | InvalidInstruction(2); |
6153 | break; |
6154 | } |
6155 | case 0xb7: |
6156 | { |
6157 | InvalidInstruction(2); |
6158 | break; |
6159 | } |
6160 | case 0xb8: |
6161 | { |
6162 | sdwCyclesRemaining -= 16; |
6163 | while ((sdwCyclesRemaining > 0) && (cpu.z80BC)) |
6164 | { |
6165 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
6166 | while (psMemRead->lowAddr != 0xffffffff) |
6167 | { |
6168 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
6169 | { |
6170 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6171 | if (psMemRead->memoryCall) |
6172 | { |
6173 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
6174 | } |
6175 | else |
6176 | { |
6177 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
6178 | } |
6179 | psMemRead = NULL; |
6180 | break; |
6181 | } |
6182 | ++psMemRead; |
6183 | } |
6184 | |
6185 | if (psMemRead) |
6186 | { |
6187 | bTemp = cpu.z80Base[cpu.z80HL]; |
6188 | } |
6189 | |
6190 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
6191 | while (psMemWrite->lowAddr != 0xffffffff) |
6192 | { |
6193 | if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr)) |
6194 | { |
6195 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6196 | if (psMemWrite->memoryCall) |
6197 | { |
6198 | psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite); |
6199 | } |
6200 | else |
6201 | { |
6202 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp; |
6203 | } |
6204 | psMemWrite = NULL; |
6205 | break; |
6206 | } |
6207 | ++psMemWrite; |
6208 | } |
6209 | |
6210 | if (psMemWrite) |
6211 | { |
6212 | cpu.z80Base[cpu.z80DE] = (UINT8) bTemp; |
6213 | } |
6214 | |
6215 | --cpu.z80HL; |
6216 | --cpu.z80DE; |
6217 | --cpu.z80BC; |
6218 | cpu.z80HL &= 0xffff; |
6219 | cpu.z80DE &= 0xffff; |
6220 | cpu.z80BC &= 0xffff; |
6221 | sdwCyclesRemaining -= 21; |
6222 | } |
6223 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY); |
6224 | if (cpu.z80BC) |
6225 | { |
6226 | pbPC -= 2; /* Back up so we hit this instruction again */ |
6227 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6228 | } |
6229 | sdwCyclesRemaining -= 16; |
6230 | break; |
6231 | } |
6232 | case 0xb9: |
6233 | { |
6234 | sdwCyclesRemaining -= 16; |
6235 | while ((sdwCyclesRemaining >= 0) && (cpu.z80BC)) |
6236 | { |
6237 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
6238 | while (psMemRead->lowAddr != 0xffffffff) |
6239 | { |
6240 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
6241 | { |
6242 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6243 | if (psMemRead->memoryCall) |
6244 | { |
6245 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
6246 | } |
6247 | else |
6248 | { |
6249 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
6250 | } |
6251 | psMemRead = NULL; |
6252 | break; |
6253 | } |
6254 | ++psMemRead; |
6255 | } |
6256 | |
6257 | if (psMemRead) |
6258 | { |
6259 | bTemp = cpu.z80Base[cpu.z80HL]; |
6260 | } |
6261 | |
6262 | cpu.z80HL--; |
6263 | cpu.z80HL &= 0xffff; |
6264 | cpu.z80BC--; |
6265 | cpu.z80BC &= 0xffff; |
6266 | sdwCyclesRemaining -= 16; |
6267 | if (cpu.z80A == bTemp) |
6268 | { |
6269 | break; |
6270 | } |
6271 | } |
6272 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6273 | cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO)); |
6274 | if (cpu.z80BC) |
6275 | { |
6276 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6277 | } |
6278 | break; |
6279 | } |
6280 | case 0xba: |
6281 | { |
6282 | sdwCyclesRemaining -= 16; |
6283 | while ((sdwCyclesRemaining > 0) && (cpu.z80B)) |
6284 | { |
6285 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
6286 | while (psIoRead->lowIoAddr != 0xffff) |
6287 | { |
6288 | if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr)) |
6289 | { |
6290 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6291 | bTemp = psIoRead->IOCall(cpu.z80B, psIoRead); |
6292 | psIoRead = NULL; |
6293 | break; |
6294 | } |
6295 | ++psIoRead; |
6296 | } |
6297 | |
6298 | if (psIoRead) |
6299 | { |
6300 | bTemp = 0xff; /* Unclaimed I/O read */ |
6301 | } |
6302 | |
6303 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
6304 | while (psMemWrite->lowAddr != 0xffffffff) |
6305 | { |
6306 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
6307 | { |
6308 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6309 | if (psMemWrite->memoryCall) |
6310 | { |
6311 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
6312 | } |
6313 | else |
6314 | { |
6315 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
6316 | } |
6317 | psMemWrite = NULL; |
6318 | break; |
6319 | } |
6320 | ++psMemWrite; |
6321 | } |
6322 | |
6323 | if (psMemWrite) |
6324 | { |
6325 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
6326 | } |
6327 | |
6328 | cpu.z80HL--; |
6329 | cpu.z80HL &= 0xffff; |
6330 | sdwCyclesRemaining -= 16; |
6331 | cpu.z80B--; |
6332 | } |
6333 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6334 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
6335 | if (cpu.z80B) |
6336 | { |
6337 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6338 | pbPC -= 2; |
6339 | } |
6340 | break; |
6341 | } |
6342 | case 0xbb: |
6343 | { |
6344 | sdwCyclesRemaining -= 16; |
6345 | while ((sdwCyclesRemaining > 0) && (cpu.z80B)) |
6346 | { |
6347 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
6348 | while (psMemRead->lowAddr != 0xffffffff) |
6349 | { |
6350 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
6351 | { |
6352 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6353 | if (psMemRead->memoryCall) |
6354 | { |
6355 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
6356 | } |
6357 | else |
6358 | { |
6359 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
6360 | } |
6361 | psMemRead = NULL; |
6362 | break; |
6363 | } |
6364 | ++psMemRead; |
6365 | } |
6366 | |
6367 | if (psMemRead) |
6368 | { |
6369 | bTemp = cpu.z80Base[cpu.z80HL]; |
6370 | } |
6371 | |
6372 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
6373 | while (psIoWrite->lowIoAddr != 0xffff) |
6374 | { |
6375 | if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr)) |
6376 | { |
6377 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6378 | psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite); |
6379 | psIoWrite = NULL; |
6380 | break; |
6381 | } |
6382 | ++psIoWrite; |
6383 | } |
6384 | |
6385 | cpu.z80HL--; |
6386 | cpu.z80HL &= 0xffff; |
6387 | sdwCyclesRemaining -= 16; |
6388 | cpu.z80B--; |
6389 | } |
6390 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6391 | cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY)); |
6392 | if (cpu.z80B) |
6393 | { |
6394 | cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY; |
6395 | } |
6396 | break; |
6397 | } |
6398 | case 0xbc: |
6399 | { |
6400 | InvalidInstruction(2); |
6401 | break; |
6402 | } |
6403 | case 0xbd: |
6404 | { |
6405 | InvalidInstruction(2); |
6406 | break; |
6407 | } |
6408 | case 0xbe: |
6409 | { |
6410 | InvalidInstruction(2); |
6411 | break; |
6412 | } |
6413 | case 0xbf: |
6414 | { |
6415 | InvalidInstruction(2); |
6416 | break; |
6417 | } |
6418 | case 0xc0: |
6419 | { |
6420 | InvalidInstruction(2); |
6421 | break; |
6422 | } |
6423 | case 0xc1: |
6424 | { |
6425 | InvalidInstruction(2); |
6426 | break; |
6427 | } |
6428 | case 0xc2: |
6429 | { |
6430 | InvalidInstruction(2); |
6431 | break; |
6432 | } |
6433 | case 0xc3: |
6434 | { |
6435 | InvalidInstruction(2); |
6436 | break; |
6437 | } |
6438 | case 0xc4: |
6439 | { |
6440 | InvalidInstruction(2); |
6441 | break; |
6442 | } |
6443 | case 0xc5: |
6444 | { |
6445 | InvalidInstruction(2); |
6446 | break; |
6447 | } |
6448 | case 0xc6: |
6449 | { |
6450 | InvalidInstruction(2); |
6451 | break; |
6452 | } |
6453 | case 0xc7: |
6454 | { |
6455 | InvalidInstruction(2); |
6456 | break; |
6457 | } |
6458 | case 0xc8: |
6459 | { |
6460 | InvalidInstruction(2); |
6461 | break; |
6462 | } |
6463 | case 0xc9: |
6464 | { |
6465 | InvalidInstruction(2); |
6466 | break; |
6467 | } |
6468 | case 0xca: |
6469 | { |
6470 | InvalidInstruction(2); |
6471 | break; |
6472 | } |
6473 | case 0xcb: |
6474 | { |
6475 | InvalidInstruction(2); |
6476 | break; |
6477 | } |
6478 | case 0xcc: |
6479 | { |
6480 | InvalidInstruction(2); |
6481 | break; |
6482 | } |
6483 | case 0xcd: |
6484 | { |
6485 | InvalidInstruction(2); |
6486 | break; |
6487 | } |
6488 | case 0xce: |
6489 | { |
6490 | InvalidInstruction(2); |
6491 | break; |
6492 | } |
6493 | case 0xcf: |
6494 | { |
6495 | InvalidInstruction(2); |
6496 | break; |
6497 | } |
6498 | case 0xd0: |
6499 | { |
6500 | InvalidInstruction(2); |
6501 | break; |
6502 | } |
6503 | case 0xd1: |
6504 | { |
6505 | InvalidInstruction(2); |
6506 | break; |
6507 | } |
6508 | case 0xd2: |
6509 | { |
6510 | InvalidInstruction(2); |
6511 | break; |
6512 | } |
6513 | case 0xd3: |
6514 | { |
6515 | InvalidInstruction(2); |
6516 | break; |
6517 | } |
6518 | case 0xd4: |
6519 | { |
6520 | InvalidInstruction(2); |
6521 | break; |
6522 | } |
6523 | case 0xd5: |
6524 | { |
6525 | InvalidInstruction(2); |
6526 | break; |
6527 | } |
6528 | case 0xd6: |
6529 | { |
6530 | InvalidInstruction(2); |
6531 | break; |
6532 | } |
6533 | case 0xd7: |
6534 | { |
6535 | InvalidInstruction(2); |
6536 | break; |
6537 | } |
6538 | case 0xd8: |
6539 | { |
6540 | InvalidInstruction(2); |
6541 | break; |
6542 | } |
6543 | case 0xd9: |
6544 | { |
6545 | InvalidInstruction(2); |
6546 | break; |
6547 | } |
6548 | case 0xda: |
6549 | { |
6550 | InvalidInstruction(2); |
6551 | break; |
6552 | } |
6553 | case 0xdb: |
6554 | { |
6555 | InvalidInstruction(2); |
6556 | break; |
6557 | } |
6558 | case 0xdc: |
6559 | { |
6560 | InvalidInstruction(2); |
6561 | break; |
6562 | } |
6563 | case 0xdd: |
6564 | { |
6565 | InvalidInstruction(2); |
6566 | break; |
6567 | } |
6568 | case 0xde: |
6569 | { |
6570 | InvalidInstruction(2); |
6571 | break; |
6572 | } |
6573 | case 0xdf: |
6574 | { |
6575 | InvalidInstruction(2); |
6576 | break; |
6577 | } |
6578 | case 0xe0: |
6579 | { |
6580 | InvalidInstruction(2); |
6581 | break; |
6582 | } |
6583 | case 0xe1: |
6584 | { |
6585 | InvalidInstruction(2); |
6586 | break; |
6587 | } |
6588 | case 0xe2: |
6589 | { |
6590 | InvalidInstruction(2); |
6591 | break; |
6592 | } |
6593 | case 0xe3: |
6594 | { |
6595 | InvalidInstruction(2); |
6596 | break; |
6597 | } |
6598 | case 0xe4: |
6599 | { |
6600 | InvalidInstruction(2); |
6601 | break; |
6602 | } |
6603 | case 0xe5: |
6604 | { |
6605 | InvalidInstruction(2); |
6606 | break; |
6607 | } |
6608 | case 0xe6: |
6609 | { |
6610 | InvalidInstruction(2); |
6611 | break; |
6612 | } |
6613 | case 0xe7: |
6614 | { |
6615 | InvalidInstruction(2); |
6616 | break; |
6617 | } |
6618 | case 0xe8: |
6619 | { |
6620 | InvalidInstruction(2); |
6621 | break; |
6622 | } |
6623 | case 0xe9: |
6624 | { |
6625 | InvalidInstruction(2); |
6626 | break; |
6627 | } |
6628 | case 0xea: |
6629 | { |
6630 | InvalidInstruction(2); |
6631 | break; |
6632 | } |
6633 | case 0xeb: |
6634 | { |
6635 | InvalidInstruction(2); |
6636 | break; |
6637 | } |
6638 | case 0xec: |
6639 | { |
6640 | InvalidInstruction(2); |
6641 | break; |
6642 | } |
6643 | case 0xed: |
6644 | { |
6645 | InvalidInstruction(2); |
6646 | break; |
6647 | } |
6648 | case 0xee: |
6649 | { |
6650 | InvalidInstruction(2); |
6651 | break; |
6652 | } |
6653 | case 0xef: |
6654 | { |
6655 | InvalidInstruction(2); |
6656 | break; |
6657 | } |
6658 | case 0xf0: |
6659 | { |
6660 | InvalidInstruction(2); |
6661 | break; |
6662 | } |
6663 | case 0xf1: |
6664 | { |
6665 | InvalidInstruction(2); |
6666 | break; |
6667 | } |
6668 | case 0xf2: |
6669 | { |
6670 | InvalidInstruction(2); |
6671 | break; |
6672 | } |
6673 | case 0xf3: |
6674 | { |
6675 | InvalidInstruction(2); |
6676 | break; |
6677 | } |
6678 | case 0xf4: |
6679 | { |
6680 | InvalidInstruction(2); |
6681 | break; |
6682 | } |
6683 | case 0xf5: |
6684 | { |
6685 | InvalidInstruction(2); |
6686 | break; |
6687 | } |
6688 | case 0xf6: |
6689 | { |
6690 | InvalidInstruction(2); |
6691 | break; |
6692 | } |
6693 | case 0xf7: |
6694 | { |
6695 | InvalidInstruction(2); |
6696 | break; |
6697 | } |
6698 | case 0xf8: |
6699 | { |
6700 | InvalidInstruction(2); |
6701 | break; |
6702 | } |
6703 | case 0xf9: |
6704 | { |
6705 | InvalidInstruction(2); |
6706 | break; |
6707 | } |
6708 | case 0xfa: |
6709 | { |
6710 | InvalidInstruction(2); |
6711 | break; |
6712 | } |
6713 | case 0xfb: |
6714 | { |
6715 | InvalidInstruction(2); |
6716 | break; |
6717 | } |
6718 | case 0xfc: |
6719 | { |
6720 | InvalidInstruction(2); |
6721 | break; |
6722 | } |
6723 | case 0xfd: |
6724 | { |
6725 | InvalidInstruction(2); |
6726 | break; |
6727 | } |
6728 | case 0xfe: |
6729 | { |
6730 | InvalidInstruction(2); |
6731 | break; |
6732 | } |
6733 | case 0xff: |
6734 | { |
6735 | InvalidInstruction(2); |
6736 | break; |
6737 | } |
6738 | } |
6739 | } |
6740 | |
6741 | void DDHandler(void) |
6742 | { |
6743 | switch (*pbPC++) |
6744 | { |
6745 | case 0x00: |
6746 | { |
6747 | InvalidInstruction(2); |
6748 | break; |
6749 | } |
6750 | case 0x01: |
6751 | { |
6752 | InvalidInstruction(2); |
6753 | break; |
6754 | } |
6755 | case 0x02: |
6756 | { |
6757 | InvalidInstruction(2); |
6758 | break; |
6759 | } |
6760 | case 0x03: |
6761 | { |
6762 | InvalidInstruction(2); |
6763 | break; |
6764 | } |
6765 | case 0x04: |
6766 | { |
6767 | InvalidInstruction(2); |
6768 | break; |
6769 | } |
6770 | case 0x05: |
6771 | { |
6772 | InvalidInstruction(2); |
6773 | break; |
6774 | } |
6775 | case 0x06: |
6776 | { |
6777 | InvalidInstruction(2); |
6778 | break; |
6779 | } |
6780 | case 0x07: |
6781 | { |
6782 | InvalidInstruction(2); |
6783 | break; |
6784 | } |
6785 | case 0x08: |
6786 | { |
6787 | InvalidInstruction(2); |
6788 | break; |
6789 | } |
6790 | case 0x09: |
6791 | { |
6792 | sdwCyclesRemaining -= 15; |
6793 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
6794 | dwTemp = cpu.z80IX + cpu.z80BC; |
6795 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY); |
6796 | cpu.z80IX = dwTemp & 0xffff; |
6797 | break; |
6798 | } |
6799 | case 0x0a: |
6800 | { |
6801 | InvalidInstruction(2); |
6802 | break; |
6803 | } |
6804 | case 0x0b: |
6805 | { |
6806 | InvalidInstruction(2); |
6807 | break; |
6808 | } |
6809 | case 0x0c: |
6810 | { |
6811 | InvalidInstruction(2); |
6812 | break; |
6813 | } |
6814 | case 0x0d: |
6815 | { |
6816 | InvalidInstruction(2); |
6817 | break; |
6818 | } |
6819 | case 0x0e: |
6820 | { |
6821 | InvalidInstruction(2); |
6822 | break; |
6823 | } |
6824 | case 0x0f: |
6825 | { |
6826 | InvalidInstruction(2); |
6827 | break; |
6828 | } |
6829 | case 0x10: |
6830 | { |
6831 | InvalidInstruction(2); |
6832 | break; |
6833 | } |
6834 | case 0x11: |
6835 | { |
6836 | InvalidInstruction(2); |
6837 | break; |
6838 | } |
6839 | case 0x12: |
6840 | { |
6841 | InvalidInstruction(2); |
6842 | break; |
6843 | } |
6844 | case 0x13: |
6845 | { |
6846 | InvalidInstruction(2); |
6847 | break; |
6848 | } |
6849 | case 0x14: |
6850 | { |
6851 | InvalidInstruction(2); |
6852 | break; |
6853 | } |
6854 | case 0x15: |
6855 | { |
6856 | InvalidInstruction(2); |
6857 | break; |
6858 | } |
6859 | case 0x16: |
6860 | { |
6861 | InvalidInstruction(2); |
6862 | break; |
6863 | } |
6864 | case 0x17: |
6865 | { |
6866 | InvalidInstruction(2); |
6867 | break; |
6868 | } |
6869 | case 0x18: |
6870 | { |
6871 | InvalidInstruction(2); |
6872 | break; |
6873 | } |
6874 | case 0x19: |
6875 | { |
6876 | sdwCyclesRemaining -= 15; |
6877 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
6878 | dwTemp = cpu.z80IX + cpu.z80DE; |
6879 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY); |
6880 | cpu.z80IX = dwTemp & 0xffff; |
6881 | break; |
6882 | } |
6883 | case 0x1a: |
6884 | { |
6885 | InvalidInstruction(2); |
6886 | break; |
6887 | } |
6888 | case 0x1b: |
6889 | { |
6890 | InvalidInstruction(2); |
6891 | break; |
6892 | } |
6893 | case 0x1c: |
6894 | { |
6895 | InvalidInstruction(2); |
6896 | break; |
6897 | } |
6898 | case 0x1d: |
6899 | { |
6900 | InvalidInstruction(2); |
6901 | break; |
6902 | } |
6903 | case 0x1e: |
6904 | { |
6905 | InvalidInstruction(2); |
6906 | break; |
6907 | } |
6908 | case 0x1f: |
6909 | { |
6910 | InvalidInstruction(2); |
6911 | break; |
6912 | } |
6913 | case 0x20: |
6914 | { |
6915 | InvalidInstruction(2); |
6916 | break; |
6917 | } |
6918 | case 0x21: |
6919 | { |
6920 | sdwCyclesRemaining -= 14; |
6921 | cpu.z80IX = *pbPC++; |
6922 | cpu.z80IX |= ((UINT32) *pbPC++ << 8); |
6923 | break; |
6924 | } |
6925 | case 0x22: |
6926 | { |
6927 | sdwCyclesRemaining -= 20; |
6928 | dwAddr = *pbPC++; |
6929 | dwAddr |= ((UINT32) *pbPC++ << 8); |
6930 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
6931 | while (psMemWrite->lowAddr != 0xffffffff) |
6932 | { |
6933 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
6934 | { |
6935 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
6936 | if (psMemWrite->memoryCall) |
6937 | { |
6938 | psMemWrite->memoryCall(dwAddr, (cpu.z80IX & 0xff), psMemWrite); |
6939 | psMemWrite->memoryCall(dwAddr + 1, (cpu.z80IX >> 8), psMemWrite); |
6940 | } |
6941 | else |
6942 | { |
6943 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = cpu.z80IX; |
6944 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8; |
6945 | } |
6946 | psMemWrite = NULL; |
6947 | break; |
6948 | } |
6949 | ++psMemWrite; |
6950 | } |
6951 | |
6952 | if (psMemWrite) |
6953 | { |
6954 | cpu.z80Base[dwAddr] = (UINT8) cpu.z80IX; |
6955 | cpu.z80Base[dwAddr + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8); |
6956 | } |
6957 | |
6958 | break; |
6959 | } |
6960 | case 0x23: |
6961 | { |
6962 | sdwCyclesRemaining -= 10; |
6963 | cpu.z80IX++; |
6964 | cpu.z80IX &= 0xffff; |
6965 | break; |
6966 | } |
6967 | case 0x24: |
6968 | { |
6969 | sdwCyclesRemaining -= 9; |
6970 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6971 | cpu.z80F |= bPostIncFlags[cpu.z80XH++]; |
6972 | break; |
6973 | } |
6974 | case 0x25: |
6975 | { |
6976 | sdwCyclesRemaining -= 9; |
6977 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
6978 | cpu.z80F |= bPostDecFlags[cpu.z80XH--]; |
6979 | break; |
6980 | } |
6981 | case 0x26: |
6982 | { |
6983 | sdwCyclesRemaining -= 9; |
6984 | cpu.z80XH = *pbPC++; |
6985 | break; |
6986 | } |
6987 | case 0x27: |
6988 | { |
6989 | InvalidInstruction(2); |
6990 | break; |
6991 | } |
6992 | case 0x28: |
6993 | { |
6994 | InvalidInstruction(2); |
6995 | break; |
6996 | } |
6997 | case 0x29: |
6998 | { |
6999 | sdwCyclesRemaining -= 15; |
7000 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
7001 | dwTemp = cpu.z80IX + cpu.z80IX; |
7002 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY); |
7003 | cpu.z80IX = dwTemp & 0xffff; |
7004 | break; |
7005 | } |
7006 | case 0x2a: |
7007 | { |
7008 | sdwCyclesRemaining -= 20; |
7009 | dwAddr = *pbPC++; |
7010 | dwAddr |= ((UINT32) *pbPC++ << 8); |
7011 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7012 | while (psMemRead->lowAddr != 0xffffffff) |
7013 | { |
7014 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
7015 | { |
7016 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7017 | if (psMemRead->memoryCall) |
7018 | { |
7019 | cpu.z80IX = psMemRead->memoryCall(dwAddr, psMemRead); |
7020 | cpu.z80IX |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8); |
7021 | } |
7022 | else |
7023 | { |
7024 | cpu.z80IX = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
7025 | cpu.z80IX |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8); |
7026 | } |
7027 | psMemRead = NULL; |
7028 | break; |
7029 | } |
7030 | ++psMemRead; |
7031 | } |
7032 | |
7033 | if (psMemRead) |
7034 | { |
7035 | cpu.z80IX = cpu.z80Base[dwAddr]; |
7036 | cpu.z80IX |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8); |
7037 | } |
7038 | |
7039 | break; |
7040 | } |
7041 | case 0x2b: |
7042 | { |
7043 | sdwCyclesRemaining -= 10; |
7044 | cpu.z80IX--; |
7045 | cpu.z80IX &= 0xffff; |
7046 | break; |
7047 | } |
7048 | case 0x2c: |
7049 | { |
7050 | sdwCyclesRemaining -= 9; |
7051 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
7052 | cpu.z80F |= bPostIncFlags[cpu.z80XL++]; |
7053 | break; |
7054 | } |
7055 | case 0x2d: |
7056 | { |
7057 | sdwCyclesRemaining -= 9; |
7058 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
7059 | cpu.z80F |= bPostDecFlags[cpu.z80XL--]; |
7060 | break; |
7061 | } |
7062 | case 0x2e: |
7063 | { |
7064 | sdwCyclesRemaining -= 9; |
7065 | cpu.z80XL = *pbPC++; |
7066 | break; |
7067 | } |
7068 | case 0x2f: |
7069 | { |
7070 | InvalidInstruction(2); |
7071 | break; |
7072 | } |
7073 | case 0x30: |
7074 | { |
7075 | InvalidInstruction(2); |
7076 | break; |
7077 | } |
7078 | case 0x31: |
7079 | { |
7080 | InvalidInstruction(2); |
7081 | break; |
7082 | } |
7083 | case 0x32: |
7084 | { |
7085 | InvalidInstruction(2); |
7086 | break; |
7087 | } |
7088 | case 0x33: |
7089 | { |
7090 | InvalidInstruction(2); |
7091 | break; |
7092 | } |
7093 | case 0x34: |
7094 | { |
7095 | sdwCyclesRemaining -= 23; |
7096 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
7097 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
7098 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7099 | while (psMemRead->lowAddr != 0xffffffff) |
7100 | { |
7101 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
7102 | { |
7103 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7104 | if (psMemRead->memoryCall) |
7105 | { |
7106 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
7107 | } |
7108 | else |
7109 | { |
7110 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
7111 | } |
7112 | psMemRead = NULL; |
7113 | break; |
7114 | } |
7115 | ++psMemRead; |
7116 | } |
7117 | |
7118 | if (psMemRead) |
7119 | { |
7120 | bTemp = cpu.z80Base[dwAddr]; |
7121 | } |
7122 | |
7123 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
7124 | cpu.z80F |= bPostIncFlags[bTemp++]; |
7125 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7126 | while (psMemWrite->lowAddr != 0xffffffff) |
7127 | { |
7128 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
7129 | { |
7130 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7131 | if (psMemWrite->memoryCall) |
7132 | { |
7133 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
7134 | } |
7135 | else |
7136 | { |
7137 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
7138 | } |
7139 | psMemWrite = NULL; |
7140 | break; |
7141 | } |
7142 | ++psMemWrite; |
7143 | } |
7144 | |
7145 | if (psMemWrite) |
7146 | { |
7147 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
7148 | } |
7149 | |
7150 | break; |
7151 | } |
7152 | case 0x35: |
7153 | { |
7154 | sdwCyclesRemaining -= 23; |
7155 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
7156 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
7157 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7158 | while (psMemRead->lowAddr != 0xffffffff) |
7159 | { |
7160 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
7161 | { |
7162 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7163 | if (psMemRead->memoryCall) |
7164 | { |
7165 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
7166 | } |
7167 | else |
7168 | { |
7169 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
7170 | } |
7171 | psMemRead = NULL; |
7172 | break; |
7173 | } |
7174 | ++psMemRead; |
7175 | } |
7176 | |
7177 | if (psMemRead) |
7178 | { |
7179 | bTemp = cpu.z80Base[dwAddr]; |
7180 | } |
7181 | |
7182 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
7183 | cpu.z80F |= bPostDecFlags[bTemp--]; |
7184 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7185 | while (psMemWrite->lowAddr != 0xffffffff) |
7186 | { |
7187 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
7188 | { |
7189 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7190 | if (psMemWrite->memoryCall) |
7191 | { |
7192 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
7193 | } |
7194 | else |
7195 | { |
7196 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
7197 | } |
7198 | psMemWrite = NULL; |
7199 | break; |
7200 | } |
7201 | ++psMemWrite; |
7202 | } |
7203 | |
7204 | if (psMemWrite) |
7205 | { |
7206 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
7207 | } |
7208 | |
7209 | break; |
7210 | } |
7211 | case 0x36: |
7212 | { |
7213 | sdwCyclesRemaining -= 19; |
7214 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7215 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7216 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7217 | while (psMemWrite->lowAddr != 0xffffffff) |
7218 | { |
7219 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7220 | { |
7221 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7222 | if (psMemWrite->memoryCall) |
7223 | { |
7224 | psMemWrite->memoryCall(sdwAddr, *pbPC++, psMemWrite); |
7225 | } |
7226 | else |
7227 | { |
7228 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = *pbPC++; |
7229 | } |
7230 | psMemWrite = NULL; |
7231 | break; |
7232 | } |
7233 | ++psMemWrite; |
7234 | } |
7235 | |
7236 | if (psMemWrite) |
7237 | { |
7238 | cpu.z80Base[sdwAddr] = (UINT8) *pbPC++; |
7239 | } |
7240 | |
7241 | break; |
7242 | } |
7243 | case 0x37: |
7244 | { |
7245 | InvalidInstruction(2); |
7246 | break; |
7247 | } |
7248 | case 0x38: |
7249 | { |
7250 | InvalidInstruction(2); |
7251 | break; |
7252 | } |
7253 | case 0x39: |
7254 | { |
7255 | sdwCyclesRemaining -= 15; |
7256 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
7257 | dwTemp = cpu.z80IX + cpu.z80sp; |
7258 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY); |
7259 | cpu.z80IX = dwTemp & 0xffff; |
7260 | break; |
7261 | } |
7262 | case 0x3a: |
7263 | { |
7264 | InvalidInstruction(2); |
7265 | break; |
7266 | } |
7267 | case 0x3b: |
7268 | { |
7269 | InvalidInstruction(2); |
7270 | break; |
7271 | } |
7272 | case 0x3c: |
7273 | { |
7274 | InvalidInstruction(2); |
7275 | break; |
7276 | } |
7277 | case 0x3d: |
7278 | { |
7279 | InvalidInstruction(2); |
7280 | break; |
7281 | } |
7282 | case 0x3e: |
7283 | { |
7284 | InvalidInstruction(2); |
7285 | break; |
7286 | } |
7287 | case 0x3f: |
7288 | { |
7289 | InvalidInstruction(2); |
7290 | break; |
7291 | } |
7292 | case 0x40: |
7293 | { |
7294 | InvalidInstruction(2); |
7295 | break; |
7296 | } |
7297 | case 0x41: |
7298 | { |
7299 | InvalidInstruction(2); |
7300 | break; |
7301 | } |
7302 | case 0x42: |
7303 | { |
7304 | InvalidInstruction(2); |
7305 | break; |
7306 | } |
7307 | case 0x43: |
7308 | { |
7309 | InvalidInstruction(2); |
7310 | break; |
7311 | } |
7312 | case 0x44: |
7313 | { |
7314 | sdwCyclesRemaining -= 9; |
7315 | cpu.z80B = cpu.z80XH; |
7316 | break; |
7317 | } |
7318 | case 0x45: |
7319 | { |
7320 | sdwCyclesRemaining -= 9; |
7321 | cpu.z80B = cpu.z80XL; |
7322 | break; |
7323 | } |
7324 | case 0x46: |
7325 | { |
7326 | sdwCyclesRemaining -= 19; |
7327 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7328 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7329 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7330 | while (psMemRead->lowAddr != 0xffffffff) |
7331 | { |
7332 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7333 | { |
7334 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7335 | if (psMemRead->memoryCall) |
7336 | { |
7337 | cpu.z80B = psMemRead->memoryCall(sdwAddr, psMemRead); |
7338 | } |
7339 | else |
7340 | { |
7341 | cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7342 | } |
7343 | psMemRead = NULL; |
7344 | break; |
7345 | } |
7346 | ++psMemRead; |
7347 | } |
7348 | |
7349 | if (psMemRead) |
7350 | { |
7351 | cpu.z80B = cpu.z80Base[sdwAddr]; |
7352 | } |
7353 | |
7354 | break; |
7355 | } |
7356 | case 0x47: |
7357 | { |
7358 | InvalidInstruction(2); |
7359 | break; |
7360 | } |
7361 | case 0x48: |
7362 | { |
7363 | InvalidInstruction(2); |
7364 | break; |
7365 | } |
7366 | case 0x49: |
7367 | { |
7368 | InvalidInstruction(2); |
7369 | break; |
7370 | } |
7371 | case 0x4a: |
7372 | { |
7373 | InvalidInstruction(2); |
7374 | break; |
7375 | } |
7376 | case 0x4b: |
7377 | { |
7378 | InvalidInstruction(2); |
7379 | break; |
7380 | } |
7381 | case 0x4c: |
7382 | { |
7383 | sdwCyclesRemaining -= 9; |
7384 | cpu.z80C = cpu.z80XH; |
7385 | break; |
7386 | } |
7387 | case 0x4d: |
7388 | { |
7389 | sdwCyclesRemaining -= 9; |
7390 | cpu.z80C = cpu.z80XL; |
7391 | break; |
7392 | } |
7393 | case 0x4e: |
7394 | { |
7395 | sdwCyclesRemaining -= 19; |
7396 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7397 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7398 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7399 | while (psMemRead->lowAddr != 0xffffffff) |
7400 | { |
7401 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7402 | { |
7403 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7404 | if (psMemRead->memoryCall) |
7405 | { |
7406 | cpu.z80C = psMemRead->memoryCall(sdwAddr, psMemRead); |
7407 | } |
7408 | else |
7409 | { |
7410 | cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7411 | } |
7412 | psMemRead = NULL; |
7413 | break; |
7414 | } |
7415 | ++psMemRead; |
7416 | } |
7417 | |
7418 | if (psMemRead) |
7419 | { |
7420 | cpu.z80C = cpu.z80Base[sdwAddr]; |
7421 | } |
7422 | |
7423 | break; |
7424 | } |
7425 | case 0x4f: |
7426 | { |
7427 | InvalidInstruction(2); |
7428 | break; |
7429 | } |
7430 | case 0x50: |
7431 | { |
7432 | InvalidInstruction(2); |
7433 | break; |
7434 | } |
7435 | case 0x51: |
7436 | { |
7437 | InvalidInstruction(2); |
7438 | break; |
7439 | } |
7440 | case 0x52: |
7441 | { |
7442 | InvalidInstruction(2); |
7443 | break; |
7444 | } |
7445 | case 0x53: |
7446 | { |
7447 | InvalidInstruction(2); |
7448 | break; |
7449 | } |
7450 | case 0x54: |
7451 | { |
7452 | sdwCyclesRemaining -= 9; |
7453 | cpu.z80D = cpu.z80XH; |
7454 | break; |
7455 | } |
7456 | case 0x55: |
7457 | { |
7458 | sdwCyclesRemaining -= 9; |
7459 | cpu.z80D = cpu.z80XL; |
7460 | break; |
7461 | } |
7462 | case 0x56: |
7463 | { |
7464 | sdwCyclesRemaining -= 19; |
7465 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7466 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7467 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7468 | while (psMemRead->lowAddr != 0xffffffff) |
7469 | { |
7470 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7471 | { |
7472 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7473 | if (psMemRead->memoryCall) |
7474 | { |
7475 | cpu.z80D = psMemRead->memoryCall(sdwAddr, psMemRead); |
7476 | } |
7477 | else |
7478 | { |
7479 | cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7480 | } |
7481 | psMemRead = NULL; |
7482 | break; |
7483 | } |
7484 | ++psMemRead; |
7485 | } |
7486 | |
7487 | if (psMemRead) |
7488 | { |
7489 | cpu.z80D = cpu.z80Base[sdwAddr]; |
7490 | } |
7491 | |
7492 | break; |
7493 | } |
7494 | case 0x57: |
7495 | { |
7496 | InvalidInstruction(2); |
7497 | break; |
7498 | } |
7499 | case 0x58: |
7500 | { |
7501 | InvalidInstruction(2); |
7502 | break; |
7503 | } |
7504 | case 0x59: |
7505 | { |
7506 | InvalidInstruction(2); |
7507 | break; |
7508 | } |
7509 | case 0x5a: |
7510 | { |
7511 | InvalidInstruction(2); |
7512 | break; |
7513 | } |
7514 | case 0x5b: |
7515 | { |
7516 | InvalidInstruction(2); |
7517 | break; |
7518 | } |
7519 | case 0x5c: |
7520 | { |
7521 | sdwCyclesRemaining -= 9; |
7522 | cpu.z80E = cpu.z80XH; |
7523 | break; |
7524 | } |
7525 | case 0x5d: |
7526 | { |
7527 | sdwCyclesRemaining -= 9; |
7528 | cpu.z80E = cpu.z80XL; |
7529 | break; |
7530 | } |
7531 | case 0x5e: |
7532 | { |
7533 | sdwCyclesRemaining -= 19; |
7534 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7535 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7536 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7537 | while (psMemRead->lowAddr != 0xffffffff) |
7538 | { |
7539 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7540 | { |
7541 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7542 | if (psMemRead->memoryCall) |
7543 | { |
7544 | cpu.z80E = psMemRead->memoryCall(sdwAddr, psMemRead); |
7545 | } |
7546 | else |
7547 | { |
7548 | cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7549 | } |
7550 | psMemRead = NULL; |
7551 | break; |
7552 | } |
7553 | ++psMemRead; |
7554 | } |
7555 | |
7556 | if (psMemRead) |
7557 | { |
7558 | cpu.z80E = cpu.z80Base[sdwAddr]; |
7559 | } |
7560 | |
7561 | break; |
7562 | } |
7563 | case 0x5f: |
7564 | { |
7565 | InvalidInstruction(2); |
7566 | break; |
7567 | } |
7568 | case 0x60: |
7569 | { |
7570 | sdwCyclesRemaining -= 9; |
7571 | cpu.z80XH = cpu.z80B; |
7572 | break; |
7573 | } |
7574 | case 0x61: |
7575 | { |
7576 | sdwCyclesRemaining -= 9; |
7577 | cpu.z80XH = cpu.z80C; |
7578 | break; |
7579 | } |
7580 | case 0x62: |
7581 | { |
7582 | sdwCyclesRemaining -= 9; |
7583 | cpu.z80XH = cpu.z80D; |
7584 | break; |
7585 | } |
7586 | case 0x63: |
7587 | { |
7588 | sdwCyclesRemaining -= 9; |
7589 | cpu.z80XH = cpu.z80E; |
7590 | break; |
7591 | } |
7592 | case 0x64: |
7593 | { |
7594 | sdwCyclesRemaining -= 9; |
7595 | break; |
7596 | } |
7597 | case 0x65: |
7598 | { |
7599 | sdwCyclesRemaining -= 9; |
7600 | cpu.z80XH = cpu.z80XL; |
7601 | break; |
7602 | } |
7603 | case 0x66: |
7604 | { |
7605 | sdwCyclesRemaining -= 19; |
7606 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7607 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7608 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7609 | while (psMemRead->lowAddr != 0xffffffff) |
7610 | { |
7611 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7612 | { |
7613 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7614 | if (psMemRead->memoryCall) |
7615 | { |
7616 | cpu.z80H = psMemRead->memoryCall(sdwAddr, psMemRead); |
7617 | } |
7618 | else |
7619 | { |
7620 | cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7621 | } |
7622 | psMemRead = NULL; |
7623 | break; |
7624 | } |
7625 | ++psMemRead; |
7626 | } |
7627 | |
7628 | if (psMemRead) |
7629 | { |
7630 | cpu.z80H = cpu.z80Base[sdwAddr]; |
7631 | } |
7632 | |
7633 | break; |
7634 | } |
7635 | case 0x67: |
7636 | { |
7637 | sdwCyclesRemaining -= 9; |
7638 | cpu.z80XH = cpu.z80A; |
7639 | break; |
7640 | } |
7641 | case 0x68: |
7642 | { |
7643 | sdwCyclesRemaining -= 9; |
7644 | cpu.z80XL = cpu.z80B; |
7645 | break; |
7646 | } |
7647 | case 0x69: |
7648 | { |
7649 | sdwCyclesRemaining -= 9; |
7650 | cpu.z80XL = cpu.z80C; |
7651 | break; |
7652 | } |
7653 | case 0x6a: |
7654 | { |
7655 | sdwCyclesRemaining -= 9; |
7656 | cpu.z80XL = cpu.z80D; |
7657 | break; |
7658 | } |
7659 | case 0x6b: |
7660 | { |
7661 | sdwCyclesRemaining -= 9; |
7662 | cpu.z80XL = cpu.z80E; |
7663 | break; |
7664 | } |
7665 | case 0x6c: |
7666 | { |
7667 | sdwCyclesRemaining -= 9; |
7668 | cpu.z80XL = cpu.z80XH; |
7669 | break; |
7670 | } |
7671 | case 0x6d: |
7672 | { |
7673 | sdwCyclesRemaining -= 9; |
7674 | break; |
7675 | } |
7676 | case 0x6e: |
7677 | { |
7678 | sdwCyclesRemaining -= 19; |
7679 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7680 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7681 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7682 | while (psMemRead->lowAddr != 0xffffffff) |
7683 | { |
7684 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7685 | { |
7686 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7687 | if (psMemRead->memoryCall) |
7688 | { |
7689 | cpu.z80L = psMemRead->memoryCall(sdwAddr, psMemRead); |
7690 | } |
7691 | else |
7692 | { |
7693 | cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7694 | } |
7695 | psMemRead = NULL; |
7696 | break; |
7697 | } |
7698 | ++psMemRead; |
7699 | } |
7700 | |
7701 | if (psMemRead) |
7702 | { |
7703 | cpu.z80L = cpu.z80Base[sdwAddr]; |
7704 | } |
7705 | |
7706 | break; |
7707 | } |
7708 | case 0x6f: |
7709 | { |
7710 | sdwCyclesRemaining -= 9; |
7711 | cpu.z80XL = cpu.z80A; |
7712 | break; |
7713 | } |
7714 | case 0x70: |
7715 | { |
7716 | sdwCyclesRemaining -= 19; |
7717 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7718 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7719 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7720 | while (psMemWrite->lowAddr != 0xffffffff) |
7721 | { |
7722 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7723 | { |
7724 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7725 | if (psMemWrite->memoryCall) |
7726 | { |
7727 | psMemWrite->memoryCall(sdwAddr, cpu.z80B, psMemWrite); |
7728 | } |
7729 | else |
7730 | { |
7731 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80B; |
7732 | } |
7733 | psMemWrite = NULL; |
7734 | break; |
7735 | } |
7736 | ++psMemWrite; |
7737 | } |
7738 | |
7739 | if (psMemWrite) |
7740 | { |
7741 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80B; |
7742 | } |
7743 | |
7744 | break; |
7745 | } |
7746 | case 0x71: |
7747 | { |
7748 | sdwCyclesRemaining -= 19; |
7749 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7750 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7751 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7752 | while (psMemWrite->lowAddr != 0xffffffff) |
7753 | { |
7754 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7755 | { |
7756 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7757 | if (psMemWrite->memoryCall) |
7758 | { |
7759 | psMemWrite->memoryCall(sdwAddr, cpu.z80C, psMemWrite); |
7760 | } |
7761 | else |
7762 | { |
7763 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80C; |
7764 | } |
7765 | psMemWrite = NULL; |
7766 | break; |
7767 | } |
7768 | ++psMemWrite; |
7769 | } |
7770 | |
7771 | if (psMemWrite) |
7772 | { |
7773 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80C; |
7774 | } |
7775 | |
7776 | break; |
7777 | } |
7778 | case 0x72: |
7779 | { |
7780 | sdwCyclesRemaining -= 19; |
7781 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7782 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7783 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7784 | while (psMemWrite->lowAddr != 0xffffffff) |
7785 | { |
7786 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7787 | { |
7788 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7789 | if (psMemWrite->memoryCall) |
7790 | { |
7791 | psMemWrite->memoryCall(sdwAddr, cpu.z80D, psMemWrite); |
7792 | } |
7793 | else |
7794 | { |
7795 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80D; |
7796 | } |
7797 | psMemWrite = NULL; |
7798 | break; |
7799 | } |
7800 | ++psMemWrite; |
7801 | } |
7802 | |
7803 | if (psMemWrite) |
7804 | { |
7805 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80D; |
7806 | } |
7807 | |
7808 | break; |
7809 | } |
7810 | case 0x73: |
7811 | { |
7812 | sdwCyclesRemaining -= 19; |
7813 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7814 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7815 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7816 | while (psMemWrite->lowAddr != 0xffffffff) |
7817 | { |
7818 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7819 | { |
7820 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7821 | if (psMemWrite->memoryCall) |
7822 | { |
7823 | psMemWrite->memoryCall(sdwAddr, cpu.z80E, psMemWrite); |
7824 | } |
7825 | else |
7826 | { |
7827 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80E; |
7828 | } |
7829 | psMemWrite = NULL; |
7830 | break; |
7831 | } |
7832 | ++psMemWrite; |
7833 | } |
7834 | |
7835 | if (psMemWrite) |
7836 | { |
7837 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80E; |
7838 | } |
7839 | |
7840 | break; |
7841 | } |
7842 | case 0x74: |
7843 | { |
7844 | sdwCyclesRemaining -= 19; |
7845 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7846 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7847 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7848 | while (psMemWrite->lowAddr != 0xffffffff) |
7849 | { |
7850 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7851 | { |
7852 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7853 | if (psMemWrite->memoryCall) |
7854 | { |
7855 | psMemWrite->memoryCall(sdwAddr, cpu.z80H, psMemWrite); |
7856 | } |
7857 | else |
7858 | { |
7859 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80H; |
7860 | } |
7861 | psMemWrite = NULL; |
7862 | break; |
7863 | } |
7864 | ++psMemWrite; |
7865 | } |
7866 | |
7867 | if (psMemWrite) |
7868 | { |
7869 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80H; |
7870 | } |
7871 | |
7872 | break; |
7873 | } |
7874 | case 0x75: |
7875 | { |
7876 | sdwCyclesRemaining -= 19; |
7877 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7878 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7879 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7880 | while (psMemWrite->lowAddr != 0xffffffff) |
7881 | { |
7882 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7883 | { |
7884 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7885 | if (psMemWrite->memoryCall) |
7886 | { |
7887 | psMemWrite->memoryCall(sdwAddr, cpu.z80L, psMemWrite); |
7888 | } |
7889 | else |
7890 | { |
7891 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80L; |
7892 | } |
7893 | psMemWrite = NULL; |
7894 | break; |
7895 | } |
7896 | ++psMemWrite; |
7897 | } |
7898 | |
7899 | if (psMemWrite) |
7900 | { |
7901 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80L; |
7902 | } |
7903 | |
7904 | break; |
7905 | } |
7906 | case 0x76: |
7907 | { |
7908 | sdwCyclesRemaining -= 19; |
7909 | InvalidInstruction(2); |
7910 | break; |
7911 | } |
7912 | case 0x77: |
7913 | { |
7914 | sdwCyclesRemaining -= 19; |
7915 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7916 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7917 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
7918 | while (psMemWrite->lowAddr != 0xffffffff) |
7919 | { |
7920 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
7921 | { |
7922 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7923 | if (psMemWrite->memoryCall) |
7924 | { |
7925 | psMemWrite->memoryCall(sdwAddr, cpu.z80A, psMemWrite); |
7926 | } |
7927 | else |
7928 | { |
7929 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80A; |
7930 | } |
7931 | psMemWrite = NULL; |
7932 | break; |
7933 | } |
7934 | ++psMemWrite; |
7935 | } |
7936 | |
7937 | if (psMemWrite) |
7938 | { |
7939 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80A; |
7940 | } |
7941 | |
7942 | break; |
7943 | } |
7944 | case 0x78: |
7945 | { |
7946 | InvalidInstruction(2); |
7947 | break; |
7948 | } |
7949 | case 0x79: |
7950 | { |
7951 | InvalidInstruction(2); |
7952 | break; |
7953 | } |
7954 | case 0x7a: |
7955 | { |
7956 | InvalidInstruction(2); |
7957 | break; |
7958 | } |
7959 | case 0x7b: |
7960 | { |
7961 | InvalidInstruction(2); |
7962 | break; |
7963 | } |
7964 | case 0x7c: |
7965 | { |
7966 | sdwCyclesRemaining -= 9; |
7967 | cpu.z80A = cpu.z80XH; |
7968 | break; |
7969 | } |
7970 | case 0x7d: |
7971 | { |
7972 | sdwCyclesRemaining -= 9; |
7973 | cpu.z80A = cpu.z80XL; |
7974 | break; |
7975 | } |
7976 | case 0x7e: |
7977 | { |
7978 | sdwCyclesRemaining -= 19; |
7979 | sdwAddr = (INT8) *pbPC++; // Get the offset |
7980 | sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff; |
7981 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
7982 | while (psMemRead->lowAddr != 0xffffffff) |
7983 | { |
7984 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
7985 | { |
7986 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
7987 | if (psMemRead->memoryCall) |
7988 | { |
7989 | cpu.z80A = psMemRead->memoryCall(sdwAddr, psMemRead); |
7990 | } |
7991 | else |
7992 | { |
7993 | cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
7994 | } |
7995 | psMemRead = NULL; |
7996 | break; |
7997 | } |
7998 | ++psMemRead; |
7999 | } |
8000 | |
8001 | if (psMemRead) |
8002 | { |
8003 | cpu.z80A = cpu.z80Base[sdwAddr]; |
8004 | } |
8005 | |
8006 | break; |
8007 | } |
8008 | case 0x7f: |
8009 | { |
8010 | InvalidInstruction(2); |
8011 | break; |
8012 | } |
8013 | case 0x80: |
8014 | { |
8015 | InvalidInstruction(2); |
8016 | break; |
8017 | } |
8018 | case 0x81: |
8019 | { |
8020 | InvalidInstruction(2); |
8021 | break; |
8022 | } |
8023 | case 0x82: |
8024 | { |
8025 | InvalidInstruction(2); |
8026 | break; |
8027 | } |
8028 | case 0x83: |
8029 | { |
8030 | InvalidInstruction(2); |
8031 | break; |
8032 | } |
8033 | case 0x84: |
8034 | { |
8035 | sdwCyclesRemaining -= 9; |
8036 | bTemp2 = cpu.z80A + cpu.z80XH; |
8037 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8038 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8039 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH]; |
8040 | InvalidInstruction(2); |
8041 | break; |
8042 | } |
8043 | case 0x85: |
8044 | { |
8045 | sdwCyclesRemaining -= 9; |
8046 | bTemp2 = cpu.z80A + cpu.z80XL; |
8047 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8048 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8049 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL]; |
8050 | InvalidInstruction(2); |
8051 | break; |
8052 | } |
8053 | case 0x86: |
8054 | { |
8055 | sdwCyclesRemaining -= 19; |
8056 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8057 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8058 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8059 | while (psMemRead->lowAddr != 0xffffffff) |
8060 | { |
8061 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8062 | { |
8063 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8064 | if (psMemRead->memoryCall) |
8065 | { |
8066 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8067 | } |
8068 | else |
8069 | { |
8070 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8071 | } |
8072 | psMemRead = NULL; |
8073 | break; |
8074 | } |
8075 | ++psMemRead; |
8076 | } |
8077 | |
8078 | if (psMemRead) |
8079 | { |
8080 | bTemp = cpu.z80Base[dwAddr]; |
8081 | } |
8082 | |
8083 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8084 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8085 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
8086 | cpu.z80A += bTemp; |
8087 | break; |
8088 | } |
8089 | case 0x87: |
8090 | { |
8091 | InvalidInstruction(2); |
8092 | break; |
8093 | } |
8094 | case 0x88: |
8095 | { |
8096 | InvalidInstruction(2); |
8097 | break; |
8098 | } |
8099 | case 0x89: |
8100 | { |
8101 | InvalidInstruction(2); |
8102 | break; |
8103 | } |
8104 | case 0x8a: |
8105 | { |
8106 | InvalidInstruction(2); |
8107 | break; |
8108 | } |
8109 | case 0x8b: |
8110 | { |
8111 | InvalidInstruction(2); |
8112 | break; |
8113 | } |
8114 | case 0x8c: |
8115 | { |
8116 | sdwCyclesRemaining -= 9; |
8117 | bTemp2 = cpu.z80A + cpu.z80XH + (cpu.z80F & Z80_FLAG_CARRY); |
8118 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8119 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8120 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
8121 | InvalidInstruction(2); |
8122 | break; |
8123 | } |
8124 | case 0x8d: |
8125 | { |
8126 | sdwCyclesRemaining -= 9; |
8127 | bTemp2 = cpu.z80A + cpu.z80XL + (cpu.z80F & Z80_FLAG_CARRY); |
8128 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8129 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8130 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
8131 | InvalidInstruction(2); |
8132 | break; |
8133 | } |
8134 | case 0x8e: |
8135 | { |
8136 | sdwCyclesRemaining -= 19; |
8137 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8138 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8139 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8140 | while (psMemRead->lowAddr != 0xffffffff) |
8141 | { |
8142 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8143 | { |
8144 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8145 | if (psMemRead->memoryCall) |
8146 | { |
8147 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8148 | } |
8149 | else |
8150 | { |
8151 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8152 | } |
8153 | psMemRead = NULL; |
8154 | break; |
8155 | } |
8156 | ++psMemRead; |
8157 | } |
8158 | |
8159 | if (psMemRead) |
8160 | { |
8161 | bTemp = cpu.z80Base[dwAddr]; |
8162 | } |
8163 | |
8164 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY); |
8165 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8166 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8167 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
8168 | cpu.z80A += bTemp + bTemp2; |
8169 | break; |
8170 | } |
8171 | case 0x8f: |
8172 | { |
8173 | InvalidInstruction(2); |
8174 | break; |
8175 | } |
8176 | case 0x90: |
8177 | { |
8178 | InvalidInstruction(2); |
8179 | break; |
8180 | } |
8181 | case 0x91: |
8182 | { |
8183 | InvalidInstruction(2); |
8184 | break; |
8185 | } |
8186 | case 0x92: |
8187 | { |
8188 | InvalidInstruction(2); |
8189 | break; |
8190 | } |
8191 | case 0x93: |
8192 | { |
8193 | InvalidInstruction(2); |
8194 | break; |
8195 | } |
8196 | case 0x94: |
8197 | { |
8198 | sdwCyclesRemaining -= 9; |
8199 | bTemp2 = cpu.z80A - cpu.z80XH; |
8200 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8201 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8202 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH]; |
8203 | InvalidInstruction(2); |
8204 | break; |
8205 | } |
8206 | case 0x95: |
8207 | { |
8208 | sdwCyclesRemaining -= 9; |
8209 | bTemp2 = cpu.z80A - cpu.z80XL; |
8210 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8211 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8212 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL]; |
8213 | InvalidInstruction(2); |
8214 | break; |
8215 | } |
8216 | case 0x96: |
8217 | { |
8218 | sdwCyclesRemaining -= 19; |
8219 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8220 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8221 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8222 | while (psMemRead->lowAddr != 0xffffffff) |
8223 | { |
8224 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8225 | { |
8226 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8227 | if (psMemRead->memoryCall) |
8228 | { |
8229 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8230 | } |
8231 | else |
8232 | { |
8233 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8234 | } |
8235 | psMemRead = NULL; |
8236 | break; |
8237 | } |
8238 | ++psMemRead; |
8239 | } |
8240 | |
8241 | if (psMemRead) |
8242 | { |
8243 | bTemp = cpu.z80Base[dwAddr]; |
8244 | } |
8245 | |
8246 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8247 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8248 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
8249 | cpu.z80A -= bTemp; |
8250 | break; |
8251 | } |
8252 | case 0x97: |
8253 | { |
8254 | InvalidInstruction(2); |
8255 | break; |
8256 | } |
8257 | case 0x98: |
8258 | { |
8259 | InvalidInstruction(2); |
8260 | break; |
8261 | } |
8262 | case 0x99: |
8263 | { |
8264 | InvalidInstruction(2); |
8265 | break; |
8266 | } |
8267 | case 0x9a: |
8268 | { |
8269 | InvalidInstruction(2); |
8270 | break; |
8271 | } |
8272 | case 0x9b: |
8273 | { |
8274 | InvalidInstruction(2); |
8275 | break; |
8276 | } |
8277 | case 0x9c: |
8278 | { |
8279 | sdwCyclesRemaining -= 9; |
8280 | bTemp2 = cpu.z80A - cpu.z80XH - (cpu.z80F & Z80_FLAG_CARRY); |
8281 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8282 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8283 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
8284 | InvalidInstruction(2); |
8285 | break; |
8286 | } |
8287 | case 0x9d: |
8288 | { |
8289 | sdwCyclesRemaining -= 9; |
8290 | bTemp2 = cpu.z80A - cpu.z80XL - (cpu.z80F & Z80_FLAG_CARRY); |
8291 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8292 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8293 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
8294 | InvalidInstruction(2); |
8295 | break; |
8296 | } |
8297 | case 0x9e: |
8298 | { |
8299 | sdwCyclesRemaining -= 19; |
8300 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8301 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8302 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8303 | while (psMemRead->lowAddr != 0xffffffff) |
8304 | { |
8305 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8306 | { |
8307 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8308 | if (psMemRead->memoryCall) |
8309 | { |
8310 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8311 | } |
8312 | else |
8313 | { |
8314 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8315 | } |
8316 | psMemRead = NULL; |
8317 | break; |
8318 | } |
8319 | ++psMemRead; |
8320 | } |
8321 | |
8322 | if (psMemRead) |
8323 | { |
8324 | bTemp = cpu.z80Base[dwAddr]; |
8325 | } |
8326 | |
8327 | bTemp2 = cpu.z80A; |
8328 | cpu.z80A = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY); |
8329 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8330 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8331 | pbSubSbcTable[((UINT32) bTemp2 << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
8332 | break; |
8333 | } |
8334 | case 0x9f: |
8335 | { |
8336 | InvalidInstruction(2); |
8337 | break; |
8338 | } |
8339 | case 0xa0: |
8340 | { |
8341 | InvalidInstruction(2); |
8342 | break; |
8343 | } |
8344 | case 0xa1: |
8345 | { |
8346 | InvalidInstruction(2); |
8347 | break; |
8348 | } |
8349 | case 0xa2: |
8350 | { |
8351 | InvalidInstruction(2); |
8352 | break; |
8353 | } |
8354 | case 0xa3: |
8355 | { |
8356 | InvalidInstruction(2); |
8357 | break; |
8358 | } |
8359 | case 0xa4: |
8360 | { |
8361 | sdwCyclesRemaining -= 9; |
8362 | cpu.z80A &= cpu.z80XH; |
8363 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8364 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
8365 | |
8366 | InvalidInstruction(2); |
8367 | break; |
8368 | } |
8369 | case 0xa5: |
8370 | { |
8371 | sdwCyclesRemaining -= 9; |
8372 | cpu.z80A &= cpu.z80XL; |
8373 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8374 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
8375 | |
8376 | InvalidInstruction(2); |
8377 | break; |
8378 | } |
8379 | case 0xa6: |
8380 | { |
8381 | sdwCyclesRemaining -= 19; |
8382 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8383 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8384 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8385 | while (psMemRead->lowAddr != 0xffffffff) |
8386 | { |
8387 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8388 | { |
8389 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8390 | if (psMemRead->memoryCall) |
8391 | { |
8392 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8393 | } |
8394 | else |
8395 | { |
8396 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8397 | } |
8398 | psMemRead = NULL; |
8399 | break; |
8400 | } |
8401 | ++psMemRead; |
8402 | } |
8403 | |
8404 | if (psMemRead) |
8405 | { |
8406 | bTemp = cpu.z80Base[dwAddr]; |
8407 | } |
8408 | |
8409 | cpu.z80A &= bTemp; |
8410 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8411 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
8412 | |
8413 | break; |
8414 | } |
8415 | case 0xa7: |
8416 | { |
8417 | InvalidInstruction(2); |
8418 | break; |
8419 | } |
8420 | case 0xa8: |
8421 | { |
8422 | InvalidInstruction(2); |
8423 | break; |
8424 | } |
8425 | case 0xa9: |
8426 | { |
8427 | InvalidInstruction(2); |
8428 | break; |
8429 | } |
8430 | case 0xaa: |
8431 | { |
8432 | InvalidInstruction(2); |
8433 | break; |
8434 | } |
8435 | case 0xab: |
8436 | { |
8437 | InvalidInstruction(2); |
8438 | break; |
8439 | } |
8440 | case 0xac: |
8441 | { |
8442 | sdwCyclesRemaining -= 9; |
8443 | cpu.z80A ^= cpu.z80XH; |
8444 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8445 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8446 | |
8447 | InvalidInstruction(2); |
8448 | break; |
8449 | } |
8450 | case 0xad: |
8451 | { |
8452 | sdwCyclesRemaining -= 9; |
8453 | cpu.z80A ^= cpu.z80XL; |
8454 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8455 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8456 | |
8457 | InvalidInstruction(2); |
8458 | break; |
8459 | } |
8460 | case 0xae: |
8461 | { |
8462 | sdwCyclesRemaining -= 19; |
8463 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8464 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8465 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8466 | while (psMemRead->lowAddr != 0xffffffff) |
8467 | { |
8468 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8469 | { |
8470 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8471 | if (psMemRead->memoryCall) |
8472 | { |
8473 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8474 | } |
8475 | else |
8476 | { |
8477 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8478 | } |
8479 | psMemRead = NULL; |
8480 | break; |
8481 | } |
8482 | ++psMemRead; |
8483 | } |
8484 | |
8485 | if (psMemRead) |
8486 | { |
8487 | bTemp = cpu.z80Base[dwAddr]; |
8488 | } |
8489 | |
8490 | cpu.z80A ^= bTemp; |
8491 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8492 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8493 | |
8494 | break; |
8495 | } |
8496 | case 0xaf: |
8497 | { |
8498 | InvalidInstruction(2); |
8499 | break; |
8500 | } |
8501 | case 0xb0: |
8502 | { |
8503 | InvalidInstruction(2); |
8504 | break; |
8505 | } |
8506 | case 0xb1: |
8507 | { |
8508 | InvalidInstruction(2); |
8509 | break; |
8510 | } |
8511 | case 0xb2: |
8512 | { |
8513 | InvalidInstruction(2); |
8514 | break; |
8515 | } |
8516 | case 0xb3: |
8517 | { |
8518 | InvalidInstruction(2); |
8519 | break; |
8520 | } |
8521 | case 0xb4: |
8522 | { |
8523 | sdwCyclesRemaining -= 9; |
8524 | cpu.z80A |= cpu.z80XH; |
8525 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8526 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8527 | |
8528 | InvalidInstruction(2); |
8529 | break; |
8530 | } |
8531 | case 0xb5: |
8532 | { |
8533 | sdwCyclesRemaining -= 9; |
8534 | cpu.z80A |= cpu.z80XL; |
8535 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8536 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8537 | |
8538 | InvalidInstruction(2); |
8539 | break; |
8540 | } |
8541 | case 0xb6: |
8542 | { |
8543 | sdwCyclesRemaining -= 19; |
8544 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8545 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8546 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8547 | while (psMemRead->lowAddr != 0xffffffff) |
8548 | { |
8549 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8550 | { |
8551 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8552 | if (psMemRead->memoryCall) |
8553 | { |
8554 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8555 | } |
8556 | else |
8557 | { |
8558 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8559 | } |
8560 | psMemRead = NULL; |
8561 | break; |
8562 | } |
8563 | ++psMemRead; |
8564 | } |
8565 | |
8566 | if (psMemRead) |
8567 | { |
8568 | bTemp = cpu.z80Base[dwAddr]; |
8569 | } |
8570 | |
8571 | cpu.z80A |= bTemp; |
8572 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8573 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8574 | |
8575 | break; |
8576 | } |
8577 | case 0xb7: |
8578 | { |
8579 | InvalidInstruction(2); |
8580 | break; |
8581 | } |
8582 | case 0xb8: |
8583 | { |
8584 | InvalidInstruction(2); |
8585 | break; |
8586 | } |
8587 | case 0xb9: |
8588 | { |
8589 | InvalidInstruction(2); |
8590 | break; |
8591 | } |
8592 | case 0xba: |
8593 | { |
8594 | InvalidInstruction(2); |
8595 | break; |
8596 | } |
8597 | case 0xbb: |
8598 | { |
8599 | InvalidInstruction(2); |
8600 | break; |
8601 | } |
8602 | case 0xbc: |
8603 | { |
8604 | sdwCyclesRemaining -= 9; |
8605 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8606 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8607 | |
8608 | InvalidInstruction(2); |
8609 | break; |
8610 | } |
8611 | case 0xbd: |
8612 | { |
8613 | sdwCyclesRemaining -= 9; |
8614 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
8615 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
8616 | |
8617 | InvalidInstruction(2); |
8618 | break; |
8619 | } |
8620 | case 0xbe: |
8621 | { |
8622 | sdwCyclesRemaining -= 19; |
8623 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
8624 | dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff; |
8625 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8626 | while (psMemRead->lowAddr != 0xffffffff) |
8627 | { |
8628 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
8629 | { |
8630 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8631 | if (psMemRead->memoryCall) |
8632 | { |
8633 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
8634 | } |
8635 | else |
8636 | { |
8637 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
8638 | } |
8639 | psMemRead = NULL; |
8640 | break; |
8641 | } |
8642 | ++psMemRead; |
8643 | } |
8644 | |
8645 | if (psMemRead) |
8646 | { |
8647 | bTemp = cpu.z80Base[dwAddr]; |
8648 | } |
8649 | |
8650 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
8651 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
8652 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
8653 | break; |
8654 | } |
8655 | case 0xbf: |
8656 | { |
8657 | InvalidInstruction(2); |
8658 | break; |
8659 | } |
8660 | case 0xc0: |
8661 | { |
8662 | InvalidInstruction(2); |
8663 | break; |
8664 | } |
8665 | case 0xc1: |
8666 | { |
8667 | InvalidInstruction(2); |
8668 | break; |
8669 | } |
8670 | case 0xc2: |
8671 | { |
8672 | InvalidInstruction(2); |
8673 | break; |
8674 | } |
8675 | case 0xc3: |
8676 | { |
8677 | InvalidInstruction(2); |
8678 | break; |
8679 | } |
8680 | case 0xc4: |
8681 | { |
8682 | InvalidInstruction(2); |
8683 | break; |
8684 | } |
8685 | case 0xc5: |
8686 | { |
8687 | InvalidInstruction(2); |
8688 | break; |
8689 | } |
8690 | case 0xc6: |
8691 | { |
8692 | InvalidInstruction(2); |
8693 | break; |
8694 | } |
8695 | case 0xc7: |
8696 | { |
8697 | InvalidInstruction(2); |
8698 | break; |
8699 | } |
8700 | case 0xc8: |
8701 | { |
8702 | InvalidInstruction(2); |
8703 | break; |
8704 | } |
8705 | case 0xc9: |
8706 | { |
8707 | InvalidInstruction(2); |
8708 | break; |
8709 | } |
8710 | case 0xca: |
8711 | { |
8712 | InvalidInstruction(2); |
8713 | break; |
8714 | } |
8715 | case 0xcb: |
8716 | { |
8717 | DDFDCBHandler(0); |
8718 | break; |
8719 | } |
8720 | case 0xcc: |
8721 | { |
8722 | InvalidInstruction(2); |
8723 | break; |
8724 | } |
8725 | case 0xcd: |
8726 | { |
8727 | InvalidInstruction(2); |
8728 | break; |
8729 | } |
8730 | case 0xce: |
8731 | { |
8732 | InvalidInstruction(2); |
8733 | break; |
8734 | } |
8735 | case 0xcf: |
8736 | { |
8737 | InvalidInstruction(2); |
8738 | break; |
8739 | } |
8740 | case 0xd0: |
8741 | { |
8742 | InvalidInstruction(2); |
8743 | break; |
8744 | } |
8745 | case 0xd1: |
8746 | { |
8747 | InvalidInstruction(2); |
8748 | break; |
8749 | } |
8750 | case 0xd2: |
8751 | { |
8752 | InvalidInstruction(2); |
8753 | break; |
8754 | } |
8755 | case 0xd3: |
8756 | { |
8757 | InvalidInstruction(2); |
8758 | break; |
8759 | } |
8760 | case 0xd4: |
8761 | { |
8762 | InvalidInstruction(2); |
8763 | break; |
8764 | } |
8765 | case 0xd5: |
8766 | { |
8767 | InvalidInstruction(2); |
8768 | break; |
8769 | } |
8770 | case 0xd6: |
8771 | { |
8772 | InvalidInstruction(2); |
8773 | break; |
8774 | } |
8775 | case 0xd7: |
8776 | { |
8777 | InvalidInstruction(2); |
8778 | break; |
8779 | } |
8780 | case 0xd8: |
8781 | { |
8782 | InvalidInstruction(2); |
8783 | break; |
8784 | } |
8785 | case 0xd9: |
8786 | { |
8787 | InvalidInstruction(2); |
8788 | break; |
8789 | } |
8790 | case 0xda: |
8791 | { |
8792 | InvalidInstruction(2); |
8793 | break; |
8794 | } |
8795 | case 0xdb: |
8796 | { |
8797 | InvalidInstruction(2); |
8798 | break; |
8799 | } |
8800 | case 0xdc: |
8801 | { |
8802 | InvalidInstruction(2); |
8803 | break; |
8804 | } |
8805 | case 0xdd: |
8806 | { |
8807 | InvalidInstruction(2); |
8808 | break; |
8809 | } |
8810 | case 0xde: |
8811 | { |
8812 | InvalidInstruction(2); |
8813 | break; |
8814 | } |
8815 | case 0xdf: |
8816 | { |
8817 | InvalidInstruction(2); |
8818 | break; |
8819 | } |
8820 | case 0xe0: |
8821 | { |
8822 | InvalidInstruction(2); |
8823 | break; |
8824 | } |
8825 | case 0xe1: |
8826 | { |
8827 | sdwCyclesRemaining -= 14; |
8828 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8829 | while (psMemRead->lowAddr != 0xffffffff) |
8830 | { |
8831 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
8832 | { |
8833 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8834 | if (psMemRead->memoryCall) |
8835 | { |
8836 | cpu.z80IX = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
8837 | cpu.z80IX |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
8838 | } |
8839 | else |
8840 | { |
8841 | cpu.z80IX = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
8842 | cpu.z80IX |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
8843 | } |
8844 | psMemRead = NULL; |
8845 | break; |
8846 | } |
8847 | ++psMemRead; |
8848 | } |
8849 | |
8850 | if (psMemRead) |
8851 | { |
8852 | cpu.z80IX = cpu.z80Base[cpu.z80sp]; |
8853 | cpu.z80IX |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
8854 | } |
8855 | |
8856 | cpu.z80sp += 2; |
8857 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
8858 | break; |
8859 | } |
8860 | case 0xe2: |
8861 | { |
8862 | InvalidInstruction(2); |
8863 | break; |
8864 | } |
8865 | case 0xe3: |
8866 | { |
8867 | sdwCyclesRemaining -= 23; |
8868 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
8869 | while (psMemRead->lowAddr != 0xffffffff) |
8870 | { |
8871 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
8872 | { |
8873 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8874 | if (psMemRead->memoryCall) |
8875 | { |
8876 | dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
8877 | dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
8878 | } |
8879 | else |
8880 | { |
8881 | dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
8882 | dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
8883 | } |
8884 | psMemRead = NULL; |
8885 | break; |
8886 | } |
8887 | ++psMemRead; |
8888 | } |
8889 | |
8890 | if (psMemRead) |
8891 | { |
8892 | dwAddr = cpu.z80Base[cpu.z80sp]; |
8893 | dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
8894 | } |
8895 | |
8896 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
8897 | while (psMemWrite->lowAddr != 0xffffffff) |
8898 | { |
8899 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
8900 | { |
8901 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8902 | if (psMemWrite->memoryCall) |
8903 | { |
8904 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IX & 0xff), psMemWrite); |
8905 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IX >> 8), psMemWrite); |
8906 | } |
8907 | else |
8908 | { |
8909 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IX; |
8910 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8; |
8911 | } |
8912 | psMemWrite = NULL; |
8913 | break; |
8914 | } |
8915 | ++psMemWrite; |
8916 | } |
8917 | |
8918 | if (psMemWrite) |
8919 | { |
8920 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IX; |
8921 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8); |
8922 | } |
8923 | |
8924 | cpu.z80IX = dwAddr; |
8925 | break; |
8926 | } |
8927 | case 0xe4: |
8928 | { |
8929 | InvalidInstruction(2); |
8930 | break; |
8931 | } |
8932 | case 0xe5: |
8933 | { |
8934 | sdwCyclesRemaining -= 15; |
8935 | cpu.z80sp -= 2; |
8936 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
8937 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
8938 | while (psMemWrite->lowAddr != 0xffffffff) |
8939 | { |
8940 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
8941 | { |
8942 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
8943 | if (psMemWrite->memoryCall) |
8944 | { |
8945 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IX & 0xff), psMemWrite); |
8946 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IX >> 8), psMemWrite); |
8947 | } |
8948 | else |
8949 | { |
8950 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IX; |
8951 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8; |
8952 | } |
8953 | psMemWrite = NULL; |
8954 | break; |
8955 | } |
8956 | ++psMemWrite; |
8957 | } |
8958 | |
8959 | if (psMemWrite) |
8960 | { |
8961 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IX; |
8962 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8); |
8963 | } |
8964 | |
8965 | break; |
8966 | } |
8967 | case 0xe6: |
8968 | { |
8969 | InvalidInstruction(2); |
8970 | break; |
8971 | } |
8972 | case 0xe7: |
8973 | { |
8974 | InvalidInstruction(2); |
8975 | break; |
8976 | } |
8977 | case 0xe8: |
8978 | { |
8979 | InvalidInstruction(2); |
8980 | break; |
8981 | } |
8982 | case 0xe9: |
8983 | { |
8984 | sdwCyclesRemaining -= 8; |
8985 | pbPC = cpu.z80Base + cpu.z80IX; |
8986 | break; |
8987 | } |
8988 | case 0xea: |
8989 | { |
8990 | InvalidInstruction(2); |
8991 | break; |
8992 | } |
8993 | case 0xeb: |
8994 | { |
8995 | InvalidInstruction(2); |
8996 | break; |
8997 | } |
8998 | case 0xec: |
8999 | { |
9000 | InvalidInstruction(2); |
9001 | break; |
9002 | } |
9003 | case 0xed: |
9004 | { |
9005 | InvalidInstruction(2); |
9006 | break; |
9007 | } |
9008 | case 0xee: |
9009 | { |
9010 | InvalidInstruction(2); |
9011 | break; |
9012 | } |
9013 | case 0xef: |
9014 | { |
9015 | InvalidInstruction(2); |
9016 | break; |
9017 | } |
9018 | case 0xf0: |
9019 | { |
9020 | InvalidInstruction(2); |
9021 | break; |
9022 | } |
9023 | case 0xf1: |
9024 | { |
9025 | InvalidInstruction(2); |
9026 | break; |
9027 | } |
9028 | case 0xf2: |
9029 | { |
9030 | InvalidInstruction(2); |
9031 | break; |
9032 | } |
9033 | case 0xf3: |
9034 | { |
9035 | InvalidInstruction(2); |
9036 | break; |
9037 | } |
9038 | case 0xf4: |
9039 | { |
9040 | InvalidInstruction(2); |
9041 | break; |
9042 | } |
9043 | case 0xf5: |
9044 | { |
9045 | InvalidInstruction(2); |
9046 | break; |
9047 | } |
9048 | case 0xf6: |
9049 | { |
9050 | InvalidInstruction(2); |
9051 | break; |
9052 | } |
9053 | case 0xf7: |
9054 | { |
9055 | InvalidInstruction(2); |
9056 | break; |
9057 | } |
9058 | case 0xf8: |
9059 | { |
9060 | InvalidInstruction(2); |
9061 | break; |
9062 | } |
9063 | case 0xf9: |
9064 | { |
9065 | sdwCyclesRemaining -= 10; |
9066 | cpu.z80sp = cpu.z80IX; |
9067 | break; |
9068 | } |
9069 | case 0xfa: |
9070 | { |
9071 | InvalidInstruction(2); |
9072 | break; |
9073 | } |
9074 | case 0xfb: |
9075 | { |
9076 | InvalidInstruction(2); |
9077 | break; |
9078 | } |
9079 | case 0xfc: |
9080 | { |
9081 | InvalidInstruction(2); |
9082 | break; |
9083 | } |
9084 | case 0xfd: |
9085 | { |
9086 | InvalidInstruction(2); |
9087 | break; |
9088 | } |
9089 | case 0xfe: |
9090 | { |
9091 | InvalidInstruction(2); |
9092 | break; |
9093 | } |
9094 | case 0xff: |
9095 | { |
9096 | InvalidInstruction(2); |
9097 | break; |
9098 | } |
9099 | } |
9100 | } |
9101 | void DDFDCBHandler(UINT32 dwWhich) |
9102 | { |
9103 | if (dwWhich) |
9104 | { |
9105 | dwAddr = (UINT32) ((INT32) cpu.z80IY + ((INT32) *pbPC++)) & 0xffff; |
9106 | } |
9107 | else |
9108 | { |
9109 | dwAddr = (UINT32) ((INT32) cpu.z80IX + ((INT32) *pbPC++)) & 0xffff; |
9110 | } |
9111 | |
9112 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
9113 | while (psMemRead->lowAddr != 0xffffffff) |
9114 | { |
9115 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
9116 | { |
9117 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9118 | if (psMemRead->memoryCall) |
9119 | { |
9120 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
9121 | } |
9122 | else |
9123 | { |
9124 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
9125 | } |
9126 | psMemRead = NULL; |
9127 | break; |
9128 | } |
9129 | ++psMemRead; |
9130 | } |
9131 | |
9132 | if (psMemRead) |
9133 | { |
9134 | bTemp = cpu.z80Base[dwAddr]; |
9135 | } |
9136 | |
9137 | switch (*pbPC++) |
9138 | { |
9139 | case 0x00: |
9140 | { |
9141 | InvalidInstruction(4); |
9142 | break; |
9143 | } |
9144 | case 0x01: |
9145 | { |
9146 | InvalidInstruction(4); |
9147 | break; |
9148 | } |
9149 | case 0x02: |
9150 | { |
9151 | InvalidInstruction(4); |
9152 | break; |
9153 | } |
9154 | case 0x03: |
9155 | { |
9156 | InvalidInstruction(4); |
9157 | break; |
9158 | } |
9159 | case 0x04: |
9160 | { |
9161 | InvalidInstruction(4); |
9162 | break; |
9163 | } |
9164 | case 0x05: |
9165 | { |
9166 | InvalidInstruction(4); |
9167 | break; |
9168 | } |
9169 | case 0x06: |
9170 | { |
9171 | sdwCyclesRemaining -= 23; |
9172 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9173 | bTemp2 = (bTemp >> 7); |
9174 | bTemp = (bTemp << 1) | bTemp2; |
9175 | cpu.z80F |= bTemp2 | bPostORFlags[bTemp]; |
9176 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9177 | while (psMemWrite->lowAddr != 0xffffffff) |
9178 | { |
9179 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9180 | { |
9181 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9182 | if (psMemWrite->memoryCall) |
9183 | { |
9184 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9185 | } |
9186 | else |
9187 | { |
9188 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9189 | } |
9190 | psMemWrite = NULL; |
9191 | break; |
9192 | } |
9193 | ++psMemWrite; |
9194 | } |
9195 | |
9196 | if (psMemWrite) |
9197 | { |
9198 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9199 | } |
9200 | |
9201 | break; |
9202 | } |
9203 | case 0x07: |
9204 | { |
9205 | InvalidInstruction(4); |
9206 | break; |
9207 | } |
9208 | case 0x08: |
9209 | { |
9210 | InvalidInstruction(4); |
9211 | break; |
9212 | } |
9213 | case 0x09: |
9214 | { |
9215 | InvalidInstruction(4); |
9216 | break; |
9217 | } |
9218 | case 0x0a: |
9219 | { |
9220 | InvalidInstruction(4); |
9221 | break; |
9222 | } |
9223 | case 0x0b: |
9224 | { |
9225 | InvalidInstruction(4); |
9226 | break; |
9227 | } |
9228 | case 0x0c: |
9229 | { |
9230 | InvalidInstruction(4); |
9231 | break; |
9232 | } |
9233 | case 0x0d: |
9234 | { |
9235 | InvalidInstruction(4); |
9236 | break; |
9237 | } |
9238 | case 0x0e: |
9239 | { |
9240 | sdwCyclesRemaining -= 23; |
9241 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9242 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
9243 | bTemp = (bTemp >> 1) | (bTemp << 7); |
9244 | cpu.z80F |= bPostORFlags[bTemp]; |
9245 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9246 | while (psMemWrite->lowAddr != 0xffffffff) |
9247 | { |
9248 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9249 | { |
9250 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9251 | if (psMemWrite->memoryCall) |
9252 | { |
9253 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9254 | } |
9255 | else |
9256 | { |
9257 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9258 | } |
9259 | psMemWrite = NULL; |
9260 | break; |
9261 | } |
9262 | ++psMemWrite; |
9263 | } |
9264 | |
9265 | if (psMemWrite) |
9266 | { |
9267 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9268 | } |
9269 | |
9270 | break; |
9271 | } |
9272 | case 0x0f: |
9273 | { |
9274 | InvalidInstruction(4); |
9275 | break; |
9276 | } |
9277 | case 0x10: |
9278 | { |
9279 | InvalidInstruction(4); |
9280 | break; |
9281 | } |
9282 | case 0x11: |
9283 | { |
9284 | InvalidInstruction(4); |
9285 | break; |
9286 | } |
9287 | case 0x12: |
9288 | { |
9289 | InvalidInstruction(4); |
9290 | break; |
9291 | } |
9292 | case 0x13: |
9293 | { |
9294 | InvalidInstruction(4); |
9295 | break; |
9296 | } |
9297 | case 0x14: |
9298 | { |
9299 | InvalidInstruction(4); |
9300 | break; |
9301 | } |
9302 | case 0x15: |
9303 | { |
9304 | InvalidInstruction(4); |
9305 | break; |
9306 | } |
9307 | case 0x16: |
9308 | { |
9309 | sdwCyclesRemaining -= 23; |
9310 | bTemp2 = cpu.z80F & Z80_FLAG_CARRY; |
9311 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9312 | cpu.z80F |= (bTemp >> 7); |
9313 | bTemp = (bTemp << 1) | bTemp2; |
9314 | cpu.z80F |= bPostORFlags[bTemp]; |
9315 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9316 | while (psMemWrite->lowAddr != 0xffffffff) |
9317 | { |
9318 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9319 | { |
9320 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9321 | if (psMemWrite->memoryCall) |
9322 | { |
9323 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9324 | } |
9325 | else |
9326 | { |
9327 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9328 | } |
9329 | psMemWrite = NULL; |
9330 | break; |
9331 | } |
9332 | ++psMemWrite; |
9333 | } |
9334 | |
9335 | if (psMemWrite) |
9336 | { |
9337 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9338 | } |
9339 | |
9340 | break; |
9341 | } |
9342 | case 0x17: |
9343 | { |
9344 | InvalidInstruction(4); |
9345 | break; |
9346 | } |
9347 | case 0x18: |
9348 | { |
9349 | InvalidInstruction(4); |
9350 | break; |
9351 | } |
9352 | case 0x19: |
9353 | { |
9354 | InvalidInstruction(4); |
9355 | break; |
9356 | } |
9357 | case 0x1a: |
9358 | { |
9359 | InvalidInstruction(4); |
9360 | break; |
9361 | } |
9362 | case 0x1b: |
9363 | { |
9364 | InvalidInstruction(4); |
9365 | break; |
9366 | } |
9367 | case 0x1c: |
9368 | { |
9369 | InvalidInstruction(4); |
9370 | break; |
9371 | } |
9372 | case 0x1d: |
9373 | { |
9374 | InvalidInstruction(4); |
9375 | break; |
9376 | } |
9377 | case 0x1e: |
9378 | { |
9379 | sdwCyclesRemaining -= 23; |
9380 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
9381 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9382 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
9383 | bTemp = (bTemp >> 1) | bTemp2; |
9384 | cpu.z80F |= bPostORFlags[bTemp]; |
9385 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9386 | while (psMemWrite->lowAddr != 0xffffffff) |
9387 | { |
9388 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9389 | { |
9390 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9391 | if (psMemWrite->memoryCall) |
9392 | { |
9393 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9394 | } |
9395 | else |
9396 | { |
9397 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9398 | } |
9399 | psMemWrite = NULL; |
9400 | break; |
9401 | } |
9402 | ++psMemWrite; |
9403 | } |
9404 | |
9405 | if (psMemWrite) |
9406 | { |
9407 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9408 | } |
9409 | |
9410 | break; |
9411 | } |
9412 | case 0x1f: |
9413 | { |
9414 | InvalidInstruction(4); |
9415 | break; |
9416 | } |
9417 | case 0x20: |
9418 | { |
9419 | InvalidInstruction(4); |
9420 | break; |
9421 | } |
9422 | case 0x21: |
9423 | { |
9424 | InvalidInstruction(4); |
9425 | break; |
9426 | } |
9427 | case 0x22: |
9428 | { |
9429 | InvalidInstruction(4); |
9430 | break; |
9431 | } |
9432 | case 0x23: |
9433 | { |
9434 | InvalidInstruction(4); |
9435 | break; |
9436 | } |
9437 | case 0x24: |
9438 | { |
9439 | InvalidInstruction(4); |
9440 | break; |
9441 | } |
9442 | case 0x25: |
9443 | { |
9444 | InvalidInstruction(4); |
9445 | break; |
9446 | } |
9447 | case 0x26: |
9448 | { |
9449 | sdwCyclesRemaining -= 23; |
9450 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9451 | cpu.z80F |= (bTemp >> 7); |
9452 | bTemp = (bTemp << 1); |
9453 | cpu.z80F |= bPostORFlags[bTemp]; |
9454 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9455 | while (psMemWrite->lowAddr != 0xffffffff) |
9456 | { |
9457 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9458 | { |
9459 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9460 | if (psMemWrite->memoryCall) |
9461 | { |
9462 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9463 | } |
9464 | else |
9465 | { |
9466 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9467 | } |
9468 | psMemWrite = NULL; |
9469 | break; |
9470 | } |
9471 | ++psMemWrite; |
9472 | } |
9473 | |
9474 | if (psMemWrite) |
9475 | { |
9476 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9477 | } |
9478 | |
9479 | break; |
9480 | } |
9481 | case 0x27: |
9482 | { |
9483 | InvalidInstruction(4); |
9484 | break; |
9485 | } |
9486 | case 0x28: |
9487 | { |
9488 | InvalidInstruction(4); |
9489 | break; |
9490 | } |
9491 | case 0x29: |
9492 | { |
9493 | InvalidInstruction(4); |
9494 | break; |
9495 | } |
9496 | case 0x2a: |
9497 | { |
9498 | InvalidInstruction(4); |
9499 | break; |
9500 | } |
9501 | case 0x2b: |
9502 | { |
9503 | InvalidInstruction(4); |
9504 | break; |
9505 | } |
9506 | case 0x2c: |
9507 | { |
9508 | InvalidInstruction(4); |
9509 | break; |
9510 | } |
9511 | case 0x2d: |
9512 | { |
9513 | InvalidInstruction(4); |
9514 | break; |
9515 | } |
9516 | case 0x2e: |
9517 | { |
9518 | sdwCyclesRemaining -= 23; |
9519 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9520 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
9521 | bTemp = (bTemp >> 1) | (bTemp & 0x80); |
9522 | cpu.z80F |= bPostORFlags[bTemp]; |
9523 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9524 | while (psMemWrite->lowAddr != 0xffffffff) |
9525 | { |
9526 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9527 | { |
9528 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9529 | if (psMemWrite->memoryCall) |
9530 | { |
9531 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9532 | } |
9533 | else |
9534 | { |
9535 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9536 | } |
9537 | psMemWrite = NULL; |
9538 | break; |
9539 | } |
9540 | ++psMemWrite; |
9541 | } |
9542 | |
9543 | if (psMemWrite) |
9544 | { |
9545 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9546 | } |
9547 | |
9548 | break; |
9549 | } |
9550 | case 0x2f: |
9551 | { |
9552 | InvalidInstruction(4); |
9553 | break; |
9554 | } |
9555 | case 0x30: |
9556 | { |
9557 | InvalidInstruction(4); |
9558 | break; |
9559 | } |
9560 | case 0x31: |
9561 | { |
9562 | InvalidInstruction(4); |
9563 | break; |
9564 | } |
9565 | case 0x32: |
9566 | { |
9567 | InvalidInstruction(4); |
9568 | break; |
9569 | } |
9570 | case 0x33: |
9571 | { |
9572 | InvalidInstruction(4); |
9573 | break; |
9574 | } |
9575 | case 0x34: |
9576 | { |
9577 | InvalidInstruction(4); |
9578 | break; |
9579 | } |
9580 | case 0x35: |
9581 | { |
9582 | InvalidInstruction(4); |
9583 | break; |
9584 | } |
9585 | case 0x36: |
9586 | { |
9587 | sdwCyclesRemaining -= 23; |
9588 | InvalidInstruction(4); |
9589 | break; |
9590 | } |
9591 | case 0x37: |
9592 | { |
9593 | InvalidInstruction(4); |
9594 | break; |
9595 | } |
9596 | case 0x38: |
9597 | { |
9598 | InvalidInstruction(4); |
9599 | break; |
9600 | } |
9601 | case 0x39: |
9602 | { |
9603 | InvalidInstruction(4); |
9604 | break; |
9605 | } |
9606 | case 0x3a: |
9607 | { |
9608 | InvalidInstruction(4); |
9609 | break; |
9610 | } |
9611 | case 0x3b: |
9612 | { |
9613 | InvalidInstruction(4); |
9614 | break; |
9615 | } |
9616 | case 0x3c: |
9617 | { |
9618 | InvalidInstruction(4); |
9619 | break; |
9620 | } |
9621 | case 0x3d: |
9622 | { |
9623 | InvalidInstruction(4); |
9624 | break; |
9625 | } |
9626 | case 0x3e: |
9627 | { |
9628 | sdwCyclesRemaining -= 23; |
9629 | cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY); |
9630 | cpu.z80F |= (bTemp & Z80_FLAG_CARRY); |
9631 | bTemp = (bTemp >> 1); |
9632 | cpu.z80F |= bPostORFlags[bTemp]; |
9633 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
9634 | while (psMemWrite->lowAddr != 0xffffffff) |
9635 | { |
9636 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
9637 | { |
9638 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
9639 | if (psMemWrite->memoryCall) |
9640 | { |
9641 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
9642 | } |
9643 | else |
9644 | { |
9645 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
9646 | } |
9647 | psMemWrite = NULL; |
9648 | break; |
9649 | } |
9650 | ++psMemWrite; |
9651 | } |
9652 | |
9653 | if (psMemWrite) |
9654 | { |
9655 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
9656 | } |
9657 | |
9658 | break; |
9659 | } |
9660 | case 0x3f: |
9661 | { |
9662 | InvalidInstruction(4); |
9663 | break; |
9664 | } |
9665 | case 0x40: |
9666 | { |
9667 | sdwCyclesRemaining -= 20; |
9668 | InvalidInstruction(4); |
9669 | break; |
9670 | } |
9671 | case 0x41: |
9672 | { |
9673 | sdwCyclesRemaining -= 20; |
9674 | InvalidInstruction(4); |
9675 | break; |
9676 | } |
9677 | case 0x42: |
9678 | { |
9679 | sdwCyclesRemaining -= 20; |
9680 | InvalidInstruction(4); |
9681 | break; |
9682 | } |
9683 | case 0x43: |
9684 | { |
9685 | sdwCyclesRemaining -= 20; |
9686 | InvalidInstruction(4); |
9687 | break; |
9688 | } |
9689 | case 0x44: |
9690 | { |
9691 | sdwCyclesRemaining -= 20; |
9692 | InvalidInstruction(4); |
9693 | break; |
9694 | } |
9695 | case 0x45: |
9696 | { |
9697 | sdwCyclesRemaining -= 20; |
9698 | InvalidInstruction(4); |
9699 | break; |
9700 | } |
9701 | case 0x46: |
9702 | { |
9703 | sdwCyclesRemaining -= 20; |
9704 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
9705 | if (!(bTemp & 0x01)) |
9706 | { |
9707 | cpu.z80F |= Z80_FLAG_ZERO; |
9708 | } |
9709 | break; |
9710 | } |
9711 | case 0x47: |
9712 | { |
9713 | sdwCyclesRemaining -= 20; |
9714 | InvalidInstruction(4); |
9715 | break; |
9716 | } |
9717 | case 0x48: |
9718 | { |
9719 | sdwCyclesRemaining -= 20; |
9720 | InvalidInstruction(4); |
9721 | break; |
9722 | } |
9723 | case 0x49: |
9724 | { |
9725 | sdwCyclesRemaining -= 20; |
9726 | InvalidInstruction(4); |
9727 | break; |
9728 | } |
9729 | case 0x4a: |
9730 | { |
9731 | sdwCyclesRemaining -= 20; |
9732 | InvalidInstruction(4); |
9733 | break; |
9734 | } |
9735 | case 0x4b: |
9736 | { |
9737 | sdwCyclesRemaining -= 20; |
9738 | InvalidInstruction(4); |
9739 | break; |
9740 | } |
9741 | case 0x4c: |
9742 | { |
9743 | sdwCyclesRemaining -= 20; |
9744 | InvalidInstruction(4); |
9745 | break; |
9746 | } |
9747 | case 0x4d: |
9748 | { |
9749 | sdwCyclesRemaining -= 20; |
9750 | InvalidInstruction(4); |
9751 | break; |
9752 | } |
9753 | case 0x4e: |
9754 | { |
9755 | sdwCyclesRemaining -= 20; |
9756 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
9757 | if (!(bTemp & 0x02)) |
9758 | { |
9759 | cpu.z80F |= Z80_FLAG_ZERO; |
9760 | } |
9761 | break; |
9762 | } |
9763 | case 0x4f: |
9764 | { |
9765 | sdwCyclesRemaining -= 20; |
9766 | InvalidInstruction(4); |
9767 | break; |
9768 | } |
9769 | case 0x50: |
9770 | { |
9771 | sdwCyclesRemaining -= 20; |
9772 | InvalidInstruction(4); |
9773 | break; |
9774 | } |
9775 | case 0x51: |
9776 | { |
9777 | sdwCyclesRemaining -= 20; |
9778 | InvalidInstruction(4); |
9779 | break; |
9780 | } |
9781 | case 0x52: |
9782 | { |
9783 | sdwCyclesRemaining -= 20; |
9784 | InvalidInstruction(4); |
9785 | break; |
9786 | } |
9787 | case 0x53: |
9788 | { |
9789 | sdwCyclesRemaining -= 20; |
9790 | InvalidInstruction(4); |
9791 | break; |
9792 | } |
9793 | case 0x54: |
9794 | { |
9795 | sdwCyclesRemaining -= 20; |
9796 | InvalidInstruction(4); |
9797 | break; |
9798 | } |
9799 | case 0x55: |
9800 | { |
9801 | sdwCyclesRemaining -= 20; |
9802 | InvalidInstruction(4); |
9803 | break; |
9804 | } |
9805 | case 0x56: |
9806 | { |
9807 | sdwCyclesRemaining -= 20; |
9808 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
9809 | if (!(bTemp & 0x04)) |
9810 | { |
9811 | cpu.z80F |= Z80_FLAG_ZERO; |
9812 | } |
9813 | break; |
9814 | } |
9815 | case 0x57: |
9816 | { |
9817 | sdwCyclesRemaining -= 20; |
9818 | InvalidInstruction(4); |
9819 | break; |
9820 | } |
9821 | case 0x58: |
9822 | { |
9823 | sdwCyclesRemaining -= 20; |
9824 | InvalidInstruction(4); |
9825 | break; |
9826 | } |
9827 | case 0x59: |
9828 | { |
9829 | sdwCyclesRemaining -= 20; |
9830 | InvalidInstruction(4); |
9831 | break; |
9832 | } |
9833 | case 0x5a: |
9834 | { |
9835 | sdwCyclesRemaining -= 20; |
9836 | InvalidInstruction(4); |
9837 | break; |
9838 | } |
9839 | case 0x5b: |
9840 | { |
9841 | sdwCyclesRemaining -= 20; |
9842 | InvalidInstruction(4); |
9843 | break; |
9844 | } |
9845 | case 0x5c: |
9846 | { |
9847 | sdwCyclesRemaining -= 20; |
9848 | InvalidInstruction(4); |
9849 | break; |
9850 | } |
9851 | case 0x5d: |
9852 | { |
9853 | sdwCyclesRemaining -= 20; |
9854 | InvalidInstruction(4); |
9855 | break; |
9856 | } |
9857 | case 0x5e: |
9858 | { |
9859 | sdwCyclesRemaining -= 20; |
9860 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
9861 | if (!(bTemp & 0x08)) |
9862 | { |
9863 | cpu.z80F |= Z80_FLAG_ZERO; |
9864 | } |
9865 | break; |
9866 | } |
9867 | case 0x5f: |
9868 | { |
9869 | sdwCyclesRemaining -= 20; |
9870 | InvalidInstruction(4); |
9871 | break; |
9872 | } |
9873 | case 0x60: |
9874 | { |
9875 | sdwCyclesRemaining -= 20; |
9876 | InvalidInstruction(4); |
9877 | break; |
9878 | } |
9879 | case 0x61: |
9880 | { |
9881 | sdwCyclesRemaining -= 20; |
9882 | InvalidInstruction(4); |
9883 | break; |
9884 | } |
9885 | case 0x62: |
9886 | { |
9887 | sdwCyclesRemaining -= 20; |
9888 | InvalidInstruction(4); |
9889 | break; |
9890 | } |
9891 | case 0x63: |
9892 | { |
9893 | sdwCyclesRemaining -= 20; |
9894 | InvalidInstruction(4); |
9895 | break; |
9896 | } |
9897 | case 0x64: |
9898 | { |
9899 | sdwCyclesRemaining -= 20; |
9900 | InvalidInstruction(4); |
9901 | break; |
9902 | } |
9903 | case 0x65: |
9904 | { |
9905 | sdwCyclesRemaining -= 20; |
9906 | InvalidInstruction(4); |
9907 | break; |
9908 | } |
9909 | case 0x66: |
9910 | { |
9911 | sdwCyclesRemaining -= 20; |
9912 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
9913 | if (!(bTemp & 0x10)) |
9914 | { |
9915 | cpu.z80F |= Z80_FLAG_ZERO; |
9916 | } |
9917 | break; |
9918 | } |
9919 | case 0x67: |
9920 | { |
9921 | sdwCyclesRemaining -= 20; |
9922 | InvalidInstruction(4); |
9923 | break; |
9924 | } |
9925 | case 0x68: |
9926 | { |
9927 | sdwCyclesRemaining -= 20; |
9928 | InvalidInstruction(4); |
9929 | break; |
9930 | } |
9931 | case 0x69: |
9932 | { |
9933 | sdwCyclesRemaining -= 20; |
9934 | InvalidInstruction(4); |
9935 | break; |
9936 | } |
9937 | case 0x6a: |
9938 | { |
9939 | sdwCyclesRemaining -= 20; |
9940 | InvalidInstruction(4); |
9941 | break; |
9942 | } |
9943 | case 0x6b: |
9944 | { |
9945 | sdwCyclesRemaining -= 20; |
9946 | InvalidInstruction(4); |
9947 | break; |
9948 | } |
9949 | case 0x6c: |
9950 | { |
9951 | sdwCyclesRemaining -= 20; |
9952 | InvalidInstruction(4); |
9953 | break; |
9954 | } |
9955 | case 0x6d: |
9956 | { |
9957 | sdwCyclesRemaining -= 20; |
9958 | InvalidInstruction(4); |
9959 | break; |
9960 | } |
9961 | case 0x6e: |
9962 | { |
9963 | sdwCyclesRemaining -= 20; |
9964 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
9965 | if (!(bTemp & 0x20)) |
9966 | { |
9967 | cpu.z80F |= Z80_FLAG_ZERO; |
9968 | } |
9969 | break; |
9970 | } |
9971 | case 0x6f: |
9972 | { |
9973 | sdwCyclesRemaining -= 20; |
9974 | InvalidInstruction(4); |
9975 | break; |
9976 | } |
9977 | case 0x70: |
9978 | { |
9979 | sdwCyclesRemaining -= 20; |
9980 | InvalidInstruction(4); |
9981 | break; |
9982 | } |
9983 | case 0x71: |
9984 | { |
9985 | sdwCyclesRemaining -= 20; |
9986 | InvalidInstruction(4); |
9987 | break; |
9988 | } |
9989 | case 0x72: |
9990 | { |
9991 | sdwCyclesRemaining -= 20; |
9992 | InvalidInstruction(4); |
9993 | break; |
9994 | } |
9995 | case 0x73: |
9996 | { |
9997 | sdwCyclesRemaining -= 20; |
9998 | InvalidInstruction(4); |
9999 | break; |
10000 | } |
10001 | case 0x74: |
10002 | { |
10003 | sdwCyclesRemaining -= 20; |
10004 | InvalidInstruction(4); |
10005 | break; |
10006 | } |
10007 | case 0x75: |
10008 | { |
10009 | sdwCyclesRemaining -= 20; |
10010 | InvalidInstruction(4); |
10011 | break; |
10012 | } |
10013 | case 0x76: |
10014 | { |
10015 | sdwCyclesRemaining -= 20; |
10016 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
10017 | if (!(bTemp & 0x40)) |
10018 | { |
10019 | cpu.z80F |= Z80_FLAG_ZERO; |
10020 | } |
10021 | break; |
10022 | } |
10023 | case 0x77: |
10024 | { |
10025 | sdwCyclesRemaining -= 20; |
10026 | InvalidInstruction(4); |
10027 | break; |
10028 | } |
10029 | case 0x78: |
10030 | { |
10031 | sdwCyclesRemaining -= 20; |
10032 | InvalidInstruction(4); |
10033 | break; |
10034 | } |
10035 | case 0x79: |
10036 | { |
10037 | sdwCyclesRemaining -= 20; |
10038 | InvalidInstruction(4); |
10039 | break; |
10040 | } |
10041 | case 0x7a: |
10042 | { |
10043 | sdwCyclesRemaining -= 20; |
10044 | InvalidInstruction(4); |
10045 | break; |
10046 | } |
10047 | case 0x7b: |
10048 | { |
10049 | sdwCyclesRemaining -= 20; |
10050 | InvalidInstruction(4); |
10051 | break; |
10052 | } |
10053 | case 0x7c: |
10054 | { |
10055 | sdwCyclesRemaining -= 20; |
10056 | InvalidInstruction(4); |
10057 | break; |
10058 | } |
10059 | case 0x7d: |
10060 | { |
10061 | sdwCyclesRemaining -= 20; |
10062 | InvalidInstruction(4); |
10063 | break; |
10064 | } |
10065 | case 0x7e: |
10066 | { |
10067 | sdwCyclesRemaining -= 20; |
10068 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY; |
10069 | if (!(bTemp & 0x80)) |
10070 | { |
10071 | cpu.z80F |= Z80_FLAG_ZERO; |
10072 | } |
10073 | break; |
10074 | } |
10075 | case 0x7f: |
10076 | { |
10077 | sdwCyclesRemaining -= 20; |
10078 | InvalidInstruction(4); |
10079 | break; |
10080 | } |
10081 | case 0x80: |
10082 | { |
10083 | InvalidInstruction(4); |
10084 | break; |
10085 | } |
10086 | case 0x81: |
10087 | { |
10088 | InvalidInstruction(4); |
10089 | break; |
10090 | } |
10091 | case 0x82: |
10092 | { |
10093 | InvalidInstruction(4); |
10094 | break; |
10095 | } |
10096 | case 0x83: |
10097 | { |
10098 | InvalidInstruction(4); |
10099 | break; |
10100 | } |
10101 | case 0x84: |
10102 | { |
10103 | InvalidInstruction(4); |
10104 | break; |
10105 | } |
10106 | case 0x85: |
10107 | { |
10108 | InvalidInstruction(4); |
10109 | break; |
10110 | } |
10111 | case 0x86: |
10112 | { |
10113 | sdwCyclesRemaining -= 23; |
10114 | bTemp &= 0xfe; |
10115 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10116 | while (psMemWrite->lowAddr != 0xffffffff) |
10117 | { |
10118 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10119 | { |
10120 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10121 | if (psMemWrite->memoryCall) |
10122 | { |
10123 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10124 | } |
10125 | else |
10126 | { |
10127 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10128 | } |
10129 | psMemWrite = NULL; |
10130 | break; |
10131 | } |
10132 | ++psMemWrite; |
10133 | } |
10134 | |
10135 | if (psMemWrite) |
10136 | { |
10137 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10138 | } |
10139 | |
10140 | break; |
10141 | } |
10142 | case 0x87: |
10143 | { |
10144 | InvalidInstruction(4); |
10145 | break; |
10146 | } |
10147 | case 0x88: |
10148 | { |
10149 | InvalidInstruction(4); |
10150 | break; |
10151 | } |
10152 | case 0x89: |
10153 | { |
10154 | InvalidInstruction(4); |
10155 | break; |
10156 | } |
10157 | case 0x8a: |
10158 | { |
10159 | InvalidInstruction(4); |
10160 | break; |
10161 | } |
10162 | case 0x8b: |
10163 | { |
10164 | InvalidInstruction(4); |
10165 | break; |
10166 | } |
10167 | case 0x8c: |
10168 | { |
10169 | InvalidInstruction(4); |
10170 | break; |
10171 | } |
10172 | case 0x8d: |
10173 | { |
10174 | InvalidInstruction(4); |
10175 | break; |
10176 | } |
10177 | case 0x8e: |
10178 | { |
10179 | sdwCyclesRemaining -= 23; |
10180 | bTemp &= 0xfd; |
10181 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10182 | while (psMemWrite->lowAddr != 0xffffffff) |
10183 | { |
10184 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10185 | { |
10186 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10187 | if (psMemWrite->memoryCall) |
10188 | { |
10189 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10190 | } |
10191 | else |
10192 | { |
10193 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10194 | } |
10195 | psMemWrite = NULL; |
10196 | break; |
10197 | } |
10198 | ++psMemWrite; |
10199 | } |
10200 | |
10201 | if (psMemWrite) |
10202 | { |
10203 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10204 | } |
10205 | |
10206 | break; |
10207 | } |
10208 | case 0x8f: |
10209 | { |
10210 | InvalidInstruction(4); |
10211 | break; |
10212 | } |
10213 | case 0x90: |
10214 | { |
10215 | InvalidInstruction(4); |
10216 | break; |
10217 | } |
10218 | case 0x91: |
10219 | { |
10220 | InvalidInstruction(4); |
10221 | break; |
10222 | } |
10223 | case 0x92: |
10224 | { |
10225 | InvalidInstruction(4); |
10226 | break; |
10227 | } |
10228 | case 0x93: |
10229 | { |
10230 | InvalidInstruction(4); |
10231 | break; |
10232 | } |
10233 | case 0x94: |
10234 | { |
10235 | InvalidInstruction(4); |
10236 | break; |
10237 | } |
10238 | case 0x95: |
10239 | { |
10240 | InvalidInstruction(4); |
10241 | break; |
10242 | } |
10243 | case 0x96: |
10244 | { |
10245 | sdwCyclesRemaining -= 23; |
10246 | bTemp &= 0xfb; |
10247 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10248 | while (psMemWrite->lowAddr != 0xffffffff) |
10249 | { |
10250 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10251 | { |
10252 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10253 | if (psMemWrite->memoryCall) |
10254 | { |
10255 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10256 | } |
10257 | else |
10258 | { |
10259 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10260 | } |
10261 | psMemWrite = NULL; |
10262 | break; |
10263 | } |
10264 | ++psMemWrite; |
10265 | } |
10266 | |
10267 | if (psMemWrite) |
10268 | { |
10269 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10270 | } |
10271 | |
10272 | break; |
10273 | } |
10274 | case 0x97: |
10275 | { |
10276 | InvalidInstruction(4); |
10277 | break; |
10278 | } |
10279 | case 0x98: |
10280 | { |
10281 | InvalidInstruction(4); |
10282 | break; |
10283 | } |
10284 | case 0x99: |
10285 | { |
10286 | InvalidInstruction(4); |
10287 | break; |
10288 | } |
10289 | case 0x9a: |
10290 | { |
10291 | InvalidInstruction(4); |
10292 | break; |
10293 | } |
10294 | case 0x9b: |
10295 | { |
10296 | InvalidInstruction(4); |
10297 | break; |
10298 | } |
10299 | case 0x9c: |
10300 | { |
10301 | InvalidInstruction(4); |
10302 | break; |
10303 | } |
10304 | case 0x9d: |
10305 | { |
10306 | InvalidInstruction(4); |
10307 | break; |
10308 | } |
10309 | case 0x9e: |
10310 | { |
10311 | sdwCyclesRemaining -= 23; |
10312 | bTemp &= 0xf7; |
10313 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10314 | while (psMemWrite->lowAddr != 0xffffffff) |
10315 | { |
10316 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10317 | { |
10318 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10319 | if (psMemWrite->memoryCall) |
10320 | { |
10321 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10322 | } |
10323 | else |
10324 | { |
10325 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10326 | } |
10327 | psMemWrite = NULL; |
10328 | break; |
10329 | } |
10330 | ++psMemWrite; |
10331 | } |
10332 | |
10333 | if (psMemWrite) |
10334 | { |
10335 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10336 | } |
10337 | |
10338 | break; |
10339 | } |
10340 | case 0x9f: |
10341 | { |
10342 | InvalidInstruction(4); |
10343 | break; |
10344 | } |
10345 | case 0xa0: |
10346 | { |
10347 | InvalidInstruction(4); |
10348 | break; |
10349 | } |
10350 | case 0xa1: |
10351 | { |
10352 | InvalidInstruction(4); |
10353 | break; |
10354 | } |
10355 | case 0xa2: |
10356 | { |
10357 | InvalidInstruction(4); |
10358 | break; |
10359 | } |
10360 | case 0xa3: |
10361 | { |
10362 | InvalidInstruction(4); |
10363 | break; |
10364 | } |
10365 | case 0xa4: |
10366 | { |
10367 | InvalidInstruction(4); |
10368 | break; |
10369 | } |
10370 | case 0xa5: |
10371 | { |
10372 | InvalidInstruction(4); |
10373 | break; |
10374 | } |
10375 | case 0xa6: |
10376 | { |
10377 | sdwCyclesRemaining -= 23; |
10378 | bTemp &= 0xef; |
10379 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10380 | while (psMemWrite->lowAddr != 0xffffffff) |
10381 | { |
10382 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10383 | { |
10384 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10385 | if (psMemWrite->memoryCall) |
10386 | { |
10387 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10388 | } |
10389 | else |
10390 | { |
10391 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10392 | } |
10393 | psMemWrite = NULL; |
10394 | break; |
10395 | } |
10396 | ++psMemWrite; |
10397 | } |
10398 | |
10399 | if (psMemWrite) |
10400 | { |
10401 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10402 | } |
10403 | |
10404 | break; |
10405 | } |
10406 | case 0xa7: |
10407 | { |
10408 | InvalidInstruction(4); |
10409 | break; |
10410 | } |
10411 | case 0xa8: |
10412 | { |
10413 | InvalidInstruction(4); |
10414 | break; |
10415 | } |
10416 | case 0xa9: |
10417 | { |
10418 | InvalidInstruction(4); |
10419 | break; |
10420 | } |
10421 | case 0xaa: |
10422 | { |
10423 | InvalidInstruction(4); |
10424 | break; |
10425 | } |
10426 | case 0xab: |
10427 | { |
10428 | InvalidInstruction(4); |
10429 | break; |
10430 | } |
10431 | case 0xac: |
10432 | { |
10433 | InvalidInstruction(4); |
10434 | break; |
10435 | } |
10436 | case 0xad: |
10437 | { |
10438 | InvalidInstruction(4); |
10439 | break; |
10440 | } |
10441 | case 0xae: |
10442 | { |
10443 | sdwCyclesRemaining -= 23; |
10444 | bTemp &= 0xdf; |
10445 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10446 | while (psMemWrite->lowAddr != 0xffffffff) |
10447 | { |
10448 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10449 | { |
10450 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10451 | if (psMemWrite->memoryCall) |
10452 | { |
10453 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10454 | } |
10455 | else |
10456 | { |
10457 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10458 | } |
10459 | psMemWrite = NULL; |
10460 | break; |
10461 | } |
10462 | ++psMemWrite; |
10463 | } |
10464 | |
10465 | if (psMemWrite) |
10466 | { |
10467 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10468 | } |
10469 | |
10470 | break; |
10471 | } |
10472 | case 0xaf: |
10473 | { |
10474 | InvalidInstruction(4); |
10475 | break; |
10476 | } |
10477 | case 0xb0: |
10478 | { |
10479 | InvalidInstruction(4); |
10480 | break; |
10481 | } |
10482 | case 0xb1: |
10483 | { |
10484 | InvalidInstruction(4); |
10485 | break; |
10486 | } |
10487 | case 0xb2: |
10488 | { |
10489 | InvalidInstruction(4); |
10490 | break; |
10491 | } |
10492 | case 0xb3: |
10493 | { |
10494 | InvalidInstruction(4); |
10495 | break; |
10496 | } |
10497 | case 0xb4: |
10498 | { |
10499 | InvalidInstruction(4); |
10500 | break; |
10501 | } |
10502 | case 0xb5: |
10503 | { |
10504 | InvalidInstruction(4); |
10505 | break; |
10506 | } |
10507 | case 0xb6: |
10508 | { |
10509 | sdwCyclesRemaining -= 23; |
10510 | bTemp &= 0xbf; |
10511 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10512 | while (psMemWrite->lowAddr != 0xffffffff) |
10513 | { |
10514 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10515 | { |
10516 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10517 | if (psMemWrite->memoryCall) |
10518 | { |
10519 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10520 | } |
10521 | else |
10522 | { |
10523 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10524 | } |
10525 | psMemWrite = NULL; |
10526 | break; |
10527 | } |
10528 | ++psMemWrite; |
10529 | } |
10530 | |
10531 | if (psMemWrite) |
10532 | { |
10533 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10534 | } |
10535 | |
10536 | break; |
10537 | } |
10538 | case 0xb7: |
10539 | { |
10540 | InvalidInstruction(4); |
10541 | break; |
10542 | } |
10543 | case 0xb8: |
10544 | { |
10545 | InvalidInstruction(4); |
10546 | break; |
10547 | } |
10548 | case 0xb9: |
10549 | { |
10550 | InvalidInstruction(4); |
10551 | break; |
10552 | } |
10553 | case 0xba: |
10554 | { |
10555 | InvalidInstruction(4); |
10556 | break; |
10557 | } |
10558 | case 0xbb: |
10559 | { |
10560 | InvalidInstruction(4); |
10561 | break; |
10562 | } |
10563 | case 0xbc: |
10564 | { |
10565 | InvalidInstruction(4); |
10566 | break; |
10567 | } |
10568 | case 0xbd: |
10569 | { |
10570 | InvalidInstruction(4); |
10571 | break; |
10572 | } |
10573 | case 0xbe: |
10574 | { |
10575 | sdwCyclesRemaining -= 23; |
10576 | bTemp &= 0x7f; |
10577 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10578 | while (psMemWrite->lowAddr != 0xffffffff) |
10579 | { |
10580 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10581 | { |
10582 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10583 | if (psMemWrite->memoryCall) |
10584 | { |
10585 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10586 | } |
10587 | else |
10588 | { |
10589 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10590 | } |
10591 | psMemWrite = NULL; |
10592 | break; |
10593 | } |
10594 | ++psMemWrite; |
10595 | } |
10596 | |
10597 | if (psMemWrite) |
10598 | { |
10599 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10600 | } |
10601 | |
10602 | break; |
10603 | } |
10604 | case 0xbf: |
10605 | { |
10606 | InvalidInstruction(4); |
10607 | break; |
10608 | } |
10609 | case 0xc0: |
10610 | { |
10611 | InvalidInstruction(4); |
10612 | break; |
10613 | } |
10614 | case 0xc1: |
10615 | { |
10616 | InvalidInstruction(4); |
10617 | break; |
10618 | } |
10619 | case 0xc2: |
10620 | { |
10621 | InvalidInstruction(4); |
10622 | break; |
10623 | } |
10624 | case 0xc3: |
10625 | { |
10626 | InvalidInstruction(4); |
10627 | break; |
10628 | } |
10629 | case 0xc4: |
10630 | { |
10631 | InvalidInstruction(4); |
10632 | break; |
10633 | } |
10634 | case 0xc5: |
10635 | { |
10636 | InvalidInstruction(4); |
10637 | break; |
10638 | } |
10639 | case 0xc6: |
10640 | { |
10641 | sdwCyclesRemaining -= 23; |
10642 | bTemp |= 0x01; |
10643 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10644 | while (psMemWrite->lowAddr != 0xffffffff) |
10645 | { |
10646 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10647 | { |
10648 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10649 | if (psMemWrite->memoryCall) |
10650 | { |
10651 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10652 | } |
10653 | else |
10654 | { |
10655 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10656 | } |
10657 | psMemWrite = NULL; |
10658 | break; |
10659 | } |
10660 | ++psMemWrite; |
10661 | } |
10662 | |
10663 | if (psMemWrite) |
10664 | { |
10665 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10666 | } |
10667 | |
10668 | break; |
10669 | } |
10670 | case 0xc7: |
10671 | { |
10672 | InvalidInstruction(4); |
10673 | break; |
10674 | } |
10675 | case 0xc8: |
10676 | { |
10677 | InvalidInstruction(4); |
10678 | break; |
10679 | } |
10680 | case 0xc9: |
10681 | { |
10682 | InvalidInstruction(4); |
10683 | break; |
10684 | } |
10685 | case 0xca: |
10686 | { |
10687 | InvalidInstruction(4); |
10688 | break; |
10689 | } |
10690 | case 0xcb: |
10691 | { |
10692 | InvalidInstruction(4); |
10693 | break; |
10694 | } |
10695 | case 0xcc: |
10696 | { |
10697 | InvalidInstruction(4); |
10698 | break; |
10699 | } |
10700 | case 0xcd: |
10701 | { |
10702 | InvalidInstruction(4); |
10703 | break; |
10704 | } |
10705 | case 0xce: |
10706 | { |
10707 | sdwCyclesRemaining -= 23; |
10708 | bTemp |= 0x02; |
10709 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10710 | while (psMemWrite->lowAddr != 0xffffffff) |
10711 | { |
10712 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10713 | { |
10714 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10715 | if (psMemWrite->memoryCall) |
10716 | { |
10717 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10718 | } |
10719 | else |
10720 | { |
10721 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10722 | } |
10723 | psMemWrite = NULL; |
10724 | break; |
10725 | } |
10726 | ++psMemWrite; |
10727 | } |
10728 | |
10729 | if (psMemWrite) |
10730 | { |
10731 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10732 | } |
10733 | |
10734 | break; |
10735 | } |
10736 | case 0xcf: |
10737 | { |
10738 | InvalidInstruction(4); |
10739 | break; |
10740 | } |
10741 | case 0xd0: |
10742 | { |
10743 | InvalidInstruction(4); |
10744 | break; |
10745 | } |
10746 | case 0xd1: |
10747 | { |
10748 | InvalidInstruction(4); |
10749 | break; |
10750 | } |
10751 | case 0xd2: |
10752 | { |
10753 | InvalidInstruction(4); |
10754 | break; |
10755 | } |
10756 | case 0xd3: |
10757 | { |
10758 | InvalidInstruction(4); |
10759 | break; |
10760 | } |
10761 | case 0xd4: |
10762 | { |
10763 | InvalidInstruction(4); |
10764 | break; |
10765 | } |
10766 | case 0xd5: |
10767 | { |
10768 | InvalidInstruction(4); |
10769 | break; |
10770 | } |
10771 | case 0xd6: |
10772 | { |
10773 | sdwCyclesRemaining -= 23; |
10774 | bTemp |= 0x04; |
10775 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10776 | while (psMemWrite->lowAddr != 0xffffffff) |
10777 | { |
10778 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10779 | { |
10780 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10781 | if (psMemWrite->memoryCall) |
10782 | { |
10783 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10784 | } |
10785 | else |
10786 | { |
10787 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10788 | } |
10789 | psMemWrite = NULL; |
10790 | break; |
10791 | } |
10792 | ++psMemWrite; |
10793 | } |
10794 | |
10795 | if (psMemWrite) |
10796 | { |
10797 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10798 | } |
10799 | |
10800 | break; |
10801 | } |
10802 | case 0xd7: |
10803 | { |
10804 | InvalidInstruction(4); |
10805 | break; |
10806 | } |
10807 | case 0xd8: |
10808 | { |
10809 | InvalidInstruction(4); |
10810 | break; |
10811 | } |
10812 | case 0xd9: |
10813 | { |
10814 | InvalidInstruction(4); |
10815 | break; |
10816 | } |
10817 | case 0xda: |
10818 | { |
10819 | InvalidInstruction(4); |
10820 | break; |
10821 | } |
10822 | case 0xdb: |
10823 | { |
10824 | InvalidInstruction(4); |
10825 | break; |
10826 | } |
10827 | case 0xdc: |
10828 | { |
10829 | InvalidInstruction(4); |
10830 | break; |
10831 | } |
10832 | case 0xdd: |
10833 | { |
10834 | InvalidInstruction(4); |
10835 | break; |
10836 | } |
10837 | case 0xde: |
10838 | { |
10839 | sdwCyclesRemaining -= 23; |
10840 | bTemp |= 0x08; |
10841 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10842 | while (psMemWrite->lowAddr != 0xffffffff) |
10843 | { |
10844 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10845 | { |
10846 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10847 | if (psMemWrite->memoryCall) |
10848 | { |
10849 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10850 | } |
10851 | else |
10852 | { |
10853 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10854 | } |
10855 | psMemWrite = NULL; |
10856 | break; |
10857 | } |
10858 | ++psMemWrite; |
10859 | } |
10860 | |
10861 | if (psMemWrite) |
10862 | { |
10863 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10864 | } |
10865 | |
10866 | break; |
10867 | } |
10868 | case 0xdf: |
10869 | { |
10870 | InvalidInstruction(4); |
10871 | break; |
10872 | } |
10873 | case 0xe0: |
10874 | { |
10875 | InvalidInstruction(4); |
10876 | break; |
10877 | } |
10878 | case 0xe1: |
10879 | { |
10880 | InvalidInstruction(4); |
10881 | break; |
10882 | } |
10883 | case 0xe2: |
10884 | { |
10885 | InvalidInstruction(4); |
10886 | break; |
10887 | } |
10888 | case 0xe3: |
10889 | { |
10890 | InvalidInstruction(4); |
10891 | break; |
10892 | } |
10893 | case 0xe4: |
10894 | { |
10895 | InvalidInstruction(4); |
10896 | break; |
10897 | } |
10898 | case 0xe5: |
10899 | { |
10900 | InvalidInstruction(4); |
10901 | break; |
10902 | } |
10903 | case 0xe6: |
10904 | { |
10905 | sdwCyclesRemaining -= 23; |
10906 | bTemp |= 0x10; |
10907 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10908 | while (psMemWrite->lowAddr != 0xffffffff) |
10909 | { |
10910 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10911 | { |
10912 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10913 | if (psMemWrite->memoryCall) |
10914 | { |
10915 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10916 | } |
10917 | else |
10918 | { |
10919 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10920 | } |
10921 | psMemWrite = NULL; |
10922 | break; |
10923 | } |
10924 | ++psMemWrite; |
10925 | } |
10926 | |
10927 | if (psMemWrite) |
10928 | { |
10929 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10930 | } |
10931 | |
10932 | break; |
10933 | } |
10934 | case 0xe7: |
10935 | { |
10936 | InvalidInstruction(4); |
10937 | break; |
10938 | } |
10939 | case 0xe8: |
10940 | { |
10941 | InvalidInstruction(4); |
10942 | break; |
10943 | } |
10944 | case 0xe9: |
10945 | { |
10946 | InvalidInstruction(4); |
10947 | break; |
10948 | } |
10949 | case 0xea: |
10950 | { |
10951 | InvalidInstruction(4); |
10952 | break; |
10953 | } |
10954 | case 0xeb: |
10955 | { |
10956 | InvalidInstruction(4); |
10957 | break; |
10958 | } |
10959 | case 0xec: |
10960 | { |
10961 | InvalidInstruction(4); |
10962 | break; |
10963 | } |
10964 | case 0xed: |
10965 | { |
10966 | InvalidInstruction(4); |
10967 | break; |
10968 | } |
10969 | case 0xee: |
10970 | { |
10971 | sdwCyclesRemaining -= 23; |
10972 | bTemp |= 0x20; |
10973 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
10974 | while (psMemWrite->lowAddr != 0xffffffff) |
10975 | { |
10976 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
10977 | { |
10978 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
10979 | if (psMemWrite->memoryCall) |
10980 | { |
10981 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
10982 | } |
10983 | else |
10984 | { |
10985 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
10986 | } |
10987 | psMemWrite = NULL; |
10988 | break; |
10989 | } |
10990 | ++psMemWrite; |
10991 | } |
10992 | |
10993 | if (psMemWrite) |
10994 | { |
10995 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
10996 | } |
10997 | |
10998 | break; |
10999 | } |
11000 | case 0xef: |
11001 | { |
11002 | InvalidInstruction(4); |
11003 | break; |
11004 | } |
11005 | case 0xf0: |
11006 | { |
11007 | InvalidInstruction(4); |
11008 | break; |
11009 | } |
11010 | case 0xf1: |
11011 | { |
11012 | InvalidInstruction(4); |
11013 | break; |
11014 | } |
11015 | case 0xf2: |
11016 | { |
11017 | InvalidInstruction(4); |
11018 | break; |
11019 | } |
11020 | case 0xf3: |
11021 | { |
11022 | InvalidInstruction(4); |
11023 | break; |
11024 | } |
11025 | case 0xf4: |
11026 | { |
11027 | InvalidInstruction(4); |
11028 | break; |
11029 | } |
11030 | case 0xf5: |
11031 | { |
11032 | InvalidInstruction(4); |
11033 | break; |
11034 | } |
11035 | case 0xf6: |
11036 | { |
11037 | sdwCyclesRemaining -= 23; |
11038 | bTemp |= 0x40; |
11039 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
11040 | while (psMemWrite->lowAddr != 0xffffffff) |
11041 | { |
11042 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
11043 | { |
11044 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11045 | if (psMemWrite->memoryCall) |
11046 | { |
11047 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
11048 | } |
11049 | else |
11050 | { |
11051 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
11052 | } |
11053 | psMemWrite = NULL; |
11054 | break; |
11055 | } |
11056 | ++psMemWrite; |
11057 | } |
11058 | |
11059 | if (psMemWrite) |
11060 | { |
11061 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
11062 | } |
11063 | |
11064 | break; |
11065 | } |
11066 | case 0xf7: |
11067 | { |
11068 | InvalidInstruction(4); |
11069 | break; |
11070 | } |
11071 | case 0xf8: |
11072 | { |
11073 | InvalidInstruction(4); |
11074 | break; |
11075 | } |
11076 | case 0xf9: |
11077 | { |
11078 | InvalidInstruction(4); |
11079 | break; |
11080 | } |
11081 | case 0xfa: |
11082 | { |
11083 | InvalidInstruction(4); |
11084 | break; |
11085 | } |
11086 | case 0xfb: |
11087 | { |
11088 | InvalidInstruction(4); |
11089 | break; |
11090 | } |
11091 | case 0xfc: |
11092 | { |
11093 | InvalidInstruction(4); |
11094 | break; |
11095 | } |
11096 | case 0xfd: |
11097 | { |
11098 | InvalidInstruction(4); |
11099 | break; |
11100 | } |
11101 | case 0xfe: |
11102 | { |
11103 | sdwCyclesRemaining -= 23; |
11104 | bTemp |= 0x80; |
11105 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
11106 | while (psMemWrite->lowAddr != 0xffffffff) |
11107 | { |
11108 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
11109 | { |
11110 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11111 | if (psMemWrite->memoryCall) |
11112 | { |
11113 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
11114 | } |
11115 | else |
11116 | { |
11117 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
11118 | } |
11119 | psMemWrite = NULL; |
11120 | break; |
11121 | } |
11122 | ++psMemWrite; |
11123 | } |
11124 | |
11125 | if (psMemWrite) |
11126 | { |
11127 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
11128 | } |
11129 | |
11130 | break; |
11131 | } |
11132 | case 0xff: |
11133 | { |
11134 | InvalidInstruction(4); |
11135 | break; |
11136 | } |
11137 | } |
11138 | } |
11139 | void FDHandler(void) |
11140 | { |
11141 | switch (*pbPC++) |
11142 | { |
11143 | case 0x00: |
11144 | { |
11145 | InvalidInstruction(2); |
11146 | break; |
11147 | } |
11148 | case 0x01: |
11149 | { |
11150 | InvalidInstruction(2); |
11151 | break; |
11152 | } |
11153 | case 0x02: |
11154 | { |
11155 | InvalidInstruction(2); |
11156 | break; |
11157 | } |
11158 | case 0x03: |
11159 | { |
11160 | InvalidInstruction(2); |
11161 | break; |
11162 | } |
11163 | case 0x04: |
11164 | { |
11165 | InvalidInstruction(2); |
11166 | break; |
11167 | } |
11168 | case 0x05: |
11169 | { |
11170 | InvalidInstruction(2); |
11171 | break; |
11172 | } |
11173 | case 0x06: |
11174 | { |
11175 | InvalidInstruction(2); |
11176 | break; |
11177 | } |
11178 | case 0x07: |
11179 | { |
11180 | InvalidInstruction(2); |
11181 | break; |
11182 | } |
11183 | case 0x08: |
11184 | { |
11185 | InvalidInstruction(2); |
11186 | break; |
11187 | } |
11188 | case 0x09: |
11189 | { |
11190 | sdwCyclesRemaining -= 15; |
11191 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
11192 | dwTemp = cpu.z80IY + cpu.z80BC; |
11193 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY); |
11194 | cpu.z80IY = dwTemp & 0xffff; |
11195 | break; |
11196 | } |
11197 | case 0x0a: |
11198 | { |
11199 | InvalidInstruction(2); |
11200 | break; |
11201 | } |
11202 | case 0x0b: |
11203 | { |
11204 | InvalidInstruction(2); |
11205 | break; |
11206 | } |
11207 | case 0x0c: |
11208 | { |
11209 | InvalidInstruction(2); |
11210 | break; |
11211 | } |
11212 | case 0x0d: |
11213 | { |
11214 | InvalidInstruction(2); |
11215 | break; |
11216 | } |
11217 | case 0x0e: |
11218 | { |
11219 | InvalidInstruction(2); |
11220 | break; |
11221 | } |
11222 | case 0x0f: |
11223 | { |
11224 | InvalidInstruction(2); |
11225 | break; |
11226 | } |
11227 | case 0x10: |
11228 | { |
11229 | InvalidInstruction(2); |
11230 | break; |
11231 | } |
11232 | case 0x11: |
11233 | { |
11234 | InvalidInstruction(2); |
11235 | break; |
11236 | } |
11237 | case 0x12: |
11238 | { |
11239 | InvalidInstruction(2); |
11240 | break; |
11241 | } |
11242 | case 0x13: |
11243 | { |
11244 | InvalidInstruction(2); |
11245 | break; |
11246 | } |
11247 | case 0x14: |
11248 | { |
11249 | InvalidInstruction(2); |
11250 | break; |
11251 | } |
11252 | case 0x15: |
11253 | { |
11254 | InvalidInstruction(2); |
11255 | break; |
11256 | } |
11257 | case 0x16: |
11258 | { |
11259 | InvalidInstruction(2); |
11260 | break; |
11261 | } |
11262 | case 0x17: |
11263 | { |
11264 | InvalidInstruction(2); |
11265 | break; |
11266 | } |
11267 | case 0x18: |
11268 | { |
11269 | InvalidInstruction(2); |
11270 | break; |
11271 | } |
11272 | case 0x19: |
11273 | { |
11274 | sdwCyclesRemaining -= 15; |
11275 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
11276 | dwTemp = cpu.z80IY + cpu.z80DE; |
11277 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY); |
11278 | cpu.z80IY = dwTemp & 0xffff; |
11279 | break; |
11280 | } |
11281 | case 0x1a: |
11282 | { |
11283 | InvalidInstruction(2); |
11284 | break; |
11285 | } |
11286 | case 0x1b: |
11287 | { |
11288 | InvalidInstruction(2); |
11289 | break; |
11290 | } |
11291 | case 0x1c: |
11292 | { |
11293 | InvalidInstruction(2); |
11294 | break; |
11295 | } |
11296 | case 0x1d: |
11297 | { |
11298 | InvalidInstruction(2); |
11299 | break; |
11300 | } |
11301 | case 0x1e: |
11302 | { |
11303 | InvalidInstruction(2); |
11304 | break; |
11305 | } |
11306 | case 0x1f: |
11307 | { |
11308 | InvalidInstruction(2); |
11309 | break; |
11310 | } |
11311 | case 0x20: |
11312 | { |
11313 | InvalidInstruction(2); |
11314 | break; |
11315 | } |
11316 | case 0x21: |
11317 | { |
11318 | sdwCyclesRemaining -= 14; |
11319 | cpu.z80IY = *pbPC++; |
11320 | cpu.z80IY |= ((UINT32) *pbPC++ << 8); |
11321 | break; |
11322 | } |
11323 | case 0x22: |
11324 | { |
11325 | sdwCyclesRemaining -= 20; |
11326 | dwAddr = *pbPC++; |
11327 | dwAddr |= ((UINT32) *pbPC++ << 8); |
11328 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
11329 | while (psMemWrite->lowAddr != 0xffffffff) |
11330 | { |
11331 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
11332 | { |
11333 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11334 | if (psMemWrite->memoryCall) |
11335 | { |
11336 | psMemWrite->memoryCall(dwAddr, (cpu.z80IY & 0xff), psMemWrite); |
11337 | psMemWrite->memoryCall(dwAddr + 1, (cpu.z80IY >> 8), psMemWrite); |
11338 | } |
11339 | else |
11340 | { |
11341 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = cpu.z80IY; |
11342 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8; |
11343 | } |
11344 | psMemWrite = NULL; |
11345 | break; |
11346 | } |
11347 | ++psMemWrite; |
11348 | } |
11349 | |
11350 | if (psMemWrite) |
11351 | { |
11352 | cpu.z80Base[dwAddr] = (UINT8) cpu.z80IY; |
11353 | cpu.z80Base[dwAddr + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8); |
11354 | } |
11355 | |
11356 | break; |
11357 | } |
11358 | case 0x23: |
11359 | { |
11360 | sdwCyclesRemaining -= 10; |
11361 | cpu.z80IY++; |
11362 | cpu.z80IY &= 0xffff; |
11363 | break; |
11364 | } |
11365 | case 0x24: |
11366 | { |
11367 | sdwCyclesRemaining -= 9; |
11368 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
11369 | cpu.z80F |= bPostIncFlags[cpu.z80YH++]; |
11370 | break; |
11371 | } |
11372 | case 0x25: |
11373 | { |
11374 | sdwCyclesRemaining -= 9; |
11375 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
11376 | cpu.z80F |= bPostDecFlags[cpu.z80YH--]; |
11377 | break; |
11378 | } |
11379 | case 0x26: |
11380 | { |
11381 | sdwCyclesRemaining -= 9; |
11382 | cpu.z80YH = *pbPC++; |
11383 | break; |
11384 | } |
11385 | case 0x27: |
11386 | { |
11387 | InvalidInstruction(2); |
11388 | break; |
11389 | } |
11390 | case 0x28: |
11391 | { |
11392 | InvalidInstruction(2); |
11393 | break; |
11394 | } |
11395 | case 0x29: |
11396 | { |
11397 | sdwCyclesRemaining -= 15; |
11398 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
11399 | dwTemp = cpu.z80IY + cpu.z80IY; |
11400 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY); |
11401 | cpu.z80IY = dwTemp & 0xffff; |
11402 | break; |
11403 | } |
11404 | case 0x2a: |
11405 | { |
11406 | sdwCyclesRemaining -= 20; |
11407 | dwAddr = *pbPC++; |
11408 | dwAddr |= ((UINT32) *pbPC++ << 8); |
11409 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11410 | while (psMemRead->lowAddr != 0xffffffff) |
11411 | { |
11412 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
11413 | { |
11414 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11415 | if (psMemRead->memoryCall) |
11416 | { |
11417 | cpu.z80IY = psMemRead->memoryCall(dwAddr, psMemRead); |
11418 | cpu.z80IY |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8); |
11419 | } |
11420 | else |
11421 | { |
11422 | cpu.z80IY = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
11423 | cpu.z80IY |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8); |
11424 | } |
11425 | psMemRead = NULL; |
11426 | break; |
11427 | } |
11428 | ++psMemRead; |
11429 | } |
11430 | |
11431 | if (psMemRead) |
11432 | { |
11433 | cpu.z80IY = cpu.z80Base[dwAddr]; |
11434 | cpu.z80IY |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8); |
11435 | } |
11436 | |
11437 | break; |
11438 | } |
11439 | case 0x2b: |
11440 | { |
11441 | sdwCyclesRemaining -= 10; |
11442 | cpu.z80IY--; |
11443 | cpu.z80IY &= 0xffff; |
11444 | break; |
11445 | } |
11446 | case 0x2c: |
11447 | { |
11448 | sdwCyclesRemaining -= 9; |
11449 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
11450 | cpu.z80F |= bPostIncFlags[cpu.z80YL++]; |
11451 | break; |
11452 | } |
11453 | case 0x2d: |
11454 | { |
11455 | sdwCyclesRemaining -= 9; |
11456 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
11457 | cpu.z80F |= bPostDecFlags[cpu.z80YL--]; |
11458 | break; |
11459 | } |
11460 | case 0x2e: |
11461 | { |
11462 | sdwCyclesRemaining -= 9; |
11463 | cpu.z80YL = *pbPC++; |
11464 | break; |
11465 | } |
11466 | case 0x2f: |
11467 | { |
11468 | InvalidInstruction(2); |
11469 | break; |
11470 | } |
11471 | case 0x30: |
11472 | { |
11473 | InvalidInstruction(2); |
11474 | break; |
11475 | } |
11476 | case 0x31: |
11477 | { |
11478 | InvalidInstruction(2); |
11479 | break; |
11480 | } |
11481 | case 0x32: |
11482 | { |
11483 | InvalidInstruction(2); |
11484 | break; |
11485 | } |
11486 | case 0x33: |
11487 | { |
11488 | InvalidInstruction(2); |
11489 | break; |
11490 | } |
11491 | case 0x34: |
11492 | { |
11493 | sdwCyclesRemaining -= 23; |
11494 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
11495 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
11496 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11497 | while (psMemRead->lowAddr != 0xffffffff) |
11498 | { |
11499 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
11500 | { |
11501 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11502 | if (psMemRead->memoryCall) |
11503 | { |
11504 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
11505 | } |
11506 | else |
11507 | { |
11508 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
11509 | } |
11510 | psMemRead = NULL; |
11511 | break; |
11512 | } |
11513 | ++psMemRead; |
11514 | } |
11515 | |
11516 | if (psMemRead) |
11517 | { |
11518 | bTemp = cpu.z80Base[dwAddr]; |
11519 | } |
11520 | |
11521 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
11522 | cpu.z80F |= bPostIncFlags[bTemp++]; |
11523 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
11524 | while (psMemWrite->lowAddr != 0xffffffff) |
11525 | { |
11526 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
11527 | { |
11528 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11529 | if (psMemWrite->memoryCall) |
11530 | { |
11531 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
11532 | } |
11533 | else |
11534 | { |
11535 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
11536 | } |
11537 | psMemWrite = NULL; |
11538 | break; |
11539 | } |
11540 | ++psMemWrite; |
11541 | } |
11542 | |
11543 | if (psMemWrite) |
11544 | { |
11545 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
11546 | } |
11547 | |
11548 | break; |
11549 | } |
11550 | case 0x35: |
11551 | { |
11552 | sdwCyclesRemaining -= 23; |
11553 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
11554 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
11555 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11556 | while (psMemRead->lowAddr != 0xffffffff) |
11557 | { |
11558 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
11559 | { |
11560 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11561 | if (psMemRead->memoryCall) |
11562 | { |
11563 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
11564 | } |
11565 | else |
11566 | { |
11567 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
11568 | } |
11569 | psMemRead = NULL; |
11570 | break; |
11571 | } |
11572 | ++psMemRead; |
11573 | } |
11574 | |
11575 | if (psMemRead) |
11576 | { |
11577 | bTemp = cpu.z80Base[dwAddr]; |
11578 | } |
11579 | |
11580 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
11581 | cpu.z80F |= bPostDecFlags[bTemp--]; |
11582 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
11583 | while (psMemWrite->lowAddr != 0xffffffff) |
11584 | { |
11585 | if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr)) |
11586 | { |
11587 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11588 | if (psMemWrite->memoryCall) |
11589 | { |
11590 | psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite); |
11591 | } |
11592 | else |
11593 | { |
11594 | *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp; |
11595 | } |
11596 | psMemWrite = NULL; |
11597 | break; |
11598 | } |
11599 | ++psMemWrite; |
11600 | } |
11601 | |
11602 | if (psMemWrite) |
11603 | { |
11604 | cpu.z80Base[dwAddr] = (UINT8) bTemp; |
11605 | } |
11606 | |
11607 | break; |
11608 | } |
11609 | case 0x36: |
11610 | { |
11611 | sdwCyclesRemaining -= 19; |
11612 | sdwAddr = (INT8) *pbPC++; // Get the offset |
11613 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
11614 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
11615 | while (psMemWrite->lowAddr != 0xffffffff) |
11616 | { |
11617 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
11618 | { |
11619 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11620 | if (psMemWrite->memoryCall) |
11621 | { |
11622 | psMemWrite->memoryCall(sdwAddr, *pbPC++, psMemWrite); |
11623 | } |
11624 | else |
11625 | { |
11626 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = *pbPC++; |
11627 | } |
11628 | psMemWrite = NULL; |
11629 | break; |
11630 | } |
11631 | ++psMemWrite; |
11632 | } |
11633 | |
11634 | if (psMemWrite) |
11635 | { |
11636 | cpu.z80Base[sdwAddr] = (UINT8) *pbPC++; |
11637 | } |
11638 | |
11639 | break; |
11640 | } |
11641 | case 0x37: |
11642 | { |
11643 | InvalidInstruction(2); |
11644 | break; |
11645 | } |
11646 | case 0x38: |
11647 | { |
11648 | InvalidInstruction(2); |
11649 | break; |
11650 | } |
11651 | case 0x39: |
11652 | { |
11653 | sdwCyclesRemaining -= 15; |
11654 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
11655 | dwTemp = cpu.z80IY + cpu.z80sp; |
11656 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY); |
11657 | cpu.z80IY = dwTemp & 0xffff; |
11658 | break; |
11659 | } |
11660 | case 0x3a: |
11661 | { |
11662 | InvalidInstruction(2); |
11663 | break; |
11664 | } |
11665 | case 0x3b: |
11666 | { |
11667 | InvalidInstruction(2); |
11668 | break; |
11669 | } |
11670 | case 0x3c: |
11671 | { |
11672 | InvalidInstruction(2); |
11673 | break; |
11674 | } |
11675 | case 0x3d: |
11676 | { |
11677 | InvalidInstruction(2); |
11678 | break; |
11679 | } |
11680 | case 0x3e: |
11681 | { |
11682 | InvalidInstruction(2); |
11683 | break; |
11684 | } |
11685 | case 0x3f: |
11686 | { |
11687 | InvalidInstruction(2); |
11688 | break; |
11689 | } |
11690 | case 0x40: |
11691 | { |
11692 | InvalidInstruction(2); |
11693 | break; |
11694 | } |
11695 | case 0x41: |
11696 | { |
11697 | InvalidInstruction(2); |
11698 | break; |
11699 | } |
11700 | case 0x42: |
11701 | { |
11702 | InvalidInstruction(2); |
11703 | break; |
11704 | } |
11705 | case 0x43: |
11706 | { |
11707 | InvalidInstruction(2); |
11708 | break; |
11709 | } |
11710 | case 0x44: |
11711 | { |
11712 | sdwCyclesRemaining -= 9; |
11713 | cpu.z80B = cpu.z80YH; |
11714 | break; |
11715 | } |
11716 | case 0x45: |
11717 | { |
11718 | sdwCyclesRemaining -= 9; |
11719 | cpu.z80B = cpu.z80YL; |
11720 | break; |
11721 | } |
11722 | case 0x46: |
11723 | { |
11724 | sdwCyclesRemaining -= 19; |
11725 | sdwAddr = (INT8) *pbPC++; // Get the offset |
11726 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
11727 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11728 | while (psMemRead->lowAddr != 0xffffffff) |
11729 | { |
11730 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
11731 | { |
11732 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11733 | if (psMemRead->memoryCall) |
11734 | { |
11735 | cpu.z80B = psMemRead->memoryCall(sdwAddr, psMemRead); |
11736 | } |
11737 | else |
11738 | { |
11739 | cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
11740 | } |
11741 | psMemRead = NULL; |
11742 | break; |
11743 | } |
11744 | ++psMemRead; |
11745 | } |
11746 | |
11747 | if (psMemRead) |
11748 | { |
11749 | cpu.z80B = cpu.z80Base[sdwAddr]; |
11750 | } |
11751 | |
11752 | break; |
11753 | } |
11754 | case 0x47: |
11755 | { |
11756 | InvalidInstruction(2); |
11757 | break; |
11758 | } |
11759 | case 0x48: |
11760 | { |
11761 | InvalidInstruction(2); |
11762 | break; |
11763 | } |
11764 | case 0x49: |
11765 | { |
11766 | InvalidInstruction(2); |
11767 | break; |
11768 | } |
11769 | case 0x4a: |
11770 | { |
11771 | InvalidInstruction(2); |
11772 | break; |
11773 | } |
11774 | case 0x4b: |
11775 | { |
11776 | InvalidInstruction(2); |
11777 | break; |
11778 | } |
11779 | case 0x4c: |
11780 | { |
11781 | sdwCyclesRemaining -= 9; |
11782 | cpu.z80C = cpu.z80YH; |
11783 | break; |
11784 | } |
11785 | case 0x4d: |
11786 | { |
11787 | sdwCyclesRemaining -= 9; |
11788 | cpu.z80C = cpu.z80YL; |
11789 | break; |
11790 | } |
11791 | case 0x4e: |
11792 | { |
11793 | sdwCyclesRemaining -= 19; |
11794 | sdwAddr = (INT8) *pbPC++; // Get the offset |
11795 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
11796 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11797 | while (psMemRead->lowAddr != 0xffffffff) |
11798 | { |
11799 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
11800 | { |
11801 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11802 | if (psMemRead->memoryCall) |
11803 | { |
11804 | cpu.z80C = psMemRead->memoryCall(sdwAddr, psMemRead); |
11805 | } |
11806 | else |
11807 | { |
11808 | cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
11809 | } |
11810 | psMemRead = NULL; |
11811 | break; |
11812 | } |
11813 | ++psMemRead; |
11814 | } |
11815 | |
11816 | if (psMemRead) |
11817 | { |
11818 | cpu.z80C = cpu.z80Base[sdwAddr]; |
11819 | } |
11820 | |
11821 | break; |
11822 | } |
11823 | case 0x4f: |
11824 | { |
11825 | InvalidInstruction(2); |
11826 | break; |
11827 | } |
11828 | case 0x50: |
11829 | { |
11830 | InvalidInstruction(2); |
11831 | break; |
11832 | } |
11833 | case 0x51: |
11834 | { |
11835 | InvalidInstruction(2); |
11836 | break; |
11837 | } |
11838 | case 0x52: |
11839 | { |
11840 | InvalidInstruction(2); |
11841 | break; |
11842 | } |
11843 | case 0x53: |
11844 | { |
11845 | InvalidInstruction(2); |
11846 | break; |
11847 | } |
11848 | case 0x54: |
11849 | { |
11850 | sdwCyclesRemaining -= 9; |
11851 | cpu.z80D = cpu.z80YH; |
11852 | break; |
11853 | } |
11854 | case 0x55: |
11855 | { |
11856 | sdwCyclesRemaining -= 9; |
11857 | cpu.z80D = cpu.z80YL; |
11858 | break; |
11859 | } |
11860 | case 0x56: |
11861 | { |
11862 | sdwCyclesRemaining -= 19; |
11863 | sdwAddr = (INT8) *pbPC++; // Get the offset |
11864 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
11865 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11866 | while (psMemRead->lowAddr != 0xffffffff) |
11867 | { |
11868 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
11869 | { |
11870 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11871 | if (psMemRead->memoryCall) |
11872 | { |
11873 | cpu.z80D = psMemRead->memoryCall(sdwAddr, psMemRead); |
11874 | } |
11875 | else |
11876 | { |
11877 | cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
11878 | } |
11879 | psMemRead = NULL; |
11880 | break; |
11881 | } |
11882 | ++psMemRead; |
11883 | } |
11884 | |
11885 | if (psMemRead) |
11886 | { |
11887 | cpu.z80D = cpu.z80Base[sdwAddr]; |
11888 | } |
11889 | |
11890 | break; |
11891 | } |
11892 | case 0x57: |
11893 | { |
11894 | InvalidInstruction(2); |
11895 | break; |
11896 | } |
11897 | case 0x58: |
11898 | { |
11899 | InvalidInstruction(2); |
11900 | break; |
11901 | } |
11902 | case 0x59: |
11903 | { |
11904 | InvalidInstruction(2); |
11905 | break; |
11906 | } |
11907 | case 0x5a: |
11908 | { |
11909 | InvalidInstruction(2); |
11910 | break; |
11911 | } |
11912 | case 0x5b: |
11913 | { |
11914 | InvalidInstruction(2); |
11915 | break; |
11916 | } |
11917 | case 0x5c: |
11918 | { |
11919 | sdwCyclesRemaining -= 9; |
11920 | cpu.z80E = cpu.z80YH; |
11921 | break; |
11922 | } |
11923 | case 0x5d: |
11924 | { |
11925 | sdwCyclesRemaining -= 9; |
11926 | cpu.z80E = cpu.z80YL; |
11927 | break; |
11928 | } |
11929 | case 0x5e: |
11930 | { |
11931 | sdwCyclesRemaining -= 19; |
11932 | sdwAddr = (INT8) *pbPC++; // Get the offset |
11933 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
11934 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
11935 | while (psMemRead->lowAddr != 0xffffffff) |
11936 | { |
11937 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
11938 | { |
11939 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
11940 | if (psMemRead->memoryCall) |
11941 | { |
11942 | cpu.z80E = psMemRead->memoryCall(sdwAddr, psMemRead); |
11943 | } |
11944 | else |
11945 | { |
11946 | cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
11947 | } |
11948 | psMemRead = NULL; |
11949 | break; |
11950 | } |
11951 | ++psMemRead; |
11952 | } |
11953 | |
11954 | if (psMemRead) |
11955 | { |
11956 | cpu.z80E = cpu.z80Base[sdwAddr]; |
11957 | } |
11958 | |
11959 | break; |
11960 | } |
11961 | case 0x5f: |
11962 | { |
11963 | InvalidInstruction(2); |
11964 | break; |
11965 | } |
11966 | case 0x60: |
11967 | { |
11968 | sdwCyclesRemaining -= 9; |
11969 | cpu.z80YH = cpu.z80B; |
11970 | break; |
11971 | } |
11972 | case 0x61: |
11973 | { |
11974 | sdwCyclesRemaining -= 9; |
11975 | cpu.z80YH = cpu.z80C; |
11976 | break; |
11977 | } |
11978 | case 0x62: |
11979 | { |
11980 | sdwCyclesRemaining -= 9; |
11981 | cpu.z80YH = cpu.z80D; |
11982 | break; |
11983 | } |
11984 | case 0x63: |
11985 | { |
11986 | sdwCyclesRemaining -= 9; |
11987 | cpu.z80YH = cpu.z80E; |
11988 | break; |
11989 | } |
11990 | case 0x64: |
11991 | { |
11992 | sdwCyclesRemaining -= 9; |
11993 | break; |
11994 | } |
11995 | case 0x65: |
11996 | { |
11997 | sdwCyclesRemaining -= 9; |
11998 | cpu.z80YH = cpu.z80YL; |
11999 | break; |
12000 | } |
12001 | case 0x66: |
12002 | { |
12003 | sdwCyclesRemaining -= 19; |
12004 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12005 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12006 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12007 | while (psMemRead->lowAddr != 0xffffffff) |
12008 | { |
12009 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
12010 | { |
12011 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12012 | if (psMemRead->memoryCall) |
12013 | { |
12014 | cpu.z80H = psMemRead->memoryCall(sdwAddr, psMemRead); |
12015 | } |
12016 | else |
12017 | { |
12018 | cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
12019 | } |
12020 | psMemRead = NULL; |
12021 | break; |
12022 | } |
12023 | ++psMemRead; |
12024 | } |
12025 | |
12026 | if (psMemRead) |
12027 | { |
12028 | cpu.z80H = cpu.z80Base[sdwAddr]; |
12029 | } |
12030 | |
12031 | break; |
12032 | } |
12033 | case 0x67: |
12034 | { |
12035 | sdwCyclesRemaining -= 9; |
12036 | cpu.z80YH = cpu.z80A; |
12037 | break; |
12038 | } |
12039 | case 0x68: |
12040 | { |
12041 | sdwCyclesRemaining -= 9; |
12042 | cpu.z80YL = cpu.z80B; |
12043 | break; |
12044 | } |
12045 | case 0x69: |
12046 | { |
12047 | sdwCyclesRemaining -= 9; |
12048 | cpu.z80YL = cpu.z80C; |
12049 | break; |
12050 | } |
12051 | case 0x6a: |
12052 | { |
12053 | sdwCyclesRemaining -= 9; |
12054 | cpu.z80YL = cpu.z80D; |
12055 | break; |
12056 | } |
12057 | case 0x6b: |
12058 | { |
12059 | sdwCyclesRemaining -= 9; |
12060 | cpu.z80YL = cpu.z80E; |
12061 | break; |
12062 | } |
12063 | case 0x6c: |
12064 | { |
12065 | sdwCyclesRemaining -= 9; |
12066 | cpu.z80YL = cpu.z80YH; |
12067 | break; |
12068 | } |
12069 | case 0x6d: |
12070 | { |
12071 | sdwCyclesRemaining -= 9; |
12072 | break; |
12073 | } |
12074 | case 0x6e: |
12075 | { |
12076 | sdwCyclesRemaining -= 19; |
12077 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12078 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12079 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12080 | while (psMemRead->lowAddr != 0xffffffff) |
12081 | { |
12082 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
12083 | { |
12084 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12085 | if (psMemRead->memoryCall) |
12086 | { |
12087 | cpu.z80L = psMemRead->memoryCall(sdwAddr, psMemRead); |
12088 | } |
12089 | else |
12090 | { |
12091 | cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
12092 | } |
12093 | psMemRead = NULL; |
12094 | break; |
12095 | } |
12096 | ++psMemRead; |
12097 | } |
12098 | |
12099 | if (psMemRead) |
12100 | { |
12101 | cpu.z80L = cpu.z80Base[sdwAddr]; |
12102 | } |
12103 | |
12104 | break; |
12105 | } |
12106 | case 0x6f: |
12107 | { |
12108 | sdwCyclesRemaining -= 9; |
12109 | cpu.z80YL = cpu.z80A; |
12110 | break; |
12111 | } |
12112 | case 0x70: |
12113 | { |
12114 | sdwCyclesRemaining -= 19; |
12115 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12116 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12117 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12118 | while (psMemWrite->lowAddr != 0xffffffff) |
12119 | { |
12120 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12121 | { |
12122 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12123 | if (psMemWrite->memoryCall) |
12124 | { |
12125 | psMemWrite->memoryCall(sdwAddr, cpu.z80B, psMemWrite); |
12126 | } |
12127 | else |
12128 | { |
12129 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80B; |
12130 | } |
12131 | psMemWrite = NULL; |
12132 | break; |
12133 | } |
12134 | ++psMemWrite; |
12135 | } |
12136 | |
12137 | if (psMemWrite) |
12138 | { |
12139 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80B; |
12140 | } |
12141 | |
12142 | break; |
12143 | } |
12144 | case 0x71: |
12145 | { |
12146 | sdwCyclesRemaining -= 19; |
12147 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12148 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12149 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12150 | while (psMemWrite->lowAddr != 0xffffffff) |
12151 | { |
12152 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12153 | { |
12154 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12155 | if (psMemWrite->memoryCall) |
12156 | { |
12157 | psMemWrite->memoryCall(sdwAddr, cpu.z80C, psMemWrite); |
12158 | } |
12159 | else |
12160 | { |
12161 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80C; |
12162 | } |
12163 | psMemWrite = NULL; |
12164 | break; |
12165 | } |
12166 | ++psMemWrite; |
12167 | } |
12168 | |
12169 | if (psMemWrite) |
12170 | { |
12171 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80C; |
12172 | } |
12173 | |
12174 | break; |
12175 | } |
12176 | case 0x72: |
12177 | { |
12178 | sdwCyclesRemaining -= 19; |
12179 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12180 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12181 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12182 | while (psMemWrite->lowAddr != 0xffffffff) |
12183 | { |
12184 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12185 | { |
12186 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12187 | if (psMemWrite->memoryCall) |
12188 | { |
12189 | psMemWrite->memoryCall(sdwAddr, cpu.z80D, psMemWrite); |
12190 | } |
12191 | else |
12192 | { |
12193 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80D; |
12194 | } |
12195 | psMemWrite = NULL; |
12196 | break; |
12197 | } |
12198 | ++psMemWrite; |
12199 | } |
12200 | |
12201 | if (psMemWrite) |
12202 | { |
12203 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80D; |
12204 | } |
12205 | |
12206 | break; |
12207 | } |
12208 | case 0x73: |
12209 | { |
12210 | sdwCyclesRemaining -= 19; |
12211 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12212 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12213 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12214 | while (psMemWrite->lowAddr != 0xffffffff) |
12215 | { |
12216 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12217 | { |
12218 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12219 | if (psMemWrite->memoryCall) |
12220 | { |
12221 | psMemWrite->memoryCall(sdwAddr, cpu.z80E, psMemWrite); |
12222 | } |
12223 | else |
12224 | { |
12225 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80E; |
12226 | } |
12227 | psMemWrite = NULL; |
12228 | break; |
12229 | } |
12230 | ++psMemWrite; |
12231 | } |
12232 | |
12233 | if (psMemWrite) |
12234 | { |
12235 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80E; |
12236 | } |
12237 | |
12238 | break; |
12239 | } |
12240 | case 0x74: |
12241 | { |
12242 | sdwCyclesRemaining -= 19; |
12243 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12244 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12245 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12246 | while (psMemWrite->lowAddr != 0xffffffff) |
12247 | { |
12248 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12249 | { |
12250 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12251 | if (psMemWrite->memoryCall) |
12252 | { |
12253 | psMemWrite->memoryCall(sdwAddr, cpu.z80H, psMemWrite); |
12254 | } |
12255 | else |
12256 | { |
12257 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80H; |
12258 | } |
12259 | psMemWrite = NULL; |
12260 | break; |
12261 | } |
12262 | ++psMemWrite; |
12263 | } |
12264 | |
12265 | if (psMemWrite) |
12266 | { |
12267 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80H; |
12268 | } |
12269 | |
12270 | break; |
12271 | } |
12272 | case 0x75: |
12273 | { |
12274 | sdwCyclesRemaining -= 19; |
12275 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12276 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12277 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12278 | while (psMemWrite->lowAddr != 0xffffffff) |
12279 | { |
12280 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12281 | { |
12282 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12283 | if (psMemWrite->memoryCall) |
12284 | { |
12285 | psMemWrite->memoryCall(sdwAddr, cpu.z80L, psMemWrite); |
12286 | } |
12287 | else |
12288 | { |
12289 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80L; |
12290 | } |
12291 | psMemWrite = NULL; |
12292 | break; |
12293 | } |
12294 | ++psMemWrite; |
12295 | } |
12296 | |
12297 | if (psMemWrite) |
12298 | { |
12299 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80L; |
12300 | } |
12301 | |
12302 | break; |
12303 | } |
12304 | case 0x76: |
12305 | { |
12306 | sdwCyclesRemaining -= 19; |
12307 | InvalidInstruction(2); |
12308 | break; |
12309 | } |
12310 | case 0x77: |
12311 | { |
12312 | sdwCyclesRemaining -= 19; |
12313 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12314 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12315 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
12316 | while (psMemWrite->lowAddr != 0xffffffff) |
12317 | { |
12318 | if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr)) |
12319 | { |
12320 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12321 | if (psMemWrite->memoryCall) |
12322 | { |
12323 | psMemWrite->memoryCall(sdwAddr, cpu.z80A, psMemWrite); |
12324 | } |
12325 | else |
12326 | { |
12327 | *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80A; |
12328 | } |
12329 | psMemWrite = NULL; |
12330 | break; |
12331 | } |
12332 | ++psMemWrite; |
12333 | } |
12334 | |
12335 | if (psMemWrite) |
12336 | { |
12337 | cpu.z80Base[sdwAddr] = (UINT8) cpu.z80A; |
12338 | } |
12339 | |
12340 | break; |
12341 | } |
12342 | case 0x78: |
12343 | { |
12344 | InvalidInstruction(2); |
12345 | break; |
12346 | } |
12347 | case 0x79: |
12348 | { |
12349 | InvalidInstruction(2); |
12350 | break; |
12351 | } |
12352 | case 0x7a: |
12353 | { |
12354 | InvalidInstruction(2); |
12355 | break; |
12356 | } |
12357 | case 0x7b: |
12358 | { |
12359 | InvalidInstruction(2); |
12360 | break; |
12361 | } |
12362 | case 0x7c: |
12363 | { |
12364 | sdwCyclesRemaining -= 9; |
12365 | cpu.z80A = cpu.z80YH; |
12366 | break; |
12367 | } |
12368 | case 0x7d: |
12369 | { |
12370 | sdwCyclesRemaining -= 9; |
12371 | cpu.z80A = cpu.z80YL; |
12372 | break; |
12373 | } |
12374 | case 0x7e: |
12375 | { |
12376 | sdwCyclesRemaining -= 19; |
12377 | sdwAddr = (INT8) *pbPC++; // Get the offset |
12378 | sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff; |
12379 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12380 | while (psMemRead->lowAddr != 0xffffffff) |
12381 | { |
12382 | if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr)) |
12383 | { |
12384 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12385 | if (psMemRead->memoryCall) |
12386 | { |
12387 | cpu.z80A = psMemRead->memoryCall(sdwAddr, psMemRead); |
12388 | } |
12389 | else |
12390 | { |
12391 | cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr)); |
12392 | } |
12393 | psMemRead = NULL; |
12394 | break; |
12395 | } |
12396 | ++psMemRead; |
12397 | } |
12398 | |
12399 | if (psMemRead) |
12400 | { |
12401 | cpu.z80A = cpu.z80Base[sdwAddr]; |
12402 | } |
12403 | |
12404 | break; |
12405 | } |
12406 | case 0x7f: |
12407 | { |
12408 | InvalidInstruction(2); |
12409 | break; |
12410 | } |
12411 | case 0x80: |
12412 | { |
12413 | InvalidInstruction(2); |
12414 | break; |
12415 | } |
12416 | case 0x81: |
12417 | { |
12418 | InvalidInstruction(2); |
12419 | break; |
12420 | } |
12421 | case 0x82: |
12422 | { |
12423 | InvalidInstruction(2); |
12424 | break; |
12425 | } |
12426 | case 0x83: |
12427 | { |
12428 | InvalidInstruction(2); |
12429 | break; |
12430 | } |
12431 | case 0x84: |
12432 | { |
12433 | sdwCyclesRemaining -= 9; |
12434 | bTemp2 = cpu.z80A + cpu.z80YH; |
12435 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12436 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12437 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH]; |
12438 | InvalidInstruction(2); |
12439 | break; |
12440 | } |
12441 | case 0x85: |
12442 | { |
12443 | sdwCyclesRemaining -= 9; |
12444 | bTemp2 = cpu.z80A + cpu.z80YL; |
12445 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12446 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12447 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL]; |
12448 | InvalidInstruction(2); |
12449 | break; |
12450 | } |
12451 | case 0x86: |
12452 | { |
12453 | sdwCyclesRemaining -= 19; |
12454 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12455 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12456 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12457 | while (psMemRead->lowAddr != 0xffffffff) |
12458 | { |
12459 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12460 | { |
12461 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12462 | if (psMemRead->memoryCall) |
12463 | { |
12464 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12465 | } |
12466 | else |
12467 | { |
12468 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12469 | } |
12470 | psMemRead = NULL; |
12471 | break; |
12472 | } |
12473 | ++psMemRead; |
12474 | } |
12475 | |
12476 | if (psMemRead) |
12477 | { |
12478 | bTemp = cpu.z80Base[dwAddr]; |
12479 | } |
12480 | |
12481 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12482 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12483 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
12484 | cpu.z80A += bTemp; |
12485 | break; |
12486 | } |
12487 | case 0x87: |
12488 | { |
12489 | InvalidInstruction(2); |
12490 | break; |
12491 | } |
12492 | case 0x88: |
12493 | { |
12494 | InvalidInstruction(2); |
12495 | break; |
12496 | } |
12497 | case 0x89: |
12498 | { |
12499 | InvalidInstruction(2); |
12500 | break; |
12501 | } |
12502 | case 0x8a: |
12503 | { |
12504 | InvalidInstruction(2); |
12505 | break; |
12506 | } |
12507 | case 0x8b: |
12508 | { |
12509 | InvalidInstruction(2); |
12510 | break; |
12511 | } |
12512 | case 0x8c: |
12513 | { |
12514 | sdwCyclesRemaining -= 9; |
12515 | bTemp2 = cpu.z80A + cpu.z80YH + (cpu.z80F & Z80_FLAG_CARRY); |
12516 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12517 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12518 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
12519 | InvalidInstruction(2); |
12520 | break; |
12521 | } |
12522 | case 0x8d: |
12523 | { |
12524 | sdwCyclesRemaining -= 9; |
12525 | bTemp2 = cpu.z80A + cpu.z80YL + (cpu.z80F & Z80_FLAG_CARRY); |
12526 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12527 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12528 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
12529 | InvalidInstruction(2); |
12530 | break; |
12531 | } |
12532 | case 0x8e: |
12533 | { |
12534 | sdwCyclesRemaining -= 19; |
12535 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12536 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12537 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12538 | while (psMemRead->lowAddr != 0xffffffff) |
12539 | { |
12540 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12541 | { |
12542 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12543 | if (psMemRead->memoryCall) |
12544 | { |
12545 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12546 | } |
12547 | else |
12548 | { |
12549 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12550 | } |
12551 | psMemRead = NULL; |
12552 | break; |
12553 | } |
12554 | ++psMemRead; |
12555 | } |
12556 | |
12557 | if (psMemRead) |
12558 | { |
12559 | bTemp = cpu.z80Base[dwAddr]; |
12560 | } |
12561 | |
12562 | bTemp2 = (cpu.z80F & Z80_FLAG_CARRY); |
12563 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12564 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12565 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
12566 | cpu.z80A += bTemp + bTemp2; |
12567 | break; |
12568 | } |
12569 | case 0x8f: |
12570 | { |
12571 | InvalidInstruction(2); |
12572 | break; |
12573 | } |
12574 | case 0x90: |
12575 | { |
12576 | InvalidInstruction(2); |
12577 | break; |
12578 | } |
12579 | case 0x91: |
12580 | { |
12581 | InvalidInstruction(2); |
12582 | break; |
12583 | } |
12584 | case 0x92: |
12585 | { |
12586 | InvalidInstruction(2); |
12587 | break; |
12588 | } |
12589 | case 0x93: |
12590 | { |
12591 | InvalidInstruction(2); |
12592 | break; |
12593 | } |
12594 | case 0x94: |
12595 | { |
12596 | sdwCyclesRemaining -= 9; |
12597 | bTemp2 = cpu.z80A - cpu.z80YH; |
12598 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12599 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12600 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH]; |
12601 | InvalidInstruction(2); |
12602 | break; |
12603 | } |
12604 | case 0x95: |
12605 | { |
12606 | sdwCyclesRemaining -= 9; |
12607 | bTemp2 = cpu.z80A - cpu.z80YL; |
12608 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12609 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12610 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL]; |
12611 | InvalidInstruction(2); |
12612 | break; |
12613 | } |
12614 | case 0x96: |
12615 | { |
12616 | sdwCyclesRemaining -= 19; |
12617 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12618 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12619 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12620 | while (psMemRead->lowAddr != 0xffffffff) |
12621 | { |
12622 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12623 | { |
12624 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12625 | if (psMemRead->memoryCall) |
12626 | { |
12627 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12628 | } |
12629 | else |
12630 | { |
12631 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12632 | } |
12633 | psMemRead = NULL; |
12634 | break; |
12635 | } |
12636 | ++psMemRead; |
12637 | } |
12638 | |
12639 | if (psMemRead) |
12640 | { |
12641 | bTemp = cpu.z80Base[dwAddr]; |
12642 | } |
12643 | |
12644 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12645 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12646 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
12647 | cpu.z80A -= bTemp; |
12648 | break; |
12649 | } |
12650 | case 0x97: |
12651 | { |
12652 | InvalidInstruction(2); |
12653 | break; |
12654 | } |
12655 | case 0x98: |
12656 | { |
12657 | InvalidInstruction(2); |
12658 | break; |
12659 | } |
12660 | case 0x99: |
12661 | { |
12662 | InvalidInstruction(2); |
12663 | break; |
12664 | } |
12665 | case 0x9a: |
12666 | { |
12667 | InvalidInstruction(2); |
12668 | break; |
12669 | } |
12670 | case 0x9b: |
12671 | { |
12672 | InvalidInstruction(2); |
12673 | break; |
12674 | } |
12675 | case 0x9c: |
12676 | { |
12677 | sdwCyclesRemaining -= 9; |
12678 | bTemp2 = cpu.z80A - cpu.z80YH - (cpu.z80F & Z80_FLAG_CARRY); |
12679 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12680 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12681 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
12682 | InvalidInstruction(2); |
12683 | break; |
12684 | } |
12685 | case 0x9d: |
12686 | { |
12687 | sdwCyclesRemaining -= 9; |
12688 | bTemp2 = cpu.z80A - cpu.z80YL - (cpu.z80F & Z80_FLAG_CARRY); |
12689 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12690 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12691 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
12692 | InvalidInstruction(2); |
12693 | break; |
12694 | } |
12695 | case 0x9e: |
12696 | { |
12697 | sdwCyclesRemaining -= 19; |
12698 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12699 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12700 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12701 | while (psMemRead->lowAddr != 0xffffffff) |
12702 | { |
12703 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12704 | { |
12705 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12706 | if (psMemRead->memoryCall) |
12707 | { |
12708 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12709 | } |
12710 | else |
12711 | { |
12712 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12713 | } |
12714 | psMemRead = NULL; |
12715 | break; |
12716 | } |
12717 | ++psMemRead; |
12718 | } |
12719 | |
12720 | if (psMemRead) |
12721 | { |
12722 | bTemp = cpu.z80Base[dwAddr]; |
12723 | } |
12724 | |
12725 | bTemp2 = cpu.z80A; |
12726 | cpu.z80A = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY); |
12727 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
12728 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
12729 | pbSubSbcTable[((UINT32) bTemp2 << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
12730 | break; |
12731 | } |
12732 | case 0x9f: |
12733 | { |
12734 | InvalidInstruction(2); |
12735 | break; |
12736 | } |
12737 | case 0xa0: |
12738 | { |
12739 | InvalidInstruction(2); |
12740 | break; |
12741 | } |
12742 | case 0xa1: |
12743 | { |
12744 | InvalidInstruction(2); |
12745 | break; |
12746 | } |
12747 | case 0xa2: |
12748 | { |
12749 | InvalidInstruction(2); |
12750 | break; |
12751 | } |
12752 | case 0xa3: |
12753 | { |
12754 | InvalidInstruction(2); |
12755 | break; |
12756 | } |
12757 | case 0xa4: |
12758 | { |
12759 | sdwCyclesRemaining -= 9; |
12760 | cpu.z80A &= cpu.z80YH; |
12761 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12762 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
12763 | |
12764 | InvalidInstruction(2); |
12765 | break; |
12766 | } |
12767 | case 0xa5: |
12768 | { |
12769 | sdwCyclesRemaining -= 9; |
12770 | cpu.z80A &= cpu.z80YL; |
12771 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12772 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
12773 | |
12774 | InvalidInstruction(2); |
12775 | break; |
12776 | } |
12777 | case 0xa6: |
12778 | { |
12779 | sdwCyclesRemaining -= 19; |
12780 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12781 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12782 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12783 | while (psMemRead->lowAddr != 0xffffffff) |
12784 | { |
12785 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12786 | { |
12787 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12788 | if (psMemRead->memoryCall) |
12789 | { |
12790 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12791 | } |
12792 | else |
12793 | { |
12794 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12795 | } |
12796 | psMemRead = NULL; |
12797 | break; |
12798 | } |
12799 | ++psMemRead; |
12800 | } |
12801 | |
12802 | if (psMemRead) |
12803 | { |
12804 | bTemp = cpu.z80Base[dwAddr]; |
12805 | } |
12806 | |
12807 | cpu.z80A &= bTemp; |
12808 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12809 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
12810 | |
12811 | break; |
12812 | } |
12813 | case 0xa7: |
12814 | { |
12815 | InvalidInstruction(2); |
12816 | break; |
12817 | } |
12818 | case 0xa8: |
12819 | { |
12820 | InvalidInstruction(2); |
12821 | break; |
12822 | } |
12823 | case 0xa9: |
12824 | { |
12825 | InvalidInstruction(2); |
12826 | break; |
12827 | } |
12828 | case 0xaa: |
12829 | { |
12830 | InvalidInstruction(2); |
12831 | break; |
12832 | } |
12833 | case 0xab: |
12834 | { |
12835 | InvalidInstruction(2); |
12836 | break; |
12837 | } |
12838 | case 0xac: |
12839 | { |
12840 | sdwCyclesRemaining -= 9; |
12841 | cpu.z80A ^= cpu.z80YH; |
12842 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12843 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
12844 | |
12845 | InvalidInstruction(2); |
12846 | break; |
12847 | } |
12848 | case 0xad: |
12849 | { |
12850 | sdwCyclesRemaining -= 9; |
12851 | cpu.z80A ^= cpu.z80YL; |
12852 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12853 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
12854 | |
12855 | InvalidInstruction(2); |
12856 | break; |
12857 | } |
12858 | case 0xae: |
12859 | { |
12860 | sdwCyclesRemaining -= 19; |
12861 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12862 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12863 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12864 | while (psMemRead->lowAddr != 0xffffffff) |
12865 | { |
12866 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12867 | { |
12868 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12869 | if (psMemRead->memoryCall) |
12870 | { |
12871 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12872 | } |
12873 | else |
12874 | { |
12875 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12876 | } |
12877 | psMemRead = NULL; |
12878 | break; |
12879 | } |
12880 | ++psMemRead; |
12881 | } |
12882 | |
12883 | if (psMemRead) |
12884 | { |
12885 | bTemp = cpu.z80Base[dwAddr]; |
12886 | } |
12887 | |
12888 | cpu.z80A ^= bTemp; |
12889 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12890 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
12891 | |
12892 | break; |
12893 | } |
12894 | case 0xaf: |
12895 | { |
12896 | InvalidInstruction(2); |
12897 | break; |
12898 | } |
12899 | case 0xb0: |
12900 | { |
12901 | InvalidInstruction(2); |
12902 | break; |
12903 | } |
12904 | case 0xb1: |
12905 | { |
12906 | InvalidInstruction(2); |
12907 | break; |
12908 | } |
12909 | case 0xb2: |
12910 | { |
12911 | InvalidInstruction(2); |
12912 | break; |
12913 | } |
12914 | case 0xb3: |
12915 | { |
12916 | InvalidInstruction(2); |
12917 | break; |
12918 | } |
12919 | case 0xb4: |
12920 | { |
12921 | sdwCyclesRemaining -= 9; |
12922 | cpu.z80A |= cpu.z80YH; |
12923 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12924 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
12925 | |
12926 | InvalidInstruction(2); |
12927 | break; |
12928 | } |
12929 | case 0xb5: |
12930 | { |
12931 | sdwCyclesRemaining -= 9; |
12932 | cpu.z80A |= cpu.z80YL; |
12933 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12934 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
12935 | |
12936 | InvalidInstruction(2); |
12937 | break; |
12938 | } |
12939 | case 0xb6: |
12940 | { |
12941 | sdwCyclesRemaining -= 19; |
12942 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
12943 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
12944 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
12945 | while (psMemRead->lowAddr != 0xffffffff) |
12946 | { |
12947 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
12948 | { |
12949 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
12950 | if (psMemRead->memoryCall) |
12951 | { |
12952 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
12953 | } |
12954 | else |
12955 | { |
12956 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
12957 | } |
12958 | psMemRead = NULL; |
12959 | break; |
12960 | } |
12961 | ++psMemRead; |
12962 | } |
12963 | |
12964 | if (psMemRead) |
12965 | { |
12966 | bTemp = cpu.z80Base[dwAddr]; |
12967 | } |
12968 | |
12969 | cpu.z80A |= bTemp; |
12970 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
12971 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
12972 | |
12973 | break; |
12974 | } |
12975 | case 0xb7: |
12976 | { |
12977 | InvalidInstruction(2); |
12978 | break; |
12979 | } |
12980 | case 0xb8: |
12981 | { |
12982 | InvalidInstruction(2); |
12983 | break; |
12984 | } |
12985 | case 0xb9: |
12986 | { |
12987 | InvalidInstruction(2); |
12988 | break; |
12989 | } |
12990 | case 0xba: |
12991 | { |
12992 | InvalidInstruction(2); |
12993 | break; |
12994 | } |
12995 | case 0xbb: |
12996 | { |
12997 | InvalidInstruction(2); |
12998 | break; |
12999 | } |
13000 | case 0xbc: |
13001 | { |
13002 | sdwCyclesRemaining -= 9; |
13003 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
13004 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
13005 | |
13006 | InvalidInstruction(2); |
13007 | break; |
13008 | } |
13009 | case 0xbd: |
13010 | { |
13011 | sdwCyclesRemaining -= 9; |
13012 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
13013 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
13014 | |
13015 | InvalidInstruction(2); |
13016 | break; |
13017 | } |
13018 | case 0xbe: |
13019 | { |
13020 | sdwCyclesRemaining -= 19; |
13021 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
13022 | dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff; |
13023 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
13024 | while (psMemRead->lowAddr != 0xffffffff) |
13025 | { |
13026 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
13027 | { |
13028 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13029 | if (psMemRead->memoryCall) |
13030 | { |
13031 | bTemp = psMemRead->memoryCall(dwAddr, psMemRead); |
13032 | } |
13033 | else |
13034 | { |
13035 | bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
13036 | } |
13037 | psMemRead = NULL; |
13038 | break; |
13039 | } |
13040 | ++psMemRead; |
13041 | } |
13042 | |
13043 | if (psMemRead) |
13044 | { |
13045 | bTemp = cpu.z80Base[dwAddr]; |
13046 | } |
13047 | |
13048 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
13049 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
13050 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
13051 | break; |
13052 | } |
13053 | case 0xbf: |
13054 | { |
13055 | InvalidInstruction(2); |
13056 | break; |
13057 | } |
13058 | case 0xc0: |
13059 | { |
13060 | InvalidInstruction(2); |
13061 | break; |
13062 | } |
13063 | case 0xc1: |
13064 | { |
13065 | InvalidInstruction(2); |
13066 | break; |
13067 | } |
13068 | case 0xc2: |
13069 | { |
13070 | InvalidInstruction(2); |
13071 | break; |
13072 | } |
13073 | case 0xc3: |
13074 | { |
13075 | InvalidInstruction(2); |
13076 | break; |
13077 | } |
13078 | case 0xc4: |
13079 | { |
13080 | InvalidInstruction(2); |
13081 | break; |
13082 | } |
13083 | case 0xc5: |
13084 | { |
13085 | InvalidInstruction(2); |
13086 | break; |
13087 | } |
13088 | case 0xc6: |
13089 | { |
13090 | InvalidInstruction(2); |
13091 | break; |
13092 | } |
13093 | case 0xc7: |
13094 | { |
13095 | InvalidInstruction(2); |
13096 | break; |
13097 | } |
13098 | case 0xc8: |
13099 | { |
13100 | InvalidInstruction(2); |
13101 | break; |
13102 | } |
13103 | case 0xc9: |
13104 | { |
13105 | InvalidInstruction(2); |
13106 | break; |
13107 | } |
13108 | case 0xca: |
13109 | { |
13110 | InvalidInstruction(2); |
13111 | break; |
13112 | } |
13113 | case 0xcb: |
13114 | { |
13115 | DDFDCBHandler(1); |
13116 | break; |
13117 | } |
13118 | case 0xcc: |
13119 | { |
13120 | InvalidInstruction(2); |
13121 | break; |
13122 | } |
13123 | case 0xcd: |
13124 | { |
13125 | InvalidInstruction(2); |
13126 | break; |
13127 | } |
13128 | case 0xce: |
13129 | { |
13130 | InvalidInstruction(2); |
13131 | break; |
13132 | } |
13133 | case 0xcf: |
13134 | { |
13135 | InvalidInstruction(2); |
13136 | break; |
13137 | } |
13138 | case 0xd0: |
13139 | { |
13140 | InvalidInstruction(2); |
13141 | break; |
13142 | } |
13143 | case 0xd1: |
13144 | { |
13145 | InvalidInstruction(2); |
13146 | break; |
13147 | } |
13148 | case 0xd2: |
13149 | { |
13150 | InvalidInstruction(2); |
13151 | break; |
13152 | } |
13153 | case 0xd3: |
13154 | { |
13155 | InvalidInstruction(2); |
13156 | break; |
13157 | } |
13158 | case 0xd4: |
13159 | { |
13160 | InvalidInstruction(2); |
13161 | break; |
13162 | } |
13163 | case 0xd5: |
13164 | { |
13165 | InvalidInstruction(2); |
13166 | break; |
13167 | } |
13168 | case 0xd6: |
13169 | { |
13170 | InvalidInstruction(2); |
13171 | break; |
13172 | } |
13173 | case 0xd7: |
13174 | { |
13175 | InvalidInstruction(2); |
13176 | break; |
13177 | } |
13178 | case 0xd8: |
13179 | { |
13180 | InvalidInstruction(2); |
13181 | break; |
13182 | } |
13183 | case 0xd9: |
13184 | { |
13185 | InvalidInstruction(2); |
13186 | break; |
13187 | } |
13188 | case 0xda: |
13189 | { |
13190 | InvalidInstruction(2); |
13191 | break; |
13192 | } |
13193 | case 0xdb: |
13194 | { |
13195 | InvalidInstruction(2); |
13196 | break; |
13197 | } |
13198 | case 0xdc: |
13199 | { |
13200 | InvalidInstruction(2); |
13201 | break; |
13202 | } |
13203 | case 0xdd: |
13204 | { |
13205 | InvalidInstruction(2); |
13206 | break; |
13207 | } |
13208 | case 0xde: |
13209 | { |
13210 | InvalidInstruction(2); |
13211 | break; |
13212 | } |
13213 | case 0xdf: |
13214 | { |
13215 | InvalidInstruction(2); |
13216 | break; |
13217 | } |
13218 | case 0xe0: |
13219 | { |
13220 | InvalidInstruction(2); |
13221 | break; |
13222 | } |
13223 | case 0xe1: |
13224 | { |
13225 | sdwCyclesRemaining -= 14; |
13226 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
13227 | while (psMemRead->lowAddr != 0xffffffff) |
13228 | { |
13229 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
13230 | { |
13231 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13232 | if (psMemRead->memoryCall) |
13233 | { |
13234 | cpu.z80IY = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
13235 | cpu.z80IY |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
13236 | } |
13237 | else |
13238 | { |
13239 | cpu.z80IY = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
13240 | cpu.z80IY |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
13241 | } |
13242 | psMemRead = NULL; |
13243 | break; |
13244 | } |
13245 | ++psMemRead; |
13246 | } |
13247 | |
13248 | if (psMemRead) |
13249 | { |
13250 | cpu.z80IY = cpu.z80Base[cpu.z80sp]; |
13251 | cpu.z80IY |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
13252 | } |
13253 | |
13254 | cpu.z80sp += 2; |
13255 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
13256 | break; |
13257 | } |
13258 | case 0xe2: |
13259 | { |
13260 | InvalidInstruction(2); |
13261 | break; |
13262 | } |
13263 | case 0xe3: |
13264 | { |
13265 | sdwCyclesRemaining -= 23; |
13266 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
13267 | while (psMemRead->lowAddr != 0xffffffff) |
13268 | { |
13269 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
13270 | { |
13271 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13272 | if (psMemRead->memoryCall) |
13273 | { |
13274 | dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
13275 | dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
13276 | } |
13277 | else |
13278 | { |
13279 | dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
13280 | dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
13281 | } |
13282 | psMemRead = NULL; |
13283 | break; |
13284 | } |
13285 | ++psMemRead; |
13286 | } |
13287 | |
13288 | if (psMemRead) |
13289 | { |
13290 | dwAddr = cpu.z80Base[cpu.z80sp]; |
13291 | dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
13292 | } |
13293 | |
13294 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
13295 | while (psMemWrite->lowAddr != 0xffffffff) |
13296 | { |
13297 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
13298 | { |
13299 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13300 | if (psMemWrite->memoryCall) |
13301 | { |
13302 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IY & 0xff), psMemWrite); |
13303 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IY >> 8), psMemWrite); |
13304 | } |
13305 | else |
13306 | { |
13307 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IY; |
13308 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8; |
13309 | } |
13310 | psMemWrite = NULL; |
13311 | break; |
13312 | } |
13313 | ++psMemWrite; |
13314 | } |
13315 | |
13316 | if (psMemWrite) |
13317 | { |
13318 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IY; |
13319 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8); |
13320 | } |
13321 | |
13322 | cpu.z80IY = dwAddr; |
13323 | break; |
13324 | } |
13325 | case 0xe4: |
13326 | { |
13327 | InvalidInstruction(2); |
13328 | break; |
13329 | } |
13330 | case 0xe5: |
13331 | { |
13332 | sdwCyclesRemaining -= 15; |
13333 | cpu.z80sp -= 2; |
13334 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
13335 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
13336 | while (psMemWrite->lowAddr != 0xffffffff) |
13337 | { |
13338 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
13339 | { |
13340 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13341 | if (psMemWrite->memoryCall) |
13342 | { |
13343 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IY & 0xff), psMemWrite); |
13344 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IY >> 8), psMemWrite); |
13345 | } |
13346 | else |
13347 | { |
13348 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IY; |
13349 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8; |
13350 | } |
13351 | psMemWrite = NULL; |
13352 | break; |
13353 | } |
13354 | ++psMemWrite; |
13355 | } |
13356 | |
13357 | if (psMemWrite) |
13358 | { |
13359 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IY; |
13360 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8); |
13361 | } |
13362 | |
13363 | break; |
13364 | } |
13365 | case 0xe6: |
13366 | { |
13367 | InvalidInstruction(2); |
13368 | break; |
13369 | } |
13370 | case 0xe7: |
13371 | { |
13372 | InvalidInstruction(2); |
13373 | break; |
13374 | } |
13375 | case 0xe8: |
13376 | { |
13377 | InvalidInstruction(2); |
13378 | break; |
13379 | } |
13380 | case 0xe9: |
13381 | { |
13382 | sdwCyclesRemaining -= 8; |
13383 | pbPC = cpu.z80Base + cpu.z80IY; |
13384 | break; |
13385 | } |
13386 | case 0xea: |
13387 | { |
13388 | InvalidInstruction(2); |
13389 | break; |
13390 | } |
13391 | case 0xeb: |
13392 | { |
13393 | InvalidInstruction(2); |
13394 | break; |
13395 | } |
13396 | case 0xec: |
13397 | { |
13398 | InvalidInstruction(2); |
13399 | break; |
13400 | } |
13401 | case 0xed: |
13402 | { |
13403 | InvalidInstruction(2); |
13404 | break; |
13405 | } |
13406 | case 0xee: |
13407 | { |
13408 | InvalidInstruction(2); |
13409 | break; |
13410 | } |
13411 | case 0xef: |
13412 | { |
13413 | InvalidInstruction(2); |
13414 | break; |
13415 | } |
13416 | case 0xf0: |
13417 | { |
13418 | InvalidInstruction(2); |
13419 | break; |
13420 | } |
13421 | case 0xf1: |
13422 | { |
13423 | InvalidInstruction(2); |
13424 | break; |
13425 | } |
13426 | case 0xf2: |
13427 | { |
13428 | InvalidInstruction(2); |
13429 | break; |
13430 | } |
13431 | case 0xf3: |
13432 | { |
13433 | InvalidInstruction(2); |
13434 | break; |
13435 | } |
13436 | case 0xf4: |
13437 | { |
13438 | InvalidInstruction(2); |
13439 | break; |
13440 | } |
13441 | case 0xf5: |
13442 | { |
13443 | InvalidInstruction(2); |
13444 | break; |
13445 | } |
13446 | case 0xf6: |
13447 | { |
13448 | InvalidInstruction(2); |
13449 | break; |
13450 | } |
13451 | case 0xf7: |
13452 | { |
13453 | InvalidInstruction(2); |
13454 | break; |
13455 | } |
13456 | case 0xf8: |
13457 | { |
13458 | InvalidInstruction(2); |
13459 | break; |
13460 | } |
13461 | case 0xf9: |
13462 | { |
13463 | sdwCyclesRemaining -= 10; |
13464 | cpu.z80sp = cpu.z80IY; |
13465 | break; |
13466 | } |
13467 | case 0xfa: |
13468 | { |
13469 | InvalidInstruction(2); |
13470 | break; |
13471 | } |
13472 | case 0xfb: |
13473 | { |
13474 | InvalidInstruction(2); |
13475 | break; |
13476 | } |
13477 | case 0xfc: |
13478 | { |
13479 | InvalidInstruction(2); |
13480 | break; |
13481 | } |
13482 | case 0xfd: |
13483 | { |
13484 | InvalidInstruction(2); |
13485 | break; |
13486 | } |
13487 | case 0xfe: |
13488 | { |
13489 | InvalidInstruction(2); |
13490 | break; |
13491 | } |
13492 | case 0xff: |
13493 | { |
13494 | InvalidInstruction(2); |
13495 | break; |
13496 | } |
13497 | } |
13498 | } |
13499 | /* Main execution entry point */ |
13500 | |
13501 | UINT32 mz80exec(UINT32 dwCycles) |
13502 | { |
13503 | UINT8 bOpcode; |
13504 | |
13505 | dwReturnCode = 0x80000000; /* Assume it'll work */ |
13506 | sdwCyclesRemaining = dwCycles; |
13507 | dwOriginalCycles = dwCycles; |
13508 | if (cpu.z80halted) |
13509 | { |
13510 | dwElapsedTicks += dwCycles; |
13511 | return(0x80000000); |
13512 | } |
13513 | |
13514 | pbPC = cpu.z80Base + cpu.z80pc; |
13515 | |
13516 | while (sdwCyclesRemaining > 0) |
13517 | { |
13518 | bOpcode = *pbPC++; |
13519 | switch (bOpcode) |
13520 | { |
13521 | case 0x00: |
13522 | { |
13523 | sdwCyclesRemaining -= 4; |
13524 | /* Intentionally not doing anything - NOP! */ |
13525 | break; |
13526 | } |
13527 | case 0x01: |
13528 | { |
13529 | sdwCyclesRemaining -= 10; |
13530 | cpu.z80BC = *pbPC++; /* LSB First */ |
13531 | cpu.z80BC |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */ |
13532 | break; |
13533 | } |
13534 | case 0x02: |
13535 | { |
13536 | sdwCyclesRemaining -= 7; |
13537 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
13538 | while (psMemWrite->lowAddr != 0xffffffff) |
13539 | { |
13540 | if ((cpu.z80BC >= psMemWrite->lowAddr) && (cpu.z80BC <= psMemWrite->highAddr)) |
13541 | { |
13542 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13543 | if (psMemWrite->memoryCall) |
13544 | { |
13545 | psMemWrite->memoryCall(cpu.z80BC, cpu.z80A, psMemWrite); |
13546 | } |
13547 | else |
13548 | { |
13549 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80BC - psMemWrite->lowAddr)) = cpu.z80A; |
13550 | } |
13551 | psMemWrite = NULL; |
13552 | break; |
13553 | } |
13554 | ++psMemWrite; |
13555 | } |
13556 | |
13557 | if (psMemWrite) |
13558 | { |
13559 | cpu.z80Base[cpu.z80BC] = (UINT8) cpu.z80A; |
13560 | } |
13561 | |
13562 | break; |
13563 | } |
13564 | case 0x03: |
13565 | { |
13566 | sdwCyclesRemaining -= 6; |
13567 | cpu.z80BC++; |
13568 | cpu.z80BC &= 0xffff; |
13569 | break; |
13570 | } |
13571 | case 0x04: |
13572 | { |
13573 | sdwCyclesRemaining -= 4; |
13574 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
13575 | cpu.z80F |= bPostIncFlags[cpu.z80B++]; |
13576 | break; |
13577 | } |
13578 | case 0x05: |
13579 | { |
13580 | sdwCyclesRemaining -= 4; |
13581 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
13582 | cpu.z80F |= bPostDecFlags[cpu.z80B--]; |
13583 | break; |
13584 | } |
13585 | case 0x06: |
13586 | { |
13587 | sdwCyclesRemaining -= 7; |
13588 | cpu.z80B = *pbPC++; /* Get immediate byte into register */ |
13589 | break; |
13590 | } |
13591 | case 0x07: |
13592 | { |
13593 | sdwCyclesRemaining -= 4; |
13594 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
13595 | cpu.z80F |= (cpu.z80A >> 7); |
13596 | cpu.z80A = (cpu.z80A << 1) | (cpu.z80A >> 7); |
13597 | break; |
13598 | } |
13599 | case 0x08: |
13600 | { |
13601 | sdwCyclesRemaining -= 4; |
13602 | dwAddr = (UINT32) cpu.z80AF; |
13603 | cpu.z80AF = cpu.z80afprime; |
13604 | cpu.z80afprime = dwAddr; |
13605 | break; |
13606 | } |
13607 | case 0x09: |
13608 | { |
13609 | sdwCyclesRemaining -= 11; |
13610 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
13611 | dwTemp = cpu.z80HL + cpu.z80BC; |
13612 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY); |
13613 | cpu.z80HL = dwTemp & 0xffff; |
13614 | break; |
13615 | } |
13616 | case 0x0a: |
13617 | { |
13618 | sdwCyclesRemaining -= 7; |
13619 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
13620 | while (psMemRead->lowAddr != 0xffffffff) |
13621 | { |
13622 | if ((cpu.z80BC >= psMemRead->lowAddr) && (cpu.z80BC <= psMemRead->highAddr)) |
13623 | { |
13624 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13625 | if (psMemRead->memoryCall) |
13626 | { |
13627 | cpu.z80A = psMemRead->memoryCall(cpu.z80BC, psMemRead); |
13628 | } |
13629 | else |
13630 | { |
13631 | cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80BC - psMemRead->lowAddr)); |
13632 | } |
13633 | psMemRead = NULL; |
13634 | break; |
13635 | } |
13636 | ++psMemRead; |
13637 | } |
13638 | |
13639 | if (psMemRead) |
13640 | { |
13641 | cpu.z80A = cpu.z80Base[cpu.z80BC]; |
13642 | } |
13643 | |
13644 | break; |
13645 | } |
13646 | case 0x0b: |
13647 | { |
13648 | sdwCyclesRemaining -= 6; |
13649 | cpu.z80BC--; |
13650 | cpu.z80BC &= 0xffff; |
13651 | break; |
13652 | } |
13653 | case 0x0c: |
13654 | { |
13655 | sdwCyclesRemaining -= 4; |
13656 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
13657 | cpu.z80F |= bPostIncFlags[cpu.z80C++]; |
13658 | break; |
13659 | } |
13660 | case 0x0d: |
13661 | { |
13662 | sdwCyclesRemaining -= 4; |
13663 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
13664 | cpu.z80F |= bPostDecFlags[cpu.z80C--]; |
13665 | break; |
13666 | } |
13667 | case 0x0e: |
13668 | { |
13669 | sdwCyclesRemaining -= 7; |
13670 | cpu.z80C = *pbPC++; /* Get immediate byte into register */ |
13671 | break; |
13672 | } |
13673 | case 0x0f: |
13674 | { |
13675 | sdwCyclesRemaining -= 4; |
13676 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
13677 | cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY); |
13678 | cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A << 7); |
13679 | break; |
13680 | } |
13681 | case 0x10: |
13682 | { |
13683 | sdwCyclesRemaining -= 8; |
13684 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
13685 | if (--cpu.z80B) |
13686 | { |
13687 | dwElapsedTicks += 5; /* 5 More for jump taken */ |
13688 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13689 | sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff; |
13690 | pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */ |
13691 | } |
13692 | break; |
13693 | } |
13694 | case 0x11: |
13695 | { |
13696 | sdwCyclesRemaining -= 10; |
13697 | cpu.z80DE = *pbPC++; /* LSB First */ |
13698 | cpu.z80DE |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */ |
13699 | break; |
13700 | } |
13701 | case 0x12: |
13702 | { |
13703 | sdwCyclesRemaining -= 7; |
13704 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
13705 | while (psMemWrite->lowAddr != 0xffffffff) |
13706 | { |
13707 | if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr)) |
13708 | { |
13709 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13710 | if (psMemWrite->memoryCall) |
13711 | { |
13712 | psMemWrite->memoryCall(cpu.z80DE, cpu.z80A, psMemWrite); |
13713 | } |
13714 | else |
13715 | { |
13716 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = cpu.z80A; |
13717 | } |
13718 | psMemWrite = NULL; |
13719 | break; |
13720 | } |
13721 | ++psMemWrite; |
13722 | } |
13723 | |
13724 | if (psMemWrite) |
13725 | { |
13726 | cpu.z80Base[cpu.z80DE] = (UINT8) cpu.z80A; |
13727 | } |
13728 | |
13729 | break; |
13730 | } |
13731 | case 0x13: |
13732 | { |
13733 | sdwCyclesRemaining -= 6; |
13734 | cpu.z80DE++; |
13735 | cpu.z80DE &= 0xffff; |
13736 | break; |
13737 | } |
13738 | case 0x14: |
13739 | { |
13740 | sdwCyclesRemaining -= 4; |
13741 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
13742 | cpu.z80F |= bPostIncFlags[cpu.z80D++]; |
13743 | break; |
13744 | } |
13745 | case 0x15: |
13746 | { |
13747 | sdwCyclesRemaining -= 4; |
13748 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
13749 | cpu.z80F |= bPostDecFlags[cpu.z80D--]; |
13750 | break; |
13751 | } |
13752 | case 0x16: |
13753 | { |
13754 | sdwCyclesRemaining -= 7; |
13755 | cpu.z80D = *pbPC++; /* Get immediate byte into register */ |
13756 | break; |
13757 | } |
13758 | case 0x17: |
13759 | { |
13760 | sdwCyclesRemaining -= 4; |
13761 | bTemp = cpu.z80A >> 7; |
13762 | cpu.z80A = (cpu.z80A << 1) | (cpu.z80F & Z80_FLAG_CARRY); |
13763 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY)) | bTemp; |
13764 | break; |
13765 | } |
13766 | case 0x18: |
13767 | { |
13768 | sdwCyclesRemaining -= 12; |
13769 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
13770 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13771 | sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff; |
13772 | { |
13773 | sdwCyclesRemaining -= 5; |
13774 | pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */ |
13775 | } |
13776 | break; |
13777 | } |
13778 | case 0x19: |
13779 | { |
13780 | sdwCyclesRemaining -= 11; |
13781 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
13782 | dwTemp = cpu.z80HL + cpu.z80DE; |
13783 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY); |
13784 | cpu.z80HL = dwTemp & 0xffff; |
13785 | break; |
13786 | } |
13787 | case 0x1a: |
13788 | { |
13789 | sdwCyclesRemaining -= 7; |
13790 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
13791 | while (psMemRead->lowAddr != 0xffffffff) |
13792 | { |
13793 | if ((cpu.z80DE >= psMemRead->lowAddr) && (cpu.z80DE <= psMemRead->highAddr)) |
13794 | { |
13795 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13796 | if (psMemRead->memoryCall) |
13797 | { |
13798 | cpu.z80A = psMemRead->memoryCall(cpu.z80DE, psMemRead); |
13799 | } |
13800 | else |
13801 | { |
13802 | cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80DE - psMemRead->lowAddr)); |
13803 | } |
13804 | psMemRead = NULL; |
13805 | break; |
13806 | } |
13807 | ++psMemRead; |
13808 | } |
13809 | |
13810 | if (psMemRead) |
13811 | { |
13812 | cpu.z80A = cpu.z80Base[cpu.z80DE]; |
13813 | } |
13814 | |
13815 | break; |
13816 | } |
13817 | case 0x1b: |
13818 | { |
13819 | sdwCyclesRemaining -= 6; |
13820 | cpu.z80DE--; |
13821 | cpu.z80DE &= 0xffff; |
13822 | break; |
13823 | } |
13824 | case 0x1c: |
13825 | { |
13826 | sdwCyclesRemaining -= 4; |
13827 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
13828 | cpu.z80F |= bPostIncFlags[cpu.z80E++]; |
13829 | break; |
13830 | } |
13831 | case 0x1d: |
13832 | { |
13833 | sdwCyclesRemaining -= 4; |
13834 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
13835 | cpu.z80F |= bPostDecFlags[cpu.z80E--]; |
13836 | break; |
13837 | } |
13838 | case 0x1e: |
13839 | { |
13840 | sdwCyclesRemaining -= 7; |
13841 | cpu.z80E = *pbPC++; /* Get immediate byte into register */ |
13842 | break; |
13843 | } |
13844 | case 0x1f: |
13845 | { |
13846 | sdwCyclesRemaining -= 4; |
13847 | bTemp = (cpu.z80F & Z80_FLAG_CARRY) << 7; |
13848 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY)) | (cpu.z80A & Z80_FLAG_CARRY); |
13849 | cpu.z80A = ((cpu.z80A >> 1) | bTemp); |
13850 | break; |
13851 | } |
13852 | case 0x20: |
13853 | { |
13854 | sdwCyclesRemaining -= 7; |
13855 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
13856 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13857 | sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff; |
13858 | if (!(cpu.z80F & Z80_FLAG_ZERO)) |
13859 | { |
13860 | sdwCyclesRemaining -= 5; |
13861 | pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */ |
13862 | } |
13863 | break; |
13864 | } |
13865 | case 0x21: |
13866 | { |
13867 | sdwCyclesRemaining -= 10; |
13868 | cpu.z80HL = *pbPC++; /* LSB First */ |
13869 | cpu.z80HL |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */ |
13870 | break; |
13871 | } |
13872 | case 0x22: |
13873 | { |
13874 | sdwCyclesRemaining -= 16; |
13875 | dwTemp = *pbPC++; |
13876 | dwTemp |= ((UINT32) *pbPC++ << 8); |
13877 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
13878 | while (psMemWrite->lowAddr != 0xffffffff) |
13879 | { |
13880 | if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr)) |
13881 | { |
13882 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13883 | if (psMemWrite->memoryCall) |
13884 | { |
13885 | psMemWrite->memoryCall(dwTemp, (cpu.z80HL & 0xff), psMemWrite); |
13886 | psMemWrite->memoryCall(dwTemp + 1, (cpu.z80HL >> 8), psMemWrite); |
13887 | } |
13888 | else |
13889 | { |
13890 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80HL; |
13891 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8; |
13892 | } |
13893 | psMemWrite = NULL; |
13894 | break; |
13895 | } |
13896 | ++psMemWrite; |
13897 | } |
13898 | |
13899 | if (psMemWrite) |
13900 | { |
13901 | cpu.z80Base[dwTemp] = (UINT8) cpu.z80HL; |
13902 | cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8); |
13903 | } |
13904 | |
13905 | break; |
13906 | } |
13907 | case 0x23: |
13908 | { |
13909 | sdwCyclesRemaining -= 6; |
13910 | cpu.z80HL++; |
13911 | cpu.z80HL &= 0xffff; |
13912 | break; |
13913 | } |
13914 | case 0x24: |
13915 | { |
13916 | sdwCyclesRemaining -= 4; |
13917 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
13918 | cpu.z80F |= bPostIncFlags[cpu.z80H++]; |
13919 | break; |
13920 | } |
13921 | case 0x25: |
13922 | { |
13923 | sdwCyclesRemaining -= 4; |
13924 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
13925 | cpu.z80F |= bPostDecFlags[cpu.z80H--]; |
13926 | break; |
13927 | } |
13928 | case 0x26: |
13929 | { |
13930 | sdwCyclesRemaining -= 7; |
13931 | cpu.z80H = *pbPC++; /* Get immediate byte into register */ |
13932 | break; |
13933 | } |
13934 | case 0x27: |
13935 | { |
13936 | sdwCyclesRemaining -= 4; |
13937 | dwAddr = (((cpu.z80F & Z80_FLAG_CARRY) | |
13938 | ((cpu.z80F & Z80_FLAG_HALF_CARRY) >> 3) | |
13939 | ((cpu.z80F & Z80_FLAG_NEGATIVE) << 1)) << 8) | cpu.z80A; |
13940 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
13941 | cpu.z80F |= (wDAATable[dwAddr] >> 8); |
13942 | cpu.z80A = wDAATable[dwAddr] & 0xff; |
13943 | break; |
13944 | } |
13945 | case 0x28: |
13946 | { |
13947 | sdwCyclesRemaining -= 7; |
13948 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
13949 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13950 | sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff; |
13951 | if (cpu.z80F & Z80_FLAG_ZERO) |
13952 | { |
13953 | sdwCyclesRemaining -= 5; |
13954 | pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */ |
13955 | } |
13956 | break; |
13957 | } |
13958 | case 0x29: |
13959 | { |
13960 | sdwCyclesRemaining -= 11; |
13961 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
13962 | dwTemp = cpu.z80HL + cpu.z80HL; |
13963 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY); |
13964 | cpu.z80HL = dwTemp & 0xffff; |
13965 | break; |
13966 | } |
13967 | case 0x2a: |
13968 | { |
13969 | sdwCyclesRemaining -= 16; |
13970 | dwAddr = *pbPC++; |
13971 | dwAddr |= ((UINT32) *pbPC++ << 8); |
13972 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
13973 | while (psMemRead->lowAddr != 0xffffffff) |
13974 | { |
13975 | if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr)) |
13976 | { |
13977 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
13978 | if (psMemRead->memoryCall) |
13979 | { |
13980 | cpu.z80HL = psMemRead->memoryCall(dwAddr, psMemRead); |
13981 | cpu.z80HL |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8); |
13982 | } |
13983 | else |
13984 | { |
13985 | cpu.z80HL = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr)); |
13986 | cpu.z80HL |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8); |
13987 | } |
13988 | psMemRead = NULL; |
13989 | break; |
13990 | } |
13991 | ++psMemRead; |
13992 | } |
13993 | |
13994 | if (psMemRead) |
13995 | { |
13996 | cpu.z80HL = cpu.z80Base[dwAddr]; |
13997 | cpu.z80HL |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8); |
13998 | } |
13999 | |
14000 | break; |
14001 | } |
14002 | case 0x2b: |
14003 | { |
14004 | sdwCyclesRemaining -= 6; |
14005 | cpu.z80HL--; |
14006 | cpu.z80HL &= 0xffff; |
14007 | break; |
14008 | } |
14009 | case 0x2c: |
14010 | { |
14011 | sdwCyclesRemaining -= 4; |
14012 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
14013 | cpu.z80F |= bPostIncFlags[cpu.z80L++]; |
14014 | break; |
14015 | } |
14016 | case 0x2d: |
14017 | { |
14018 | sdwCyclesRemaining -= 4; |
14019 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
14020 | cpu.z80F |= bPostDecFlags[cpu.z80L--]; |
14021 | break; |
14022 | } |
14023 | case 0x2e: |
14024 | { |
14025 | sdwCyclesRemaining -= 7; |
14026 | cpu.z80L = *pbPC++; /* Get immediate byte into register */ |
14027 | break; |
14028 | } |
14029 | case 0x2f: |
14030 | { |
14031 | sdwCyclesRemaining -= 4; |
14032 | cpu.z80A ^= 0xff; |
14033 | cpu.z80F |= (Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
14034 | break; |
14035 | } |
14036 | case 0x30: |
14037 | { |
14038 | sdwCyclesRemaining -= 7; |
14039 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
14040 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14041 | sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff; |
14042 | if (!(cpu.z80F & Z80_FLAG_CARRY)) |
14043 | { |
14044 | sdwCyclesRemaining -= 5; |
14045 | pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */ |
14046 | } |
14047 | break; |
14048 | } |
14049 | case 0x31: |
14050 | { |
14051 | sdwCyclesRemaining -= 10; |
14052 | cpu.z80sp = *pbPC++; /* LSB First */ |
14053 | cpu.z80sp |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */ |
14054 | break; |
14055 | } |
14056 | case 0x32: |
14057 | { |
14058 | sdwCyclesRemaining -= 13; |
14059 | dwTemp = *pbPC++; |
14060 | dwTemp |= ((UINT32) *pbPC++ << 8); |
14061 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14062 | while (psMemWrite->lowAddr != 0xffffffff) |
14063 | { |
14064 | if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr)) |
14065 | { |
14066 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14067 | if (psMemWrite->memoryCall) |
14068 | { |
14069 | psMemWrite->memoryCall(dwTemp, cpu.z80A, psMemWrite); |
14070 | } |
14071 | else |
14072 | { |
14073 | *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80A; |
14074 | } |
14075 | psMemWrite = NULL; |
14076 | break; |
14077 | } |
14078 | ++psMemWrite; |
14079 | } |
14080 | |
14081 | if (psMemWrite) |
14082 | { |
14083 | cpu.z80Base[dwTemp] = (UINT8) cpu.z80A; |
14084 | } |
14085 | |
14086 | break; |
14087 | } |
14088 | case 0x33: |
14089 | { |
14090 | sdwCyclesRemaining -= 6; |
14091 | cpu.z80sp++; |
14092 | cpu.z80sp &= 0xffff; |
14093 | break; |
14094 | } |
14095 | case 0x34: |
14096 | { |
14097 | sdwCyclesRemaining -= 11; |
14098 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14099 | while (psMemRead->lowAddr != 0xffffffff) |
14100 | { |
14101 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14102 | { |
14103 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14104 | if (psMemRead->memoryCall) |
14105 | { |
14106 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14107 | } |
14108 | else |
14109 | { |
14110 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14111 | } |
14112 | psMemRead = NULL; |
14113 | break; |
14114 | } |
14115 | ++psMemRead; |
14116 | } |
14117 | |
14118 | if (psMemRead) |
14119 | { |
14120 | bTemp = cpu.z80Base[cpu.z80HL]; |
14121 | } |
14122 | |
14123 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
14124 | cpu.z80F |= bPostIncFlags[bTemp]; |
14125 | bTemp++; |
14126 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14127 | while (psMemWrite->lowAddr != 0xffffffff) |
14128 | { |
14129 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14130 | { |
14131 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14132 | if (psMemWrite->memoryCall) |
14133 | { |
14134 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
14135 | } |
14136 | else |
14137 | { |
14138 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
14139 | } |
14140 | psMemWrite = NULL; |
14141 | break; |
14142 | } |
14143 | ++psMemWrite; |
14144 | } |
14145 | |
14146 | if (psMemWrite) |
14147 | { |
14148 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
14149 | } |
14150 | |
14151 | break; |
14152 | } |
14153 | case 0x35: |
14154 | { |
14155 | sdwCyclesRemaining -= 11; |
14156 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14157 | while (psMemRead->lowAddr != 0xffffffff) |
14158 | { |
14159 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14160 | { |
14161 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14162 | if (psMemRead->memoryCall) |
14163 | { |
14164 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14165 | } |
14166 | else |
14167 | { |
14168 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14169 | } |
14170 | psMemRead = NULL; |
14171 | break; |
14172 | } |
14173 | ++psMemRead; |
14174 | } |
14175 | |
14176 | if (psMemRead) |
14177 | { |
14178 | bTemp = cpu.z80Base[cpu.z80HL]; |
14179 | } |
14180 | |
14181 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
14182 | cpu.z80F |= bPostDecFlags[bTemp]; |
14183 | bTemp--; |
14184 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14185 | while (psMemWrite->lowAddr != 0xffffffff) |
14186 | { |
14187 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14188 | { |
14189 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14190 | if (psMemWrite->memoryCall) |
14191 | { |
14192 | psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite); |
14193 | } |
14194 | else |
14195 | { |
14196 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp; |
14197 | } |
14198 | psMemWrite = NULL; |
14199 | break; |
14200 | } |
14201 | ++psMemWrite; |
14202 | } |
14203 | |
14204 | if (psMemWrite) |
14205 | { |
14206 | cpu.z80Base[cpu.z80HL] = (UINT8) bTemp; |
14207 | } |
14208 | |
14209 | break; |
14210 | } |
14211 | case 0x36: |
14212 | { |
14213 | sdwCyclesRemaining -= 10; |
14214 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14215 | while (psMemWrite->lowAddr != 0xffffffff) |
14216 | { |
14217 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14218 | { |
14219 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14220 | if (psMemWrite->memoryCall) |
14221 | { |
14222 | psMemWrite->memoryCall(cpu.z80HL, *pbPC++, psMemWrite); |
14223 | } |
14224 | else |
14225 | { |
14226 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = *pbPC++; |
14227 | } |
14228 | psMemWrite = NULL; |
14229 | break; |
14230 | } |
14231 | ++psMemWrite; |
14232 | } |
14233 | |
14234 | if (psMemWrite) |
14235 | { |
14236 | cpu.z80Base[cpu.z80HL] = (UINT8) *pbPC++; |
14237 | } |
14238 | |
14239 | break; |
14240 | } |
14241 | case 0x37: |
14242 | { |
14243 | sdwCyclesRemaining -= 4; |
14244 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE); |
14245 | cpu.z80F |= Z80_FLAG_CARRY; |
14246 | break; |
14247 | } |
14248 | case 0x38: |
14249 | { |
14250 | sdwCyclesRemaining -= 7; |
14251 | sdwAddr = (INT8) *pbPC++; /* Get LSB first */ |
14252 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14253 | sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff; |
14254 | if (cpu.z80F & Z80_FLAG_CARRY) |
14255 | { |
14256 | sdwCyclesRemaining -= 5; |
14257 | pbPC = cpu.z80Base + sdwAddr; /* Normalize the address */ |
14258 | } |
14259 | break; |
14260 | } |
14261 | case 0x39: |
14262 | { |
14263 | sdwCyclesRemaining -= 11; |
14264 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY); |
14265 | dwTemp = cpu.z80HL + cpu.z80sp; |
14266 | cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY); |
14267 | cpu.z80HL = dwTemp & 0xffff; |
14268 | break; |
14269 | } |
14270 | case 0x3a: |
14271 | { |
14272 | sdwCyclesRemaining -= 13; |
14273 | dwTemp = *pbPC++; |
14274 | dwTemp |= (((UINT32) *pbPC++) << 8); |
14275 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14276 | while (psMemRead->lowAddr != 0xffffffff) |
14277 | { |
14278 | if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr)) |
14279 | { |
14280 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14281 | if (psMemRead->memoryCall) |
14282 | { |
14283 | cpu.z80A = psMemRead->memoryCall(dwTemp, psMemRead); |
14284 | } |
14285 | else |
14286 | { |
14287 | cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr)); |
14288 | } |
14289 | psMemRead = NULL; |
14290 | break; |
14291 | } |
14292 | ++psMemRead; |
14293 | } |
14294 | |
14295 | if (psMemRead) |
14296 | { |
14297 | cpu.z80A = cpu.z80Base[dwTemp]; |
14298 | } |
14299 | |
14300 | break; |
14301 | } |
14302 | case 0x3b: |
14303 | { |
14304 | sdwCyclesRemaining -= 6; |
14305 | cpu.z80sp--; |
14306 | cpu.z80sp &= 0xffff; |
14307 | break; |
14308 | } |
14309 | case 0x3c: |
14310 | { |
14311 | sdwCyclesRemaining -= 4; |
14312 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE); |
14313 | cpu.z80F |= bPostIncFlags[cpu.z80A++]; |
14314 | break; |
14315 | } |
14316 | case 0x3d: |
14317 | { |
14318 | sdwCyclesRemaining -= 4; |
14319 | cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY); |
14320 | cpu.z80F |= bPostDecFlags[cpu.z80A--]; |
14321 | break; |
14322 | } |
14323 | case 0x3e: |
14324 | { |
14325 | sdwCyclesRemaining -= 7; |
14326 | cpu.z80A = *pbPC++; /* Get immediate byte into register */ |
14327 | break; |
14328 | } |
14329 | case 0x3f: |
14330 | { |
14331 | sdwCyclesRemaining -= 4; |
14332 | bTemp = (cpu.z80F & Z80_FLAG_CARRY) << 4; |
14333 | cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE); |
14334 | cpu.z80F ^= Z80_FLAG_CARRY; |
14335 | break; |
14336 | } |
14337 | case 0x40: |
14338 | { |
14339 | sdwCyclesRemaining -= 4; |
14340 | break; |
14341 | } |
14342 | case 0x41: |
14343 | { |
14344 | sdwCyclesRemaining -= 4; |
14345 | cpu.z80B = cpu.z80C; |
14346 | break; |
14347 | } |
14348 | case 0x42: |
14349 | { |
14350 | sdwCyclesRemaining -= 4; |
14351 | cpu.z80B = cpu.z80D; |
14352 | break; |
14353 | } |
14354 | case 0x43: |
14355 | { |
14356 | sdwCyclesRemaining -= 4; |
14357 | cpu.z80B = cpu.z80E; |
14358 | break; |
14359 | } |
14360 | case 0x44: |
14361 | { |
14362 | sdwCyclesRemaining -= 4; |
14363 | cpu.z80B = cpu.z80H; |
14364 | break; |
14365 | } |
14366 | case 0x45: |
14367 | { |
14368 | sdwCyclesRemaining -= 4; |
14369 | cpu.z80B = cpu.z80L; |
14370 | break; |
14371 | } |
14372 | case 0x46: |
14373 | { |
14374 | sdwCyclesRemaining -= 7; |
14375 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14376 | while (psMemRead->lowAddr != 0xffffffff) |
14377 | { |
14378 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14379 | { |
14380 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14381 | if (psMemRead->memoryCall) |
14382 | { |
14383 | cpu.z80B = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14384 | } |
14385 | else |
14386 | { |
14387 | cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14388 | } |
14389 | psMemRead = NULL; |
14390 | break; |
14391 | } |
14392 | ++psMemRead; |
14393 | } |
14394 | |
14395 | if (psMemRead) |
14396 | { |
14397 | cpu.z80B = cpu.z80Base[cpu.z80HL]; |
14398 | } |
14399 | |
14400 | break; |
14401 | } |
14402 | case 0x47: |
14403 | { |
14404 | sdwCyclesRemaining -= 4; |
14405 | cpu.z80B = cpu.z80A; |
14406 | break; |
14407 | } |
14408 | case 0x48: |
14409 | { |
14410 | sdwCyclesRemaining -= 4; |
14411 | cpu.z80C = cpu.z80B; |
14412 | break; |
14413 | } |
14414 | case 0x49: |
14415 | { |
14416 | sdwCyclesRemaining -= 4; |
14417 | break; |
14418 | } |
14419 | case 0x4a: |
14420 | { |
14421 | sdwCyclesRemaining -= 4; |
14422 | cpu.z80C = cpu.z80D; |
14423 | break; |
14424 | } |
14425 | case 0x4b: |
14426 | { |
14427 | sdwCyclesRemaining -= 4; |
14428 | cpu.z80C = cpu.z80E; |
14429 | break; |
14430 | } |
14431 | case 0x4c: |
14432 | { |
14433 | sdwCyclesRemaining -= 4; |
14434 | cpu.z80C = cpu.z80H; |
14435 | break; |
14436 | } |
14437 | case 0x4d: |
14438 | { |
14439 | sdwCyclesRemaining -= 4; |
14440 | cpu.z80C = cpu.z80L; |
14441 | break; |
14442 | } |
14443 | case 0x4e: |
14444 | { |
14445 | sdwCyclesRemaining -= 7; |
14446 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14447 | while (psMemRead->lowAddr != 0xffffffff) |
14448 | { |
14449 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14450 | { |
14451 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14452 | if (psMemRead->memoryCall) |
14453 | { |
14454 | cpu.z80C = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14455 | } |
14456 | else |
14457 | { |
14458 | cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14459 | } |
14460 | psMemRead = NULL; |
14461 | break; |
14462 | } |
14463 | ++psMemRead; |
14464 | } |
14465 | |
14466 | if (psMemRead) |
14467 | { |
14468 | cpu.z80C = cpu.z80Base[cpu.z80HL]; |
14469 | } |
14470 | |
14471 | break; |
14472 | } |
14473 | case 0x4f: |
14474 | { |
14475 | sdwCyclesRemaining -= 4; |
14476 | cpu.z80C = cpu.z80A; |
14477 | break; |
14478 | } |
14479 | case 0x50: |
14480 | { |
14481 | sdwCyclesRemaining -= 4; |
14482 | cpu.z80D = cpu.z80B; |
14483 | break; |
14484 | } |
14485 | case 0x51: |
14486 | { |
14487 | sdwCyclesRemaining -= 4; |
14488 | cpu.z80D = cpu.z80C; |
14489 | break; |
14490 | } |
14491 | case 0x52: |
14492 | { |
14493 | sdwCyclesRemaining -= 4; |
14494 | break; |
14495 | } |
14496 | case 0x53: |
14497 | { |
14498 | sdwCyclesRemaining -= 4; |
14499 | cpu.z80D = cpu.z80E; |
14500 | break; |
14501 | } |
14502 | case 0x54: |
14503 | { |
14504 | sdwCyclesRemaining -= 4; |
14505 | cpu.z80D = cpu.z80H; |
14506 | break; |
14507 | } |
14508 | case 0x55: |
14509 | { |
14510 | sdwCyclesRemaining -= 4; |
14511 | cpu.z80D = cpu.z80L; |
14512 | break; |
14513 | } |
14514 | case 0x56: |
14515 | { |
14516 | sdwCyclesRemaining -= 7; |
14517 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14518 | while (psMemRead->lowAddr != 0xffffffff) |
14519 | { |
14520 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14521 | { |
14522 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14523 | if (psMemRead->memoryCall) |
14524 | { |
14525 | cpu.z80D = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14526 | } |
14527 | else |
14528 | { |
14529 | cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14530 | } |
14531 | psMemRead = NULL; |
14532 | break; |
14533 | } |
14534 | ++psMemRead; |
14535 | } |
14536 | |
14537 | if (psMemRead) |
14538 | { |
14539 | cpu.z80D = cpu.z80Base[cpu.z80HL]; |
14540 | } |
14541 | |
14542 | break; |
14543 | } |
14544 | case 0x57: |
14545 | { |
14546 | sdwCyclesRemaining -= 4; |
14547 | cpu.z80D = cpu.z80A; |
14548 | break; |
14549 | } |
14550 | case 0x58: |
14551 | { |
14552 | sdwCyclesRemaining -= 4; |
14553 | cpu.z80E = cpu.z80B; |
14554 | break; |
14555 | } |
14556 | case 0x59: |
14557 | { |
14558 | sdwCyclesRemaining -= 4; |
14559 | cpu.z80E = cpu.z80C; |
14560 | break; |
14561 | } |
14562 | case 0x5a: |
14563 | { |
14564 | sdwCyclesRemaining -= 4; |
14565 | cpu.z80E = cpu.z80D; |
14566 | break; |
14567 | } |
14568 | case 0x5b: |
14569 | { |
14570 | sdwCyclesRemaining -= 4; |
14571 | break; |
14572 | } |
14573 | case 0x5c: |
14574 | { |
14575 | sdwCyclesRemaining -= 4; |
14576 | cpu.z80E = cpu.z80H; |
14577 | break; |
14578 | } |
14579 | case 0x5d: |
14580 | { |
14581 | sdwCyclesRemaining -= 4; |
14582 | cpu.z80E = cpu.z80L; |
14583 | break; |
14584 | } |
14585 | case 0x5e: |
14586 | { |
14587 | sdwCyclesRemaining -= 7; |
14588 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14589 | while (psMemRead->lowAddr != 0xffffffff) |
14590 | { |
14591 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14592 | { |
14593 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14594 | if (psMemRead->memoryCall) |
14595 | { |
14596 | cpu.z80E = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14597 | } |
14598 | else |
14599 | { |
14600 | cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14601 | } |
14602 | psMemRead = NULL; |
14603 | break; |
14604 | } |
14605 | ++psMemRead; |
14606 | } |
14607 | |
14608 | if (psMemRead) |
14609 | { |
14610 | cpu.z80E = cpu.z80Base[cpu.z80HL]; |
14611 | } |
14612 | |
14613 | break; |
14614 | } |
14615 | case 0x5f: |
14616 | { |
14617 | sdwCyclesRemaining -= 4; |
14618 | cpu.z80E = cpu.z80A; |
14619 | break; |
14620 | } |
14621 | case 0x60: |
14622 | { |
14623 | sdwCyclesRemaining -= 4; |
14624 | cpu.z80H = cpu.z80B; |
14625 | break; |
14626 | } |
14627 | case 0x61: |
14628 | { |
14629 | sdwCyclesRemaining -= 4; |
14630 | cpu.z80H = cpu.z80C; |
14631 | break; |
14632 | } |
14633 | case 0x62: |
14634 | { |
14635 | sdwCyclesRemaining -= 4; |
14636 | cpu.z80H = cpu.z80D; |
14637 | break; |
14638 | } |
14639 | case 0x63: |
14640 | { |
14641 | sdwCyclesRemaining -= 4; |
14642 | cpu.z80H = cpu.z80E; |
14643 | break; |
14644 | } |
14645 | case 0x64: |
14646 | { |
14647 | sdwCyclesRemaining -= 4; |
14648 | break; |
14649 | } |
14650 | case 0x65: |
14651 | { |
14652 | sdwCyclesRemaining -= 4; |
14653 | cpu.z80H = cpu.z80L; |
14654 | break; |
14655 | } |
14656 | case 0x66: |
14657 | { |
14658 | sdwCyclesRemaining -= 7; |
14659 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14660 | while (psMemRead->lowAddr != 0xffffffff) |
14661 | { |
14662 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14663 | { |
14664 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14665 | if (psMemRead->memoryCall) |
14666 | { |
14667 | cpu.z80H = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14668 | } |
14669 | else |
14670 | { |
14671 | cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14672 | } |
14673 | psMemRead = NULL; |
14674 | break; |
14675 | } |
14676 | ++psMemRead; |
14677 | } |
14678 | |
14679 | if (psMemRead) |
14680 | { |
14681 | cpu.z80H = cpu.z80Base[cpu.z80HL]; |
14682 | } |
14683 | |
14684 | break; |
14685 | } |
14686 | case 0x67: |
14687 | { |
14688 | sdwCyclesRemaining -= 4; |
14689 | cpu.z80H = cpu.z80A; |
14690 | break; |
14691 | } |
14692 | case 0x68: |
14693 | { |
14694 | sdwCyclesRemaining -= 4; |
14695 | cpu.z80L = cpu.z80B; |
14696 | break; |
14697 | } |
14698 | case 0x69: |
14699 | { |
14700 | sdwCyclesRemaining -= 4; |
14701 | cpu.z80L = cpu.z80C; |
14702 | break; |
14703 | } |
14704 | case 0x6a: |
14705 | { |
14706 | sdwCyclesRemaining -= 4; |
14707 | cpu.z80L = cpu.z80D; |
14708 | break; |
14709 | } |
14710 | case 0x6b: |
14711 | { |
14712 | sdwCyclesRemaining -= 4; |
14713 | cpu.z80L = cpu.z80E; |
14714 | break; |
14715 | } |
14716 | case 0x6c: |
14717 | { |
14718 | sdwCyclesRemaining -= 4; |
14719 | cpu.z80L = cpu.z80H; |
14720 | break; |
14721 | } |
14722 | case 0x6d: |
14723 | { |
14724 | sdwCyclesRemaining -= 4; |
14725 | break; |
14726 | } |
14727 | case 0x6e: |
14728 | { |
14729 | sdwCyclesRemaining -= 7; |
14730 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
14731 | while (psMemRead->lowAddr != 0xffffffff) |
14732 | { |
14733 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
14734 | { |
14735 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14736 | if (psMemRead->memoryCall) |
14737 | { |
14738 | cpu.z80L = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
14739 | } |
14740 | else |
14741 | { |
14742 | cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
14743 | } |
14744 | psMemRead = NULL; |
14745 | break; |
14746 | } |
14747 | ++psMemRead; |
14748 | } |
14749 | |
14750 | if (psMemRead) |
14751 | { |
14752 | cpu.z80L = cpu.z80Base[cpu.z80HL]; |
14753 | } |
14754 | |
14755 | break; |
14756 | } |
14757 | case 0x6f: |
14758 | { |
14759 | sdwCyclesRemaining -= 4; |
14760 | cpu.z80L = cpu.z80A; |
14761 | break; |
14762 | } |
14763 | case 0x70: |
14764 | { |
14765 | sdwCyclesRemaining -= 7; |
14766 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14767 | while (psMemWrite->lowAddr != 0xffffffff) |
14768 | { |
14769 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14770 | { |
14771 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14772 | if (psMemWrite->memoryCall) |
14773 | { |
14774 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80B, psMemWrite); |
14775 | } |
14776 | else |
14777 | { |
14778 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80B; |
14779 | } |
14780 | psMemWrite = NULL; |
14781 | break; |
14782 | } |
14783 | ++psMemWrite; |
14784 | } |
14785 | |
14786 | if (psMemWrite) |
14787 | { |
14788 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80B; |
14789 | } |
14790 | |
14791 | break; |
14792 | } |
14793 | case 0x71: |
14794 | { |
14795 | sdwCyclesRemaining -= 7; |
14796 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14797 | while (psMemWrite->lowAddr != 0xffffffff) |
14798 | { |
14799 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14800 | { |
14801 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14802 | if (psMemWrite->memoryCall) |
14803 | { |
14804 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80C, psMemWrite); |
14805 | } |
14806 | else |
14807 | { |
14808 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80C; |
14809 | } |
14810 | psMemWrite = NULL; |
14811 | break; |
14812 | } |
14813 | ++psMemWrite; |
14814 | } |
14815 | |
14816 | if (psMemWrite) |
14817 | { |
14818 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80C; |
14819 | } |
14820 | |
14821 | break; |
14822 | } |
14823 | case 0x72: |
14824 | { |
14825 | sdwCyclesRemaining -= 7; |
14826 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14827 | while (psMemWrite->lowAddr != 0xffffffff) |
14828 | { |
14829 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14830 | { |
14831 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14832 | if (psMemWrite->memoryCall) |
14833 | { |
14834 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80D, psMemWrite); |
14835 | } |
14836 | else |
14837 | { |
14838 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80D; |
14839 | } |
14840 | psMemWrite = NULL; |
14841 | break; |
14842 | } |
14843 | ++psMemWrite; |
14844 | } |
14845 | |
14846 | if (psMemWrite) |
14847 | { |
14848 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80D; |
14849 | } |
14850 | |
14851 | break; |
14852 | } |
14853 | case 0x73: |
14854 | { |
14855 | sdwCyclesRemaining -= 7; |
14856 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14857 | while (psMemWrite->lowAddr != 0xffffffff) |
14858 | { |
14859 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14860 | { |
14861 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14862 | if (psMemWrite->memoryCall) |
14863 | { |
14864 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80E, psMemWrite); |
14865 | } |
14866 | else |
14867 | { |
14868 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80E; |
14869 | } |
14870 | psMemWrite = NULL; |
14871 | break; |
14872 | } |
14873 | ++psMemWrite; |
14874 | } |
14875 | |
14876 | if (psMemWrite) |
14877 | { |
14878 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80E; |
14879 | } |
14880 | |
14881 | break; |
14882 | } |
14883 | case 0x74: |
14884 | { |
14885 | sdwCyclesRemaining -= 7; |
14886 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14887 | while (psMemWrite->lowAddr != 0xffffffff) |
14888 | { |
14889 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14890 | { |
14891 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14892 | if (psMemWrite->memoryCall) |
14893 | { |
14894 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80H, psMemWrite); |
14895 | } |
14896 | else |
14897 | { |
14898 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80H; |
14899 | } |
14900 | psMemWrite = NULL; |
14901 | break; |
14902 | } |
14903 | ++psMemWrite; |
14904 | } |
14905 | |
14906 | if (psMemWrite) |
14907 | { |
14908 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80H; |
14909 | } |
14910 | |
14911 | break; |
14912 | } |
14913 | case 0x75: |
14914 | { |
14915 | sdwCyclesRemaining -= 7; |
14916 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14917 | while (psMemWrite->lowAddr != 0xffffffff) |
14918 | { |
14919 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14920 | { |
14921 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14922 | if (psMemWrite->memoryCall) |
14923 | { |
14924 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80L, psMemWrite); |
14925 | } |
14926 | else |
14927 | { |
14928 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80L; |
14929 | } |
14930 | psMemWrite = NULL; |
14931 | break; |
14932 | } |
14933 | ++psMemWrite; |
14934 | } |
14935 | |
14936 | if (psMemWrite) |
14937 | { |
14938 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80L; |
14939 | } |
14940 | |
14941 | break; |
14942 | } |
14943 | case 0x76: |
14944 | { |
14945 | sdwCyclesRemaining -= 4; |
14946 | cpu.z80halted = 1; |
14947 | dwElapsedTicks += sdwCyclesRemaining; |
14948 | sdwCyclesRemaining = 0; |
14949 | break; |
14950 | } |
14951 | case 0x77: |
14952 | { |
14953 | sdwCyclesRemaining -= 7; |
14954 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
14955 | while (psMemWrite->lowAddr != 0xffffffff) |
14956 | { |
14957 | if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr)) |
14958 | { |
14959 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
14960 | if (psMemWrite->memoryCall) |
14961 | { |
14962 | psMemWrite->memoryCall(cpu.z80HL, cpu.z80A, psMemWrite); |
14963 | } |
14964 | else |
14965 | { |
14966 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80A; |
14967 | } |
14968 | psMemWrite = NULL; |
14969 | break; |
14970 | } |
14971 | ++psMemWrite; |
14972 | } |
14973 | |
14974 | if (psMemWrite) |
14975 | { |
14976 | cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80A; |
14977 | } |
14978 | |
14979 | break; |
14980 | } |
14981 | case 0x78: |
14982 | { |
14983 | sdwCyclesRemaining -= 4; |
14984 | cpu.z80A = cpu.z80B; |
14985 | break; |
14986 | } |
14987 | case 0x79: |
14988 | { |
14989 | sdwCyclesRemaining -= 4; |
14990 | cpu.z80A = cpu.z80C; |
14991 | break; |
14992 | } |
14993 | case 0x7a: |
14994 | { |
14995 | sdwCyclesRemaining -= 4; |
14996 | cpu.z80A = cpu.z80D; |
14997 | break; |
14998 | } |
14999 | case 0x7b: |
15000 | { |
15001 | sdwCyclesRemaining -= 4; |
15002 | cpu.z80A = cpu.z80E; |
15003 | break; |
15004 | } |
15005 | case 0x7c: |
15006 | { |
15007 | sdwCyclesRemaining -= 4; |
15008 | cpu.z80A = cpu.z80H; |
15009 | break; |
15010 | } |
15011 | case 0x7d: |
15012 | { |
15013 | sdwCyclesRemaining -= 4; |
15014 | cpu.z80A = cpu.z80L; |
15015 | break; |
15016 | } |
15017 | case 0x7e: |
15018 | { |
15019 | sdwCyclesRemaining -= 7; |
15020 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15021 | while (psMemRead->lowAddr != 0xffffffff) |
15022 | { |
15023 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15024 | { |
15025 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15026 | if (psMemRead->memoryCall) |
15027 | { |
15028 | cpu.z80A = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15029 | } |
15030 | else |
15031 | { |
15032 | cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15033 | } |
15034 | psMemRead = NULL; |
15035 | break; |
15036 | } |
15037 | ++psMemRead; |
15038 | } |
15039 | |
15040 | if (psMemRead) |
15041 | { |
15042 | cpu.z80A = cpu.z80Base[cpu.z80HL]; |
15043 | } |
15044 | |
15045 | break; |
15046 | } |
15047 | case 0x7f: |
15048 | { |
15049 | sdwCyclesRemaining -= 4; |
15050 | break; |
15051 | } |
15052 | case 0x80: |
15053 | { |
15054 | sdwCyclesRemaining -= 4; |
15055 | bTemp2 = cpu.z80A + cpu.z80B; |
15056 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15057 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15058 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80B]; |
15059 | cpu.z80A = bTemp2; |
15060 | break; |
15061 | } |
15062 | case 0x81: |
15063 | { |
15064 | sdwCyclesRemaining -= 4; |
15065 | bTemp2 = cpu.z80A + cpu.z80C; |
15066 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15067 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15068 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80C]; |
15069 | cpu.z80A = bTemp2; |
15070 | break; |
15071 | } |
15072 | case 0x82: |
15073 | { |
15074 | sdwCyclesRemaining -= 4; |
15075 | bTemp2 = cpu.z80A + cpu.z80D; |
15076 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15077 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15078 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80D]; |
15079 | cpu.z80A = bTemp2; |
15080 | break; |
15081 | } |
15082 | case 0x83: |
15083 | { |
15084 | sdwCyclesRemaining -= 4; |
15085 | bTemp2 = cpu.z80A + cpu.z80E; |
15086 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15087 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15088 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80E]; |
15089 | cpu.z80A = bTemp2; |
15090 | break; |
15091 | } |
15092 | case 0x84: |
15093 | { |
15094 | sdwCyclesRemaining -= 4; |
15095 | bTemp2 = cpu.z80A + cpu.z80H; |
15096 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15097 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15098 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80H]; |
15099 | cpu.z80A = bTemp2; |
15100 | break; |
15101 | } |
15102 | case 0x85: |
15103 | { |
15104 | sdwCyclesRemaining -= 4; |
15105 | bTemp2 = cpu.z80A + cpu.z80L; |
15106 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15107 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15108 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80L]; |
15109 | cpu.z80A = bTemp2; |
15110 | break; |
15111 | } |
15112 | case 0x86: |
15113 | { |
15114 | sdwCyclesRemaining -= 7; |
15115 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15116 | while (psMemRead->lowAddr != 0xffffffff) |
15117 | { |
15118 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15119 | { |
15120 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15121 | if (psMemRead->memoryCall) |
15122 | { |
15123 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15124 | } |
15125 | else |
15126 | { |
15127 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15128 | } |
15129 | psMemRead = NULL; |
15130 | break; |
15131 | } |
15132 | ++psMemRead; |
15133 | } |
15134 | |
15135 | if (psMemRead) |
15136 | { |
15137 | bTemp = cpu.z80Base[cpu.z80HL]; |
15138 | } |
15139 | |
15140 | bTemp2 = cpu.z80A + bTemp; |
15141 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15142 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15143 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
15144 | cpu.z80A = bTemp2; |
15145 | break; |
15146 | } |
15147 | case 0x87: |
15148 | { |
15149 | sdwCyclesRemaining -= 4; |
15150 | bTemp2 = cpu.z80A + cpu.z80A; |
15151 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15152 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15153 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80A]; |
15154 | cpu.z80A = bTemp2; |
15155 | break; |
15156 | } |
15157 | case 0x88: |
15158 | { |
15159 | sdwCyclesRemaining -= 4; |
15160 | bTemp2 = cpu.z80A + cpu.z80B + (cpu.z80F & Z80_FLAG_CARRY); |
15161 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15162 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15163 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80B | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15164 | cpu.z80A = bTemp2; |
15165 | break; |
15166 | } |
15167 | case 0x89: |
15168 | { |
15169 | sdwCyclesRemaining -= 4; |
15170 | bTemp2 = cpu.z80A + cpu.z80C + (cpu.z80F & Z80_FLAG_CARRY); |
15171 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15172 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15173 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80C | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15174 | cpu.z80A = bTemp2; |
15175 | break; |
15176 | } |
15177 | case 0x8a: |
15178 | { |
15179 | sdwCyclesRemaining -= 4; |
15180 | bTemp2 = cpu.z80A + cpu.z80D + (cpu.z80F & Z80_FLAG_CARRY); |
15181 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15182 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15183 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80D | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15184 | cpu.z80A = bTemp2; |
15185 | break; |
15186 | } |
15187 | case 0x8b: |
15188 | { |
15189 | sdwCyclesRemaining -= 4; |
15190 | bTemp2 = cpu.z80A + cpu.z80E + (cpu.z80F & Z80_FLAG_CARRY); |
15191 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15192 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15193 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80E | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15194 | cpu.z80A = bTemp2; |
15195 | break; |
15196 | } |
15197 | case 0x8c: |
15198 | { |
15199 | sdwCyclesRemaining -= 4; |
15200 | bTemp2 = cpu.z80A + cpu.z80H + (cpu.z80F & Z80_FLAG_CARRY); |
15201 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15202 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15203 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80H | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15204 | cpu.z80A = bTemp2; |
15205 | break; |
15206 | } |
15207 | case 0x8d: |
15208 | { |
15209 | sdwCyclesRemaining -= 4; |
15210 | bTemp2 = cpu.z80A + cpu.z80L + (cpu.z80F & Z80_FLAG_CARRY); |
15211 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15212 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15213 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80L | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15214 | cpu.z80A = bTemp2; |
15215 | break; |
15216 | } |
15217 | case 0x8e: |
15218 | { |
15219 | sdwCyclesRemaining -= 7; |
15220 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15221 | while (psMemRead->lowAddr != 0xffffffff) |
15222 | { |
15223 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15224 | { |
15225 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15226 | if (psMemRead->memoryCall) |
15227 | { |
15228 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15229 | } |
15230 | else |
15231 | { |
15232 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15233 | } |
15234 | psMemRead = NULL; |
15235 | break; |
15236 | } |
15237 | ++psMemRead; |
15238 | } |
15239 | |
15240 | if (psMemRead) |
15241 | { |
15242 | bTemp = cpu.z80Base[cpu.z80HL]; |
15243 | } |
15244 | |
15245 | bTemp2 = cpu.z80A + bTemp + (cpu.z80F & Z80_FLAG_CARRY); |
15246 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15247 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15248 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15249 | cpu.z80A = bTemp2; |
15250 | break; |
15251 | } |
15252 | case 0x8f: |
15253 | { |
15254 | sdwCyclesRemaining -= 4; |
15255 | bTemp2 = cpu.z80A + cpu.z80A + (cpu.z80F & Z80_FLAG_CARRY); |
15256 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15257 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15258 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80A | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15259 | cpu.z80A = bTemp2; |
15260 | break; |
15261 | } |
15262 | case 0x90: |
15263 | { |
15264 | sdwCyclesRemaining -= 4; |
15265 | bTemp2 = cpu.z80A - cpu.z80B; |
15266 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15267 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15268 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B]; |
15269 | cpu.z80A = bTemp2; |
15270 | break; |
15271 | } |
15272 | case 0x91: |
15273 | { |
15274 | sdwCyclesRemaining -= 4; |
15275 | bTemp2 = cpu.z80A - cpu.z80C; |
15276 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15277 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15278 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C]; |
15279 | cpu.z80A = bTemp2; |
15280 | break; |
15281 | } |
15282 | case 0x92: |
15283 | { |
15284 | sdwCyclesRemaining -= 4; |
15285 | bTemp2 = cpu.z80A - cpu.z80D; |
15286 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15287 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15288 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D]; |
15289 | cpu.z80A = bTemp2; |
15290 | break; |
15291 | } |
15292 | case 0x93: |
15293 | { |
15294 | sdwCyclesRemaining -= 4; |
15295 | bTemp2 = cpu.z80A - cpu.z80E; |
15296 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15297 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15298 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E]; |
15299 | cpu.z80A = bTemp2; |
15300 | break; |
15301 | } |
15302 | case 0x94: |
15303 | { |
15304 | sdwCyclesRemaining -= 4; |
15305 | bTemp2 = cpu.z80A - cpu.z80H; |
15306 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15307 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15308 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H]; |
15309 | cpu.z80A = bTemp2; |
15310 | break; |
15311 | } |
15312 | case 0x95: |
15313 | { |
15314 | sdwCyclesRemaining -= 4; |
15315 | bTemp2 = cpu.z80A - cpu.z80L; |
15316 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15317 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15318 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L]; |
15319 | cpu.z80A = bTemp2; |
15320 | break; |
15321 | } |
15322 | case 0x96: |
15323 | { |
15324 | sdwCyclesRemaining -= 7; |
15325 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15326 | while (psMemRead->lowAddr != 0xffffffff) |
15327 | { |
15328 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15329 | { |
15330 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15331 | if (psMemRead->memoryCall) |
15332 | { |
15333 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15334 | } |
15335 | else |
15336 | { |
15337 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15338 | } |
15339 | psMemRead = NULL; |
15340 | break; |
15341 | } |
15342 | ++psMemRead; |
15343 | } |
15344 | |
15345 | if (psMemRead) |
15346 | { |
15347 | bTemp = cpu.z80Base[cpu.z80HL]; |
15348 | } |
15349 | |
15350 | bTemp2 = cpu.z80A - bTemp; |
15351 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15352 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15353 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
15354 | cpu.z80A = bTemp2; |
15355 | break; |
15356 | } |
15357 | case 0x97: |
15358 | { |
15359 | sdwCyclesRemaining -= 4; |
15360 | bTemp2 = cpu.z80A - cpu.z80A; |
15361 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15362 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15363 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A]; |
15364 | cpu.z80A = bTemp2; |
15365 | break; |
15366 | } |
15367 | case 0x98: |
15368 | { |
15369 | sdwCyclesRemaining -= 4; |
15370 | bTemp2 = cpu.z80A - cpu.z80B - (cpu.z80F & Z80_FLAG_CARRY); |
15371 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15372 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15373 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15374 | cpu.z80A = bTemp2; |
15375 | break; |
15376 | } |
15377 | case 0x99: |
15378 | { |
15379 | sdwCyclesRemaining -= 4; |
15380 | bTemp2 = cpu.z80A - cpu.z80C - (cpu.z80F & Z80_FLAG_CARRY); |
15381 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15382 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15383 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15384 | cpu.z80A = bTemp2; |
15385 | break; |
15386 | } |
15387 | case 0x9a: |
15388 | { |
15389 | sdwCyclesRemaining -= 4; |
15390 | bTemp2 = cpu.z80A - cpu.z80D - (cpu.z80F & Z80_FLAG_CARRY); |
15391 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15392 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15393 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15394 | cpu.z80A = bTemp2; |
15395 | break; |
15396 | } |
15397 | case 0x9b: |
15398 | { |
15399 | sdwCyclesRemaining -= 4; |
15400 | bTemp2 = cpu.z80A - cpu.z80E - (cpu.z80F & Z80_FLAG_CARRY); |
15401 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15402 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15403 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15404 | cpu.z80A = bTemp2; |
15405 | break; |
15406 | } |
15407 | case 0x9c: |
15408 | { |
15409 | sdwCyclesRemaining -= 4; |
15410 | bTemp2 = cpu.z80A - cpu.z80H - (cpu.z80F & Z80_FLAG_CARRY); |
15411 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15412 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15413 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15414 | cpu.z80A = bTemp2; |
15415 | break; |
15416 | } |
15417 | case 0x9d: |
15418 | { |
15419 | sdwCyclesRemaining -= 4; |
15420 | bTemp2 = cpu.z80A - cpu.z80L - (cpu.z80F & Z80_FLAG_CARRY); |
15421 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15422 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15423 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15424 | cpu.z80A = bTemp2; |
15425 | break; |
15426 | } |
15427 | case 0x9e: |
15428 | { |
15429 | sdwCyclesRemaining -= 7; |
15430 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15431 | while (psMemRead->lowAddr != 0xffffffff) |
15432 | { |
15433 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15434 | { |
15435 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15436 | if (psMemRead->memoryCall) |
15437 | { |
15438 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15439 | } |
15440 | else |
15441 | { |
15442 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15443 | } |
15444 | psMemRead = NULL; |
15445 | break; |
15446 | } |
15447 | ++psMemRead; |
15448 | } |
15449 | |
15450 | if (psMemRead) |
15451 | { |
15452 | bTemp = cpu.z80Base[cpu.z80HL]; |
15453 | } |
15454 | |
15455 | bTemp2 = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY); |
15456 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15457 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15458 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15459 | cpu.z80A = bTemp2; |
15460 | break; |
15461 | } |
15462 | case 0x9f: |
15463 | { |
15464 | sdwCyclesRemaining -= 4; |
15465 | bTemp2 = cpu.z80A - cpu.z80A - (cpu.z80F & Z80_FLAG_CARRY); |
15466 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15467 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15468 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
15469 | cpu.z80A = bTemp2; |
15470 | break; |
15471 | } |
15472 | case 0xa0: |
15473 | { |
15474 | sdwCyclesRemaining -= 4; |
15475 | cpu.z80A &= cpu.z80B; |
15476 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15477 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15478 | |
15479 | break; |
15480 | } |
15481 | case 0xa1: |
15482 | { |
15483 | sdwCyclesRemaining -= 4; |
15484 | cpu.z80A &= cpu.z80C; |
15485 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15486 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15487 | |
15488 | break; |
15489 | } |
15490 | case 0xa2: |
15491 | { |
15492 | sdwCyclesRemaining -= 4; |
15493 | cpu.z80A &= cpu.z80D; |
15494 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15495 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15496 | |
15497 | break; |
15498 | } |
15499 | case 0xa3: |
15500 | { |
15501 | sdwCyclesRemaining -= 4; |
15502 | cpu.z80A &= cpu.z80E; |
15503 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15504 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15505 | |
15506 | break; |
15507 | } |
15508 | case 0xa4: |
15509 | { |
15510 | sdwCyclesRemaining -= 4; |
15511 | cpu.z80A &= cpu.z80H; |
15512 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15513 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15514 | |
15515 | break; |
15516 | } |
15517 | case 0xa5: |
15518 | { |
15519 | sdwCyclesRemaining -= 4; |
15520 | cpu.z80A &= cpu.z80L; |
15521 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15522 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15523 | |
15524 | break; |
15525 | } |
15526 | case 0xa6: |
15527 | { |
15528 | sdwCyclesRemaining -= 7; |
15529 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15530 | while (psMemRead->lowAddr != 0xffffffff) |
15531 | { |
15532 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15533 | { |
15534 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15535 | if (psMemRead->memoryCall) |
15536 | { |
15537 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15538 | } |
15539 | else |
15540 | { |
15541 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15542 | } |
15543 | psMemRead = NULL; |
15544 | break; |
15545 | } |
15546 | ++psMemRead; |
15547 | } |
15548 | |
15549 | if (psMemRead) |
15550 | { |
15551 | bTemp = cpu.z80Base[cpu.z80HL]; |
15552 | } |
15553 | |
15554 | cpu.z80A &= bTemp; |
15555 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15556 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15557 | |
15558 | break; |
15559 | } |
15560 | case 0xa7: |
15561 | { |
15562 | sdwCyclesRemaining -= 4; |
15563 | cpu.z80A &= cpu.z80A; |
15564 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15565 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
15566 | |
15567 | break; |
15568 | } |
15569 | case 0xa8: |
15570 | { |
15571 | sdwCyclesRemaining -= 4; |
15572 | cpu.z80A ^= cpu.z80B; |
15573 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15574 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15575 | |
15576 | break; |
15577 | } |
15578 | case 0xa9: |
15579 | { |
15580 | sdwCyclesRemaining -= 4; |
15581 | cpu.z80A ^= cpu.z80C; |
15582 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15583 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15584 | |
15585 | break; |
15586 | } |
15587 | case 0xaa: |
15588 | { |
15589 | sdwCyclesRemaining -= 4; |
15590 | cpu.z80A ^= cpu.z80D; |
15591 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15592 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15593 | |
15594 | break; |
15595 | } |
15596 | case 0xab: |
15597 | { |
15598 | sdwCyclesRemaining -= 4; |
15599 | cpu.z80A ^= cpu.z80E; |
15600 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15601 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15602 | |
15603 | break; |
15604 | } |
15605 | case 0xac: |
15606 | { |
15607 | sdwCyclesRemaining -= 4; |
15608 | cpu.z80A ^= cpu.z80H; |
15609 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15610 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15611 | |
15612 | break; |
15613 | } |
15614 | case 0xad: |
15615 | { |
15616 | sdwCyclesRemaining -= 4; |
15617 | cpu.z80A ^= cpu.z80L; |
15618 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15619 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15620 | |
15621 | break; |
15622 | } |
15623 | case 0xae: |
15624 | { |
15625 | sdwCyclesRemaining -= 7; |
15626 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15627 | while (psMemRead->lowAddr != 0xffffffff) |
15628 | { |
15629 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15630 | { |
15631 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15632 | if (psMemRead->memoryCall) |
15633 | { |
15634 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15635 | } |
15636 | else |
15637 | { |
15638 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15639 | } |
15640 | psMemRead = NULL; |
15641 | break; |
15642 | } |
15643 | ++psMemRead; |
15644 | } |
15645 | |
15646 | if (psMemRead) |
15647 | { |
15648 | bTemp = cpu.z80Base[cpu.z80HL]; |
15649 | } |
15650 | |
15651 | cpu.z80A ^= bTemp; |
15652 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15653 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15654 | |
15655 | break; |
15656 | } |
15657 | case 0xaf: |
15658 | { |
15659 | sdwCyclesRemaining -= 4; |
15660 | cpu.z80A ^= cpu.z80A; |
15661 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15662 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15663 | |
15664 | break; |
15665 | } |
15666 | case 0xb0: |
15667 | { |
15668 | sdwCyclesRemaining -= 4; |
15669 | cpu.z80A |= cpu.z80B; |
15670 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15671 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15672 | |
15673 | break; |
15674 | } |
15675 | case 0xb1: |
15676 | { |
15677 | sdwCyclesRemaining -= 4; |
15678 | cpu.z80A |= cpu.z80C; |
15679 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15680 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15681 | |
15682 | break; |
15683 | } |
15684 | case 0xb2: |
15685 | { |
15686 | sdwCyclesRemaining -= 4; |
15687 | cpu.z80A |= cpu.z80D; |
15688 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15689 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15690 | |
15691 | break; |
15692 | } |
15693 | case 0xb3: |
15694 | { |
15695 | sdwCyclesRemaining -= 4; |
15696 | cpu.z80A |= cpu.z80E; |
15697 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15698 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15699 | |
15700 | break; |
15701 | } |
15702 | case 0xb4: |
15703 | { |
15704 | sdwCyclesRemaining -= 4; |
15705 | cpu.z80A |= cpu.z80H; |
15706 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15707 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15708 | |
15709 | break; |
15710 | } |
15711 | case 0xb5: |
15712 | { |
15713 | sdwCyclesRemaining -= 4; |
15714 | cpu.z80A |= cpu.z80L; |
15715 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15716 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15717 | |
15718 | break; |
15719 | } |
15720 | case 0xb6: |
15721 | { |
15722 | sdwCyclesRemaining -= 7; |
15723 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15724 | while (psMemRead->lowAddr != 0xffffffff) |
15725 | { |
15726 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15727 | { |
15728 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15729 | if (psMemRead->memoryCall) |
15730 | { |
15731 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15732 | } |
15733 | else |
15734 | { |
15735 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15736 | } |
15737 | psMemRead = NULL; |
15738 | break; |
15739 | } |
15740 | ++psMemRead; |
15741 | } |
15742 | |
15743 | if (psMemRead) |
15744 | { |
15745 | bTemp = cpu.z80Base[cpu.z80HL]; |
15746 | } |
15747 | |
15748 | cpu.z80A |= bTemp; |
15749 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15750 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15751 | |
15752 | break; |
15753 | } |
15754 | case 0xb7: |
15755 | { |
15756 | sdwCyclesRemaining -= 4; |
15757 | cpu.z80A |= cpu.z80A; |
15758 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
15759 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
15760 | |
15761 | break; |
15762 | } |
15763 | case 0xb8: |
15764 | { |
15765 | sdwCyclesRemaining -= 4; |
15766 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15767 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15768 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B]; |
15769 | break; |
15770 | } |
15771 | case 0xb9: |
15772 | { |
15773 | sdwCyclesRemaining -= 4; |
15774 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15775 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15776 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C]; |
15777 | break; |
15778 | } |
15779 | case 0xba: |
15780 | { |
15781 | sdwCyclesRemaining -= 4; |
15782 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15783 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15784 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D]; |
15785 | break; |
15786 | } |
15787 | case 0xbb: |
15788 | { |
15789 | sdwCyclesRemaining -= 4; |
15790 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15791 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15792 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E]; |
15793 | break; |
15794 | } |
15795 | case 0xbc: |
15796 | { |
15797 | sdwCyclesRemaining -= 4; |
15798 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15799 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15800 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H]; |
15801 | break; |
15802 | } |
15803 | case 0xbd: |
15804 | { |
15805 | sdwCyclesRemaining -= 4; |
15806 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15807 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15808 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L]; |
15809 | break; |
15810 | } |
15811 | case 0xbe: |
15812 | { |
15813 | sdwCyclesRemaining -= 7; |
15814 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15815 | while (psMemRead->lowAddr != 0xffffffff) |
15816 | { |
15817 | if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr)) |
15818 | { |
15819 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15820 | if (psMemRead->memoryCall) |
15821 | { |
15822 | bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead); |
15823 | } |
15824 | else |
15825 | { |
15826 | bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr)); |
15827 | } |
15828 | psMemRead = NULL; |
15829 | break; |
15830 | } |
15831 | ++psMemRead; |
15832 | } |
15833 | |
15834 | if (psMemRead) |
15835 | { |
15836 | bTemp = cpu.z80Base[cpu.z80HL]; |
15837 | } |
15838 | |
15839 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15840 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15841 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
15842 | break; |
15843 | } |
15844 | case 0xbf: |
15845 | { |
15846 | sdwCyclesRemaining -= 4; |
15847 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15848 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15849 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A]; |
15850 | break; |
15851 | } |
15852 | case 0xc0: |
15853 | { |
15854 | sdwCyclesRemaining -= 5; |
15855 | if (!(cpu.z80F & Z80_FLAG_ZERO)) |
15856 | { |
15857 | dwElapsedTicks += 6; |
15858 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
15859 | dwAddr = *pbSP++; /* Pop LSB */ |
15860 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
15861 | cpu.z80sp += 2; /* Pop the word off */ |
15862 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
15863 | } |
15864 | break; |
15865 | } |
15866 | case 0xc1: |
15867 | { |
15868 | sdwCyclesRemaining -= 10; |
15869 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
15870 | while (psMemRead->lowAddr != 0xffffffff) |
15871 | { |
15872 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
15873 | { |
15874 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15875 | if (psMemRead->memoryCall) |
15876 | { |
15877 | cpu.z80BC = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
15878 | cpu.z80BC |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
15879 | } |
15880 | else |
15881 | { |
15882 | cpu.z80BC = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
15883 | cpu.z80BC |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
15884 | } |
15885 | psMemRead = NULL; |
15886 | break; |
15887 | } |
15888 | ++psMemRead; |
15889 | } |
15890 | |
15891 | if (psMemRead) |
15892 | { |
15893 | cpu.z80BC = cpu.z80Base[cpu.z80sp]; |
15894 | cpu.z80BC |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
15895 | } |
15896 | |
15897 | cpu.z80sp += 2; |
15898 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
15899 | break; |
15900 | } |
15901 | case 0xc2: |
15902 | { |
15903 | sdwCyclesRemaining -= 10; |
15904 | dwAddr = *pbPC++; /* Get LSB first */ |
15905 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
15906 | if (!(cpu.z80F & Z80_FLAG_ZERO)) |
15907 | { |
15908 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
15909 | } |
15910 | break; |
15911 | } |
15912 | case 0xc3: |
15913 | { |
15914 | sdwCyclesRemaining -= 10; |
15915 | dwAddr = *pbPC++; /* Get LSB first */ |
15916 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
15917 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
15918 | break; |
15919 | } |
15920 | case 0xc4: |
15921 | { |
15922 | sdwCyclesRemaining -= 10; |
15923 | dwAddr = *pbPC++; /* Get LSB first */ |
15924 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
15925 | if (!(cpu.z80F & Z80_FLAG_ZERO)) |
15926 | { |
15927 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15928 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
15929 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
15930 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
15931 | cpu.z80sp -= 2; /* Back our stack up */ |
15932 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
15933 | } |
15934 | break; |
15935 | } |
15936 | case 0xc5: |
15937 | { |
15938 | sdwCyclesRemaining -= 11; |
15939 | cpu.z80sp -= 2; |
15940 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
15941 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
15942 | while (psMemWrite->lowAddr != 0xffffffff) |
15943 | { |
15944 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
15945 | { |
15946 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15947 | if (psMemWrite->memoryCall) |
15948 | { |
15949 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80BC & 0xff), psMemWrite); |
15950 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80BC >> 8), psMemWrite); |
15951 | } |
15952 | else |
15953 | { |
15954 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80BC; |
15955 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80BC >> 8; |
15956 | } |
15957 | psMemWrite = NULL; |
15958 | break; |
15959 | } |
15960 | ++psMemWrite; |
15961 | } |
15962 | |
15963 | if (psMemWrite) |
15964 | { |
15965 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80BC; |
15966 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80BC >> 8); |
15967 | } |
15968 | |
15969 | break; |
15970 | } |
15971 | case 0xc6: |
15972 | { |
15973 | sdwCyclesRemaining -= 7; |
15974 | bTemp = *pbPC++; |
15975 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
15976 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
15977 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
15978 | cpu.z80A += bTemp; |
15979 | break; |
15980 | } |
15981 | case 0xc7: |
15982 | { |
15983 | sdwCyclesRemaining -= 11; |
15984 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
15985 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
15986 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
15987 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
15988 | cpu.z80sp -= 2; /* Back our stack up */ |
15989 | pbPC = cpu.z80Base + 0x00; /* Normalize the address */ |
15990 | break; |
15991 | } |
15992 | case 0xc8: |
15993 | { |
15994 | sdwCyclesRemaining -= 5; |
15995 | if (cpu.z80F & Z80_FLAG_ZERO) |
15996 | { |
15997 | dwElapsedTicks += 6; |
15998 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
15999 | dwAddr = *pbSP++; /* Pop LSB */ |
16000 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16001 | cpu.z80sp += 2; /* Pop the word off */ |
16002 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16003 | } |
16004 | break; |
16005 | } |
16006 | case 0xc9: |
16007 | { |
16008 | sdwCyclesRemaining -= 10; |
16009 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16010 | dwAddr = *pbSP++; /* Pop LSB */ |
16011 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16012 | cpu.z80sp += 2; /* Pop the word off */ |
16013 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16014 | break; |
16015 | } |
16016 | case 0xca: |
16017 | { |
16018 | sdwCyclesRemaining -= 10; |
16019 | dwAddr = *pbPC++; /* Get LSB first */ |
16020 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16021 | if (cpu.z80F & Z80_FLAG_ZERO) |
16022 | { |
16023 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16024 | } |
16025 | break; |
16026 | } |
16027 | case 0xcb: |
16028 | { |
16029 | CBHandler(); |
16030 | break; |
16031 | } |
16032 | case 0xcc: |
16033 | { |
16034 | sdwCyclesRemaining -= 10; |
16035 | dwAddr = *pbPC++; /* Get LSB first */ |
16036 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16037 | if (cpu.z80F & Z80_FLAG_ZERO) |
16038 | { |
16039 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16040 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16041 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16042 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16043 | cpu.z80sp -= 2; /* Back our stack up */ |
16044 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16045 | } |
16046 | break; |
16047 | } |
16048 | case 0xcd: |
16049 | { |
16050 | sdwCyclesRemaining -= 17; |
16051 | dwAddr = *pbPC++; /* Get LSB first */ |
16052 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16053 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16054 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16055 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16056 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16057 | cpu.z80sp -= 2; /* Back our stack up */ |
16058 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16059 | break; |
16060 | } |
16061 | case 0xce: |
16062 | { |
16063 | sdwCyclesRemaining -= 7; |
16064 | bTemp = *pbPC++ + (cpu.z80F & Z80_FLAG_CARRY); |
16065 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
16066 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
16067 | pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
16068 | cpu.z80A += bTemp; |
16069 | break; |
16070 | } |
16071 | case 0xcf: |
16072 | { |
16073 | sdwCyclesRemaining -= 11; |
16074 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16075 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16076 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16077 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16078 | cpu.z80sp -= 2; /* Back our stack up */ |
16079 | pbPC = cpu.z80Base + 0x08; /* Normalize the address */ |
16080 | break; |
16081 | } |
16082 | case 0xd0: |
16083 | { |
16084 | sdwCyclesRemaining -= 5; |
16085 | if (!(cpu.z80F & Z80_FLAG_CARRY)) |
16086 | { |
16087 | dwElapsedTicks += 6; |
16088 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16089 | dwAddr = *pbSP++; /* Pop LSB */ |
16090 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16091 | cpu.z80sp += 2; /* Pop the word off */ |
16092 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16093 | } |
16094 | break; |
16095 | } |
16096 | case 0xd1: |
16097 | { |
16098 | sdwCyclesRemaining -= 10; |
16099 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
16100 | while (psMemRead->lowAddr != 0xffffffff) |
16101 | { |
16102 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
16103 | { |
16104 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16105 | if (psMemRead->memoryCall) |
16106 | { |
16107 | cpu.z80DE = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
16108 | cpu.z80DE |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
16109 | } |
16110 | else |
16111 | { |
16112 | cpu.z80DE = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
16113 | cpu.z80DE |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
16114 | } |
16115 | psMemRead = NULL; |
16116 | break; |
16117 | } |
16118 | ++psMemRead; |
16119 | } |
16120 | |
16121 | if (psMemRead) |
16122 | { |
16123 | cpu.z80DE = cpu.z80Base[cpu.z80sp]; |
16124 | cpu.z80DE |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
16125 | } |
16126 | |
16127 | cpu.z80sp += 2; |
16128 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
16129 | break; |
16130 | } |
16131 | case 0xd2: |
16132 | { |
16133 | sdwCyclesRemaining -= 10; |
16134 | dwAddr = *pbPC++; /* Get LSB first */ |
16135 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16136 | if (!(cpu.z80F & Z80_FLAG_CARRY)) |
16137 | { |
16138 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16139 | } |
16140 | break; |
16141 | } |
16142 | case 0xd3: |
16143 | { |
16144 | sdwCyclesRemaining -= 11; |
16145 | dwTemp = *pbPC++; |
16146 | psIoWrite = cpu.z80IoWrite; /* Beginning of our handler */ |
16147 | while (psIoWrite->lowIoAddr != 0xffff) |
16148 | { |
16149 | if ((dwTemp >= psIoWrite->lowIoAddr) && (dwTemp <= psIoWrite->highIoAddr)) |
16150 | { |
16151 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16152 | psIoWrite->IOCall(dwTemp, cpu.z80A, psIoWrite); |
16153 | psIoWrite = NULL; |
16154 | break; |
16155 | } |
16156 | ++psIoWrite; |
16157 | } |
16158 | |
16159 | break; |
16160 | } |
16161 | case 0xd4: |
16162 | { |
16163 | sdwCyclesRemaining -= 10; |
16164 | dwAddr = *pbPC++; /* Get LSB first */ |
16165 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16166 | if (!(cpu.z80F & Z80_FLAG_CARRY)) |
16167 | { |
16168 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16169 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16170 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16171 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16172 | cpu.z80sp -= 2; /* Back our stack up */ |
16173 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16174 | } |
16175 | break; |
16176 | } |
16177 | case 0xd5: |
16178 | { |
16179 | sdwCyclesRemaining -= 11; |
16180 | cpu.z80sp -= 2; |
16181 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
16182 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
16183 | while (psMemWrite->lowAddr != 0xffffffff) |
16184 | { |
16185 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
16186 | { |
16187 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16188 | if (psMemWrite->memoryCall) |
16189 | { |
16190 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80DE & 0xff), psMemWrite); |
16191 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80DE >> 8), psMemWrite); |
16192 | } |
16193 | else |
16194 | { |
16195 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80DE; |
16196 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80DE >> 8; |
16197 | } |
16198 | psMemWrite = NULL; |
16199 | break; |
16200 | } |
16201 | ++psMemWrite; |
16202 | } |
16203 | |
16204 | if (psMemWrite) |
16205 | { |
16206 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80DE; |
16207 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80DE >> 8); |
16208 | } |
16209 | |
16210 | break; |
16211 | } |
16212 | case 0xd6: |
16213 | { |
16214 | sdwCyclesRemaining -= 7; |
16215 | bTemp = *pbPC++; |
16216 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
16217 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
16218 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp]; |
16219 | cpu.z80A -= bTemp; |
16220 | break; |
16221 | } |
16222 | case 0xd7: |
16223 | { |
16224 | sdwCyclesRemaining -= 11; |
16225 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16226 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16227 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16228 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16229 | cpu.z80sp -= 2; /* Back our stack up */ |
16230 | pbPC = cpu.z80Base + 0x10; /* Normalize the address */ |
16231 | break; |
16232 | } |
16233 | case 0xd8: |
16234 | { |
16235 | sdwCyclesRemaining -= 5; |
16236 | if (cpu.z80F & Z80_FLAG_CARRY) |
16237 | { |
16238 | dwElapsedTicks += 6; |
16239 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16240 | dwAddr = *pbSP++; /* Pop LSB */ |
16241 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16242 | cpu.z80sp += 2; /* Pop the word off */ |
16243 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16244 | } |
16245 | break; |
16246 | } |
16247 | case 0xd9: |
16248 | { |
16249 | sdwCyclesRemaining -= 4; |
16250 | dwTemp = cpu.z80DE; |
16251 | cpu.z80DE = cpu.z80deprime; |
16252 | cpu.z80deprime = dwTemp; |
16253 | dwTemp = cpu.z80BC; |
16254 | cpu.z80BC = cpu.z80bcprime; |
16255 | cpu.z80bcprime = dwTemp; |
16256 | dwTemp = cpu.z80HL; |
16257 | cpu.z80HL = cpu.z80hlprime; |
16258 | cpu.z80hlprime = dwTemp; |
16259 | break; |
16260 | } |
16261 | case 0xda: |
16262 | { |
16263 | sdwCyclesRemaining -= 10; |
16264 | dwAddr = *pbPC++; /* Get LSB first */ |
16265 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16266 | if (cpu.z80F & Z80_FLAG_CARRY) |
16267 | { |
16268 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16269 | } |
16270 | break; |
16271 | } |
16272 | case 0xdb: |
16273 | { |
16274 | sdwCyclesRemaining -= 11; |
16275 | dwTemp = *pbPC++; |
16276 | psIoRead = cpu.z80IoRead; /* Beginning of our handler */ |
16277 | while (psIoRead->lowIoAddr != 0xffff) |
16278 | { |
16279 | if ((dwTemp >= psIoRead->lowIoAddr) && (dwTemp <= psIoRead->highIoAddr)) |
16280 | { |
16281 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16282 | cpu.z80A = psIoRead->IOCall(dwTemp, psIoRead); |
16283 | psIoRead = NULL; |
16284 | break; |
16285 | } |
16286 | ++psIoRead; |
16287 | } |
16288 | |
16289 | if (psIoRead) |
16290 | { |
16291 | cpu.z80A = 0xff; /* Unclaimed I/O read */ |
16292 | } |
16293 | |
16294 | break; |
16295 | } |
16296 | case 0xdc: |
16297 | { |
16298 | sdwCyclesRemaining -= 10; |
16299 | dwAddr = *pbPC++; /* Get LSB first */ |
16300 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16301 | if (cpu.z80F & Z80_FLAG_CARRY) |
16302 | { |
16303 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16304 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16305 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16306 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16307 | cpu.z80sp -= 2; /* Back our stack up */ |
16308 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16309 | } |
16310 | break; |
16311 | } |
16312 | case 0xdd: |
16313 | { |
16314 | DDHandler(); |
16315 | break; |
16316 | } |
16317 | case 0xde: |
16318 | { |
16319 | sdwCyclesRemaining -= 7; |
16320 | bTemp = *pbPC++ + (cpu.z80F & Z80_FLAG_CARRY); |
16321 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
16322 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
16323 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)]; |
16324 | cpu.z80A = cpu.z80A - bTemp; |
16325 | break; |
16326 | } |
16327 | case 0xdf: |
16328 | { |
16329 | sdwCyclesRemaining -= 11; |
16330 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16331 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16332 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16333 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16334 | cpu.z80sp -= 2; /* Back our stack up */ |
16335 | pbPC = cpu.z80Base + 0x18; /* Normalize the address */ |
16336 | break; |
16337 | } |
16338 | case 0xe0: |
16339 | { |
16340 | sdwCyclesRemaining -= 5; |
16341 | if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)) |
16342 | { |
16343 | dwElapsedTicks += 6; |
16344 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16345 | dwAddr = *pbSP++; /* Pop LSB */ |
16346 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16347 | cpu.z80sp += 2; /* Pop the word off */ |
16348 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16349 | } |
16350 | break; |
16351 | } |
16352 | case 0xe1: |
16353 | { |
16354 | sdwCyclesRemaining -= 10; |
16355 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
16356 | while (psMemRead->lowAddr != 0xffffffff) |
16357 | { |
16358 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
16359 | { |
16360 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16361 | if (psMemRead->memoryCall) |
16362 | { |
16363 | cpu.z80HL = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
16364 | cpu.z80HL |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
16365 | } |
16366 | else |
16367 | { |
16368 | cpu.z80HL = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
16369 | cpu.z80HL |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
16370 | } |
16371 | psMemRead = NULL; |
16372 | break; |
16373 | } |
16374 | ++psMemRead; |
16375 | } |
16376 | |
16377 | if (psMemRead) |
16378 | { |
16379 | cpu.z80HL = cpu.z80Base[cpu.z80sp]; |
16380 | cpu.z80HL |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
16381 | } |
16382 | |
16383 | cpu.z80sp += 2; |
16384 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
16385 | break; |
16386 | } |
16387 | case 0xe2: |
16388 | { |
16389 | sdwCyclesRemaining -= 10; |
16390 | dwAddr = *pbPC++; /* Get LSB first */ |
16391 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16392 | if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)) |
16393 | { |
16394 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16395 | } |
16396 | break; |
16397 | } |
16398 | case 0xe3: |
16399 | { |
16400 | sdwCyclesRemaining -= 19; |
16401 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
16402 | while (psMemRead->lowAddr != 0xffffffff) |
16403 | { |
16404 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
16405 | { |
16406 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16407 | if (psMemRead->memoryCall) |
16408 | { |
16409 | dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
16410 | dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
16411 | } |
16412 | else |
16413 | { |
16414 | dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
16415 | dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
16416 | } |
16417 | psMemRead = NULL; |
16418 | break; |
16419 | } |
16420 | ++psMemRead; |
16421 | } |
16422 | |
16423 | if (psMemRead) |
16424 | { |
16425 | dwAddr = cpu.z80Base[cpu.z80sp]; |
16426 | dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
16427 | } |
16428 | |
16429 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
16430 | while (psMemWrite->lowAddr != 0xffffffff) |
16431 | { |
16432 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
16433 | { |
16434 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16435 | if (psMemWrite->memoryCall) |
16436 | { |
16437 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80HL & 0xff), psMemWrite); |
16438 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80HL >> 8), psMemWrite); |
16439 | } |
16440 | else |
16441 | { |
16442 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80HL; |
16443 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8; |
16444 | } |
16445 | psMemWrite = NULL; |
16446 | break; |
16447 | } |
16448 | ++psMemWrite; |
16449 | } |
16450 | |
16451 | if (psMemWrite) |
16452 | { |
16453 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80HL; |
16454 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8); |
16455 | } |
16456 | |
16457 | cpu.z80HL = dwAddr; |
16458 | break; |
16459 | } |
16460 | case 0xe4: |
16461 | { |
16462 | sdwCyclesRemaining -= 10; |
16463 | dwAddr = *pbPC++; /* Get LSB first */ |
16464 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16465 | if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)) |
16466 | { |
16467 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16468 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16469 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16470 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16471 | cpu.z80sp -= 2; /* Back our stack up */ |
16472 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16473 | } |
16474 | break; |
16475 | } |
16476 | case 0xe5: |
16477 | { |
16478 | sdwCyclesRemaining -= 11; |
16479 | cpu.z80sp -= 2; |
16480 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
16481 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
16482 | while (psMemWrite->lowAddr != 0xffffffff) |
16483 | { |
16484 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
16485 | { |
16486 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16487 | if (psMemWrite->memoryCall) |
16488 | { |
16489 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80HL & 0xff), psMemWrite); |
16490 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80HL >> 8), psMemWrite); |
16491 | } |
16492 | else |
16493 | { |
16494 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80HL; |
16495 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8; |
16496 | } |
16497 | psMemWrite = NULL; |
16498 | break; |
16499 | } |
16500 | ++psMemWrite; |
16501 | } |
16502 | |
16503 | if (psMemWrite) |
16504 | { |
16505 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80HL; |
16506 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8); |
16507 | } |
16508 | |
16509 | break; |
16510 | } |
16511 | case 0xe6: |
16512 | { |
16513 | sdwCyclesRemaining -= 7; |
16514 | cpu.z80A &= *pbPC++; |
16515 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
16516 | cpu.z80F |= bPostANDFlags[cpu.z80A]; |
16517 | |
16518 | break; |
16519 | } |
16520 | case 0xe7: |
16521 | { |
16522 | sdwCyclesRemaining -= 11; |
16523 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16524 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16525 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16526 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16527 | cpu.z80sp -= 2; /* Back our stack up */ |
16528 | pbPC = cpu.z80Base + 0x20; /* Normalize the address */ |
16529 | break; |
16530 | } |
16531 | case 0xe8: |
16532 | { |
16533 | sdwCyclesRemaining -= 5; |
16534 | if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY) |
16535 | { |
16536 | dwElapsedTicks += 6; |
16537 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16538 | dwAddr = *pbSP++; /* Pop LSB */ |
16539 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16540 | cpu.z80sp += 2; /* Pop the word off */ |
16541 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16542 | } |
16543 | break; |
16544 | } |
16545 | case 0xe9: |
16546 | { |
16547 | sdwCyclesRemaining -= 4; |
16548 | pbPC = cpu.z80Base + cpu.z80HL; |
16549 | break; |
16550 | } |
16551 | case 0xea: |
16552 | { |
16553 | sdwCyclesRemaining -= 10; |
16554 | dwAddr = *pbPC++; /* Get LSB first */ |
16555 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16556 | if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY) |
16557 | { |
16558 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16559 | } |
16560 | break; |
16561 | } |
16562 | case 0xeb: |
16563 | { |
16564 | sdwCyclesRemaining -= 4; |
16565 | dwAddr = cpu.z80DE; |
16566 | cpu.z80DE = cpu.z80HL; |
16567 | cpu.z80HL = dwAddr; |
16568 | break; |
16569 | } |
16570 | case 0xec: |
16571 | { |
16572 | sdwCyclesRemaining -= 10; |
16573 | dwAddr = *pbPC++; /* Get LSB first */ |
16574 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16575 | if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY) |
16576 | { |
16577 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16578 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16579 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16580 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16581 | cpu.z80sp -= 2; /* Back our stack up */ |
16582 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16583 | } |
16584 | break; |
16585 | } |
16586 | case 0xed: |
16587 | { |
16588 | EDHandler(); |
16589 | break; |
16590 | } |
16591 | case 0xee: |
16592 | { |
16593 | sdwCyclesRemaining -= 7; |
16594 | cpu.z80A ^= *pbPC++; |
16595 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
16596 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
16597 | |
16598 | break; |
16599 | } |
16600 | case 0xef: |
16601 | { |
16602 | sdwCyclesRemaining -= 11; |
16603 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16604 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16605 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16606 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16607 | cpu.z80sp -= 2; /* Back our stack up */ |
16608 | pbPC = cpu.z80Base + 0x28; /* Normalize the address */ |
16609 | break; |
16610 | } |
16611 | case 0xf0: |
16612 | { |
16613 | sdwCyclesRemaining -= 5; |
16614 | if (!(cpu.z80F & Z80_FLAG_SIGN)) |
16615 | { |
16616 | dwElapsedTicks += 6; |
16617 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16618 | dwAddr = *pbSP++; /* Pop LSB */ |
16619 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16620 | cpu.z80sp += 2; /* Pop the word off */ |
16621 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16622 | } |
16623 | break; |
16624 | } |
16625 | case 0xf1: |
16626 | { |
16627 | sdwCyclesRemaining -= 10; |
16628 | psMemRead = cpu.z80MemRead; /* Beginning of our handler */ |
16629 | while (psMemRead->lowAddr != 0xffffffff) |
16630 | { |
16631 | if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr)) |
16632 | { |
16633 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16634 | if (psMemRead->memoryCall) |
16635 | { |
16636 | cpu.z80AF = psMemRead->memoryCall(cpu.z80sp, psMemRead); |
16637 | cpu.z80AF |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8); |
16638 | } |
16639 | else |
16640 | { |
16641 | cpu.z80AF = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr)); |
16642 | cpu.z80AF |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8); |
16643 | } |
16644 | psMemRead = NULL; |
16645 | break; |
16646 | } |
16647 | ++psMemRead; |
16648 | } |
16649 | |
16650 | if (psMemRead) |
16651 | { |
16652 | cpu.z80AF = cpu.z80Base[cpu.z80sp]; |
16653 | cpu.z80AF |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8); |
16654 | } |
16655 | |
16656 | cpu.z80sp += 2; |
16657 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
16658 | break; |
16659 | } |
16660 | case 0xf2: |
16661 | { |
16662 | sdwCyclesRemaining -= 10; |
16663 | dwAddr = *pbPC++; /* Get LSB first */ |
16664 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16665 | if (!(cpu.z80F & Z80_FLAG_SIGN)) |
16666 | { |
16667 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16668 | } |
16669 | break; |
16670 | } |
16671 | case 0xf3: |
16672 | { |
16673 | sdwCyclesRemaining -= 4; |
16674 | cpu.z80iff &= (~IFF1); |
16675 | break; |
16676 | } |
16677 | case 0xf4: |
16678 | { |
16679 | sdwCyclesRemaining -= 10; |
16680 | dwAddr = *pbPC++; /* Get LSB first */ |
16681 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16682 | if (!(cpu.z80F & Z80_FLAG_SIGN)) |
16683 | { |
16684 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16685 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16686 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16687 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16688 | cpu.z80sp -= 2; /* Back our stack up */ |
16689 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16690 | } |
16691 | break; |
16692 | } |
16693 | case 0xf5: |
16694 | { |
16695 | sdwCyclesRemaining -= 11; |
16696 | cpu.z80sp -= 2; |
16697 | pbSP = (cpu.z80Base + cpu.z80sp); /* Normalize the stack pointer */ |
16698 | psMemWrite = cpu.z80MemWrite; /* Beginning of our handler */ |
16699 | while (psMemWrite->lowAddr != 0xffffffff) |
16700 | { |
16701 | if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr)) |
16702 | { |
16703 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16704 | if (psMemWrite->memoryCall) |
16705 | { |
16706 | psMemWrite->memoryCall(cpu.z80sp, (cpu.z80AF & 0xff), psMemWrite); |
16707 | psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80AF >> 8), psMemWrite); |
16708 | } |
16709 | else |
16710 | { |
16711 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80AF; |
16712 | *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80AF >> 8; |
16713 | } |
16714 | psMemWrite = NULL; |
16715 | break; |
16716 | } |
16717 | ++psMemWrite; |
16718 | } |
16719 | |
16720 | if (psMemWrite) |
16721 | { |
16722 | cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80AF; |
16723 | cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80AF >> 8); |
16724 | } |
16725 | |
16726 | break; |
16727 | } |
16728 | case 0xf6: |
16729 | { |
16730 | sdwCyclesRemaining -= 7; |
16731 | cpu.z80A |= *pbPC++; |
16732 | cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN); |
16733 | cpu.z80F |= bPostORFlags[cpu.z80A]; |
16734 | |
16735 | break; |
16736 | } |
16737 | case 0xf7: |
16738 | { |
16739 | sdwCyclesRemaining -= 11; |
16740 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16741 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16742 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16743 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16744 | cpu.z80sp -= 2; /* Back our stack up */ |
16745 | pbPC = cpu.z80Base + 0x30; /* Normalize the address */ |
16746 | break; |
16747 | } |
16748 | case 0xf8: |
16749 | { |
16750 | sdwCyclesRemaining -= 5; |
16751 | if (cpu.z80F & Z80_FLAG_SIGN) |
16752 | { |
16753 | dwElapsedTicks += 6; |
16754 | pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */ |
16755 | dwAddr = *pbSP++; /* Pop LSB */ |
16756 | dwAddr |= ((UINT32) *pbSP << 8); /* Pop MSB */ |
16757 | cpu.z80sp += 2; /* Pop the word off */ |
16758 | pbPC = (cpu.z80Base + dwAddr); /* Point PC to our return address */ |
16759 | } |
16760 | break; |
16761 | } |
16762 | case 0xf9: |
16763 | { |
16764 | sdwCyclesRemaining -= 6; |
16765 | cpu.z80sp = cpu.z80HL; |
16766 | break; |
16767 | } |
16768 | case 0xfa: |
16769 | { |
16770 | sdwCyclesRemaining -= 10; |
16771 | dwAddr = *pbPC++; /* Get LSB first */ |
16772 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16773 | if (cpu.z80F & Z80_FLAG_SIGN) |
16774 | { |
16775 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16776 | } |
16777 | break; |
16778 | } |
16779 | case 0xfb: |
16780 | { |
16781 | sdwCyclesRemaining -= 4; |
16782 | cpu.z80iff |= IFF1; |
16783 | break; |
16784 | } |
16785 | case 0xfc: |
16786 | { |
16787 | sdwCyclesRemaining -= 10; |
16788 | dwAddr = *pbPC++; /* Get LSB first */ |
16789 | dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */ |
16790 | if (cpu.z80F & Z80_FLAG_SIGN) |
16791 | { |
16792 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16793 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16794 | *pbSP-- = cpu.z80pc >> 8; /* MSB */ |
16795 | *pbSP = (UINT8) cpu.z80pc; /* LSB */ |
16796 | cpu.z80sp -= 2; /* Back our stack up */ |
16797 | pbPC = cpu.z80Base + dwAddr; /* Normalize the address */ |
16798 | } |
16799 | break; |
16800 | } |
16801 | case 0xfd: |
16802 | { |
16803 | FDHandler(); |
16804 | break; |
16805 | } |
16806 | case 0xfe: |
16807 | { |
16808 | sdwCyclesRemaining -= 7; |
16809 | cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | |
16810 | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) | |
16811 | pbSubSbcTable[((UINT32) cpu.z80A << 8) | *pbPC++]; |
16812 | break; |
16813 | } |
16814 | case 0xff: |
16815 | { |
16816 | sdwCyclesRemaining -= 11; |
16817 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16818 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16819 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16820 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16821 | cpu.z80sp -= 2; /* Back our stack up */ |
16822 | pbPC = cpu.z80Base + 0x38; /* Normalize the address */ |
16823 | break; |
16824 | } |
16825 | } |
16826 | } |
16827 | |
16828 | dwElapsedTicks += (dwOriginalCycles - sdwCyclesRemaining); |
16829 | |
16830 | cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base; |
16831 | return(dwReturnCode); /* Indicate success */ |
16832 | } |
16833 | |
16834 | /* Get mz80's context */ |
16835 | |
16836 | void mz80GetContext(void *pData) |
16837 | { |
16838 | memcpy(pData, &cpu, sizeof(CONTEXTMZ80)); |
16839 | } |
16840 | |
16841 | /* Set mz80's context */ |
16842 | |
16843 | void mz80SetContext(void *pData) |
16844 | { |
16845 | memcpy(&cpu, pData, sizeof(CONTEXTMZ80)); |
16846 | } |
16847 | |
16848 | /* Get mz80's context size */ |
16849 | |
16850 | UINT32 mz80GetContextSize(void) |
16851 | { |
16852 | return(sizeof(CONTEXTMZ80)); |
16853 | } |
16854 | |
16855 | /* This will return the elapsed ticks */ |
16856 | |
16857 | UINT32 mz80GetElapsedTicks(UINT32 dwClear) |
16858 | { |
16859 | UINT32 dwTemp = dwElapsedTicks; |
16860 | |
16861 | if (dwClear) |
16862 | { |
16863 | dwElapsedTicks = 0; |
16864 | } |
16865 | |
16866 | return(dwTemp); |
16867 | } |
16868 | |
16869 | /* Releases mz80 from its current timeslice */ |
16870 | |
16871 | void mz80ReleaseTimeslice(void) |
16872 | { |
16873 | dwOriginalCycles -= sdwCyclesRemaining; |
16874 | sdwCyclesRemaining = 0; |
16875 | } |
16876 | |
16877 | /* This routine is mz80's reset handler */ |
16878 | |
16879 | void mz80reset(void) |
16880 | { |
16881 | cpu.z80halted = 0; |
16882 | cpu.z80AF = 0; |
16883 | cpu.z80F = Z80_FLAG_ZERO; |
16884 | cpu.z80BC = 0; |
16885 | cpu.z80DE = 0; |
16886 | cpu.z80HL = 0; |
16887 | cpu.z80afprime = 0; |
16888 | cpu.z80bcprime = 0; |
16889 | cpu.z80deprime = 0; |
16890 | cpu.z80hlprime = 0; |
16891 | cpu.z80i = 0; |
16892 | cpu.z80r = 0; |
16893 | cpu.z80IX = 0xffff; /* Yes, this is intentional */ |
16894 | cpu.z80IY = 0xffff; /* Yes, this is intentional */ |
16895 | cpu.z80pc = 0; |
16896 | cpu.z80sp = 0; |
16897 | cpu.z80interruptMode = 0; |
16898 | cpu.z80intAddr = 0x38; |
16899 | cpu.z80nmiAddr = 0x66; |
16900 | } |
16901 | |
16902 | /* Interrupt handler */ |
16903 | |
16904 | UINT32 mz80int(UINT32 dwLowAddr) |
16905 | { |
16906 | cpu.z80halted = 0; |
16907 | if (0 == (cpu.z80iff & IFF1)) |
16908 | return(0xffffffff); |
16909 | cpu.z80iff &= ~(IFF1 | IFF2); |
16910 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16911 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16912 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16913 | cpu.z80sp -= 2; /* Back our stack up */ |
16914 | if (2 == cpu.z80interruptMode) |
16915 | { |
16916 | cpu.z80pc = ((UINT16) cpu.z80i << 8) | (dwLowAddr & 0xff); |
16917 | cpu.z80pc = ((UINT16) cpu.z80Base[cpu.z80pc + 1] << 8) | (cpu.z80Base[cpu.z80pc]); |
16918 | } |
16919 | else |
16920 | { |
16921 | cpu.z80pc = cpu.z80intAddr; |
16922 | } |
16923 | pbPC = cpu.z80Base + cpu.z80pc; /* Normalize the address */ |
16924 | return(0); |
16925 | } |
16926 | |
16927 | /* NMI Handler */ |
16928 | |
16929 | UINT32 mz80nmi(void) |
16930 | { |
16931 | cpu.z80halted = 0; |
16932 | pbSP = (cpu.z80Base + cpu.z80sp - 1); /* Normalize the stack pointer */ |
16933 | *pbSP-- = cpu.z80pc >> 8; /* LSB */ |
16934 | *pbSP = (UINT8) cpu.z80pc; /* MSB */ |
16935 | cpu.z80sp -= 2; /* Back our stack up */ |
16936 | cpu.z80pc = cpu.z80nmiAddr; /* Our NMI */ |
16937 | return(0); |
16938 | } |
16939 | |
16940 | /* Initialize MZ80 for action */ |
16941 | |
16942 | void mz80init(void) |
16943 | { |
16944 | UINT32 dwLoop; |
16945 | UINT8 *pbTempPtr; |
16946 | UINT8 *pbTempPtr2; |
16947 | UINT8 bNewAdd; |
16948 | UINT8 bNewSub; |
16949 | UINT8 bFlag; |
16950 | UINT8 bLow; |
16951 | UINT8 bHigh; |
16952 | UINT8 bCarry; |
16953 | |
16954 | if (NULL == pbAddAdcTable) |
16955 | { |
16956 | pbAddAdcTable = malloc(256*256*2); |
16957 | |
16958 | if (NULL == pbAddAdcTable) |
16959 | { |
16960 | return; |
16961 | } |
16962 | |
16963 | pbTempPtr = pbAddAdcTable; |
16964 | |
16965 | pbSubSbcTable = malloc(256*256*2); |
16966 | |
16967 | if (NULL == pbSubSbcTable) |
16968 | { |
16969 | return; |
16970 | } |
16971 | |
16972 | pbTempPtr2 = pbSubSbcTable; |
16973 | |
16974 | for (dwLoop = 0; dwLoop < (256*256*2); dwLoop++) |
16975 | { |
16976 | bLow = dwLoop & 0xff; |
16977 | bHigh = (dwLoop >> 8) & 0xff; |
16978 | bCarry = (dwLoop >> 16); |
16979 | |
16980 | bFlag = 0; |
16981 | bNewAdd = bHigh + bLow + bCarry; |
16982 | |
16983 | if (0 == bNewAdd) |
16984 | { |
16985 | bFlag |= Z80_FLAG_ZERO; |
16986 | } |
16987 | else |
16988 | { |
16989 | bFlag = bNewAdd & 0x80; /* Sign flag */ |
16990 | } |
16991 | |
16992 | if (((UINT32) bLow + (UINT32) bHigh + (UINT32) bCarry) >= 0x100) |
16993 | { |
16994 | bFlag |= Z80_FLAG_CARRY; |
16995 | } |
16996 | |
16997 | if ( ((bLow ^ bHigh ^ 0x80) & (bLow ^ (bNewAdd & 0x80))) & 0x80) |
16998 | { |
16999 | bFlag |= Z80_FLAG_OVERFLOW_PARITY; |
17000 | } |
17001 | |
17002 | if (((bLow & 0x0f) + (bHigh & 0x0f) + bCarry) >= 0x10) |
17003 | { |
17004 | bFlag |= Z80_FLAG_HALF_CARRY; |
17005 | } |
17006 | |
17007 | *pbTempPtr++ = bFlag; /* Store our new flag */ |
17008 | |
17009 | // Now do subtract - Zero |
17010 | |
17011 | bFlag = Z80_FLAG_NEGATIVE; |
17012 | bNewSub = bHigh - bLow - bCarry; |
17013 | |
17014 | if (0 == bNewSub) |
17015 | { |
17016 | bFlag |= Z80_FLAG_ZERO; |
17017 | } |
17018 | else |
17019 | { |
17020 | bFlag |= bNewSub & 0x80; /* Sign flag */ |
17021 | } |
17022 | |
17023 | if ( ((INT32) bHigh - (INT32) bLow - (INT32) bCarry) < 0) |
17024 | { |
17025 | bFlag |= Z80_FLAG_CARRY; |
17026 | } |
17027 | |
17028 | if ( ((INT32) (bHigh & 0xf) - (INT32) (bLow & 0x0f) - (INT32) bCarry) < 0) |
17029 | { |
17030 | bFlag |= Z80_FLAG_HALF_CARRY; |
17031 | } |
17032 | |
17033 | if ( ((bLow ^ bHigh) & (bHigh ^ bNewSub) & 0x80) ) |
17034 | { |
17035 | bFlag |= Z80_FLAG_OVERFLOW_PARITY; |
17036 | } |
17037 | |
17038 | *pbTempPtr2++ = bFlag; /* Store our sub flag */ |
17039 | |
17040 | } |
17041 | } |
17042 | } |
17043 | /* Shut down MZ80 */ |
17044 | |
17045 | void mz80shutdown(void) |
17046 | { |
17047 | // notaz: why weren't these here? |
17048 | free(pbAddAdcTable); |
17049 | pbAddAdcTable = 0; |
17050 | free(pbSubSbcTable); |
17051 | pbSubSbcTable = 0; |
17052 | } |
17053 | |