Subversion Repositories Shiroi

Rev

Rev 42 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
#pragma once
2
/*#
3
    # z80.h
4
 
5
    A cycle-stepped Z80 emulator in a C header.
6
 
7
    Do this:
8
    ~~~~C
9
    #define CHIPS_IMPL
10
    ~~~~
11
    before you include this file in *one* C or C++ file to create the
12
    implementation.
13
 
14
    Optionally provide
15
    ~~~C
16
    #define CHIPS_ASSERT(x) your_own_asset_macro(x)
17
    ~~~
18
 
19
    ## Emulated Pins
20
    ***********************************
21
    *           +-----------+         *
22
    * M1    <---|           |---> A0  *
23
    * MREQ  <---|           |---> A1  *
24
    * IORQ  <---|           |---> A2  *
25
    * RD    <---|           |---> ..  *
26
    * WR    <---|    Z80    |---> A15 *
27
    * HALT  <---|           |         *
28
    * WAIT  --->|           |<--> D0  *
29
    * INT   --->|           |<--> D1  *
30
    * NMI   --->|           |<--> ... *
31
    * RFSH  <---|           |<--> D7  *
32
    *           +-----------+         *
33
    ***********************************
34
 
35
    ## Functions
36
 
37
    ~~~C
38
    uint64_t z80_init(z80_t* cpu);
39
    ~~~
40
	Initializes a new z80_t instance, returns initial pin mask to start
41
	execution at address 0.
42
 
43
    ~~~C
44
    uint64_t z80_reset(z80_t* cpu)
45
    ~~~
46
	Resets a z80_t instance, returns pin mask to start execution at
47
	address 0.
48
 
49
    ~~~C
50
    uint64_t z80_tick(z80_t* cpu, uint64_t pins)
51
    ~~~
52
	Step the z80_t instance for one clock cycle.
53
 
54
    ~~~C
55
    uint64_t z80_prefetch(z80_t* cpu, uint16_t new_pc)
56
    ~~~
57
	Call this function to force execution to start at a specific
58
	PC. Use the returned pin mask as argument into the next z80_tick() call.
59
 
60
    ~~~C
61
    bool z80_opdone(z80_t* cpu)
62
    ~~~
63
	Helper function to detect whether the z80_t instance has completed
64
	an instruction.
65
 
66
    ## HOWTO
67
 
68
    Initialize a new z80_t instance and start ticking it:
69
    ~~~C
70
	z80_t cpu;
71
	uint64_t pins = z80_init(&cpu);
72
	while (!done) {
73
	    pins = z80_tick(&cpu, pins);
74
	}
75
    ~~~
76
    Since there is no memory attached yet, the CPU will simply run whatever opcode
77
    bytes are present on the data bus (in this case the data bus is zero, so the CPU
78
    just runs throught the same NOP over and over).
79
 
80
    Next, add some memory and inspect and modify the pin mask to handle memory accesses:
81
    ~~~C
82
	uint8_t mem[(1<<16)] = {0};
83
	z80_t cpu;
84
	uint64_t pins = z80_init(&cpu);
85
	while (!done) {
86
	    pins = z80_tick(&cpu, pins);
87
	    if (pins & Z80_MREQ) {
88
		const uint16_t addr = Z80_GET_ADDR(pins);
89
		if (pins & Z80_RD) {
90
		    uint8_t data = mem[addr];
91
		    Z80_SET_DATA(pins, data);
92
		}
93
		else if (pins & Z80_WR) {
94
		    uint8_t data = Z80_GET_DATA(pins);
95
		    mem[addr] = data;
96
		}
97
	    }
98
	}
99
    ~~~
100
    The CPU will now run through the whole address space executing NOPs (because the memory is
101
    filled with 0s instead of a valid program). If there would be a valid Z80 program at memory
102
    address 0, this would be executed instead.
103
 
104
    IO requests are handled the same as memory requests, but instead of the MREQ pin, the
105
    IORQ pin must be checked:
106
    ~~~C
107
	uint8_t mem[(1<<16)] = {0};
108
	z80_t cpu;
109
	uint64_t pins = z80_init(&cpu);
110
	while (!done) {
111
	    pins = z80_tick(&cpu, pins);
112
	    if (pins & Z80_MREQ) {
113
		const uint16_t addr = Z80_GET_ADDR(pins);
114
		if (pins & Z80_RD) {
115
		    uint8_t data = mem[addr];
116
		    Z80_SET_DATA(pins, data);
117
		}
118
		else if (pins & Z80_WR) {
119
		    uint8_t data = Z80_GET_DATA(pins);
120
		    mem[addr] = data;
121
		}
122
	    }
123
	    else if (pins & Z80_IORQ) {
124
		const uint16_t port = Z80_GET_ADDR(pins);
125
		if (pins & Z80_RD) {
126
		    // handle IO input request at port
127
		    ...
128
		}
129
		else if (pins & Z80_WR) {
130
		    // handle IO output request at port
131
		    ...
132
		}
133
	    }
134
	}
135
    ~~~
136
 
137
    Handle interrupt acknowledge cycles by checking for Z80_IORQ|Z80_M1:
138
    ~~~C
139
	uint8_t mem[(1<<16)] = {0};
140
	z80_t cpu;
141
	uint64_t pins = z80_init(&cpu);
142
	while (!done) {
143
	    pins = z80_tick(&cpu, pins);
144
	    if (pins & Z80_MREQ) {
145
		const uint16_t addr = Z80_GET_ADDR(pins);
146
		if (pins & Z80_RD) {
147
		    uint8_t data = mem[addr];
148
		    Z80_SET_DATA(pins, data);
149
		}
150
		else if (pins & Z80_WR) {
151
		    uint8_t data = Z80_GET_DATA(pins);
152
		    mem[addr] = data;
153
		}
154
	    }
155
	    else if (pins & Z80_IORQ) {
156
		const uint16_t addr = Z80_GET_ADDR(pins);
157
		if (pins & Z80_M1) {
158
		    // an interrupt acknowledge cycle, depending on the emulated system,
159
		    // put either an instruction byte, or an interrupt vector on the data bus
160
		    Z80_SET_DATA(pins, opcode_or_intvec);
161
		}
162
		else if (pins & Z80_RD) {
163
		    // handle IO input request at port `addr`
164
		    ...
165
		}
166
		else if (pins & Z80_WR) {
167
		    // handle IO output request at port `addr`
168
		    ...
169
		}
170
	    }
171
	}
172
    ~~~
173
 
174
    To request an interrupt, or inject a wait state just set the respective pin
175
    (Z80_INT, Z80_NMI, Z80_WAIT), don't forget to clear the pin again later (the
176
    details on when those pins are set and cleared depend heavily on the
177
    emulated system).
178
 
179
    !!! note
180
	NOTE: The Z80_RES pin is currently not emulated. Instead call the `z80_reset()` function.
181
 
182
    To emulate a whole computer system, add the per-tick code for the rest of the system to the
183
    basic ticking code above.
184
 
185
    If the emulated system uses the Z80 daisychain interrupt protocol (for instance when using
186
    the Z80 family chips like the PIO or CTC), tick those chips in interrupt priority order and
187
    set the Z80_IEIO pin before the highest priority chip in the daisychain is ticked:
188
 
189
    ~~~C
190
	...
191
	while (!done) {
192
	    pins = z80_tick(&cpu, pins);
193
	    ...
194
	    // tick Z80 family chips in 'daisychain order':
195
	    pins |= Z80_IEIO;
196
	    ...
197
	    pins = z80ctc_tick(&ctc, pins);
198
	    ...
199
	    pins = z80pio_tick(&pio, pins);
200
	    ...
201
	    // the Z80_INT pin will now be set if any of the chips wants to issue an interrupt request
202
	}
203
    ~~~
204
#*/
205
/*
206
    zlib/libpng license
207
 
208
    Copyright (c) 2021 Andre Weissflog
209
    This software is provided 'as-is', without any express or implied warranty.
210
    In no event will the authors be held liable for any damages arising from the
211
    use of this software.
212
    Permission is granted to anyone to use this software for any purpose,
213
    including commercial applications, and to alter it and redistribute it
214
    freely, subject to the following restrictions:
215
	1. The origin of this software must not be misrepresented; you must not
216
	claim that you wrote the original software. If you use this software in a
217
	product, an acknowledgment in the product documentation would be
218
	appreciated but is not required.
219
	2. Altered source versions must be plainly marked as such, and must not
220
	be misrepresented as being the original software.
221
	3. This notice may not be removed or altered from any source
222
	distribution.
223
*/
224
#include <stdint.h>
225
#include <stdbool.h>
226
 
227
#ifdef __cplusplus
228
extern "C" {
229
#endif
230
 
231
// address pins
232
#define Z80_PIN_A0 (0)
233
#define Z80_PIN_A1 (1)
234
#define Z80_PIN_A2 (2)
235
#define Z80_PIN_A3 (3)
236
#define Z80_PIN_A4 (4)
237
#define Z80_PIN_A5 (5)
238
#define Z80_PIN_A6 (6)
239
#define Z80_PIN_A7 (7)
240
#define Z80_PIN_A8 (8)
241
#define Z80_PIN_A9 (9)
242
#define Z80_PIN_A10 (10)
243
#define Z80_PIN_A11 (11)
244
#define Z80_PIN_A12 (12)
245
#define Z80_PIN_A13 (13)
246
#define Z80_PIN_A14 (14)
247
#define Z80_PIN_A15 (15)
248
 
249
// data pins
250
#define Z80_PIN_D0 (16)
251
#define Z80_PIN_D1 (17)
252
#define Z80_PIN_D2 (18)
253
#define Z80_PIN_D3 (19)
254
#define Z80_PIN_D4 (20)
255
#define Z80_PIN_D5 (21)
256
#define Z80_PIN_D6 (22)
257
#define Z80_PIN_D7 (23)
258
 
259
// control pins
260
#define Z80_PIN_M1 (24)	  // machine cycle 1
261
#define Z80_PIN_MREQ (25) // memory request
262
#define Z80_PIN_IORQ (26) // input/output request
263
#define Z80_PIN_RD (27)	  // read
264
#define Z80_PIN_WR (28)	  // write
265
#define Z80_PIN_HALT (29) // halt state
266
#define Z80_PIN_INT (30)  // interrupt request
267
#define Z80_PIN_RES (31)  // reset requested
268
#define Z80_PIN_NMI (32)  // non-maskable interrupt
269
#define Z80_PIN_WAIT (33) // wait requested
270
#define Z80_PIN_RFSH (34) // refresh
271
 
272
// virtual pins (for interrupt daisy chain protocol)
273
#define Z80_PIN_IEIO (37) // unified daisy chain 'Interrupt Enable In+Out'
274
#define Z80_PIN_RETI (38) // cpu has decoded a RETI instruction
275
 
276
// pin bit masks
277
#define Z80_A0 (1ULL << Z80_PIN_A0)
278
#define Z80_A1 (1ULL << Z80_PIN_A1)
279
#define Z80_A2 (1ULL << Z80_PIN_A2)
280
#define Z80_A3 (1ULL << Z80_PIN_A3)
281
#define Z80_A4 (1ULL << Z80_PIN_A4)
282
#define Z80_A5 (1ULL << Z80_PIN_A5)
283
#define Z80_A6 (1ULL << Z80_PIN_A6)
284
#define Z80_A7 (1ULL << Z80_PIN_A7)
285
#define Z80_A8 (1ULL << Z80_PIN_A8)
286
#define Z80_A9 (1ULL << Z80_PIN_A9)
287
#define Z80_A10 (1ULL << Z80_PIN_A10)
288
#define Z80_A11 (1ULL << Z80_PIN_A11)
289
#define Z80_A12 (1ULL << Z80_PIN_A12)
290
#define Z80_A13 (1ULL << Z80_PIN_A13)
291
#define Z80_A14 (1ULL << Z80_PIN_A14)
292
#define Z80_A15 (1ULL << Z80_PIN_A15)
293
#define Z80_D0 (1ULL << Z80_PIN_D0)
294
#define Z80_D1 (1ULL << Z80_PIN_D1)
295
#define Z80_D2 (1ULL << Z80_PIN_D2)
296
#define Z80_D3 (1ULL << Z80_PIN_D3)
297
#define Z80_D4 (1ULL << Z80_PIN_D4)
298
#define Z80_D5 (1ULL << Z80_PIN_D5)
299
#define Z80_D6 (1ULL << Z80_PIN_D6)
300
#define Z80_D7 (1ULL << Z80_PIN_D7)
301
#define Z80_M1 (1ULL << Z80_PIN_M1)
302
#define Z80_MREQ (1ULL << Z80_PIN_MREQ)
303
#define Z80_IORQ (1ULL << Z80_PIN_IORQ)
304
#define Z80_RD (1ULL << Z80_PIN_RD)
305
#define Z80_WR (1ULL << Z80_PIN_WR)
306
#define Z80_HALT (1ULL << Z80_PIN_HALT)
307
#define Z80_INT (1ULL << Z80_PIN_INT)
308
#define Z80_RES (1ULL << Z80_PIN_RES)
309
#define Z80_NMI (1ULL << Z80_PIN_NMI)
310
#define Z80_WAIT (1ULL << Z80_PIN_WAIT)
311
#define Z80_RFSH (1ULL << Z80_PIN_RFSH)
312
#define Z80_IEIO (1ULL << Z80_PIN_IEIO)
313
#define Z80_RETI (1ULL << Z80_PIN_RETI)
314
 
315
#define Z80_CTRL_PIN_MASK (Z80_M1 | Z80_MREQ | Z80_IORQ | Z80_RD | Z80_WR | Z80_RFSH)
316
#define Z80_PIN_MASK ((1ULL << 40) - 1)
317
 
318
// pin access helper macros
43 nishi 319
#define Z80_MAKE_PINS(ctrl, addr, data) ((ctrl) | ((data & 0xFF) << 16) | ((addr) & 0xFFFFULL))
1 nishi 320
#define Z80_GET_ADDR(p) ((uint16_t)(p))
321
#define Z80_SET_ADDR(p, a) \
43 nishi 322
	{ p = ((p) & ~0xFFFF) | ((a) & 0xFFFF); }
1 nishi 323
#define Z80_GET_DATA(p) ((uint8_t)((p) >> 16))
324
#define Z80_SET_DATA(p, d) \
325
	{ p = ((p) & ~0xFF0000ULL) | (((d) << 16) & 0xFF0000ULL); }
326
 
327
// status flags
328
#define Z80_CF (1 << 0) // carry
329
#define Z80_NF (1 << 1) // add/subtract
330
#define Z80_VF (1 << 2) // parity/overflow
331
#define Z80_PF Z80_VF
332
#define Z80_XF (1 << 3) // undocumented bit 3
333
#define Z80_HF (1 << 4) // half carry
334
#define Z80_YF (1 << 5) // undocumented bit 5
335
#define Z80_ZF (1 << 6) // zero
336
#define Z80_SF (1 << 7) // sign
337
 
338
// CPU state
339
typedef struct {
340
	uint16_t step;	    // the currently active decoder step
341
	uint16_t addr;	    // effective address for (HL),(IX+d),(IY+d)
342
	uint8_t dlatch;	    // temporary store for data bus value
343
	uint8_t opcode;	    // current opcode
344
	uint8_t hlx_idx;    // index into hlx[] for mapping hl to ix or iy (0: hl, 1: ix, 2: iy)
345
	bool prefix_active; // true if any prefix currently active (only needed in z80_opdone())
346
	uint64_t pins;	    // last pin state, used for NMI detection
347
	uint64_t int_bits;  // track INT and NMI state
348
	union {
349
		struct {
350
			uint8_t pcl;
351
			uint8_t pch;
352
		};
353
		uint16_t pc;
354
	};
355
 
356
	// NOTE: These unions are fine in C, but not C++.
357
	union {
358
		struct {
359
			uint8_t f;
360
			uint8_t a;
361
		};
362
		uint16_t af;
363
	};
364
	union {
365
		struct {
366
			uint8_t c;
367
			uint8_t b;
368
		};
369
		uint16_t bc;
370
	};
371
	union {
372
		struct {
373
			uint8_t e;
374
			uint8_t d;
375
		};
376
		uint16_t de;
377
	};
378
	union {
379
		struct {
380
			union {
381
				struct {
382
					uint8_t l;
383
					uint8_t h;
384
				};
385
				uint16_t hl;
386
			};
387
			union {
388
				struct {
389
					uint8_t ixl;
390
					uint8_t ixh;
391
				};
392
				uint16_t ix;
393
			};
394
			union {
395
				struct {
396
					uint8_t iyl;
397
					uint8_t iyh;
398
				};
399
				uint16_t iy;
400
			};
401
		};
402
		struct {
403
			union {
404
				struct {
405
					uint8_t l;
406
					uint8_t h;
407
				};
408
				uint16_t hl;
409
			};
410
		} hlx[3];
411
	};
412
	union {
413
		struct {
414
			uint8_t wzl;
415
			uint8_t wzh;
416
		};
417
		uint16_t wz;
418
	};
419
	union {
420
		struct {
421
			uint8_t spl;
422
			uint8_t sph;
423
		};
424
		uint16_t sp;
425
	};
426
	union {
427
		struct {
428
			uint8_t r;
429
			uint8_t i;
430
		};
431
		uint16_t ir;
432
	};
433
	uint16_t af2, bc2, de2, hl2; // shadow register bank
434
	uint8_t im;
435
	bool iff1, iff2;
436
} z80_t;
437
 
438
// initialize a new Z80 instance and return initial pin mask
439
uint64_t z80_init(z80_t* cpu);
440
// immediately put Z80 into reset state
441
uint64_t z80_reset(z80_t* cpu);
442
// execute one tick, return new pin mask
443
uint64_t z80_tick(z80_t* cpu, uint64_t pins);
444
// force execution to continue at address 'new_pc'
445
uint64_t z80_prefetch(z80_t* cpu, uint16_t new_pc);
446
// return true when full instruction has finished
447
bool z80_opdone(z80_t* cpu);
448
 
449
#ifdef __cplusplus
450
} // extern C
451
#endif
452
 
453
//-- IMPLEMENTATION ------------------------------------------------------------
454
#ifdef CHIPS_IMPL
455
#include <string.h> // memset
456
#ifndef CHIPS_ASSERT
457
#include <assert.h>
458
#define CHIPS_ASSERT(c) assert(c)
459
#endif
460
 
461
#if defined(__GNUC__)
462
#define _Z80_UNREACHABLE __builtin_unreachable()
463
#elif defined(_MSC_VER)
464
#define _Z80_UNREACHABLE __assume(0)
465
#else
466
#define _Z80_UNREACHABLE
467
#endif
468
 
469
// values for hlx_idx for mapping HL, IX or IY, used as index into hlx[]
470
#define _Z80_MAP_HL (0)
471
#define _Z80_MAP_IX (1)
472
#define _Z80_MAP_IY (2)
473
 
474
uint64_t z80_init(z80_t* cpu) {
475
	CHIPS_ASSERT(cpu);
476
	// initial state as described in 'The Undocumented Z80 Documented'
477
	memset(cpu, 0, sizeof(z80_t));
478
	cpu->af = cpu->bc = cpu->de = cpu->hl = 0xFFFF;
479
	cpu->wz = cpu->sp = cpu->ix = cpu->iy = 0xFFFF;
480
	cpu->af2 = cpu->bc2 = cpu->de2 = cpu->hl2 = 0xFFFF;
481
	return z80_prefetch(cpu, 0x0000);
482
}
483
 
484
uint64_t z80_reset(z80_t* cpu) {
485
	// reset state as described in 'The Undocumented Z80 Documented'
486
	memset(cpu, 0, sizeof(z80_t));
487
	cpu->af = cpu->bc = cpu->de = cpu->hl = 0xFFFF;
488
	cpu->wz = cpu->sp = cpu->ix = cpu->iy = 0xFFFF;
489
	cpu->af2 = cpu->bc2 = cpu->de2 = cpu->hl2 = 0xFFFF;
490
	return z80_prefetch(cpu, 0x0000);
491
}
492
 
493
bool z80_opdone(z80_t* cpu) {
494
	// because of the overlapped cycle, the result of the previous
495
	// instruction is only available in M1/T2
496
	return ((cpu->pins & (Z80_M1 | Z80_RD)) == (Z80_M1 | Z80_RD)) && !cpu->prefix_active;
497
}
498
 
499
static inline uint64_t _z80_halt(z80_t* cpu, uint64_t pins) {
500
	cpu->pc--;
501
	return pins | Z80_HALT;
502
}
503
 
504
// sign+zero+parity lookup table
505
static const uint8_t _z80_szp_flags[256] = {
506
    0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, 0x08, 0x0c, 0x0c, 0x08, 0x0c, 0x08, 0x08, 0x0c, 0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04, 0x0c, 0x08, 0x08, 0x0c, 0x08, 0x0c, 0x0c, 0x08, 0x20, 0x24, 0x24, 0x20, 0x24, 0x20, 0x20, 0x24, 0x2c, 0x28, 0x28, 0x2c, 0x28, 0x2c, 0x2c, 0x28, 0x24, 0x20, 0x20, 0x24, 0x20, 0x24, 0x24, 0x20, 0x28, 0x2c, 0x2c, 0x28, 0x2c, 0x28, 0x28, 0x2c, 0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04, 0x0c, 0x08, 0x08, 0x0c, 0x08, 0x0c, 0x0c, 0x08, 0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, 0x08, 0x0c, 0x0c, 0x08, 0x0c, 0x08, 0x08, 0x0c, 0x24, 0x20, 0x20, 0x24, 0x20, 0x24, 0x24, 0x20, 0x28, 0x2c, 0x2c, 0x28, 0x2c, 0x28, 0x28, 0x2c, 0x20, 0x24, 0x24, 0x20, 0x24, 0x20, 0x20, 0x24, 0x2c, 0x28, 0x28, 0x2c, 0x28, 0x2c, 0x2c, 0x28,
507
    0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84, 0x8c, 0x88, 0x88, 0x8c, 0x88, 0x8c, 0x8c, 0x88, 0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80, 0x88, 0x8c, 0x8c, 0x88, 0x8c, 0x88, 0x88, 0x8c, 0xa4, 0xa0, 0xa0, 0xa4, 0xa0, 0xa4, 0xa4, 0xa0, 0xa8, 0xac, 0xac, 0xa8, 0xac, 0xa8, 0xa8, 0xac, 0xa0, 0xa4, 0xa4, 0xa0, 0xa4, 0xa0, 0xa0, 0xa4, 0xac, 0xa8, 0xa8, 0xac, 0xa8, 0xac, 0xac, 0xa8, 0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80, 0x88, 0x8c, 0x8c, 0x88, 0x8c, 0x88, 0x88, 0x8c, 0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84, 0x8c, 0x88, 0x88, 0x8c, 0x88, 0x8c, 0x8c, 0x88, 0xa0, 0xa4, 0xa4, 0xa0, 0xa4, 0xa0, 0xa0, 0xa4, 0xac, 0xa8, 0xa8, 0xac, 0xa8, 0xac, 0xac, 0xa8, 0xa4, 0xa0, 0xa0, 0xa4, 0xa0, 0xa4, 0xa4, 0xa0, 0xa8, 0xac, 0xac, 0xa8, 0xac, 0xa8, 0xa8, 0xac,
508
};
509
 
510
static inline uint8_t _z80_sz_flags(uint8_t val) { return (val != 0) ? (val & Z80_SF) : Z80_ZF; }
511
 
512
static inline uint8_t _z80_szyxch_flags(uint8_t acc, uint8_t val, uint32_t res) { return _z80_sz_flags(res) | (res & (Z80_YF | Z80_XF)) | ((res >> 8) & Z80_CF) | ((acc ^ val ^ res) & Z80_HF); }
513
 
514
static inline uint8_t _z80_add_flags(uint8_t acc, uint8_t val, uint32_t res) { return _z80_szyxch_flags(acc, val, res) | ((((val ^ acc ^ 0x80) & (val ^ res)) >> 5) & Z80_VF); }
515
 
516
static inline uint8_t _z80_sub_flags(uint8_t acc, uint8_t val, uint32_t res) { return Z80_NF | _z80_szyxch_flags(acc, val, res) | ((((val ^ acc) & (res ^ acc)) >> 5) & Z80_VF); }
517
 
518
static inline uint8_t _z80_cp_flags(uint8_t acc, uint8_t val, uint32_t res) { return Z80_NF | _z80_sz_flags(res) | (val & (Z80_YF | Z80_XF)) | ((res >> 8) & Z80_CF) | ((acc ^ val ^ res) & Z80_HF) | ((((val ^ acc) & (res ^ acc)) >> 5) & Z80_VF); }
519
 
520
static inline uint8_t _z80_sziff2_flags(z80_t* cpu, uint8_t val) { return (cpu->f & Z80_CF) | _z80_sz_flags(val) | (val & (Z80_YF | Z80_XF)) | (cpu->iff2 ? Z80_PF : 0); }
521
 
522
static inline void _z80_add8(z80_t* cpu, uint8_t val) {
523
	uint32_t res = cpu->a + val;
524
	cpu->f = _z80_add_flags(cpu->a, val, res);
525
	cpu->a = (uint8_t)res;
526
}
527
 
528
static inline void _z80_adc8(z80_t* cpu, uint8_t val) {
529
	uint32_t res = cpu->a + val + (cpu->f & Z80_CF);
530
	cpu->f = _z80_add_flags(cpu->a, val, res);
531
	cpu->a = (uint8_t)res;
532
}
533
 
534
static inline void _z80_sub8(z80_t* cpu, uint8_t val) {
535
	uint32_t res = (uint32_t)((int)cpu->a - (int)val);
536
	cpu->f = _z80_sub_flags(cpu->a, val, res);
537
	cpu->a = (uint8_t)res;
538
}
539
 
540
static inline void _z80_sbc8(z80_t* cpu, uint8_t val) {
541
	uint32_t res = (uint32_t)((int)cpu->a - (int)val - (cpu->f & Z80_CF));
542
	cpu->f = _z80_sub_flags(cpu->a, val, res);
543
	cpu->a = (uint8_t)res;
544
}
545
 
546
static inline void _z80_and8(z80_t* cpu, uint8_t val) {
547
	cpu->a &= val;
548
	cpu->f = _z80_szp_flags[cpu->a] | Z80_HF;
549
}
550
 
551
static inline void _z80_xor8(z80_t* cpu, uint8_t val) {
552
	cpu->a ^= val;
553
	cpu->f = _z80_szp_flags[cpu->a];
554
}
555
 
556
static inline void _z80_or8(z80_t* cpu, uint8_t val) {
557
	cpu->a |= val;
558
	cpu->f = _z80_szp_flags[cpu->a];
559
}
560
 
561
static inline void _z80_cp8(z80_t* cpu, uint8_t val) {
562
	uint32_t res = (uint32_t)((int)cpu->a - (int)val);
563
	cpu->f = _z80_cp_flags(cpu->a, val, res);
564
}
565
 
566
static inline void _z80_neg8(z80_t* cpu) {
567
	uint32_t res = (uint32_t)(0 - (int)cpu->a);
568
	cpu->f = _z80_sub_flags(0, cpu->a, res);
569
	cpu->a = (uint8_t)res;
570
}
571
 
572
static inline uint8_t _z80_inc8(z80_t* cpu, uint8_t val) {
573
	uint8_t res = val + 1;
574
	uint8_t f = _z80_sz_flags(res) | (res & (Z80_XF | Z80_YF)) | ((res ^ val) & Z80_HF);
575
	if(res == 0x80) {
576
		f |= Z80_VF;
577
	}
578
	cpu->f = f | (cpu->f & Z80_CF);
579
	return res;
580
}
581
 
582
static inline uint8_t _z80_dec8(z80_t* cpu, uint8_t val) {
583
	uint8_t res = val - 1;
584
	uint8_t f = Z80_NF | _z80_sz_flags(res) | (res & (Z80_XF | Z80_YF)) | ((res ^ val) & Z80_HF);
585
	if(res == 0x7F) {
586
		f |= Z80_VF;
587
	}
588
	cpu->f = f | (cpu->f & Z80_CF);
589
	return res;
590
}
591
 
592
static inline void _z80_ex_de_hl(z80_t* cpu) {
593
	uint16_t tmp = cpu->hl;
594
	cpu->hl = cpu->de;
595
	cpu->de = tmp;
596
}
597
 
598
static inline void _z80_ex_af_af2(z80_t* cpu) {
599
	uint16_t tmp = cpu->af2;
600
	cpu->af2 = cpu->af;
601
	cpu->af = tmp;
602
}
603
 
604
static inline void _z80_exx(z80_t* cpu) {
605
	uint16_t tmp;
606
	tmp = cpu->bc;
607
	cpu->bc = cpu->bc2;
608
	cpu->bc2 = tmp;
609
	tmp = cpu->de;
610
	cpu->de = cpu->de2;
611
	cpu->de2 = tmp;
612
	tmp = cpu->hl;
613
	cpu->hl = cpu->hl2;
614
	cpu->hl2 = tmp;
615
}
616
 
617
static inline void _z80_rlca(z80_t* cpu) {
618
	uint8_t res = (cpu->a << 1) | (cpu->a >> 7);
619
	cpu->f = ((cpu->a >> 7) & Z80_CF) | (cpu->f & (Z80_SF | Z80_ZF | Z80_PF)) | (res & (Z80_YF | Z80_XF));
620
	cpu->a = res;
621
}
622
 
623
static inline void _z80_rrca(z80_t* cpu) {
624
	uint8_t res = (cpu->a >> 1) | (cpu->a << 7);
625
	cpu->f = (cpu->a & Z80_CF) | (cpu->f & (Z80_SF | Z80_ZF | Z80_PF)) | (res & (Z80_YF | Z80_XF));
626
	cpu->a = res;
627
}
628
 
629
static inline void _z80_rla(z80_t* cpu) {
630
	uint8_t res = (cpu->a << 1) | (cpu->f & Z80_CF);
631
	cpu->f = ((cpu->a >> 7) & Z80_CF) | (cpu->f & (Z80_SF | Z80_ZF | Z80_PF)) | (res & (Z80_YF | Z80_XF));
632
	cpu->a = res;
633
}
634
 
635
static inline void _z80_rra(z80_t* cpu) {
636
	uint8_t res = (cpu->a >> 1) | ((cpu->f & Z80_CF) << 7);
637
	cpu->f = (cpu->a & Z80_CF) | (cpu->f & (Z80_SF | Z80_ZF | Z80_PF)) | (res & (Z80_YF | Z80_XF));
638
	cpu->a = res;
639
}
640
 
641
static inline void _z80_daa(z80_t* cpu) {
642
	uint8_t res = cpu->a;
643
	if(cpu->f & Z80_NF) {
644
		if(((cpu->a & 0xF) > 0x9) || (cpu->f & Z80_HF)) {
645
			res -= 0x06;
646
		}
647
		if((cpu->a > 0x99) || (cpu->f & Z80_CF)) {
648
			res -= 0x60;
649
		}
650
	} else {
651
		if(((cpu->a & 0xF) > 0x9) || (cpu->f & Z80_HF)) {
652
			res += 0x06;
653
		}
654
		if((cpu->a > 0x99) || (cpu->f & Z80_CF)) {
655
			res += 0x60;
656
		}
657
	}
658
	cpu->f &= Z80_CF | Z80_NF;
659
	cpu->f |= (cpu->a > 0x99) ? Z80_CF : 0;
660
	cpu->f |= (cpu->a ^ res) & Z80_HF;
661
	cpu->f |= _z80_szp_flags[res];
662
	cpu->a = res;
663
}
664
 
665
static inline void _z80_cpl(z80_t* cpu) {
666
	cpu->a ^= 0xFF;
667
	cpu->f = (cpu->f & (Z80_SF | Z80_ZF | Z80_PF | Z80_CF)) | Z80_HF | Z80_NF | (cpu->a & (Z80_YF | Z80_XF));
668
}
669
 
670
static inline void _z80_scf(z80_t* cpu) { cpu->f = (cpu->f & (Z80_SF | Z80_ZF | Z80_PF | Z80_CF)) | Z80_CF | (cpu->a & (Z80_YF | Z80_XF)); }
671
 
672
static inline void _z80_ccf(z80_t* cpu) { cpu->f = ((cpu->f & (Z80_SF | Z80_ZF | Z80_PF | Z80_CF)) | ((cpu->f & Z80_CF) << 4) | (cpu->a & (Z80_YF | Z80_XF))) ^ Z80_CF; }
673
 
674
static inline void _z80_add16(z80_t* cpu, uint16_t val) {
675
	const uint16_t acc = cpu->hlx[cpu->hlx_idx].hl;
676
	cpu->wz = acc + 1;
677
	const uint32_t res = acc + val;
678
	cpu->hlx[cpu->hlx_idx].hl = res;
679
	cpu->f = (cpu->f & (Z80_SF | Z80_ZF | Z80_VF)) | (((acc ^ res ^ val) >> 8) & Z80_HF) | ((res >> 16) & Z80_CF) | ((res >> 8) & (Z80_YF | Z80_XF));
680
}
681
 
682
static inline void _z80_adc16(z80_t* cpu, uint16_t val) {
683
	// NOTE: adc is ED-prefixed, so they are never rewired to IX/IY
684
	const uint16_t acc = cpu->hl;
685
	cpu->wz = acc + 1;
686
	const uint32_t res = acc + val + (cpu->f & Z80_CF);
687
	cpu->hl = res;
688
	cpu->f = (((val ^ acc ^ 0x8000) & (val ^ res) & 0x8000) >> 13) | (((acc ^ res ^ val) >> 8) & Z80_HF) | ((res >> 16) & Z80_CF) | ((res >> 8) & (Z80_SF | Z80_YF | Z80_XF)) | ((res & 0xFFFF) ? 0 : Z80_ZF);
689
}
690
 
691
static inline void _z80_sbc16(z80_t* cpu, uint16_t val) {
692
	// NOTE: sbc is ED-prefixed, so they are never rewired to IX/IY
693
	const uint16_t acc = cpu->hl;
694
	cpu->wz = acc + 1;
695
	const uint32_t res = acc - val - (cpu->f & Z80_CF);
696
	cpu->hl = res;
697
	cpu->f = (Z80_NF | (((val ^ acc) & (acc ^ res) & 0x8000) >> 13)) | (((acc ^ res ^ val) >> 8) & Z80_HF) | ((res >> 16) & Z80_CF) | ((res >> 8) & (Z80_SF | Z80_YF | Z80_XF)) | ((res & 0xFFFF) ? 0 : Z80_ZF);
698
}
699
 
700
static inline bool _z80_ldi_ldd(z80_t* cpu, uint8_t val) {
701
	const uint8_t res = cpu->a + val;
702
	cpu->bc -= 1;
703
	cpu->f = (cpu->f & (Z80_SF | Z80_ZF | Z80_CF)) | ((res & 2) ? Z80_YF : 0) | ((res & 8) ? Z80_XF : 0) | (cpu->bc ? Z80_VF : 0);
704
	return cpu->bc != 0;
705
}
706
 
707
static inline bool _z80_cpi_cpd(z80_t* cpu, uint8_t val) {
708
	uint32_t res = (uint32_t)((int)cpu->a - (int)val);
709
	cpu->bc -= 1;
710
	uint8_t f = (cpu->f & Z80_CF) | Z80_NF | _z80_sz_flags(res);
711
	if((res & 0xF) > ((uint32_t)cpu->a & 0xF)) {
712
		f |= Z80_HF;
713
		res--;
714
	}
715
	if(res & 2) {
716
		f |= Z80_YF;
717
	}
718
	if(res & 8) {
719
		f |= Z80_XF;
720
	}
721
	if(cpu->bc) {
722
		f |= Z80_VF;
723
	}
724
	cpu->f = f;
725
	return (cpu->bc != 0) && !(f & Z80_ZF);
726
}
727
 
728
static inline bool _z80_ini_ind(z80_t* cpu, uint8_t val, uint8_t c) {
729
	const uint8_t b = cpu->b;
730
	uint8_t f = _z80_sz_flags(b) | (b & (Z80_XF | Z80_YF));
731
	if(val & Z80_SF) {
732
		f |= Z80_NF;
733
	}
734
	uint32_t t = (uint32_t)c + val;
735
	if(t & 0x100) {
736
		f |= Z80_HF | Z80_CF;
737
	}
738
	f |= _z80_szp_flags[((uint8_t)(t & 7)) ^ b] & Z80_PF;
739
	cpu->f = f;
740
	return (b != 0);
741
}
742
 
