From b40bcf31d1d2f29614671a276fc73c81a426b00a Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Thu, 3 Sep 2009 17:02:29 +0000 Subject: [PATCH] * fixed 2-Cell vertical scrolling when column 0 is shifted. * added support for 2-Cell vertical scrolling in Interlaced 2 mode. * improved Z80 core accuracy --- HISTORY.txt | 2 + source/render.c | 257 ++++++++++++++++++---- source/z80/z80.c | 558 ++++++++++++++++++++++++----------------------- 3 files changed, 498 insertions(+), 319 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index 0e2c245..3517a43 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -14,6 +14,8 @@ Genesis Plus GX 1.4.0 (??/??/????) (Eke-Eke) * added 3-Band EQ for fully configurable sound filtering (credits to Neil C / Etanza Systems) * removed libsamplerate support, implemented faster/better FIR resampler (thanks to Blargg and AamirM) * improved VDP sprite masking emulation: fixes 3D level in Mickey Mania (thanks to Nemesis for his sprite test program) +* fixed 2-Cell vertical scrolling when column 0 is shifted. +* added support for 2-Cell vertical scrolling in Interlaced 2 mode. * fixed lightgun autodetection: fixes cursor position in Lethal Enforcers II * improved DIVU/DVIS (thanks to Jorge Cwik) & MULU/MULS 68000 instructions timing accuracy * updated Z80 core to last version (fixes interrupt Mode 0 timing and some BIT instructions) diff --git a/source/render.c b/source/render.c index b39257f..39b9bdc 100644 --- a/source/render.c +++ b/source/render.c @@ -970,13 +970,13 @@ static void render_bg(uint32 line, uint32 width) /* common data */ uint32 xscroll = get_hscroll(line); + uint32 yscroll = *(uint32 *)&vsram[0]; uint32 pf_col_mask = playfield_col_mask; uint32 pf_row_mask = playfield_row_mask; uint32 pf_shift = playfield_shift; uint32 pf_y_mask = y_mask; - uint32 *vs = (uint32 *)&vsram[0]; - /* B Plane */ + /* Plane B */ uint8 *buf = ntb_buf; uint32 start = 0; uint32 end = width >> 4; @@ -984,21 +984,21 @@ static void render_bg(uint32 line, uint32 width) #ifdef LSB_FIRST uint32 shift = (xscroll >> 16) & 0x0F; uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); - uint32 y_scroll = (line + ((vs[0] >> 16) & 0x3FF)) & pf_row_mask; + uint32 v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; #else uint32 shift = (xscroll & 0x0F); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); - uint32 y_scroll = (line + (vs[0] & 0x3FF)) & pf_row_mask; + uint32 v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; #endif - uint32 v_line = (y_scroll & 7) << 3; - uint32 *nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + uint32 *nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (v_line & 7) << 3; if(shift) { dst = (uint32 *)&buf[0x10 + shift]; atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN(atbuf, v_line); + DRAW_COLUMN(atbuf, v_line) } dst = (uint32 *)&buf[0x20 + shift]; @@ -1010,8 +1010,10 @@ static void render_bg(uint32 line, uint32 width) /* Window and Plane A */ buf = nta_buf; + uint32 a = (reg[18] & 0x1F) << 3; uint32 w = (reg[18] >> 7) & 1; + if (w == (line >= a)) { /* Window takes up entire line */ @@ -1035,15 +1037,15 @@ static void render_bg(uint32 line, uint32 width) #ifdef LSB_FIRST shift = (xscroll & 0x0F); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); - y_scroll = (line + (vs[0] & 0x3FF)) & pf_row_mask; + v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; #else shift = (xscroll >> 16) & 0x0F; index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); - y_scroll = (line + ((vs[0] >> 16) & 0x3FF)) & pf_row_mask; + v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; #endif - v_line = (y_scroll & 7) << 3; - nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (v_line & 7) << 3; if(shift) { @@ -1053,7 +1055,7 @@ static void render_bg(uint32 line, uint32 width) if (start) atbuf = nt[index & pf_col_mask]; else atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN(atbuf, v_line); + DRAW_COLUMN(atbuf, v_line) } dst = (uint32 *)&buf[0x20 + shift + (start<<4)]; @@ -1074,6 +1076,7 @@ static void render_bg(uint32 line, uint32 width) v_line = (line & 7) << 3; nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; dst = (uint32 *)&buf[0x20 + (start << 4)]; + for(column = start; column < end; column ++) { atbuf = nt[column]; @@ -1094,7 +1097,7 @@ static void render_bg_vs(uint32 line, uint32 width) uint32 pf_y_mask = y_mask; uint32 *vs = (uint32 *)&vsram[0]; - /* B Plane */ + /* Plane B */ uint8 *buf = ntb_buf; uint32 start = 0; uint32 end = width >> 4; @@ -1107,36 +1110,45 @@ static void render_bg_vs(uint32 line, uint32 width) uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); #endif - uint32 y_scroll, v_line, *nt; + uint32 v_line, *nt; if(shift) { - y_scroll = (line & pf_row_mask); - v_line = (y_scroll & 7) << 3; - nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; dst = (uint32 *)&buf[0x10 + shift]; + +#ifdef LSB_FIRST + v_line = (line + ((vs[0] >> 16) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + (vs[0] & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (v_line & 7) << 3; + atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN(atbuf, v_line); + DRAW_COLUMN(atbuf, v_line) } dst = (uint32 *)&buf[0x20 + shift]; - for(column = start; column < end; column ++, index ++) + for(column = 0; column < end; column ++, index ++) { #ifdef LSB_FIRST - y_scroll = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; + v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; #else - y_scroll = (line + (vs[column] & 0x3FF)) & pf_row_mask; + v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; #endif - v_line = (y_scroll & 7) << 3; - nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (v_line & 7) << 3; + atbuf = nt[index & pf_col_mask]; DRAW_COLUMN(atbuf, v_line) } /* Window and Plane A */ buf = nta_buf; + uint32 a = (reg[18] & 0x1F) << 3; uint32 w = (reg[18] >> 7) & 1; + if (w == (line >= a)) { /* Window takes up entire line */ @@ -1168,27 +1180,33 @@ static void render_bg_vs(uint32 line, uint32 width) if(shift) { dst = (uint32 *)&buf[0x10 + shift + (start<<4)]; - y_scroll = (line & pf_row_mask); - v_line = (y_scroll & 7) << 3; - nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + +#ifdef LSB_FIRST + v_line = (line + (vs[start] & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[start] >> 16) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (v_line & 7) << 3; /* Window bug */ if (start) atbuf = nt[index & pf_col_mask]; else atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN(atbuf, v_line); + DRAW_COLUMN(atbuf, v_line) } dst = (uint32 *)&buf[0x20 + shift + (start<<4)]; for(column = start; column < end; column ++, index ++) { #ifdef LSB_FIRST - y_scroll = (line + (vs[column] & 0x3FF)) & pf_row_mask; + v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; #else - y_scroll = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; + v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; #endif - v_line = (y_scroll & 7) << 3; - nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (v_line & 7) << 3; + atbuf = nt[index & pf_col_mask]; DRAW_COLUMN(atbuf, v_line) } @@ -1218,13 +1236,13 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) /* common data */ uint32 xscroll = get_hscroll(line); + uint32 yscroll = *(uint32 *)&vsram[0]; uint32 pf_col_mask = playfield_col_mask; uint32 pf_row_mask = playfield_row_mask; uint32 pf_shift = playfield_shift; uint32 pf_y_mask = y_mask; - uint32 *vs = (uint32 *)&vsram[0]; - /* B Plane */ + /* Plane B */ uint8 *buf = ntb_buf; uint32 start = 0; uint32 end = width >> 4; @@ -1232,28 +1250,28 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) #ifdef LSB_FIRST uint32 shift = (xscroll >> 16) & 0x0F; uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); - uint32 y_scroll = (line + ((vs[0] >> 17) & 0x3FF)) & pf_row_mask; /* IM2 specific */ + uint32 v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; #else uint32 shift = (xscroll & 0x0F); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); - uint32 y_scroll = (line + ((vs[0] >> 1) & 0x3FF)) & pf_row_mask; /* IM2 specific */ + uint32 v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; #endif - uint32 v_line = (((y_scroll & 7) << 1) | odd) << 3; /* IM2 specific */ - uint32 *nt = (uint32 *)&vram[ntbb + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + uint32 *nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((v_line & 7) << 1) | odd) << 3; if(shift) { dst = (uint32 *)&buf[0x10 + shift]; atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN_IM2(atbuf, v_line); /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line) } dst = (uint32 *)&buf[0x20 + shift]; for(column = 0; column < end; column ++, index ++) { atbuf = nt[index & pf_col_mask]; - DRAW_COLUMN_IM2(atbuf, v_line) /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line) } /* Window and Plane A */ @@ -1283,15 +1301,15 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) #ifdef LSB_FIRST shift = (xscroll & 0x0F); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); - y_scroll = (line + ((vs[0] >> 1) & 0x3FF)) & pf_row_mask; /* IM2 specific */ + v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; #else shift = (xscroll >> 16) & 0x0F; index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); - y_scroll = (line + ((vs[0] >> 17) & 0x3FF)) & pf_row_mask; /* IM2 specific */ + v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; #endif - v_line = (((y_scroll & 7) << 1) | odd) << 3; /* IM2 specific */ - nt = (uint32 *)&vram[ntab + (((y_scroll >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((v_line & 7) << 1) | odd) << 3; if(shift) { @@ -1301,14 +1319,14 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) if (start) atbuf = nt[index & pf_col_mask]; else atbuf = nt[(index-1) & pf_col_mask]; - DRAW_COLUMN_IM2(atbuf, v_line); /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line) } dst = (uint32 *)&buf[0x20 + shift + (start<<4)]; for(column = start; column < end; column ++, index ++) { atbuf = nt[index & pf_col_mask]; - DRAW_COLUMN_IM2(atbuf, v_line) /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line) } /* set for Window */ @@ -1319,17 +1337,159 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) /* Window */ if (w) { - v_line = ((line & 7) << 1 | odd) << 3; /* IM2 specific */ + v_line = ((line & 7) << 1 | odd) << 3; nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; dst = (uint32 *)&buf[0x20 + (start << 4)]; for(column = start; column < end; column ++) { atbuf = nt[column]; - DRAW_COLUMN_IM2(atbuf, v_line) /* IM2 specific */ + DRAW_COLUMN_IM2(atbuf, v_line) } } } +static void render_bg_im2_vs(uint32 line, uint32 width, uint32 odd) +{ + uint32 column, atex, atbuf, offs, *src, *dst; + + /* common data */ + uint32 xscroll = get_hscroll(line); + uint32 pf_col_mask = playfield_col_mask; + uint32 pf_row_mask = playfield_row_mask; + uint32 pf_shift = playfield_shift; + uint32 pf_y_mask = y_mask; + uint32 *vs = (uint32 *)&vsram[0]; + + /* Plane B */ + uint8 *buf = ntb_buf; + uint32 start = 0; + uint32 end = width >> 4; + +#ifdef LSB_FIRST + uint32 shift = (xscroll >> 16) & 0x0F; + uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); +#else + uint32 shift = (xscroll & 0x0F); + uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); +#endif + + uint32 v_line, *nt; + + if(shift) + { + dst = (uint32 *)&buf[0x10 + shift]; + +#ifdef LSB_FIRST + v_line = (line + ((vs[0] >> 17) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[0] >> 1) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((v_line & 7) << 1) | odd) << 3; + + atbuf = nt[(index-1) & pf_col_mask]; + DRAW_COLUMN_IM2(atbuf, v_line) + } + + dst = (uint32 *)&buf[0x20 + shift]; + for(column = 0; column < end; column ++, index ++) + { +#ifdef LSB_FIRST + v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((v_line & 7) << 1) | odd) << 3; + + atbuf = nt[index & pf_col_mask]; + DRAW_COLUMN_IM2(atbuf, v_line) + } + + /* Window and Plane A */ + buf = nta_buf; + uint32 a = (reg[18] & 0x1F) << 3; + uint32 w = (reg[18] >> 7) & 1; + if (w == (line >= a)) + { + /* Window takes up entire line */ + a = 0; + w = 1; + } + else + { + /* Window and Plane A share the line */ + a = clip[0].enable; + w = clip[1].enable; + } + + /* Plane A */ + if (a) + { + /* set for Plane A */ + start = clip[0].left; + end = clip[0].right; + +#ifdef LSB_FIRST + shift = (xscroll & 0x0F); + index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); +#else + shift = (xscroll >> 16) & 0x0F; + index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); +#endif + + if(shift) + { + dst = (uint32 *)&buf[0x10 + shift + (start<<4)]; + +#ifdef LSB_FIRST + v_line = (line + ((vs[start] >> 1) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[start] >> 17) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((v_line & 7) << 1) | odd) << 3; + + /* Window bug */ + if (start) atbuf = nt[index & pf_col_mask]; + else atbuf = nt[(index-1) & pf_col_mask]; + + DRAW_COLUMN_IM2(atbuf, v_line) + } + + dst = (uint32 *)&buf[0x20 + shift + (start<<4)]; + for(column = start; column < end; column ++, index ++) + { +#ifdef LSB_FIRST + v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + v_line = (((v_line & 7) << 1) | odd) << 3; + + atbuf = nt[index & pf_col_mask]; + DRAW_COLUMN_IM2(atbuf, v_line) + } + + /* set for Window */ + start = clip[1].left; + end = clip[1].right; + } + + /* Window */ + if (w) + { + v_line = ((line & 7) << 1 | odd) << 3; + nt = (uint32 *)&vram[ntwb | ((line >> 3) << (6 + (reg[12] & 1)))]; + dst = (uint32 *)&buf[0x20 + (start << 4)]; + for(column = start; column < end; column ++) + { + atbuf = nt[column]; + DRAW_COLUMN_IM2(atbuf, v_line) + } + } +} /*--------------------------------------------------------------------------*/ /* Object render functions */ @@ -1622,7 +1782,8 @@ void render_line(uint32 line, uint32 overscan) uint32 odd = odd_frame; /* render BG layers */ - render_bg_im2(line, width, odd); + if(reg[11] & 4) render_bg_im2_vs(line, width, odd); + else render_bg_im2(line, width, odd); if (reg[12] & 8) { diff --git a/source/z80/z80.c b/source/z80/z80.c index 5296920..5ca0310 100644 --- a/source/z80/z80.c +++ b/source/z80/z80.c @@ -131,8 +131,6 @@ #define INT_IRQ 0x01 #define NMI_IRQ 0x02 -#define PRVPC Z80.prvpc.d /* previous program counter */ - #define PCD Z80.pc.d #define PC Z80.pc.w.l @@ -248,7 +246,7 @@ static const UINT8 cc_ed[0x100] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}; -static const UINT8 cc_xy[0x100] = { +/*static const UINT8 cc_xy[0x100] = { 4, 4, 4, 4, 4, 4, 4, 4, 4,15, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,15, 4, 4, 4, 4, 4, 4, 4,14,20,10, 9, 9,11, 4, 4,15,20,10, 9, 9,11, 4, @@ -265,6 +263,26 @@ static const UINT8 cc_xy[0x100] = { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,14, 4,23, 4,15, 4, 4, 4, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,10, 4, 4, 4, 4, 4, 4}; +*/ + +/* illegal combo should return 4 + cc_op[i] */ +static const UINT8 cc_xy[0x100] ={ + 8,14,11,10, 8, 8,11, 8, 8,15,11,10, 8, 8,11, 8, +12,14,11,10, 8, 8,11, 8,16,15,11,10, 8, 8,11, 8, +11,14,20,10, 9, 9,12, 8,11,15,20,10, 9, 9,12, 8, +11,14,17,10,23,23,19, 8,11,15,17,10, 8, 8,11, 8, + 8, 8, 8, 8, 9, 9,19, 8, 8, 8, 8, 8, 9, 9,19, 8, + 8, 8, 8, 8, 9, 9,19, 8, 8, 8, 8, 8, 9, 9,19, 8, + 9, 9, 9, 9, 9, 9,19, 9, 9, 9, 9, 9, 9, 9,19, 9, +19,19,19,19,19,19, 8,19, 8, 8, 8, 8, 9, 9,19, 8, + 8, 8, 8, 8, 9, 9,19, 8, 8, 8, 8, 8, 9, 9,19, 8, + 8, 8, 8, 8, 9, 9,19, 8, 8, 8, 8, 8, 9, 9,19, 8, + 8, 8, 8, 8, 9, 9,19, 8, 8, 8, 8, 8, 9, 9,19, 8, + 8, 8, 8, 8, 9, 9,19, 8, 8, 8, 8, 8, 9, 9,19, 8, + 9,14,14,14,14,15,11,15, 9,14,14, 0,14,21,11,15, + 9,14,14,15,14,15,11,15, 9, 8,14,15,14, 4,11,15, + 9,14,14,23,14,15,11,15, 9, 8,14, 8,14, 4,11,15, + 9,14,14, 8,14,15,11,15, 9,10,14, 8,14, 4,11,15}; static const UINT8 cc_xycb[0x100] = { 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23, @@ -296,7 +314,7 @@ static const UINT8 cc_ex[0x100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, /* INI/IND (cycle-accurate I/O port reads) */ 5, 5, 5, 5, 0, 0, 0, 0, 5, 5, 5, 5, 0, 0, 0, 0, /* LDIR/CPIR/INIR/OTIR LDDR/CPDR/INDR/OTDR */ 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2, @@ -442,20 +460,20 @@ INLINE void BURNODD(int cycles, int opcodes, int cyclesum) /*************************************************************** * execute an opcode ***************************************************************/ -#define EXEC(prefix,opcode) \ -{ \ - unsigned op = opcode; \ - CC(prefix,op); \ +#define EXEC(prefix,opcode) \ +{ \ + unsigned op = opcode; \ + CC(prefix,op); \ (*Z80##prefix[op])(); \ } #if BIG_SWITCH -#define EXEC_INLINE(prefix,opcode) \ -{ \ - unsigned op = opcode; \ +#define EXEC_INLINE(prefix,opcode) \ +{ \ + unsigned op = opcode; \ CC(prefix,op); \ - switch(op) \ - { \ + switch(op) \ + { \ case 0x00:prefix##_##00();break; case 0x01:prefix##_##01();break; case 0x02:prefix##_##02();break; case 0x03:prefix##_##03();break; \ case 0x04:prefix##_##04();break; case 0x05:prefix##_##05();break; case 0x06:prefix##_##06();break; case 0x07:prefix##_##07();break; \ case 0x08:prefix##_##08();break; case 0x09:prefix##_##09();break; case 0x0a:prefix##_##0a();break; case 0x0b:prefix##_##0b();break; \ @@ -520,7 +538,7 @@ INLINE void BURNODD(int cycles, int opcodes, int cyclesum) case 0xf4:prefix##_##f4();break; case 0xf5:prefix##_##f5();break; case 0xf6:prefix##_##f6();break; case 0xf7:prefix##_##f7();break; \ case 0xf8:prefix##_##f8();break; case 0xf9:prefix##_##f9();break; case 0xfa:prefix##_##fa();break; case 0xfb:prefix##_##fb();break; \ case 0xfc:prefix##_##fc();break; case 0xfd:prefix##_##fd();break; case 0xfe:prefix##_##fe();break; case 0xff:prefix##_##ff();break; \ - } \ + } \ } #else #define EXEC_INLINE EXEC @@ -530,22 +548,20 @@ INLINE void BURNODD(int cycles, int opcodes, int cyclesum) /*************************************************************** * Enter HALT state; write 1 to fake port on first execution ***************************************************************/ -#define ENTER_HALT { \ - PC--; \ - HALT = 1; \ - if( Z80.irq_state == CLEAR_LINE ) \ - z80_burn( z80_ICount ); \ +#define ENTER_HALT { \ + PC--; \ + HALT = 1; \ } /*************************************************************** * Leave HALT state; write 0 to fake port ***************************************************************/ -#define LEAVE_HALT { \ - if( HALT ) \ - { \ - HALT = 0; \ - PC++; \ - } \ +#define LEAVE_HALT { \ + if( HALT ) \ + { \ + HALT = 0; \ + PC++; \ + } \ } /*************************************************************** @@ -622,8 +638,8 @@ INLINE UINT32 ARG16(void) * Calculate the effective address EA of an opcode using * IX+offset resp. IY+offset addressing. ***************************************************************/ -#define EAX { EA = (UINT32)(UINT16)(IX + (INT8)ARG()); MEMPTR = EA; } while (0) -#define EAY { EA = (UINT32)(UINT16)(IY + (INT8)ARG()); MEMPTR = EA; } while (0) +#define EAX do { EA = (UINT32)(UINT16)(IX + (INT8)ARG()); MEMPTR = EA; } while (0) +#define EAY do { EA = (UINT32)(UINT16)(IY + (INT8)ARG()); MEMPTR = EA; } while (0) /*************************************************************** * POP @@ -638,8 +654,8 @@ INLINE UINT32 ARG16(void) /*************************************************************** * JP ***************************************************************/ -#define JP { \ - PCD = ARG16(); \ +#define JP { \ + PCD = ARG16(); \ MEMPTR = PCD; \ } @@ -648,12 +664,12 @@ INLINE UINT32 ARG16(void) ***************************************************************/ #define JP_COND(cond) { \ if (cond) \ - { \ - PCD = ARG16(); \ + { \ + PCD = ARG16(); \ MEMPTR = PCD; \ - } \ - else \ - { \ + } \ + else \ + { \ MEMPTR = ARG16(); /* implicit do PC += 2 */ \ } \ } @@ -662,8 +678,8 @@ INLINE UINT32 ARG16(void) * JR ***************************************************************/ #define JR() { \ - INT8 arg = (INT8)ARG(); /* ARG() also increments PC */ \ - PC += arg; /* so don't do PC += ARG() */ \ + INT8 arg = (INT8)ARG(); /* ARG() also increments PC */ \ + PC += arg; /* so don't do PC += ARG() */ \ MEMPTR = PC; \ } @@ -672,21 +688,21 @@ INLINE UINT32 ARG16(void) ***************************************************************/ #define JR_COND(cond, opcode) { \ if (cond) \ - { \ + { \ JR(); \ CC(ex, opcode); \ - } \ - else PC++; \ + } \ + else PC++; \ } /*************************************************************** * CALL ***************************************************************/ #define CALL() { \ - EA = ARG16(); \ + EA = ARG16(); \ MEMPTR = EA; \ PUSH(pc); \ - PCD = EA; \ + PCD = EA; \ } /*************************************************************** @@ -929,7 +945,6 @@ INLINE UINT8 DEC(UINT8 value) diff = hf ? 0x06 : 0x00; \ if (nf) A -= diff; \ else A += diff; \ - \ F = SZP[A] | (F & NF); \ if (cf || (lo <= 9 ? hi >= 10 : hi >= 9)) F |= CF; \ if (nf ? hf && lo <= 5 : lo >= 10) F |= HF; \ @@ -1215,6 +1230,7 @@ INLINE UINT8 SET(UINT8 bit, UINT8 value) unsigned t; \ UINT8 io = IN(BC); \ MEMPTR = BC + 1; \ + CC(ex,0xa2); \ B--; \ WM( HL, io ); \ HL++; \ @@ -1277,6 +1293,7 @@ INLINE UINT8 SET(UINT8 bit, UINT8 value) unsigned t; \ UINT8 io = IN(BC); \ MEMPTR = BC - 1; \ + CC(ex,0xaa); \ B--; \ WM( HL, io ); \ HL--; \ @@ -2007,7 +2024,7 @@ OP(dd,06) { illegal_1(); op_06(); } /* DB DD */ OP(dd,07) { illegal_1(); op_07(); } /* DB DD */ OP(dd,08) { illegal_1(); op_08(); } /* DB DD */ -OP(dd,09) { R++; ADD16(ix,bc); } /* ADD IX,BC */ +OP(dd,09) { ADD16(ix,bc); } /* ADD IX,BC */ OP(dd,0a) { illegal_1(); op_0a(); } /* DB DD */ OP(dd,0b) { illegal_1(); op_0b(); } /* DB DD */ OP(dd,0c) { illegal_1(); op_0c(); } /* DB DD */ @@ -2025,7 +2042,7 @@ OP(dd,16) { illegal_1(); op_16(); } /* DB DD */ OP(dd,17) { illegal_1(); op_17(); } /* DB DD */ OP(dd,18) { illegal_1(); op_18(); } /* DB DD */ -OP(dd,19) { R++; ADD16(ix,de); } /* ADD IX,DE */ +OP(dd,19) { ADD16(ix,de); } /* ADD IX,DE */ OP(dd,1a) { illegal_1(); op_1a(); } /* DB DD */ OP(dd,1b) { illegal_1(); op_1b(); } /* DB DD */ OP(dd,1c) { illegal_1(); op_1c(); } /* DB DD */ @@ -2034,34 +2051,34 @@ OP(dd,1e) { illegal_1(); op_1e(); } /* DB DD */ OP(dd,1f) { illegal_1(); op_1f(); } /* DB DD */ OP(dd,20) { illegal_1(); op_20(); } /* DB DD */ -OP(dd,21) { R++; IX = ARG16(); } /* LD IX,w */ -OP(dd,22) { R++; EA = ARG16(); WM16( EA, &Z80.ix ); MEMPTR = EA+1; } /* LD (w),IX */ -OP(dd,23) { R++; IX++; } /* INC IX */ -OP(dd,24) { R++; HX = INC(HX); } /* INC HX */ -OP(dd,25) { R++; HX = DEC(HX); } /* DEC HX */ -OP(dd,26) { R++; HX = ARG(); } /* LD HX,n */ +OP(dd,21) { IX = ARG16(); } /* LD IX,w */ +OP(dd,22) { EA = ARG16(); WM16( EA, &Z80.ix ); MEMPTR = EA+1; } /* LD (w),IX */ +OP(dd,23) { IX++; } /* INC IX */ +OP(dd,24) { HX = INC(HX); } /* INC HX */ +OP(dd,25) { HX = DEC(HX); } /* DEC HX */ +OP(dd,26) { HX = ARG(); } /* LD HX,n */ OP(dd,27) { illegal_1(); op_27(); } /* DB DD */ OP(dd,28) { illegal_1(); op_28(); } /* DB DD */ -OP(dd,29) { R++; ADD16(ix,ix); } /* ADD IX,IX */ -OP(dd,2a) { R++; EA = ARG16(); RM16( EA, &Z80.ix ); MEMPTR = EA+1; } /* LD IX,(w) */ -OP(dd,2b) { R++; IX--; } /* DEC IX */ -OP(dd,2c) { R++; LX = INC(LX); } /* INC LX */ -OP(dd,2d) { R++; LX = DEC(LX); } /* DEC LX */ -OP(dd,2e) { R++; LX = ARG(); } /* LD LX,n */ +OP(dd,29) { ADD16(ix,ix); } /* ADD IX,IX */ +OP(dd,2a) { EA = ARG16(); RM16( EA, &Z80.ix ); MEMPTR = EA+1; } /* LD IX,(w) */ +OP(dd,2b) { IX--; } /* DEC IX */ +OP(dd,2c) { LX = INC(LX); } /* INC LX */ +OP(dd,2d) { LX = DEC(LX); } /* DEC LX */ +OP(dd,2e) { LX = ARG(); } /* LD LX,n */ OP(dd,2f) { illegal_1(); op_2f(); } /* DB DD */ OP(dd,30) { illegal_1(); op_30(); } /* DB DD */ OP(dd,31) { illegal_1(); op_31(); } /* DB DD */ OP(dd,32) { illegal_1(); op_32(); } /* DB DD */ OP(dd,33) { illegal_1(); op_33(); } /* DB DD */ -OP(dd,34) { R++; EAX; WM( EA, INC(RM(EA)) ); } /* INC (IX+o) */ -OP(dd,35) { R++; EAX; WM( EA, DEC(RM(EA)) ); } /* DEC (IX+o) */ -OP(dd,36) { R++; EAX; WM( EA, ARG() ); } /* LD (IX+o),n */ +OP(dd,34) { EAX; WM( EA, INC(RM(EA)) ); } /* INC (IX+o) */ +OP(dd,35) { EAX; WM( EA, DEC(RM(EA)) ); } /* DEC (IX+o) */ +OP(dd,36) { EAX; WM( EA, ARG() ); } /* LD (IX+o),n */ OP(dd,37) { illegal_1(); op_37(); } /* DB DD */ OP(dd,38) { illegal_1(); op_38(); } /* DB DD */ -OP(dd,39) { R++; ADD16(ix,sp); } /* ADD IX,SP */ +OP(dd,39) { ADD16(ix,sp); } /* ADD IX,SP */ OP(dd,3a) { illegal_1(); op_3a(); } /* DB DD */ OP(dd,3b) { illegal_1(); op_3b(); } /* DB DD */ OP(dd,3c) { illegal_1(); op_3c(); } /* DB DD */ @@ -2073,144 +2090,144 @@ OP(dd,40) { illegal_1(); op_40(); } /* DB DD */ OP(dd,41) { illegal_1(); op_41(); } /* DB DD */ OP(dd,42) { illegal_1(); op_42(); } /* DB DD */ OP(dd,43) { illegal_1(); op_43(); } /* DB DD */ -OP(dd,44) { R++; B = HX; } /* LD B,HX */ -OP(dd,45) { R++; B = LX; } /* LD B,LX */ -OP(dd,46) { R++; EAX; B = RM(EA); } /* LD B,(IX+o) */ +OP(dd,44) { B = HX; } /* LD B,HX */ +OP(dd,45) { B = LX; } /* LD B,LX */ +OP(dd,46) { EAX; B = RM(EA); } /* LD B,(IX+o) */ OP(dd,47) { illegal_1(); op_47(); } /* DB DD */ OP(dd,48) { illegal_1(); op_48(); } /* DB DD */ OP(dd,49) { illegal_1(); op_49(); } /* DB DD */ OP(dd,4a) { illegal_1(); op_4a(); } /* DB DD */ OP(dd,4b) { illegal_1(); op_4b(); } /* DB DD */ -OP(dd,4c) { R++; C = HX; } /* LD C,HX */ -OP(dd,4d) { R++; C = LX; } /* LD C,LX */ -OP(dd,4e) { R++; EAX; C = RM(EA); } /* LD C,(IX+o) */ +OP(dd,4c) { C = HX; } /* LD C,HX */ +OP(dd,4d) { C = LX; } /* LD C,LX */ +OP(dd,4e) { EAX; C = RM(EA); } /* LD C,(IX+o) */ OP(dd,4f) { illegal_1(); op_4f(); } /* DB DD */ OP(dd,50) { illegal_1(); op_50(); } /* DB DD */ OP(dd,51) { illegal_1(); op_51(); } /* DB DD */ OP(dd,52) { illegal_1(); op_52(); } /* DB DD */ OP(dd,53) { illegal_1(); op_53(); } /* DB DD */ -OP(dd,54) { R++; D = HX; } /* LD D,HX */ -OP(dd,55) { R++; D = LX; } /* LD D,LX */ -OP(dd,56) { R++; EAX; D = RM(EA); } /* LD D,(IX+o) */ +OP(dd,54) { D = HX; } /* LD D,HX */ +OP(dd,55) { D = LX; } /* LD D,LX */ +OP(dd,56) { EAX; D = RM(EA); } /* LD D,(IX+o) */ OP(dd,57) { illegal_1(); op_57(); } /* DB DD */ OP(dd,58) { illegal_1(); op_58(); } /* DB DD */ OP(dd,59) { illegal_1(); op_59(); } /* DB DD */ OP(dd,5a) { illegal_1(); op_5a(); } /* DB DD */ OP(dd,5b) { illegal_1(); op_5b(); } /* DB DD */ -OP(dd,5c) { R++; E = HX; } /* LD E,HX */ -OP(dd,5d) { R++; E = LX; } /* LD E,LX */ -OP(dd,5e) { R++; EAX; E = RM(EA); } /* LD E,(IX+o) */ +OP(dd,5c) { E = HX; } /* LD E,HX */ +OP(dd,5d) { E = LX; } /* LD E,LX */ +OP(dd,5e) { EAX; E = RM(EA); } /* LD E,(IX+o) */ OP(dd,5f) { illegal_1(); op_5f(); } /* DB DD */ -OP(dd,60) { R++; HX = B; } /* LD HX,B */ -OP(dd,61) { R++; HX = C; } /* LD HX,C */ -OP(dd,62) { R++; HX = D; } /* LD HX,D */ -OP(dd,63) { R++; HX = E; } /* LD HX,E */ +OP(dd,60) { HX = B; } /* LD HX,B */ +OP(dd,61) { HX = C; } /* LD HX,C */ +OP(dd,62) { HX = D; } /* LD HX,D */ +OP(dd,63) { HX = E; } /* LD HX,E */ OP(dd,64) { } /* LD HX,HX */ -OP(dd,65) { R++; HX = LX; } /* LD HX,LX */ -OP(dd,66) { R++; EAX; H = RM(EA); } /* LD H,(IX+o) */ -OP(dd,67) { R++; HX = A; } /* LD HX,A */ +OP(dd,65) { HX = LX; } /* LD HX,LX */ +OP(dd,66) { EAX; H = RM(EA); } /* LD H,(IX+o) */ +OP(dd,67) { HX = A; } /* LD HX,A */ -OP(dd,68) { R++; LX = B; } /* LD LX,B */ -OP(dd,69) { R++; LX = C; } /* LD LX,C */ -OP(dd,6a) { R++; LX = D; } /* LD LX,D */ -OP(dd,6b) { R++; LX = E; } /* LD LX,E */ -OP(dd,6c) { R++; LX = HX; } /* LD LX,HX */ +OP(dd,68) { LX = B; } /* LD LX,B */ +OP(dd,69) { LX = C; } /* LD LX,C */ +OP(dd,6a) { LX = D; } /* LD LX,D */ +OP(dd,6b) { LX = E; } /* LD LX,E */ +OP(dd,6c) { LX = HX; } /* LD LX,HX */ OP(dd,6d) { } /* LD LX,LX */ -OP(dd,6e) { R++; EAX; L = RM(EA); } /* LD L,(IX+o) */ -OP(dd,6f) { R++; LX = A; } /* LD LX,A */ +OP(dd,6e) { EAX; L = RM(EA); } /* LD L,(IX+o) */ +OP(dd,6f) { LX = A; } /* LD LX,A */ -OP(dd,70) { R++; EAX; WM( EA, B ); } /* LD (IX+o),B */ -OP(dd,71) { R++; EAX; WM( EA, C ); } /* LD (IX+o),C */ -OP(dd,72) { R++; EAX; WM( EA, D ); } /* LD (IX+o),D */ -OP(dd,73) { R++; EAX; WM( EA, E ); } /* LD (IX+o),E */ -OP(dd,74) { R++; EAX; WM( EA, H ); } /* LD (IX+o),H */ -OP(dd,75) { R++; EAX; WM( EA, L ); } /* LD (IX+o),L */ +OP(dd,70) { EAX; WM( EA, B ); } /* LD (IX+o),B */ +OP(dd,71) { EAX; WM( EA, C ); } /* LD (IX+o),C */ +OP(dd,72) { EAX; WM( EA, D ); } /* LD (IX+o),D */ +OP(dd,73) { EAX; WM( EA, E ); } /* LD (IX+o),E */ +OP(dd,74) { EAX; WM( EA, H ); } /* LD (IX+o),H */ +OP(dd,75) { EAX; WM( EA, L ); } /* LD (IX+o),L */ OP(dd,76) { illegal_1(); op_76(); } /* DB DD */ -OP(dd,77) { R++; EAX; WM( EA, A ); } /* LD (IX+o),A */ +OP(dd,77) { EAX; WM( EA, A ); } /* LD (IX+o),A */ OP(dd,78) { illegal_1(); op_78(); } /* DB DD */ OP(dd,79) { illegal_1(); op_79(); } /* DB DD */ OP(dd,7a) { illegal_1(); op_7a(); } /* DB DD */ OP(dd,7b) { illegal_1(); op_7b(); } /* DB DD */ -OP(dd,7c) { R++; A = HX; } /* LD A,HX */ -OP(dd,7d) { R++; A = LX; } /* LD A,LX */ -OP(dd,7e) { R++; EAX; A = RM(EA); } /* LD A,(IX+o) */ +OP(dd,7c) { A = HX; } /* LD A,HX */ +OP(dd,7d) { A = LX; } /* LD A,LX */ +OP(dd,7e) { EAX; A = RM(EA); } /* LD A,(IX+o) */ OP(dd,7f) { illegal_1(); op_7f(); } /* DB DD */ OP(dd,80) { illegal_1(); op_80(); } /* DB DD */ OP(dd,81) { illegal_1(); op_81(); } /* DB DD */ OP(dd,82) { illegal_1(); op_82(); } /* DB DD */ OP(dd,83) { illegal_1(); op_83(); } /* DB DD */ -OP(dd,84) { R++; ADD(HX); } /* ADD A,HX */ -OP(dd,85) { R++; ADD(LX); } /* ADD A,LX */ -OP(dd,86) { R++; EAX; ADD(RM(EA)); } /* ADD A,(IX+o) */ +OP(dd,84) { ADD(HX); } /* ADD A,HX */ +OP(dd,85) { ADD(LX); } /* ADD A,LX */ +OP(dd,86) { EAX; ADD(RM(EA)); } /* ADD A,(IX+o) */ OP(dd,87) { illegal_1(); op_87(); } /* DB DD */ OP(dd,88) { illegal_1(); op_88(); } /* DB DD */ OP(dd,89) { illegal_1(); op_89(); } /* DB DD */ OP(dd,8a) { illegal_1(); op_8a(); } /* DB DD */ OP(dd,8b) { illegal_1(); op_8b(); } /* DB DD */ -OP(dd,8c) { R++; ADC(HX); } /* ADC A,HX */ -OP(dd,8d) { R++; ADC(LX); } /* ADC A,LX */ -OP(dd,8e) { R++; EAX; ADC(RM(EA)); } /* ADC A,(IX+o) */ +OP(dd,8c) { ADC(HX); } /* ADC A,HX */ +OP(dd,8d) { ADC(LX); } /* ADC A,LX */ +OP(dd,8e) { EAX; ADC(RM(EA)); } /* ADC A,(IX+o) */ OP(dd,8f) { illegal_1(); op_8f(); } /* DB DD */ OP(dd,90) { illegal_1(); op_90(); } /* DB DD */ OP(dd,91) { illegal_1(); op_91(); } /* DB DD */ OP(dd,92) { illegal_1(); op_92(); } /* DB DD */ OP(dd,93) { illegal_1(); op_93(); } /* DB DD */ -OP(dd,94) { R++; SUB(HX); } /* SUB HX */ -OP(dd,95) { R++; SUB(LX); } /* SUB LX */ -OP(dd,96) { R++; EAX; SUB(RM(EA)); } /* SUB (IX+o) */ +OP(dd,94) { SUB(HX); } /* SUB HX */ +OP(dd,95) { SUB(LX); } /* SUB LX */ +OP(dd,96) { EAX; SUB(RM(EA)); } /* SUB (IX+o) */ OP(dd,97) { illegal_1(); op_97(); } /* DB DD */ OP(dd,98) { illegal_1(); op_98(); } /* DB DD */ OP(dd,99) { illegal_1(); op_99(); } /* DB DD */ OP(dd,9a) { illegal_1(); op_9a(); } /* DB DD */ OP(dd,9b) { illegal_1(); op_9b(); } /* DB DD */ -OP(dd,9c) { R++; SBC(HX); } /* SBC A,HX */ -OP(dd,9d) { R++; SBC(LX); } /* SBC A,LX */ -OP(dd,9e) { R++; EAX; SBC(RM(EA)); } /* SBC A,(IX+o) */ +OP(dd,9c) { SBC(HX); } /* SBC A,HX */ +OP(dd,9d) { SBC(LX); } /* SBC A,LX */ +OP(dd,9e) { EAX; SBC(RM(EA)); } /* SBC A,(IX+o) */ OP(dd,9f) { illegal_1(); op_9f(); } /* DB DD */ OP(dd,a0) { illegal_1(); op_a0(); } /* DB DD */ OP(dd,a1) { illegal_1(); op_a1(); } /* DB DD */ OP(dd,a2) { illegal_1(); op_a2(); } /* DB DD */ OP(dd,a3) { illegal_1(); op_a3(); } /* DB DD */ -OP(dd,a4) { R++; AND(HX); } /* AND HX */ -OP(dd,a5) { R++; AND(LX); } /* AND LX */ -OP(dd,a6) { R++; EAX; AND(RM(EA)); } /* AND (IX+o) */ +OP(dd,a4) { AND(HX); } /* AND HX */ +OP(dd,a5) { AND(LX); } /* AND LX */ +OP(dd,a6) { EAX; AND(RM(EA)); } /* AND (IX+o) */ OP(dd,a7) { illegal_1(); op_a7(); } /* DB DD */ OP(dd,a8) { illegal_1(); op_a8(); } /* DB DD */ OP(dd,a9) { illegal_1(); op_a9(); } /* DB DD */ OP(dd,aa) { illegal_1(); op_aa(); } /* DB DD */ OP(dd,ab) { illegal_1(); op_ab(); } /* DB DD */ -OP(dd,ac) { R++; XOR(HX); } /* XOR HX */ -OP(dd,ad) { R++; XOR(LX); } /* XOR LX */ -OP(dd,ae) { R++; EAX; XOR(RM(EA)); } /* XOR (IX+o) */ +OP(dd,ac) { XOR(HX); } /* XOR HX */ +OP(dd,ad) { XOR(LX); } /* XOR LX */ +OP(dd,ae) { EAX; XOR(RM(EA)); } /* XOR (IX+o) */ OP(dd,af) { illegal_1(); op_af(); } /* DB DD */ OP(dd,b0) { illegal_1(); op_b0(); } /* DB DD */ OP(dd,b1) { illegal_1(); op_b1(); } /* DB DD */ OP(dd,b2) { illegal_1(); op_b2(); } /* DB DD */ OP(dd,b3) { illegal_1(); op_b3(); } /* DB DD */ -OP(dd,b4) { R++; OR(HX); } /* OR HX */ -OP(dd,b5) { R++; OR(LX); } /* OR LX */ -OP(dd,b6) { R++; EAX; OR(RM(EA)); } /* OR (IX+o) */ +OP(dd,b4) { OR(HX); } /* OR HX */ +OP(dd,b5) { OR(LX); } /* OR LX */ +OP(dd,b6) { EAX; OR(RM(EA)); } /* OR (IX+o) */ OP(dd,b7) { illegal_1(); op_b7(); } /* DB DD */ OP(dd,b8) { illegal_1(); op_b8(); } /* DB DD */ OP(dd,b9) { illegal_1(); op_b9(); } /* DB DD */ OP(dd,ba) { illegal_1(); op_ba(); } /* DB DD */ OP(dd,bb) { illegal_1(); op_bb(); } /* DB DD */ -OP(dd,bc) { R++; CP(HX); } /* CP HX */ -OP(dd,bd) { R++; CP(LX); } /* CP LX */ -OP(dd,be) { R++; EAX; CP(RM(EA)); } /* CP (IX+o) */ +OP(dd,bc) { CP(HX); } /* CP HX */ +OP(dd,bd) { CP(LX); } /* CP LX */ +OP(dd,be) { EAX; CP(RM(EA)); } /* CP (IX+o) */ OP(dd,bf) { illegal_1(); op_bf(); } /* DB DD */ OP(dd,c0) { illegal_1(); op_c0(); } /* DB DD */ @@ -2225,7 +2242,7 @@ OP(dd,c7) { illegal_1(); op_c7(); } /* DB DD */ OP(dd,c8) { illegal_1(); op_c8(); } /* DB DD */ OP(dd,c9) { illegal_1(); op_c9(); } /* DB DD */ OP(dd,ca) { illegal_1(); op_ca(); } /* DB DD */ -OP(dd,cb) { R++; EAX; EXEC(xycb,ARG()); } /* ** DD CB xx */ +OP(dd,cb) { EAX; EXEC(xycb,ARG()); } /* **** DD CB xx */ OP(dd,cc) { illegal_1(); op_cc(); } /* DB DD */ OP(dd,cd) { illegal_1(); op_cd(); } /* DB DD */ OP(dd,ce) { illegal_1(); op_ce(); } /* DB DD */ @@ -2245,21 +2262,21 @@ OP(dd,d9) { illegal_1(); op_d9(); } /* DB DD */ OP(dd,da) { illegal_1(); op_da(); } /* DB DD */ OP(dd,db) { illegal_1(); op_db(); } /* DB DD */ OP(dd,dc) { illegal_1(); op_dc(); } /* DB DD */ -OP(dd,dd) { illegal_1(); op_dd(); } /* DB DD */ +OP(dd,dd) { EXEC(dd,ROP()); } /* **** DD DD xx */ OP(dd,de) { illegal_1(); op_de(); } /* DB DD */ OP(dd,df) { illegal_1(); op_df(); } /* DB DD */ OP(dd,e0) { illegal_1(); op_e0(); } /* DB DD */ -OP(dd,e1) { R++; POP( ix ); } /* POP IX */ +OP(dd,e1) { POP( ix ); } /* POP IX */ OP(dd,e2) { illegal_1(); op_e2(); } /* DB DD */ -OP(dd,e3) { R++; EXSP( ix ); } /* EX (SP),IX */ +OP(dd,e3) { EXSP( ix ); } /* EX (SP),IX */ OP(dd,e4) { illegal_1(); op_e4(); } /* DB DD */ -OP(dd,e5) { R++; PUSH( ix ); } /* PUSH IX */ +OP(dd,e5) { PUSH( ix ); } /* PUSH IX */ OP(dd,e6) { illegal_1(); op_e6(); } /* DB DD */ OP(dd,e7) { illegal_1(); op_e7(); } /* DB DD */ OP(dd,e8) { illegal_1(); op_e8(); } /* DB DD */ -OP(dd,e9) { R++; PC = IX; } /* JP (IX) */ +OP(dd,e9) { PC = IX; } /* JP (IX) */ OP(dd,ea) { illegal_1(); op_ea(); } /* DB DD */ OP(dd,eb) { illegal_1(); op_eb(); } /* DB DD */ OP(dd,ec) { illegal_1(); op_ec(); } /* DB DD */ @@ -2277,11 +2294,11 @@ OP(dd,f6) { illegal_1(); op_f6(); } /* DB DD */ OP(dd,f7) { illegal_1(); op_f7(); } /* DB DD */ OP(dd,f8) { illegal_1(); op_f8(); } /* DB DD */ -OP(dd,f9) { R++; SP = IX; } /* LD SP,IX */ +OP(dd,f9) { SP = IX; } /* LD SP,IX */ OP(dd,fa) { illegal_1(); op_fa(); } /* DB DD */ OP(dd,fb) { illegal_1(); op_fb(); } /* DB DD */ OP(dd,fc) { illegal_1(); op_fc(); } /* DB DD */ -OP(dd,fd) { illegal_1(); op_fd(); } /* DB DD */ +OP(dd,fd) { EXEC(fd,ROP()); } /* **** DD FD xx */ OP(dd,fe) { illegal_1(); op_fe(); } /* DB DD */ OP(dd,ff) { illegal_1(); op_ff(); } /* DB DD */ @@ -2298,7 +2315,7 @@ OP(fd,06) { illegal_1(); op_06(); } /* DB FD */ OP(fd,07) { illegal_1(); op_07(); } /* DB FD */ OP(fd,08) { illegal_1(); op_08(); } /* DB FD */ -OP(fd,09) { R++; ADD16(iy,bc); } /* ADD IY,BC */ +OP(fd,09) { ADD16(iy,bc); } /* ADD IY,BC */ OP(fd,0a) { illegal_1(); op_0a(); } /* DB FD */ OP(fd,0b) { illegal_1(); op_0b(); } /* DB FD */ OP(fd,0c) { illegal_1(); op_0c(); } /* DB FD */ @@ -2316,7 +2333,7 @@ OP(fd,16) { illegal_1(); op_16(); } /* DB FD */ OP(fd,17) { illegal_1(); op_17(); } /* DB FD */ OP(fd,18) { illegal_1(); op_18(); } /* DB FD */ -OP(fd,19) { R++; ADD16(iy,de); } /* ADD IY,DE */ +OP(fd,19) { ADD16(iy,de); } /* ADD IY,DE */ OP(fd,1a) { illegal_1(); op_1a(); } /* DB FD */ OP(fd,1b) { illegal_1(); op_1b(); } /* DB FD */ OP(fd,1c) { illegal_1(); op_1c(); } /* DB FD */ @@ -2325,34 +2342,34 @@ OP(fd,1e) { illegal_1(); op_1e(); } /* DB FD */ OP(fd,1f) { illegal_1(); op_1f(); } /* DB FD */ OP(fd,20) { illegal_1(); op_20(); } /* DB FD */ -OP(fd,21) { R++; IY = ARG16(); } /* LD IY,w */ -OP(fd,22) { R++; EA = ARG16(); WM16( EA, &Z80.iy ); MEMPTR = EA+1; } /* LD (w),IY */ -OP(fd,23) { R++; IY++; } /* INC IY */ -OP(fd,24) { R++; HY = INC(HY); } /* INC HY */ -OP(fd,25) { R++; HY = DEC(HY); } /* DEC HY */ -OP(fd,26) { R++; HY = ARG(); } /* LD HY,n */ +OP(fd,21) { IY = ARG16(); } /* LD IY,w */ +OP(fd,22) { EA = ARG16(); WM16( EA, &Z80.iy ); MEMPTR = EA+1; } /* LD (w),IY */ +OP(fd,23) { IY++; } /* INC IY */ +OP(fd,24) { HY = INC(HY); } /* INC HY */ +OP(fd,25) { HY = DEC(HY); } /* DEC HY */ +OP(fd,26) { HY = ARG(); } /* LD HY,n */ OP(fd,27) { illegal_1(); op_27(); } /* DB FD */ OP(fd,28) { illegal_1(); op_28(); } /* DB FD */ -OP(fd,29) { R++; ADD16(iy,iy); } /* ADD IY,IY */ -OP(fd,2a) { R++; EA = ARG16(); RM16( EA, &Z80.iy ); MEMPTR = EA+1; } /* LD IY,(w) */ -OP(fd,2b) { R++; IY--; } /* DEC IY */ -OP(fd,2c) { R++; LY = INC(LY); } /* INC LY */ -OP(fd,2d) { R++; LY = DEC(LY); } /* DEC LY */ -OP(fd,2e) { R++; LY = ARG(); } /* LD LY,n */ +OP(fd,29) { ADD16(iy,iy); } /* ADD IY,IY */ +OP(fd,2a) { EA = ARG16(); RM16( EA, &Z80.iy ); MEMPTR = EA+1; } /* LD IY,(w) */ +OP(fd,2b) { IY--; } /* DEC IY */ +OP(fd,2c) { LY = INC(LY); } /* INC LY */ +OP(fd,2d) { LY = DEC(LY); } /* DEC LY */ +OP(fd,2e) { LY = ARG(); } /* LD LY,n */ OP(fd,2f) { illegal_1(); op_2f(); } /* DB FD */ OP(fd,30) { illegal_1(); op_30(); } /* DB FD */ OP(fd,31) { illegal_1(); op_31(); } /* DB FD */ OP(fd,32) { illegal_1(); op_32(); } /* DB FD */ OP(fd,33) { illegal_1(); op_33(); } /* DB FD */ -OP(fd,34) { R++; EAY; WM( EA, INC(RM(EA)) ); } /* INC (IY+o) */ -OP(fd,35) { R++; EAY; WM( EA, DEC(RM(EA)) ); } /* DEC (IY+o) */ -OP(fd,36) { R++; EAY; WM( EA, ARG() ); } /* LD (IY+o),n */ +OP(fd,34) { EAY; WM( EA, INC(RM(EA)) ); } /* INC (IY+o) */ +OP(fd,35) { EAY; WM( EA, DEC(RM(EA)) ); } /* DEC (IY+o) */ +OP(fd,36) { EAY; WM( EA, ARG() ); } /* LD (IY+o),n */ OP(fd,37) { illegal_1(); op_37(); } /* DB FD */ OP(fd,38) { illegal_1(); op_38(); } /* DB FD */ -OP(fd,39) { R++; ADD16(iy,sp); } /* ADD IY,SP */ +OP(fd,39) { ADD16(iy,sp); } /* ADD IY,SP */ OP(fd,3a) { illegal_1(); op_3a(); } /* DB FD */ OP(fd,3b) { illegal_1(); op_3b(); } /* DB FD */ OP(fd,3c) { illegal_1(); op_3c(); } /* DB FD */ @@ -2364,144 +2381,144 @@ OP(fd,40) { illegal_1(); op_40(); } /* DB FD */ OP(fd,41) { illegal_1(); op_41(); } /* DB FD */ OP(fd,42) { illegal_1(); op_42(); } /* DB FD */ OP(fd,43) { illegal_1(); op_43(); } /* DB FD */ -OP(fd,44) { R++; B = HY; } /* LD B,HY */ -OP(fd,45) { R++; B = LY; } /* LD B,LY */ -OP(fd,46) { R++; EAY; B = RM(EA); } /* LD B,(IY+o) */ +OP(fd,44) { B = HY; } /* LD B,HY */ +OP(fd,45) { B = LY; } /* LD B,LY */ +OP(fd,46) { EAY; B = RM(EA); } /* LD B,(IY+o) */ OP(fd,47) { illegal_1(); op_47(); } /* DB FD */ OP(fd,48) { illegal_1(); op_48(); } /* DB FD */ OP(fd,49) { illegal_1(); op_49(); } /* DB FD */ OP(fd,4a) { illegal_1(); op_4a(); } /* DB FD */ OP(fd,4b) { illegal_1(); op_4b(); } /* DB FD */ -OP(fd,4c) { R++; C = HY; } /* LD C,HY */ -OP(fd,4d) { R++; C = LY; } /* LD C,LY */ -OP(fd,4e) { R++; EAY; C = RM(EA); } /* LD C,(IY+o) */ +OP(fd,4c) { C = HY; } /* LD C,HY */ +OP(fd,4d) { C = LY; } /* LD C,LY */ +OP(fd,4e) { EAY; C = RM(EA); } /* LD C,(IY+o) */ OP(fd,4f) { illegal_1(); op_4f(); } /* DB FD */ OP(fd,50) { illegal_1(); op_50(); } /* DB FD */ OP(fd,51) { illegal_1(); op_51(); } /* DB FD */ OP(fd,52) { illegal_1(); op_52(); } /* DB FD */ OP(fd,53) { illegal_1(); op_53(); } /* DB FD */ -OP(fd,54) { R++; D = HY; } /* LD D,HY */ -OP(fd,55) { R++; D = LY; } /* LD D,LY */ -OP(fd,56) { R++; EAY; D = RM(EA); } /* LD D,(IY+o) */ +OP(fd,54) { D = HY; } /* LD D,HY */ +OP(fd,55) { D = LY; } /* LD D,LY */ +OP(fd,56) { EAY; D = RM(EA); } /* LD D,(IY+o) */ OP(fd,57) { illegal_1(); op_57(); } /* DB FD */ OP(fd,58) { illegal_1(); op_58(); } /* DB FD */ OP(fd,59) { illegal_1(); op_59(); } /* DB FD */ OP(fd,5a) { illegal_1(); op_5a(); } /* DB FD */ OP(fd,5b) { illegal_1(); op_5b(); } /* DB FD */ -OP(fd,5c) { R++; E = HY; } /* LD E,HY */ -OP(fd,5d) { R++; E = LY; } /* LD E,LY */ -OP(fd,5e) { R++; EAY; E = RM(EA); } /* LD E,(IY+o) */ +OP(fd,5c) { E = HY; } /* LD E,HY */ +OP(fd,5d) { E = LY; } /* LD E,LY */ +OP(fd,5e) { EAY; E = RM(EA); } /* LD E,(IY+o) */ OP(fd,5f) { illegal_1(); op_5f(); } /* DB FD */ -OP(fd,60) { R++; HY = B; } /* LD HY,B */ -OP(fd,61) { R++; HY = C; } /* LD HY,C */ -OP(fd,62) { R++; HY = D; } /* LD HY,D */ -OP(fd,63) { R++; HY = E; } /* LD HY,E */ -OP(fd,64) { R++; } /* LD HY,HY */ -OP(fd,65) { R++; HY = LY; } /* LD HY,LY */ -OP(fd,66) { R++; EAY; H = RM(EA); } /* LD H,(IY+o) */ -OP(fd,67) { R++; HY = A; } /* LD HY,A */ +OP(fd,60) { HY = B; } /* LD HY,B */ +OP(fd,61) { HY = C; } /* LD HY,C */ +OP(fd,62) { HY = D; } /* LD HY,D */ +OP(fd,63) { HY = E; } /* LD HY,E */ +OP(fd,64) { } /* LD HY,HY */ +OP(fd,65) { HY = LY; } /* LD HY,LY */ +OP(fd,66) { EAY; H = RM(EA); } /* LD H,(IY+o) */ +OP(fd,67) { HY = A; } /* LD HY,A */ -OP(fd,68) { R++; LY = B; } /* LD LY,B */ -OP(fd,69) { R++; LY = C; } /* LD LY,C */ -OP(fd,6a) { R++; LY = D; } /* LD LY,D */ -OP(fd,6b) { R++; LY = E; } /* LD LY,E */ -OP(fd,6c) { R++; LY = HY; } /* LD LY,HY */ -OP(fd,6d) { R++; } /* LD LY,LY */ -OP(fd,6e) { R++; EAY; L = RM(EA); } /* LD L,(IY+o) */ -OP(fd,6f) { R++; LY = A; } /* LD LY,A */ +OP(fd,68) { LY = B; } /* LD LY,B */ +OP(fd,69) { LY = C; } /* LD LY,C */ +OP(fd,6a) { LY = D; } /* LD LY,D */ +OP(fd,6b) { LY = E; } /* LD LY,E */ +OP(fd,6c) { LY = HY; } /* LD LY,HY */ +OP(fd,6d) { } /* LD LY,LY */ +OP(fd,6e) { EAY; L = RM(EA); } /* LD L,(IY+o) */ +OP(fd,6f) { LY = A; } /* LD LY,A */ -OP(fd,70) { R++; EAY; WM( EA, B ); } /* LD (IY+o),B */ -OP(fd,71) { R++; EAY; WM( EA, C ); } /* LD (IY+o),C */ -OP(fd,72) { R++; EAY; WM( EA, D ); } /* LD (IY+o),D */ -OP(fd,73) { R++; EAY; WM( EA, E ); } /* LD (IY+o),E */ -OP(fd,74) { R++; EAY; WM( EA, H ); } /* LD (IY+o),H */ -OP(fd,75) { R++; EAY; WM( EA, L ); } /* LD (IY+o),L */ +OP(fd,70) { EAY; WM( EA, B ); } /* LD (IY+o),B */ +OP(fd,71) { EAY; WM( EA, C ); } /* LD (IY+o),C */ +OP(fd,72) { EAY; WM( EA, D ); } /* LD (IY+o),D */ +OP(fd,73) { EAY; WM( EA, E ); } /* LD (IY+o),E */ +OP(fd,74) { EAY; WM( EA, H ); } /* LD (IY+o),H */ +OP(fd,75) { EAY; WM( EA, L ); } /* LD (IY+o),L */ OP(fd,76) { illegal_1(); op_76(); } /* DB FD */ -OP(fd,77) { R++; EAY; WM( EA, A ); } /* LD (IY+o),A */ +OP(fd,77) { EAY; WM( EA, A ); } /* LD (IY+o),A */ OP(fd,78) { illegal_1(); op_78(); } /* DB FD */ OP(fd,79) { illegal_1(); op_79(); } /* DB FD */ OP(fd,7a) { illegal_1(); op_7a(); } /* DB FD */ OP(fd,7b) { illegal_1(); op_7b(); } /* DB FD */ -OP(fd,7c) { R++; A = HY; } /* LD A,HY */ -OP(fd,7d) { R++; A = LY; } /* LD A,LY */ -OP(fd,7e) { R++; EAY; A = RM(EA); } /* LD A,(IY+o) */ +OP(fd,7c) { A = HY; } /* LD A,HY */ +OP(fd,7d) { A = LY; } /* LD A,LY */ +OP(fd,7e) { EAY; A = RM(EA); } /* LD A,(IY+o) */ OP(fd,7f) { illegal_1(); op_7f(); } /* DB FD */ OP(fd,80) { illegal_1(); op_80(); } /* DB FD */ OP(fd,81) { illegal_1(); op_81(); } /* DB FD */ OP(fd,82) { illegal_1(); op_82(); } /* DB FD */ OP(fd,83) { illegal_1(); op_83(); } /* DB FD */ -OP(fd,84) { R++; ADD(HY); } /* ADD A,HY */ -OP(fd,85) { R++; ADD(LY); } /* ADD A,LY */ -OP(fd,86) { R++; EAY; ADD(RM(EA)); } /* ADD A,(IY+o) */ +OP(fd,84) { ADD(HY); } /* ADD A,HY */ +OP(fd,85) { ADD(LY); } /* ADD A,LY */ +OP(fd,86) { EAY; ADD(RM(EA)); } /* ADD A,(IY+o) */ OP(fd,87) { illegal_1(); op_87(); } /* DB FD */ OP(fd,88) { illegal_1(); op_88(); } /* DB FD */ OP(fd,89) { illegal_1(); op_89(); } /* DB FD */ OP(fd,8a) { illegal_1(); op_8a(); } /* DB FD */ OP(fd,8b) { illegal_1(); op_8b(); } /* DB FD */ -OP(fd,8c) { R++; ADC(HY); } /* ADC A,HY */ -OP(fd,8d) { R++; ADC(LY); } /* ADC A,LY */ -OP(fd,8e) { R++; EAY; ADC(RM(EA)); } /* ADC A,(IY+o) */ +OP(fd,8c) { ADC(HY); } /* ADC A,HY */ +OP(fd,8d) { ADC(LY); } /* ADC A,LY */ +OP(fd,8e) { EAY; ADC(RM(EA)); } /* ADC A,(IY+o) */ OP(fd,8f) { illegal_1(); op_8f(); } /* DB FD */ OP(fd,90) { illegal_1(); op_90(); } /* DB FD */ OP(fd,91) { illegal_1(); op_91(); } /* DB FD */ OP(fd,92) { illegal_1(); op_92(); } /* DB FD */ OP(fd,93) { illegal_1(); op_93(); } /* DB FD */ -OP(fd,94) { R++; SUB(HY); } /* SUB HY */ -OP(fd,95) { R++; SUB(LY); } /* SUB LY */ -OP(fd,96) { R++; EAY; SUB(RM(EA)); } /* SUB (IY+o) */ +OP(fd,94) { SUB(HY); } /* SUB HY */ +OP(fd,95) { SUB(LY); } /* SUB LY */ +OP(fd,96) { EAY; SUB(RM(EA)); } /* SUB (IY+o) */ OP(fd,97) { illegal_1(); op_97(); } /* DB FD */ OP(fd,98) { illegal_1(); op_98(); } /* DB FD */ OP(fd,99) { illegal_1(); op_99(); } /* DB FD */ OP(fd,9a) { illegal_1(); op_9a(); } /* DB FD */ OP(fd,9b) { illegal_1(); op_9b(); } /* DB FD */ -OP(fd,9c) { R++; SBC(HY); } /* SBC A,HY */ -OP(fd,9d) { R++; SBC(LY); } /* SBC A,LY */ -OP(fd,9e) { R++; EAY; SBC(RM(EA)); } /* SBC A,(IY+o) */ +OP(fd,9c) { SBC(HY); } /* SBC A,HY */ +OP(fd,9d) { SBC(LY); } /* SBC A,LY */ +OP(fd,9e) { EAY; SBC(RM(EA)); } /* SBC A,(IY+o) */ OP(fd,9f) { illegal_1(); op_9f(); } /* DB FD */ OP(fd,a0) { illegal_1(); op_a0(); } /* DB FD */ OP(fd,a1) { illegal_1(); op_a1(); } /* DB FD */ OP(fd,a2) { illegal_1(); op_a2(); } /* DB FD */ OP(fd,a3) { illegal_1(); op_a3(); } /* DB FD */ -OP(fd,a4) { R++; AND(HY); } /* AND HY */ -OP(fd,a5) { R++; AND(LY); } /* AND LY */ -OP(fd,a6) { R++; EAY; AND(RM(EA)); } /* AND (IY+o) */ +OP(fd,a4) { AND(HY); } /* AND HY */ +OP(fd,a5) { AND(LY); } /* AND LY */ +OP(fd,a6) { EAY; AND(RM(EA)); } /* AND (IY+o) */ OP(fd,a7) { illegal_1(); op_a7(); } /* DB FD */ OP(fd,a8) { illegal_1(); op_a8(); } /* DB FD */ OP(fd,a9) { illegal_1(); op_a9(); } /* DB FD */ OP(fd,aa) { illegal_1(); op_aa(); } /* DB FD */ OP(fd,ab) { illegal_1(); op_ab(); } /* DB FD */ -OP(fd,ac) { R++; XOR(HY); } /* XOR HY */ -OP(fd,ad) { R++; XOR(LY); } /* XOR LY */ -OP(fd,ae) { R++; EAY; XOR(RM(EA)); } /* XOR (IY+o) */ +OP(fd,ac) { XOR(HY); } /* XOR HY */ +OP(fd,ad) { XOR(LY); } /* XOR LY */ +OP(fd,ae) { EAY; XOR(RM(EA)); } /* XOR (IY+o) */ OP(fd,af) { illegal_1(); op_af(); } /* DB FD */ OP(fd,b0) { illegal_1(); op_b0(); } /* DB FD */ OP(fd,b1) { illegal_1(); op_b1(); } /* DB FD */ OP(fd,b2) { illegal_1(); op_b2(); } /* DB FD */ OP(fd,b3) { illegal_1(); op_b3(); } /* DB FD */ -OP(fd,b4) { R++; OR(HY); } /* OR HY */ -OP(fd,b5) { R++; OR(LY); } /* OR LY */ -OP(fd,b6) { R++; EAY; OR(RM(EA)); } /* OR (IY+o) */ +OP(fd,b4) { OR(HY); } /* OR HY */ +OP(fd,b5) { OR(LY); } /* OR LY */ +OP(fd,b6) { EAY; OR(RM(EA)); } /* OR (IY+o) */ OP(fd,b7) { illegal_1(); op_b7(); } /* DB FD */ OP(fd,b8) { illegal_1(); op_b8(); } /* DB FD */ OP(fd,b9) { illegal_1(); op_b9(); } /* DB FD */ OP(fd,ba) { illegal_1(); op_ba(); } /* DB FD */ OP(fd,bb) { illegal_1(); op_bb(); } /* DB FD */ -OP(fd,bc) { R++; CP(HY); } /* CP HY */ -OP(fd,bd) { R++; CP(LY); } /* CP LY */ -OP(fd,be) { R++; EAY; CP(RM(EA)); } /* CP (IY+o) */ +OP(fd,bc) { CP(HY); } /* CP HY */ +OP(fd,bd) { CP(LY); } /* CP LY */ +OP(fd,be) { EAY; CP(RM(EA)); } /* CP (IY+o) */ OP(fd,bf) { illegal_1(); op_bf(); } /* DB FD */ OP(fd,c0) { illegal_1(); op_c0(); } /* DB FD */ @@ -2516,7 +2533,7 @@ OP(fd,c7) { illegal_1(); op_c7(); } /* DB FD */ OP(fd,c8) { illegal_1(); op_c8(); } /* DB FD */ OP(fd,c9) { illegal_1(); op_c9(); } /* DB FD */ OP(fd,ca) { illegal_1(); op_ca(); } /* DB FD */ -OP(fd,cb) { R++; EAY; EXEC(xycb,ARG()); } /* ** FD CB xx */ +OP(fd,cb) { EAY; EXEC(xycb,ARG()); } /* **** FD CB xx */ OP(fd,cc) { illegal_1(); op_cc(); } /* DB FD */ OP(fd,cd) { illegal_1(); op_cd(); } /* DB FD */ OP(fd,ce) { illegal_1(); op_ce(); } /* DB FD */ @@ -2536,21 +2553,21 @@ OP(fd,d9) { illegal_1(); op_d9(); } /* DB FD */ OP(fd,da) { illegal_1(); op_da(); } /* DB FD */ OP(fd,db) { illegal_1(); op_db(); } /* DB FD */ OP(fd,dc) { illegal_1(); op_dc(); } /* DB FD */ -OP(fd,dd) { illegal_1(); op_dd(); } /* DB FD */ +OP(fd,dd) { EXEC(dd,ROP()); } /* **** FD DD xx */ OP(fd,de) { illegal_1(); op_de(); } /* DB FD */ OP(fd,df) { illegal_1(); op_df(); } /* DB FD */ OP(fd,e0) { illegal_1(); op_e0(); } /* DB FD */ -OP(fd,e1) { R++; POP( iy ); } /* POP IY */ +OP(fd,e1) { POP( iy ); } /* POP IY */ OP(fd,e2) { illegal_1(); op_e2(); } /* DB FD */ -OP(fd,e3) { R++; EXSP( iy ); } /* EX (SP),IY */ +OP(fd,e3) { EXSP( iy ); } /* EX (SP),IY */ OP(fd,e4) { illegal_1(); op_e4(); } /* DB FD */ -OP(fd,e5) { R++; PUSH( iy ); } /* PUSH IY */ +OP(fd,e5) { PUSH( iy ); } /* PUSH IY */ OP(fd,e6) { illegal_1(); op_e6(); } /* DB FD */ OP(fd,e7) { illegal_1(); op_e7(); } /* DB FD */ OP(fd,e8) { illegal_1(); op_e8(); } /* DB FD */ -OP(fd,e9) { R++; PC = IY; } /* JP (IY) */ +OP(fd,e9) { PC = IY; } /* JP (IY) */ OP(fd,ea) { illegal_1(); op_ea(); } /* DB FD */ OP(fd,eb) { illegal_1(); op_eb(); } /* DB FD */ OP(fd,ec) { illegal_1(); op_ec(); } /* DB FD */ @@ -2568,11 +2585,11 @@ OP(fd,f6) { illegal_1(); op_f6(); } /* DB FD */ OP(fd,f7) { illegal_1(); op_f7(); } /* DB FD */ OP(fd,f8) { illegal_1(); op_f8(); } /* DB FD */ -OP(fd,f9) { R++; SP = IY; } /* LD SP,IY */ +OP(fd,f9) { SP = IY; } /* LD SP,IY */ OP(fd,fa) { illegal_1(); op_fa(); } /* DB FD */ OP(fd,fb) { illegal_1(); op_fb(); } /* DB FD */ OP(fd,fc) { illegal_1(); op_fc(); } /* DB FD */ -OP(fd,fd) { illegal_1(); op_fd(); } /* DB FD */ +OP(fd,fd) { EXEC(fd,ROP()); } /* **** FD FD xx */ OP(fd,fe) { illegal_1(); op_fe(); } /* DB FD */ OP(fd,ff) { illegal_1(); op_ff(); } /* DB FD */ @@ -3136,45 +3153,42 @@ OP(op,e1) { POP( hl ); } /* POP HL */ OP(op,e2) { JP_COND( !(F & PF) ); } /* JP PO,a */ OP(op,e3) { EXSP( hl ); } /* EX HL,(SP) */ OP(op,e4) { CALL_COND( !(F & PF), 0xe4 ); } /* CALL PO,a */ -OP(op,e5) { PUSH( hl ); } /* PUSH HL */ -OP(op,e6) { AND(ARG()); } /* AND n */ -OP(op,e7) { RST(0x20); } /* RST 4 */ +OP(op,e5) { PUSH( hl ); } /* PUSH HL */ +OP(op,e6) { AND(ARG()); } /* AND n */ +OP(op,e7) { RST(0x20); } /* RST 4 */ -OP(op,e8) { RET_COND( F & PF, 0xe8 ); } /* RET PE */ +OP(op,e8) { RET_COND( F & PF, 0xe8 ); } /* RET PE */ OP(op,e9) { PC = HL; } /* JP (HL) */ -OP(op,ea) { JP_COND( F & PF ); } /* JP PE,a */ -OP(op,eb) { EX_DE_HL; } /* EX DE,HL */ -OP(op,ec) { CALL_COND( F & PF, 0xec ); } /* CALL PE,a */ -OP(op,ed) { R++; EXEC(ed,ROP()); } /* **** ED xx */ -OP(op,ee) { XOR(ARG()); } /* XOR n */ -OP(op,ef) { RST(0x28); } /* RST 5 */ +OP(op,ea) { JP_COND( F & PF ); } /* JP PE,a */ +OP(op,eb) { EX_DE_HL; } /* EX DE,HL */ +OP(op,ec) { CALL_COND( F & PF, 0xec ); } /* CALL PE,a */ +OP(op,ed) { R++; EXEC(ed,ROP()); } /* **** ED xx */ +OP(op,ee) { XOR(ARG()); } /* XOR n */ +OP(op,ef) { RST(0x28); } /* RST 5 */ -OP(op,f0) { RET_COND( !(F & SF), 0xf0 ); } /* RET P */ -OP(op,f1) { POP( af ); } /* POP AF */ -OP(op,f2) { JP_COND( !(F & SF) ); } /* JP P,a */ -OP(op,f3) { IFF1 = IFF2 = 0; } /* DI */ -OP(op,f4) { CALL_COND( !(F & SF), 0xf4 ); } /* CALL P,a */ -OP(op,f5) { PUSH( af ); } /* PUSH AF */ -OP(op,f6) { OR(ARG()); } /* OR n */ -OP(op,f7) { RST(0x30); } /* RST 6 */ +OP(op,f0) { RET_COND( !(F & SF), 0xf0 ); } /* RET P */ +OP(op,f1) { POP( af ); } /* POP AF */ +OP(op,f2) { JP_COND( !(F & SF) ); } /* JP P,a */ +OP(op,f3) { IFF1 = IFF2 = 0; } /* DI */ +OP(op,f4) { CALL_COND( !(F & SF), 0xf4 ); } /* CALL P,a */ +OP(op,f5) { PUSH( af ); } /* PUSH AF */ +OP(op,f6) { OR(ARG()); } /* OR n */ +OP(op,f7) { RST(0x30); } /* RST 6 */ -OP(op,f8) { RET_COND( F & SF, 0xf8 ); } /* RET M */ -OP(op,f9) { SP = HL; } /* LD SP,HL */ -OP(op,fa) { JP_COND(F & SF); } /* JP M,a */ -OP(op,fb) { EI; } /* EI */ -OP(op,fc) { CALL_COND( F & SF, 0xfc ); } /* CALL M,a */ -OP(op,fd) { R++; EXEC(fd,ROP()); } /* **** FD xx */ -OP(op,fe) { CP(ARG()); } /* CP n */ -OP(op,ff) { RST(0x38); } /* RST 7 */ +OP(op,f8) { RET_COND( F & SF, 0xf8 ); } /* RET M */ +OP(op,f9) { SP = HL; } /* LD SP,HL */ +OP(op,fa) { JP_COND(F & SF); } /* JP M,a */ +OP(op,fb) { EI; } /* EI */ +OP(op,fc) { CALL_COND( F & SF, 0xfc ); } /* CALL M,a */ +OP(op,fd) { R++; EXEC(fd,ROP()); } /* **** FD xx */ +OP(op,fe) { CP(ARG()); } /* CP n */ +OP(op,ff) { RST(0x38); } /* RST 7 */ static void take_interrupt(void) { int irq_vector; - /* there isn't a valid previous program counter */ - PRVPC = -1; - /* Check if processor was halted */ LEAVE_HALT; @@ -3188,51 +3202,51 @@ static void take_interrupt(void) /* Interrupt mode 2. Call [Z80.i:databyte] */ if( IM == 2 ) - { + { irq_vector = (irq_vector & 0xff) | (I << 8); PUSH( pc ); RM16( irq_vector, &Z80.pc ); LOG(("Z80 #%d IM2 [$%04x] = $%04x\n",cpu_getactivecpu() , irq_vector, PCD)); - /* CALL opcode timing */ - z80_ICount -= cc[Z80_TABLE_op][0xcd]; - } - else + /* CALL $xxxx + 'interrupt latency' cycles */ + z80_ICount -= cc[Z80_TABLE_op][0xcd] + cc[Z80_TABLE_ex][0xff]; + } + else /* Interrupt mode 1. RST 38h */ if( IM == 1 ) - { + { LOG(("Z80 #%d IM1 $0038\n",cpu_getactivecpu() )); PUSH( pc ); PCD = 0x0038; /* RST $38 + 'interrupt latency' cycles */ z80_ICount -= cc[Z80_TABLE_op][0xff] + cc[Z80_TABLE_ex][0xff]; - } - else - { - /* Interrupt mode 0. We check for CALL and JP instructions, */ - /* if neither of these were found we assume a 1 byte opcode */ - /* was placed on the databus */ + } + else + { + /* Interrupt mode 0. We check for CALL and JP instructions, */ + /* if neither of these were found we assume a 1 byte opcode */ + /* was placed on the databus */ LOG(("Z80 #%d IM0 $%04x\n",cpu_getactivecpu() , irq_vector)); - switch (irq_vector & 0xff0000) - { - case 0xcd0000: /* call */ + switch (irq_vector & 0xff0000) + { + case 0xcd0000: /* call */ PUSH( pc ); PCD = irq_vector & 0xffff; /* CALL $xxxx + 'interrupt latency' cycles */ z80_ICount -= cc[Z80_TABLE_op][0xcd] + cc[Z80_TABLE_ex][0xff]; - break; - case 0xc30000: /* jump */ + break; + case 0xc30000: /* jump */ PCD = irq_vector & 0xffff; /* JP $xxxx + 2 cycles */ z80_ICount -= cc[Z80_TABLE_op][0xc3] + cc[Z80_TABLE_ex][0xff]; - break; - default: /* rst (or other opcodes?) */ + break; + default: /* rst (or other opcodes?) */ PUSH( pc ); PCD = irq_vector & 0x0038; /* RST $xx + 2 cycles */ z80_ICount -= cc[Z80_TABLE_op][0xff] + cc[Z80_TABLE_ex][0xff]; - break; - } + break; } + } MEMPTR=PCD; } @@ -3328,6 +3342,7 @@ void z80_init(int index, int clock, const void *config, int (*irqcallback)(int)) /* Reset registers to their initial values */ Z80.daisy = config; Z80.irq_callback = irqcallback; + /* setup cycle tables */ cc[Z80_TABLE_op] = cc_op; cc[Z80_TABLE_cb] = cc_cb; @@ -3383,9 +3398,8 @@ int z80_execute(int cycles) /* via timers, and can't be dynamically enabled, so it is safe */ /* to just check here */ if (Z80.nmi_pending) -{ + { LOG(("Z80 #%d take NMI\n", cpu_getactivecpu())); - PRVPC = -1; /* there isn't a valid previous program counter */ LEAVE_HALT; /* Check if processor was halted */ IFF1 = 0; @@ -3396,17 +3410,19 @@ int z80_execute(int cycles) Z80.nmi_pending = FALSE; } - do + while( z80_ICount > 0 ) { /* check for IRQs before each instruction */ if (Z80.irq_state != CLEAR_LINE && IFF1 && !Z80.after_ei) take_interrupt(); Z80.after_ei = FALSE; - PRVPC = PCD; + if (z80_ICount > 0) + { R++; EXEC_INLINE(op,ROP()); - } while( z80_ICount > 0 ); + } + } return cycles - z80_ICount; }