743
static inline bool _z80_outi_outd(z80_t* cpu, uint8_t val) {
744
	const uint8_t b = cpu->b;
745
	uint8_t f = _z80_sz_flags(b) | (b & (Z80_XF | Z80_YF));
746
	if(val & Z80_SF) {
747
		f |= Z80_NF;
748
	}
749
	uint32_t t = (uint32_t)cpu->l + val;
750
	if(t & 0x0100) {
751
		f |= Z80_HF | Z80_CF;
752
	}
753
	f |= _z80_szp_flags[((uint8_t)(t & 7)) ^ b] & Z80_PF;
754
	cpu->f = f;
755
	return (b != 0);
756
}
757
 
758
static inline uint8_t _z80_in(z80_t* cpu, uint8_t val) {
759
	cpu->f = (cpu->f & Z80_CF) | _z80_szp_flags[val];
760
	return val;
761
}
762
 
763
static inline uint8_t _z80_rrd(z80_t* cpu, uint8_t val) {
764
	const uint8_t l = cpu->a & 0x0F;
765
	cpu->a = (cpu->a & 0xF0) | (val & 0x0F);
766
	val = (val >> 4) | (l << 4);
767
	cpu->f = (cpu->f & Z80_CF) | _z80_szp_flags[cpu->a];
768
	return val;
769
}
770
 
771
static inline uint8_t _z80_rld(z80_t* cpu, uint8_t val) {
772
	const uint8_t l = cpu->a & 0x0F;
773
	cpu->a = (cpu->a & 0xF0) | (val >> 4);
774
	val = (val << 4) | l;
775
	cpu->f = (cpu->f & Z80_CF) | _z80_szp_flags[cpu->a];
776
	return val;
777
}
778
 
779
static inline uint8_t _z80_rlc(z80_t* cpu, uint8_t val) {
780
	uint8_t res = (val << 1) | (val >> 7);
781
	cpu->f = _z80_szp_flags[res] | ((val >> 7) & Z80_CF);
782
	return res;
783
}
784
 
785
static inline uint8_t _z80_rrc(z80_t* cpu, uint8_t val) {
786
	uint8_t res = (val >> 1) | (val << 7);
787
	cpu->f = _z80_szp_flags[res] | (val & Z80_CF);
788
	return res;
789
}
790
 
791
static inline uint8_t _z80_rl(z80_t* cpu, uint8_t val) {
792
	uint8_t res = (val << 1) | (cpu->f & Z80_CF);
793
	cpu->f = _z80_szp_flags[res] | ((val >> 7) & Z80_CF);
794
	return res;
795
}
796
 
797
static inline uint8_t _z80_rr(z80_t* cpu, uint8_t val) {
798
	uint8_t res = (val >> 1) | ((cpu->f & Z80_CF) << 7);
799
	cpu->f = _z80_szp_flags[res] | (val & Z80_CF);
800
	return res;
801
}
802
 
803
static inline uint8_t _z80_sla(z80_t* cpu, uint8_t val) {
804
	uint8_t res = val << 1;
805
	cpu->f = _z80_szp_flags[res] | ((val >> 7) & Z80_CF);
806
	return res;
807
}
808
 
809
static inline uint8_t _z80_sra(z80_t* cpu, uint8_t val) {
810
	uint8_t res = (val >> 1) | (val & 0x80);
811
	cpu->f = _z80_szp_flags[res] | (val & Z80_CF);
812
	return res;
813
}
814
 
815
static inline uint8_t _z80_sll(z80_t* cpu, uint8_t val) {
816
	uint8_t res = (val << 1) | 1;
817
	cpu->f = _z80_szp_flags[res] | ((val >> 7) & Z80_CF);
818
	return res;
819
}
820
 
821
static inline uint8_t _z80_srl(z80_t* cpu, uint8_t val) {
822
	uint8_t res = val >> 1;
823
	cpu->f = _z80_szp_flags[res] | (val & Z80_CF);
824
	return res;
825
}
826
 
827
static inline uint64_t _z80_set_ab(uint64_t pins, uint16_t ab) { return (pins & ~0xFFFF) | ab; }
828
 
829
static inline uint64_t _z80_set_ab_x(uint64_t pins, uint16_t ab, uint64_t x) { return (pins & ~0xFFFF) | ab | x; }
830
 
831
static inline uint64_t _z80_set_ab_db(uint64_t pins, uint16_t ab, uint8_t db) { return (pins & ~0xFFFFFF) | (db << 16) | ab; }
832
 
833
static inline uint64_t _z80_set_ab_db_x(uint64_t pins, uint16_t ab, uint8_t db, uint64_t x) { return (pins & ~0xFFFFFF) | (db << 16) | ab | x; }
834
 
835
static inline uint8_t _z80_get_db(uint64_t pins) { return (uint8_t)(pins >> 16); }
836
 
837
// CB-prefix block action
838
static inline bool _z80_cb_action(z80_t* cpu, uint8_t z0, uint8_t z1) {
839
	const uint8_t x = cpu->opcode >> 6;
840
	const uint8_t y = (cpu->opcode >> 3) & 7;
841
	uint8_t val, res;
842
	switch(z0) {
843
	case 0:
844
		val = cpu->b;
845
		break;
846
	case 1:
847
		val = cpu->c;
848
		break;
849
	case 2:
850
		val = cpu->d;
851
		break;
852
	case 3:
853
		val = cpu->e;
854
		break;
855
	case 4:
856
		val = cpu->h;
857
		break;
858
	case 5:
859
		val = cpu->l;
860
		break;
861
	case 6:
862
		val = cpu->dlatch;
863
		break; // (HL)
864
	case 7:
865
		val = cpu->a;
866
		break;
867
	default:
868
		_Z80_UNREACHABLE;
869
	}
870
	switch(x) {
871
	case 0: // rot/shift
872
		switch(y) {
873
		case 0:
874
			res = _z80_rlc(cpu, val);
875
			break;
876
		case 1:
877
			res = _z80_rrc(cpu, val);
878
			break;
879
		case 2:
880
			res = _z80_rl(cpu, val);
881
			break;
882
		case 3:
883
			res = _z80_rr(cpu, val);
884
			break;
885
		case 4:
886
			res = _z80_sla(cpu, val);
887
			break;
888
		case 5:
889
			res = _z80_sra(cpu, val);
890
			break;
891
		case 6:
892
			res = _z80_sll(cpu, val);
893
			break;
894
		case 7:
895
			res = _z80_srl(cpu, val);
896
			break;
897
		default:
898
			_Z80_UNREACHABLE;
899
		}
900
		break;
901
	case 1: // bit
902
		res = val & (1 << y);
903
		cpu->f = (cpu->f & Z80_CF) | Z80_HF | (res ? (res & Z80_SF) : (Z80_ZF | Z80_PF));
904
		if(z0 == 6) {
905
			cpu->f |= (cpu->wz >> 8) & (Z80_YF | Z80_XF);
906
		} else {
907
			cpu->f |= val & (Z80_YF | Z80_XF);
908
		}
909
		break;
910
	case 2: // res
911
		res = val & ~(1 << y);
912
		break;
913
	case 3: // set
914
		res = val | (1 << y);
915
		break;
916
	default:
917
		_Z80_UNREACHABLE;
918
	}
919
	// don't write result back for BIT
920
	if(x != 1) {
921
		cpu->dlatch = res;
922
		switch(z1) {
923
		case 0:
924
			cpu->b = res;
925
			break;
926
		case 1:
927
			cpu->c = res;
928
			break;
929
		case 2:
930
			cpu->d = res;
931
			break;
932
		case 3:
933
			cpu->e = res;
934
			break;
935
		case 4:
936
			cpu->h = res;
937
			break;
938
		case 5:
939
			cpu->l = res;
940
			break;
941
		case 6:
942
			break; // (HL)
943
		case 7:
944
			cpu->a = res;
945
			break;
946
		default:
947
			_Z80_UNREACHABLE;
948
		}
949
		return true;
950
	} else {
951
		return false;
952
	}
953
}
954
 
955
// compute the effective memory address for DD+CB/FD+CB instructions
956
static inline void _z80_ddfdcb_addr(z80_t* cpu, uint64_t pins) {
957
	uint8_t d = _z80_get_db(pins);
958
	cpu->addr = cpu->hlx[cpu->hlx_idx].hl + (int8_t)d;
959
	cpu->wz = cpu->addr;
960
}
961
 
962
// special case opstate table slots
963
#define _Z80_OPSTATE_SLOT_CB (0)
964
#define _Z80_OPSTATE_SLOT_CBHL (1)
965
#define _Z80_OPSTATE_SLOT_DDFDCB (2)
966
#define _Z80_OPSTATE_SLOT_INT_IM0 (3)
967
#define _Z80_OPSTATE_SLOT_INT_IM1 (4)
968
#define _Z80_OPSTATE_SLOT_INT_IM2 (5)
969
#define _Z80_OPSTATE_SLOT_NMI (6)
970
#define _Z80_OPSTATE_NUM_SPECIAL_OPS (7)
971
 
972
#define _Z80_OPSTATE_STEP_INDIRECT (5)	     // see case-branch '6'
973
#define _Z80_OPSTATE_STEP_INDIRECT_IMM8 (13) // see case-branch '14'
974
 
975
static const uint16_t _z80_optable[256] = {
976
    27,	 // 00: NOP (M:1 T:4 steps:1)
977
    28,	 // 01: LD BC,nn (M:3 T:10 steps:7)
978
    35,	 // 02: LD (BC),A (M:2 T:7 steps:4)
979
    39,	 // 03: INC BC (M:2 T:6 steps:3)
980
    42,	 // 04: INC B (M:1 T:4 steps:1)
981
    43,	 // 05: DEC B (M:1 T:4 steps:1)
982
    44,	 // 06: LD B,n (M:2 T:7 steps:4)
983
    48,	 // 07: RLCA (M:1 T:4 steps:1)
984
    49,	 // 08: EX AF,AF' (M:1 T:4 steps:1)
985
    50,	 // 09: ADD HL,BC (M:2 T:11 steps:8)
986
    58,	 // 0A: LD A,(BC) (M:2 T:7 steps:4)
987
    62,	 // 0B: DEC BC (M:2 T:6 steps:3)
988
    65,	 // 0C: INC C (M:1 T:4 steps:1)
989
    66,	 // 0D: DEC C (M:1 T:4 steps:1)
990
    67,	 // 0E: LD C,n (M:2 T:7 steps:4)
991
    71,	 // 0F: RRCA (M:1 T:4 steps:1)
992
    72,	 // 10: DJNZ d (M:4 T:13 steps:10)
993
    82,	 // 11: LD DE,nn (M:3 T:10 steps:7)
994
    89,	 // 12: LD (DE),A (M:2 T:7 steps:4)
995
    93,	 // 13: INC DE (M:2 T:6 steps:3)
996
    96,	 // 14: INC D (M:1 T:4 steps:1)
997
    97,	 // 15: DEC D (M:1 T:4 steps:1)
998
    98,	 // 16: LD D,n (M:2 T:7 steps:4)
999
    102, // 17: RLA (M:1 T:4 steps:1)
1000
    103, // 18: JR d (M:3 T:12 steps:9)
1001
    112, // 19: ADD HL,DE (M:2 T:11 steps:8)
1002
    120, // 1A: LD A,(DE) (M:2 T:7 steps:4)
1003
    124, // 1B: DEC DE (M:2 T:6 steps:3)
1004
    127, // 1C: INC E (M:1 T:4 steps:1)
1005
    128, // 1D: DEC E (M:1 T:4 steps:1)
1006
    129, // 1E: LD E,n (M:2 T:7 steps:4)
1007
    133, // 1F: RRA (M:1 T:4 steps:1)
1008
    134, // 20: JR NZ,d (M:3 T:12 steps:9)
1009
    143, // 21: LD HL,nn (M:3 T:10 steps:7)
1010
    150, // 22: LD (nn),HL (M:5 T:16 steps:13)
1011
    163, // 23: INC HL (M:2 T:6 steps:3)
1012
    166, // 24: INC H (M:1 T:4 steps:1)
1013
    167, // 25: DEC H (M:1 T:4 steps:1)
1014
    168, // 26: LD H,n (M:2 T:7 steps:4)
1015
    172, // 27: DAA (M:1 T:4 steps:1)
1016
    173, // 28: JR Z,d (M:3 T:12 steps:9)
1017
    182, // 29: ADD HL,HL (M:2 T:11 steps:8)
1018
    190, // 2A: LD HL,(nn) (M:5 T:16 steps:13)
1019
    203, // 2B: DEC HL (M:2 T:6 steps:3)
1020
    206, // 2C: INC L (M:1 T:4 steps:1)
1021
    207, // 2D: DEC L (M:1 T:4 steps:1)
1022
    208, // 2E: LD L,n (M:2 T:7 steps:4)
1023
    212, // 2F: CPL (M:1 T:4 steps:1)
1024
    213, // 30: JR NC,d (M:3 T:12 steps:9)
1025
    222, // 31: LD SP,nn (M:3 T:10 steps:7)
1026
    229, // 32: LD (nn),A (M:4 T:13 steps:10)
1027
    239, // 33: INC SP (M:2 T:6 steps:3)
1028
    242, // 34: INC (HL) (M:3 T:11 steps:8)
1029
    250, // 35: DEC (HL) (M:3 T:11 steps:8)
1030
    258, // 36: LD (HL),n (M:3 T:10 steps:7)
1031
    265, // 37: SCF (M:1 T:4 steps:1)
1032
    266, // 38: JR C,d (M:3 T:12 steps:9)
1033
    275, // 39: ADD HL,SP (M:2 T:11 steps:8)
1034
    283, // 3A: LD A,(nn) (M:4 T:13 steps:10)
1035
    293, // 3B: DEC SP (M:2 T:6 steps:3)
1036
    296, // 3C: INC A (M:1 T:4 steps:1)
1037
    297, // 3D: DEC A (M:1 T:4 steps:1)
1038
    298, // 3E: LD A,n (M:2 T:7 steps:4)
1039
    302, // 3F: CCF (M:1 T:4 steps:1)
1040
    303, // 40: LD B,B (M:1 T:4 steps:1)
1041
    304, // 41: LD B,C (M:1 T:4 steps:1)
1042
    305, // 42: LD B,D (M:1 T:4 steps:1)
1043
    306, // 43: LD B,E (M:1 T:4 steps:1)
1044
    307, // 44: LD B,H (M:1 T:4 steps:1)
1045
    308, // 45: LD B,L (M:1 T:4 steps:1)
1046
    309, // 46: LD B,(HL) (M:2 T:7 steps:4)
1047
    313, // 47: LD B,A (M:1 T:4 steps:1)
1048
    314, // 48: LD C,B (M:1 T:4 steps:1)
1049
    315, // 49: LD C,C (M:1 T:4 steps:1)
1050
    316, // 4A: LD C,D (M:1 T:4 steps:1)
1051
    317, // 4B: LD C,E (M:1 T:4 steps:1)
1052
    318, // 4C: LD C,H (M:1 T:4 steps:1)
1053
    319, // 4D: LD C,L (M:1 T:4 steps:1)
1054
    320, // 4E: LD C,(HL) (M:2 T:7 steps:4)
1055
    324, // 4F: LD C,A (M:1 T:4 steps:1)
1056
    325, // 50: LD D,B (M:1 T:4 steps:1)
1057
    326, // 51: LD D,C (M:1 T:4 steps:1)
1058
    327, // 52: LD D,D (M:1 T:4 steps:1)
1059
    328, // 53: LD D,E (M:1 T:4 steps:1)
1060
    329, // 54: LD D,H (M:1 T:4 steps:1)
1061
    330, // 55: LD D,L (M:1 T:4 steps:1)
1062
    331, // 56: LD D,(HL) (M:2 T:7 steps:4)
1063
    335, // 57: LD D,A (M:1 T:4 steps:1)
1064
    336, // 58: LD E,B (M:1 T:4 steps:1)
1065
    337, // 59: LD E,C (M:1 T:4 steps:1)
1066
    338, // 5A: LD E,D (M:1 T:4 steps:1)
1067
    339, // 5B: LD E,E (M:1 T:4 steps:1)
1068
    340, // 5C: LD E,H (M:1 T:4 steps:1)
1069
    341, // 5D: LD E,L (M:1 T:4 steps:1)
1070
    342, // 5E: LD E,(HL) (M:2 T:7 steps:4)
1071
    346, // 5F: LD E,A (M:1 T:4 steps:1)
1072
    347, // 60: LD H,B (M:1 T:4 steps:1)
1073
    348, // 61: LD H,C (M:1 T:4 steps:1)
1074
    349, // 62: LD H,D (M:1 T:4 steps:1)
1075
    350, // 63: LD H,E (M:1 T:4 steps:1)
1076
    351, // 64: LD H,H (M:1 T:4 steps:1)
1077
    352, // 65: LD H,L (M:1 T:4 steps:1)
1078
    353, // 66: LD H,(HL) (M:2 T:7 steps:4)
1079
    357, // 67: LD H,A (M:1 T:4 steps:1)
1080
    358, // 68: LD L,B (M:1 T:4 steps:1)
1081
    359, // 69: LD L,C (M:1 T:4 steps:1)
1082
    360, // 6A: LD L,D (M:1 T:4 steps:1)
1083
    361, // 6B: LD L,E (M:1 T:4 steps:1)
1084
    362, // 6C: LD L,H (M:1 T:4 steps:1)
1085
    363, // 6D: LD L,L (M:1 T:4 steps:1)
1086
    364, // 6E: LD L,(HL) (M:2 T:7 steps:4)
1087
    368, // 6F: LD L,A (M:1 T:4 steps:1)
1088
    369, // 70: LD (HL),B (M:2 T:7 steps:4)
1089
    373, // 71: LD (HL),C (M:2 T:7 steps:4)
1090
    377, // 72: LD (HL),D (M:2 T:7 steps:4)
1091
    381, // 73: LD (HL),E (M:2 T:7 steps:4)
1092
    385, // 74: LD (HL),H (M:2 T:7 steps:4)
1093
    389, // 75: LD (HL),L (M:2 T:7 steps:4)
1094
    393, // 76: HALT (M:1 T:4 steps:1)
1095
    394, // 77: LD (HL),A (M:2 T:7 steps:4)
1096
    398, // 78: LD A,B (M:1 T:4 steps:1)
1097
    399, // 79: LD A,C (M:1 T:4 steps:1)
1098
    400, // 7A: LD A,D (M:1 T:4 steps:1)
1099
    401, // 7B: LD A,E (M:1 T:4 steps:1)
1100
    402, // 7C: LD A,H (M:1 T:4 steps:1)
1101
    403, // 7D: LD A,L (M:1 T:4 steps:1)
1102
    404, // 7E: LD A,(HL) (M:2 T:7 steps:4)
1103
    408, // 7F: LD A,A (M:1 T:4 steps:1)
1104
    409, // 80: ADD B (M:1 T:4 steps:1)
1105
    410, // 81: ADD C (M:1 T:4 steps:1)
1106
    411, // 82: ADD D (M:1 T:4 steps:1)
1107
    412, // 83: ADD E (M:1 T:4 steps:1)
1108
    413, // 84: ADD H (M:1 T:4 steps:1)
1109
    414, // 85: ADD L (M:1 T:4 steps:1)
1110
    415, // 86: ADD (HL) (M:2 T:7 steps:4)
1111
    419, // 87: ADD A (M:1 T:4 steps:1)
1112
    420, // 88: ADC B (M:1 T:4 steps:1)
1113
    421, // 89: ADC C (M:1 T:4 steps:1)
1114
    422, // 8A: ADC D (M:1 T:4 steps:1)
1115
    423, // 8B: ADC E (M:1 T:4 steps:1)
1116
    424, // 8C: ADC H (M:1 T:4 steps:1)
1117
    425, // 8D: ADC L (M:1 T:4 steps:1)
1118
    426, // 8E: ADC (HL) (M:2 T:7 steps:4)
1119
    430, // 8F: ADC A (M:1 T:4 steps:1)
1120
    431, // 90: SUB B (M:1 T:4 steps:1)
1121
    432, // 91: SUB C (M:1 T:4 steps:1)
1122
    433, // 92: SUB D (M:1 T:4 steps:1)
1123
    434, // 93: SUB E (M:1 T:4 steps:1)
1124
    435, // 94: SUB H (M:1 T:4 steps:1)
1125
    436, // 95: SUB L (M:1 T:4 steps:1)
1126
    437, // 96: SUB (HL) (M:2 T:7 steps:4)
1127
    441, // 97: SUB A (M:1 T:4 steps:1)
1128
    442, // 98: SBC B (M:1 T:4 steps:1)
1129
    443, // 99: SBC C (M:1 T:4 steps:1)
1130
    444, // 9A: SBC D (M:1 T:4 steps:1)
1131
    445, // 9B: SBC E (M:1 T:4 steps:1)
1132
    446, // 9C: SBC H (M:1 T:4 steps:1)
1133
    447, // 9D: SBC L (M:1 T:4 steps:1)
1134
    448, // 9E: SBC (HL) (M:2 T:7 steps:4)
1135
    452, // 9F: SBC A (M:1 T:4 steps:1)
1136
    453, // A0: AND B (M:1 T:4 steps:1)
1137
    454, // A1: AND C (M:1 T:4 steps:1)
1138
    455, // A2: AND D (M:1 T:4 steps:1)
1139
    456, // A3: AND E (M:1 T:4 steps:1)
1140
    457, // A4: AND H (M:1 T:4 steps:1)
1141
    458, // A5: AND L (M:1 T:4 steps:1)
1142
    459, // A6: AND (HL) (M:2 T:7 steps:4)
1143
    463, // A7: AND A (M:1 T:4 steps:1)
1144
    464, // A8: XOR B (M:1 T:4 steps:1)
1145
    465, // A9: XOR C (M:1 T:4 steps:1)
1146
    466, // AA: XOR D (M:1 T:4 steps:1)
1147
    467, // AB: XOR E (M:1 T:4 steps:1)
1148
    468, // AC: XOR H (M:1 T:4 steps:1)
1149
    469, // AD: XOR L (M:1 T:4 steps:1)
1150
    470, // AE: XOR (HL) (M:2 T:7 steps:4)
1151
    474, // AF: XOR A (M:1 T:4 steps:1)
1152
    475, // B0: OR B (M:1 T:4 steps:1)
1153
    476, // B1: OR C (M:1 T:4 steps:1)
1154
    477, // B2: OR D (M:1 T:4 steps:1)
1155
    478, // B3: OR E (M:1 T:4 steps:1)
1156
    479, // B4: OR H (M:1 T:4 steps:1)
1157
    480, // B5: OR L (M:1 T:4 steps:1)
1158
    481, // B6: OR (HL) (M:2 T:7 steps:4)
1159
    485, // B7: OR A (M:1 T:4 steps:1)
1160
    486, // B8: CP B (M:1 T:4 steps:1)
1161
    487, // B9: CP C (M:1 T:4 steps:1)
1162
    488, // BA: CP D (M:1 T:4 steps:1)
1163
    489, // BB: CP E (M:1 T:4 steps:1)
1164
    490, // BC: CP H (M:1 T:4 steps:1)
1165
    491, // BD: CP L (M:1 T:4 steps:1)
1166
    492, // BE: CP (HL) (M:2 T:7 steps:4)
1167
    496, // BF: CP A (M:1 T:4 steps:1)
1168
    497, // C0: RET NZ (M:4 T:11 steps:8)
1169
    505, // C1: POP BC (M:3 T:10 steps:7)
1170
    512, // C2: JP NZ,nn (M:3 T:10 steps:7)
1171
    519, // C3: JP nn (M:3 T:10 steps:7)
1172
    526, // C4: CALL NZ,nn (M:6 T:17 steps:14)
1173
    540, // C5: PUSH BC (M:4 T:11 steps:8)
1174
    548, // C6: ADD n (M:2 T:7 steps:4)
1175
    552, // C7: RST 0h (M:4 T:11 steps:8)
1176
    560, // C8: RET Z (M:4 T:11 steps:8)
1177
    568, // C9: RET (M:3 T:10 steps:7)
1178
    575, // CA: JP Z,nn (M:3 T:10 steps:7)
1179
    582, // CB: CB prefix (M:1 T:4 steps:1)
1180
    583, // CC: CALL Z,nn (M:6 T:17 steps:14)
1181
    597, // CD: CALL nn (M:5 T:17 steps:14)
1182
    611, // CE: ADC n (M:2 T:7 steps:4)
1183
    615, // CF: RST 8h (M:4 T:11 steps:8)
1184
    623, // D0: RET NC (M:4 T:11 steps:8)
1185
    631, // D1: POP DE (M:3 T:10 steps:7)
1186
    638, // D2: JP NC,nn (M:3 T:10 steps:7)
1187
    645, // D3: OUT (n),A (M:3 T:11 steps:8)
1188
    653, // D4: CALL NC,nn (M:6 T:17 steps:14)
1189
    667, // D5: PUSH DE (M:4 T:11 steps:8)
1190
    675, // D6: SUB n (M:2 T:7 steps:4)
1191
    679, // D7: RST 10h (M:4 T:11 steps:8)
1192
    687, // D8: RET C (M:4 T:11 steps:8)
1193
    695, // D9: EXX (M:1 T:4 steps:1)
1194
    696, // DA: JP C,nn (M:3 T:10 steps:7)
1195
    703, // DB: IN A,(n) (M:3 T:11 steps:8)
1196
    711, // DC: CALL C,nn (M:6 T:17 steps:14)
1197
    725, // DD: DD prefix (M:1 T:4 steps:1)
1198
    726, // DE: SBC n (M:2 T:7 steps:4)
1199
    730, // DF: RST 18h (M:4 T:11 steps:8)
1200
    738, // E0: RET PO (M:4 T:11 steps:8)
1201
    746, // E1: POP HL (M:3 T:10 steps:7)
1202
    753, // E2: JP PO,nn (M:3 T:10 steps:7)
1203
    760, // E3: EX (SP),HL (M:5 T:19 steps:16)
1204
    776, // E4: CALL PO,nn (M:6 T:17 steps:14)
1205
    790, // E5: PUSH HL (M:4 T:11 steps:8)
1206
    798, // E6: AND n (M:2 T:7 steps:4)
1207
    802, // E7: RST 20h (M:4 T:11 steps:8)
1208
    810, // E8: RET PE (M:4 T:11 steps:8)
1209
    818, // E9: JP HL (M:1 T:4 steps:1)
1210
    819, // EA: JP PE,nn (M:3 T:10 steps:7)
1211
    826, // EB: EX DE,HL (M:1 T:4 steps:1)
1212
    827, // EC: CALL PE,nn (M:6 T:17 steps:14)
1213
    841, // ED: ED prefix (M:1 T:4 steps:1)
1214
    842, // EE: XOR n (M:2 T:7 steps:4)
1215
    846, // EF: RST 28h (M:4 T:11 steps:8)
1216
    854, // F0: RET P (M:4 T:11 steps:8)
1217
    862, // F1: POP AF (M:3 T:10 steps:7)
1218
    869, // F2: JP P,nn (M:3 T:10 steps:7)
1219
    876, // F3: DI (M:1 T:4 steps:1)
1220
    877, // F4: CALL P,nn (M:6 T:17 steps:14)
1221
    891, // F5: PUSH AF (M:4 T:11 steps:8)
1222
    899, // F6: OR n (M:2 T:7 steps:4)
1223
    903, // F7: RST 30h (M:4 T:11 steps:8)
1224
    911, // F8: RET M (M:4 T:11 steps:8)
1225
    919, // F9: LD SP,HL (M:2 T:6 steps:3)
1226
    922, // FA: JP M,nn (M:3 T:10 steps:7)
1227
    929, // FB: EI (M:1 T:4 steps:1)
1228
    930, // FC: CALL M,nn (M:6 T:17 steps:14)
1229
    944, // FD: FD prefix (M:1 T:4 steps:1)
1230
    945, // FE: CP n (M:2 T:7 steps:4)
1231
    949, // FF: RST 38h (M:4 T:11 steps:8)
1232
};
1233
 
1234
static const uint16_t _z80_ddfd_optable[256] = {
1235
    27,				     // 00: NOP (M:1 T:4 steps:1)
1236
    28,				     // 01: LD BC,nn (M:3 T:10 steps:7)
1237
    35,				     // 02: LD (BC),A (M:2 T:7 steps:4)
1238
    39,				     // 03: INC BC (M:2 T:6 steps:3)
1239
    42,				     // 04: INC B (M:1 T:4 steps:1)
1240
    43,				     // 05: DEC B (M:1 T:4 steps:1)
1241
    44,				     // 06: LD B,n (M:2 T:7 steps:4)
1242
    48,				     // 07: RLCA (M:1 T:4 steps:1)
1243
    49,				     // 08: EX AF,AF' (M:1 T:4 steps:1)
1244
    50,				     // 09: ADD HL,BC (M:2 T:11 steps:8)
1245
    58,				     // 0A: LD A,(BC) (M:2 T:7 steps:4)
1246
    62,				     // 0B: DEC BC (M:2 T:6 steps:3)
1247
    65,				     // 0C: INC C (M:1 T:4 steps:1)
1248
    66,				     // 0D: DEC C (M:1 T:4 steps:1)
1249
    67,				     // 0E: LD C,n (M:2 T:7 steps:4)
1250
    71,				     // 0F: RRCA (M:1 T:4 steps:1)
1251
    72,				     // 10: DJNZ d (M:4 T:13 steps:10)
1252
    82,				     // 11: LD DE,nn (M:3 T:10 steps:7)
1253
    89,				     // 12: LD (DE),A (M:2 T:7 steps:4)
1254
    93,				     // 13: INC DE (M:2 T:6 steps:3)
1255
    96,				     // 14: INC D (M:1 T:4 steps:1)
1256
    97,				     // 15: DEC D (M:1 T:4 steps:1)
1257
    98,				     // 16: LD D,n (M:2 T:7 steps:4)
1258
    102,			     // 17: RLA (M:1 T:4 steps:1)
1259
    103,			     // 18: JR d (M:3 T:12 steps:9)
1260
    112,			     // 19: ADD HL,DE (M:2 T:11 steps:8)
1261
    120,			     // 1A: LD A,(DE) (M:2 T:7 steps:4)
1262
    124,			     // 1B: DEC DE (M:2 T:6 steps:3)
1263
    127,			     // 1C: INC E (M:1 T:4 steps:1)
1264
    128,			     // 1D: DEC E (M:1 T:4 steps:1)
1265
    129,			     // 1E: LD E,n (M:2 T:7 steps:4)
1266
    133,			     // 1F: RRA (M:1 T:4 steps:1)
1267
    134,			     // 20: JR NZ,d (M:3 T:12 steps:9)
1268
    143,			     // 21: LD HL,nn (M:3 T:10 steps:7)
1269
    150,			     // 22: LD (nn),HL (M:5 T:16 steps:13)
1270
    163,			     // 23: INC HL (M:2 T:6 steps:3)
1271
    166,			     // 24: INC H (M:1 T:4 steps:1)
1272
    167,			     // 25: DEC H (M:1 T:4 steps:1)
1273
    168,			     // 26: LD H,n (M:2 T:7 steps:4)
1274
    172,			     // 27: DAA (M:1 T:4 steps:1)
1275
    173,			     // 28: JR Z,d (M:3 T:12 steps:9)
1276
    182,			     // 29: ADD HL,HL (M:2 T:11 steps:8)
1277
    190,			     // 2A: LD HL,(nn) (M:5 T:16 steps:13)
1278
    203,			     // 2B: DEC HL (M:2 T:6 steps:3)
1279
    206,			     // 2C: INC L (M:1 T:4 steps:1)
1280
    207,			     // 2D: DEC L (M:1 T:4 steps:1)
1281
    208,			     // 2E: LD L,n (M:2 T:7 steps:4)
1282
    212,			     // 2F: CPL (M:1 T:4 steps:1)
1283
    213,			     // 30: JR NC,d (M:3 T:12 steps:9)
1284
    222,			     // 31: LD SP,nn (M:3 T:10 steps:7)
1285
    229,			     // 32: LD (nn),A (M:4 T:13 steps:10)
1286
    239,			     // 33: INC SP (M:2 T:6 steps:3)
1287
    _Z80_OPSTATE_STEP_INDIRECT,	     // 34: INC (HL) (M:3 T:11 steps:8)
1288
    _Z80_OPSTATE_STEP_INDIRECT,	     // 35: DEC (HL) (M:3 T:11 steps:8)
1289
    _Z80_OPSTATE_STEP_INDIRECT_IMM8, // 36: LD (HL),n (M:3 T:10 steps:7)
1290
    265,			     // 37: SCF (M:1 T:4 steps:1)
1291
    266,			     // 38: JR C,d (M:3 T:12 steps:9)
1292
    275,			     // 39: ADD HL,SP (M:2 T:11 steps:8)
1293
    283,			     // 3A: LD A,(nn) (M:4 T:13 steps:10)
1294
    293,			     // 3B: DEC SP (M:2 T:6 steps:3)
1295
    296,			     // 3C: INC A (M:1 T:4 steps:1)
1296
    297,			     // 3D: DEC A (M:1 T:4 steps:1)
1297
    298,			     // 3E: LD A,n (M:2 T:7 steps:4)
1298
    302,			     // 3F: CCF (M:1 T:4 steps:1)
1299
    303,			     // 40: LD B,B (M:1 T:4 steps:1)
1300
    304,			     // 41: LD B,C (M:1 T:4 steps:1)
1301
    305,			     // 42: LD B,D (M:1 T:4 steps:1)
1302
    306,			     // 43: LD B,E (M:1 T:4 steps:1)
1303
    307,			     // 44: LD B,H (M:1 T:4 steps:1)
1304
    308,			     // 45: LD B,L (M:1 T:4 steps:1)
1305
    _Z80_OPSTATE_STEP_INDIRECT,	     // 46: LD B,(HL) (M:2 T:7 steps:4)
1306
    313,			     // 47: LD B,A (M:1 T:4 steps:1)
1307
    314,			     // 48: LD C,B (M:1 T:4 steps:1)
1308
    315,			     // 49: LD C,C (M:1 T:4 steps:1)
1309
    316,			     // 4A: LD C,D (M:1 T:4 steps:1)
1310
    317,			     // 4B: LD C,E (M:1 T:4 steps:1)
1311
    318,			     // 4C: LD C,H (M:1 T:4 steps:1)
1312
    319,			     // 4D: LD C,L (M:1 T:4 steps:1)
1313
    _Z80_OPSTATE_STEP_INDIRECT,	     // 4E: LD C,(HL) (M:2 T:7 steps:4)
1314
    324,			     // 4F: LD C,A (M:1 T:4 steps:1)
1315
    325,			     // 50: LD D,B (M:1 T:4 steps:1)
1316
    326,			     // 51: LD D,C (M:1 T:4 steps:1)
1317
    327,			     // 52: LD D,D (M:1 T:4 steps:1)
1318
    328,			     // 53: LD D,E (M:1 T:4 steps:1)
1319
    329,			     // 54: LD D,H (M:1 T:4 steps:1)
1320
    330,			     // 55: LD D,L (M:1 T:4 steps:1)
1321
    _Z80_OPSTATE_STEP_INDIRECT,	     // 56: LD D,(HL) (M:2 T:7 steps:4)
1322
    335,			     // 57: LD D,A (M:1 T:4 steps:1)
1323
    336,			     // 58: LD E,B (M:1 T:4 steps:1)
1324
    337,			     // 59: LD E,C (M:1 T:4 steps:1)
1325
    338,			     // 5A: LD E,D (M:1 T:4 steps:1)
1326
    339,			     // 5B: LD E,E (M:1 T:4 steps:1)
1327
    340,			     // 5C: LD E,H (M:1 T:4 steps:1)
1328
    341,			     // 5D: LD E,L (M:1 T:4 steps:1)
1329
    _Z80_OPSTATE_STEP_INDIRECT,	     // 5E: LD E,(HL) (M:2 T:7 steps:4)
1330
    346,			     // 5F: LD E,A (M:1 T:4 steps:1)
1331
    347,			     // 60: LD H,B (M:1 T:4 steps:1)
1332
    348,			     // 61: LD H,C (M:1 T:4 steps:1)
1333
    349,			     // 62: LD H,D (M:1 T:4 steps:1)
1334
    350,			     // 63: LD H,E (M:1 T:4 steps:1)
1335
    351,			     // 64: LD H,H (M:1 T:4 steps:1)
1336
    352,			     // 65: LD H,L (M:1 T:4 steps:1)
1337
    _Z80_OPSTATE_STEP_INDIRECT,	     // 66: LD H,(HL) (M:2 T:7 steps:4)
1338
    357,			     // 67: LD H,A (M:1 T:4 steps:1)
1339
    358,			     // 68: LD L,B (M:1 T:4 steps:1)
1340
    359,			     // 69: LD L,C (M:1 T:4 steps:1)
1341
    360,			     // 6A: LD L,D (M:1 T:4 steps:1)
1342
    361,			     // 6B: LD L,E (M:1 T:4 steps:1)
1343
    362,			     // 6C: LD L,H (M:1 T:4 steps:1)
1344
    363,			     // 6D: LD L,L (M:1 T:4 steps:1)
1345
    _Z80_OPSTATE_STEP_INDIRECT,	     // 6E: LD L,(HL) (M:2 T:7 steps:4)
1346
    368,			     // 6F: LD L,A (M:1 T:4 steps:1)
1347
    _Z80_OPSTATE_STEP_INDIRECT,	     // 70: LD (HL),B (M:2 T:7 steps:4)
1348
    _Z80_OPSTATE_STEP_INDIRECT,	     // 71: LD (HL),C (M:2 T:7 steps:4)
1349
    _Z80_OPSTATE_STEP_INDIRECT,	     // 72: LD (HL),D (M:2 T:7 steps:4)
1350
    _Z80_OPSTATE_STEP_INDIRECT,	     // 73: LD (HL),E (M:2 T:7 steps:4)
1351
    _Z80_OPSTATE_STEP_INDIRECT,	     // 74: LD (HL),H (M:2 T:7 steps:4)
1352
    _Z80_OPSTATE_STEP_INDIRECT,	     // 75: LD (HL),L (M:2 T:7 steps:4)
1353
    393,			     // 76: HALT (M:1 T:4 steps:1)
1354
    _Z80_OPSTATE_STEP_INDIRECT,	     // 77: LD (HL),A (M:2 T:7 steps:4)
1355
    398,			     // 78: LD A,B (M:1 T:4 steps:1)
1356
    399,			     // 79: LD A,C (M:1 T:4 steps:1)
1357
    400,			     // 7A: LD A,D (M:1 T:4 steps:1)
1358
    401,			     // 7B: LD A,E (M:1 T:4 steps:1)
1359
    402,			     // 7C: LD A,H (M:1 T:4 steps:1)
1360
    403,			     // 7D: LD A,L (M:1 T:4 steps:1)
1361
    _Z80_OPSTATE_STEP_INDIRECT,	     // 7E: LD A,(HL) (M:2 T:7 steps:4)
1362
    408,			     // 7F: LD A,A (M:1 T:4 steps:1)
1363
    409,			     // 80: ADD B (M:1 T:4 steps:1)
1364
    410,			     // 81: ADD C (M:1 T:4 steps:1)
1365
    411,			     // 82: ADD D (M:1 T:4 steps:1)
1366
    412,			     // 83: ADD E (M:1 T:4 steps:1)
1367
    413,			     // 84: ADD H (M:1 T:4 steps:1)
1368
    414,			     // 85: ADD L (M:1 T:4 steps:1)
1369
    _Z80_OPSTATE_STEP_INDIRECT,	     // 86: ADD (HL) (M:2 T:7 steps:4)
1370
    419,			     // 87: ADD A (M:1 T:4 steps:1)
1371
    420,			     // 88: ADC B (M:1 T:4 steps:1)
1372
    421,			     // 89: ADC C (M:1 T:4 steps:1)
1373
    422,			     // 8A: ADC D (M:1 T:4 steps:1)
1374
    423,			     // 8B: ADC E (M:1 T:4 steps:1)
1375
    424,			     // 8C: ADC H (M:1 T:4 steps:1)
1376
    425,			     // 8D: ADC L (M:1 T:4 steps:1)
1377
    _Z80_OPSTATE_STEP_INDIRECT,	     // 8E: ADC (HL) (M:2 T:7 steps:4)
1378
    430,			     // 8F: ADC A (M:1 T:4 steps:1)
1379
    431,			     // 90: SUB B (M:1 T:4 steps:1)
1380
    432,			     // 91: SUB C (M:1 T:4 steps:1)
1381
    433,			     // 92: SUB D (M:1 T:4 steps:1)
1382
    434,			     // 93: SUB E (M:1 T:4 steps:1)
1383
    435,			     // 94: SUB H (M:1 T:4 steps:1)
1384
    436,			     // 95: SUB L (M:1 T:4 steps:1)
1385
    _Z80_OPSTATE_STEP_INDIRECT,	     // 96: SUB (HL) (M:2 T:7 steps:4)
1386
    441,			     // 97: SUB A (M:1 T:4 steps:1)
1387
    442,			     // 98: SBC B (M:1 T:4 steps:1)
1388
    443,			     // 99: SBC C (M:1 T:4 steps:1)
1389
    444,			     // 9A: SBC D (M:1 T:4 steps:1)
1390
    445,			     // 9B: SBC E (M:1 T:4 steps:1)
1391
    446,			     // 9C: SBC H (M:1 T:4 steps:1)
1392
    447,			     // 9D: SBC L (M:1 T:4 steps:1)
1393
    _Z80_OPSTATE_STEP_INDIRECT,	     // 9E: SBC (HL) (M:2 T:7 steps:4)
1394
    452,			     // 9F: SBC A (M:1 T:4 steps:1)
1395
    453,			     // A0: AND B (M:1 T:4 steps:1)
1396
    454,			     // A1: AND C (M:1 T:4 steps:1)
1397
    455,			     // A2: AND D (M:1 T:4 steps:1)
1398
    456,			     // A3: AND E (M:1 T:4 steps:1)
1399
    457,			     // A4: AND H (M:1 T:4 steps:1)
1400
    458,			     // A5: AND L (M:1 T:4 steps:1)
1401
    _Z80_OPSTATE_STEP_INDIRECT,	     // A6: AND (HL) (M:2 T:7 steps:4)
1402
    463,			     // A7: AND A (M:1 T:4 steps:1)
1403
    464,			     // A8: XOR B (M:1 T:4 steps:1)
1404
    465,			     // A9: XOR C (M:1 T:4 steps:1)
1405
    466,			     // AA: XOR D (M:1 T:4 steps:1)
1406
    467,			     // AB: XOR E (M:1 T:4 steps:1)
1407
    468,			     // AC: XOR H (M:1 T:4 steps:1)
1408
    469,			     // AD: XOR L (M:1 T:4 steps:1)
1409
    _Z80_OPSTATE_STEP_INDIRECT,	     // AE: XOR (HL) (M:2 T:7 steps:4)
1410
    474,			     // AF: XOR A (M:1 T:4 steps:1)
1411
    475,			     // B0: OR B (M:1 T:4 steps:1)
1412
    476,			     // B1: OR C (M:1 T:4 steps:1)
1413
    477,			     // B2: OR D (M:1 T:4 steps:1)
1414
    478,			     // B3: OR E (M:1 T:4 steps:1)
1415
    479,			     // B4: OR H (M:1 T:4 steps:1)
1416
    480,			     // B5: OR L (M:1 T:4 steps:1)
1417
    _Z80_OPSTATE_STEP_INDIRECT,	     // B6: OR (HL) (M:2 T:7 steps:4)
1418
    485,			     // B7: OR A (M:1 T:4 steps:1)
1419
    486,			     // B8: CP B (M:1 T:4 steps:1)
1420
    487,			     // B9: CP C (M:1 T:4 steps:1)
1421
    488,			     // BA: CP D (M:1 T:4 steps:1)
1422
    489,			     // BB: CP E (M:1 T:4 steps:1)
1423
    490,			     // BC: CP H (M:1 T:4 steps:1)
1424
    491,			     // BD: CP L (M:1 T:4 steps:1)
1425
    _Z80_OPSTATE_STEP_INDIRECT,	     // BE: CP (HL) (M:2 T:7 steps:4)
1426
    496,			     // BF: CP A (M:1 T:4 steps:1)
1427
    497,			     // C0: RET NZ (M:4 T:11 steps:8)
1428
    505,			     // C1: POP BC (M:3 T:10 steps:7)
1429
    512,			     // C2: JP NZ,nn (M:3 T:10 steps:7)
1430
    519,			     // C3: JP nn (M:3 T:10 steps:7)
1431
    526,			     // C4: CALL NZ,nn (M:6 T:17 steps:14)
1432
    540,			     // C5: PUSH BC (M:4 T:11 steps:8)
1433
    548,			     // C6: ADD n (M:2 T:7 steps:4)
1434
    552,			     // C7: RST 0h (M:4 T:11 steps:8)
1435
    560,			     // C8: RET Z (M:4 T:11 steps:8)
1436
    568,			     // C9: RET (M:3 T:10 steps:7)
1437
    575,			     // CA: JP Z,nn (M:3 T:10 steps:7)
1438
    582,			     // CB: CB prefix (M:1 T:4 steps:1)
1439
    583,			     // CC: CALL Z,nn (M:6 T:17 steps:14)
1440
    597,			     // CD: CALL nn (M:5 T:17 steps:14)
1441
    611,			     // CE: ADC n (M:2 T:7 steps:4)
1442
    615,			     // CF: RST 8h (M:4 T:11 steps:8)
1443
    623,			     // D0: RET NC (M:4 T:11 steps:8)
1444
    631,			     // D1: POP DE (M:3 T:10 steps:7)
1445
    638,			     // D2: JP NC,nn (M:3 T:10 steps:7)
1446
    645,			     // D3: OUT (n),A (M:3 T:11 steps:8)
1447
    653,			     // D4: CALL NC,nn (M:6 T:17 steps:14)
1448
    667,			     // D5: PUSH DE (M:4 T:11 steps:8)
1449
    675,			     // D6: SUB n (M:2 T:7 steps:4)
1450
    679,			     // D7: RST 10h (M:4 T:11 steps:8)
1451
    687,			     // D8: RET C (M:4 T:11 steps:8)
1452
    695,			     // D9: EXX (M:1 T:4 steps:1)
1453
    696,			     // DA: JP C,nn (M:3 T:10 steps:7)
1454
    703,			     // DB: IN A,(n) (M:3 T:11 steps:8)
1455
    711,			     // DC: CALL C,nn (M:6 T:17 steps:14)
1456
    725,			     // DD: DD prefix (M:1 T:4 steps:1)
1457
    726,			     // DE: SBC n (M:2 T:7 steps:4)
1458
    730,			     // DF: RST 18h (M:4 T:11 steps:8)
1459
    738,			     // E0: RET PO (M:4 T:11 steps:8)
1460
    746,			     // E1: POP HL (M:3 T:10 steps:7)
1461
    753,			     // E2: JP PO,nn (M:3 T:10 steps:7)
1462
    760,			     // E3: EX (SP),HL (M:5 T:19 steps:16)
1463
    776,			     // E4: CALL PO,nn (M:6 T:17 steps:14)
1464
    790,			     // E5: PUSH HL (M:4 T:11 steps:8)
1465
    798,			     // E6: AND n (M:2 T:7 steps:4)
1466
    802,			     // E7: RST 20h (M:4 T:11 steps:8)
1467
    810,			     // E8: RET PE (M:4 T:11 steps:8)
1468
    818,			     // E9: JP HL (M:1 T:4 steps:1)
1469
    819,			     // EA: JP PE,nn (M:3 T:10 steps:7)
1470
    826,			     // EB: EX DE,HL (M:1 T:4 steps:1)
1471
    827,			     // EC: CALL PE,nn (M:6 T:17 steps:14)
1472
    841,			     // ED: ED prefix (M:1 T:4 steps:1)
1473
    842,			     // EE: XOR n (M:2 T:7 steps:4)
1474
    846,			     // EF: RST 28h (M:4 T:11 steps:8)
1475
    854,			     // F0: RET P (M:4 T:11 steps:8)
1476
    862,			     // F1: POP AF (M:3 T:10 steps:7)
1477
    869,			     // F2: JP P,nn (M:3 T:10 steps:7)
1478
    876,			     // F3: DI (M:1 T:4 steps:1)
1479
    877,			     // F4: CALL P,nn (M:6 T:17 steps:14)
1480
    891,			     // F5: PUSH AF (M:4 T:11 steps:8)
1481
    899,			     // F6: OR n (M:2 T:7 steps:4)
1482
    903,			     // F7: RST 30h (M:4 T:11 steps:8)
1483
    911,			     // F8: RET M (M:4 T:11 steps:8)
1484
    919,			     // F9: LD SP,HL (M:2 T:6 steps:3)
1485
    922,			     // FA: JP M,nn (M:3 T:10 steps:7)
1486
    929,			     // FB: EI (M:1 T:4 steps:1)
1487
    930,			     // FC: CALL M,nn (M:6 T:17 steps:14)
1488
    944,			     // FD: FD prefix (M:1 T:4 steps:1)
1489
    945,			     // FE: CP n (M:2 T:7 steps:4)
1490
    949,			     // FF: RST 38h (M:4 T:11 steps:8)
1491
};
1492
 
1493
static const uint16_t _z80_ed_optable[256] = {
1494
    957,  // 00: ED NOP (M:1 T:4 steps:1)
1495
    957,  // 01: ED NOP (M:1 T:4 steps:1)
1496
    957,  // 02: ED NOP (M:1 T:4 steps:1)
1497
    957,  // 03: ED NOP (M:1 T:4 steps:1)
1498
    957,  // 04: ED NOP (M:1 T:4 steps:1)
1499
    957,  // 05: ED NOP (M:1 T:4 steps:1)
1500
    957,  // 06: ED NOP (M:1 T:4 steps:1)
1501
    957,  // 07: ED NOP (M:1 T:4 steps:1)
1502
    957,  // 08: ED NOP (M:1 T:4 steps:1)
1503
    957,  // 09: ED NOP (M:1 T:4 steps:1)
1504
    957,  // 0A: ED NOP (M:1 T:4 steps:1)
1505
    957,  // 0B: ED NOP (M:1 T:4 steps:1)
1506
    957,  // 0C: ED NOP (M:1 T:4 steps:1)
1507
    957,  // 0D: ED NOP (M:1 T:4 steps:1)
1508
    957,  // 0E: ED NOP (M:1 T:4 steps:1)
1509
    957,  // 0F: ED NOP (M:1 T:4 steps:1)
1510
    957,  // 10: ED NOP (M:1 T:4 steps:1)
1511
    957,  // 11: ED NOP (M:1 T:4 steps:1)
1512
    957,  // 12: ED NOP (M:1 T:4 steps:1)
1513
    957,  // 13: ED NOP (M:1 T:4 steps:1)
1514
    957,  // 14: ED NOP (M:1 T:4 steps:1)
1515
    957,  // 15: ED NOP (M:1 T:4 steps:1)
1516
    957,  // 16: ED NOP (M:1 T:4 steps:1)
1517
    957,  // 17: ED NOP (M:1 T:4 steps:1)
1518
    957,  // 18: ED NOP (M:1 T:4 steps:1)
1519
    957,  // 19: ED NOP (M:1 T:4 steps:1)
1520
    957,  // 1A: ED NOP (M:1 T:4 steps:1)
1521
    957,  // 1B: ED NOP (M:1 T:4 steps:1)
1522
    957,  // 1C: ED NOP (M:1 T:4 steps:1)
1523
    957,  // 1D: ED NOP (M:1 T:4 steps:1)
1524
    957,  // 1E: ED NOP (M:1 T:4 steps:1)
1525
    957,  // 1F: ED NOP (M:1 T:4 steps:1)
1526
    957,  // 20: ED NOP (M:1 T:4 steps:1)
1527
    957,  // 21: ED NOP (M:1 T:4 steps:1)
1528
    957,  // 22: ED NOP (M:1 T:4 steps:1)
1529
    957,  // 23: ED NOP (M:1 T:4 steps:1)
1530
    957,  // 24: ED NOP (M:1 T:4 steps:1)
1531
    957,  // 25: ED NOP (M:1 T:4 steps:1)
1532
    957,  // 26: ED NOP (M:1 T:4 steps:1)
1533
    957,  // 27: ED NOP (M:1 T:4 steps:1)
1534
    957,  // 28: ED NOP (M:1 T:4 steps:1)
1535
    957,  // 29: ED NOP (M:1 T:4 steps:1)
1536
    957,  // 2A: ED NOP (M:1 T:4 steps:1)
1537
    957,  // 2B: ED NOP (M:1 T:4 steps:1)
1538
    957,  // 2C: ED NOP (M:1 T:4 steps:1)
1539
    957,  // 2D: ED NOP (M:1 T:4 steps:1)
1540
    957,  // 2E: ED NOP (M:1 T:4 steps:1)
1541
    957,  // 2F: ED NOP (M:1 T:4 steps:1)
1542
    957,  // 30: ED NOP (M:1 T:4 steps:1)
1543
    957,  // 31: ED NOP (M:1 T:4 steps:1)
1544
    957,  // 32: ED NOP (M:1 T:4 steps:1)
1545
    957,  // 33: ED NOP (M:1 T:4 steps:1)
1546
    957,  // 34: ED NOP (M:1 T:4 steps:1)
1547
    957,  // 35: ED NOP (M:1 T:4 steps:1)
1548
    957,  // 36: ED NOP (M:1 T:4 steps:1)
1549
    957,  // 37: ED NOP (M:1 T:4 steps:1)
1550
    957,  // 38: ED NOP (M:1 T:4 steps:1)
1551
    957,  // 39: ED NOP (M:1 T:4 steps:1)
1552
    957,  // 3A: ED NOP (M:1 T:4 steps:1)
1553
    957,  // 3B: ED NOP (M:1 T:4 steps:1)
1554
    957,  // 3C: ED NOP (M:1 T:4 steps:1)
1555
    957,  // 3D: ED NOP (M:1 T:4 steps:1)
1556
    957,  // 3E: ED NOP (M:1 T:4 steps:1)
1557
    957,  // 3F: ED NOP (M:1 T:4 steps:1)
1558
    958,  // 40: IN B,(C) (M:2 T:8 steps:5)
1559
    963,  // 41: OUT (C),B (M:2 T:8 steps:5)
1560
    968,  // 42: SBC HL,BC (M:2 T:11 steps:8)
1561
    976,  // 43: LD (nn),BC (M:5 T:16 steps:13)
1562
    989,  // 44: NEG (M:1 T:4 steps:1)
1563
    990,  // 45: RETN (M:3 T:10 steps:7)
1564
    997,  // 46: IM 0 (M:1 T:4 steps:1)
1565
    998,  // 47: LD I,A (M:2 T:5 steps:2)
1566
    1000, // 48: IN C,(C) (M:2 T:8 steps:5)
1567
    1005, // 49: OUT (C),C (M:2 T:8 steps:5)
1568
    1010, // 4A: ADC HL,BC (M:2 T:11 steps:8)
1569
    1018, // 4B: LD BC,(nn) (M:5 T:16 steps:13)
1570
    989,  // 4C: NEG (M:1 T:4 steps:1)
1571
    1031, // 4D: RETI (M:3 T:10 steps:7)
1572
    1038, // 4E: IM 0 (M:1 T:4 steps:1)
1573
    1039, // 4F: LD R,A (M:2 T:5 steps:2)
1574
    1041, // 50: IN D,(C) (M:2 T:8 steps:5)
1575
    1046, // 51: OUT (C),D (M:2 T:8 steps:5)
1576
    1051, // 52: SBC HL,DE (M:2 T:11 steps:8)
1577
    1059, // 53: LD (nn),DE (M:5 T:16 steps:13)
1578
    989,  // 54: NEG (M:1 T:4 steps:1)
1579
    1031, // 55: RETI (M:3 T:10 steps:7)
1580
    1072, // 56: IM 1 (M:1 T:4 steps:1)
1581
    1073, // 57: LD A,I (M:2 T:5 steps:2)
1582
    1075, // 58: IN E,(C) (M:2 T:8 steps:5)
1583
    1080, // 59: OUT (C),E (M:2 T:8 steps:5)
1584
    1085, // 5A: ADC HL,DE (M:2 T:11 steps:8)
1585
    1093, // 5B: LD DE,(nn) (M:5 T:16 steps:13)
1586
    989,  // 5C: NEG (M:1 T:4 steps:1)
1587
    1031, // 5D: RETI (M:3 T:10 steps:7)
1588
    1106, // 5E: IM 2 (M:1 T:4 steps:1)
1589
    1107, // 5F: LD A,R (M:2 T:5 steps:2)
1590
    1109, // 60: IN H,(C) (M:2 T:8 steps:5)
1591
    1114, // 61: OUT (C),H (M:2 T:8 steps:5)
1592
    1119, // 62: SBC HL,HL (M:2 T:11 steps:8)
1593
    1127, // 63: LD (nn),HL (M:5 T:16 steps:13)
1594
    989,  // 64: NEG (M:1 T:4 steps:1)
1595
    1031, // 65: RETI (M:3 T:10 steps:7)
1596
    1140, // 66: IM 0 (M:1 T:4 steps:1)
1597
    1141, // 67: RRD (M:4 T:14 steps:11)
1598
    1152, // 68: IN L,(C) (M:2 T:8 steps:5)
1599
    1157, // 69: OUT (C),L (M:2 T:8 steps:5)
1600
    1162, // 6A: ADC HL,HL (M:2 T:11 steps:8)
1601
    1170, // 6B: LD HL,(nn) (M:5 T:16 steps:13)
1602
    989,  // 6C: NEG (M:1 T:4 steps:1)
1603
    1031, // 6D: RETI (M:3 T:10 steps:7)
1604
    1183, // 6E: IM 0 (M:1 T:4 steps:1)
1605
    1184, // 6F: RLD (M:4 T:14 steps:11)
1606
    1195, // 70: IN (C) (M:2 T:8 steps:5)
1607
    1200, // 71: OUT (C),0 (M:2 T:8 steps:5)
1608
    1205, // 72: SBC HL,SP (M:2 T:11 steps:8)
1609
    1213, // 73: LD (nn),SP (M:5 T:16 steps:13)
1610
    989,  // 74: NEG (M:1 T:4 steps:1)
1611
    1031, // 75: RETI (M:3 T:10 steps:7)
1612
    1226, // 76: IM 1 (M:1 T:4 steps:1)
1613
    957,  // 77: ED NOP (M:1 T:4 steps:1)
1614
    1227, // 78: IN A,(C) (M:2 T:8 steps:5)
1615
    1232, // 79: OUT (C),A (M:2 T:8 steps:5)
1616
    1237, // 7A: ADC HL,SP (M:2 T:11 steps:8)
1617
    1245, // 7B: LD SP,(nn) (M:5 T:16 steps:13)
1618
    989,  // 7C: NEG (M:1 T:4 steps:1)
1619
    1031, // 7D: RETI (M:3 T:10 steps:7)
1620
    1258, // 7E: IM 2 (M:1 T:4 steps:1)
1621
    957,  // 7F: ED NOP (M:1 T:4 steps:1)
1622
    957,  // 80: ED NOP (M:1 T:4 steps:1)
1623
    957,  // 81: ED NOP (M:1 T:4 steps:1)
1624
    957,  // 82: ED NOP (M:1 T:4 steps:1)
1625
    957,  // 83: ED NOP (M:1 T:4 steps:1)
1626
    957,  // 84: ED NOP (M:1 T:4 steps:1)
1627
    957,  // 85: ED NOP (M:1 T:4 steps:1)
1628
    957,  // 86: ED NOP (M:1 T:4 steps:1)
1629
    957,  // 87: ED NOP (M:1 T:4 steps:1)
1630
    957,  // 88: ED NOP (M:1 T:4 steps:1)
1631
    957,  // 89: ED NOP (M:1 T:4 steps:1)
1632
    957,  // 8A: ED NOP (M:1 T:4 steps:1)
1633
    957,  // 8B: ED NOP (M:1 T:4 steps:1)
1634
    957,  // 8C: ED NOP (M:1 T:4 steps:1)
1635
    957,  // 8D: ED NOP (M:1 T:4 steps:1)
1636
    957,  // 8E: ED NOP (M:1 T:4 steps:1)
1637
    957,  // 8F: ED NOP (M:1 T:4 steps:1)
1638
    957,  // 90: ED NOP (M:1 T:4 steps:1)
1639
    957,  // 91: ED NOP (M:1 T:4 steps:1)
1640
    957,  // 92: ED NOP (M:1 T:4 steps:1)
1641
    957,  // 93: ED NOP (M:1 T:4 steps:1)
1642
    957,  // 94: ED NOP (M:1 T:4 steps:1)
1643
    957,  // 95: ED NOP (M:1 T:4 steps:1)
1644
    957,  // 96: ED NOP (M:1 T:4 steps:1)
1645
    957,  // 97: ED NOP (M:1 T:4 steps:1)
1646
    957,  // 98: ED NOP (M:1 T:4 steps:1)
1647
    957,  // 99: ED NOP (M:1 T:4 steps:1)
1648
    957,  // 9A: ED NOP (M:1 T:4 steps:1)
1649
    957,  // 9B: ED NOP (M:1 T:4 steps:1)
1650
    957,  // 9C: ED NOP (M:1 T:4 steps:1)
1651
    957,  // 9D: ED NOP (M:1 T:4 steps:1)
1652
    957,  // 9E: ED NOP (M:1 T:4 steps:1)
1653
    957,  // 9F: ED NOP (M:1 T:4 steps:1)
1654
    1259, // A0: LDI (M:4 T:12 steps:9)
1655
    1268, // A1: CPI (M:3 T:12 steps:9)
1656
    1277, // A2: INI (M:4 T:12 steps:9)
1657
    1286, // A3: OUTI (M:4 T:12 steps:9)
1658
    957,  // A4: ED NOP (M:1 T:4 steps:1)
1659
    957,  // A5: ED NOP (M:1 T:4 steps:1)
1660
    957,  // A6: ED NOP (M:1 T:4 steps:1)
1661
    957,  // A7: ED NOP (M:1 T:4 steps:1)
1662
    1295, // A8: LDD (M:4 T:12 steps:9)
1663
    1304, // A9: CPD (M:3 T:12 steps:9)
1664
    1313, // AA: IND (M:4 T:12 steps:9)
1665
    1322, // AB: OUTD (M:4 T:12 steps:9)
1666
    957,  // AC: ED NOP (M:1 T:4 steps:1)
1667
    957,  // AD: ED NOP (M:1 T:4 steps:1)
1668
    957,  // AE: ED NOP (M:1 T:4 steps:1)
1669
    957,  // AF: ED NOP (M:1 T:4 steps:1)
1670
    1331, // B0: LDIR (M:5 T:17 steps:14)
1671
    1345, // B1: CPIR (M:4 T:17 steps:14)
1672
    1359, // B2: INIR (M:5 T:17 steps:14)
1673
    1373, // B3: OTIR (M:5 T:17 steps:14)
1674
    957,  // B4: ED NOP (M:1 T:4 steps:1)
1675
    957,  // B5: ED NOP (M:1 T:4 steps:1)
1676
    957,  // B6: ED NOP (M:1 T:4 steps:1)
1677
    957,  // B7: ED NOP (M:1 T:4 steps:1)
1678
    1387, // B8: LDDR (M:5 T:17 steps:14)
1679
    1401, // B9: CPDR (M:4 T:17 steps:14)
1680
    1415, // BA: INDR (M:5 T:17 steps:14)
1681
    1429, // BB: OTDR (M:5 T:17 steps:14)
1682
    957,  // BC: ED NOP (M:1 T:4 steps:1)
1683
    957,  // BD: ED NOP (M:1 T:4 steps:1)
1684
    957,  // BE: ED NOP (M:1 T:4 steps:1)
1685
    957,  // BF: ED NOP (M:1 T:4 steps:1)
1686
    957,  // C0: ED NOP (M:1 T:4 steps:1)
1687
    957,  // C1: ED NOP (M:1 T:4 steps:1)
1688
    957,  // C2: ED NOP (M:1 T:4 steps:1)
1689
    957,  // C3: ED NOP (M:1 T:4 steps:1)
1690
    957,  // C4: ED NOP (M:1 T:4 steps:1)
1691
    957,  // C5: ED NOP (M:1 T:4 steps:1)
1692
    957,  // C6: ED NOP (M:1 T:4 steps:1)
1693
    957,  // C7: ED NOP (M:1 T:4 steps:1)
1694
    957,  // C8: ED NOP (M:1 T:4 steps:1)
1695
    957,  // C9: ED NOP (M:1 T:4 steps:1)
1696
    957,  // CA: ED NOP (M:1 T:4 steps:1)
1697
    957,  // CB: ED NOP (M:1 T:4 steps:1)
1698
    957,  // CC: ED NOP (M:1 T:4 steps:1)
1699
    957,  // CD: ED NOP (M:1 T:4 steps:1)
1700
    957,  // CE: ED NOP (M:1 T:4 steps:1)
1701
    957,  // CF: ED NOP (M:1 T:4 steps:1)
1702
    957,  // D0: ED NOP (M:1 T:4 steps:1)
1703
    957,  // D1: ED NOP (M:1 T:4 steps:1)
1704
    957,  // D2: ED NOP (M:1 T:4 steps:1)
1705
    957,  // D3: ED NOP (M:1 T:4 steps:1)
1706
    957,  // D4: ED NOP (M:1 T:4 steps:1)
1707
    957,  // D5: ED NOP (M:1 T:4 steps:1)
1708
    957,  // D6: ED NOP (M:1 T:4 steps:1)
1709
    957,  // D7: ED NOP (M:1 T:4 steps:1)
1710
    957,  // D8: ED NOP (M:1 T:4 steps:1)
1711
    957,  // D9: ED NOP (M:1 T:4 steps:1)
1712
    957,  // DA: ED NOP (M:1 T:4 steps:1)
1713
    957,  // DB: ED NOP (M:1 T:4 steps:1)
1714
    957,  // DC: ED NOP (M:1 T:4 steps:1)
1715
    957,  // DD: ED NOP (M:1 T:4 steps:1)
1716
    957,  // DE: ED NOP (M:1 T:4 steps:1)
1717
    957,  // DF: ED NOP (M:1 T:4 steps:1)
1718
    957,  // E0: ED NOP (M:1 T:4 steps:1)
1719
    957,  // E1: ED NOP (M:1 T:4 steps:1)
1720
    957,  // E2: ED NOP (M:1 T:4 steps:1)
1721
    957,  // E3: ED NOP (M:1 T:4 steps:1)
1722
    957,  // E4: ED NOP (M:1 T:4 steps:1)
1723
    957,  // E5: ED NOP (M:1 T:4 steps:1)
1724
    957,  // E6: ED NOP (M:1 T:4 steps:1)
1725
    957,  // E7: ED NOP (M:1 T:4 steps:1)
1726
    957,  // E8: ED NOP (M:1 T:4 steps:1)
1727
    957,  // E9: ED NOP (M:1 T:4 steps:1)
1728
    957,  // EA: ED NOP (M:1 T:4 steps:1)
1729
    957,  // EB: ED NOP (M:1 T:4 steps:1)
1730
    957,  // EC: ED NOP (M:1 T:4 steps:1)
1731
    957,  // ED: ED NOP (M:1 T:4 steps:1)
1732
    957,  // EE: ED NOP (M:1 T:4 steps:1)
1733
    957,  // EF: ED NOP (M:1 T:4 steps:1)
1734
    957,  // F0: ED NOP (M:1 T:4 steps:1)
1735
    957,  // F1: ED NOP (M:1 T:4 steps:1)
1736
    957,  // F2: ED NOP (M:1 T:4 steps:1)
1737
    957,  // F3: ED NOP (M:1 T:4 steps:1)
1738
    957,  // F4: ED NOP (M:1 T:4 steps:1)
1739
    957,  // F5: ED NOP (M:1 T:4 steps:1)
1740
    957,  // F6: ED NOP (M:1 T:4 steps:1)
1741
    957,  // F7: ED NOP (M:1 T:4 steps:1)
1742
    957,  // F8: ED NOP (M:1 T:4 steps:1)
1743
    957,  // F9: ED NOP (M:1 T:4 steps:1)
1744
    957,  // FA: ED NOP (M:1 T:4 steps:1)
1745
    957,  // FB: ED NOP (M:1 T:4 steps:1)
1746
    957,  // FC: ED NOP (M:1 T:4 steps:1)
1747
    957,  // FD: ED NOP (M:1 T:4 steps:1)
1748
    957,  // FE: ED NOP (M:1 T:4 steps:1)
1749
    957,  // FF: ED NOP (M:1 T:4 steps:1)
1750
};
1751
 
1752
static const uint16_t _z80_special_optable[_Z80_OPSTATE_NUM_SPECIAL_OPS] = {
1753
    1443, // 00: cb (M:1 T:4 steps:1)
1754
    1444, // 01: cbhl (M:3 T:11 steps:8)
1755
    1452, // 02: ddfdcb (M:6 T:18 steps:15)
1756
    1467, // 03: int_im0 (M:6 T:9 steps:6)
1757
    1473, // 04: int_im1 (M:7 T:16 steps:13)
1758
    1486, // 05: int_im2 (M:9 T:22 steps:19)
1759
    1505, // 06: nmi (M:5 T:14 steps:11)
1760
};
1761
 
1762
// initiate refresh cycle
1763
static inline uint64_t _z80_refresh(z80_t* cpu, uint64_t pins) {
1764
	pins = _z80_set_ab_x(pins, cpu->ir, Z80_MREQ | Z80_RFSH);
1765
	cpu->r = (cpu->r & 0x80) | ((cpu->r + 1) & 0x7F);
1766
	return pins;
1767
}
1768
 
1769
// initiate a fetch machine cycle for regular (non-prefixed) instructions, or initiate interrupt handling
1770
static inline uint64_t _z80_fetch(z80_t* cpu, uint64_t pins) {
1771
	cpu->hlx_idx = 0;
1772
	cpu->prefix_active = false;
1773
	// shortcut no interrupts requested
1774
	if(cpu->int_bits == 0) {
1775
		cpu->step = 0xFFFF;
1776
		return _z80_set_ab_x(pins, cpu->pc++, Z80_M1 | Z80_MREQ | Z80_RD);
1777
	} else if(cpu->int_bits & Z80_NMI) {
1778
		// non-maskable interrupt starts with a regular M1 machine cycle
1779
		cpu->step = _z80_special_optable[_Z80_OPSTATE_SLOT_NMI];
1780
		cpu->int_bits = 0;
1781
		if(pins & Z80_HALT) {
1782
			pins &= ~Z80_HALT;
1783
			cpu->pc++;
1784
		}
1785
		// NOTE: PC is *not* incremented!
1786
		return _z80_set_ab_x(pins, cpu->pc, Z80_M1 | Z80_MREQ | Z80_RD);
1787
	} else if(cpu->int_bits & Z80_INT) {
1788
		if(cpu->iff1) {
1789
			// maskable interrupts start with a special M1 machine cycle which
1790
			// doesn't fetch the next opcode, but instead activate the
1791
			// pins M1|IOQR to request a special byte which is handled differently
1792
			// depending on interrupt mode
1793
			cpu->step = _z80_special_optable[_Z80_OPSTATE_SLOT_INT_IM0 + cpu->im];
1794
			cpu->int_bits = 0;
1795
			if(pins & Z80_HALT) {
1796
				pins &= ~Z80_HALT;
1797
				cpu->pc++;
1798
			}
1799
			// NOTE: PC is not incremented, and no pins are activated here
1800
			return pins;
1801
		} else {
1802
			// oops, maskable interrupt requested but disabled
1803
			cpu->step = 0xFFFF;
1804
			return _z80_set_ab_x(pins, cpu->pc++, Z80_M1 | Z80_MREQ | Z80_RD);
1805
		}
1806
	} else {
1807
		_Z80_UNREACHABLE;
1808
		return pins;
1809
	}
1810
}
1811
 
1812
static inline uint64_t _z80_fetch_cb(z80_t* cpu, uint64_t pins) {
1813
	cpu->prefix_active = true;
1814
	if(cpu->hlx_idx > 0) {
1815
		// this is a DD+CB / FD+CB instruction, continue
1816
		// execution on the special DDCB/FDCB decoder block which
1817
		// loads the d-offset first and then the opcode in a
1818
		// regular memory read machine cycle
1819
		cpu->step = _z80_special_optable[_Z80_OPSTATE_SLOT_DDFDCB];
1820
	} else {
1821
		// this is a regular CB-prefixed instruction, continue
1822
		// execution on a special fetch machine cycle which doesn't
1823
		// handle DD/FD prefix and then branches either to the
1824
		// special CB or CBHL decoder block
1825
		cpu->step = 21; // => step 22: opcode fetch for CB prefixed instructions
1826
		pins = _z80_set_ab_x(pins, cpu->pc++, Z80_M1 | Z80_MREQ | Z80_RD);
1827
	}
1828
	return pins;
1829
}
1830
 
1831
static inline uint64_t _z80_fetch_dd(z80_t* cpu, uint64_t pins) {
1832
	cpu->step = 2; // => step 3: opcode fetch for DD/FD prefixed instructions
1833
	cpu->hlx_idx = 1;
1834
	cpu->prefix_active = true;
1835
	return _z80_set_ab_x(pins, cpu->pc++, Z80_M1 | Z80_MREQ | Z80_RD);
1836
}
1837
 
1838
static inline uint64_t _z80_fetch_fd(z80_t* cpu, uint64_t pins) {
1839
	cpu->step = 2; // => step 3: opcode fetch for DD/FD prefixed instructions
1840
	cpu->hlx_idx = 2;
1841
	cpu->prefix_active = true;
1842
	return _z80_set_ab_x(pins, cpu->pc++, Z80_M1 | Z80_MREQ | Z80_RD);
1843
}
1844
 
1845
static inline uint64_t _z80_fetch_ed(z80_t* cpu, uint64_t pins) {
1846
	cpu->step = 24; // => step 25: opcode fetch for ED prefixed instructions
1847
	cpu->hlx_idx = 0;
1848
	cpu->prefix_active = true;
1849
	return _z80_set_ab_x(pins, cpu->pc++, Z80_M1 | Z80_MREQ | Z80_RD);
1850
}
1851
 
1852
uint64_t z80_prefetch(z80_t* cpu, uint16_t new_pc) {
1853
	cpu->pc = new_pc;
1854
	// overlapped M1:T1 of the NOP instruction to initiate opcode fetch at new pc
1855
	cpu->step = _z80_optable[0] + 1;
1856
	return 0;
1857
}
1858
 
1859
// pin helper macros
1860
#define _sa(ab) pins = _z80_set_ab(pins, ab)
1861
#define _sax(ab, x) pins = _z80_set_ab_x(pins, ab, x)
1862
#define _sad(ab, d) pins = _z80_set_ab_db(pins, ab, d)
1863
#define _sadx(ab, d, x) pins = _z80_set_ab_db_x(pins, ab, d, x)
1864
#define _gd() _z80_get_db(pins)
1865
 
1866
// high level helper macros
1867
#define _skip(n) cpu->step += (n);
1868
#define _fetch_dd() pins = _z80_fetch_dd(cpu, pins);
1869
#define _fetch_fd() pins = _z80_fetch_fd(cpu, pins);
1870
#define _fetch_ed() pins = _z80_fetch_ed(cpu, pins);
1871
#define _fetch_cb() pins = _z80_fetch_cb(cpu, pins);
1872
#define _mread(ab) _sax(ab, Z80_MREQ | Z80_RD)
1873
#define _mwrite(ab, d) _sadx(ab, d, Z80_MREQ | Z80_WR)
1874
#define _ioread(ab) _sax(ab, Z80_IORQ | Z80_RD)
1875
#define _iowrite(ab, d) _sadx(ab, d, Z80_IORQ | Z80_WR)
1876
#define _wait() \
1877
	{ \
1878
		if(pins & Z80_WAIT) goto track_int_bits; \
1879
	}
1880
#define _cc_nz (!(cpu->f & Z80_ZF))
1881
#define _cc_z (cpu->f & Z80_ZF)
1882
#define _cc_nc (!(cpu->f & Z80_CF))
1883
#define _cc_c (cpu->f & Z80_CF)
1884
#define _cc_po (!(cpu->f & Z80_PF))
1885
#define _cc_pe (cpu->f & Z80_PF)
1886
#define _cc_p (!(cpu->f & Z80_SF))
1887
#define _cc_m (cpu->f & Z80_SF)
1888
 
1889
uint64_t z80_tick(z80_t* cpu, uint64_t pins) {
1890
	pins &= ~(Z80_CTRL_PIN_MASK | Z80_RETI);
1891
	switch(cpu->step) {
1892
	//=== shared fetch machine cycle for non-DD/FD-prefixed ops
1893
	// M1/T2: load opcode from data bus
1894
	case 0:
1895
		_wait();
1896
		cpu->opcode = _gd();
1897
		goto step_next;
1898
	// M1/T3: refresh cycle
1899
	case 1:
1900
		pins = _z80_refresh(cpu, pins);
1901
		goto step_next;
1902
	// M1/T4: branch to instruction 'payload'
1903
	case 2: {
1904
		cpu->step = _z80_optable[cpu->opcode];
1905
		// preload effective address for (HL) ops
1906
		cpu->addr = cpu->hl;
1907
	}
1908
		goto step_next;
1909
	//=== shared fetch machine cycle for DD/FD-prefixed ops
1910
	// M1/T2: load opcode from data bus
1911
	case 3:
1912
		_wait();
1913
		cpu->opcode = _gd();
1914
		goto step_next;
1915
	// M1/T3: refresh cycle
1916
	case 4:
1917
		pins = _z80_refresh(cpu, pins);
1918
		goto step_next;
1919
	// M1/T4: branch to instruction 'payload'
1920
	case 5: {
1921
		cpu->step = _z80_ddfd_optable[cpu->opcode];
1922
		cpu->addr = cpu->hlx[cpu->hlx_idx].hl;
1923
	}
1924
		goto step_next;
1925
	//=== optional d-loading cycle for (IX+d), (IY+d)
1926
	//--- mread
1927
	case 6:
1928
		goto step_next;
1929
	case 7:
1930
		_wait();
1931
		_mread(cpu->pc++);
1932
		goto step_next;
1933
	case 8:
1934
		cpu->addr += (int8_t)_gd();
1935
		cpu->wz = cpu->addr;
1936
		goto step_next;
1937
	//--- filler ticks
1938
	case 9:
1939
		goto step_next;
1940
	case 10:
1941
		goto step_next;
1942
	case 11:
1943
		goto step_next;
1944
	case 12:
1945
		goto step_next;
1946
	case 13: {
1947
		// branch to actual instruction
1948
		cpu->step = _z80_optable[cpu->opcode];
1949
	}
1950
		goto step_next;
1951
	//=== special case d-loading cycle for (IX+d),n where the immediate load
1952
	//    is hidden in the d-cycle load
1953
	//--- mread for d offset
1954
	case 14:
1955
		goto step_next;
1956
	case 15:
1957
		_wait();
1958
		_mread(cpu->pc++);
1959
		goto step_next;
1960
	case 16:
1961
		cpu->addr += (int8_t)_gd();
1962
		cpu->wz = cpu->addr;
1963
		goto step_next;
1964
	//--- mread for n
1965
	case 17:
1966
		goto step_next;
1967
	case 18:
1968
		_wait();
1969
		_mread(cpu->pc++);
1970
		goto step_next;
1971
	case 19:
1972
		cpu->dlatch = _gd();
1973
		goto step_next;
1974
	//--- filler tick
1975
	case 20:
1976
		goto step_next;
1977
	case 21: {
1978
		// branch to ld (hl),n and skip the original mread cycle for loading 'n'
1979
		cpu->step = _z80_optable[cpu->opcode] + 3;
1980
	}
1981
		goto step_next;
1982
	//=== special opcode fetch machine cycle for CB-prefixed instructions
1983
	case 22:
1984
		_wait();
1985
		cpu->opcode = _gd();
1986
		goto step_next;
1987
	case 23:
1988
		pins = _z80_refresh(cpu, pins);
1989
		goto step_next;
1990
	case 24: {
1991
		if((cpu->opcode & 7) == 6) {
1992
			// this is a (HL) instruction
1993
			cpu->addr = cpu->hl;
1994
			cpu->step = _z80_special_optable[_Z80_OPSTATE_SLOT_CBHL];
1995
		} else {
1996
			cpu->step = _z80_special_optable[_Z80_OPSTATE_SLOT_CB];
1997
		}
1998
	}
1999
		goto step_next;
2000
	//=== special opcode fetch machine cycle for ED-prefixed instructions
2001
	// M1/T2: load opcode from data bus
2002
	case 25:
2003
		_wait();
2004
		cpu->opcode = _gd();
2005
		goto step_next;
2006
	// M1/T3: refresh cycle
2007
	case 26:
2008
		pins = _z80_refresh(cpu, pins);
2009
		goto step_next;
2010
	// M1/T4: branch to instruction 'payload'
2011
	case 27:
2012
		cpu->step = _z80_ed_optable[cpu->opcode];
2013
		goto step_next;
2014
	//=== from here on code-generated
2015
 
2016
	//  00: NOP (M:1 T:4)
2017
	// -- overlapped
2018
	case 28:
2019
		goto fetch_next;
2020
 
2021
	//  01: LD BC,nn (M:3 T:10)
2022
	// -- mread
2023
	case 29:
2024
		goto step_next;
2025
	case 30:
2026
		_wait();
2027
		_mread(cpu->pc++);
2028
		goto step_next;
2029
	case 31:
2030
		cpu->c = _gd();
2031
		goto step_next;
2032
	// -- mread
2033
	case 32:
2034
		goto step_next;
2035
	case 33:
2036
		_wait();
2037
		_mread(cpu->pc++);
2038
		goto step_next;
2039
	case 34:
2040
		cpu->b = _gd();
2041
		goto step_next;
2042
	// -- overlapped
2043
	case 35:
2044
		goto fetch_next;
2045
 
2046
	//  02: LD (BC),A (M:2 T:7)
2047
	// -- mwrite
2048
	case 36:
2049
		goto step_next;
2050
	case 37:
2051
		_wait();
2052
		_mwrite(cpu->bc, cpu->a);
2053
		cpu->wzl = cpu->c + 1;
2054
		cpu->wzh = cpu->a;
2055
		goto step_next;
2056
	case 38:
2057
		goto step_next;
2058
	// -- overlapped
2059
	case 39:
2060
		goto fetch_next;
2061
 
2062
	//  03: INC BC (M:2 T:6)
2063
	// -- generic
2064
	case 40:
2065
		cpu->bc++;
2066
		goto step_next;
2067
	case 41:
2068
		goto step_next;
2069
	// -- overlapped
2070
	case 42:
2071
		goto fetch_next;
2072
 
2073
	//  04: INC B (M:1 T:4)
2074
	// -- overlapped
2075
	case 43:
2076
		cpu->b = _z80_inc8(cpu, cpu->b);
2077
		goto fetch_next;
2078
 
2079
	//  05: DEC B (M:1 T:4)
2080
	// -- overlapped
2081
	case 44:
2082
		cpu->b = _z80_dec8(cpu, cpu->b);
2083
		goto fetch_next;
2084
 
2085
	//  06: LD B,n (M:2 T:7)
2086
	// -- mread
2087
	case 45:
2088
		goto step_next;
2089
	case 46:
2090
		_wait();
2091
		_mread(cpu->pc++);
2092
		goto step_next;
2093
	case 47:
2094
		cpu->b = _gd();
2095
		goto step_next;
2096
	// -- overlapped
2097
	case 48:
2098
		goto fetch_next;
2099
 
2100
	//  07: RLCA (M:1 T:4)
2101
	// -- overlapped
2102
	case 49:
2103
		_z80_rlca(cpu);
2104
		goto fetch_next;
2105
 
2106
	//  08: EX AF,AF' (M:1 T:4)
2107
	// -- overlapped
2108
	case 50:
2109
		_z80_ex_af_af2(cpu);
2110
		goto fetch_next;
2111
 
2112
	//  09: ADD HL,BC (M:2 T:11)
2113
	// -- generic
2114
	case 51:
2115
		_z80_add16(cpu, cpu->bc);
2116
		goto step_next;
2117
	case 52:
2118
		goto step_next;
2119
	case 53:
2120
		goto step_next;
2121
	case 54:
2122
		goto step_next;
2123
	case 55:
2124
		goto step_next;
2125
	case 56:
2126
		goto step_next;
2127
	case 57:
2128
		goto step_next;
2129
	// -- overlapped
2130
	case 58:
2131
		goto fetch_next;
2132
 
2133
	//  0A: LD A,(BC) (M:2 T:7)
2134
	// -- mread
2135
	case 59:
2136
		goto step_next;
2137
	case 60:
2138
		_wait();
2139
		_mread(cpu->bc);
2140
		goto step_next;
2141
	case 61:
2142
		cpu->a = _gd();
2143
		cpu->wz = cpu->bc + 1;
2144
		goto step_next;
2145
	// -- overlapped
2146
	case 62:
2147
		goto fetch_next;
2148
 
2149
	//  0B: DEC BC (M:2 T:6)
2150
	// -- generic
2151
	case 63:
2152
		cpu->bc--;
2153
		goto step_next;
2154
	case 64:
2155
		goto step_next;
2156
	// -- overlapped
2157
	case 65:
2158
		goto fetch_next;
2159
 
2160
	//  0C: INC C (M:1 T:4)
2161
	// -- overlapped
2162
	case 66:
2163
		cpu->c = _z80_inc8(cpu, cpu->c);
2164
		goto fetch_next;
2165
 
2166
	//  0D: DEC C (M:1 T:4)
2167
	// -- overlapped
2168
	case 67:
2169
		cpu->c = _z80_dec8(cpu, cpu->c);
2170
		goto fetch_next;
2171
 
2172
	//  0E: LD C,n (M:2 T:7)
2173
	// -- mread
2174
	case 68:
2175
		goto step_next;
2176
	case 69:
2177
		_wait();
2178
		_mread(cpu->pc++);
2179
		goto step_next;
2180
	case 70:
2181
		cpu->c = _gd();
2182
		goto step_next;
2183
	// -- overlapped
2184
	case 71:
2185
		goto fetch_next;
2186
 
2187
	//  0F: RRCA (M:1 T:4)
2188
	// -- overlapped
2189
	case 72:
2190
		_z80_rrca(cpu);
2191
		goto fetch_next;
2192
 
2193
	//  10: DJNZ d (M:4 T:13)
2194
	// -- generic
2195
	case 73:
2196
		goto step_next;
2197
	// -- mread
2198
	case 74:
2199
		goto step_next;
2200
	case 75:
2201
		_wait();
2202
		_mread(cpu->pc++);
2203
		goto step_next;
2204
	case 76:
2205
		cpu->dlatch = _gd();
2206
		if(--cpu->b == 0) {
2207
			_skip(5);
2208
		};
2209
		goto step_next;
2210
	// -- generic
2211
	case 77:
2212
		cpu->pc += (int8_t)cpu->dlatch;
2213
		cpu->wz = cpu->pc;
2214
		goto step_next;
2215
	case 78:
2216
		goto step_next;
2217
	case 79:
2218
		goto step_next;
2219
	case 80:
2220
		goto step_next;
2221
	case 81:
2222
		goto step_next;
2223
	// -- overlapped
2224
	case 82:
2225
		goto fetch_next;
2226
 
2227
	//  11: LD DE,nn (M:3 T:10)
2228
	// -- mread
2229
	case 83:
2230
		goto step_next;
2231
	case 84:
2232
		_wait();
2233
		_mread(cpu->pc++);
2234
		goto step_next;
2235
	case 85:
2236
		cpu->e = _gd();
2237
		goto step_next;
2238
	// -- mread
2239
	case 86:
2240
		goto step_next;
2241
	case 87:
2242
		_wait();
2243
		_mread(cpu->pc++);
2244
		goto step_next;
2245
	case 88:
2246
		cpu->d = _gd();
2247
		goto step_next;
2248
	// -- overlapped
2249
	case 89:
2250
		goto fetch_next;
2251
 
2252
	//  12: LD (DE),A (M:2 T:7)
2253
	// -- mwrite
2254
	case 90:
2255
		goto step_next;
2256
	case 91:
2257
		_wait();
2258
		_mwrite(cpu->de, cpu->a);
2259
		cpu->wzl = cpu->e + 1;
2260
		cpu->wzh = cpu->a;
2261
		goto step_next;
2262
	case 92:
2263
		goto step_next;
2264
	// -- overlapped
2265
	case 93:
2266
		goto fetch_next;
2267
 
2268
	//  13: INC DE (M:2 T:6)
2269
	// -- generic
2270
	case 94:
2271
		cpu->de++;
2272
		goto step_next;
2273
	case 95:
2274
		goto step_next;
2275
	// -- overlapped
2276
	case 96:
2277
		goto fetch_next;
2278
 
2279
	//  14: INC D (M:1 T:4)
2280
	// -- overlapped
2281
	case 97:
2282
		cpu->d = _z80_inc8(cpu, cpu->d);
2283
		goto fetch_next;
2284
 
2285
	//  15: DEC D (M:1 T:4)
2286
	// -- overlapped
2287
	case 98:
2288
		cpu->d = _z80_dec8(cpu, cpu->d);
2289
		goto fetch_next;
2290
 
2291
	//  16: LD D,n (M:2 T:7)
2292
	// -- mread
2293
	case 99:
2294
		goto step_next;
2295
	case 100:
2296
		_wait();
2297
		_mread(cpu->pc++);
2298
		goto step_next;
2299
	case 101:
2300
		cpu->d = _gd();
2301
		goto step_next;
2302
	// -- overlapped
2303
	case 102:
2304
		goto fetch_next;
2305
 
2306
	//  17: RLA (M:1 T:4)
2307
	// -- overlapped
2308
	case 103:
2309
		_z80_rla(cpu);
2310
		goto fetch_next;
2311
 
2312
	//  18: JR d (M:3 T:12)
2313
	// -- mread
2314
	case 104:
2315
		goto step_next;
2316
	case 105:
2317
		_wait();
2318
		_mread(cpu->pc++);
2319
		goto step_next;
2320
	case 106:
2321
		cpu->dlatch = _gd();
2322
		goto step_next;
2323
	// -- generic
2324
	case 107:
2325
		cpu->pc += (int8_t)cpu->dlatch;
2326
		cpu->wz = cpu->pc;
2327
		goto step_next;
2328
	case 108:
2329
		goto step_next;
2330
	case 109:
2331
		goto step_next;
2332
	case 110:
2333
		goto step_next;
2334
	case 111:
2335
		goto step_next;
2336
	// -- overlapped
2337
	case 112:
2338
		goto fetch_next;
2339
 
2340
	//  19: ADD HL,DE (M:2 T:11)
2341
	// -- generic
2342
	case 113:
2343
		_z80_add16(cpu, cpu->de);
2344
		goto step_next;
2345
	case 114:
2346
		goto step_next;
2347
	case 115:
2348
		goto step_next;
2349
	case 116:
2350
		goto step_next;
2351
	case 117:
2352
		goto step_next;
2353
	case 118:
2354
		goto step_next;
2355
	case 119:
2356
		goto step_next;
2357
	// -- overlapped
2358
	case 120:
2359
		goto fetch_next;
2360
 
2361
	//  1A: LD A,(DE) (M:2 T:7)
2362
	// -- mread
2363
	case 121:
2364
		goto step_next;
2365
	case 122:
2366
		_wait();
2367
		_mread(cpu->de);
2368
		goto step_next;
2369
	case 123:
2370
		cpu->a = _gd();
2371
		cpu->wz = cpu->de + 1;
2372
		goto step_next;
2373
	// -- overlapped
2374
	case 124:
2375
		goto fetch_next;
2376
 
2377
	//  1B: DEC DE (M:2 T:6)
2378
	// -- generic
2379
	case 125:
2380
		cpu->de--;
2381
		goto step_next;
2382
	case 126:
2383
		goto step_next;
2384
	// -- overlapped
2385
	case 127:
2386
		goto fetch_next;
2387
 
2388
	//  1C: INC E (M:1 T:4)
2389
	// -- overlapped
2390
	case 128:
2391
		cpu->e = _z80_inc8(cpu, cpu->e);
2392
		goto fetch_next;
2393
 
2394
	//  1D: DEC E (M:1 T:4)
2395
	// -- overlapped
2396
	case 129:
2397
		cpu->e = _z80_dec8(cpu, cpu->e);
2398
		goto fetch_next;
2399
 
2400
	//  1E: LD E,n (M:2 T:7)
2401
	// -- mread
2402
	case 130:
2403
		goto step_next;
2404
	case 131:
2405
		_wait();
2406
		_mread(cpu->pc++);
2407
		goto step_next;
2408
	case 132:
2409
		cpu->e = _gd();
2410
		goto step_next;
2411
	// -- overlapped
2412
	case 133:
2413
		goto fetch_next;
2414
 
2415
	//  1F: RRA (M:1 T:4)
2416
	// -- overlapped
2417
	case 134:
2418
		_z80_rra(cpu);
2419
		goto fetch_next;
2420
 
2421
	//  20: JR NZ,d (M:3 T:12)
2422
	// -- mread
2423
	case 135:
2424
		goto step_next;
2425
	case 136:
2426
		_wait();
2427
		_mread(cpu->pc++);
2428
		goto step_next;
2429
	case 137:
2430
		cpu->dlatch = _gd();
2431
		if(!(_cc_nz)) {
2432
			_skip(5);
2433
		};
2434
		goto step_next;
2435
	// -- generic
2436
	case 138:
2437
		cpu->pc += (int8_t)cpu->dlatch;
2438
		cpu->wz = cpu->pc;
2439
		goto step_next;
2440
	case 139:
2441
		goto step_next;
2442
	case 140:
2443
		goto step_next;
2444
	case 141:
2445
		goto step_next;
2446
	case 142:
2447
		goto step_next;
2448
	// -- overlapped
2449
	case 143:
2450
		goto fetch_next;
2451
 
2452
	//  21: LD HL,nn (M:3 T:10)
2453
	// -- mread
2454
	case 144:
2455
		goto step_next;
2456
	case 145:
2457
		_wait();
2458
		_mread(cpu->pc++);
2459
		goto step_next;
2460
	case 146:
2461
		cpu->hlx[cpu->hlx_idx].l = _gd();
2462
		goto step_next;
2463
	// -- mread
2464
	case 147:
2465
		goto step_next;
2466
	case 148:
2467
		_wait();
2468
		_mread(cpu->pc++);
2469
		goto step_next;
2470
	case 149:
2471
		cpu->hlx[cpu->hlx_idx].h = _gd();
2472
		goto step_next;
2473
	// -- overlapped
2474
	case 150:
2475
		goto fetch_next;
2476
 
2477
	//  22: LD (nn),HL (M:5 T:16)
2478
	// -- mread
2479
	case 151:
2480
		goto step_next;
2481
	case 152:
2482
		_wait();
2483
		_mread(cpu->pc++);
2484
		goto step_next;
2485
	case 153:
2486
		cpu->wzl = _gd();
2487
		goto step_next;
2488
	// -- mread
2489
	case 154:
2490
		goto step_next;
2491
	case 155:
2492
		_wait();
2493
		_mread(cpu->pc++);
2494
		goto step_next;
2495
	case 156:
2496
		cpu->wzh = _gd();
2497
		goto step_next;
2498
	// -- mwrite
2499
	case 157:
2500
		goto step_next;
2501
	case 158:
2502
		_wait();
2503
		_mwrite(cpu->wz++, cpu->hlx[cpu->hlx_idx].l);
2504
		goto step_next;
2505
	case 159:
2506
		goto step_next;
2507
	// -- mwrite
2508
	case 160:
2509
		goto step_next;
2510
	case 161:
2511
		_wait();
2512
		_mwrite(cpu->wz, cpu->hlx[cpu->hlx_idx].h);
2513
		goto step_next;
2514
	case 162:
2515
		goto step_next;
2516
	// -- overlapped
2517
	case 163:
2518
		goto fetch_next;
2519
 
2520
	//  23: INC HL (M:2 T:6)
2521
	// -- generic
2522
	case 164:
2523
		cpu->hlx[cpu->hlx_idx].hl++;
2524
		goto step_next;
2525
	case 165:
2526
		goto step_next;
2527
	// -- overlapped
2528
	case 166:
2529
		goto fetch_next;
2530
 
2531
	//  24: INC H (M:1 T:4)
2532
	// -- overlapped
2533
	case 167:
2534
		cpu->hlx[cpu->hlx_idx].h = _z80_inc8(cpu, cpu->hlx[cpu->hlx_idx].h);
2535
		goto fetch_next;
2536
 
2537
	//  25: DEC H (M:1 T:4)
2538
	// -- overlapped
2539
	case 168:
2540
		cpu->hlx[cpu->hlx_idx].h = _z80_dec8(cpu, cpu->hlx[cpu->hlx_idx].h);
2541
		goto fetch_next;
2542
 
2543
	//  26: LD H,n (M:2 T:7)
2544
	// -- mread
2545
	case 169:
2546
		goto step_next;
2547
	case 170:
2548
		_wait();
2549
		_mread(cpu->pc++);
2550
		goto step_next;
2551
	case 171:
2552
		cpu->hlx[cpu->hlx_idx].h = _gd();
2553
		goto step_next;
2554
	// -- overlapped
2555
	case 172:
2556
		goto fetch_next;
2557
 
2558
	//  27: DAA (M:1 T:4)
2559
	// -- overlapped
2560
	case 173:
2561
		_z80_daa(cpu);
2562
		goto fetch_next;
2563
 
2564
	//  28: JR Z,d (M:3 T:12)
2565
	// -- mread
2566
	case 174:
2567
		goto step_next;
2568
	case 175:
2569
		_wait();
2570
		_mread(cpu->pc++);
2571
		goto step_next;
2572
	case 176:
2573
		cpu->dlatch = _gd();
2574
		if(!(_cc_z)) {
2575
			_skip(5);
2576
		};
2577
		goto step_next;
2578
	// -- generic
2579
	case 177:
2580
		cpu->pc += (int8_t)cpu->dlatch;
2581
		cpu->wz = cpu->pc;
2582
		goto step_next;
2583
	case 178:
2584
		goto step_next;
2585
	case 179:
2586
		goto step_next;
2587
	case 180:
2588
		goto step_next;
2589
	case 181:
2590
		goto step_next;
2591
	// -- overlapped
2592
	case 182:
2593
		goto fetch_next;
2594
 
2595
	//  29: ADD HL,HL (M:2 T:11)
2596
	// -- generic
2597
	case 183:
2598
		_z80_add16(cpu, cpu->hlx[cpu->hlx_idx].hl);
2599
		goto step_next;
2600
	case 184:
2601
		goto step_next;
2602
	case 185:
2603
		goto step_next;
2604
	case 186:
2605
		goto step_next;
2606
	case 187:
2607
		goto step_next;
2608
	case 188:
2609
		goto step_next;
2610
	case 189:
2611
		goto step_next;
2612
	// -- overlapped
2613
	case 190:
2614
		goto fetch_next;
2615
 
2616
	//  2A: LD HL,(nn) (M:5 T:16)
2617
	// -- mread
2618
	case 191:
2619
		goto step_next;
2620
	case 192:
2621
		_wait();
2622
		_mread(cpu->pc++);
2623
		goto step_next;
2624
	case 193:
2625
		cpu->wzl = _gd();
2626
		goto step_next;
2627
	// -- mread
2628
	case 194:
2629
		goto step_next;
2630
	case 195:
2631
		_wait();
2632
		_mread(cpu->pc++);
2633
		goto step_next;
2634
	case 196:
2635
		cpu->wzh = _gd();
2636
		goto step_next;
2637
	// -- mread
2638
	case 197:
2639
		goto step_next;
2640
	case 198:
2641
		_wait();
2642
		_mread(cpu->wz++);
2643
		goto step_next;
2644
	case 199:
2645
		cpu->hlx[cpu->hlx_idx].l = _gd();
2646
		goto step_next;
2647
	// -- mread
2648
	case 200:
2649
		goto step_next;
2650
	case 201:
2651
		_wait();
2652
		_mread(cpu->wz);
2653
		goto step_next;
2654
	case 202:
2655
		cpu->hlx[cpu->hlx_idx].h = _gd();
2656
		goto step_next;
2657
	// -- overlapped
2658
	case 203:
2659
		goto fetch_next;
2660
 
2661
	//  2B: DEC HL (M:2 T:6)
2662
	// -- generic
2663
	case 204:
2664
		cpu->hlx[cpu->hlx_idx].hl--;
2665
		goto step_next;
2666
	case 205:
2667
		goto step_next;
2668
	// -- overlapped
2669
	case 206:
2670
		goto fetch_next;
2671
 
2672
	//  2C: INC L (M:1 T:4)
2673
	// -- overlapped
2674
	case 207:
2675
		cpu->hlx[cpu->hlx_idx].l = _z80_inc8(cpu, cpu->hlx[cpu->hlx_idx].l);
2676
		goto fetch_next;
2677
 
2678
	//  2D: DEC L (M:1 T:4)
2679
	// -- overlapped
2680
	case 208:
2681
		cpu->hlx[cpu->hlx_idx].l = _z80_dec8(cpu, cpu->hlx[cpu->hlx_idx].l);
2682
		goto fetch_next;
2683
 
2684
	//  2E: LD L,n (M:2 T:7)
2685
	// -- mread
2686
	case 209:
2687
		goto step_next;
2688
	case 210:
2689
		_wait();
2690
		_mread(cpu->pc++);
2691
		goto step_next;
2692
	case 211:
2693
		cpu->hlx[cpu->hlx_idx].l = _gd();
2694
		goto step_next;
2695
	// -- overlapped
2696
	case 212:
2697
		goto fetch_next;
2698
 
2699
	//  2F: CPL (M:1 T:4)
2700
	// -- overlapped
2701
	case 213:
2702
		_z80_cpl(cpu);
2703
		goto fetch_next;
2704
 
2705
	//  30: JR NC,d (M:3 T:12)
2706
	// -- mread
2707
	case 214:
2708
		goto step_next;
2709
	case 215:
2710
		_wait();
2711
		_mread(cpu->pc++);
2712
		goto step_next;
2713
	case 216:
2714
		cpu->dlatch = _gd();
2715
		if(!(_cc_nc)) {
2716
			_skip(5);
2717
		};
2718
		goto step_next;
2719
	// -- generic
2720
	case 217:
2721
		cpu->pc += (int8_t)cpu->dlatch;
2722
		cpu->wz = cpu->pc;
2723
		goto step_next;
2724
	case 218:
2725
		goto step_next;
2726
	case 219:
2727
		goto step_next;
2728
	case 220:
2729
		goto step_next;
2730
	case 221:
2731
		goto step_next;
2732
	// -- overlapped
2733
	case 222:
2734
		goto fetch_next;
2735
 
2736
	//  31: LD SP,nn (M:3 T:10)
2737
	// -- mread
2738
	case 223:
2739
		goto step_next;
2740
	case 224:
2741
		_wait();
2742
		_mread(cpu->pc++);
2743
		goto step_next;
2744
	case 225:
2745
		cpu->spl = _gd();
2746
		goto step_next;
2747
	// -- mread
2748
	case 226:
2749
		goto step_next;
2750
	case 227:
2751
		_wait();
2752
		_mread(cpu->pc++);
2753
		goto step_next;
2754
	case 228:
2755
		cpu->sph = _gd();
2756
		goto step_next;
2757
	// -- overlapped
2758
	case 229:
2759
		goto fetch_next;
2760
 
2761
	//  32: LD (nn),A (M:4 T:13)
2762
	// -- mread
2763
	case 230:
2764
		goto step_next;
2765
	case 231:
2766
		_wait();
2767
		_mread(cpu->pc++);
2768
		goto step_next;
2769
	case 232:
2770
		cpu->wzl = _gd();
2771
		goto step_next;
2772
	// -- mread
2773
	case 233:
2774
		goto step_next;
2775
	case 234:
2776
		_wait();
2777
		_mread(cpu->pc++);
2778
		goto step_next;
2779
	case 235:
2780
		cpu->wzh = _gd();
2781
		goto step_next;
2782
	// -- mwrite
2783
	case 236:
2784
		goto step_next;
2785
	case 237:
2786
		_wait();
2787
		_mwrite(cpu->wz++, cpu->a);
2788
		cpu->wzh = cpu->a;
2789
		goto step_next;
2790
	case 238:
2791
		goto step_next;
2792
	// -- overlapped
2793
	case 239:
2794
		goto fetch_next;
2795
 
2796
	//  33: INC SP (M:2 T:6)
2797
	// -- generic
2798
	case 240:
2799
		cpu->sp++;
2800
		goto step_next;
2801
	case 241:
2802
		goto step_next;
2803
	// -- overlapped
2804
	case 242:
2805
		goto fetch_next;
2806
 
2807
	//  34: INC (HL) (M:3 T:11)
2808
	// -- mread
2809
	case 243:
2810
		goto step_next;
2811
	case 244:
2812
		_wait();
2813
		_mread(cpu->addr);
2814
		goto step_next;
2815
	case 245:
2816
		cpu->dlatch = _gd();
2817
		cpu->dlatch = _z80_inc8(cpu, cpu->dlatch);
2818
		goto step_next;
2819
	case 246:
2820
		goto step_next;
2821
	// -- mwrite
2822
	case 247:
2823
		goto step_next;
2824
	case 248:
2825
		_wait();
2826
		_mwrite(cpu->addr, cpu->dlatch);
2827
		goto step_next;
2828
	case 249:
2829
		goto step_next;
2830
	// -- overlapped
2831
	case 250:
2832
		goto fetch_next;
2833
 
2834
	//  35: DEC (HL) (M:3 T:11)
2835
	// -- mread
2836
	case 251:
2837
		goto step_next;
2838
	case 252:
2839
		_wait();
2840
		_mread(cpu->addr);
2841
		goto step_next;
2842
	case 253:
2843
		cpu->dlatch = _gd();
2844
		cpu->dlatch = _z80_dec8(cpu, cpu->dlatch);
2845
		goto step_next;
2846
	case 254:
2847
		goto step_next;
2848
	// -- mwrite
2849
	case 255:
2850
		goto step_next;
2851
	case 256:
2852
		_wait();
2853
		_mwrite(cpu->addr, cpu->dlatch);
2854
		goto step_next;
2855
	case 257:
2856
		goto step_next;
2857
	// -- overlapped
2858
	case 258:
2859
		goto fetch_next;
2860
 
2861
	//  36: LD (HL),n (M:3 T:10)
2862
	// -- mread
2863
	case 259:
2864
		goto step_next;
2865
	case 260:
2866
		_wait();
2867
		_mread(cpu->pc++);
2868
		goto step_next;
2869
	case 261:
2870
		cpu->dlatch = _gd();
2871
		goto step_next;
2872
	// -- mwrite
2873
	case 262:
2874
		goto step_next;
2875
	case 263:
2876
		_wait();
2877
		_mwrite(cpu->addr, cpu->dlatch);
2878
		goto step_next;
2879
	case 264:
2880
		goto step_next;
2881
	// -- overlapped
2882
	case 265:
2883
		goto fetch_next;
2884
 
2885
	//  37: SCF (M:1 T:4)
2886
	// -- overlapped
2887
	case 266:
2888
		_z80_scf(cpu);
2889
		goto fetch_next;
2890
 
2891
	//  38: JR C,d (M:3 T:12)
2892
	// -- mread
2893
	case 267:
2894
		goto step_next;
2895
	case 268:
2896
		_wait();
2897
		_mread(cpu->pc++);
2898
		goto step_next;
2899
	case 269:
2900
		cpu->dlatch = _gd();
2901
		if(!(_cc_c)) {
2902
			_skip(5);
2903
		};
2904
		goto step_next;
2905
	// -- generic
2906
	case 270:
2907
		cpu->pc += (int8_t)cpu->dlatch;
2908
		cpu->wz = cpu->pc;
2909
		goto step_next;
2910
	case 271:
2911
		goto step_next;
2912
	case 272:
2913
		goto step_next;
2914
	case 273:
2915
		goto step_next;
2916
	case 274:
2917
		goto step_next;
2918
	// -- overlapped
2919
	case 275:
2920
		goto fetch_next;
2921
 
2922
	//  39: ADD HL,SP (M:2 T:11)
2923
	// -- generic
2924
	case 276:
2925
		_z80_add16(cpu, cpu->sp);
2926
		goto step_next;
2927
	case 277:
2928
		goto step_next;
2929
	case 278:
2930
		goto step_next;
2931
	case 279:
2932
		goto step_next;
2933
	case 280:
2934
		goto step_next;
2935
	case 281:
2936
		goto step_next;
2937
	case 282:
2938
		goto step_next;
2939
	// -- overlapped
2940
	case 283:
2941
		goto fetch_next;
2942
 
2943
	//  3A: LD A,(nn) (M:4 T:13)
2944
	// -- mread
2945
	case 284:
2946
		goto step_next;
2947
	case 285:
2948
		_wait();
2949
		_mread(cpu->pc++);
2950
		goto step_next;
2951
	case 286:
2952
		cpu->wzl = _gd();
2953
		goto step_next;
2954
	// -- mread
2955
	case 287:
2956
		goto step_next;
2957
	case 288:
2958
		_wait();
2959
		_mread(cpu->pc++);
2960
		goto step_next;
2961
	case 289:
2962
		cpu->wzh = _gd();
2963
		goto step_next;
2964
	// -- mread
2965
	case 290:
2966
		goto step_next;
2967
	case 291:
2968
		_wait();
2969
		_mread(cpu->wz++);
2970
		goto step_next;
2971
	case 292:
2972
		cpu->a = _gd();
2973
		goto step_next;
2974
	// -- overlapped
2975
	case 293:
2976
		goto fetch_next;
2977
 
2978
	//  3B: DEC SP (M:2 T:6)
2979
	// -- generic
2980
	case 294:
2981
		cpu->sp--;
2982
		goto step_next;
2983
	case 295:
2984
		goto step_next;
2985
	// -- overlapped
2986
	case 296:
2987
		goto fetch_next;
2988
 
2989
	//  3C: INC A (M:1 T:4)
2990
	// -- overlapped
2991
	case 297:
2992
		cpu->a = _z80_inc8(cpu, cpu->a);
2993
		goto fetch_next;
2994
 
2995
	//  3D: DEC A (M:1 T:4)
2996
	// -- overlapped
2997
	case 298:
2998
		cpu->a = _z80_dec8(cpu, cpu->a);
2999
		goto fetch_next;
3000
 
3001
	//  3E: LD A,n (M:2 T:7)
3002
	// -- mread
3003
	case 299:
3004
		goto step_next;
3005
	case 300:
3006
		_wait();
3007
		_mread(cpu->pc++);
3008
		goto step_next;
3009
	case 301:
3010
		cpu->a = _gd();
3011
		goto step_next;
3012
	// -- overlapped
3013
	case 302:
3014
		goto fetch_next;
3015
 
3016
	//  3F: CCF (M:1 T:4)
3017
	// -- overlapped
3018
	case 303:
3019
		_z80_ccf(cpu);
3020
		goto fetch_next;
3021
 
3022
	//  40: LD B,B (M:1 T:4)
3023
	// -- overlapped
3024
	case 304:
3025
		cpu->b = cpu->b;
3026
		goto fetch_next;
3027
 
3028
	//  41: LD B,C (M:1 T:4)
3029
	// -- overlapped
3030
	case 305:
3031
		cpu->b = cpu->c;
3032
		goto fetch_next;
3033
 
3034
	//  42: LD B,D (M:1 T:4)
3035
	// -- overlapped
3036
	case 306:
3037
		cpu->b = cpu->d;
3038
		goto fetch_next;
3039
 
3040
	//  43: LD B,E (M:1 T:4)
3041
	// -- overlapped
3042
	case 307:
3043
		cpu->b = cpu->e;
3044
		goto fetch_next;
3045
 
3046
	//  44: LD B,H (M:1 T:4)
3047
	// -- overlapped
3048
	case 308:
3049
		cpu->b = cpu->hlx[cpu->hlx_idx].h;
3050
		goto fetch_next;
3051
 
3052
	//  45: LD B,L (M:1 T:4)
3053
	// -- overlapped
3054
	case 309:
3055
		cpu->b = cpu->hlx[cpu->hlx_idx].l;
3056
		goto fetch_next;
3057
 
3058
	//  46: LD B,(HL) (M:2 T:7)
3059
	// -- mread
3060
	case 310:
3061
		goto step_next;
3062
	case 311:
3063
		_wait();
3064
		_mread(cpu->addr);
3065
		goto step_next;
3066
	case 312:
3067
		cpu->b = _gd();
3068
		goto step_next;
3069
	// -- overlapped
3070
	case 313:
3071
		goto fetch_next;
3072
 
3073
	//  47: LD B,A (M:1 T:4)
3074
	// -- overlapped
3075
	case 314:
3076
		cpu->b = cpu->a;
3077
		goto fetch_next;
3078
 
3079
	//  48: LD C,B (M:1 T:4)
3080
	// -- overlapped
3081
	case 315:
3082
		cpu->c = cpu->b;
3083
		goto fetch_next;
3084
 
3085
	//  49: LD C,C (M:1 T:4)
3086
	// -- overlapped
3087
	case 316:
3088
		cpu->c = cpu->c;
3089
		goto fetch_next;
3090
 
3091
	//  4A: LD C,D (M:1 T:4)
3092
	// -- overlapped
3093
	case 317:
3094
		cpu->c = cpu->d;
3095
		goto fetch_next;
3096
 
3097
	//  4B: LD C,E (M:1 T:4)
3098
	// -- overlapped
3099
	case 318:
3100
		cpu->c = cpu->e;
3101
		goto fetch_next;
3102
 
3103
	//  4C: LD C,H (M:1 T:4)
3104
	// -- overlapped
3105
	case 319:
3106
		cpu->c = cpu->hlx[cpu->hlx_idx].h;
3107
		goto fetch_next;
3108
 
3109
	//  4D: LD C,L (M:1 T:4)
3110
	// -- overlapped
3111
	case 320:
3112
		cpu->c = cpu->hlx[cpu->hlx_idx].l;
3113
		goto fetch_next;
3114
 
3115
	//  4E: LD C,(HL) (M:2 T:7)
3116
	// -- mread
3117
	case 321:
3118
		goto step_next;
3119
	case 322:
3120
		_wait();
3121
		_mread(cpu->addr);
3122
		goto step_next;
3123
	case 323:
3124
		cpu->c = _gd();
3125
		goto step_next;
3126
	// -- overlapped
3127
	case 324:
3128
		goto fetch_next;
3129
 
3130
	//  4F: LD C,A (M:1 T:4)
3131
	// -- overlapped
3132
	case 325:
3133
		cpu->c = cpu->a;
3134
		goto fetch_next;
3135
 
3136
	//  50: LD D,B (M:1 T:4)
3137
	// -- overlapped
3138
	case 326:
3139
		cpu->d = cpu->b;
3140
		goto fetch_next;
3141
 
3142
	//  51: LD D,C (M:1 T:4)
3143
	// -- overlapped
3144
	case 327:
3145
		cpu->d = cpu->c;
3146
		goto fetch_next;
3147
 
3148
	//  52: LD D,D (M:1 T:4)
3149
	// -- overlapped
3150
	case 328:
3151
		cpu->d = cpu->d;
3152
		goto fetch_next;
3153
 
3154
	//  53: LD D,E (M:1 T:4)
3155
	// -- overlapped
3156
	case 329:
3157
		cpu->d = cpu->e;
3158
		goto fetch_next;
3159
 
3160
	//  54: LD D,H (M:1 T:4)
3161
	// -- overlapped
3162
	case 330:
3163
		cpu->d = cpu->hlx[cpu->hlx_idx].h;
3164
		goto fetch_next;
3165
 
3166
	//  55: LD D,L (M:1 T:4)
3167
	// -- overlapped
3168
	case 331:
3169
		cpu->d = cpu->hlx[cpu->hlx_idx].l;
3170
		goto fetch_next;
3171
 
3172
	//  56: LD D,(HL) (M:2 T:7)
3173
	// -- mread
3174
	case 332:
3175
		goto step_next;
3176
	case 333:
3177
		_wait();
3178
		_mread(cpu->addr);
3179
		goto step_next;
3180
	case 334:
3181
		cpu->d = _gd();
3182
		goto step_next;
3183
	// -- overlapped
3184
	case 335:
3185
		goto fetch_next;
3186
 
3187
	//  57: LD D,A (M:1 T:4)
3188
	// -- overlapped
3189
	case 336:
3190
		cpu->d = cpu->a;
3191
		goto fetch_next;
3192
 
3193
	//  58: LD E,B (M:1 T:4)
3194
	// -- overlapped
3195
	case 337:
3196
		cpu->e = cpu->b;
3197
		goto fetch_next;
3198
 
3199
	//  59: LD E,C (M:1 T:4)
3200
	// -- overlapped
3201
	case 338:
3202
		cpu->e = cpu->c;
3203
		goto fetch_next;
3204
 
3205
	//  5A: LD E,D (M:1 T:4)
3206
	// -- overlapped
3207
	case 339:
3208
		cpu->e = cpu->d;
3209
		goto fetch_next;
3210
 
3211
	//  5B: LD E,E (M:1 T:4)
3212
	// -- overlapped
3213
	case 340:
3214
		cpu->e = cpu->e;
3215
		goto fetch_next;
3216
 
3217
	//  5C: LD E,H (M:1 T:4)
3218
	// -- overlapped
3219
	case 341:
3220
		cpu->e = cpu->hlx[cpu->hlx_idx].h;
3221
		goto fetch_next;
3222
 
3223
	//  5D: LD E,L (M:1 T:4)
3224
	// -- overlapped
3225
	case 342:
3226
		cpu->e = cpu->hlx[cpu->hlx_idx].l;
3227
		goto fetch_next;
3228
 
3229
	//  5E: LD E,(HL) (M:2 T:7)
3230
	// -- mread
3231
	case 343:
3232
		goto step_next;
3233
	case 344:
3234
		_wait();
3235
		_mread(cpu->addr);
3236
		goto step_next;
3237
	case 345:
3238
		cpu->e = _gd();
3239
		goto step_next;
3240
	// -- overlapped
3241
	case 346:
3242
		goto fetch_next;
3243
 
3244
	//  5F: LD E,A (M:1 T:4)
3245
	// -- overlapped
3246
	case 347:
3247
		cpu->e = cpu->a;
3248
		goto fetch_next;
3249
 
3250
	//  60: LD H,B (M:1 T:4)
3251
	// -- overlapped
3252
	case 348:
3253
		cpu->hlx[cpu->hlx_idx].h = cpu->b;
3254
		goto fetch_next;
3255
 
3256
	//  61: LD H,C (M:1 T:4)
3257
	// -- overlapped
3258
	case 349:
3259
		cpu->hlx[cpu->hlx_idx].h = cpu->c;
3260
		goto fetch_next;
3261
 
3262
	//  62: LD H,D (M:1 T:4)
3263
	// -- overlapped
3264
	case 350:
3265
		cpu->hlx[cpu->hlx_idx].h = cpu->d;
3266
		goto fetch_next;
3267
 
3268
	//  63: LD H,E (M:1 T:4)
3269
	// -- overlapped
3270
	case 351:
3271
		cpu->hlx[cpu->hlx_idx].h = cpu->e;
3272
		goto fetch_next;
3273
 
3274
	//  64: LD H,H (M:1 T:4)
3275
	// -- overlapped
3276
	case 352:
3277
		cpu->hlx[cpu->hlx_idx].h = cpu->hlx[cpu->hlx_idx].h;
3278
		goto fetch_next;
3279
 
3280
	//  65: LD H,L (M:1 T:4)
3281
	// -- overlapped
3282
	case 353:
3283
		cpu->hlx[cpu->hlx_idx].h = cpu->hlx[cpu->hlx_idx].l;
3284
		goto fetch_next;
3285
 
3286
	//  66: LD H,(HL) (M:2 T:7)
3287
	// -- mread
3288
	case 354:
3289
		goto step_next;
3290
	case 355:
3291
		_wait();
3292
		_mread(cpu->addr);
3293
		goto step_next;
3294
	case 356:
3295
		cpu->h = _gd();
3296
		goto step_next;
3297
	// -- overlapped
3298
	case 357:
3299
		goto fetch_next;
3300
 
3301
	//  67: LD H,A (M:1 T:4)
3302
	// -- overlapped
3303
	case 358:
3304
		cpu->hlx[cpu->hlx_idx].h = cpu->a;
3305
		goto fetch_next;
3306
 
3307
	//  68: LD L,B (M:1 T:4)
3308
	// -- overlapped
3309
	case 359:
3310
		cpu->hlx[cpu->hlx_idx].l = cpu->b;
3311
		goto fetch_next;
3312
 
3313
	//  69: LD L,C (M:1 T:4)
3314
	// -- overlapped
3315
	case 360:
3316
		cpu->hlx[cpu->hlx_idx].l = cpu->c;
3317
		goto fetch_next;
3318
 
3319
	//  6A: LD L,D (M:1 T:4)
3320
	// -- overlapped
3321
	case 361:
3322
		cpu->hlx[cpu->hlx_idx].l = cpu->d;
3323
		goto fetch_next;
3324
 
3325
	//  6B: LD L,E (M:1 T:4)
3326
	// -- overlapped
3327
	case 362:
3328
		cpu->hlx[cpu->hlx_idx].l = cpu->e;
3329
		goto fetch_next;
3330
 
3331
	//  6C: LD L,H (M:1 T:4)
3332
	// -- overlapped
3333
	case 363:
3334
		cpu->hlx[cpu->hlx_idx].l = cpu->hlx[cpu->hlx_idx].h;
3335
		goto fetch_next;
3336
 
3337
	//  6D: LD L,L (M:1 T:4)
3338
	// -- overlapped
3339
	case 364:
3340
		cpu->hlx[cpu->hlx_idx].l = cpu->hlx[cpu->hlx_idx].l;
3341
		goto fetch_next;
3342
 
3343
	//  6E: LD L,(HL) (M:2 T:7)
3344
	// -- mread
3345
	case 365:
3346
		goto step_next;
3347
	case 366:
3348
		_wait();
3349
		_mread(cpu->addr);
3350
		goto step_next;
3351
	case 367:
3352
		cpu->l = _gd();
3353
		goto step_next;
3354
	// -- overlapped
3355
	case 368:
3356
		goto fetch_next;
3357
 
3358
	//  6F: LD L,A (M:1 T:4)
3359
	// -- overlapped
3360
	case 369:
3361
		cpu->hlx[cpu->hlx_idx].l = cpu->a;
3362
		goto fetch_next;
3363
 
3364
	//  70: LD (HL),B (M:2 T:7)
3365
	// -- mwrite
3366
	case 370:
3367
		goto step_next;
3368
	case 371:
3369
		_wait();
3370
		_mwrite(cpu->addr, cpu->b);
3371
		goto step_next;
3372
	case 372:
3373
		goto step_next;
3374
	// -- overlapped
3375
	case 373:
3376
		goto fetch_next;
3377
 
3378
	//  71: LD (HL),C (M:2 T:7)
3379
	// -- mwrite
3380
	case 374:
3381
		goto step_next;
3382
	case 375:
3383
		_wait();
3384
		_mwrite(cpu->addr, cpu->c);
3385
		goto step_next;
3386
	case 376:
3387
		goto step_next;
3388
	// -- overlapped
3389
	case 377:
3390
		goto fetch_next;
3391
 
3392
	//  72: LD (HL),D (M:2 T:7)
3393
	// -- mwrite
3394
	case 378:
3395
		goto step_next;
3396
	case 379:
3397
		_wait();
3398
		_mwrite(cpu->addr, cpu->d);
3399
		goto step_next;
3400
	case 380:
3401
		goto step_next;
3402
	// -- overlapped
3403
	case 381:
3404
		goto fetch_next;
3405
 
3406
	//  73: LD (HL),E (M:2 T:7)
3407
	// -- mwrite
3408
	case 382:
3409
		goto step_next;
3410
	case 383:
3411
		_wait();
3412
		_mwrite(cpu->addr, cpu->e);
3413
		goto step_next;
3414
	case 384:
3415
		goto step_next;
3416
	// -- overlapped
3417
	case 385:
3418
		goto fetch_next;
3419
 
3420
	//  74: LD (HL),H (M:2 T:7)
3421
	// -- mwrite
3422
	case 386:
3423
		goto step_next;
3424
	case 387:
3425
		_wait();
3426
		_mwrite(cpu->addr, cpu->h);
3427
		goto step_next;
3428
	case 388:
3429
		goto step_next;
3430
	// -- overlapped
3431
	case 389:
3432
		goto fetch_next;
3433
 
3434
	//  75: LD (HL),L (M:2 T:7)
3435
	// -- mwrite
3436
	case 390:
3437
		goto step_next;
3438
	case 391:
3439
		_wait();
3440
		_mwrite(cpu->addr, cpu->l);
3441
		goto step_next;
3442
	case 392:
3443
		goto step_next;
3444
	// -- overlapped
3445
	case 393:
3446
		goto fetch_next;
3447
 
3448
	//  76: HALT (M:1 T:4)
3449
	// -- overlapped
3450
	case 394:
3451
		pins = _z80_halt(cpu, pins);
3452
		goto fetch_next;
3453
 
3454
	//  77: LD (HL),A (M:2 T:7)
3455
	// -- mwrite
3456
	case 395:
3457
		goto step_next;
3458
	case 396:
3459
		_wait();
3460
		_mwrite(cpu->addr, cpu->a);
3461
		goto step_next;
3462
	case 397:
3463
		goto step_next;
3464
	// -- overlapped
3465
	case 398:
3466
		goto fetch_next;
3467
 
3468
	//  78: LD A,B (M:1 T:4)
3469
	// -- overlapped
3470
	case 399:
3471
		cpu->a = cpu->b;
3472
		goto fetch_next;
3473
 
3474
	//  79: LD A,C (M:1 T:4)
3475
	// -- overlapped
3476
	case 400:
3477
		cpu->a = cpu->c;
3478
		goto fetch_next;
3479
 
3480
	//  7A: LD A,D (M:1 T:4)
3481
	// -- overlapped
3482
	case 401:
3483
		cpu->a = cpu->d;
3484
		goto fetch_next;
3485
 
3486
	//  7B: LD A,E (M:1 T:4)
3487
	// -- overlapped
3488
	case 402:
3489
		cpu->a = cpu->e;
3490
		goto fetch_next;
3491
 
3492
	//  7C: LD A,H (M:1 T:4)
3493
	// -- overlapped
3494
	case 403:
3495
		cpu->a = cpu->hlx[cpu->hlx_idx].h;
3496
		goto fetch_next;
3497
 
3498
	//  7D: LD A,L (M:1 T:4)
3499
	// -- overlapped
3500
	case 404:
3501
		cpu->a = cpu->hlx[cpu->hlx_idx].l;
3502
		goto fetch_next;
3503
 
3504
	//  7E: LD A,(HL) (M:2 T:7)
3505
	// -- mread
3506
	case 405:
3507
		goto step_next;
3508
	case 406:
3509
		_wait();
3510
		_mread(cpu->addr);
3511
		goto step_next;
3512
	case 407:
3513
		cpu->a = _gd();
3514
		goto step_next;
3515
	// -- overlapped
3516
	case 408:
3517
		goto fetch_next;
3518
 
3519
	//  7F: LD A,A (M:1 T:4)
3520
	// -- overlapped
3521
	case 409:
3522
		cpu->a = cpu->a;
3523
		goto fetch_next;
3524
 
3525
	//  80: ADD B (M:1 T:4)
3526
	// -- overlapped
3527
	case 410:
3528
		_z80_add8(cpu, cpu->b);
3529
		goto fetch_next;
3530
 
3531
	//  81: ADD C (M:1 T:4)
3532
	// -- overlapped
3533
	case 411:
3534
		_z80_add8(cpu, cpu->c);
3535
		goto fetch_next;
3536
 
3537
	//  82: ADD D (M:1 T:4)
3538
	// -- overlapped
3539
	case 412:
3540
		_z80_add8(cpu, cpu->d);
3541
		goto fetch_next;
3542
 
3543
	//  83: ADD E (M:1 T:4)
3544
	// -- overlapped
3545
	case 413:
3546
		_z80_add8(cpu, cpu->e);
3547
		goto fetch_next;
3548
 
3549
	//  84: ADD H (M:1 T:4)
3550
	// -- overlapped
3551
	case 414:
3552
		_z80_add8(cpu, cpu->hlx[cpu->hlx_idx].h);
3553
		goto fetch_next;
3554
 
3555
	//  85: ADD L (M:1 T:4)
3556
	// -- overlapped
3557
	case 415:
3558
		_z80_add8(cpu, cpu->hlx[cpu->hlx_idx].l);
3559
		goto fetch_next;
3560
 
3561
	//  86: ADD (HL) (M:2 T:7)
3562
	// -- mread
3563
	case 416:
3564
		goto step_next;
3565
	case 417:
3566
		_wait();
3567
		_mread(cpu->addr);
3568
		goto step_next;
3569
	case 418:
3570
		cpu->dlatch = _gd();
3571
		goto step_next;
3572
	// -- overlapped
3573
	case 419:
3574
		_z80_add8(cpu, cpu->dlatch);
3575
		goto fetch_next;
3576
 
3577
	//  87: ADD A (M:1 T:4)
3578
	// -- overlapped
3579
	case 420:
3580
		_z80_add8(cpu, cpu->a);
3581
		goto fetch_next;
3582
 
3583
	//  88: ADC B (M:1 T:4)
3584
	// -- overlapped
3585
	case 421:
3586
		_z80_adc8(cpu, cpu->b);
3587
		goto fetch_next;
3588
 
3589
	//  89: ADC C (M:1 T:4)
3590
	// -- overlapped
3591
	case 422:
3592
		_z80_adc8(cpu, cpu->c);
3593
		goto fetch_next;
3594
 
3595
	//  8A: ADC D (M:1 T:4)
3596
	// -- overlapped
3597
	case 423:
3598
		_z80_adc8(cpu, cpu->d);
3599
		goto fetch_next;
3600
 
3601
	//  8B: ADC E (M:1 T:4)
3602
	// -- overlapped
3603
	case 424:
3604
		_z80_adc8(cpu, cpu->e);
3605
		goto fetch_next;
3606
 
3607
	//  8C: ADC H (M:1 T:4)
3608
	// -- overlapped
3609
	case 425:
3610
		_z80_adc8(cpu, cpu->hlx[cpu->hlx_idx].h);
3611
		goto fetch_next;
3612
 
3613
	//  8D: ADC L (M:1 T:4)
3614
	// -- overlapped
3615
	case 426:
3616
		_z80_adc8(cpu, cpu->hlx[cpu->hlx_idx].l);
3617
		goto fetch_next;
3618
 
3619
	//  8E: ADC (HL) (M:2 T:7)
3620
	// -- mread
3621
	case 427:
3622
		goto step_next;
3623
	case 428:
3624
		_wait();
3625
		_mread(cpu->addr);
3626
		goto step_next;
3627
	case 429:
3628
		cpu->dlatch = _gd();
3629
		goto step_next;
3630
	// -- overlapped
3631
	case 430:
3632
		_z80_adc8(cpu, cpu->dlatch);
3633
		goto fetch_next;
3634
 
3635
	//  8F: ADC A (M:1 T:4)
3636
	// -- overlapped
3637
	case 431:
3638
		_z80_adc8(cpu, cpu->a);
3639
		goto fetch_next;
3640
 
3641
	//  90: SUB B (M:1 T:4)
3642
	// -- overlapped
3643
	case 432:
3644
		_z80_sub8(cpu, cpu->b);
3645
		goto fetch_next;
3646
 
3647
	//  91: SUB C (M:1 T:4)
3648
	// -- overlapped
3649
	case 433:
3650
		_z80_sub8(cpu, cpu->c);
3651
		goto fetch_next;
3652
 
3653
	//  92: SUB D (M:1 T:4)
3654
	// -- overlapped
3655
	case 434:
3656
		_z80_sub8(cpu, cpu->d);
3657
		goto fetch_next;
3658
 
3659
	//  93: SUB E (M:1 T:4)
3660
	// -- overlapped
3661
	case 435:
3662
		_z80_sub8(cpu, cpu->e);
3663
		goto fetch_next;
3664
 
3665
	//  94: SUB H (M:1 T:4)
3666
	// -- overlapped
3667
	case 436:
3668
		_z80_sub8(cpu, cpu->hlx[cpu->hlx_idx].h);
3669
		goto fetch_next;
3670
 
3671
	//  95: SUB L (M:1 T:4)
3672
	// -- overlapped
3673
	case 437:
3674
		_z80_sub8(cpu, cpu->hlx[cpu->hlx_idx].l);
3675
		goto fetch_next;
3676
 
3677
	//  96: SUB (HL) (M:2 T:7)
3678
	// -- mread
3679
	case 438:
3680
		goto step_next;
3681
	case 439:
3682
		_wait();
3683
		_mread(cpu->addr);
3684
		goto step_next;
3685
	case 440:
3686
		cpu->dlatch = _gd();
3687
		goto step_next;
3688
	// -- overlapped
3689
	case 441:
3690
		_z80_sub8(cpu, cpu->dlatch);
3691
		goto fetch_next;
3692
 
3693
	//  97: SUB A (M:1 T:4)
3694
	// -- overlapped
3695
	case 442:
3696
		_z80_sub8(cpu, cpu->a);
3697
		goto fetch_next;
3698
 
3699
	//  98: SBC B (M:1 T:4)
3700
	// -- overlapped
3701
	case 443:
3702
		_z80_sbc8(cpu, cpu->b);
3703
		goto fetch_next;
3704
 
3705
	//  99: SBC C (M:1 T:4)
3706
	// -- overlapped
3707
	case 444:
3708
		_z80_sbc8(cpu, cpu->c);
3709
		goto fetch_next;
3710
 
3711
	//  9A: SBC D (M:1 T:4)
3712
	// -- overlapped
3713
	case 445:
3714
		_z80_sbc8(cpu, cpu->d);
3715
		goto fetch_next;
3716
 
3717
	//  9B: SBC E (M:1 T:4)
3718
	// -- overlapped
3719
	case 446:
3720
		_z80_sbc8(cpu, cpu->e);
3721
		goto fetch_next;
3722
 
3723
	//  9C: SBC H (M:1 T:4)
3724
	// -- overlapped
3725
	case 447:
3726
		_z80_sbc8(cpu, cpu->hlx[cpu->hlx_idx].h);
3727
		goto fetch_next;
3728
 
3729
	//  9D: SBC L (M:1 T:4)
3730
	// -- overlapped
3731
	case 448:
3732
		_z80_sbc8(cpu, cpu->hlx[cpu->hlx_idx].l);
3733
		goto fetch_next;
3734
 
3735
	//  9E: SBC (HL) (M:2 T:7)
3736
	// -- mread
3737
	case 449:
3738
		goto step_next;
3739
	case 450:
3740
		_wait();
3741
		_mread(cpu->addr);
3742
		goto step_next;
3743
	case 451:
3744
		cpu->dlatch = _gd();
3745
		goto step_next;
3746
	// -- overlapped
3747
	case 452:
3748
		_z80_sbc8(cpu, cpu->dlatch);
3749
		goto fetch_next;
3750
 
3751
	//  9F: SBC A (M:1 T:4)
3752
	// -- overlapped
3753
	case 453:
3754
		_z80_sbc8(cpu, cpu->a);
3755
		goto fetch_next;
3756
 
3757
	//  A0: AND B (M:1 T:4)
3758
	// -- overlapped
3759
	case 454:
3760
		_z80_and8(cpu, cpu->b);
3761
		goto fetch_next;
3762
 
3763
	//  A1: AND C (M:1 T:4)
3764
	// -- overlapped
3765
	case 455:
3766
		_z80_and8(cpu, cpu->c);
3767
		goto fetch_next;
3768
 
3769
	//  A2: AND D (M:1 T:4)
3770
	// -- overlapped
3771
	case 456:
3772
		_z80_and8(cpu, cpu->d);
3773
		goto fetch_next;
3774
 
3775
	//  A3: AND E (M:1 T:4)
3776
	// -- overlapped
3777
	case 457:
3778
		_z80_and8(cpu, cpu->e);
3779
		goto fetch_next;
3780
 
3781
	//  A4: AND H (M:1 T:4)
3782
	// -- overlapped
3783
	case 458:
3784
		_z80_and8(cpu, cpu->hlx[cpu->hlx_idx].h);
3785
		goto fetch_next;
3786
 
3787
	//  A5: AND L (M:1 T:4)
3788
	// -- overlapped
3789
	case 459:
3790
		_z80_and8(cpu, cpu->hlx[cpu->hlx_idx].l);
3791
		goto fetch_next;
3792
 
3793
	//  A6: AND (HL) (M:2 T:7)
3794
	// -- mread
3795
	case 460:
3796
		goto step_next;
3797
	case 461:
3798
		_wait();
3799
		_mread(cpu->addr);
3800
		goto step_next;
3801
	case 462:
3802
		cpu->dlatch = _gd();
3803
		goto step_next;
3804
	// -- overlapped
3805
	case 463:
3806
		_z80_and8(cpu, cpu->dlatch);
3807
		goto fetch_next;
3808
 
3809
	//  A7: AND A (M:1 T:4)
3810
	// -- overlapped
3811
	case 464:
3812
		_z80_and8(cpu, cpu->a);
3813
		goto fetch_next;
3814
 
3815
	//  A8: XOR B (M:1 T:4)
3816
	// -- overlapped
3817
	case 465:
3818
		_z80_xor8(cpu, cpu->b);
3819
		goto fetch_next;
3820
 
3821
	//  A9: XOR C (M:1 T:4)
3822
	// -- overlapped
3823
	case 466:
3824
		_z80_xor8(cpu, cpu->c);
3825
		goto fetch_next;
3826
 
3827
	//  AA: XOR D (M:1 T:4)
3828
	// -- overlapped
3829
	case 467:
3830
		_z80_xor8(cpu, cpu->d);
3831
		goto fetch_next;
3832
 
3833
	//  AB: XOR E (M:1 T:4)
3834
	// -- overlapped
3835
	case 468:
3836
		_z80_xor8(cpu, cpu->e);
3837
		goto fetch_next;
3838
 
3839
	//  AC: XOR H (M:1 T:4)
3840
	// -- overlapped
3841
	case 469:
3842
		_z80_xor8(cpu, cpu->hlx[cpu->hlx_idx].h);
3843
		goto fetch_next;
3844
 
3845
	//  AD: XOR L (M:1 T:4)
3846
	// -- overlapped
3847
	case 470:
3848
		_z80_xor8(cpu, cpu->hlx[cpu->hlx_idx].l);
3849
		goto fetch_next;
3850
 
3851
	//  AE: XOR (HL) (M:2 T:7)
3852
	// -- mread
3853
	case 471:
3854
		goto step_next;
3855
	case 472:
3856
		_wait();
3857
		_mread(cpu->addr);
3858
		goto step_next;
3859
	case 473:
3860
		cpu->dlatch = _gd();
3861
		goto step_next;
3862
	// -- overlapped
3863
	case 474:
3864
		_z80_xor8(cpu, cpu->dlatch);
3865
		goto fetch_next;
3866
 
3867
	//  AF: XOR A (M:1 T:4)
3868
	// -- overlapped
3869
	case 475:
3870
		_z80_xor8(cpu, cpu->a);
3871
		goto fetch_next;
3872
 
3873
	//  B0: OR B (M:1 T:4)
3874
	// -- overlapped
3875
	case 476:
3876
		_z80_or8(cpu, cpu->b);
3877
		goto fetch_next;
3878
 
3879
	//  B1: OR C (M:1 T:4)
3880
	// -- overlapped
3881
	case 477:
3882
		_z80_or8(cpu, cpu->c);
3883
		goto fetch_next;
3884
 
3885
	//  B2: OR D (M:1 T:4)
3886
	// -- overlapped
3887
	case 478:
3888
		_z80_or8(cpu, cpu->d);
3889
		goto fetch_next;
3890
 
3891
	//  B3: OR E (M:1 T:4)
3892
	// -- overlapped
3893
	case 479:
3894
		_z80_or8(cpu, cpu->e);
3895
		goto fetch_next;
3896
 
3897
	//  B4: OR H (M:1 T:4)
3898
	// -- overlapped
3899
	case 480:
3900
		_z80_or8(cpu, cpu->hlx[cpu->hlx_idx].h);
3901
		goto fetch_next;
3902
 
3903
	//  B5: OR L (M:1 T:4)
3904
	// -- overlapped
3905
	case 481:
3906
		_z80_or8(cpu, cpu->hlx[cpu->hlx_idx].l);
3907
		goto fetch_next;
3908
 
3909
	//  B6: OR (HL) (M:2 T:7)
3910
	// -- mread
3911
	case 482:
3912
		goto step_next;
3913
	case 483:
3914
		_wait();
3915
		_mread(cpu->addr);
3916
		goto step_next;
3917
	case 484:
3918
		cpu->dlatch = _gd();
3919
		goto step_next;
3920
	// -- overlapped
3921
	case 485:
3922
		_z80_or8(cpu, cpu->dlatch);
3923
		goto fetch_next;
3924
 
3925
	//  B7: OR A (M:1 T:4)
3926
	// -- overlapped
3927
	case 486:
3928
		_z80_or8(cpu, cpu->a);
3929
		goto fetch_next;
3930
 
3931
	//  B8: CP B (M:1 T:4)
3932
	// -- overlapped
3933
	case 487:
3934
		_z80_cp8(cpu, cpu->b);
3935
		goto fetch_next;
3936
 
3937
	//  B9: CP C (M:1 T:4)
3938
	// -- overlapped
3939
	case 488:
3940
		_z80_cp8(cpu, cpu->c);
3941
		goto fetch_next;
3942
 
3943
	//  BA: CP D (M:1 T:4)
3944
	// -- overlapped
3945
	case 489:
3946
		_z80_cp8(cpu, cpu->d);
3947
		goto fetch_next;
3948
 
3949
	//  BB: CP E (M:1 T:4)
3950
	// -- overlapped
3951
	case 490:
3952
		_z80_cp8(cpu, cpu->e);
3953
		goto fetch_next;
3954
 
3955
	//  BC: CP H (M:1 T:4)
3956
	// -- overlapped
3957
	case 491:
3958
		_z80_cp8(cpu, cpu->hlx[cpu->hlx_idx].h);
3959
		goto fetch_next;
3960
 
3961
	//  BD: CP L (M:1 T:4)
3962
	// -- overlapped
3963
	case 492:
3964
		_z80_cp8(cpu, cpu->hlx[cpu->hlx_idx].l);
3965
		goto fetch_next;
3966
 
3967
	//  BE: CP (HL) (M:2 T:7)
3968
	// -- mread
3969
	case 493:
3970
		goto step_next;
3971
	case 494:
3972
		_wait();
3973
		_mread(cpu->addr);
3974
		goto step_next;
3975
	case 495:
3976
		cpu->dlatch = _gd();
3977
		goto step_next;
3978
	// -- overlapped
3979
	case 496:
3980
		_z80_cp8(cpu, cpu->dlatch);
3981
		goto fetch_next;
3982
 
3983
	//  BF: CP A (M:1 T:4)
3984
	// -- overlapped
3985
	case 497:
3986
		_z80_cp8(cpu, cpu->a);
3987
		goto fetch_next;
3988
 
3989
	//  C0: RET NZ (M:4 T:11)
3990
	// -- generic
3991
	case 498:
3992
		if(!_cc_nz) {
3993
			_skip(6);
3994
		};
3995
		goto step_next;
3996
	// -- mread
3997
	case 499:
3998
		goto step_next;
3999
	case 500:
4000
		_wait();
4001
		_mread(cpu->sp++);
4002
		goto step_next;
4003
	case 501:
4004
		cpu->wzl = _gd();
4005
		goto step_next;
4006
	// -- mread
4007
	case 502:
4008
		goto step_next;
4009
	case 503:
4010
		_wait();
4011
		_mread(cpu->sp++);
4012
		goto step_next;
4013
	case 504:
4014
		cpu->wzh = _gd();
4015
		cpu->pc = cpu->wz;
4016
		goto step_next;
4017
	// -- overlapped
4018
	case 505:
4019
		goto fetch_next;
4020
 
4021
	//  C1: POP BC (M:3 T:10)
4022
	// -- mread
4023
	case 506:
4024
		goto step_next;
4025
	case 507:
4026
		_wait();
4027
		_mread(cpu->sp++);
4028
		goto step_next;
4029
	case 508:
4030
		cpu->c = _gd();
4031
		goto step_next;
4032
	// -- mread
4033
	case 509:
4034
		goto step_next;
4035
	case 510:
4036
		_wait();
4037
		_mread(cpu->sp++);
4038
		goto step_next;
4039
	case 511:
4040
		cpu->b = _gd();
4041
		goto step_next;
4042
	// -- overlapped
4043
	case 512:
4044
		goto fetch_next;
4045
 
4046
	//  C2: JP NZ,nn (M:3 T:10)
4047
	// -- mread
4048
	case 513:
4049
		goto step_next;
4050
	case 514:
4051
		_wait();
4052
		_mread(cpu->pc++);
4053
		goto step_next;
4054
	case 515:
4055
		cpu->wzl = _gd();
4056
		goto step_next;
4057
	// -- mread
4058
	case 516:
4059
		goto step_next;
4060
	case 517:
4061
		_wait();
4062
		_mread(cpu->pc++);
4063
		goto step_next;
4064
	case 518:
4065
		cpu->wzh = _gd();
4066
		if(_cc_nz) {
4067
			cpu->pc = cpu->wz;
4068
		};
4069
		goto step_next;
4070
	// -- overlapped
4071
	case 519:
4072
		goto fetch_next;
4073
 
4074
	//  C3: JP nn (M:3 T:10)
4075
	// -- mread
4076
	case 520:
4077
		goto step_next;
4078
	case 521:
4079
		_wait();
4080
		_mread(cpu->pc++);
4081
		goto step_next;
4082
	case 522:
4083
		cpu->wzl = _gd();
4084
		goto step_next;
4085
	// -- mread
4086
	case 523:
4087
		goto step_next;
4088
	case 524:
4089
		_wait();
4090
		_mread(cpu->pc++);
4091
		goto step_next;
4092
	case 525:
4093
		cpu->wzh = _gd();
4094
		cpu->pc = cpu->wz;
4095
		goto step_next;
4096
	// -- overlapped
4097
	case 526:
4098
		goto fetch_next;
4099
 
4100
	//  C4: CALL NZ,nn (M:6 T:17)
4101
	// -- mread
4102
	case 527:
4103
		goto step_next;
4104
	case 528:
4105
		_wait();
4106
		_mread(cpu->pc++);
4107
		goto step_next;
4108
	case 529:
4109
		cpu->wzl = _gd();
4110
		goto step_next;
4111
	// -- mread
4112
	case 530:
4113
		goto step_next;
4114
	case 531:
4115
		_wait();
4116
		_mread(cpu->pc++);
4117
		goto step_next;
4118
	case 532:
4119
		cpu->wzh = _gd();
4120
		if(!_cc_nz) {
4121
			_skip(7);
4122
		};
4123
		goto step_next;
4124
	// -- generic
4125
	case 533:
4126
		goto step_next;
4127
	// -- mwrite
4128
	case 534:
4129
		goto step_next;
4130
	case 535:
4131
		_wait();
4132
		_mwrite(--cpu->sp, cpu->pch);
4133
		goto step_next;
4134
	case 536:
4135
		goto step_next;
4136
	// -- mwrite
4137
	case 537:
4138
		goto step_next;
4139
	case 538:
4140
		_wait();
4141
		_mwrite(--cpu->sp, cpu->pcl);
4142
		cpu->pc = cpu->wz;
4143
		goto step_next;
4144
	case 539:
4145
		goto step_next;
4146
	// -- overlapped
4147
	case 540:
4148
		goto fetch_next;
4149
 
4150
	//  C5: PUSH BC (M:4 T:11)
4151
	// -- generic
4152
	case 541:
4153
		goto step_next;
4154
	// -- mwrite
4155
	case 542:
4156
		goto step_next;
4157
	case 543:
4158
		_wait();
4159
		_mwrite(--cpu->sp, cpu->b);
4160
		goto step_next;
4161
	case 544:
4162
		goto step_next;
4163
	// -- mwrite
4164
	case 545:
4165
		goto step_next;
4166
	case 546:
4167
		_wait();
4168
		_mwrite(--cpu->sp, cpu->c);
4169
		goto step_next;
4170
	case 547:
4171
		goto step_next;
4172
	// -- overlapped
4173
	case 548:
4174
		goto fetch_next;
4175
 
4176
	//  C6: ADD n (M:2 T:7)
4177
	// -- mread
4178
	case 549:
4179
		goto step_next;
4180
	case 550:
4181
		_wait();
4182
		_mread(cpu->pc++);
4183
		goto step_next;
4184
	case 551:
4185
		cpu->dlatch = _gd();
4186
		goto step_next;
4187
	// -- overlapped
4188
	case 552:
4189
		_z80_add8(cpu, cpu->dlatch);
4190
		goto fetch_next;
4191
 
4192
	//  C7: RST 0h (M:4 T:11)
4193
	// -- generic
4194
	case 553:
4195
		goto step_next;
4196
	// -- mwrite
4197
	case 554:
4198
		goto step_next;
4199
	case 555:
4200
		_wait();
4201
		_mwrite(--cpu->sp, cpu->pch);
4202
		goto step_next;
4203
	case 556:
4204
		goto step_next;
4205
	// -- mwrite
4206
	case 557:
4207
		goto step_next;
4208
	case 558:
4209
		_wait();
4210
		_mwrite(--cpu->sp, cpu->pcl);
4211
		cpu->wz = 0x00;
4212
		cpu->pc = cpu->wz;
4213
		goto step_next;
4214
	case 559:
4215
		goto step_next;
4216
	// -- overlapped
4217
	case 560:
4218
		goto fetch_next;
4219
 
4220
	//  C8: RET Z (M:4 T:11)
4221
	// -- generic
4222
	case 561:
4223
		if(!_cc_z) {
4224
			_skip(6);
4225
		};
4226
		goto step_next;
4227
	// -- mread
4228
	case 562:
4229
		goto step_next;
4230
	case 563:
4231
		_wait();
4232
		_mread(cpu->sp++);
4233
		goto step_next;
4234
	case 564:
4235
		cpu->wzl = _gd();
4236
		goto step_next;
4237
	// -- mread
4238
	case 565:
4239
		goto step_next;
4240
	case 566:
4241
		_wait();
4242
		_mread(cpu->sp++);
4243
		goto step_next;
4244
	case 567:
4245
		cpu->wzh = _gd();
4246
		cpu->pc = cpu->wz;
4247
		goto step_next;
4248
	// -- overlapped
4249
	case 568:
4250
		goto fetch_next;
4251
 
4252
	//  C9: RET (M:3 T:10)
4253
	// -- mread
4254
	case 569:
4255
		goto step_next;
4256
	case 570:
4257
		_wait();
4258
		_mread(cpu->sp++);
4259
		goto step_next;
4260
	case 571:
4261
		cpu->wzl = _gd();
4262
		goto step_next;
4263
	// -- mread
4264
	case 572:
4265
		goto step_next;
4266
	case 573:
4267
		_wait();
4268
		_mread(cpu->sp++);
4269
		goto step_next;
4270
	case 574:
4271
		cpu->wzh = _gd();
4272
		cpu->pc = cpu->wz;
4273
		goto step_next;
4274
	// -- overlapped
4275
	case 575:
4276
		goto fetch_next;
4277
 
4278
	//  CA: JP Z,nn (M:3 T:10)
4279
	// -- mread
4280
	case 576:
4281
		goto step_next;
4282
	case 577:
4283
		_wait();
4284
		_mread(cpu->pc++);
4285
		goto step_next;
4286
	case 578:
4287
		cpu->wzl = _gd();
4288
		goto step_next;
4289
	// -- mread
4290
	case 579:
4291
		goto step_next;
4292
	case 580:
4293
		_wait();
4294
		_mread(cpu->pc++);
4295
		goto step_next;
4296
	case 581:
4297
		cpu->wzh = _gd();
4298
		if(_cc_z) {
4299
			cpu->pc = cpu->wz;
4300
		};
4301
		goto step_next;
4302
	// -- overlapped
4303
	case 582:
4304
		goto fetch_next;
4305
 
4306
	//  CB: CB prefix (M:1 T:4)
4307
	// -- overlapped
4308
	case 583:
4309
		_fetch_cb();
4310
		goto step_next;
4311
 
4312
	//  CC: CALL Z,nn (M:6 T:17)
4313
	// -- mread
4314
	case 584:
4315
		goto step_next;
4316
	case 585:
4317
		_wait();
4318
		_mread(cpu->pc++);
4319
		goto step_next;
4320
	case 586:
4321
		cpu->wzl = _gd();
4322
		goto step_next;
4323
	// -- mread
4324
	case 587:
4325
		goto step_next;
4326
	case 588:
4327
		_wait();
4328
		_mread(cpu->pc++);
4329
		goto step_next;
4330
	case 589:
4331
		cpu->wzh = _gd();
4332
		if(!_cc_z) {
4333
			_skip(7);
4334
		};
4335
		goto step_next;
4336
	// -- generic
4337
	case 590:
4338
		goto step_next;
4339
	// -- mwrite
4340
	case 591:
4341
		goto step_next;
4342
	case 592:
4343
		_wait();
4344
		_mwrite(--cpu->sp, cpu->pch);
4345
		goto step_next;
4346
	case 593:
4347
		goto step_next;
4348
	// -- mwrite
4349
	case 594:
4350
		goto step_next;
4351
	case 595:
4352
		_wait();
4353
		_mwrite(--cpu->sp, cpu->pcl);
4354
		cpu->pc = cpu->wz;
4355
		goto step_next;
4356
	case 596:
4357
		goto step_next;
4358
	// -- overlapped
4359
	case 597:
4360
		goto fetch_next;
4361
 
4362
	//  CD: CALL nn (M:5 T:17)
4363
	// -- mread
4364
	case 598:
4365
		goto step_next;
4366
	case 599:
4367
		_wait();
4368
		_mread(cpu->pc++);
4369
		goto step_next;
4370
	case 600:
4371
		cpu->wzl = _gd();
4372
		goto step_next;
4373
	// -- mread
4374
	case 601:
4375
		goto step_next;
4376
	case 602:
4377
		_wait();
4378
		_mread(cpu->pc++);
4379
		goto step_next;
4380
	case 603:
4381
		cpu->wzh = _gd();
4382
		goto step_next;
4383
	case 604:
4384
		goto step_next;
4385
	// -- mwrite
4386
	case 605:
4387
		goto step_next;
4388
	case 606:
4389
		_wait();
4390
		_mwrite(--cpu->sp, cpu->pch);
4391
		goto step_next;
4392
	case 607:
4393
		goto step_next;
4394
	// -- mwrite
4395
	case 608:
4396
		goto step_next;
4397
	case 609:
4398
		_wait();
4399
		_mwrite(--cpu->sp, cpu->pcl);
4400
		cpu->pc = cpu->wz;
4401
		goto step_next;
4402
	case 610:
4403
		goto step_next;
4404
	// -- overlapped
4405
	case 611:
4406
		goto fetch_next;
4407
 
4408
	//  CE: ADC n (M:2 T:7)
4409
	// -- mread
4410
	case 612:
4411
		goto step_next;
4412
	case 613:
4413
		_wait();
4414
		_mread(cpu->pc++);
4415
		goto step_next;
4416
	case 614:
4417
		cpu->dlatch = _gd();
4418
		goto step_next;
4419
	// -- overlapped
4420
	case 615:
4421
		_z80_adc8(cpu, cpu->dlatch);
4422
		goto fetch_next;
4423
 
4424
	//  CF: RST 8h (M:4 T:11)
4425
	// -- generic
4426
	case 616:
4427
		goto step_next;
4428
	// -- mwrite
4429
	case 617:
4430
		goto step_next;
4431
	case 618:
4432
		_wait();
4433
		_mwrite(--cpu->sp, cpu->pch);
4434
		goto step_next;
4435
	case 619:
4436
		goto step_next;
4437
	// -- mwrite
4438
	case 620:
4439
		goto step_next;
4440
	case 621:
4441
		_wait();
4442
		_mwrite(--cpu->sp, cpu->pcl);
4443
		cpu->wz = 0x08;
4444
		cpu->pc = cpu->wz;
4445
		goto step_next;
4446
	case 622:
4447
		goto step_next;
4448
	// -- overlapped
4449
	case 623:
4450
		goto fetch_next;
4451
 
4452
	//  D0: RET NC (M:4 T:11)
4453
	// -- generic
4454
	case 624:
4455
		if(!_cc_nc) {
4456
			_skip(6);
4457
		};
4458
		goto step_next;
4459
	// -- mread
4460
	case 625:
4461
		goto step_next;
4462
	case 626:
4463
		_wait();
4464
		_mread(cpu->sp++);
4465
		goto step_next;
4466
	case 627:
4467
		cpu->wzl = _gd();
4468
		goto step_next;
4469
	// -- mread
4470
	case 628:
4471
		goto step_next;
4472
	case 629:
4473
		_wait();
4474
		_mread(cpu->sp++);
4475
		goto step_next;
4476
	case 630:
4477
		cpu->wzh = _gd();
4478
		cpu->pc = cpu->wz;
4479
		goto step_next;
4480
	// -- overlapped
4481
	case 631:
4482
		goto fetch_next;
4483
 
4484
	//  D1: POP DE (M:3 T:10)
4485
	// -- mread
4486
	case 632:
4487
		goto step_next;
4488
	case 633:
4489
		_wait();
4490
		_mread(cpu->sp++);
4491
		goto step_next;
4492
	case 634:
4493
		cpu->e = _gd();
4494
		goto step_next;
4495
	// -- mread
4496
	case 635:
4497
		goto step_next;
4498
	case 636:
4499
		_wait();
4500
		_mread(cpu->sp++);
4501
		goto step_next;
4502
	case 637:
4503
		cpu->d = _gd();
4504
		goto step_next;
4505
	// -- overlapped
4506
	case 638:
4507
		goto fetch_next;
4508
 
4509
	//  D2: JP NC,nn (M:3 T:10)
4510
	// -- mread
4511
	case 639:
4512
		goto step_next;
4513
	case 640:
4514
		_wait();
4515
		_mread(cpu->pc++);
4516
		goto step_next;
4517
	case 641:
4518
		cpu->wzl = _gd();
4519
		goto step_next;
4520
	// -- mread
4521
	case 642:
4522
		goto step_next;
4523
	case 643:
4524
		_wait();
4525
		_mread(cpu->pc++);
4526
		goto step_next;
4527
	case 644:
4528
		cpu->wzh = _gd();
4529
		if(_cc_nc) {
4530
			cpu->pc = cpu->wz;
4531
		};
4532
		goto step_next;
4533
	// -- overlapped
4534
	case 645:
4535
		goto fetch_next;
4536
 
4537
	//  D3: OUT (n),A (M:3 T:11)
4538
	// -- mread
4539
	case 646:
4540
		goto step_next;
4541
	case 647:
4542
		_wait();
4543
		_mread(cpu->pc++);
4544
		goto step_next;
4545
	case 648:
4546
		cpu->wzl = _gd();
4547
		cpu->wzh = cpu->a;
4548
		goto step_next;
4549
	// -- iowrite
4550
	case 649:
4551
		goto step_next;
4552
	case 650:
4553
		_iowrite(cpu->wz, cpu->a);
4554
		goto step_next;
4555
	case 651:
4556
		_wait();
4557
		cpu->wzl++;
4558
		goto step_next;
4559
	case 652:
4560
		goto step_next;
4561
	// -- overlapped
4562
	case 653:
4563
		goto fetch_next;
4564
 
4565
	//  D4: CALL NC,nn (M:6 T:17)
4566
	// -- mread
4567
	case 654:
4568
		goto step_next;
4569
	case 655:
4570
		_wait();
4571
		_mread(cpu->pc++);
4572
		goto step_next;
4573
	case 656:
4574
		cpu->wzl = _gd();
4575
		goto step_next;
4576
	// -- mread
4577
	case 657:
4578
		goto step_next;
4579
	case 658:
4580
		_wait();
4581
		_mread(cpu->pc++);
4582
		goto step_next;
4583
	case 659:
4584
		cpu->wzh = _gd();
4585
		if(!_cc_nc) {
4586
			_skip(7);
4587
		};
4588
		goto step_next;
4589
	// -- generic
4590
	case 660:
4591
		goto step_next;
4592
	// -- mwrite
4593
	case 661:
4594
		goto step_next;
4595
	case 662:
4596
		_wait();
4597
		_mwrite(--cpu->sp, cpu->pch);
4598
		goto step_next;
4599
	case 663:
4600
		goto step_next;
4601
	// -- mwrite
4602
	case 664:
4603
		goto step_next;
4604
	case 665:
4605
		_wait();
4606
		_mwrite(--cpu->sp, cpu->pcl);
4607
		cpu->pc = cpu->wz;
4608
		goto step_next;
4609
	case 666:
4610
		goto step_next;
4611
	// -- overlapped
4612
	case 667:
4613
		goto fetch_next;
4614
 
4615
	//  D5: PUSH DE (M:4 T:11)
4616
	// -- generic
4617
	case 668:
4618
		goto step_next;
4619
	// -- mwrite
4620
	case 669:
4621
		goto step_next;
4622
	case 670:
4623
		_wait();
4624
		_mwrite(--cpu->sp, cpu->d);
4625
		goto step_next;
4626
	case 671:
4627
		goto step_next;
4628
	// -- mwrite
4629
	case 672:
4630
		goto step_next;
4631
	case 673:
4632
		_wait();
4633
		_mwrite(--cpu->sp, cpu->e);
4634
		goto step_next;
4635
	case 674:
4636
		goto step_next;
4637
	// -- overlapped
4638
	case 675:
4639
		goto fetch_next;
4640
 
4641
	//  D6: SUB n (M:2 T:7)
4642
	// -- mread
4643
	case 676:
4644
		goto step_next;
4645
	case 677:
4646
		_wait();
4647
		_mread(cpu->pc++);
4648
		goto step_next;
4649
	case 678:
4650
		cpu->dlatch = _gd();
4651
		goto step_next;
4652
	// -- overlapped
4653
	case 679:
4654
		_z80_sub8(cpu, cpu->dlatch);
4655
		goto fetch_next;
4656
 
4657
	//  D7: RST 10h (M:4 T:11)
4658
	// -- generic
4659
	case 680:
4660
		goto step_next;
4661
	// -- mwrite
4662
	case 681:
4663
		goto step_next;
4664
	case 682:
4665
		_wait();
4666
		_mwrite(--cpu->sp, cpu->pch);
4667
		goto step_next;
4668
	case 683:
4669
		goto step_next;
4670
	// -- mwrite
4671
	case 684:
4672
		goto step_next;
4673
	case 685:
4674
		_wait();
4675
		_mwrite(--cpu->sp, cpu->pcl);
4676
		cpu->wz = 0x10;
4677
		cpu->pc = cpu->wz;
4678
		goto step_next;
4679
	case 686:
4680
		goto step_next;
4681
	// -- overlapped
4682
	case 687:
4683
		goto fetch_next;
4684
 
4685
	//  D8: RET C (M:4 T:11)
4686
	// -- generic
4687
	case 688:
4688
		if(!_cc_c) {
4689
			_skip(6);
4690
		};
4691
		goto step_next;
4692
	// -- mread
4693
	case 689:
4694
		goto step_next;
4695
	case 690:
4696
		_wait();
4697
		_mread(cpu->sp++);
4698
		goto step_next;
4699
	case 691:
4700
		cpu->wzl = _gd();
4701
		goto step_next;
4702
	// -- mread
4703
	case 692:
4704
		goto step_next;
4705
	case 693:
4706
		_wait();
4707
		_mread(cpu->sp++);
4708
		goto step_next;
4709
	case 694:
4710
		cpu->wzh = _gd();
4711
		cpu->pc = cpu->wz;
4712
		goto step_next;
4713
	// -- overlapped
4714
	case 695:
4715
		goto fetch_next;
4716
 
4717
	//  D9: EXX (M:1 T:4)
4718
	// -- overlapped
4719
	case 696:
4720
		_z80_exx(cpu);
4721
		goto fetch_next;
4722
 
4723
	//  DA: JP C,nn (M:3 T:10)
4724
	// -- mread
4725
	case 697:
4726
		goto step_next;
4727
	case 698:
4728
		_wait();
4729
		_mread(cpu->pc++);
4730
		goto step_next;
4731
	case 699:
4732
		cpu->wzl = _gd();
4733
		goto step_next;
4734
	// -- mread
4735
	case 700:
4736
		goto step_next;
4737
	case 701:
4738
		_wait();
4739
		_mread(cpu->pc++);
4740
		goto step_next;
4741
	case 702:
4742
		cpu->wzh = _gd();
4743
		if(_cc_c) {
4744
			cpu->pc = cpu->wz;
4745
		};
4746
		goto step_next;
4747
	// -- overlapped
4748
	case 703:
4749
		goto fetch_next;
4750
 
4751
	//  DB: IN A,(n) (M:3 T:11)
4752
	// -- mread
4753
	case 704:
4754
		goto step_next;
4755
	case 705:
4756
		_wait();
4757
		_mread(cpu->pc++);
4758
		goto step_next;
4759
	case 706:
4760
		cpu->wzl = _gd();
4761
		cpu->wzh = cpu->a;
4762
		goto step_next;
4763
	// -- ioread
4764
	case 707:
4765
		goto step_next;
4766
	case 708:
4767
		goto step_next;
4768
	case 709:
4769
		_wait();
4770
		_ioread(cpu->wz++);
4771
		goto step_next;
4772
	case 710:
4773
		cpu->a = _gd();
4774
		goto step_next;
4775
	// -- overlapped
4776
	case 711:
4777
		goto fetch_next;
4778
 
4779
	//  DC: CALL C,nn (M:6 T:17)
4780
	// -- mread
4781
	case 712:
4782
		goto step_next;
4783
	case 713:
4784
		_wait();
4785
		_mread(cpu->pc++);
4786
		goto step_next;
4787
	case 714:
4788
		cpu->wzl = _gd();
4789
		goto step_next;
4790
	// -- mread
4791
	case 715:
4792
		goto step_next;
4793
	case 716:
4794
		_wait();
4795
		_mread(cpu->pc++);
4796
		goto step_next;
4797
	case 717:
4798
		cpu->wzh = _gd();
4799
		if(!_cc_c) {
4800
			_skip(7);
4801
		};
4802
		goto step_next;
4803
	// -- generic
4804
	case 718:
4805
		goto step_next;
4806
	// -- mwrite
4807
	case 719:
4808
		goto step_next;
4809
	case 720:
4810
		_wait();
4811
		_mwrite(--cpu->sp, cpu->pch);
4812
		goto step_next;
4813
	case 721:
4814
		goto step_next;
4815
	// -- mwrite
4816
	case 722:
4817
		goto step_next;
4818
	case 723:
4819
		_wait();
4820
		_mwrite(--cpu->sp, cpu->pcl);
4821
		cpu->pc = cpu->wz;
4822
		goto step_next;
4823
	case 724:
4824
		goto step_next;
4825
	// -- overlapped
4826
	case 725:
4827
		goto fetch_next;
4828
 
4829
	//  DD: DD prefix (M:1 T:4)
4830
	// -- overlapped
4831
	case 726:
4832
		_fetch_dd();
4833
		goto step_next;
4834
 
4835
	//  DE: SBC n (M:2 T:7)
4836
	// -- mread
4837
	case 727:
4838
		goto step_next;
4839
	case 728:
4840
		_wait();
4841
		_mread(cpu->pc++);
4842
		goto step_next;
4843
	case 729:
4844
		cpu->dlatch = _gd();
4845
		goto step_next;
4846
	// -- overlapped
4847
	case 730:
4848
		_z80_sbc8(cpu, cpu->dlatch);
4849
		goto fetch_next;
4850
 
4851
	//  DF: RST 18h (M:4 T:11)
4852
	// -- generic
4853
	case 731:
4854
		goto step_next;
4855
	// -- mwrite
4856
	case 732:
4857
		goto step_next;
4858
	case 733:
4859
		_wait();
4860
		_mwrite(--cpu->sp, cpu->pch);
4861
		goto step_next;
4862
	case 734:
4863
		goto step_next;
4864
	// -- mwrite
4865
	case 735:
4866
		goto step_next;
4867
	case 736:
4868
		_wait();
4869
		_mwrite(--cpu->sp, cpu->pcl);
4870
		cpu->wz = 0x18;
4871
		cpu->pc = cpu->wz;
4872
		goto step_next;
4873
	case 737:
4874
		goto step_next;
4875
	// -- overlapped
4876
	case 738:
4877
		goto fetch_next;
4878
 
4879
	//  E0: RET PO (M:4 T:11)
4880
	// -- generic
4881
	case 739:
4882
		if(!_cc_po) {
4883
			_skip(6);
4884
		};
4885
		goto step_next;
4886
	// -- mread
4887
	case 740:
4888
		goto step_next;
4889
	case 741:
4890
		_wait();
4891
		_mread(cpu->sp++);
4892
		goto step_next;
4893
	case 742:
4894
		cpu->wzl = _gd();
4895
		goto step_next;
4896
	// -- mread
4897
	case 743:
4898
		goto step_next;
4899
	case 744:
4900
		_wait();
4901
		_mread(cpu->sp++);
4902
		goto step_next;
4903
	case 745:
4904
		cpu->wzh = _gd();
4905
		cpu->pc = cpu->wz;
4906
		goto step_next;
4907
	// -- overlapped
4908
	case 746:
4909
		goto fetch_next;
4910
 
4911
	//  E1: POP HL (M:3 T:10)
4912
	// -- mread
4913
	case 747:
4914
		goto step_next;
4915
	case 748:
4916
		_wait();
4917
		_mread(cpu->sp++);
4918
		goto step_next;
4919
	case 749:
4920
		cpu->hlx[cpu->hlx_idx].l = _gd();
4921
		goto step_next;
4922
	// -- mread
4923
	case 750:
4924
		goto step_next;
4925
	case 751:
4926
		_wait();
4927
		_mread(cpu->sp++);
4928
		goto step_next;
4929
	case 752:
4930
		cpu->hlx[cpu->hlx_idx].h = _gd();
4931
		goto step_next;
4932
	// -- overlapped
4933
	case 753:
4934
		goto fetch_next;
4935
 
4936
	//  E2: JP PO,nn (M:3 T:10)
4937
	// -- mread
4938
	case 754:
4939
		goto step_next;
4940
	case 755:
4941
		_wait();
4942
		_mread(cpu->pc++);
4943
		goto step_next;
4944
	case 756:
4945
		cpu->wzl = _gd();
4946
		goto step_next;
4947
	// -- mread
4948
	case 757:
4949
		goto step_next;
4950
	case 758:
4951
		_wait();
4952
		_mread(cpu->pc++);
4953
		goto step_next;
4954
	case 759:
4955
		cpu->wzh = _gd();
4956
		if(_cc_po) {
4957
			cpu->pc = cpu->wz;
4958
		};
4959
		goto step_next;
4960
	// -- overlapped
4961
	case 760:
4962
		goto fetch_next;
4963
 
4964
	//  E3: EX (SP),HL (M:5 T:19)
4965
	// -- mread
4966
	case 761:
4967
		goto step_next;
4968
	case 762:
4969
		_wait();
4970
		_mread(cpu->sp);
4971
		goto step_next;
4972
	case 763:
4973
		cpu->wzl = _gd();
4974
		goto step_next;
4975
	// -- mread
4976
	case 764:
4977
		goto step_next;
4978
	case 765:
4979
		_wait();
4980
		_mread(cpu->sp + 1);
4981
		goto step_next;
4982
	case 766:
4983
		cpu->wzh = _gd();
4984
		goto step_next;
4985
	case 767:
4986
		goto step_next;
4987
	// -- mwrite
4988
	case 768:
4989
		goto step_next;
4990
	case 769:
4991
		_wait();
4992
		_mwrite(cpu->sp + 1, cpu->hlx[cpu->hlx_idx].h);
4993
		goto step_next;
4994
	case 770:
4995
		goto step_next;
4996
	// -- mwrite
4997
	case 771:
4998
		goto step_next;
4999
	case 772:
5000
		_wait();
5001
		_mwrite(cpu->sp, cpu->hlx[cpu->hlx_idx].l);
5002
		cpu->hlx[cpu->hlx_idx].hl = cpu->wz;
5003
		goto step_next;
5004
	case 773:
5005
		goto step_next;
5006
	case 774:
5007
		goto step_next;
5008
	case 775:
5009
		goto step_next;
5010
	// -- overlapped
5011
	case 776:
5012
		goto fetch_next;
5013
 
5014
	//  E4: CALL PO,nn (M:6 T:17)
5015
	// -- mread
5016
	case 777:
5017
		goto step_next;
5018
	case 778:
5019
		_wait();
5020
		_mread(cpu->pc++);
5021
		goto step_next;
5022
	case 779:
5023
		cpu->wzl = _gd();
5024
		goto step_next;
5025
	// -- mread
5026
	case 780:
5027
		goto step_next;
5028
	case 781:
5029
		_wait();
5030
		_mread(cpu->pc++);
5031
		goto step_next;
5032
	case 782:
5033
		cpu->wzh = _gd();
5034
		if(!_cc_po) {
5035
			_skip(7);
5036
		};
5037
		goto step_next;
5038
	// -- generic
5039
	case 783:
5040
		goto step_next;
5041
	// -- mwrite
5042
	case 784:
5043
		goto step_next;
5044
	case 785:
5045
		_wait();
5046
		_mwrite(--cpu->sp, cpu->pch);
5047
		goto step_next;
5048
	case 786:
5049
		goto step_next;
5050
	// -- mwrite
5051
	case 787:
5052
		goto step_next;
5053
	case 788:
5054
		_wait();
5055
		_mwrite(--cpu->sp, cpu->pcl);
5056
		cpu->pc = cpu->wz;
5057
		goto step_next;
5058
	case 789:
5059
		goto step_next;
5060
	// -- overlapped
5061
	case 790:
5062
		goto fetch_next;
5063
 
5064
	//  E5: PUSH HL (M:4 T:11)
5065
	// -- generic
5066
	case 791:
5067
		goto step_next;
5068
	// -- mwrite
5069
	case 792:
5070
		goto step_next;
5071
	case 793:
5072
		_wait();
5073
		_mwrite(--cpu->sp, cpu->hlx[cpu->hlx_idx].h);
5074
		goto step_next;
5075
	case 794:
5076
		goto step_next;
5077
	// -- mwrite
5078
	case 795:
5079
		goto step_next;
5080
	case 796:
5081
		_wait();
5082
		_mwrite(--cpu->sp, cpu->hlx[cpu->hlx_idx].l);
5083
		goto step_next;
5084
	case 797:
5085
		goto step_next;
5086
	// -- overlapped
5087
	case 798:
5088
		goto fetch_next;
5089
 
5090
	//  E6: AND n (M:2 T:7)
5091
	// -- mread
5092
	case 799:
5093
		goto step_next;
5094
	case 800:
5095
		_wait();
5096
		_mread(cpu->pc++);
5097
		goto step_next;
5098
	case 801:
5099
		cpu->dlatch = _gd();
5100
		goto step_next;
5101
	// -- overlapped
5102
	case 802:
5103
		_z80_and8(cpu, cpu->dlatch);
5104
		goto fetch_next;
5105
 
5106
	//  E7: RST 20h (M:4 T:11)
5107
	// -- generic
5108
	case 803:
5109
		goto step_next;
5110
	// -- mwrite
5111
	case 804:
5112
		goto step_next;
5113
	case 805:
5114
		_wait();
5115
		_mwrite(--cpu->sp, cpu->pch);
5116
		goto step_next;
5117
	case 806:
5118
		goto step_next;
5119
	// -- mwrite
5120
	case 807:
5121
		goto step_next;
5122
	case 808:
5123
		_wait();
5124
		_mwrite(--cpu->sp, cpu->pcl);
5125
		cpu->wz = 0x20;
5126
		cpu->pc = cpu->wz;
5127
		goto step_next;
5128
	case 809:
5129
		goto step_next;
5130
	// -- overlapped
5131
	case 810:
5132
		goto fetch_next;
5133
 
5134
	//  E8: RET PE (M:4 T:11)
5135
	// -- generic
5136
	case 811:
5137
		if(!_cc_pe) {
5138
			_skip(6);
5139
		};
5140
		goto step_next;
5141
	// -- mread
5142
	case 812:
5143
		goto step_next;
5144
	case 813:
5145
		_wait();
5146
		_mread(cpu->sp++);
5147
		goto step_next;
5148
	case 814:
5149
		cpu->wzl = _gd();
5150
		goto step_next;
5151
	// -- mread
5152
	case 815:
5153
		goto step_next;
5154
	case 816:
5155
		_wait();
5156
		_mread(cpu->sp++);
5157
		goto step_next;
5158
	case 817:
5159
		cpu->wzh = _gd();
5160
		cpu->pc = cpu->wz;
5161
		goto step_next;
5162
	// -- overlapped
5163
	case 818:
5164
		goto fetch_next;
5165
 
5166
	//  E9: JP HL (M:1 T:4)
5167
	// -- overlapped
5168
	case 819:
5169
		cpu->pc = cpu->hlx[cpu->hlx_idx].hl;
5170
		goto fetch_next;
5171
 
5172
	//  EA: JP PE,nn (M:3 T:10)
5173
	// -- mread
5174
	case 820:
5175
		goto step_next;
5176
	case 821:
5177
		_wait();
5178
		_mread(cpu->pc++);
5179
		goto step_next;
5180
	case 822:
5181
		cpu->wzl = _gd();
5182
		goto step_next;
5183
	// -- mread
5184
	case 823:
5185
		goto step_next;
5186
	case 824:
5187
		_wait();
5188
		_mread(cpu->pc++);
5189
		goto step_next;
5190
	case 825:
5191
		cpu->wzh = _gd();
5192
		if(_cc_pe) {
5193
			cpu->pc = cpu->wz;
5194
		};
5195
		goto step_next;
5196
	// -- overlapped
5197
	case 826:
5198
		goto fetch_next;
5199
 
5200
	//  EB: EX DE,HL (M:1 T:4)
5201
	// -- overlapped
5202
	case 827:
5203
		_z80_ex_de_hl(cpu);
5204
		goto fetch_next;
5205
 
5206
	//  EC: CALL PE,nn (M:6 T:17)
5207
	// -- mread
5208
	case 828:
5209
		goto step_next;
5210
	case 829:
5211
		_wait();
5212
		_mread(cpu->pc++);
5213
		goto step_next;
5214
	case 830:
5215
		cpu->wzl = _gd();
5216
		goto step_next;
5217
	// -- mread
5218
	case 831:
5219
		goto step_next;
5220
	case 832:
5221
		_wait();
5222
		_mread(cpu->pc++);
5223
		goto step_next;
5224
	case 833:
5225
		cpu->wzh = _gd();
5226
		if(!_cc_pe) {
5227
			_skip(7);
5228
		};
5229
		goto step_next;
5230
	// -- generic
5231
	case 834:
5232
		goto step_next;
5233
	// -- mwrite
5234
	case 835:
5235
		goto step_next;
5236
	case 836:
5237
		_wait();
5238
		_mwrite(--cpu->sp, cpu->pch);
5239
		goto step_next;
5240
	case 837:
5241
		goto step_next;
5242
	// -- mwrite
5243
	case 838:
5244
		goto step_next;
5245
	case 839:
5246
		_wait();
5247
		_mwrite(--cpu->sp, cpu->pcl);
5248
		cpu->pc = cpu->wz;
5249
		goto step_next;
5250
	case 840:
5251
		goto step_next;
5252
	// -- overlapped
5253
	case 841:
5254
		goto fetch_next;
5255
 
5256
	//  ED: ED prefix (M:1 T:4)
5257
	// -- overlapped
5258
	case 842:
5259
		_fetch_ed();
5260
		goto step_next;
5261
 
5262
	//  EE: XOR n (M:2 T:7)
5263
	// -- mread
5264
	case 843:
5265
		goto step_next;
5266
	case 844:
5267
		_wait();
5268
		_mread(cpu->pc++);
5269
		goto step_next;
5270
	case 845:
5271
		cpu->dlatch = _gd();
5272
		goto step_next;
5273
	// -- overlapped
5274
	case 846:
5275
		_z80_xor8(cpu, cpu->dlatch);
5276
		goto fetch_next;
5277
 
5278
	//  EF: RST 28h (M:4 T:11)
5279
	// -- generic
5280
	case 847:
5281
		goto step_next;
5282
	// -- mwrite
5283
	case 848:
5284
		goto step_next;
5285
	case 849:
5286
		_wait();
5287
		_mwrite(--cpu->sp, cpu->pch);
5288
		goto step_next;
5289
	case 850:
5290
		goto step_next;
5291
	// -- mwrite
5292
	case 851:
5293
		goto step_next;
5294
	case 852:
5295
		_wait();
5296
		_mwrite(--cpu->sp, cpu->pcl);
5297
		cpu->wz = 0x28;
5298
		cpu->pc = cpu->wz;
5299
		goto step_next;
5300
	case 853:
5301
		goto step_next;
5302
	// -- overlapped
5303
	case 854:
5304
		goto fetch_next;
5305
 
5306
	//  F0: RET P (M:4 T:11)
5307
	// -- generic
5308
	case 855:
5309
		if(!_cc_p) {
5310
			_skip(6);
5311
		};
5312
		goto step_next;
5313
	// -- mread
5314
	case 856:
5315
		goto step_next;
5316
	case 857:
5317
		_wait();
5318
		_mread(cpu->sp++);
5319
		goto step_next;
5320
	case 858:
5321
		cpu->wzl = _gd();
5322
		goto step_next;
5323
	// -- mread
5324
	case 859:
5325
		goto step_next;
5326
	case 860:
5327
		_wait();
5328
		_mread(cpu->sp++);
5329
		goto step_next;
5330
	case 861:
5331
		cpu->wzh = _gd();
5332
		cpu->pc = cpu->wz;
5333
		goto step_next;
5334
	// -- overlapped
5335
	case 862:
5336
		goto fetch_next;
5337
 
5338
	//  F1: POP AF (M:3 T:10)
5339
	// -- mread
5340
	case 863:
5341
		goto step_next;
5342
	case 864:
5343
		_wait();
5344
		_mread(cpu->sp++);
5345
		goto step_next;
5346
	case 865:
5347
		cpu->f = _gd();
5348
		goto step_next;
5349
	// -- mread
5350
	case 866:
5351
		goto step_next;
5352
	case 867:
5353
		_wait();
5354
		_mread(cpu->sp++);
5355
		goto step_next;
5356
	case 868:
5357
		cpu->a = _gd();
5358
		goto step_next;
5359
	// -- overlapped
5360
	case 869:
5361
		goto fetch_next;
5362
 
5363
	//  F2: JP P,nn (M:3 T:10)
5364
	// -- mread
5365
	case 870:
5366
		goto step_next;
5367
	case 871:
5368
		_wait();
5369
		_mread(cpu->pc++);
5370
		goto step_next;
5371
	case 872:
5372
		cpu->wzl = _gd();
5373
		goto step_next;
5374
	// -- mread
5375
	case 873:
5376
		goto step_next;
5377
	case 874:
5378
		_wait();
5379
		_mread(cpu->pc++);
5380
		goto step_next;
5381
	case 875:
5382
		cpu->wzh = _gd();
5383
		if(_cc_p) {
5384
			cpu->pc = cpu->wz;
5385
		};
5386
		goto step_next;
5387
	// -- overlapped
5388
	case 876:
5389
		goto fetch_next;
5390
 
5391
	//  F3: DI (M:1 T:4)
5392
	// -- overlapped
5393
	case 877:
5394
		cpu->iff1 = cpu->iff2 = false;
5395
		goto fetch_next;
5396
 
5397
	//  F4: CALL P,nn (M:6 T:17)
5398
	// -- mread
5399
	case 878:
5400
		goto step_next;
5401
	case 879:
5402
		_wait();
5403
		_mread(cpu->pc++);
5404
		goto step_next;
5405
	case 880:
5406
		cpu->wzl = _gd();
5407
		goto step_next;
5408
	// -- mread
5409
	case 881:
5410
		goto step_next;
5411
	case 882:
5412
		_wait();
5413
		_mread(cpu->pc++);
5414
		goto step_next;
5415
	case 883:
5416
		cpu->wzh = _gd();
5417
		if(!_cc_p) {
5418
			_skip(7);
5419
		};
5420
		goto step_next;
5421
	// -- generic
5422
	case 884:
5423
		goto step_next;
5424
	// -- mwrite
5425
	case 885:
5426
		goto step_next;
5427
	case 886:
5428
		_wait();
5429
		_mwrite(--cpu->sp, cpu->pch);
5430
		goto step_next;
5431
	case 887:
5432
		goto step_next;
5433
	// -- mwrite
5434
	case 888:
5435
		goto step_next;
5436
	case 889:
5437
		_wait();
5438
		_mwrite(--cpu->sp, cpu->pcl);
5439
		cpu->pc = cpu->wz;
5440
		goto step_next;
5441
	case 890:
5442
		goto step_next;
5443
	// -- overlapped
5444
	case 891:
5445
		goto fetch_next;
5446
 
5447
	//  F5: PUSH AF (M:4 T:11)
5448
	// -- generic
5449
	case 892:
5450
		goto step_next;
5451
	// -- mwrite
5452
	case 893:
5453
		goto step_next;
5454
	case 894:
5455
		_wait();
5456
		_mwrite(--cpu->sp, cpu->a);
5457
		goto step_next;
5458
	case 895:
5459
		goto step_next;
5460
	// -- mwrite
5461
	case 896:
5462
		goto step_next;
5463
	case 897:
5464
		_wait();
5465
		_mwrite(--cpu->sp, cpu->f);
5466
		goto step_next;
5467
	case 898:
5468
		goto step_next;
5469
	// -- overlapped
5470
	case 899:
5471
		goto fetch_next;
5472
 
5473
	//  F6: OR n (M:2 T:7)
5474
	// -- mread
5475
	case 900:
5476
		goto step_next;
5477
	case 901:
5478
		_wait();
5479
		_mread(cpu->pc++);
5480
		goto step_next;
5481
	case 902:
5482
		cpu->dlatch = _gd();
5483
		goto step_next;
5484
	// -- overlapped
5485
	case 903:
5486
		_z80_or8(cpu, cpu->dlatch);
5487
		goto fetch_next;
5488
 
5489
	//  F7: RST 30h (M:4 T:11)
5490
	// -- generic
5491
	case 904:
5492
		goto step_next;
5493
	// -- mwrite
5494
	case 905:
5495
		goto step_next;
5496
	case 906:
5497
		_wait();
5498
		_mwrite(--cpu->sp, cpu->pch);
5499
		goto step_next;
5500
	case 907:
5501
		goto step_next;
5502
	// -- mwrite
5503
	case 908:
5504
		goto step_next;
5505
	case 909:
5506
		_wait();
5507
		_mwrite(--cpu->sp, cpu->pcl);
5508
		cpu->wz = 0x30;
5509
		cpu->pc = cpu->wz;
5510
		goto step_next;
5511
	case 910:
5512
		goto step_next;
5513
	// -- overlapped
5514
	case 911:
5515
		goto fetch_next;
5516
 
5517
	//  F8: RET M (M:4 T:11)
5518
	// -- generic
5519
	case 912:
5520
		if(!_cc_m) {
5521
			_skip(6);
5522
		};
5523
		goto step_next;
5524
	// -- mread
5525
	case 913:
5526
		goto step_next;
5527
	case 914:
5528
		_wait();
5529
		_mread(cpu->sp++);
5530
		goto step_next;
5531
	case 915:
5532
		cpu->wzl = _gd();
5533
		goto step_next;
5534
	// -- mread
5535
	case 916:
5536
		goto step_next;
5537
	case 917:
5538
		_wait();
5539
		_mread(cpu->sp++);
5540
		goto step_next;
5541
	case 918:
5542
		cpu->wzh = _gd();
5543
		cpu->pc = cpu->wz;
5544
		goto step_next;
5545
	// -- overlapped
5546
	case 919:
5547
		goto fetch_next;
5548
 
5549
	//  F9: LD SP,HL (M:2 T:6)
5550
	// -- generic
5551
	case 920:
5552
		cpu->sp = cpu->hlx[cpu->hlx_idx].hl;
5553
		goto step_next;
5554
	case 921:
5555
		goto step_next;
5556
	// -- overlapped
5557
	case 922:
5558
		goto fetch_next;
5559
 
5560
	//  FA: JP M,nn (M:3 T:10)
5561
	// -- mread
5562
	case 923:
5563
		goto step_next;
5564
	case 924:
5565
		_wait();
5566
		_mread(cpu->pc++);
5567
		goto step_next;
5568
	case 925:
5569
		cpu->wzl = _gd();
5570
		goto step_next;
5571
	// -- mread
5572
	case 926:
5573
		goto step_next;
5574
	case 927:
5575
		_wait();
5576
		_mread(cpu->pc++);
5577
		goto step_next;
5578
	case 928:
5579
		cpu->wzh = _gd();
5580
		if(_cc_m) {
5581
			cpu->pc = cpu->wz;
5582
		};
5583
		goto step_next;
5584
	// -- overlapped
5585
	case 929:
5586
		goto fetch_next;
5587
 
5588
	//  FB: EI (M:1 T:4)
5589
	// -- overlapped
5590
	case 930:
5591
		cpu->iff1 = cpu->iff2 = false;
5592
		pins = _z80_fetch(cpu, pins);
5593
		cpu->iff1 = cpu->iff2 = true;
5594
		goto step_next;
5595
 
5596
	//  FC: CALL M,nn (M:6 T:17)
5597
	// -- mread
5598
	case 931:
5599
		goto step_next;
5600
	case 932:
5601
		_wait();
5602
		_mread(cpu->pc++);
5603
		goto step_next;
5604
	case 933:
5605
		cpu->wzl = _gd();
5606
		goto step_next;
5607
	// -- mread
5608
	case 934:
5609
		goto step_next;
5610
	case 935:
5611
		_wait();
5612
		_mread(cpu->pc++);
5613
		goto step_next;
5614
	case 936:
5615
		cpu->wzh = _gd();
5616
		if(!_cc_m) {
5617
			_skip(7);
5618
		};
5619
		goto step_next;
5620
	// -- generic
5621
	case 937:
5622
		goto step_next;
5623
	// -- mwrite
5624
	case 938:
5625
		goto step_next;
5626
	case 939:
5627
		_wait();
5628
		_mwrite(--cpu->sp, cpu->pch);
5629
		goto step_next;
5630
	case 940:
5631
		goto step_next;
5632
	// -- mwrite
5633
	case 941:
5634
		goto step_next;
5635
	case 942:
5636
		_wait();
5637
		_mwrite(--cpu->sp, cpu->pcl);
5638
		cpu->pc = cpu->wz;
5639
		goto step_next;
5640
	case 943:
5641
		goto step_next;
5642
	// -- overlapped
5643
	case 944:
5644
		goto fetch_next;
5645
 
5646
	//  FD: FD prefix (M:1 T:4)
5647
	// -- overlapped
5648
	case 945:
5649
		_fetch_fd();
5650
		goto step_next;
5651
 
5652
	//  FE: CP n (M:2 T:7)
5653
	// -- mread
5654
	case 946:
5655
		goto step_next;
5656
	case 947:
5657
		_wait();
5658
		_mread(cpu->pc++);
5659
		goto step_next;
5660
	case 948:
5661
		cpu->dlatch = _gd();
5662
		goto step_next;
5663
	// -- overlapped
5664
	case 949:
5665
		_z80_cp8(cpu, cpu->dlatch);
5666
		goto fetch_next;
5667
 
5668
	//  FF: RST 38h (M:4 T:11)
5669
	// -- generic
5670
	case 950:
5671
		goto step_next;
5672
	// -- mwrite
5673
	case 951:
5674
		goto step_next;
5675
	case 952:
5676
		_wait();
5677
		_mwrite(--cpu->sp, cpu->pch);
5678
		goto step_next;
5679
	case 953:
5680
		goto step_next;
5681
	// -- mwrite
5682
	case 954:
5683
		goto step_next;
5684
	case 955:
5685
		_wait();
5686
		_mwrite(--cpu->sp, cpu->pcl);
5687
		cpu->wz = 0x38;
5688
		cpu->pc = cpu->wz;
5689
		goto step_next;
5690
	case 956:
5691
		goto step_next;
5692
	// -- overlapped
5693
	case 957:
5694
		goto fetch_next;
5695
 
5696
	// ED 00: ED NOP (M:1 T:4)
5697
	// -- overlapped
5698
	case 958:
5699
		goto fetch_next;
5700
 
5701
	// ED 40: IN B,(C) (M:2 T:8)
5702
	// -- ioread
5703
	case 959:
5704
		goto step_next;
5705
	case 960:
5706
		goto step_next;
5707
	case 961:
5708
		_wait();
5709
		_ioread(cpu->bc);
5710
		goto step_next;
5711
	case 962:
5712
		cpu->dlatch = _gd();
5713
		cpu->wz = cpu->bc + 1;
5714
		goto step_next;
5715
	// -- overlapped
5716
	case 963:
5717
		cpu->b = _z80_in(cpu, cpu->dlatch);
5718
		goto fetch_next;
5719
 
5720
	// ED 41: OUT (C),B (M:2 T:8)
5721
	// -- iowrite
5722
	case 964:
5723
		goto step_next;
5724
	case 965:
5725
		_iowrite(cpu->bc, cpu->b);
5726
		goto step_next;
5727
	case 966:
5728
		_wait();
5729
		cpu->wz = cpu->bc + 1;
5730
		goto step_next;
5731
	case 967:
5732
		goto step_next;
5733
	// -- overlapped
5734
	case 968:
5735
		goto fetch_next;
5736
 
5737
	// ED 42: SBC HL,BC (M:2 T:11)
5738
	// -- generic
5739
	case 969:
5740
		_z80_sbc16(cpu, cpu->bc);
5741
		goto step_next;
5742
	case 970:
5743
		goto step_next;
5744
	case 971:
5745
		goto step_next;
5746
	case 972:
5747
		goto step_next;
5748
	case 973:
5749
		goto step_next;
5750
	case 974:
5751
		goto step_next;
5752
	case 975:
5753
		goto step_next;
5754
	// -- overlapped
5755
	case 976:
5756
		goto fetch_next;
5757
 
5758
	// ED 43: LD (nn),BC (M:5 T:16)
5759
	// -- mread
5760
	case 977:
5761
		goto step_next;
5762
	case 978:
5763
		_wait();
5764
		_mread(cpu->pc++);
5765
		goto step_next;
5766
	case 979:
5767
		cpu->wzl = _gd();
5768
		goto step_next;
5769
	// -- mread
5770
	case 980:
5771
		goto step_next;
5772
	case 981:
5773
		_wait();
5774
		_mread(cpu->pc++);
5775
		goto step_next;
5776
	case 982:
5777
		cpu->wzh = _gd();
5778
		goto step_next;
5779
	// -- mwrite
5780
	case 983:
5781
		goto step_next;
5782
	case 984:
5783
		_wait();
5784
		_mwrite(cpu->wz++, cpu->c);
5785
		goto step_next;
5786
	case 985:
5787
		goto step_next;
5788
	// -- mwrite
5789
	case 986:
5790
		goto step_next;
5791
	case 987:
5792
		_wait();
5793
		_mwrite(cpu->wz, cpu->b);
5794
		goto step_next;
5795
	case 988:
5796
		goto step_next;
5797
	// -- overlapped
5798
	case 989:
5799
		goto fetch_next;
5800
 
5801
	// ED 44: NEG (M:1 T:4)
5802
	// -- overlapped
5803
	case 990:
5804
		_z80_neg8(cpu);
5805
		goto fetch_next;
5806
 
5807
	// ED 45: RETN (M:3 T:10)
5808
	// -- mread
5809
	case 991:
5810
		goto step_next;
5811
	case 992:
5812
		_wait();
5813
		_mread(cpu->sp++);
5814
		goto step_next;
5815
	case 993:
5816
		cpu->wzl = _gd();
5817
		goto step_next;
5818
	// -- mread
5819
	case 994:
5820
		goto step_next;
5821
	case 995:
5822
		_wait();
5823
		_mread(cpu->sp++);
5824
		goto step_next;
5825
	case 996:
5826
		cpu->wzh = _gd();
5827
		cpu->pc = cpu->wz;
5828
		goto step_next;
5829
	// -- overlapped
5830
	case 997:
5831
		pins = _z80_fetch(cpu, pins);
5832
		cpu->iff1 = cpu->iff2;
5833
		goto step_next;
5834
 
5835
	// ED 46: IM 0 (M:1 T:4)
5836
	// -- overlapped
5837
	case 998:
5838
		cpu->im = 0;
5839
		goto fetch_next;
5840
 
5841
	// ED 47: LD I,A (M:2 T:5)
5842
	// -- generic
5843
	case 999:
5844
		goto step_next;
5845
	// -- overlapped
5846
	case 1000:
5847
		cpu->i = cpu->a;
5848
		goto fetch_next;
5849
 
5850
	// ED 48: IN C,(C) (M:2 T:8)
5851
	// -- ioread
5852
	case 1001:
5853
		goto step_next;
5854
	case 1002:
5855
		goto step_next;
5856
	case 1003:
5857
		_wait();
5858
		_ioread(cpu->bc);
5859
		goto step_next;
5860
	case 1004:
5861
		cpu->dlatch = _gd();
5862
		cpu->wz = cpu->bc + 1;
5863
		goto step_next;
5864
	// -- overlapped
5865
	case 1005:
5866
		cpu->c = _z80_in(cpu, cpu->dlatch);
5867
		goto fetch_next;
5868
 
5869
	// ED 49: OUT (C),C (M:2 T:8)
5870
	// -- iowrite
5871
	case 1006:
5872
		goto step_next;
5873
	case 1007:
5874
		_iowrite(cpu->bc, cpu->c);
5875
		goto step_next;
5876
	case 1008:
5877
		_wait();
5878
		cpu->wz = cpu->bc + 1;
5879
		goto step_next;
5880
	case 1009:
5881
		goto step_next;
5882
	// -- overlapped
5883
	case 1010:
5884
		goto fetch_next;
5885
 
5886
	// ED 4A: ADC HL,BC (M:2 T:11)
5887
	// -- generic
5888
	case 1011:
5889
		_z80_adc16(cpu, cpu->bc);
5890
		goto step_next;
5891
	case 1012:
5892
		goto step_next;
5893
	case 1013:
5894
		goto step_next;
5895
	case 1014:
5896
		goto step_next;
5897
	case 1015:
5898
		goto step_next;
5899
	case 1016:
5900
		goto step_next;
5901
	case 1017:
5902
		goto step_next;
5903
	// -- overlapped
5904
	case 1018:
5905
		goto fetch_next;
5906
 
5907
	// ED 4B: LD BC,(nn) (M:5 T:16)
5908
	// -- mread
5909
	case 1019:
5910
		goto step_next;
5911
	case 1020:
5912
		_wait();
5913
		_mread(cpu->pc++);
5914
		goto step_next;
5915
	case 1021:
5916
		cpu->wzl = _gd();
5917
		goto step_next;
5918
	// -- mread
5919
	case 1022:
5920
		goto step_next;
5921
	case 1023:
5922
		_wait();
5923
		_mread(cpu->pc++);
5924
		goto step_next;
5925
	case 1024:
5926
		cpu->wzh = _gd();
5927
		goto step_next;
5928
	// -- mread
5929
	case 1025:
5930
		goto step_next;
5931
	case 1026:
5932
		_wait();
5933
		_mread(cpu->wz++);
5934
		goto step_next;
5935
	case 1027:
5936
		cpu->c = _gd();
5937
		goto step_next;
5938
	// -- mread
5939
	case 1028:
5940
		goto step_next;
5941
	case 1029:
5942
		_wait();
5943
		_mread(cpu->wz);
5944
		goto step_next;
5945
	case 1030:
5946
		cpu->b = _gd();
5947
		goto step_next;
5948
	// -- overlapped
5949
	case 1031:
5950
		goto fetch_next;
5951
 
5952
	// ED 4D: RETI (M:3 T:10)
5953
	// -- mread
5954
	case 1032:
5955
		goto step_next;
5956
	case 1033:
5957
		_wait();
5958
		_mread(cpu->sp++);
5959
		goto step_next;
5960
	case 1034:
5961
		cpu->wzl = _gd();
5962
		pins |= Z80_RETI;
5963
		goto step_next;
5964
	// -- mread
5965
	case 1035:
5966
		goto step_next;
5967
	case 1036:
5968
		_wait();
5969
		_mread(cpu->sp++);
5970
		goto step_next;
5971
	case 1037:
5972
		cpu->wzh = _gd();
5973
		cpu->pc = cpu->wz;
5974
		goto step_next;
5975
	// -- overlapped
5976
	case 1038:
5977
		pins = _z80_fetch(cpu, pins);
5978
		cpu->iff1 = cpu->iff2;
5979
		goto step_next;
5980
 
5981
	// ED 4E: IM 0 (M:1 T:4)
5982
	// -- overlapped
5983
	case 1039:
5984
		cpu->im = 0;
5985
		goto fetch_next;
5986
 
5987
	// ED 4F: LD R,A (M:2 T:5)
5988
	// -- generic
5989
	case 1040:
5990
		goto step_next;
5991
	// -- overlapped
5992
	case 1041:
5993
		cpu->r = cpu->a;
5994
		goto fetch_next;
5995
 
5996
	// ED 50: IN D,(C) (M:2 T:8)
5997
	// -- ioread
5998
	case 1042:
5999
		goto step_next;
6000
	case 1043:
6001
		goto step_next;
6002
	case 1044:
6003
		_wait();
6004
		_ioread(cpu->bc);
6005
		goto step_next;
6006
	case 1045:
6007
		cpu->dlatch = _gd();
6008
		cpu->wz = cpu->bc + 1;
6009
		goto step_next;
6010
	// -- overlapped
6011
	case 1046:
6012
		cpu->d = _z80_in(cpu, cpu->dlatch);
6013
		goto fetch_next;
6014
 
6015
	// ED 51: OUT (C),D (M:2 T:8)
6016
	// -- iowrite
6017
	case 1047:
6018
		goto step_next;
6019
	case 1048:
6020
		_iowrite(cpu->bc, cpu->d);
6021
		goto step_next;
6022
	case 1049:
6023
		_wait();
6024
		cpu->wz = cpu->bc + 1;
6025
		goto step_next;
6026
	case 1050:
6027
		goto step_next;
6028
	// -- overlapped
6029
	case 1051:
6030
		goto fetch_next;
6031
 
6032
	// ED 52: SBC HL,DE (M:2 T:11)
6033
	// -- generic
6034
	case 1052:
6035
		_z80_sbc16(cpu, cpu->de);
6036
		goto step_next;
6037
	case 1053:
6038
		goto step_next;
6039
	case 1054:
6040
		goto step_next;
6041
	case 1055:
6042
		goto step_next;
6043
	case 1056:
6044
		goto step_next;
6045
	case 1057:
6046
		goto step_next;
6047
	case 1058:
6048
		goto step_next;
6049
	// -- overlapped
6050
	case 1059:
6051
		goto fetch_next;
6052
 
6053
	// ED 53: LD (nn),DE (M:5 T:16)
6054
	// -- mread
6055
	case 1060:
6056
		goto step_next;
6057
	case 1061:
6058
		_wait();
6059
		_mread(cpu->pc++);
6060
		goto step_next;
6061
	case 1062:
6062
		cpu->wzl = _gd();
6063
		goto step_next;
6064
	// -- mread
6065
	case 1063:
6066
		goto step_next;
6067
	case 1064:
6068
		_wait();
6069
		_mread(cpu->pc++);
6070
		goto step_next;
6071
	case 1065:
6072
		cpu->wzh = _gd();
6073
		goto step_next;
6074
	// -- mwrite
6075
	case 1066:
6076
		goto step_next;
6077
	case 1067:
6078
		_wait();
6079
		_mwrite(cpu->wz++, cpu->e);
6080
		goto step_next;
6081
	case 1068:
6082
		goto step_next;
6083
	// -- mwrite
6084
	case 1069:
6085
		goto step_next;
6086
	case 1070:
6087
		_wait();
6088
		_mwrite(cpu->wz, cpu->d);
6089
		goto step_next;
6090
	case 1071:
6091
		goto step_next;
6092
	// -- overlapped
6093
	case 1072:
6094
		goto fetch_next;
6095
 
6096
	// ED 56: IM 1 (M:1 T:4)
6097
	// -- overlapped
6098
	case 1073:
6099
		cpu->im = 1;
6100
		goto fetch_next;
6101
 
6102
	// ED 57: LD A,I (M:2 T:5)
6103
	// -- generic
6104
	case 1074:
6105
		goto step_next;
6106
	// -- overlapped
6107
	case 1075:
6108
		cpu->a = cpu->i;
6109
		cpu->f = _z80_sziff2_flags(cpu, cpu->i);
6110
		goto fetch_next;
6111
 
6112
	// ED 58: IN E,(C) (M:2 T:8)
6113
	// -- ioread
6114
	case 1076:
6115
		goto step_next;
6116
	case 1077:
6117
		goto step_next;
6118
	case 1078:
6119
		_wait();
6120
		_ioread(cpu->bc);
6121
		goto step_next;
6122
	case 1079:
6123
		cpu->dlatch = _gd();
6124
		cpu->wz = cpu->bc + 1;
6125
		goto step_next;
6126
	// -- overlapped
6127
	case 1080:
6128
		cpu->e = _z80_in(cpu, cpu->dlatch);
6129
		goto fetch_next;
6130
 
6131
	// ED 59: OUT (C),E (M:2 T:8)
6132
	// -- iowrite
6133
	case 1081:
6134
		goto step_next;
6135
	case 1082:
6136
		_iowrite(cpu->bc, cpu->e);
6137
		goto step_next;
6138
	case 1083:
6139
		_wait();
6140
		cpu->wz = cpu->bc + 1;
6141
		goto step_next;
6142
	case 1084:
6143
		goto step_next;
6144
	// -- overlapped
6145
	case 1085:
6146
		goto fetch_next;
6147
 
6148
	// ED 5A: ADC HL,DE (M:2 T:11)
6149
	// -- generic
6150
	case 1086:
6151
		_z80_adc16(cpu, cpu->de);
6152
		goto step_next;
6153
	case 1087:
6154
		goto step_next;
6155
	case 1088:
6156
		goto step_next;
6157
	case 1089:
6158
		goto step_next;
6159
	case 1090:
6160
		goto step_next;
6161
	case 1091:
6162
		goto step_next;
6163
	case 1092:
6164
		goto step_next;
6165
	// -- overlapped
6166
	case 1093:
6167
		goto fetch_next;
6168
 
6169
	// ED 5B: LD DE,(nn) (M:5 T:16)
6170
	// -- mread
6171
	case 1094:
6172
		goto step_next;
6173
	case 1095:
6174
		_wait();
6175
		_mread(cpu->pc++);
6176
		goto step_next;
6177
	case 1096:
6178
		cpu->wzl = _gd();
6179
		goto step_next;
6180
	// -- mread
6181
	case 1097:
6182
		goto step_next;
6183
	case 1098:
6184
		_wait();
6185
		_mread(cpu->pc++);
6186
		goto step_next;
6187
	case 1099:
6188
		cpu->wzh = _gd();
6189
		goto step_next;
6190
	// -- mread
6191
	case 1100:
6192
		goto step_next;
6193
	case 1101:
6194
		_wait();
6195
		_mread(cpu->wz++);
6196
		goto step_next;
6197
	case 1102:
6198
		cpu->e = _gd();
6199
		goto step_next;
6200
	// -- mread
6201
	case 1103:
6202
		goto step_next;
6203
	case 1104:
6204
		_wait();
6205
		_mread(cpu->wz);
6206
		goto step_next;
6207
	case 1105:
6208
		cpu->d = _gd();
6209
		goto step_next;
6210
	// -- overlapped
6211
	case 1106:
6212
		goto fetch_next;
6213
 
6214
	// ED 5E: IM 2 (M:1 T:4)
6215
	// -- overlapped
6216
	case 1107:
6217
		cpu->im = 2;
6218
		goto fetch_next;
6219
 
6220
	// ED 5F: LD A,R (M:2 T:5)
6221
	// -- generic
6222
	case 1108:
6223
		goto step_next;
6224
	// -- overlapped
6225
	case 1109:
6226
		cpu->a = cpu->r;
6227
		cpu->f = _z80_sziff2_flags(cpu, cpu->r);
6228
		goto fetch_next;
6229
 
6230
	// ED 60: IN H,(C) (M:2 T:8)
6231
	// -- ioread
6232
	case 1110:
6233
		goto step_next;
6234
	case 1111:
6235
		goto step_next;
6236
	case 1112:
6237
		_wait();
6238
		_ioread(cpu->bc);
6239
		goto step_next;
6240
	case 1113:
6241
		cpu->dlatch = _gd();
6242
		cpu->wz = cpu->bc + 1;
6243
		goto step_next;
6244
	// -- overlapped
6245
	case 1114:
6246
		cpu->h = _z80_in(cpu, cpu->dlatch);
6247
		goto fetch_next;
6248
 
6249
	// ED 61: OUT (C),H (M:2 T:8)
6250
	// -- iowrite
6251
	case 1115:
6252
		goto step_next;
6253
	case 1116:
6254
		_iowrite(cpu->bc, cpu->h);
6255
		goto step_next;
6256
	case 1117:
6257
		_wait();
6258
		cpu->wz = cpu->bc + 1;
6259
		goto step_next;
6260
	case 1118:
6261
		goto step_next;
6262
	// -- overlapped
6263
	case 1119:
6264
		goto fetch_next;
6265
 
6266
	// ED 62: SBC HL,HL (M:2 T:11)
6267
	// -- generic
6268
	case 1120:
6269
		_z80_sbc16(cpu, cpu->hl);
6270
		goto step_next;
6271
	case 1121:
6272
		goto step_next;
6273
	case 1122:
6274
		goto step_next;
6275
	case 1123:
6276
		goto step_next;
6277
	case 1124:
6278
		goto step_next;
6279
	case 1125:
6280
		goto step_next;
6281
	case 1126:
6282
		goto step_next;
6283
	// -- overlapped
6284
	case 1127:
6285
		goto fetch_next;
6286
 
6287
	// ED 63: LD (nn),HL (M:5 T:16)
6288
	// -- mread
6289
	case 1128:
6290
		goto step_next;
6291
	case 1129:
6292
		_wait();
6293
		_mread(cpu->pc++);
6294
		goto step_next;
6295
	case 1130:
6296
		cpu->wzl = _gd();
6297
		goto step_next;
6298
	// -- mread
6299
	case 1131:
6300
		goto step_next;
6301
	case 1132:
6302
		_wait();
6303
		_mread(cpu->pc++);
6304
		goto step_next;
6305
	case 1133:
6306
		cpu->wzh = _gd();
6307
		goto step_next;
6308
	// -- mwrite
6309
	case 1134:
6310
		goto step_next;
6311
	case 1135:
6312
		_wait();
6313
		_mwrite(cpu->wz++, cpu->l);
6314
		goto step_next;
6315
	case 1136:
6316
		goto step_next;
6317
	// -- mwrite
6318
	case 1137:
6319
		goto step_next;
6320
	case 1138:
6321
		_wait();
6322
		_mwrite(cpu->wz, cpu->h);
6323
		goto step_next;
6324
	case 1139:
6325
		goto step_next;
6326
	// -- overlapped
6327
	case 1140:
6328
		goto fetch_next;
6329
 
6330
	// ED 66: IM 0 (M:1 T:4)
6331
	// -- overlapped
6332
	case 1141:
6333
		cpu->im = 0;
6334
		goto fetch_next;
6335
 
6336
	// ED 67: RRD (M:4 T:14)
6337
	// -- mread
6338
	case 1142:
6339
		goto step_next;
6340
	case 1143:
6341
		_wait();
6342
		_mread(cpu->hl);
6343
		goto step_next;
6344
	case 1144:
6345
		cpu->dlatch = _gd();
6346
		goto step_next;
6347
	// -- generic
6348
	case 1145:
6349
		cpu->dlatch = _z80_rrd(cpu, cpu->dlatch);
6350
		goto step_next;
6351
	case 1146:
6352
		goto step_next;
6353
	case 1147:
6354
		goto step_next;
6355
	case 1148:
6356
		goto step_next;
6357
	// -- mwrite
6358
	case 1149:
6359
		goto step_next;
6360
	case 1150:
6361
		_wait();
6362
		_mwrite(cpu->hl, cpu->dlatch);
6363
		cpu->wz = cpu->hl + 1;
6364
		goto step_next;
6365
	case 1151:
6366
		goto step_next;
6367
	// -- overlapped
6368
	case 1152:
6369
		goto fetch_next;
6370
 
6371
	// ED 68: IN L,(C) (M:2 T:8)
6372
	// -- ioread
6373
	case 1153:
6374
		goto step_next;
6375
	case 1154:
6376
		goto step_next;
6377
	case 1155:
6378
		_wait();
6379
		_ioread(cpu->bc);
6380
		goto step_next;
6381
	case 1156:
6382
		cpu->dlatch = _gd();
6383
		cpu->wz = cpu->bc + 1;
6384
		goto step_next;
6385
	// -- overlapped
6386
	case 1157:
6387
		cpu->l = _z80_in(cpu, cpu->dlatch);
6388
		goto fetch_next;
6389
 
6390
	// ED 69: OUT (C),L (M:2 T:8)
6391
	// -- iowrite
6392
	case 1158:
6393
		goto step_next;
6394
	case 1159:
6395
		_iowrite(cpu->bc, cpu->l);
6396
		goto step_next;
6397
	case 1160:
6398
		_wait();
6399
		cpu->wz = cpu->bc + 1;
6400
		goto step_next;
6401
	case 1161:
6402
		goto step_next;
6403
	// -- overlapped
6404
	case 1162:
6405
		goto fetch_next;
6406
 
6407
	// ED 6A: ADC HL,HL (M:2 T:11)
6408
	// -- generic
6409
	case 1163:
6410
		_z80_adc16(cpu, cpu->hl);
6411
		goto step_next;
6412
	case 1164:
6413
		goto step_next;
6414
	case 1165:
6415
		goto step_next;
6416
	case 1166:
6417
		goto step_next;
6418
	case 1167:
6419
		goto step_next;
6420
	case 1168:
6421
		goto step_next;
6422
	case 1169:
6423
		goto step_next;
6424
	// -- overlapped
6425
	case 1170:
6426
		goto fetch_next;
6427
 
6428
	// ED 6B: LD HL,(nn) (M:5 T:16)
6429
	// -- mread
6430
	case 1171:
6431
		goto step_next;
6432
	case 1172:
6433
		_wait();
6434
		_mread(cpu->pc++);
6435
		goto step_next;
6436
	case 1173:
6437
		cpu->wzl = _gd();
6438
		goto step_next;
6439
	// -- mread
6440
	case 1174:
6441
		goto step_next;
6442
	case 1175:
6443
		_wait();
6444
		_mread(cpu->pc++);
6445
		goto step_next;
6446
	case 1176:
6447
		cpu->wzh = _gd();
6448
		goto step_next;
6449
	// -- mread
6450
	case 1177:
6451
		goto step_next;
6452
	case 1178:
6453
		_wait();
6454
		_mread(cpu->wz++);
6455
		goto step_next;
6456
	case 1179:
6457
		cpu->l = _gd();
6458
		goto step_next;
6459
	// -- mread
6460
	case 1180:
6461
		goto step_next;
6462
	case 1181:
6463
		_wait();
6464
		_mread(cpu->wz);
6465
		goto step_next;
6466
	case 1182:
6467
		cpu->h = _gd();
6468
		goto step_next;
6469
	// -- overlapped
6470
	case 1183:
6471
		goto fetch_next;
6472
 
6473
	// ED 6E: IM 0 (M:1 T:4)
6474
	// -- overlapped
6475
	case 1184:
6476
		cpu->im = 0;
6477
		goto fetch_next;
6478
 
6479
	// ED 6F: RLD (M:4 T:14)
6480
	// -- mread
6481
	case 1185:
6482
		goto step_next;
6483
	case 1186:
6484
		_wait();
6485
		_mread(cpu->hl);
6486
		goto step_next;
6487
	case 1187:
6488
		cpu->dlatch = _gd();
6489
		goto step_next;
6490
	// -- generic
6491
	case 1188:
6492
		cpu->dlatch = _z80_rld(cpu, cpu->dlatch);
6493
		goto step_next;
6494
	case 1189:
6495
		goto step_next;
6496
	case 1190:
6497
		goto step_next;
6498
	case 1191:
6499
		goto step_next;
6500
	// -- mwrite
6501
	case 1192:
6502
		goto step_next;
6503
	case 1193:
6504
		_wait();
6505
		_mwrite(cpu->hl, cpu->dlatch);
6506
		cpu->wz = cpu->hl + 1;
6507
		goto step_next;
6508
	case 1194:
6509
		goto step_next;
6510
	// -- overlapped
6511
	case 1195:
6512
		goto fetch_next;
6513
 
6514
	// ED 70: IN (C) (M:2 T:8)
6515
	// -- ioread
6516
	case 1196:
6517
		goto step_next;
6518
	case 1197:
6519
		goto step_next;
6520
	case 1198:
6521
		_wait();
6522
		_ioread(cpu->bc);
6523
		goto step_next;
6524
	case 1199:
6525
		cpu->dlatch = _gd();
6526
		cpu->wz = cpu->bc + 1;
6527
		goto step_next;
6528
	// -- overlapped
6529
	case 1200:
6530
		_z80_in(cpu, cpu->dlatch);
6531
		goto fetch_next;
6532
 
6533
	// ED 71: OUT (C),0 (M:2 T:8)
6534
	// -- iowrite
6535
	case 1201:
6536
		goto step_next;
6537
	case 1202:
6538
		_iowrite(cpu->bc, 0);
6539
		goto step_next;
6540
	case 1203:
6541
		_wait();
6542
		cpu->wz = cpu->bc + 1;
6543
		goto step_next;
6544
	case 1204:
6545
		goto step_next;
6546
	// -- overlapped
6547
	case 1205:
6548
		goto fetch_next;
6549
 
6550
	// ED 72: SBC HL,SP (M:2 T:11)
6551
	// -- generic
6552
	case 1206:
6553
		_z80_sbc16(cpu, cpu->sp);
6554
		goto step_next;
6555
	case 1207:
6556
		goto step_next;
6557
	case 1208:
6558
		goto step_next;
6559
	case 1209:
6560
		goto step_next;
6561
	case 1210:
6562
		goto step_next;
6563
	case 1211:
6564
		goto step_next;
6565
	case 1212:
6566
		goto step_next;
6567
	// -- overlapped
6568
	case 1213:
6569
		goto fetch_next;
6570
 
6571
	// ED 73: LD (nn),SP (M:5 T:16)
6572
	// -- mread
6573
	case 1214:
6574
		goto step_next;
6575
	case 1215:
6576
		_wait();
6577
		_mread(cpu->pc++);
6578
		goto step_next;
6579
	case 1216:
6580
		cpu->wzl = _gd();
6581
		goto step_next;
6582
	// -- mread
6583
	case 1217:
6584
		goto step_next;
6585
	case 1218:
6586
		_wait();
6587
		_mread(cpu->pc++);
6588
		goto step_next;
6589
	case 1219:
6590
		cpu->wzh = _gd();
6591
		goto step_next;
6592
	// -- mwrite
6593
	case 1220:
6594
		goto step_next;
6595
	case 1221:
6596
		_wait();
6597
		_mwrite(cpu->wz++, cpu->spl);
6598
		goto step_next;
6599
	case 1222:
6600
		goto step_next;
6601
	// -- mwrite
6602
	case 1223:
6603
		goto step_next;
6604
	case 1224:
6605
		_wait();
6606
		_mwrite(cpu->wz, cpu->sph);
6607
		goto step_next;
6608
	case 1225:
6609
		goto step_next;
6610
	// -- overlapped
6611
	case 1226:
6612
		goto fetch_next;
6613
 
6614
	// ED 76: IM 1 (M:1 T:4)
6615
	// -- overlapped
6616
	case 1227:
6617
		cpu->im = 1;
6618
		goto fetch_next;
6619
 
6620
	// ED 78: IN A,(C) (M:2 T:8)
6621
	// -- ioread
6622
	case 1228:
6623
		goto step_next;
6624
	case 1229:
6625
		goto step_next;
6626
	case 1230:
6627
		_wait();
6628
		_ioread(cpu->bc);
6629
		goto step_next;
6630
	case 1231:
6631
		cpu->dlatch = _gd();
6632
		cpu->wz = cpu->bc + 1;
6633
		goto step_next;
6634
	// -- overlapped
6635
	case 1232:
6636
		cpu->a = _z80_in(cpu, cpu->dlatch);
6637
		goto fetch_next;
6638
 
6639
	// ED 79: OUT (C),A (M:2 T:8)
6640
	// -- iowrite
6641
	case 1233:
6642
		goto step_next;
6643
	case 1234:
6644
		_iowrite(cpu->bc, cpu->a);
6645
		goto step_next;
6646
	case 1235:
6647
		_wait();
6648
		cpu->wz = cpu->bc + 1;
6649
		goto step_next;
6650
	case 1236:
6651
		goto step_next;
6652
	// -- overlapped
6653
	case 1237:
6654
		goto fetch_next;
6655
 
6656
	// ED 7A: ADC HL,SP (M:2 T:11)
6657
	// -- generic
6658
	case 1238:
6659
		_z80_adc16(cpu, cpu->sp);
6660
		goto step_next;
6661
	case 1239:
6662
		goto step_next;
6663
	case 1240:
6664
		goto step_next;
6665
	case 1241:
6666
		goto step_next;
6667
	case 1242:
6668
		goto step_next;
6669
	case 1243:
6670
		goto step_next;
6671
	case 1244:
6672
		goto step_next;
6673
	// -- overlapped
6674
	case 1245:
6675
		goto fetch_next;
6676
 
6677
	// ED 7B: LD SP,(nn) (M:5 T:16)
6678
	// -- mread
6679
	case 1246:
6680
		goto step_next;
6681
	case 1247:
6682
		_wait();
6683
		_mread(cpu->pc++);
6684
		goto step_next;
6685
	case 1248:
6686
		cpu->wzl = _gd();
6687
		goto step_next;
6688
	// -- mread
6689
	case 1249:
6690
		goto step_next;
6691
	case 1250:
6692
		_wait();
6693
		_mread(cpu->pc++);
6694
		goto step_next;
6695
	case 1251:
6696
		cpu->wzh = _gd();
6697
		goto step_next;
6698
	// -- mread
6699
	case 1252:
6700
		goto step_next;
6701
	case 1253:
6702
		_wait();
6703
		_mread(cpu->wz++);
6704
		goto step_next;
6705
	case 1254:
6706
		cpu->spl = _gd();
6707
		goto step_next;
6708
	// -- mread
6709
	case 1255:
6710
		goto step_next;
6711
	case 1256:
6712
		_wait();
6713
		_mread(cpu->wz);
6714
		goto step_next;
6715
	case 1257:
6716
		cpu->sph = _gd();
6717
		goto step_next;
6718
	// -- overlapped
6719
	case 1258:
6720
		goto fetch_next;
6721
 
6722
	// ED 7E: IM 2 (M:1 T:4)
6723
	// -- overlapped
6724
	case 1259:
6725
		cpu->im = 2;
6726
		goto fetch_next;
6727
 
6728
	// ED A0: LDI (M:4 T:12)
6729
	// -- mread
6730
	case 1260:
6731
		goto step_next;
6732
	case 1261:
6733
		_wait();
6734
		_mread(cpu->hl++);
6735
		goto step_next;
6736
	case 1262:
6737
		cpu->dlatch = _gd();
6738
		goto step_next;
6739
	// -- mwrite
6740
	case 1263:
6741
		goto step_next;
6742
	case 1264:
6743
		_wait();
6744
		_mwrite(cpu->de++, cpu->dlatch);
6745
		goto step_next;
6746
	case 1265:
6747
		goto step_next;
6748
	// -- generic
6749
	case 1266:
6750
		_z80_ldi_ldd(cpu, cpu->dlatch);
6751
		goto step_next;
6752
	case 1267:
6753
		goto step_next;
6754
	// -- overlapped
6755
	case 1268:
6756
		goto fetch_next;
6757
 
6758
	// ED A1: CPI (M:3 T:12)
6759
	// -- mread
6760
	case 1269:
6761
		goto step_next;
6762
	case 1270:
6763
		_wait();
6764
		_mread(cpu->hl++);
6765
		goto step_next;
6766
	case 1271:
6767
		cpu->dlatch = _gd();
6768
		goto step_next;
6769
	// -- generic
6770
	case 1272:
6771
		cpu->wz++;
6772
		_z80_cpi_cpd(cpu, cpu->dlatch);
6773
		goto step_next;
6774
	case 1273:
6775
		goto step_next;
6776
	case 1274:
6777
		goto step_next;
6778
	case 1275:
6779
		goto step_next;
6780
	case 1276:
6781
		goto step_next;
6782
	// -- overlapped
6783
	case 1277:
6784
		goto fetch_next;
6785
 
6786
	// ED A2: INI (M:4 T:12)
6787
	// -- generic
6788
	case 1278:
6789
		goto step_next;
6790
	// -- ioread
6791
	case 1279:
6792
		goto step_next;
6793
	case 1280:
6794
		goto step_next;
6795
	case 1281:
6796
		_wait();
6797
		_ioread(cpu->bc);
6798
		goto step_next;
6799
	case 1282:
6800
		cpu->dlatch = _gd();
6801
		cpu->wz = cpu->bc + 1;
6802
		cpu->b--;
6803
		;
6804
		goto step_next;
6805
	// -- mwrite
6806
	case 1283:
6807
		goto step_next;
6808
	case 1284:
6809
		_wait();
6810
		_mwrite(cpu->hl++, cpu->dlatch);
6811
		_z80_ini_ind(cpu, cpu->dlatch, cpu->c + 1);
6812
		goto step_next;
6813
	case 1285:
6814
		goto step_next;
6815
	// -- overlapped
6816
	case 1286:
6817
		goto fetch_next;
6818
 
6819
	// ED A3: OUTI (M:4 T:12)
6820
	// -- generic
6821
	case 1287:
6822
		goto step_next;
6823
	// -- mread
6824
	case 1288:
6825
		goto step_next;
6826
	case 1289:
6827
		_wait();
6828
		_mread(cpu->hl++);
6829
		goto step_next;
6830
	case 1290:
6831
		cpu->dlatch = _gd();
6832
		cpu->b--;
6833
		goto step_next;
6834
	// -- iowrite
6835
	case 1291:
6836
		goto step_next;
6837
	case 1292:
6838
		_iowrite(cpu->bc, cpu->dlatch);
6839
		goto step_next;
6840
	case 1293:
6841
		_wait();
6842
		cpu->wz = cpu->bc + 1;
6843
		_z80_outi_outd(cpu, cpu->dlatch);
6844
		goto step_next;
6845
	case 1294:
6846
		goto step_next;
6847
	// -- overlapped
6848
	case 1295:
6849
		goto fetch_next;
6850
 
6851
	// ED A8: LDD (M:4 T:12)
6852
	// -- mread
6853
	case 1296:
6854
		goto step_next;
6855
	case 1297:
6856
		_wait();
6857
		_mread(cpu->hl--);
6858
		goto step_next;
6859
	case 1298:
6860
		cpu->dlatch = _gd();
6861
		goto step_next;
6862
	// -- mwrite
6863
	case 1299:
6864
		goto step_next;
6865
	case 1300:
6866
		_wait();
6867
		_mwrite(cpu->de--, cpu->dlatch);
6868
		goto step_next;
6869
	case 1301:
6870
		goto step_next;
6871
	// -- generic
6872
	case 1302:
6873
		_z80_ldi_ldd(cpu, cpu->dlatch);
6874
		goto step_next;
6875
	case 1303:
6876
		goto step_next;
6877
	// -- overlapped
6878
	case 1304:
6879
		goto fetch_next;
6880
 
6881
	// ED A9: CPD (M:3 T:12)
6882
	// -- mread
6883
	case 1305:
6884
		goto step_next;
6885
	case 1306:
6886
		_wait();
6887
		_mread(cpu->hl--);
6888
		goto step_next;
6889
	case 1307:
6890
		cpu->dlatch = _gd();
6891
		goto step_next;
6892
	// -- generic
6893
	case 1308:
6894
		cpu->wz--;
6895
		_z80_cpi_cpd(cpu, cpu->dlatch);
6896
		goto step_next;
6897
	case 1309:
6898
		goto step_next;
6899
	case 1310:
6900
		goto step_next;
6901
	case 1311:
6902
		goto step_next;
6903
	case 1312:
6904
		goto step_next;
6905
	// -- overlapped
6906
	case 1313:
6907
		goto fetch_next;
6908
 
6909
	// ED AA: IND (M:4 T:12)
6910
	// -- generic
6911
	case 1314:
6912
		goto step_next;
6913
	// -- ioread
6914
	case 1315:
6915
		goto step_next;
6916
	case 1316:
6917
		goto step_next;
6918
	case 1317:
6919
		_wait();
6920
		_ioread(cpu->bc);
6921
		goto step_next;
6922
	case 1318:
6923
		cpu->dlatch = _gd();
6924
		cpu->wz = cpu->bc - 1;
6925
		cpu->b--;
6926
		;
6927
		goto step_next;
6928
	// -- mwrite
6929
	case 1319:
6930
		goto step_next;
6931
	case 1320:
6932
		_wait();
6933
		_mwrite(cpu->hl--, cpu->dlatch);
6934
		_z80_ini_ind(cpu, cpu->dlatch, cpu->c - 1);
6935
		goto step_next;
6936
	case 1321:
6937
		goto step_next;
6938
	// -- overlapped
6939
	case 1322:
6940
		goto fetch_next;
6941
 
6942
	// ED AB: OUTD (M:4 T:12)
6943
	// -- generic
6944
	case 1323:
6945
		goto step_next;
6946
	// -- mread
6947
	case 1324:
6948
		goto step_next;
6949
	case 1325:
6950
		_wait();
6951
		_mread(cpu->hl--);
6952
		goto step_next;
6953
	case 1326:
6954
		cpu->dlatch = _gd();
6955
		cpu->b--;
6956
		goto step_next;
6957
	// -- iowrite
6958
	case 1327:
6959
		goto step_next;
6960
	case 1328:
6961
		_iowrite(cpu->bc, cpu->dlatch);
6962
		goto step_next;
6963
	case 1329:
6964
		_wait();
6965
		cpu->wz = cpu->bc - 1;
6966
		_z80_outi_outd(cpu, cpu->dlatch);
6967
		goto step_next;
6968
	case 1330:
6969
		goto step_next;
6970
	// -- overlapped
6971
	case 1331:
6972
		goto fetch_next;
6973
 
6974
	// ED B0: LDIR (M:5 T:17)
6975
	// -- mread
6976
	case 1332:
6977
		goto step_next;
6978
	case 1333:
6979
		_wait();
6980
		_mread(cpu->hl++);
6981
		goto step_next;
6982
	case 1334:
6983
		cpu->dlatch = _gd();
6984
		goto step_next;
6985
	// -- mwrite
6986
	case 1335:
6987
		goto step_next;
6988
	case 1336:
6989
		_wait();
6990
		_mwrite(cpu->de++, cpu->dlatch);
6991
		goto step_next;
6992
	case 1337:
6993
		goto step_next;
6994
	// -- generic
6995
	case 1338:
6996
		if(!_z80_ldi_ldd(cpu, cpu->dlatch)) {
6997
			_skip(5);
6998
		};
6999
		goto step_next;
7000
	case 1339:
7001
		goto step_next;
7002
	// -- generic
7003
	case 1340:
7004
		cpu->wz = --cpu->pc;
7005
		--cpu->pc;
7006
		;
7007
		goto step_next;
7008
	case 1341:
7009
		goto step_next;
7010
	case 1342:
7011
		goto step_next;
7012
	case 1343:
7013
		goto step_next;
7014
	case 1344:
7015
		goto step_next;
7016
	// -- overlapped
7017
	case 1345:
7018
		goto fetch_next;
7019
 
7020
	// ED B1: CPIR (M:4 T:17)
7021
	// -- mread
7022
	case 1346:
7023
		goto step_next;
7024
	case 1347:
7025
		_wait();
7026
		_mread(cpu->hl++);
7027
		goto step_next;
7028
	case 1348:
7029
		cpu->dlatch = _gd();
7030
		goto step_next;
7031
	// -- generic
7032
	case 1349:
7033
		cpu->wz++;
7034
		if(!_z80_cpi_cpd(cpu, cpu->dlatch)) {
7035
			_skip(5);
7036
		};
7037
		goto step_next;
7038
	case 1350:
7039
		goto step_next;
7040
	case 1351:
7041
		goto step_next;
7042
	case 1352:
7043
		goto step_next;
7044
	case 1353:
7045
		goto step_next;
7046
	// -- generic
7047
	case 1354:
7048
		cpu->wz = --cpu->pc;
7049
		--cpu->pc;
7050
		goto step_next;
7051
	case 1355:
7052
		goto step_next;
7053
	case 1356:
7054
		goto step_next;
7055
	case 1357:
7056
		goto step_next;
7057
	case 1358:
7058
		goto step_next;
7059
	// -- overlapped
7060
	case 1359:
7061
		goto fetch_next;
7062
 
7063
	// ED B2: INIR (M:5 T:17)
7064
	// -- generic
7065
	case 1360:
7066
		goto step_next;
7067
	// -- ioread
7068
	case 1361:
7069
		goto step_next;
7070
	case 1362:
7071
		goto step_next;
7072
	case 1363:
7073
		_wait();
7074
		_ioread(cpu->bc);
7075
		goto step_next;
7076
	case 1364:
7077
		cpu->dlatch = _gd();
7078
		cpu->wz = cpu->bc + 1;
7079
		cpu->b--;
7080
		;
7081
		goto step_next;
7082
	// -- mwrite
7083
	case 1365:
7084
		goto step_next;
7085
	case 1366:
7086
		_wait();
7087
		_mwrite(cpu->hl++, cpu->dlatch);
7088
		if(!_z80_ini_ind(cpu, cpu->dlatch, cpu->c + 1)) {
7089
			_skip(5);
7090
		};
7091
		goto step_next;
7092
	case 1367:
7093
		goto step_next;
7094
	// -- generic
7095
	case 1368:
7096
		cpu->wz = --cpu->pc;
7097
		--cpu->pc;
7098
		goto step_next;
7099
	case 1369:
7100
		goto step_next;
7101
	case 1370:
7102
		goto step_next;
7103
	case 1371:
7104
		goto step_next;
7105
	case 1372:
7106
		goto step_next;
7107
	// -- overlapped
7108
	case 1373:
7109
		goto fetch_next;
7110
 
7111
	// ED B3: OTIR (M:5 T:17)
7112
	// -- generic
7113
	case 1374:
7114
		goto step_next;
7115
	// -- mread
7116
	case 1375:
7117
		goto step_next;
7118
	case 1376:
7119
		_wait();
7120
		_mread(cpu->hl++);
7121
		goto step_next;
7122
	case 1377:
7123
		cpu->dlatch = _gd();
7124
		cpu->b--;
7125
		goto step_next;
7126
	// -- iowrite
7127
	case 1378:
7128
		goto step_next;
7129
	case 1379:
7130
		_iowrite(cpu->bc, cpu->dlatch);
7131
		goto step_next;
7132
	case 1380:
7133
		_wait();
7134
		cpu->wz = cpu->bc + 1;
7135
		if(!_z80_outi_outd(cpu, cpu->dlatch)) {
7136
			_skip(5);
7137
		};
7138
		goto step_next;
7139
	case 1381:
7140
		goto step_next;
7141
	// -- generic
7142
	case 1382:
7143
		cpu->wz = --cpu->pc;
7144
		--cpu->pc;
7145
		goto step_next;
7146
	case 1383:
7147
		goto step_next;
7148
	case 1384:
7149
		goto step_next;
7150
	case 1385:
7151
		goto step_next;
7152
	case 1386:
7153
		goto step_next;
7154
	// -- overlapped
7155
	case 1387:
7156
		goto fetch_next;
7157
 
7158
	// ED B8: LDDR (M:5 T:17)
7159
	// -- mread
7160
	case 1388:
7161
		goto step_next;
7162
	case 1389:
7163
		_wait();
7164
		_mread(cpu->hl--);
7165
		goto step_next;
7166
	case 1390:
7167
		cpu->dlatch = _gd();
7168
		goto step_next;
7169
	// -- mwrite
7170
	case 1391:
7171
		goto step_next;
7172
	case 1392:
7173
		_wait();
7174
		_mwrite(cpu->de--, cpu->dlatch);
7175
		goto step_next;
7176
	case 1393:
7177
		goto step_next;
7178
	// -- generic
7179
	case 1394:
7180
		if(!_z80_ldi_ldd(cpu, cpu->dlatch)) {
7181
			_skip(5);
7182
		};
7183
		goto step_next;
7184
	case 1395:
7185
		goto step_next;
7186
	// -- generic
7187
	case 1396:
7188
		cpu->wz = --cpu->pc;
7189
		--cpu->pc;
7190
		;
7191
		goto step_next;
7192
	case 1397:
7193
		goto step_next;
7194
	case 1398:
7195
		goto step_next;
7196
	case 1399:
7197
		goto step_next;
7198
	case 1400:
7199
		goto step_next;
7200
	// -- overlapped
7201
	case 1401:
7202
		goto fetch_next;
7203
 
7204
	// ED B9: CPDR (M:4 T:17)
7205
	// -- mread
7206
	case 1402:
7207
		goto step_next;
7208
	case 1403:
7209
		_wait();
7210
		_mread(cpu->hl--);
7211
		goto step_next;
7212
	case 1404:
7213
		cpu->dlatch = _gd();
7214
		goto step_next;
7215
	// -- generic
7216
	case 1405:
7217
		cpu->wz--;
7218
		if(!_z80_cpi_cpd(cpu, cpu->dlatch)) {
7219
			_skip(5);
7220
		};
7221
		goto step_next;
7222
	case 1406:
7223
		goto step_next;
7224
	case 1407:
7225
		goto step_next;
7226
	case 1408:
7227
		goto step_next;
7228
	case 1409:
7229
		goto step_next;
7230
	// -- generic
7231
	case 1410:
7232
		cpu->wz = --cpu->pc;
7233
		--cpu->pc;
7234
		goto step_next;
7235
	case 1411:
7236
		goto step_next;
7237
	case 1412:
7238
		goto step_next;
7239
	case 1413:
7240
		goto step_next;
7241
	case 1414:
7242
		goto step_next;
7243
	// -- overlapped
7244
	case 1415:
7245
		goto fetch_next;
7246
 
7247
	// ED BA: INDR (M:5 T:17)
7248
	// -- generic
7249
	case 1416:
7250
		goto step_next;
7251
	// -- ioread
7252
	case 1417:
7253
		goto step_next;
7254
	case 1418:
7255
		goto step_next;
7256
	case 1419:
7257
		_wait();
7258
		_ioread(cpu->bc);
7259
		goto step_next;
7260
	case 1420:
7261
		cpu->dlatch = _gd();
7262
		cpu->wz = cpu->bc - 1;
7263
		cpu->b--;
7264
		;
7265
		goto step_next;
7266
	// -- mwrite
7267
	case 1421:
7268
		goto step_next;
7269
	case 1422:
7270
		_wait();
7271
		_mwrite(cpu->hl--, cpu->dlatch);
7272
		if(!_z80_ini_ind(cpu, cpu->dlatch, cpu->c - 1)) {
7273
			_skip(5);
7274
		};
7275
		goto step_next;
7276
	case 1423:
7277
		goto step_next;
7278
	// -- generic
7279
	case 1424:
7280
		cpu->wz = --cpu->pc;
7281
		--cpu->pc;
7282
		goto step_next;
7283
	case 1425:
7284
		goto step_next;
7285
	case 1426:
7286
		goto step_next;
7287
	case 1427:
7288
		goto step_next;
7289
	case 1428:
7290
		goto step_next;
7291
	// -- overlapped
7292
	case 1429:
7293
		goto fetch_next;
7294
 
7295
	// ED BB: OTDR (M:5 T:17)
7296
	// -- generic
7297
	case 1430:
7298
		goto step_next;
7299
	// -- mread
7300
	case 1431:
7301
		goto step_next;
7302
	case 1432:
7303
		_wait();
7304
		_mread(cpu->hl--);
7305
		goto step_next;
7306
	case 1433:
7307
		cpu->dlatch = _gd();
7308
		cpu->b--;
7309
		goto step_next;
7310
	// -- iowrite
7311
	case 1434:
7312
		goto step_next;
7313
	case 1435:
7314
		_iowrite(cpu->bc, cpu->dlatch);
7315
		goto step_next;
7316
	case 1436:
7317
		_wait();
7318
		cpu->wz = cpu->bc - 1;
7319
		if(!_z80_outi_outd(cpu, cpu->dlatch)) {
7320
			_skip(5);
7321
		};
7322
		goto step_next;
7323
	case 1437:
7324
		goto step_next;
7325
	// -- generic
7326
	case 1438:
7327
		cpu->wz = --cpu->pc;
7328
		--cpu->pc;
7329
		goto step_next;
7330
	case 1439:
7331
		goto step_next;
7332
	case 1440:
7333
		goto step_next;
7334
	case 1441:
7335
		goto step_next;
7336
	case 1442:
7337
		goto step_next;
7338
	// -- overlapped
7339
	case 1443:
7340
		goto fetch_next;
7341
 
7342
	// CB 00: cb (M:1 T:4)
7343
	// -- overlapped
7344
	case 1444: {
7345
		uint8_t z = cpu->opcode & 7;
7346
		_z80_cb_action(cpu, z, z);
7347
	};
7348
		goto fetch_next;
7349
 
7350
	// CB 00: cbhl (M:3 T:11)
7351
	// -- mread
7352
	case 1445:
7353
		goto step_next;
7354
	case 1446:
7355
		_wait();
7356
		_mread(cpu->hl);
7357
		goto step_next;
7358
	case 1447:
7359
		cpu->dlatch = _gd();
7360
		if(!_z80_cb_action(cpu, 6, 6)) {
7361
			_skip(3);
7362
		};
7363
		goto step_next;
7364
	case 1448:
7365
		goto step_next;
7366
	// -- mwrite
7367
	case 1449:
7368
		goto step_next;
7369
	case 1450:
7370
		_wait();
7371
		_mwrite(cpu->hl, cpu->dlatch);
7372
		goto step_next;
7373
	case 1451:
7374
		goto step_next;
7375
	// -- overlapped
7376
	case 1452:
7377
		goto fetch_next;
7378
 
7379
	// CB 00: ddfdcb (M:6 T:18)
7380
	// -- generic
7381
	case 1453:
7382
		_wait();
7383
		_mread(cpu->pc++);
7384
		goto step_next;
7385
	// -- generic
7386
	case 1454:
7387
		_z80_ddfdcb_addr(cpu, pins);
7388
		goto step_next;
7389
	// -- mread
7390
	case 1455:
7391
		goto step_next;
7392
	case 1456:
7393
		_wait();
7394
		_mread(cpu->pc++);
7395
		goto step_next;
7396
	case 1457:
7397
		cpu->opcode = _gd();
7398
		goto step_next;
7399
	case 1458:
7400
		goto step_next;
7401
	case 1459:
7402
		goto step_next;
7403
	// -- mread
7404
	case 1460:
7405
		goto step_next;
7406
	case 1461:
7407
		_wait();
7408
		_mread(cpu->addr);
7409
		goto step_next;
7410
	case 1462:
7411
		cpu->dlatch = _gd();
7412
		if(!_z80_cb_action(cpu, 6, cpu->opcode & 7)) {
7413
			_skip(3);
7414
		};
7415
		goto step_next;
7416
	case 1463:
7417
		goto step_next;
7418
	// -- mwrite
7419
	case 1464:
7420
		goto step_next;
7421
	case 1465:
7422
		_wait();
7423
		_mwrite(cpu->addr, cpu->dlatch);
7424
		goto step_next;
7425
	case 1466:
7426
		goto step_next;
7427
	// -- overlapped
7428
	case 1467:
7429
		goto fetch_next;
7430
 
7431
	//  00: int_im0 (M:6 T:9)
7432
	// -- generic
7433
	case 1468:
7434
		cpu->iff1 = cpu->iff2 = false;
7435
		goto step_next;
7436
	// -- generic
7437
	case 1469:
7438
		pins |= (Z80_M1 | Z80_IORQ);
7439
		goto step_next;
7440
	// -- generic
7441
	case 1470:
7442
		_wait();
7443
		cpu->opcode = _z80_get_db(pins);
7444
		goto step_next;
7445
	// -- generic
7446
	case 1471:
7447
		pins = _z80_refresh(cpu, pins);
7448
		goto step_next;
7449
	// -- generic
7450
	case 1472:
7451
		cpu->step = _z80_optable[cpu->opcode];
7452
		cpu->addr = cpu->hl;
7453
		goto step_next;
7454
	// -- overlapped
7455
	case 1473:
7456
		goto fetch_next;
7457
 
7458
	//  00: int_im1 (M:7 T:16)
7459
	// -- generic
7460
	case 1474:
7461
		cpu->iff1 = cpu->iff2 = false;
7462
		goto step_next;
7463
	// -- generic
7464
	case 1475:
7465
		pins |= (Z80_M1 | Z80_IORQ);
7466
		goto step_next;
7467
	// -- generic
7468
	case 1476:
7469
		_wait();
7470
		goto step_next;
7471
	// -- generic
7472
	case 1477:
7473
		pins = _z80_refresh(cpu, pins);
7474
		goto step_next;
7475
	case 1478:
7476
		goto step_next;
7477
	case 1479:
7478
		goto step_next;
7479
	// -- mwrite
7480
	case 1480:
7481
		goto step_next;
7482
	case 1481:
7483
		_wait();
7484
		_mwrite(--cpu->sp, cpu->pch);
7485
		goto step_next;
7486
	case 1482:
7487
		goto step_next;
7488
	// -- mwrite
7489
	case 1483:
7490
		goto step_next;
7491
	case 1484:
7492
		_wait();
7493
		_mwrite(--cpu->sp, cpu->pcl);
7494
		cpu->wz = cpu->pc = 0x0038;
7495
		goto step_next;
7496
	case 1485:
7497
		goto step_next;
7498
	// -- overlapped
7499
	case 1486:
7500
		goto fetch_next;
7501
 
7502
	//  00: int_im2 (M:9 T:22)
7503
	// -- generic
7504
	case 1487:
7505
		cpu->iff1 = cpu->iff2 = false;
7506
		goto step_next;
7507
	// -- generic
7508
	case 1488:
7509
		pins |= (Z80_M1 | Z80_IORQ);
7510
		goto step_next;
7511
	// -- generic
7512
	case 1489:
7513
		_wait();
7514
		cpu->dlatch = _z80_get_db(pins);
7515
		goto step_next;
7516
	// -- generic
7517
	case 1490:
7518
		pins = _z80_refresh(cpu, pins);
7519
		goto step_next;
7520
	case 1491:
7521
		goto step_next;
7522
	case 1492:
7523
		goto step_next;
7524
	// -- mwrite
7525
	case 1493:
7526
		goto step_next;
7527
	case 1494:
7528
		_wait();
7529
		_mwrite(--cpu->sp, cpu->pch);
7530
		goto step_next;
7531
	case 1495:
7532
		goto step_next;
7533
	// -- mwrite
7534
	case 1496:
7535
		goto step_next;
7536
	case 1497:
7537
		_wait();
7538
		_mwrite(--cpu->sp, cpu->pcl);
7539
		cpu->wzl = cpu->dlatch;
7540
		cpu->wzh = cpu->i;
7541
		goto step_next;
7542
	case 1498:
7543
		goto step_next;
7544
	// -- mread
7545
	case 1499:
7546
		goto step_next;
7547
	case 1500:
7548
		_wait();
7549
		_mread(cpu->wz++);
7550
		goto step_next;
7551
	case 1501:
7552
		cpu->dlatch = _gd();
7553
		goto step_next;
7554
	// -- mread
7555
	case 1502:
7556
		goto step_next;
7557
	case 1503:
7558
		_wait();
7559
		_mread(cpu->wz);
7560
		goto step_next;
7561
	case 1504:
7562
		cpu->wzh = _gd();
7563
		cpu->wzl = cpu->dlatch;
7564
		cpu->pc = cpu->wz;
7565
		goto step_next;
7566
	// -- overlapped
7567
	case 1505:
7568
		goto fetch_next;
7569
 
7570
	//  00: nmi (M:5 T:14)
7571
	// -- generic
7572
	case 1506:
7573
		_wait();
7574
		cpu->iff1 = false;
7575
		goto step_next;
7576
	// -- generic
7577
	case 1507:
7578
		pins = _z80_refresh(cpu, pins);
7579
		goto step_next;
7580
	case 1508:
7581
		goto step_next;
7582
	case 1509:
7583
		goto step_next;
7584
	// -- mwrite
7585
	case 1510:
7586
		goto step_next;
7587
	case 1511:
7588
		_wait();
7589
		_mwrite(--cpu->sp, cpu->pch);
7590
		goto step_next;
7591
	case 1512:
7592
		goto step_next;
7593
	// -- mwrite
7594
	case 1513:
7595
		goto step_next;
7596
	case 1514:
7597
		_wait();
7598
		_mwrite(--cpu->sp, cpu->pcl);
7599
		cpu->wz = cpu->pc = 0x0066;
7600
		goto step_next;
7601
	case 1515:
7602
		goto step_next;
7603
	// -- overlapped
7604
	case 1516:
7605
		goto fetch_next;
7606
 
7607
	default:
7608
		_Z80_UNREACHABLE;
7609
	}
7610
fetch_next:
7611
	pins = _z80_fetch(cpu, pins);
7612
step_next:
7613
	cpu->step += 1;
43 nishi 7614
track_int_bits: {
1 nishi 7615
	// track NMI 0 => 1 edge and current INT pin state, this will track the
7616
	// relevant interrupt status up to the last instruction cycle and will
7617
	// be checked in the first M1 cycle (during _fetch)
7618
	const uint64_t rising_nmi = (pins ^ cpu->pins) & pins; // NMI 0 => 1
7619
	cpu->pins = pins;
7620
	cpu->int_bits = ((cpu->int_bits | rising_nmi) & Z80_NMI) | (pins & Z80_INT);
7621
}
7622
	return pins;
7623
}
7624
 
7625
#undef _sa
7626
#undef _sax
7627
#undef _sad
7628
#undef _sadx
7629
#undef _gd
7630
#undef _skip
7631
#undef _fetch_dd
7632
#undef _fetch_fd
7633
#undef _fetch_ed
7634
#undef _fetch_cb
7635
#undef _mread
7636
#undef _mwrite
7637
#undef _ioread
7638
#undef _iowrite
7639
#undef _wait
7640
#undef _cc_nz
7641
#undef _cc_z
7642
#undef _cc_nc
7643
#undef _cc_c
7644
#undef _cc_po
7645
#undef _cc_pe
7646
#undef _cc_p
7647
#undef _cc_m
7648
 
7649
#endif // CHIPS_IMPL