diff options
author | Dave Chapman <dave@dchapman.com> | 2006-03-11 15:44:35 +0000 |
---|---|---|
committer | Dave Chapman <dave@dchapman.com> | 2006-03-11 15:44:35 +0000 |
commit | a814584c87fef79038f6b0f311cfc70fb51d1b95 (patch) | |
tree | 4df31679017735c7fa64b32ae78ec3ad078271ae | |
parent | 1246668a7807f1f5b9253ad7f9a682fb6b2ff7dd (diff) | |
download | rockbox-a814584c87fef79038f6b0f311cfc70fb51d1b95.tar.gz rockbox-a814584c87fef79038f6b0f311cfc70fb51d1b95.zip |
pacbox - a Pacman arcade machine emulator. Currently working for all colour targets and the iriver H1x0. Requires the Pacman arcade machine ROMs in /.rockbox/pacman/
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9001 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugin.c | 8 | ||||
-rw-r--r-- | apps/plugin.h | 12 | ||||
-rw-r--r-- | apps/plugins/Makefile | 6 | ||||
-rw-r--r-- | apps/plugins/pacbox/Makefile | 113 | ||||
-rw-r--r-- | apps/plugins/pacbox/arcade.c | 577 | ||||
-rw-r--r-- | apps/plugins/pacbox/arcade.h | 199 | ||||
-rw-r--r-- | apps/plugins/pacbox/hardware.c | 197 | ||||
-rw-r--r-- | apps/plugins/pacbox/hardware.h | 141 | ||||
-rw-r--r-- | apps/plugins/pacbox/pacbox.c | 534 | ||||
-rw-r--r-- | apps/plugins/pacbox/readme.txt | 13 | ||||
-rw-r--r-- | apps/plugins/pacbox/z80.c | 8058 | ||||
-rw-r--r-- | apps/plugins/pacbox/z80.h | 160 | ||||
-rw-r--r-- | apps/plugins/pacbox/z80_internal.h | 1062 |
13 files changed, 11079 insertions, 1 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index e7758df51c..7aa30c9ea2 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -410,6 +410,14 @@ static const struct plugin_api rockbox_api = { | |||
410 | 410 | ||
411 | /* new stuff at the end, sort into place next time | 411 | /* new stuff at the end, sort into place next time |
412 | the API gets incompatible */ | 412 | the API gets incompatible */ |
413 | |||
414 | #if CONFIG_KEYPAD == IRIVER_H300_PAD || CONFIG_KEYPAD == IPOD_4G_PAD | ||
415 | /* NOTE: This is already in the plugin api for the H100 - but we put it | ||
416 | at the end for other targets to keep the plugin api compatible */ | ||
417 | button_hold, | ||
418 | #endif | ||
419 | /* options */ | ||
420 | set_option, | ||
413 | }; | 421 | }; |
414 | 422 | ||
415 | int plugin_load(const char* plugin, void* parameter) | 423 | int plugin_load(const char* plugin, void* parameter) |
diff --git a/apps/plugin.h b/apps/plugin.h index df23ed1c00..9ebe31f806 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -99,7 +99,7 @@ | |||
99 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 99 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
100 | 100 | ||
101 | /* increase this every time the api struct changes */ | 101 | /* increase this every time the api struct changes */ |
102 | #define PLUGIN_API_VERSION 11 | 102 | #define PLUGIN_API_VERSION 12 |
103 | 103 | ||
104 | /* update this to latest version if a change to the api struct breaks | 104 | /* update this to latest version if a change to the api struct breaks |
105 | backwards compatibility (and please take the opportunity to sort in any | 105 | backwards compatibility (and please take the opportunity to sort in any |
@@ -476,6 +476,16 @@ struct plugin_api { | |||
476 | /* new stuff at the end, sort into place next time | 476 | /* new stuff at the end, sort into place next time |
477 | the API gets incompatible */ | 477 | the API gets incompatible */ |
478 | 478 | ||
479 | #if CONFIG_KEYPAD == IRIVER_H300_PAD || CONFIG_KEYPAD == IPOD_4G_PAD | ||
480 | /* NOTE: This is already in the plugin api for the H100 - but we put it | ||
481 | at the end for other targets to keep the plugin api compatible */ | ||
482 | bool (*button_hold)(void); | ||
483 | #endif | ||
484 | /* options */ | ||
485 | bool (*set_option)(const char* string, void* variable, | ||
486 | enum optiontype type, const struct opt_items* options, | ||
487 | int numoptions, void (*function)(int)); | ||
488 | |||
479 | }; | 489 | }; |
480 | 490 | ||
481 | /* plugin header */ | 491 | /* plugin header */ |
diff --git a/apps/plugins/Makefile b/apps/plugins/Makefile index 8c72294709..b591432646 100644 --- a/apps/plugins/Makefile +++ b/apps/plugins/Makefile | |||
@@ -77,6 +77,12 @@ ifneq (-DIRIVER_IFP7XX,$(TARGET)) | |||
77 | endif | 77 | endif |
78 | endif | 78 | endif |
79 | 79 | ||
80 | # For all the colour targets and iriver H1x0 | ||
81 | ifneq (,$(strip $(foreach tgt,IPOD_VIDEO IPOD_NANO IPOD_COLOR IRIVER \ | ||
82 | IAUDIO_X5 GIGABEAT,$(findstring $(tgt),$(TARGET))))) | ||
83 | SUBDIRS += pacbox | ||
84 | endif | ||
85 | |||
80 | .PHONY: $(SUBDIRS) | 86 | .PHONY: $(SUBDIRS) |
81 | all: $(BUILDDIR)/libplugin.a $(ROCKS) $(SUBDIRS) $(DEPFILE) | 87 | all: $(BUILDDIR)/libplugin.a $(ROCKS) $(SUBDIRS) $(DEPFILE) |
82 | 88 | ||
diff --git a/apps/plugins/pacbox/Makefile b/apps/plugins/pacbox/Makefile new file mode 100644 index 0000000000..817c6d451a --- /dev/null +++ b/apps/plugins/pacbox/Makefile | |||
@@ -0,0 +1,113 @@ | |||
1 | # __________ __ ___. | ||
2 | # Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
3 | # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
4 | # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
5 | # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
6 | # \/ \/ \/ \/ \/ | ||
7 | # $Id$ | ||
8 | # | ||
9 | |||
10 | INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ | ||
11 | -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) | ||
12 | CFLAGS = $(INCLUDES) $(GCCOPTS) -O2 $(TARGET) $(EXTRA_DEFINES) \ | ||
13 | -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN | ||
14 | |||
15 | |||
16 | ifdef APPEXTRA | ||
17 | INCLUDES += $(patsubst %,-I$(APPSDIR)/%,$(subst :, ,$(APPEXTRA))) | ||
18 | endif | ||
19 | |||
20 | LINKFILE := $(OBJDIR)/link.lds | ||
21 | DEPFILE = $(OBJDIR)/dep-pacbox | ||
22 | SRC = arcade.c pacbox.c hardware.c z80.c | ||
23 | |||
24 | SOURCES = $(SRC) | ||
25 | OBJS := $(SRC:%.c=$(OBJDIR)/%.o) | ||
26 | DIRS = . | ||
27 | |||
28 | LDS := ../plugin.lds | ||
29 | OUTPUT = $(OUTDIR)/pacbox.rock | ||
30 | |||
31 | all: $(OUTPUT) | ||
32 | |||
33 | ifndef SIMVER | ||
34 | $(OBJDIR)/pacbox.elf: $(OBJS) $(LINKFILE) | ||
35 | @echo "LD "`basename $@` | ||
36 | @$(CC) $(GCCOPTS) -O -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -lplugin -lgcc \ | ||
37 | -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/pacbox.map | ||
38 | |||
39 | $(OUTPUT): $(OBJDIR)/pacbox.elf | ||
40 | @echo "OBJCOPY "`basename $@` | ||
41 | @$(OC) -O binary $< $@ | ||
42 | else | ||
43 | |||
44 | ifeq ($(SIMVER), x11) | ||
45 | ################################################### | ||
46 | # This is the X11 simulator version | ||
47 | |||
48 | $(OUTPUT): $(OBJS) | ||
49 | @echo "LD $<" | ||
50 | @$(CC) $(CFLAGS) -shared $(OBJS) -L$(BUILDDIR) -lplugin -o $@ | ||
51 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) | ||
52 | # 'x' must be kept or you'll have "Win32 error 5" | ||
53 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 | ||
54 | # #define ERROR_ACCESS_DENIED 5L | ||
55 | else | ||
56 | @chmod -x $@ | ||
57 | endif | ||
58 | |||
59 | else # end of x11-simulator | ||
60 | ifeq ($(SIMVER), sdl) | ||
61 | ################################################### | ||
62 | # This is the SDL simulator version | ||
63 | |||
64 | $(OUTPUT): $(OBJS) | ||
65 | @echo "LD $<" | ||
66 | @$(CC) $(CFLAGS) -shared $(OBJS) -L$(BUILDDIR) -lplugin -o $@ | ||
67 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) | ||
68 | # 'x' must be kept or you'll have "Win32 error 5" | ||
69 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 | ||
70 | # #define ERROR_ACCESS_DENIED 5L | ||
71 | else | ||
72 | @chmod -x $@ | ||
73 | endif | ||
74 | |||
75 | else # end of sdl-simulator | ||
76 | ################################################### | ||
77 | # This is the win32 simulator version | ||
78 | DLLTOOLFLAGS = --export-all | ||
79 | DLLWRAPFLAGS = -s --entry _DllMain@12 --target=i386-mingw32 -mno-cygwin | ||
80 | |||
81 | $(OUTPUT): $(OBJS) | ||
82 | @echo "DLL "`basename $@` | ||
83 | @$(DLLTOOL) $(DLLTOOLFLAGS) -z $(OBJDIR)/$*.def $(OBJS) | ||
84 | @$(DLLWRAP) $(DLLWRAPFLAGS) --def $(OBJDIR)/$*.def $(OBJS) \ | ||
85 | $(BUILDDIR)/libplugin.a -o $@ | ||
86 | ifeq ($(findstring CYGWIN,$(UNAME)),CYGWIN) | ||
87 | # 'x' must be kept or you'll have "Win32 error 5" | ||
88 | # $ fgrep 5 /usr/include/w32api/winerror.h | head -1 | ||
89 | # #define ERROR_ACCESS_DENIED 5L | ||
90 | else | ||
91 | @chmod -x $@ | ||
92 | endif | ||
93 | endif # end of win32-simulator | ||
94 | endif | ||
95 | endif # end of simulator section | ||
96 | |||
97 | |||
98 | include $(TOOLSDIR)/make.inc | ||
99 | |||
100 | # MEMORYSIZE should be passed on to this makefile with the chosen memory size | ||
101 | # given in number of MB | ||
102 | $(LINKFILE): $(LDS) | ||
103 | @echo "build "`basename $@` | ||
104 | @cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) \ | ||
105 | $(DEFINES) -E -P - >$@ | ||
106 | |||
107 | clean: | ||
108 | @echo "cleaning pacbox" | ||
109 | @rm -rf $(OBJDIR)/pacbox | ||
110 | @rm -f $(OBJDIR)/pacbox.* $(DEPFILE) | ||
111 | |||
112 | -include $(DEPFILE) | ||
113 | |||
diff --git a/apps/plugins/pacbox/arcade.c b/apps/plugins/pacbox/arcade.c new file mode 100644 index 0000000000..e7bf124700 --- /dev/null +++ b/apps/plugins/pacbox/arcade.c | |||
@@ -0,0 +1,577 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #include "arcade.h" | ||
26 | #include "hardware.h" | ||
27 | #include <string.h> | ||
28 | #include "plugin.h" | ||
29 | |||
30 | extern struct plugin_api* rb; | ||
31 | |||
32 | #ifndef HAVE_LCD_COLOR | ||
33 | /* Convert RGB888 to 2-bit greyscale - logic taken from bmp2rb.c */ | ||
34 | static fb_data rgb_to_gray(unsigned int r, unsigned int g, unsigned int b) | ||
35 | { | ||
36 | int brightness = ((3*r + 6*g + b) / 10); | ||
37 | return ((brightness & 0xc0) >> 6); | ||
38 | } | ||
39 | #endif | ||
40 | |||
41 | unsigned char color_data_[256] = { | ||
42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0b, 0x01, | ||
43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0b, 0x03, | ||
44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0b, 0x05, | ||
45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0b, 0x07, | ||
46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x09, | ||
47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
49 | 0x00, 0x0f, 0x00, 0x0e, 0x00, 0x01, 0x0c, 0x0f, | ||
50 | 0x00, 0x0e, 0x00, 0x0b, 0x00, 0x0c, 0x0b, 0x0e, | ||
51 | 0x00, 0x0c, 0x0f, 0x01, 0x00, 0x00, 0x00, 0x00, | ||
52 | 0x00, 0x01, 0x02, 0x0f, 0x00, 0x07, 0x0c, 0x02, | ||
53 | 0x00, 0x09, 0x06, 0x0f, 0x00, 0x0d, 0x0c, 0x0f, | ||
54 | 0x00, 0x05, 0x03, 0x09, 0x00, 0x0f, 0x0b, 0x00, | ||
55 | 0x00, 0x0e, 0x00, 0x0b, 0x00, 0x0e, 0x00, 0x0b, | ||
56 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x01, | ||
57 | 0x00, 0x0f, 0x0b, 0x0e, 0x00, 0x0e, 0x00, 0x0f, | ||
58 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
59 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
60 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
61 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
62 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
63 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
64 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
65 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
66 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
67 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
68 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
69 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
70 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
71 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
72 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
73 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
74 | }; | ||
75 | |||
76 | unsigned char palette_data_[0x20] = { | ||
77 | 0x00, 0x07, 0x66, 0xef, 0x00, 0xf8, 0xea, 0x6f, | ||
78 | 0x00, 0x3f, 0x00, 0xc9, 0x38, 0xaa, 0xaf, 0xf6, | ||
79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | ||
81 | }; | ||
82 | |||
83 | enum { | ||
84 | Normal = 0x00, | ||
85 | FlipY = 0x01, | ||
86 | FlipX = 0x02, | ||
87 | FlipXY = 0x03 | ||
88 | }; | ||
89 | |||
90 | fb_data palette[256]; /* Color palette */ | ||
91 | int vchar_to_x_[1024]; | ||
92 | int vchar_to_y_[1024]; | ||
93 | |||
94 | void init_PacmanMachine(int dip) | ||
95 | { | ||
96 | int i; | ||
97 | |||
98 | /* Initialize the CPU and the RAM */ | ||
99 | z80_reset(); | ||
100 | rb->memset( &ram_[0x4000], 0xFF, 0x1000 ); | ||
101 | |||
102 | /* Initialize parameters */ | ||
103 | port1_ = 0xFF; | ||
104 | port2_ = 0xFF; | ||
105 | coin_counter_ = 0; | ||
106 | |||
107 | /* Reset the machine */ | ||
108 | reset_PacmanMachine(); | ||
109 | |||
110 | /* Set the DIP switches to a default configuration */ | ||
111 | setDipSwitches( dip ); | ||
112 | |||
113 | /* Initialize the video character translation tables: video memory has a | ||
114 | very peculiar arrangement in Pacman so we precompute a few tables to | ||
115 | move around faster */ | ||
116 | |||
117 | for( i=0x000; i<0x400; i++ ) { | ||
118 | int x, y; | ||
119 | |||
120 | if( i < 0x040 ) { | ||
121 | x = 29 - (i & 0x1F); | ||
122 | y = 34 + (i >> 5); | ||
123 | } | ||
124 | else if( i >= 0x3C0 ) { | ||
125 | x = 29 - (i & 0x1F); | ||
126 | y = ((i-0x3C0) >> 5); | ||
127 | } | ||
128 | else { | ||
129 | x = 27 - ((i-0x40) >> 5); | ||
130 | y = 2 + ((i-0x40) & 0x1F); | ||
131 | } | ||
132 | vchar_to_x_[i] = x; | ||
133 | vchar_to_y_[i] = y; | ||
134 | if( (y >= 0) && (y < 36) && (x >= 0) && (x < 28) ) | ||
135 | vchar_to_i_[i] = y*28 + x; | ||
136 | else | ||
137 | vchar_to_i_[i] = 0x3FF; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | void reset_PacmanMachine(void) | ||
142 | { | ||
143 | int i; | ||
144 | |||
145 | z80_reset(); | ||
146 | output_devices_ = 0; | ||
147 | interrupt_vector_ = 0; | ||
148 | |||
149 | rb->memset( ram_+0x4000, 0, 0x1000 ); | ||
150 | rb->memset( color_mem_, 0, sizeof(color_mem_) ); | ||
151 | rb->memset( video_mem_, 0, sizeof(video_mem_) ); | ||
152 | rb->memset( dirty_, 0, sizeof(dirty_) ); | ||
153 | |||
154 | for( i=0; i<8; i++ ) { | ||
155 | sprites_[i].color = 0; | ||
156 | sprites_[i].x = ScreenWidth; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | Run the machine for one frame. | ||
162 | */ | ||
163 | int run(void) | ||
164 | { | ||
165 | /* Run until the CPU has executed the number of cycles per frame | ||
166 | (the function returns the number of "extra" cycles spent by the | ||
167 | last instruction but that is not really important here) */ | ||
168 | |||
169 | unsigned extraCycles = z80_run( CpuCyclesPerFrame ); | ||
170 | |||
171 | /* Reset the CPU cycle counter to make sure it doesn't overflow, | ||
172 | also take into account the extra cycles from the previous run */ | ||
173 | |||
174 | setCycles( extraCycles ); | ||
175 | |||
176 | /* If interrupts are enabled, force a CPU interrupt with the vector | ||
177 | set by the program */ | ||
178 | |||
179 | if( output_devices_ & InterruptEnabled ) { | ||
180 | z80_interrupt( interrupt_vector_ ); | ||
181 | } | ||
182 | |||
183 | return 0; | ||
184 | } | ||
185 | |||
186 | /** Returns the status of the coin lockout door. */ | ||
187 | unsigned char getCoinLockout(void) { | ||
188 | return output_devices_ & CoinLockout ? 1 : 0; | ||
189 | } | ||
190 | |||
191 | static void decodeCharByte( unsigned char b, unsigned char * charbuf, int charx, int chary, int charwidth ) | ||
192 | { | ||
193 | int i; | ||
194 | |||
195 | for( i=3; i>=0; i-- ) { | ||
196 | charbuf[charx+(chary+i)*charwidth] = (b & 1) | ((b >> 3) & 2); | ||
197 | b >>= 1; | ||
198 | } | ||
199 | } | ||
200 | |||
201 | static void decodeCharLine( unsigned char * src, unsigned char * charbuf, int charx, int chary, int charwidth ) | ||
202 | { | ||
203 | int x; | ||
204 | |||
205 | for( x=7; x>=0; x-- ) { | ||
206 | decodeCharByte( *src++, charbuf, x+charx, chary, charwidth ); | ||
207 | } | ||
208 | } | ||
209 | |||
210 | static void decodeCharSet( unsigned char * mem, unsigned char * charset ) | ||
211 | { | ||
212 | int i; | ||
213 | |||
214 | for( i=0; i<256; i++ ) { | ||
215 | unsigned char * src = mem + 16*i; | ||
216 | unsigned char * dst = charset + 64*i; | ||
217 | |||
218 | decodeCharLine( src, dst, 0, 4, 8 ); | ||
219 | decodeCharLine( src+8, dst, 0, 0, 8 ); | ||
220 | } | ||
221 | } | ||
222 | |||
223 | static void decodeSprites( unsigned char * mem, unsigned char * sprite_data ) | ||
224 | { | ||
225 | int i; | ||
226 | |||
227 | for( i=0; i<64; i++ ) { | ||
228 | unsigned char * src = mem + i*64; | ||
229 | unsigned char * dst = sprite_data + 256*i; | ||
230 | |||
231 | decodeCharLine( src , dst, 8, 12, 16 ); | ||
232 | decodeCharLine( src+ 8, dst, 8, 0, 16 ); | ||
233 | decodeCharLine( src+16, dst, 8, 4, 16 ); | ||
234 | decodeCharLine( src+24, dst, 8, 8, 16 ); | ||
235 | decodeCharLine( src+32, dst, 0, 12, 16 ); | ||
236 | decodeCharLine( src+40, dst, 0, 0, 16 ); | ||
237 | decodeCharLine( src+48, dst, 0, 4, 16 ); | ||
238 | decodeCharLine( src+56, dst, 0, 8, 16 ); | ||
239 | } | ||
240 | } | ||
241 | |||
242 | /* | ||
243 | Decode one byte from the encoded color palette. | ||
244 | |||
245 | An encoded palette byte contains RGB information bit-packed as follows: | ||
246 | |||
247 | bit: 7 6 5 4 3 2 1 0 | ||
248 | color: b b g g g r r r | ||
249 | */ | ||
250 | static unsigned decodePaletteByte( unsigned char value ) | ||
251 | { | ||
252 | unsigned bit0, bit1, bit2; | ||
253 | unsigned red, green, blue; | ||
254 | |||
255 | bit0 = (value >> 0) & 0x01; | ||
256 | bit1 = (value >> 1) & 0x01; | ||
257 | bit2 = (value >> 2) & 0x01; | ||
258 | red = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; | ||
259 | |||
260 | bit0 = (value >> 3) & 0x01; | ||
261 | bit1 = (value >> 4) & 0x01; | ||
262 | bit2 = (value >> 5) & 0x01; | ||
263 | green = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; | ||
264 | |||
265 | bit0 = 0; | ||
266 | bit1 = (value >> 6) & 0x01; | ||
267 | bit2 = (value >> 7) & 0x01; | ||
268 | blue = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; | ||
269 | |||
270 | return (blue << 16 ) | (green << 8) | red; | ||
271 | } | ||
272 | |||
273 | void decodeROMs(void) | ||
274 | { | ||
275 | unsigned decoded_palette[0x20]; | ||
276 | unsigned c; | ||
277 | |||
278 | int i; | ||
279 | |||
280 | decodeCharSet( charset_rom_, charmap_ ); | ||
281 | decodeSprites( spriteset_rom_, spritemap_ ); | ||
282 | |||
283 | for( i=0x00; i<0x20; i++ ) { | ||
284 | decoded_palette[i] = decodePaletteByte( palette_data_[i] ); | ||
285 | } | ||
286 | for( i=0; i<256; i++ ) { | ||
287 | c = decoded_palette[ color_data_[i] & 0x0F ]; | ||
288 | #ifdef HAVE_LCD_COLOR | ||
289 | palette[i] = LCD_RGBPACK((unsigned char) (c), | ||
290 | (unsigned char) (c >> 8), | ||
291 | (unsigned char) (c >> 16)); | ||
292 | #else | ||
293 | palette[i] = rgb_to_gray(c, c >> 8, c >> 16); | ||
294 | #endif | ||
295 | } | ||
296 | } | ||
297 | |||
298 | void getDeviceInfo( enum InputDevice device, unsigned char * mask, unsigned char ** port ) | ||
299 | { | ||
300 | static unsigned char MaskInfo[] = { | ||
301 | 0x01 , // Joy1_Up | ||
302 | 0x02 , // Joy1_Left | ||
303 | 0x04 , // Joy1_Right | ||
304 | 0x08 , // Joy1_Down | ||
305 | 0x10 , // Switch_RackAdvance | ||
306 | 0x20 , // CoinSlot_1 | ||
307 | 0x40 , // CoinSlot_2 | ||
308 | 0x80 , // Switch_AddCredit | ||
309 | 0x01 , // Joy2_Up | ||
310 | 0x02 , // Joy2_Left | ||
311 | 0x04 , // Joy2_Right | ||
312 | 0x08 , // Joy2_Down | ||
313 | 0x10 , // Switch_Test | ||
314 | 0x20 , // Key_OnePlayer | ||
315 | 0x40 , // Key_TwoPlayers | ||
316 | 0x80 // Switch_CocktailMode | ||
317 | }; | ||
318 | |||
319 | *mask = MaskInfo[device]; | ||
320 | |||
321 | switch( device ) { | ||
322 | case Joy1_Up: | ||
323 | case Joy1_Left: | ||
324 | case Joy1_Right: | ||
325 | case Joy1_Down: | ||
326 | case Switch_RackAdvance: | ||
327 | case CoinSlot_1: | ||
328 | case CoinSlot_2: | ||
329 | case Switch_AddCredit: | ||
330 | *port = &port1_; | ||
331 | break; | ||
332 | case Joy2_Up: | ||
333 | case Joy2_Left: | ||
334 | case Joy2_Right: | ||
335 | case Joy2_Down: | ||
336 | case Switch_Test: | ||
337 | case Key_OnePlayer: | ||
338 | case Key_TwoPlayers: | ||
339 | case Switch_CocktailMode: | ||
340 | *port = &port2_; | ||
341 | break; | ||
342 | default: | ||
343 | *port = 0; | ||
344 | break; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | enum InputDeviceMode getDeviceMode( enum InputDevice device ) | ||
349 | { | ||
350 | unsigned char mask; | ||
351 | unsigned char * port; | ||
352 | |||
353 | getDeviceInfo( device, &mask, &port ); | ||
354 | |||
355 | return (*port & mask) == 0 ? DeviceOn : DeviceOff; | ||
356 | } | ||
357 | |||
358 | /* | ||
359 | Fire an input event, telling the emulator for example | ||
360 | that the joystick has been released from the down position. | ||
361 | */ | ||
362 | void setDeviceMode( enum InputDevice device, enum InputDeviceMode mode ) | ||
363 | { | ||
364 | if( (getCoinLockout() == 0) && ((device == CoinSlot_1)||(device == CoinSlot_2)||(device == Switch_AddCredit)) ) { | ||
365 | // Coin slots are locked, ignore command and exit | ||
366 | return; | ||
367 | } | ||
368 | |||
369 | unsigned char mask; | ||
370 | unsigned char * port; | ||
371 | |||
372 | getDeviceInfo( device, &mask, &port ); | ||
373 | |||
374 | if( mode == DeviceOn ) | ||
375 | *port &= ~mask; | ||
376 | else if( mode == DeviceOff ) | ||
377 | *port |= mask; | ||
378 | else if( mode == DeviceToggle ) | ||
379 | *port ^= mask; | ||
380 | } | ||
381 | |||
382 | void setDipSwitches( unsigned value ) { | ||
383 | dip_switches_ = (unsigned char) value; | ||
384 | |||
385 | setDeviceMode( Switch_RackAdvance, value & DipRackAdvance_Auto ? DeviceOn : DeviceOff ); | ||
386 | setDeviceMode( Switch_Test, value & DipMode_Test ? DeviceOn : DeviceOff ); | ||
387 | setDeviceMode( Switch_CocktailMode, value & DipCabinet_Cocktail ? DeviceOn : DeviceOff ); | ||
388 | } | ||
389 | |||
390 | unsigned getDipSwitches(void) { | ||
391 | unsigned result = dip_switches_; | ||
392 | |||
393 | if( getDeviceMode(Switch_RackAdvance) == DeviceOn ) result |= DipRackAdvance_Auto; | ||
394 | if( getDeviceMode(Switch_Test) == DeviceOn ) result |= DipMode_Test; | ||
395 | if( getDeviceMode(Switch_CocktailMode) == DeviceOn ) result |= DipCabinet_Cocktail; | ||
396 | |||
397 | return result; | ||
398 | } | ||
399 | |||
400 | static inline void drawChar( unsigned char * buffer, int index, int ox, int oy, int color ) | ||
401 | { | ||
402 | buffer += ox + oy*224; // Make the buffer point to the character position | ||
403 | index *= 64; // Make the index point to the character offset into the character table | ||
404 | color = (color & 0x3F)*4; | ||
405 | int x,y; | ||
406 | |||
407 | if( output_devices_ & FlipScreen ) { | ||
408 | // Flip character | ||
409 | buffer += 7*ScreenWidth; | ||
410 | for( y=0; y<8; y++ ) { | ||
411 | for( x=7; x>=0; x-- ) { | ||
412 | buffer[x] = charmap_[ index++ ] + color; | ||
413 | } | ||
414 | buffer -= ScreenWidth; // Go to the next line | ||
415 | } | ||
416 | } | ||
417 | else { | ||
418 | for( y=0; y<8; y++ ) { | ||
419 | for( x=0; x<=7; x++ ) { | ||
420 | buffer[x] = charmap_[ index++ ] + color; | ||
421 | } | ||
422 | buffer += ScreenWidth; // Go to the next line | ||
423 | } | ||
424 | } | ||
425 | } | ||
426 | |||
427 | inline void drawSprite( unsigned char * buffer, int index ) | ||
428 | { | ||
429 | struct PacmanSprite ps = sprites_[index]; | ||
430 | int x,y; | ||
431 | |||
432 | // Exit now if sprite not visible at all | ||
433 | if( (ps.color == 0) || (ps.x >= ScreenWidth) || (ps.y < 16) || (ps.y >= (ScreenHeight-32)) ) { | ||
434 | return; | ||
435 | } | ||
436 | |||
437 | // Clip the sprite coordinates to cut the parts that fall off the screen | ||
438 | int start_x = (ps.x < 0) ? 0 : ps.x; | ||
439 | int end_x = (ps.x < (ScreenWidth-16)) ? ps.x+16 : ScreenWidth; | ||
440 | |||
441 | // Prepare variables for drawing | ||
442 | int color = (ps.color & 0x3F)*4; | ||
443 | unsigned char * spritemap_base = spritemap_ + ((ps.n & 0x3F)*256); | ||
444 | |||
445 | buffer += ScreenWidth*ps.y; | ||
446 | |||
447 | // Draw the 16x16 sprite | ||
448 | if( ps.mode == 0 ) { // Normal | ||
449 | // Draw the 16x16 sprite | ||
450 | for( y=0; y<16; y++ ) { | ||
451 | char* s = &spritemap_base[start_x-ps.x+y*16]; | ||
452 | for( x=start_x; x<end_x; x++ ) { | ||
453 | int c = *(s++); | ||
454 | if( c ) { | ||
455 | buffer[x] = c + color; | ||
456 | } | ||
457 | } | ||
458 | buffer += ScreenWidth; | ||
459 | } | ||
460 | } else if( ps.mode == 1 ) { // Flip Y | ||
461 | for( y=0; y<16; y++ ) { | ||
462 | char* s = &spritemap_base[start_x-ps.x+(15-y)*16]; | ||
463 | for( x=start_x; x<end_x; x++ ) { | ||
464 | int c = *(s++); | ||
465 | if( c ) { | ||
466 | buffer[x] = c + color; | ||
467 | } | ||
468 | } | ||
469 | buffer += ScreenWidth; | ||
470 | } | ||
471 | } else if( ps.mode == 2 ) { // Flip X | ||
472 | for( y=0; y<16; y++ ) { | ||
473 | char* s = &spritemap_base[15-start_x+ps.x+y*16]; | ||
474 | for( x=start_x; x<end_x; x++ ) { | ||
475 | int c = *(s--); | ||
476 | if( c ) { | ||
477 | buffer[x] = c + color; | ||
478 | } | ||
479 | } | ||
480 | buffer += ScreenWidth; | ||
481 | } | ||
482 | } else { // Flip X and Y | ||
483 | for( y=0; y<16; y++ ) { | ||
484 | char* s = &spritemap_base[15-start_x+ps.x+(15-y)*16]; | ||
485 | for( x=start_x; x<end_x; x++ ) { | ||
486 | int c = *(s--); | ||
487 | if( c ) { | ||
488 | buffer[x] = c + color; | ||
489 | } | ||
490 | } | ||
491 | buffer += ScreenWidth; | ||
492 | } | ||
493 | } | ||
494 | } | ||
495 | |||
496 | /* | ||
497 | Draw the video into the specified buffer. | ||
498 | */ | ||
499 | bool renderBackground( unsigned char * buffer ) | ||
500 | { | ||
501 | unsigned char * video = video_mem_; | ||
502 | unsigned char * color = color_mem_; | ||
503 | unsigned char * dirty = dirty_; | ||
504 | int x,y; | ||
505 | bool changed=false; | ||
506 | |||
507 | // Draw the background first... | ||
508 | if( output_devices_ & FlipScreen ) { | ||
509 | for( y=ScreenHeight-CharHeight; y>=0; y-=CharHeight ) { | ||
510 | for( x=ScreenWidth-CharWidth; x>=0; x-=CharWidth ) { | ||
511 | if (*dirty) { | ||
512 | drawChar( buffer, *video++, x, y, *color++ ); | ||
513 | *(dirty++)=0; | ||
514 | changed=true; | ||
515 | } else { | ||
516 | dirty++; | ||
517 | video++; | ||
518 | color++; | ||
519 | } | ||
520 | } | ||
521 | } | ||
522 | } | ||
523 | else { | ||
524 | for( y=0; y<ScreenHeight; y+=CharHeight ) { | ||
525 | for( x=0; x<ScreenWidth; x+=CharWidth ) { | ||
526 | if (*dirty) { | ||
527 | drawChar( buffer, *video++, x, y, *color++ ); | ||
528 | *(dirty++)=0; | ||
529 | changed=true; | ||
530 | } else { | ||
531 | dirty++; | ||
532 | video++; | ||
533 | color++; | ||
534 | } | ||
535 | } | ||
536 | } | ||
537 | } | ||
538 | |||
539 | return changed; | ||
540 | } | ||
541 | |||
542 | void renderSprites( unsigned char * buffer ) | ||
543 | { | ||
544 | int i; | ||
545 | |||
546 | // ...then add the sprites | ||
547 | for( i=7; i>=0; i-- ) { | ||
548 | drawSprite( buffer, i ); | ||
549 | } | ||
550 | } | ||
551 | |||
552 | /* Enables/disables the speed hack. */ | ||
553 | int setSpeedHack( int enabled ) | ||
554 | { | ||
555 | int result = 0; | ||
556 | |||
557 | if( enabled ) { | ||
558 | if( (ram_[0x180B] == 0xBE) && (ram_[0x1FFD] == 0x00) ) { | ||
559 | // Patch the ROM to activate the speed hack | ||
560 | ram_[0x180B] = 0x01; // Activate speed hack | ||
561 | ram_[0x1FFD] = 0xBD; // Fix ROM checksum | ||
562 | |||
563 | result = 1; | ||
564 | } | ||
565 | } | ||
566 | else { | ||
567 | if( (ram_[0x180B] == 0x01) && (ram_[0x1FFD] == 0xBD) ) { | ||
568 | // Restore the patched ROM locations | ||
569 | ram_[0x180B] = 0xBE; | ||
570 | ram_[0x1FFD] = 0x00; | ||
571 | |||
572 | result = 1; | ||
573 | } | ||
574 | } | ||
575 | |||
576 | return result; | ||
577 | } | ||
diff --git a/apps/plugins/pacbox/arcade.h b/apps/plugins/pacbox/arcade.h new file mode 100644 index 0000000000..5de2517e80 --- /dev/null +++ b/apps/plugins/pacbox/arcade.h | |||
@@ -0,0 +1,199 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #ifndef ARCADE_H_ | ||
26 | #define ARCADE_H_ | ||
27 | |||
28 | #include "plugin.h" | ||
29 | #include "z80.h" | ||
30 | #include "hardware.h" | ||
31 | |||
32 | extern fb_data palette[256]; /* Color palette in native Rockbox format */ | ||
33 | |||
34 | /** | ||
35 | Pacman sprite properties. | ||
36 | |||
37 | This information is only needed by applications that want to do their own | ||
38 | sprite rendering, as the renderVideo() function already draws the sprites. | ||
39 | |||
40 | @see PacmanMachine::renderVideo | ||
41 | */ | ||
42 | |||
43 | /** Machine hardware data */ | ||
44 | enum { | ||
45 | ScreenWidth = 224, | ||
46 | ScreenHeight = 288, | ||
47 | ScreenWidthChars = 28, | ||
48 | ScreenHeightChars = 36, | ||
49 | CharWidth = 8, | ||
50 | CharHeight = 8, | ||
51 | VideoFrequency = 60, | ||
52 | CpuClock = 3072000, | ||
53 | SoundClock = 96000, // CPU clock divided by 32 | ||
54 | CpuCyclesPerFrame = CpuClock / VideoFrequency | ||
55 | }; | ||
56 | |||
57 | /** Input devices and switches */ | ||
58 | enum InputDevice { | ||
59 | Joy1_Up = 0, | ||
60 | Joy1_Left, | ||
61 | Joy1_Right, | ||
62 | Joy1_Down, | ||
63 | Switch_RackAdvance, | ||
64 | CoinSlot_1, | ||
65 | CoinSlot_2, | ||
66 | Switch_AddCredit, | ||
67 | Joy2_Up, | ||
68 | Joy2_Left, | ||
69 | Joy2_Right, | ||
70 | Joy2_Down, | ||
71 | Switch_Test, | ||
72 | Key_OnePlayer, | ||
73 | Key_TwoPlayers, | ||
74 | Switch_CocktailMode | ||
75 | }; | ||
76 | |||
77 | /** Input device mode */ | ||
78 | enum InputDeviceMode { | ||
79 | DeviceOn, | ||
80 | DevicePushed = DeviceOn, | ||
81 | DeviceOff, | ||
82 | DeviceReleased = DeviceOff, | ||
83 | DeviceToggle | ||
84 | }; | ||
85 | |||
86 | /** DIP switches */ | ||
87 | enum { | ||
88 | DipPlay_Free = 0x00, // Coins per play | ||
89 | DipPlay_OneCoinOneGame = 0x01, | ||
90 | DipPlay_OneCoinTwoGames = 0x02, | ||
91 | DipPlay_TwoCoinsOneGame = 0x03, | ||
92 | DipPlay_Mask = 0x03, | ||
93 | DipLives_1 = 0x00, // Lives per game | ||
94 | DipLives_2 = 0x04, | ||
95 | DipLives_3 = 0x08, | ||
96 | DipLives_5 = 0x0C, | ||
97 | DipLives_Mask = 0x0C, | ||
98 | DipBonus_10000 = 0x00, // Bonus life | ||
99 | DipBonus_15000 = 0x10, | ||
100 | DipBonus_20000 = 0x20, | ||
101 | DipBonus_None = 0x30, | ||
102 | DipBonus_Mask = 0x30, | ||
103 | DipDifficulty_Normal = 0x40, // Difficulty | ||
104 | DipDifficulty_Hard = 0x00, | ||
105 | DipDifficulty_Mask = 0x40, | ||
106 | DipGhostNames_Normal = 0x80, // Ghost names | ||
107 | DipGhostNames_Alternate = 0x00, | ||
108 | DipGhostNames_Mask = 0x80, | ||
109 | DipMode_Play = 0x0000, // Play/test mode | ||
110 | DipMode_Test = 0x0100, | ||
111 | DipMode_Mask = 0x0100, | ||
112 | DipCabinet_Upright = 0x0000, // Cabinet upright/cocktail | ||
113 | DipCabinet_Cocktail = 0x0200, | ||
114 | DipCabinet_Mask = 0x0200, | ||
115 | DipRackAdvance_Off = 0x0000, // Automatic level advance | ||
116 | DipRackAdvance_Auto = 0x0400, | ||
117 | DipRackAdvance_Mask = 0x0400 | ||
118 | }; | ||
119 | |||
120 | void init_PacmanMachine(int dip); | ||
121 | int run(void); | ||
122 | void reset_PacmanMachine(void); | ||
123 | void decodeROMs(void); | ||
124 | |||
125 | /** | ||
126 | Tells the emulator that the status of an input device has changed. | ||
127 | */ | ||
128 | void setDeviceMode( enum InputDevice device, enum InputDeviceMode mode ); | ||
129 | |||
130 | /** | ||
131 | Returns the value of the DIP switches. | ||
132 | */ | ||
133 | unsigned getDipSwitches(void); | ||
134 | |||
135 | /** | ||
136 | Sets the value of the DIP switches that control several game settings | ||
137 | (see the Dip... constants above). | ||
138 | |||
139 | Most of the DIP switches are read at program startup and take effect | ||
140 | only after a machine reset. | ||
141 | */ | ||
142 | void setDipSwitches( unsigned value ); | ||
143 | |||
144 | /** | ||
145 | Draws the current video into the specified buffer. | ||
146 | |||
147 | The buffer must be at least 224*288 bytes long. Pixels are stored in | ||
148 | left-to-right/top-to-bottom order starting from the upper left corner. | ||
149 | There is one byte per pixel, containing an index into the color palette | ||
150 | returned by getPalette(). | ||
151 | |||
152 | It's up to the application to display the buffer to the user. The | ||
153 | code might look like this: | ||
154 | <BLOCKQUOTE> | ||
155 | <PRE> | ||
156 | @@ unsigned char video_buffer[ PacmanMachine::ScreenWidth * PacmanMachine::ScreenHeight ]; | ||
157 | @@ unsigned char * vbuf = video_buffer; | ||
158 | @@ const unsigned * palette = arcade.getPalette(); | ||
159 | @@ | ||
160 | @@ arcade.renderVideo( vbuf ); | ||
161 | @@ | ||
162 | @@ for( int y=0; y<PacmanMachine::ScreenHeight; y++ ) { | ||
163 | @@ for( int x=0; x<PacmanMachine::ScreenWidth; x++ ) { | ||
164 | @@ unsigned color = palette[ *vbuf++ ]; | ||
165 | @@ unsigned char red = color & 0xFF; | ||
166 | @@ unsigned char green = (color >> 8) & 0xFF; | ||
167 | @@ unsigned char blue = (color >> 16) & 0xFF; | ||
168 | @@ | ||
169 | @@ setPixel( x, y, red, green, blue ); | ||
170 | @@ } | ||
171 | @@ } | ||
172 | </PRE> | ||
173 | </BLOCKQUOTE> | ||
174 | |||
175 | */ | ||
176 | bool renderBackground( unsigned char * buffer ); | ||
177 | void renderSprites( unsigned char * buffer ); | ||
178 | |||
179 | /** | ||
180 | Enables/disables a common speed hack that allows Pacman to | ||
181 | move four times faster than the ghosts. | ||
182 | |||
183 | @param enabled true to enabled the hack, false to disable | ||
184 | |||
185 | @return 0 if successful, otherwise the patch could not be applied | ||
186 | (probably because the loaded ROM set does not support it) | ||
187 | */ | ||
188 | int setSpeedHack( int enabled ); | ||
189 | |||
190 | /* Implementation of the Z80 Environment interface */ | ||
191 | unsigned char readByteHigh( unsigned addr ); | ||
192 | |||
193 | void writeByte( unsigned, unsigned char ); | ||
194 | |||
195 | unsigned char readPort( unsigned port ); | ||
196 | |||
197 | void writePort( unsigned, unsigned char ); | ||
198 | |||
199 | #endif // ARCADE_H_ | ||
diff --git a/apps/plugins/pacbox/hardware.c b/apps/plugins/pacbox/hardware.c new file mode 100644 index 0000000000..3cc4858e43 --- /dev/null +++ b/apps/plugins/pacbox/hardware.c | |||
@@ -0,0 +1,197 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #include "plugin.h" | ||
26 | #include "hardware.h" | ||
27 | |||
28 | extern struct plugin_api* rb; | ||
29 | |||
30 | /* The main data for Pacman */ | ||
31 | |||
32 | unsigned char ram_[20*1024] IBSS_ATTR; // ROM (16K) and RAM (4K) | ||
33 | unsigned char charset_rom_[4*1024] IBSS_ATTR; // Character set ROM (4K) | ||
34 | unsigned char spriteset_rom_[4*1024] IBSS_ATTR; // Sprite set ROM (4K) | ||
35 | unsigned char dirty_[1024] IBSS_ATTR; | ||
36 | unsigned char video_mem_[1024] IBSS_ATTR; // Video memory (1K) | ||
37 | unsigned char color_mem_[1024] IBSS_ATTR; // Color memory (1K) | ||
38 | unsigned char charmap_[256*8*8]; /* Character data for 256 8x8 characters */ | ||
39 | unsigned char spritemap_[64*16*16]; /* Sprite data for 64 16x16 sprites */ | ||
40 | unsigned char output_devices_ IBSS_ATTR; /* Output flip-flops set by the game program */ | ||
41 | unsigned char interrupt_vector_ IBSS_ATTR; | ||
42 | unsigned coin_counter_ IBSS_ATTR; | ||
43 | unsigned char port1_ IBSS_ATTR; | ||
44 | unsigned char port2_ IBSS_ATTR; | ||
45 | unsigned char dip_switches_ IBSS_ATTR; | ||
46 | |||
47 | /* Internal tables and structures for faster access to data */ | ||
48 | struct PacmanSprite sprites_[8]; /* Sprites */ | ||
49 | short vchar_to_i_[1024]; | ||
50 | |||
51 | |||
52 | /* | ||
53 | For Z80 Environment: write a byte to memory. | ||
54 | */ | ||
55 | void writeByte( unsigned addr, unsigned char b ) | ||
56 | { | ||
57 | addr &= 0x7FFF; | ||
58 | |||
59 | if( addr < 0x4000 ) { | ||
60 | // This is a ROM address, do not write into it! | ||
61 | } | ||
62 | else if( addr < 0x4400 ) { | ||
63 | // Video memory | ||
64 | if (ram_[addr] != b) { | ||
65 | int x = vchar_to_i_[addr-0x4000]; | ||
66 | ram_[addr] = b; | ||
67 | dirty_[x] = 1; | ||
68 | video_mem_[x] = b; | ||
69 | } | ||
70 | } | ||
71 | else if( addr < 0x4800 ) { | ||
72 | // Color memory | ||
73 | if (ram_[addr] != b) { | ||
74 | int x = vchar_to_i_[addr-0x4400]; | ||
75 | ram_[addr] = b; | ||
76 | dirty_[x] = 1; | ||
77 | color_mem_[x] = b; | ||
78 | } | ||
79 | } | ||
80 | else if( addr < 0x4FF0 ) { | ||
81 | // Standard memory | ||
82 | ram_[addr] = b; | ||
83 | } | ||
84 | else if( addr < 0x5000 ) { | ||
85 | // Sprites | ||
86 | ram_[addr] = b; | ||
87 | |||
88 | unsigned idx = (addr - 0x4FF0) / 2; | ||
89 | |||
90 | if( addr & 1 ) { | ||
91 | sprites_[ idx ].color = b; | ||
92 | } | ||
93 | else { | ||
94 | sprites_[ idx ].n = b >> 2; | ||
95 | sprites_[ idx ].mode = b & 0x03; | ||
96 | } | ||
97 | } | ||
98 | else { | ||
99 | // Memory mapped ports | ||
100 | switch( addr ) { | ||
101 | case 0x5000: | ||
102 | // Interrupt enable | ||
103 | setOutputFlipFlop( InterruptEnabled, b & 0x01 ); | ||
104 | break; | ||
105 | case 0x5001: | ||
106 | // Sound enable | ||
107 | setOutputFlipFlop( SoundEnabled, b & 0x01 ); | ||
108 | break; | ||
109 | case 0x5002: | ||
110 | // Aux board enable? | ||
111 | break; | ||
112 | case 0x5003: | ||
113 | // Flip screen | ||
114 | setOutputFlipFlop( FlipScreen, b & 0x01 ); | ||
115 | break; | ||
116 | case 0x5004: | ||
117 | // Player 1 start light | ||
118 | setOutputFlipFlop( PlayerOneLight, b & 0x01 ); | ||
119 | break; | ||
120 | case 0x5005: | ||
121 | // Player 2 start light | ||
122 | setOutputFlipFlop( PlayerTwoLight, b & 0x01 ); | ||
123 | break; | ||
124 | case 0x5006: | ||
125 | // Coin lockout: bit 0 is used to enable/disable the coin insert slots | ||
126 | // (0=disable). | ||
127 | // The coin slot is enabled at startup and (temporarily) disabled when | ||
128 | // the maximum number of credits (99) is inserted. | ||
129 | setOutputFlipFlop( CoinLockout, b & 0x01 ); | ||
130 | break; | ||
131 | case 0x5007: | ||
132 | // Coin meter (coin counter incremented on 0/1 edge) | ||
133 | if( (output_devices_ & CoinMeter) == 0 && (b & 0x01) != 0 ) | ||
134 | coin_counter_++; | ||
135 | setOutputFlipFlop( CoinMeter, b & 0x01 ); | ||
136 | break; | ||
137 | case 0x50c0: | ||
138 | // Watchdog reset | ||
139 | break; | ||
140 | default: | ||
141 | if( addr >= 0x5040 && addr < 0x5060 ) { | ||
142 | // Sound registers | ||
143 | //SOUND sound_chip_.setRegister( addr-0x5040, b ); | ||
144 | } | ||
145 | else if( addr >= 0x5060 && addr < 0x5070 ) { | ||
146 | // Sprite coordinates, x/y pairs for 8 sprites | ||
147 | unsigned idx = (addr-0x5060) / 2; | ||
148 | |||
149 | if( addr & 1 ) { | ||
150 | sprites_[ idx ].y = 272 - b + 1; | ||
151 | } | ||
152 | else { | ||
153 | sprites_[ idx ].x = 240 - b - 1; | ||
154 | |||
155 | if( idx <= 2 ) { | ||
156 | // In Pacman the first few sprites must be further offset | ||
157 | // to the left to get a correct display (is this a hack?) | ||
158 | sprites_[ idx ].x -= 1; | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | break; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | |||
167 | /* | ||
168 | For Z80 Environment: read from a port. | ||
169 | |||
170 | Note: all ports in Pacman are memory mapped so they are read with readByte(). | ||
171 | */ | ||
172 | unsigned char readPort( unsigned port ) | ||
173 | { | ||
174 | (void)port; | ||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | /* | ||
179 | For Z80 Environment: write to a port. | ||
180 | */ | ||
181 | void writePort( unsigned addr, unsigned char b ) | ||
182 | { | ||
183 | if( addr == 0 ) { | ||
184 | // Sets the interrupt vector for the next CPU interrupt | ||
185 | interrupt_vector_ = b; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | void setOutputFlipFlop( unsigned char bit, unsigned char value ) | ||
190 | { | ||
191 | if( value ) { | ||
192 | output_devices_ |= bit; | ||
193 | } | ||
194 | else { | ||
195 | output_devices_ &= ~bit; | ||
196 | } | ||
197 | } | ||
diff --git a/apps/plugins/pacbox/hardware.h b/apps/plugins/pacbox/hardware.h new file mode 100644 index 0000000000..9b225ad1a5 --- /dev/null +++ b/apps/plugins/pacbox/hardware.h | |||
@@ -0,0 +1,141 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #ifndef _HARDWARE_H | ||
26 | #define _HARDWARE_H | ||
27 | |||
28 | extern unsigned char ram_[20*1024]; // ROM (16K) and RAM (4K) | ||
29 | extern unsigned char charset_rom_[4*1024]; // Character set ROM (4K) | ||
30 | extern unsigned char spriteset_rom_[4*1024]; // Sprite set ROM (4K) | ||
31 | extern unsigned char dirty_[1024]; | ||
32 | extern unsigned char video_mem_[1024]; // Video memory (1K) | ||
33 | extern unsigned char color_mem_[1024]; // Color memory (1K) | ||
34 | extern unsigned char charmap_[256*8*8]; /* Character data for 256 8x8 characters */ | ||
35 | extern unsigned char spritemap_[64*16*16]; /* Sprite data for 64 16x16 sprites */ | ||
36 | extern unsigned char output_devices_; /* Output flip-flops set by the game program */ | ||
37 | extern unsigned char interrupt_vector_; | ||
38 | extern unsigned coin_counter_; | ||
39 | extern unsigned char port1_; | ||
40 | extern unsigned char port2_; | ||
41 | extern unsigned char dip_switches_; | ||
42 | |||
43 | /* Output flip-flops */ | ||
44 | enum { | ||
45 | FlipScreen = 0x01, | ||
46 | PlayerOneLight = 0x02, | ||
47 | PlayerTwoLight = 0x04, | ||
48 | InterruptEnabled = 0x08, | ||
49 | SoundEnabled = 0x10, | ||
50 | CoinLockout = 0x20, | ||
51 | CoinMeter = 0x40, | ||
52 | AuxBoardEnabled = 0x80 | ||
53 | }; | ||
54 | |||
55 | struct PacmanSprite | ||
56 | { | ||
57 | int mode; /** Display mode (normal or flipped) */ | ||
58 | int x; /** X coordinate */ | ||
59 | int y; /** Y coordinate */ | ||
60 | int n; /** Shape (from 0 to 63) */ | ||
61 | int color; /** Base color (0=not visible) */ | ||
62 | }; | ||
63 | |||
64 | /* Internal tables and structures for faster access to data */ | ||
65 | extern struct PacmanSprite sprites_[8]; /* Sprites */ | ||
66 | extern short vchar_to_i_[1024]; | ||
67 | |||
68 | void writeByte(unsigned addr, unsigned char b); | ||
69 | unsigned char readPort( unsigned port ); | ||
70 | void writePort( unsigned addr, unsigned char b ); | ||
71 | void setOutputFlipFlop( unsigned char bit, unsigned char value ); | ||
72 | |||
73 | /* | ||
74 | For Z80 Environment: read a byte from high memory addresses (i.e. the | ||
75 | memory-mapped registers) | ||
76 | */ | ||
77 | static inline unsigned char readByte( unsigned addr ) | ||
78 | { | ||
79 | addr &= 0xFFFF; | ||
80 | |||
81 | if (addr < sizeof(ram_)) | ||
82 | return ram_[addr]; | ||
83 | |||
84 | // Address is not in RAM, check to see if it's a memory mapped register | ||
85 | switch( addr & 0xFFC0 ) { | ||
86 | // IN0 | ||
87 | case 0x5000: | ||
88 | // bit 0 : up | ||
89 | // bit 1 : left | ||
90 | // bit 2 : right | ||
91 | // bit 3 : down | ||
92 | // bit 4 : switch: advance to next level | ||
93 | // bit 5 : coin 1 | ||
94 | // bit 6 : coin 2 | ||
95 | // bit 7 : credit (same as coin but coin counter is not incremented) | ||
96 | return port1_; | ||
97 | // IN1 | ||
98 | case 0x5040: | ||
99 | // bit 0 : up (2nd player) | ||
100 | // bit 1 : left (2nd player) | ||
101 | // bit 2 : right (2nd player) | ||
102 | // bit 3 : down (2nd player) | ||
103 | // bit 4 : switch: rack test -> 0x10=off, 0=on | ||
104 | // bit 5 : start 1 | ||
105 | // bit 6 : start 2 | ||
106 | // bit 7 : cabinet -> 0x80=upright, 0x00=table | ||
107 | return port2_; | ||
108 | // DSW1 | ||
109 | case 0x5080: | ||
110 | // bits 0,1 : coinage -> 0=free play, 1=1 coin/play, 2=1 coin/2 play, 3=2 coin/1 play | ||
111 | // bits 2,3 : lives -> 0x0=1, 0x4=2, 0x8=3, 0xC=5 | ||
112 | // bits 4,5 : bonus life -> 0=10000, 0x10=15000, 0x20=20000, 0x30=none | ||
113 | // bit 6 : jumper pad: difficulty -> 0x40=normal, 0=hard | ||
114 | // bit 7 : jumper pad: ghost name -> 0x80=normal, 0=alternate | ||
115 | return dip_switches_; | ||
116 | // Watchdog reset | ||
117 | case 0x50C0: | ||
118 | break; | ||
119 | } | ||
120 | |||
121 | return 0xFF; | ||
122 | } | ||
123 | |||
124 | /* Reads a 16 bit word from memory at the specified address. */ | ||
125 | static inline unsigned readWord( unsigned addr ) { | ||
126 | addr &= 0xFFFF; | ||
127 | |||
128 | if (addr < (sizeof(ram_)-1)) { | ||
129 | return ram_[addr] | ((ram_[addr+1]) << 8); | ||
130 | } else { | ||
131 | return readByte(addr) | (((unsigned)readByte(addr+1)) << 8); | ||
132 | } | ||
133 | } | ||
134 | |||
135 | /* Writes a 16 bit word to memory at the specified address. */ | ||
136 | static inline void writeWord( unsigned addr, unsigned value ) { | ||
137 | writeByte( addr, value & 0xFF ); | ||
138 | writeByte( addr+1, (value >> 8) & 0xFF ); | ||
139 | } | ||
140 | |||
141 | #endif | ||
diff --git a/apps/plugins/pacbox/pacbox.c b/apps/plugins/pacbox/pacbox.c new file mode 100644 index 0000000000..b8625eead6 --- /dev/null +++ b/apps/plugins/pacbox/pacbox.c | |||
@@ -0,0 +1,534 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #include "plugin.h" | ||
26 | #include "arcade.h" | ||
27 | |||
28 | PLUGIN_HEADER | ||
29 | |||
30 | #ifdef USE_IRAM | ||
31 | extern char iramcopy[]; | ||
32 | extern char iramstart[]; | ||
33 | extern char iramend[]; | ||
34 | extern char iedata[]; | ||
35 | extern char iend[]; | ||
36 | #endif | ||
37 | |||
38 | /* How many video frames (out of a possible 60) we display each second */ | ||
39 | #define FPS 20 | ||
40 | |||
41 | #if CONFIG_KEYPAD == IPOD_4G_PAD | ||
42 | |||
43 | #define PACMAN_UP BUTTON_RIGHT | ||
44 | #define PACMAN_DOWN BUTTON_LEFT | ||
45 | #define PACMAN_LEFT BUTTON_MENU | ||
46 | #define PACMAN_RIGHT BUTTON_PLAY | ||
47 | #define PACMAN_1UP BUTTON_SELECT | ||
48 | #define PACMAN_COIN BUTTON_SELECT | ||
49 | |||
50 | #elif CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD | ||
51 | |||
52 | #define PACMAN_UP BUTTON_RIGHT | ||
53 | #define PACMAN_DOWN BUTTON_LEFT | ||
54 | #define PACMAN_LEFT BUTTON_UP | ||
55 | #define PACMAN_RIGHT BUTTON_DOWN | ||
56 | #define PACMAN_1UP BUTTON_SELECT | ||
57 | #define PACMAN_2UP BUTTON_ON | ||
58 | #define PACMAN_COIN BUTTON_REC | ||
59 | #define PACMAN_MENU BUTTON_MODE | ||
60 | |||
61 | #elif CONFIG_KEYPAD == GIGABEAT_PAD | ||
62 | |||
63 | #define PACMAN_UP BUTTON_UP | ||
64 | #define PACMAN_DOWN BUTTON_DOWN | ||
65 | #define PACMAN_LEFT BUTTON_LEFT | ||
66 | #define PACMAN_RIGHT BUTTON_RIGHT | ||
67 | #define PACMAN_1UP BUTTON_SELECT | ||
68 | #define PACMAN_2UP BUTTON_POWER | ||
69 | #define PACMAN_COIN BUTTON_A | ||
70 | #define PACMAN_MENU BUTTON_MENU | ||
71 | |||
72 | #elif CONFIG_KEYPAD == IAUDIO_X5_PAD | ||
73 | |||
74 | #define PACMAN_UP BUTTON_RIGHT | ||
75 | #define PACMAN_DOWN BUTTON_LEFT | ||
76 | #define PACMAN_LEFT BUTTON_UP | ||
77 | #define PACMAN_RIGHT BUTTON_DOWN | ||
78 | #define PACMAN_1UP BUTTON_SELECT | ||
79 | #define PACMAN_2UP BUTTON_POWER | ||
80 | #define PACMAN_COIN BUTTON_REC | ||
81 | #define PACMAN_MENU BUTTON_PLAY | ||
82 | |||
83 | #endif | ||
84 | |||
85 | #if (LCD_HEIGHT >= 288) | ||
86 | #define XOFS ((LCD_WIDTH-224)/2) | ||
87 | #define YOFS ((LCD_HEIGHT-288)/2) | ||
88 | #elif (LCD_WIDTH >= 288) | ||
89 | #define XOFS ((LCD_WIDTH-288)/2) | ||
90 | #define YOFS ((LCD_HEIGHT-224)/2) | ||
91 | #elif (LCD_WIDTH >= 220) | ||
92 | #define XOFS ((LCD_WIDTH-(288*3/4))/2) | ||
93 | #define YOFS ((LCD_HEIGHT-(224*3/4))/2) | ||
94 | #elif (LCD_WIDTH >= 144) | ||
95 | #define XOFS ((LCD_WIDTH-288/2)/2) | ||
96 | #define YOFS ((LCD_HEIGHT-224/2)/2) | ||
97 | #endif | ||
98 | |||
99 | struct plugin_api* rb; | ||
100 | |||
101 | unsigned framesPerSecond = VideoFrequency; | ||
102 | unsigned long frame_counter = 0; | ||
103 | |||
104 | struct pacman_settings { | ||
105 | int difficulty; | ||
106 | int numlives; | ||
107 | int bonus; | ||
108 | int ghostnames; | ||
109 | int showfps; | ||
110 | }; | ||
111 | |||
112 | struct pacman_settings settings; | ||
113 | |||
114 | bool loadFile( const char * name, unsigned char * buf, int len ) | ||
115 | { | ||
116 | char filename[MAX_PATH]; | ||
117 | |||
118 | rb->snprintf(filename,sizeof(filename),"/.rockbox/pacman/%s",name); | ||
119 | |||
120 | int fd = rb->open( filename, O_RDONLY); | ||
121 | |||
122 | if( fd < 0 ) { | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | int n = rb->read( fd, buf, len); | ||
127 | |||
128 | rb->close( fd ); | ||
129 | |||
130 | if( n != len ) { | ||
131 | return false; | ||
132 | } | ||
133 | |||
134 | return true; | ||
135 | } | ||
136 | |||
137 | bool loadROMS( void ) | ||
138 | { | ||
139 | bool romsLoaded = false; | ||
140 | |||
141 | romsLoaded = loadFile( "pacman.6e", ram_, 0x1000) && | ||
142 | loadFile( "pacman.6f", ram_+0x1000, 0x1000) && | ||
143 | loadFile( "pacman.6h", ram_+0x2000, 0x1000) && | ||
144 | loadFile( "pacman.6j", ram_+0x3000, 0x1000) && | ||
145 | loadFile( "pacman.5e", charset_rom_, 0x1000) && | ||
146 | loadFile( "pacman.5f", spriteset_rom_, 0x1000); | ||
147 | |||
148 | if( romsLoaded ) { | ||
149 | decodeROMs(); | ||
150 | reset_PacmanMachine(); | ||
151 | } | ||
152 | |||
153 | return romsLoaded; | ||
154 | } | ||
155 | |||
156 | /* A buffer to render Pacman's 244x288 screen into */ | ||
157 | unsigned char background[ScreenWidth*ScreenHeight] __attribute__ ((aligned (4))); | ||
158 | unsigned char video_buffer[ScreenWidth*ScreenHeight] __attribute__ ((aligned (4))); | ||
159 | |||
160 | long start_time; | ||
161 | long sleep_counter = 0; | ||
162 | long video_frames = 0; | ||
163 | |||
164 | int dipDifficulty[] = { DipDifficulty_Normal, DipDifficulty_Hard }; | ||
165 | int dipLives[] = { DipLives_1, DipLives_2, DipLives_3, DipLives_5 }; | ||
166 | int dipBonus[] = { DipBonus_10000, DipBonus_15000, DipBonus_20000, DipBonus_None }; | ||
167 | int dipGhostNames[] = { DipGhostNames_Normal, DipGhostNames_Alternate }; | ||
168 | |||
169 | int settings_to_dip(struct pacman_settings settings) | ||
170 | { | ||
171 | return ( DipPlay_OneCoinOneGame | | ||
172 | DipCabinet_Upright | | ||
173 | DipMode_Play | | ||
174 | DipRackAdvance_Off | | ||
175 | |||
176 | dipDifficulty[settings.difficulty] | | ||
177 | dipLives[settings.numlives] | | ||
178 | dipBonus[settings.bonus] | | ||
179 | dipGhostNames[settings.ghostnames] | ||
180 | ); | ||
181 | } | ||
182 | |||
183 | |||
184 | |||
185 | int pacbox_menu_cb(int key, int m) | ||
186 | { | ||
187 | (void)m; | ||
188 | switch(key) | ||
189 | { | ||
190 | #ifdef MENU_ENTER2 | ||
191 | case MENU_ENTER2: | ||
192 | #endif | ||
193 | case MENU_ENTER: | ||
194 | key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */ | ||
195 | break; | ||
196 | |||
197 | #ifdef MENU_ENTER2 | ||
198 | case MENU_ENTER2 | BUTTON_REL: | ||
199 | #endif | ||
200 | case MENU_ENTER | BUTTON_REL: | ||
201 | key = MENU_ENTER; /* fake downpress, next menu doesn't like release */ | ||
202 | break; | ||
203 | } | ||
204 | |||
205 | return key; | ||
206 | } | ||
207 | |||
208 | bool pacbox_menu(void) | ||
209 | { | ||
210 | int m; | ||
211 | int result; | ||
212 | int menu_quit=0; | ||
213 | int new_setting; | ||
214 | bool need_restart = false; | ||
215 | |||
216 | static const struct opt_items noyes[2] = { | ||
217 | { "No", NULL }, | ||
218 | { "Yes", NULL }, | ||
219 | }; | ||
220 | |||
221 | static const struct opt_items difficulty_options[2] = { | ||
222 | { "Normal", NULL }, | ||
223 | { "Harder", NULL }, | ||
224 | }; | ||
225 | |||
226 | static const struct opt_items numlives_options[4] = { | ||
227 | { "1", NULL }, | ||
228 | { "2", NULL }, | ||
229 | { "3", NULL }, | ||
230 | { "5", NULL }, | ||
231 | }; | ||
232 | |||
233 | static const struct opt_items bonus_options[4] = { | ||
234 | { "10000 points", NULL }, | ||
235 | { "15000 points", NULL }, | ||
236 | { "20000 points", NULL }, | ||
237 | { "No bonus", NULL }, | ||
238 | }; | ||
239 | |||
240 | static const struct opt_items ghostname_options[2] = { | ||
241 | { "Normal", NULL }, | ||
242 | { "Alternate", NULL }, | ||
243 | }; | ||
244 | |||
245 | static const struct menu_item items[] = { | ||
246 | { "Difficulty", NULL }, | ||
247 | { "Pacmen Per Game", NULL }, | ||
248 | { "Bonus Life", NULL }, | ||
249 | { "Ghost Names", NULL }, | ||
250 | { "Display FPS", NULL }, | ||
251 | { "Restart", NULL }, | ||
252 | { "Quit", NULL }, | ||
253 | }; | ||
254 | |||
255 | m = rb->menu_init(items, sizeof(items) / sizeof(*items), | ||
256 | pacbox_menu_cb, NULL, NULL, NULL); | ||
257 | |||
258 | rb->button_clear_queue(); | ||
259 | |||
260 | while (!menu_quit) { | ||
261 | result=rb->menu_show(m); | ||
262 | |||
263 | switch(result) | ||
264 | { | ||
265 | case 0: | ||
266 | new_setting=settings.difficulty; | ||
267 | rb->set_option("Difficulty", &new_setting, INT, | ||
268 | difficulty_options , 2, NULL); | ||
269 | if (new_setting != settings.difficulty) { | ||
270 | settings.difficulty=new_setting; | ||
271 | need_restart=true; | ||
272 | } | ||
273 | break; | ||
274 | case 1: | ||
275 | new_setting=settings.numlives; | ||
276 | rb->set_option("Pacmen Per Game", &new_setting, INT, | ||
277 | numlives_options , 4, NULL); | ||
278 | if (new_setting != settings.numlives) { | ||
279 | settings.numlives=new_setting; | ||
280 | need_restart=true; | ||
281 | } | ||
282 | break; | ||
283 | case 2: | ||
284 | new_setting=settings.bonus; | ||
285 | rb->set_option("Bonus Life", &new_setting, INT, | ||
286 | bonus_options , 4, NULL); | ||
287 | if (new_setting != settings.bonus) { | ||
288 | settings.bonus=new_setting; | ||
289 | need_restart=true; | ||
290 | } | ||
291 | break; | ||
292 | case 3: | ||
293 | new_setting=settings.ghostnames; | ||
294 | rb->set_option("Ghost Names", &new_setting, INT, | ||
295 | ghostname_options , 2, NULL); | ||
296 | if (new_setting != settings.ghostnames) { | ||
297 | settings.ghostnames=new_setting; | ||
298 | need_restart=true; | ||
299 | } | ||
300 | break; | ||
301 | case 4: /* Show FPS */ | ||
302 | rb->set_option("Display FPS",&settings.showfps,INT, noyes, 2, NULL); | ||
303 | break; | ||
304 | case 5: /* Restart */ | ||
305 | need_restart=true; | ||
306 | menu_quit=1; | ||
307 | break; | ||
308 | default: | ||
309 | menu_quit=1; | ||
310 | break; | ||
311 | } | ||
312 | } | ||
313 | |||
314 | rb->menu_exit(m); | ||
315 | |||
316 | if (need_restart) { | ||
317 | init_PacmanMachine(settings_to_dip(settings)); | ||
318 | } | ||
319 | |||
320 | /* Possible results: | ||
321 | exit game | ||
322 | restart game | ||
323 | usb connected | ||
324 | */ | ||
325 | return (result==6); | ||
326 | } | ||
327 | |||
328 | |||
329 | /* | ||
330 | Runs the game engine for one frame. | ||
331 | */ | ||
332 | int gameProc( void ) | ||
333 | { | ||
334 | int x,y; | ||
335 | int fps; | ||
336 | char str[80]; | ||
337 | int status; | ||
338 | long end_time; | ||
339 | unsigned char* vbuf = video_buffer; | ||
340 | fb_data* dst; | ||
341 | fb_data* next_dst; | ||
342 | |||
343 | /* Run the machine for one frame (1/60th second) */ | ||
344 | run(); | ||
345 | |||
346 | frame_counter++; | ||
347 | |||
348 | /* Check the button status */ | ||
349 | status = rb->button_status(); | ||
350 | |||
351 | #ifdef PACMAN_MENU | ||
352 | if (status & PACMAN_MENU) { | ||
353 | #else | ||
354 | if (rb->button_hold()) { | ||
355 | #endif | ||
356 | end_time = *rb->current_tick; | ||
357 | x = pacbox_menu(); | ||
358 | rb->lcd_clear_display(); | ||
359 | #ifdef HAVE_REMOTE_LCD | ||
360 | rb->lcd_remote_clear_display(); | ||
361 | rb->lcd_remote_update(); | ||
362 | #endif | ||
363 | if (x == 1) { return 1; } | ||
364 | start_time += *rb->current_tick-end_time; | ||
365 | } | ||
366 | |||
367 | setDeviceMode( Joy1_Left, (status & PACMAN_LEFT) ? DeviceOn : DeviceOff); | ||
368 | setDeviceMode( Joy1_Right, (status & PACMAN_RIGHT) ? DeviceOn : DeviceOff); | ||
369 | setDeviceMode( Joy1_Up, (status & PACMAN_UP) ? DeviceOn : DeviceOff); | ||
370 | setDeviceMode( Joy1_Down, (status & PACMAN_DOWN) ? DeviceOn : DeviceOff); | ||
371 | setDeviceMode( CoinSlot_1, (status & PACMAN_COIN) ? DeviceOn : DeviceOff); | ||
372 | setDeviceMode( Key_OnePlayer, (status & PACMAN_1UP) ? DeviceOn : DeviceOff); | ||
373 | #ifdef PACMAN_2UP | ||
374 | setDeviceMode( Key_TwoPlayers, (status & PACMAN_2UP) ? DeviceOn : DeviceOff); | ||
375 | #endif | ||
376 | |||
377 | /* We only update the screen every third frame - Pacman's native | ||
378 | framerate is 60fps, so we are attempting to display 20fps */ | ||
379 | if( (frame_counter % (60/FPS)) == 0) { | ||
380 | |||
381 | video_frames++; | ||
382 | |||
383 | /* The following functions render the Pacman screen from the contents | ||
384 | of the video and color ram. We first update the background, and | ||
385 | then draw the Sprites on top. | ||
386 | |||
387 | Note that we only redraw the parts of the background that have | ||
388 | changed, which is why we need to keep a copy of the background without | ||
389 | the sprites on top. Even with the memcpy, this is faster than redrawing | ||
390 | the whole background. | ||
391 | */ | ||
392 | renderBackground( background ); | ||
393 | rb->memcpy(video_buffer,background,sizeof(video_buffer)); | ||
394 | renderSprites( video_buffer ); | ||
395 | |||
396 | #ifdef HAVE_LCD_COLOR | ||
397 | #if (LCD_WIDTH >= 224) && (LCD_HEIGHT >= 288) | ||
398 | /* Native resolution = 224x288 */ | ||
399 | (void)next_dst; | ||
400 | dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS]; | ||
401 | for (y=0;y<ScreenHeight;y++) { | ||
402 | for (x=0;x<ScreenWidth;x++) { | ||
403 | *(dst++) = palette[*(vbuf++)]; | ||
404 | } | ||
405 | dst += XOFS*2; | ||
406 | } | ||
407 | #elif (LCD_WIDTH >= 288) && (LCD_HEIGHT >= 224) | ||
408 | /* Native resolution - rotated 90 degrees = 288x224 */ | ||
409 | next_dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight-1]; | ||
410 | for( y=ScreenHeight-1; y>=0; y-- ) { | ||
411 | dst = (next_dst--); | ||
412 | for( x=0; x<ScreenWidth; x++ ) { | ||
413 | *dst = palette[*(vbuf++)]; | ||
414 | dst+=LCD_WIDTH; | ||
415 | } | ||
416 | } | ||
417 | #elif (LCD_WIDTH >= 216) && (LCD_HEIGHT >= 168) | ||
418 | /* 0.75 scaling - display 3 out of 4 pixels = 216x168 | ||
419 | Skipping pixel #2 out of 4 seems to give the most legible display | ||
420 | */ | ||
421 | next_dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+((ScreenHeight*3)/4)-1]; | ||
422 | for (y=ScreenHeight-1;y >= 0; y--) { | ||
423 | if ((y & 3) != 1) { | ||
424 | dst = (next_dst--); | ||
425 | for (x=0;x<ScreenWidth;x++) { | ||
426 | if ((x & 3) == 1) { vbuf++; } | ||
427 | else { | ||
428 | *dst = palette[*(vbuf++)]; | ||
429 | dst+=LCD_WIDTH; | ||
430 | } | ||
431 | } | ||
432 | } else { | ||
433 | vbuf+=ScreenWidth; | ||
434 | } | ||
435 | } | ||
436 | #elif (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) | ||
437 | /* 0.5 scaling - display every other pixel = 144x112 */ | ||
438 | next_dst=&rb->lcd_framebuffer[YOFS*LCD_WIDTH+XOFS+ScreenHeight/2-1]; | ||
439 | for (y=(ScreenHeight/2)-1;y >= 0; y--) { | ||
440 | dst = (next_dst--); | ||
441 | for (x=0;x<ScreenWidth/2;x++) { | ||
442 | *dst = palette[*(vbuf)]; | ||
443 | vbuf+=2; | ||
444 | dst+=LCD_WIDTH; | ||
445 | } | ||
446 | vbuf+=ScreenWidth; | ||
447 | } | ||
448 | #endif | ||
449 | #else /* Greyscale LCDs */ | ||
450 | #if (LCD_WIDTH >= 144) && (LCD_HEIGHT >= 112) | ||
451 | #if LCD_PIXELFORMAT == VERTICAL_PACKING | ||
452 | /* 0.5 scaling - display every other pixel = 144x112 */ | ||
453 | next_dst=&rb->lcd_framebuffer[YOFS/4*LCD_WIDTH+XOFS+ScreenHeight/2-1]; | ||
454 | for (y=(ScreenHeight/2)-1;y >= 0; y--) { | ||
455 | dst = (next_dst--); | ||
456 | for (x=0;x<ScreenWidth/8;x++) { | ||
457 | *dst = (palette[*(vbuf+6)]<<6) | (palette[*(vbuf+4)] << 4) | (palette[*(vbuf+2)] << 2) | palette[*(vbuf)]; | ||
458 | vbuf+=8; | ||
459 | dst+=LCD_WIDTH; | ||
460 | } | ||
461 | vbuf+=ScreenWidth; | ||
462 | } | ||
463 | #endif /* Vertical Packing */ | ||
464 | #endif /* Size >= 144x112 */ | ||
465 | #endif /* Not Colour */ | ||
466 | |||
467 | if (settings.showfps) { | ||
468 | fps = (video_frames*HZ*100) / (*rb->current_tick-start_time); | ||
469 | rb->snprintf(str,sizeof(str),"%d.%02d / %d fps ",fps/100,fps%100, | ||
470 | FPS); | ||
471 | rb->lcd_putsxy(0,0,str); | ||
472 | } | ||
473 | |||
474 | rb->lcd_update(); | ||
475 | |||
476 | #ifdef SIMULATOR | ||
477 | /* Keep the framerate at Pacman's 60fps */ | ||
478 | end_time = start_time + (video_frames*HZ)/FPS; | ||
479 | while (TIME_BEFORE(*rb->current_tick,end_time)) { | ||
480 | rb->sleep(1); | ||
481 | } | ||
482 | #endif | ||
483 | } | ||
484 | |||
485 | return 0; | ||
486 | } | ||
487 | |||
488 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
489 | { | ||
490 | (void)parameter; | ||
491 | int status; | ||
492 | |||
493 | rb = api; | ||
494 | |||
495 | #ifdef USE_IRAM | ||
496 | rb->memcpy(iramstart, iramcopy, iramend-iramstart); | ||
497 | rb->memset(iedata, 0, iend - iedata); | ||
498 | #endif | ||
499 | |||
500 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
501 | rb->cpu_boost(true); | ||
502 | #endif | ||
503 | |||
504 | rb->lcd_set_foreground(LCD_WHITE); | ||
505 | rb->lcd_set_background(LCD_BLACK); | ||
506 | rb->lcd_clear_display(); | ||
507 | rb->lcd_update(); | ||
508 | |||
509 | /* Set the default settings (we should load these from a file) */ | ||
510 | settings.difficulty = 0; /* Normal */ | ||
511 | settings.numlives = 2; /* 3 lives */ | ||
512 | settings.bonus = 0; /* 10000 points */ | ||
513 | settings.ghostnames = 0; /* Normal names */ | ||
514 | settings.showfps = 0; /* Do not show FPS */ | ||
515 | |||
516 | /* Initialise the hardware */ | ||
517 | init_PacmanMachine(settings_to_dip(settings)); | ||
518 | |||
519 | /* Load the romset */ | ||
520 | if (loadROMS()) { | ||
521 | start_time = *rb->current_tick-1; | ||
522 | do { | ||
523 | status = gameProc(); | ||
524 | } while (!status); | ||
525 | } else { | ||
526 | rb->splash(HZ*2,true,"No ROMs in /.rockbox/pacman/"); | ||
527 | } | ||
528 | |||
529 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
530 | rb->cpu_boost(false); | ||
531 | #endif | ||
532 | |||
533 | return PLUGIN_OK; | ||
534 | } | ||
diff --git a/apps/plugins/pacbox/readme.txt b/apps/plugins/pacbox/readme.txt new file mode 100644 index 0000000000..41fc89ea76 --- /dev/null +++ b/apps/plugins/pacbox/readme.txt | |||
@@ -0,0 +1,13 @@ | |||
1 | Pacbox is based on PIE - the Pacman Instructional Emulator written by | ||
2 | Alessandro Scotti. PIE is a Pacman arcade machine emulator licensed | ||
3 | under the GNU GPL and is available from http://www.ascotti.org/ | ||
4 | |||
5 | PIE is a Windows application written in C++ - all the Windows-specific | ||
6 | code was stripped out and the emulator converted to C for use in | ||
7 | Rockbox. | ||
8 | |||
9 | The version of PIE used as the basis of the port was v1.11 | ||
10 | |||
11 | |||
12 | Dave Chapman | ||
13 | March 2006 | ||
diff --git a/apps/plugins/pacbox/z80.c b/apps/plugins/pacbox/z80.c new file mode 100644 index 0000000000..b489682b3a --- /dev/null +++ b/apps/plugins/pacbox/z80.c | |||
@@ -0,0 +1,8058 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #include "plugin.h" | ||
26 | #include "hardware.h" | ||
27 | #include "z80.h" | ||
28 | #include "z80_internal.h" | ||
29 | |||
30 | // Table with parity, sign and zero flags precomputed for each byte value | ||
31 | unsigned char PSZ_[256] = { | ||
32 | Zero|Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, | ||
33 | 0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, | ||
34 | 0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, | ||
35 | Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, | ||
36 | 0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, | ||
37 | Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, | ||
38 | Parity, 0, 0, Parity, 0, Parity, Parity, 0, 0, Parity, Parity, 0, Parity, 0, 0, Parity, | ||
39 | 0, Parity, Parity, 0, Parity, 0, 0, Parity, Parity, 0, 0, Parity, 0, Parity, Parity, 0, | ||
40 | Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, | ||
41 | Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, | ||
42 | Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, | ||
43 | Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, | ||
44 | Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, | ||
45 | Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, | ||
46 | Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, | ||
47 | Sign|Parity, Sign, Sign, Sign|Parity, Sign, Sign|Parity, Sign|Parity, Sign, Sign, Sign|Parity, Sign|Parity, Sign, Sign|Parity, Sign, Sign, Sign|Parity | ||
48 | }; | ||
49 | |||
50 | // Interrupt flags | ||
51 | enum { | ||
52 | IFF1 = 0x40, // Interrupts enabled/disabled | ||
53 | IFF2 = 0x20, // Copy of IFF1 (used by non-maskable interrupts) | ||
54 | Halted = 0x10 // Internal use: signals that the CPU is halted | ||
55 | }; | ||
56 | |||
57 | // Implements an opcode | ||
58 | typedef void (OpcodeHandler)(void); | ||
59 | |||
60 | typedef struct { | ||
61 | OpcodeHandler* handler; | ||
62 | unsigned cycles; | ||
63 | } OpcodeInfo; | ||
64 | |||
65 | // Implements an opcode for instructions that use the form (IX/IY + b) | ||
66 | typedef void (OpcodeHandlerXY)( unsigned ); | ||
67 | |||
68 | typedef struct { | ||
69 | OpcodeHandlerXY* handler; | ||
70 | unsigned cycles; | ||
71 | } OpcodeInfoXY; | ||
72 | |||
73 | /** */ | ||
74 | void do_opcode_xy( OpcodeInfo * ); | ||
75 | |||
76 | /** */ | ||
77 | unsigned do_opcode_xycb( unsigned xy ); | ||
78 | |||
79 | unsigned iflags_; // Interrupt mode (bits 0 and 1) and flags | ||
80 | unsigned cycles_; // Number of CPU cycles elapsed so far | ||
81 | |||
82 | |||
83 | // Registers | ||
84 | unsigned char B; //@- B register | ||
85 | unsigned char C; //@- C register | ||
86 | unsigned char D; //@- D register | ||
87 | unsigned char E; //@- E register | ||
88 | unsigned char H; //@- H register | ||
89 | unsigned char L; //@- L register | ||
90 | unsigned char A; //@- A register (accumulator) | ||
91 | unsigned char F; //@- Flags register | ||
92 | unsigned char B1; //@- Alternate B register (B') | ||
93 | unsigned char C1; //@- Alternate C register (C') | ||
94 | unsigned char D1; //@- Alternate D register (D') | ||
95 | unsigned char E1; //@- Alternate E register (E') | ||
96 | unsigned char H1; //@- Alternate H register (H') | ||
97 | unsigned char L1; //@- Alternate L register (L') | ||
98 | unsigned char A1; //@- Alternate A register (A') | ||
99 | unsigned char F1; //@- Alternate flags register (F') | ||
100 | unsigned IX; //@- Index register X | ||
101 | unsigned IY; //@- Index register Y | ||
102 | unsigned PC; //@- Program counter | ||
103 | unsigned SP; //@- Stack pointer | ||
104 | unsigned char I; //@- Interrupt register | ||
105 | unsigned char R; //@- Refresh register | ||
106 | |||
107 | |||
108 | /** Returns the 16 bit register BC. */ | ||
109 | #define BC() (((unsigned)B << 8) | C) | ||
110 | #define DE() (((unsigned)D << 8) | E) | ||
111 | #define HL() (((unsigned)H << 8) | L) | ||
112 | |||
113 | /** | ||
114 | Returns the number of Z80 CPU cycles elapsed so far. | ||
115 | |||
116 | The cycle count is reset to zero when reset() is called, or | ||
117 | it can be set to any value with setCycles(). It is updated after | ||
118 | a CPU instruction is executed, for example by calling step() | ||
119 | or interrupt(). | ||
120 | */ | ||
121 | unsigned getCycles(void) { | ||
122 | return cycles_; | ||
123 | } | ||
124 | |||
125 | /** Sets the CPU cycle counter to the specified value. */ | ||
126 | void setCycles( unsigned value ) { | ||
127 | cycles_ = value; | ||
128 | } | ||
129 | |||
130 | /** Returns the current interrupt mode. */ | ||
131 | unsigned getInterruptMode(void) { | ||
132 | return iflags_ & 0x03; | ||
133 | } | ||
134 | |||
135 | /** Sets the interrupt mode to the specified value. */ | ||
136 | void setInterruptMode( unsigned mode ); | ||
137 | |||
138 | /** Returns non-zero if the CPU is halted, otherwise zero. */ | ||
139 | int isHalted(void) { | ||
140 | return iflags_ & Halted; | ||
141 | } | ||
142 | |||
143 | /* | ||
144 | Sets the interrupt mode to IM0, IM1 or IM2. | ||
145 | */ | ||
146 | void setInterruptMode( unsigned mode ) | ||
147 | { | ||
148 | if( mode <= 2 ) { | ||
149 | iflags_ = (iflags_ & ~0x03) | mode; | ||
150 | } | ||
151 | } | ||
152 | |||
153 | /* | ||
154 | Calls a subroutine at the specified address. | ||
155 | */ | ||
156 | void callSub( unsigned addr ) | ||
157 | { | ||
158 | SP -= 2; | ||
159 | writeWord( SP, PC ); // Save current program counter in the stack | ||
160 | PC = addr & 0xFFFF; // Jump to the specified address | ||
161 | } | ||
162 | |||
163 | /* | ||
164 | Decrements a byte value by one. | ||
165 | Note that this is different from subtracting one from the byte value, | ||
166 | because flags behave differently. | ||
167 | */ | ||
168 | static inline unsigned char decByte( unsigned char b ) | ||
169 | { | ||
170 | F = Subtraction | (F & Carry); // Preserve the carry flag | ||
171 | if( (b & 0x0F) == 0 ) F |= Halfcarry; | ||
172 | --b; | ||
173 | if( b == 0x7F ) F |= Overflow; | ||
174 | if( b & 0x80 ) F |= Sign; | ||
175 | if( b == 0 ) F |= Zero; | ||
176 | |||
177 | return b; | ||
178 | } | ||
179 | |||
180 | /* | ||
181 | Increments a byte value by one. | ||
182 | Note that this is different from adding one to the byte value, | ||
183 | because flags behave differently. | ||
184 | */ | ||
185 | static inline unsigned char incByte( unsigned char b ) | ||
186 | { | ||
187 | ++b; | ||
188 | F &= Carry; // Preserve the carry flag | ||
189 | if( ! (b & 0x0F) ) F |= Halfcarry; | ||
190 | if( b == 0x80 ) F |= Overflow; | ||
191 | if( b & 0x80 ) F |= Sign; | ||
192 | if( b == 0 ) F |= Zero; | ||
193 | |||
194 | return b; | ||
195 | } | ||
196 | |||
197 | /* | ||
198 | Reads one byte from port C, updating flags according to the rules of "IN r,(C)". | ||
199 | */ | ||
200 | static inline unsigned char inpReg(void) | ||
201 | { | ||
202 | unsigned char r = readPort( C ); | ||
203 | |||
204 | F = (F & Carry) | PSZ_[r]; | ||
205 | |||
206 | return r; | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | Performs a relative jump to the specified offset. | ||
211 | */ | ||
212 | static inline void relJump( unsigned char o ) | ||
213 | { | ||
214 | int offset = (int)((signed char)o); | ||
215 | |||
216 | PC = (unsigned)((int)PC + offset) & 0xFFFF; | ||
217 | cycles_++; | ||
218 | } | ||
219 | |||
220 | /* | ||
221 | Returns from a subroutine, popping the saved Program Counter from the stack. | ||
222 | */ | ||
223 | static inline void retFromSub(void) | ||
224 | { | ||
225 | PC = readWord( SP ); | ||
226 | SP += 2; | ||
227 | } | ||
228 | |||
229 | /* | ||
230 | Rotates left one byte thru the carry flag. | ||
231 | */ | ||
232 | static inline unsigned char rotateLeft( unsigned char op ) | ||
233 | { | ||
234 | unsigned char f = F; | ||
235 | |||
236 | F = 0; | ||
237 | if( op & 0x80 ) F |= Carry; | ||
238 | op <<= 1; | ||
239 | if( f & Carry ) op |= 0x01; | ||
240 | F |= PSZ_[op]; | ||
241 | |||
242 | return op; | ||
243 | } | ||
244 | |||
245 | /* | ||
246 | Rotates left one byte copying the most significant bit (bit 7) in the carry flag. | ||
247 | */ | ||
248 | static inline unsigned char rotateLeftCarry( unsigned char op ) | ||
249 | { | ||
250 | F = 0; | ||
251 | if( op & 0x80 ) F |= Carry; | ||
252 | op = (op << 1) | (op >> 7); | ||
253 | F |= PSZ_[op]; | ||
254 | |||
255 | return op; | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | Rotates right one byte thru the carry flag. | ||
260 | */ | ||
261 | static inline unsigned char rotateRight( unsigned char op ) | ||
262 | { | ||
263 | unsigned char f = F; | ||
264 | |||
265 | F = 0; | ||
266 | if( op & 0x01 ) F |= Carry; | ||
267 | op >>= 1; | ||
268 | if( f & Carry ) op |= 0x80; | ||
269 | F |= PSZ_[op]; | ||
270 | |||
271 | return op; | ||
272 | } | ||
273 | |||
274 | /* | ||
275 | Rotates right one byte copying the least significant bit (bit 0) in the carry flag. | ||
276 | */ | ||
277 | static inline unsigned char rotateRightCarry( unsigned char op ) | ||
278 | { | ||
279 | F = 0; | ||
280 | if( op & 0x01 ) F |= Carry; | ||
281 | op = (op >> 1) | (op << 7); | ||
282 | F |= PSZ_[op]; | ||
283 | |||
284 | return op; | ||
285 | } | ||
286 | |||
287 | /* | ||
288 | Shifts left one byte. | ||
289 | */ | ||
290 | static inline unsigned char shiftLeft( unsigned char op ) | ||
291 | { | ||
292 | F = 0; | ||
293 | if( op & 0x80 ) F |= Carry; | ||
294 | op <<= 1; | ||
295 | F |= PSZ_[op]; | ||
296 | |||
297 | return op; | ||
298 | } | ||
299 | |||
300 | /* | ||
301 | Shifts right one byte, preserving its sign (most significant bit). | ||
302 | */ | ||
303 | static inline unsigned char shiftRightArith( unsigned char op ) | ||
304 | { | ||
305 | F = 0; | ||
306 | if( op & 0x01 ) F |= Carry; | ||
307 | op = (op >> 1) | (op & 0x80); | ||
308 | |||
309 | F |= PSZ_[op]; | ||
310 | |||
311 | return op; | ||
312 | } | ||
313 | |||
314 | /* | ||
315 | Shifts right one byte. | ||
316 | */ | ||
317 | static inline unsigned char shiftRightLogical( unsigned char op ) | ||
318 | { | ||
319 | F = 0; | ||
320 | if( op & 0x01 ) F |= Carry; | ||
321 | op >>= 1; | ||
322 | |||
323 | F |= PSZ_[op]; | ||
324 | |||
325 | return op; | ||
326 | } | ||
327 | |||
328 | /* | ||
329 | Tests whether the specified bit of op is set. | ||
330 | */ | ||
331 | static inline void testBit( unsigned char bit, unsigned char op ) | ||
332 | { | ||
333 | // Flags for a bit test operation are: | ||
334 | // S, P: unknown | ||
335 | // Z: set if bit is zero, reset otherwise | ||
336 | // N: reset | ||
337 | // H: set | ||
338 | // C: unaffected | ||
339 | // However, it seems that parity is always set like Z, so we emulate that as well. | ||
340 | F = (F & (Carry | Sign)) | Halfcarry; | ||
341 | |||
342 | if( (op & (1 << bit)) == 0 ) { | ||
343 | // Bit is not set, so set the zero flag | ||
344 | F |= Zero | Parity; | ||
345 | } | ||
346 | } | ||
347 | |||
348 | /* | ||
349 | Adds the specified byte op to the accumulator, adding | ||
350 | carry. | ||
351 | */ | ||
352 | static inline void addByte( unsigned char op, unsigned char cf ) | ||
353 | { | ||
354 | unsigned x = A + op; | ||
355 | |||
356 | if( cf ) x++; // Add carry | ||
357 | |||
358 | F = 0; | ||
359 | if( !(x & 0xFF) ) F |= Zero; | ||
360 | if( x & 0x80 ) F |= Sign; | ||
361 | if( x >= 0x100 ) F |= Carry; | ||
362 | |||
363 | /* | ||
364 | Halfcarry is set on carry from the low order four bits. | ||
365 | |||
366 | To see how to compute it, let's take a look at the following table, which | ||
367 | shows the binary addition of two binary numbers: | ||
368 | |||
369 | A B A+B | ||
370 | ----------- | ||
371 | 0 0 0 | ||
372 | 0 1 1 | ||
373 | 1 0 1 | ||
374 | 1 1 0 | ||
375 | |||
376 | Note that if only the lowest bit is used, then A+B, A-B and A^B yield the same | ||
377 | value. If we know A, B and the sum A+B+C, then C is easily derived: | ||
378 | C = A+B+C - A - B, that is | ||
379 | C = A+B+C ^ A ^ B. | ||
380 | |||
381 | For the halfcarry, A and B above are the fifth bit of a byte, which corresponds | ||
382 | to the value 0x10. So: | ||
383 | |||
384 | Halfcarry = ((accumulator+operand+halfcarry) ^ accumulator ^ operand) & 0x10 | ||
385 | |||
386 | Note that masking off all bits but one is important because we have worked all | ||
387 | the math by using one bit only. | ||
388 | */ | ||
389 | if( (A ^ op ^ x) & 0x10 ) F |= Halfcarry; | ||
390 | |||
391 | /* | ||
392 | The overflow bit is set when the result is too large to fit into the destination | ||
393 | register, causing a change in the sign bit. | ||
394 | |||
395 | For a sum, we can only have overflow when adding two numbers that are both positive | ||
396 | or both negative. For example 0x5E + 0x4B (94 + 75) yields 0xA9 (169), which fits | ||
397 | into an 8-bit register only if it is interpreted as an unsigned number. If we | ||
398 | consider the result as a signed integer, then 0xA9 corresponds to decimal -87 and | ||
399 | we have overflow. | ||
400 | Note that if we add two signed numbers of opposite sign then we cannot overflow | ||
401 | the destination register, because the absolute value of the result will always fit | ||
402 | in 7 bits, leaving the most significant bit free for use as a sign bit. | ||
403 | |||
404 | We can code all the above concisely by noting that: | ||
405 | |||
406 | ~(A ^ op) & 0x80 | ||
407 | |||
408 | is true if and only if A and op have the same sign. Also: | ||
409 | |||
410 | (x ^ op) & 0x80 | ||
411 | |||
412 | is true if and only if the sum of A and op has taken a sign opposite to that | ||
413 | of its operands. | ||
414 | |||
415 | Thus the expression: | ||
416 | |||
417 | ~(A ^ op) & (x ^ op) & 0x80 | ||
418 | |||
419 | reads "A has the same sign as op, and the opposite as x", where x is the sum of | ||
420 | A and op (and an optional carry). | ||
421 | */ | ||
422 | if( ~(A ^ op) & (x ^ op) & 0x80 ) F |= Overflow; | ||
423 | |||
424 | A = x; | ||
425 | } | ||
426 | |||
427 | /* | ||
428 | Subtracts the specified byte op from the accumulator, using carry as | ||
429 | borrow from a previous operation. | ||
430 | */ | ||
431 | static inline unsigned char subByte( unsigned char op, unsigned char cf ) | ||
432 | { | ||
433 | unsigned char x = A - op; | ||
434 | |||
435 | if( cf ) x--; | ||
436 | |||
437 | F = Subtraction; | ||
438 | if( x == 0 ) F |= Zero; | ||
439 | if( x & 0x80 ) F |= Sign; | ||
440 | if( (x >= A) && (op | cf)) F |= Carry; | ||
441 | |||
442 | // See addByte() for an explanation of the halfcarry bit | ||
443 | if( (A ^ op ^ x) & 0x10 ) F |= Halfcarry; | ||
444 | |||
445 | // See addByte() for an explanation of the overflow bit. The only difference here | ||
446 | // is that for a subtraction we must check that the two operands have different | ||
447 | // sign, because in fact A-B is A+(-B). Note however that since subtraction is not | ||
448 | // symmetric, we have to use (x ^ A) to get the correct result, whereas for the | ||
449 | // addition (x ^ A) is equivalent to (x ^ op) | ||
450 | if( (A ^ op) & (x ^ A) & 0x80 ) F |= Overflow; | ||
451 | |||
452 | return x; | ||
453 | } | ||
454 | |||
455 | static inline unsigned addDispl( unsigned addr, unsigned char displ ) { | ||
456 | return (unsigned)((int)addr + (int)(signed char)displ); | ||
457 | } | ||
458 | |||
459 | /** Compares the accumulator and the specified operand (CP op) */ | ||
460 | static inline void cmpByte( unsigned char op ) { | ||
461 | subByte( op, 0 ); | ||
462 | } | ||
463 | |||
464 | /** Fetches a byte from the program counter location */ | ||
465 | static inline unsigned char fetchByte(void) { | ||
466 | return readByte( PC++ ); | ||
467 | } | ||
468 | |||
469 | /** Fetches a 16 bit word from the program counter location */ | ||
470 | static inline unsigned fetchWord(void) { | ||
471 | unsigned x = readWord( PC ); | ||
472 | PC += 2; | ||
473 | return x; | ||
474 | } | ||
475 | |||
476 | /** Sets the parity, sign and zero flags from the accumulator value */ | ||
477 | static inline void setFlagsPSZ(void) { | ||
478 | F = Halfcarry | PSZ_[A]; | ||
479 | } | ||
480 | |||
481 | /** Sets the parity, sign, zero, 3rd and 5th flag bits from the accumulator value */ | ||
482 | static inline void setFlags35PSZ(void) { | ||
483 | F = (F & (Carry | Halfcarry | Subtraction)) | PSZ_[A]; | ||
484 | } | ||
485 | |||
486 | /** */ | ||
487 | static inline void setFlags35PSZ000(void) { | ||
488 | F = PSZ_[A]; | ||
489 | } | ||
490 | |||
491 | /* Resets the CPU */ | ||
492 | void z80_reset() | ||
493 | { | ||
494 | PC = 0; // Program counter is zero | ||
495 | I = 0; // Interrupt register cleared | ||
496 | R = 0; // Memory refresh register cleared | ||
497 | iflags_ = 0; // IFF1 and IFF2 cleared, IM0 enabled | ||
498 | cycles_ = 0; // Could that be 2 (according to some Zilog docs)? | ||
499 | |||
500 | // There is no official documentation for the following! | ||
501 | B = B1 = 0; | ||
502 | C = C1 = 0; | ||
503 | D = D1 = 0; | ||
504 | E = E1 = 0; | ||
505 | H = H1 = 0; | ||
506 | L = L1 = 0; | ||
507 | A = A1 = 0; | ||
508 | F = F1 = 0; | ||
509 | IX = 0; | ||
510 | IY = 0; | ||
511 | SP = 0xF000; | ||
512 | } | ||
513 | |||
514 | unsigned z80_getSizeOfSnapshotBuffer(void) | ||
515 | { | ||
516 | unsigned result = | ||
517 | 8*2 + // 8-bit registers | ||
518 | 1 + // I | ||
519 | 1 + // R | ||
520 | 2 + // IX | ||
521 | 2 + // IY | ||
522 | 2 + // PC | ||
523 | 2 + // SP | ||
524 | 4 + // iflags_ | ||
525 | 4; // cycles_ | ||
526 | |||
527 | return result; | ||
528 | } | ||
529 | |||
530 | static unsigned saveUint16( unsigned char * buffer, unsigned u ) | ||
531 | { | ||
532 | *buffer++ = (unsigned char) (u >> 8); | ||
533 | *buffer = (unsigned char) (u); | ||
534 | |||
535 | return 2; | ||
536 | } | ||
537 | |||
538 | unsigned z80_takeSnapshot( unsigned char * buffer ) | ||
539 | { | ||
540 | unsigned char * buf = buffer; | ||
541 | |||
542 | *buf++ = A; *buf++ = A1; | ||
543 | *buf++ = B; *buf++ = B1; | ||
544 | *buf++ = C; *buf++ = C1; | ||
545 | *buf++ = D; *buf++ = D1; | ||
546 | *buf++ = E; *buf++ = E1; | ||
547 | *buf++ = H; *buf++ = H1; | ||
548 | *buf++ = L; *buf++ = L1; | ||
549 | *buf++ = F; *buf++ = F1; | ||
550 | |||
551 | *buf++ = I; | ||
552 | *buf++ = R; | ||
553 | |||
554 | buf += saveUint16( buf, IX ); | ||
555 | buf += saveUint16( buf, IY ); | ||
556 | buf += saveUint16( buf, PC ); | ||
557 | buf += saveUint16( buf, SP ); | ||
558 | |||
559 | buf += saveUint16( buf, iflags_ >> 16 ); | ||
560 | buf += saveUint16( buf, iflags_ ); | ||
561 | buf += saveUint16( buf, cycles_ >> 16 ); | ||
562 | buf += saveUint16( buf, cycles_ ); | ||
563 | |||
564 | return buffer - buf; | ||
565 | } | ||
566 | |||
567 | static unsigned loadUint16( unsigned char ** buffer ) | ||
568 | { | ||
569 | unsigned char * buf = *buffer; | ||
570 | unsigned result = *buf++; | ||
571 | |||
572 | result = (result << 8) | *buf++; | ||
573 | |||
574 | *buffer = buf; | ||
575 | |||
576 | return result; | ||
577 | } | ||
578 | |||
579 | unsigned z80_restoreSnapshot( unsigned char * buffer ) | ||
580 | { | ||
581 | unsigned char * buf = buffer; | ||
582 | |||
583 | A = *buf++; A1 = *buf++; | ||
584 | B = *buf++; B1 = *buf++; | ||
585 | C = *buf++; C1 = *buf++; | ||
586 | D = *buf++; D1 = *buf++; | ||
587 | E = *buf++; E1 = *buf++; | ||
588 | H = *buf++; H1 = *buf++; | ||
589 | L = *buf++; L1 = *buf++; | ||
590 | F = *buf++; F1 = *buf++; | ||
591 | |||
592 | I = *buf++; | ||
593 | R = *buf++; | ||
594 | |||
595 | IX = loadUint16( &buf ); | ||
596 | IY = loadUint16( &buf ); | ||
597 | PC = loadUint16( &buf ); | ||
598 | SP = loadUint16( &buf ); | ||
599 | |||
600 | iflags_ = loadUint16( &buf ); | ||
601 | iflags_ = (iflags_ << 16) | loadUint16(&buf); | ||
602 | cycles_ = loadUint16( &buf ); | ||
603 | cycles_ = (cycles_ << 16) | loadUint16(&buf); | ||
604 | |||
605 | return buf - buffer; | ||
606 | } | ||
607 | |||
608 | OpcodeInfo OpInfoCB_[256] = { | ||
609 | { &opcode_cb_00, 8 }, // RLC B | ||
610 | { &opcode_cb_01, 8 }, // RLC C | ||
611 | { &opcode_cb_02, 8 }, // RLC D | ||
612 | { &opcode_cb_03, 8 }, // RLC E | ||
613 | { &opcode_cb_04, 8 }, // RLC H | ||
614 | { &opcode_cb_05, 8 }, // RLC L | ||
615 | { &opcode_cb_06, 15 }, // RLC (HL) | ||
616 | { &opcode_cb_07, 8 }, // RLC A | ||
617 | { &opcode_cb_08, 8 }, // RRC B | ||
618 | { &opcode_cb_09, 8 }, // RRC C | ||
619 | { &opcode_cb_0a, 8 }, // RRC D | ||
620 | { &opcode_cb_0b, 8 }, // RRC E | ||
621 | { &opcode_cb_0c, 8 }, // RRC H | ||
622 | { &opcode_cb_0d, 8 }, // RRC L | ||
623 | { &opcode_cb_0e, 15 }, // RRC (HL) | ||
624 | { &opcode_cb_0f, 8 }, // RRC A | ||
625 | { &opcode_cb_10, 8 }, // RL B | ||
626 | { &opcode_cb_11, 8 }, // RL C | ||
627 | { &opcode_cb_12, 8 }, // RL D | ||
628 | { &opcode_cb_13, 8 }, // RL E | ||
629 | { &opcode_cb_14, 8 }, // RL H | ||
630 | { &opcode_cb_15, 8 }, // RL L | ||
631 | { &opcode_cb_16, 15 }, // RL (HL) | ||
632 | { &opcode_cb_17, 8 }, // RL A | ||
633 | { &opcode_cb_18, 8 }, // RR B | ||
634 | { &opcode_cb_19, 8 }, // RR C | ||
635 | { &opcode_cb_1a, 8 }, // RR D | ||
636 | { &opcode_cb_1b, 8 }, // RR E | ||
637 | { &opcode_cb_1c, 8 }, // RR H | ||
638 | { &opcode_cb_1d, 8 }, // RR L | ||
639 | { &opcode_cb_1e, 15 }, // RR (HL) | ||
640 | { &opcode_cb_1f, 8 }, // RR A | ||
641 | { &opcode_cb_20, 8 }, // SLA B | ||
642 | { &opcode_cb_21, 8 }, // SLA C | ||
643 | { &opcode_cb_22, 8 }, // SLA D | ||
644 | { &opcode_cb_23, 8 }, // SLA E | ||
645 | { &opcode_cb_24, 8 }, // SLA H | ||
646 | { &opcode_cb_25, 8 }, // SLA L | ||
647 | { &opcode_cb_26, 15 }, // SLA (HL) | ||
648 | { &opcode_cb_27, 8 }, // SLA A | ||
649 | { &opcode_cb_28, 8 }, // SRA B | ||
650 | { &opcode_cb_29, 8 }, // SRA C | ||
651 | { &opcode_cb_2a, 8 }, // SRA D | ||
652 | { &opcode_cb_2b, 8 }, // SRA E | ||
653 | { &opcode_cb_2c, 8 }, // SRA H | ||
654 | { &opcode_cb_2d, 8 }, // SRA L | ||
655 | { &opcode_cb_2e, 15 }, // SRA (HL) | ||
656 | { &opcode_cb_2f, 8 }, // SRA A | ||
657 | { &opcode_cb_30, 8 }, // SLL B | ||
658 | { &opcode_cb_31, 8 }, // SLL C | ||
659 | { &opcode_cb_32, 8 }, // SLL D | ||
660 | { &opcode_cb_33, 8 }, // SLL E | ||
661 | { &opcode_cb_34, 8 }, // SLL H | ||
662 | { &opcode_cb_35, 8 }, // SLL L | ||
663 | { &opcode_cb_36, 15 }, // SLL (HL) | ||
664 | { &opcode_cb_37, 8 }, // SLL A | ||
665 | { &opcode_cb_38, 8 }, // SRL B | ||
666 | { &opcode_cb_39, 8 }, // SRL C | ||
667 | { &opcode_cb_3a, 8 }, // SRL D | ||
668 | { &opcode_cb_3b, 8 }, // SRL E | ||
669 | { &opcode_cb_3c, 8 }, // SRL H | ||
670 | { &opcode_cb_3d, 8 }, // SRL L | ||
671 | { &opcode_cb_3e, 15 }, // SRL (HL) | ||
672 | { &opcode_cb_3f, 8 }, // SRL A | ||
673 | { &opcode_cb_40, 8 }, // BIT 0, B | ||
674 | { &opcode_cb_41, 8 }, // BIT 0, C | ||
675 | { &opcode_cb_42, 8 }, // BIT 0, D | ||
676 | { &opcode_cb_43, 8 }, // BIT 0, E | ||
677 | { &opcode_cb_44, 8 }, // BIT 0, H | ||
678 | { &opcode_cb_45, 8 }, // BIT 0, L | ||
679 | { &opcode_cb_46, 12 }, // BIT 0, (HL) | ||
680 | { &opcode_cb_47, 8 }, // BIT 0, A | ||
681 | { &opcode_cb_48, 8 }, // BIT 1, B | ||
682 | { &opcode_cb_49, 8 }, // BIT 1, C | ||
683 | { &opcode_cb_4a, 8 }, // BIT 1, D | ||
684 | { &opcode_cb_4b, 8 }, // BIT 1, E | ||
685 | { &opcode_cb_4c, 8 }, // BIT 1, H | ||
686 | { &opcode_cb_4d, 8 }, // BIT 1, L | ||
687 | { &opcode_cb_4e, 12 }, // BIT 1, (HL) | ||
688 | { &opcode_cb_4f, 8 }, // BIT 1, A | ||
689 | { &opcode_cb_50, 8 }, // BIT 2, B | ||
690 | { &opcode_cb_51, 8 }, // BIT 2, C | ||
691 | { &opcode_cb_52, 8 }, // BIT 2, D | ||
692 | { &opcode_cb_53, 8 }, // BIT 2, E | ||
693 | { &opcode_cb_54, 8 }, // BIT 2, H | ||
694 | { &opcode_cb_55, 8 }, // BIT 2, L | ||
695 | { &opcode_cb_56, 12 }, // BIT 2, (HL) | ||
696 | { &opcode_cb_57, 8 }, // BIT 2, A | ||
697 | { &opcode_cb_58, 8 }, // BIT 3, B | ||
698 | { &opcode_cb_59, 8 }, // BIT 3, C | ||
699 | { &opcode_cb_5a, 8 }, // BIT 3, D | ||
700 | { &opcode_cb_5b, 8 }, // BIT 3, E | ||
701 | { &opcode_cb_5c, 8 }, // BIT 3, H | ||
702 | { &opcode_cb_5d, 8 }, // BIT 3, L | ||
703 | { &opcode_cb_5e, 12 }, // BIT 3, (HL) | ||
704 | { &opcode_cb_5f, 8 }, // BIT 3, A | ||
705 | { &opcode_cb_60, 8 }, // BIT 4, B | ||
706 | { &opcode_cb_61, 8 }, // BIT 4, C | ||
707 | { &opcode_cb_62, 8 }, // BIT 4, D | ||
708 | { &opcode_cb_63, 8 }, // BIT 4, E | ||
709 | { &opcode_cb_64, 8 }, // BIT 4, H | ||
710 | { &opcode_cb_65, 8 }, // BIT 4, L | ||
711 | { &opcode_cb_66, 12 }, // BIT 4, (HL) | ||
712 | { &opcode_cb_67, 8 }, // BIT 4, A | ||
713 | { &opcode_cb_68, 8 }, // BIT 5, B | ||
714 | { &opcode_cb_69, 8 }, // BIT 5, C | ||
715 | { &opcode_cb_6a, 8 }, // BIT 5, D | ||
716 | { &opcode_cb_6b, 8 }, // BIT 5, E | ||
717 | { &opcode_cb_6c, 8 }, // BIT 5, H | ||
718 | { &opcode_cb_6d, 8 }, // BIT 5, L | ||
719 | { &opcode_cb_6e, 12 }, // BIT 5, (HL) | ||
720 | { &opcode_cb_6f, 8 }, // BIT 5, A | ||
721 | { &opcode_cb_70, 8 }, // BIT 6, B | ||
722 | { &opcode_cb_71, 8 }, // BIT 6, C | ||
723 | { &opcode_cb_72, 8 }, // BIT 6, D | ||
724 | { &opcode_cb_73, 8 }, // BIT 6, E | ||
725 | { &opcode_cb_74, 8 }, // BIT 6, H | ||
726 | { &opcode_cb_75, 8 }, // BIT 6, L | ||
727 | { &opcode_cb_76, 12 }, // BIT 6, (HL) | ||
728 | { &opcode_cb_77, 8 }, // BIT 6, A | ||
729 | { &opcode_cb_78, 8 }, // BIT 7, B | ||
730 | { &opcode_cb_79, 8 }, // BIT 7, C | ||
731 | { &opcode_cb_7a, 8 }, // BIT 7, D | ||
732 | { &opcode_cb_7b, 8 }, // BIT 7, E | ||
733 | { &opcode_cb_7c, 8 }, // BIT 7, H | ||
734 | { &opcode_cb_7d, 8 }, // BIT 7, L | ||
735 | { &opcode_cb_7e, 12 }, // BIT 7, (HL) | ||
736 | { &opcode_cb_7f, 8 }, // BIT 7, A | ||
737 | { &opcode_cb_80, 8 }, // RES 0, B | ||
738 | { &opcode_cb_81, 8 }, // RES 0, C | ||
739 | { &opcode_cb_82, 8 }, // RES 0, D | ||
740 | { &opcode_cb_83, 8 }, // RES 0, E | ||
741 | { &opcode_cb_84, 8 }, // RES 0, H | ||
742 | { &opcode_cb_85, 8 }, // RES 0, L | ||
743 | { &opcode_cb_86, 15 }, // RES 0, (HL) | ||
744 | { &opcode_cb_87, 8 }, // RES 0, A | ||
745 | { &opcode_cb_88, 8 }, // RES 1, B | ||
746 | { &opcode_cb_89, 8 }, // RES 1, C | ||
747 | { &opcode_cb_8a, 8 }, // RES 1, D | ||
748 | { &opcode_cb_8b, 8 }, // RES 1, E | ||
749 | { &opcode_cb_8c, 8 }, // RES 1, H | ||
750 | { &opcode_cb_8d, 8 }, // RES 1, L | ||
751 | { &opcode_cb_8e, 15 }, // RES 1, (HL) | ||
752 | { &opcode_cb_8f, 8 }, // RES 1, A | ||
753 | { &opcode_cb_90, 8 }, // RES 2, B | ||
754 | { &opcode_cb_91, 8 }, // RES 2, C | ||
755 | { &opcode_cb_92, 8 }, // RES 2, D | ||
756 | { &opcode_cb_93, 8 }, // RES 2, E | ||
757 | { &opcode_cb_94, 8 }, // RES 2, H | ||
758 | { &opcode_cb_95, 8 }, // RES 2, L | ||
759 | { &opcode_cb_96, 15 }, // RES 2, (HL) | ||
760 | { &opcode_cb_97, 8 }, // RES 2, A | ||
761 | { &opcode_cb_98, 8 }, // RES 3, B | ||
762 | { &opcode_cb_99, 8 }, // RES 3, C | ||
763 | { &opcode_cb_9a, 8 }, // RES 3, D | ||
764 | { &opcode_cb_9b, 8 }, // RES 3, E | ||
765 | { &opcode_cb_9c, 8 }, // RES 3, H | ||
766 | { &opcode_cb_9d, 8 }, // RES 3, L | ||
767 | { &opcode_cb_9e, 15 }, // RES 3, (HL) | ||
768 | { &opcode_cb_9f, 8 }, // RES 3, A | ||
769 | { &opcode_cb_a0, 8 }, // RES 4, B | ||
770 | { &opcode_cb_a1, 8 }, // RES 4, C | ||
771 | { &opcode_cb_a2, 8 }, // RES 4, D | ||
772 | { &opcode_cb_a3, 8 }, // RES 4, E | ||
773 | { &opcode_cb_a4, 8 }, // RES 4, H | ||
774 | { &opcode_cb_a5, 8 }, // RES 4, L | ||
775 | { &opcode_cb_a6, 15 }, // RES 4, (HL) | ||
776 | { &opcode_cb_a7, 8 }, // RES 4, A | ||
777 | { &opcode_cb_a8, 8 }, // RES 5, B | ||
778 | { &opcode_cb_a9, 8 }, // RES 5, C | ||
779 | { &opcode_cb_aa, 8 }, // RES 5, D | ||
780 | { &opcode_cb_ab, 8 }, // RES 5, E | ||
781 | { &opcode_cb_ac, 8 }, // RES 5, H | ||
782 | { &opcode_cb_ad, 8 }, // RES 5, L | ||
783 | { &opcode_cb_ae, 15 }, // RES 5, (HL) | ||
784 | { &opcode_cb_af, 8 }, // RES 5, A | ||
785 | { &opcode_cb_b0, 8 }, // RES 6, B | ||
786 | { &opcode_cb_b1, 8 }, // RES 6, C | ||
787 | { &opcode_cb_b2, 8 }, // RES 6, D | ||
788 | { &opcode_cb_b3, 8 }, // RES 6, E | ||
789 | { &opcode_cb_b4, 8 }, // RES 6, H | ||
790 | { &opcode_cb_b5, 8 }, // RES 6, L | ||
791 | { &opcode_cb_b6, 15 }, // RES 6, (HL) | ||
792 | { &opcode_cb_b7, 8 }, // RES 6, A | ||
793 | { &opcode_cb_b8, 8 }, // RES 7, B | ||
794 | { &opcode_cb_b9, 8 }, // RES 7, C | ||
795 | { &opcode_cb_ba, 8 }, // RES 7, D | ||
796 | { &opcode_cb_bb, 8 }, // RES 7, E | ||
797 | { &opcode_cb_bc, 8 }, // RES 7, H | ||
798 | { &opcode_cb_bd, 8 }, // RES 7, L | ||
799 | { &opcode_cb_be, 15 }, // RES 7, (HL) | ||
800 | { &opcode_cb_bf, 8 }, // RES 7, A | ||
801 | { &opcode_cb_c0, 8 }, // SET 0, B | ||
802 | { &opcode_cb_c1, 8 }, // SET 0, C | ||
803 | { &opcode_cb_c2, 8 }, // SET 0, D | ||
804 | { &opcode_cb_c3, 8 }, // SET 0, E | ||
805 | { &opcode_cb_c4, 8 }, // SET 0, H | ||
806 | { &opcode_cb_c5, 8 }, // SET 0, L | ||
807 | { &opcode_cb_c6, 15 }, // SET 0, (HL) | ||
808 | { &opcode_cb_c7, 8 }, // SET 0, A | ||
809 | { &opcode_cb_c8, 8 }, // SET 1, B | ||
810 | { &opcode_cb_c9, 8 }, // SET 1, C | ||
811 | { &opcode_cb_ca, 8 }, // SET 1, D | ||
812 | { &opcode_cb_cb, 8 }, // SET 1, E | ||
813 | { &opcode_cb_cc, 8 }, // SET 1, H | ||
814 | { &opcode_cb_cd, 8 }, // SET 1, L | ||
815 | { &opcode_cb_ce, 15 }, // SET 1, (HL) | ||
816 | { &opcode_cb_cf, 8 }, // SET 1, A | ||
817 | { &opcode_cb_d0, 8 }, // SET 2, B | ||
818 | { &opcode_cb_d1, 8 }, // SET 2, C | ||
819 | { &opcode_cb_d2, 8 }, // SET 2, D | ||
820 | { &opcode_cb_d3, 8 }, // SET 2, E | ||
821 | { &opcode_cb_d4, 8 }, // SET 2, H | ||
822 | { &opcode_cb_d5, 8 }, // SET 2, L | ||
823 | { &opcode_cb_d6, 15 }, // SET 2, (HL) | ||
824 | { &opcode_cb_d7, 8 }, // SET 2, A | ||
825 | { &opcode_cb_d8, 8 }, // SET 3, B | ||
826 | { &opcode_cb_d9, 8 }, // SET 3, C | ||
827 | { &opcode_cb_da, 8 }, // SET 3, D | ||
828 | { &opcode_cb_db, 8 }, // SET 3, E | ||
829 | { &opcode_cb_dc, 8 }, // SET 3, H | ||
830 | { &opcode_cb_dd, 8 }, // SET 3, L | ||
831 | { &opcode_cb_de, 15 }, // SET 3, (HL) | ||
832 | { &opcode_cb_df, 8 }, // SET 3, A | ||
833 | { &opcode_cb_e0, 8 }, // SET 4, B | ||
834 | { &opcode_cb_e1, 8 }, // SET 4, C | ||
835 | { &opcode_cb_e2, 8 }, // SET 4, D | ||
836 | { &opcode_cb_e3, 8 }, // SET 4, E | ||
837 | { &opcode_cb_e4, 8 }, // SET 4, H | ||
838 | { &opcode_cb_e5, 8 }, // SET 4, L | ||
839 | { &opcode_cb_e6, 15 }, // SET 4, (HL) | ||
840 | { &opcode_cb_e7, 8 }, // SET 4, A | ||
841 | { &opcode_cb_e8, 8 }, // SET 5, B | ||
842 | { &opcode_cb_e9, 8 }, // SET 5, C | ||
843 | { &opcode_cb_ea, 8 }, // SET 5, D | ||
844 | { &opcode_cb_eb, 8 }, // SET 5, E | ||
845 | { &opcode_cb_ec, 8 }, // SET 5, H | ||
846 | { &opcode_cb_ed, 8 }, // SET 5, L | ||
847 | { &opcode_cb_ee, 15 }, // SET 5, (HL) | ||
848 | { &opcode_cb_ef, 8 }, // SET 5, A | ||
849 | { &opcode_cb_f0, 8 }, // SET 6, B | ||
850 | { &opcode_cb_f1, 8 }, // SET 6, C | ||
851 | { &opcode_cb_f2, 8 }, // SET 6, D | ||
852 | { &opcode_cb_f3, 8 }, // SET 6, E | ||
853 | { &opcode_cb_f4, 8 }, // SET 6, H | ||
854 | { &opcode_cb_f5, 8 }, // SET 6, L | ||
855 | { &opcode_cb_f6, 15 }, // SET 6, (HL) | ||
856 | { &opcode_cb_f7, 8 }, // SET 6, A | ||
857 | { &opcode_cb_f8, 8 }, // SET 7, B | ||
858 | { &opcode_cb_f9, 8 }, // SET 7, C | ||
859 | { &opcode_cb_fa, 8 }, // SET 7, D | ||
860 | { &opcode_cb_fb, 8 }, // SET 7, E | ||
861 | { &opcode_cb_fc, 8 }, // SET 7, H | ||
862 | { &opcode_cb_fd, 8 }, // SET 7, L | ||
863 | { &opcode_cb_fe, 15 }, // SET 7, (HL) | ||
864 | { &opcode_cb_ff, 8 } // SET 7, A | ||
865 | }; | ||
866 | |||
867 | void opcode_cb_00() // RLC B | ||
868 | { | ||
869 | B = rotateLeftCarry( B ); | ||
870 | } | ||
871 | |||
872 | void opcode_cb_01() // RLC C | ||
873 | { | ||
874 | C = rotateLeftCarry( C ); | ||
875 | } | ||
876 | |||
877 | void opcode_cb_02() // RLC D | ||
878 | { | ||
879 | D = rotateLeftCarry( D ); | ||
880 | } | ||
881 | |||
882 | void opcode_cb_03() // RLC E | ||
883 | { | ||
884 | E = rotateLeftCarry( E ); | ||
885 | } | ||
886 | |||
887 | void opcode_cb_04() // RLC H | ||
888 | { | ||
889 | H = rotateLeftCarry( H ); | ||
890 | } | ||
891 | |||
892 | void opcode_cb_05() // RLC L | ||
893 | { | ||
894 | L = rotateLeftCarry( L ); | ||
895 | } | ||
896 | |||
897 | void opcode_cb_06() // RLC (HL) | ||
898 | { | ||
899 | writeByte( HL(), rotateLeftCarry( readByte( HL() ) ) ); | ||
900 | } | ||
901 | |||
902 | void opcode_cb_07() // RLC A | ||
903 | { | ||
904 | A = rotateLeftCarry( A ); | ||
905 | } | ||
906 | |||
907 | void opcode_cb_08() // RRC B | ||
908 | { | ||
909 | B = rotateRightCarry( B ); | ||
910 | } | ||
911 | |||
912 | void opcode_cb_09() // RRC C | ||
913 | { | ||
914 | C = rotateLeftCarry( C ); | ||
915 | } | ||
916 | |||
917 | void opcode_cb_0a() // RRC D | ||
918 | { | ||
919 | D = rotateLeftCarry( D ); | ||
920 | } | ||
921 | |||
922 | void opcode_cb_0b() // RRC E | ||
923 | { | ||
924 | E = rotateLeftCarry( E ); | ||
925 | } | ||
926 | |||
927 | void opcode_cb_0c() // RRC H | ||
928 | { | ||
929 | H = rotateLeftCarry( H ); | ||
930 | } | ||
931 | |||
932 | void opcode_cb_0d() // RRC L | ||
933 | { | ||
934 | L = rotateLeftCarry( L ); | ||
935 | } | ||
936 | |||
937 | void opcode_cb_0e() // RRC (HL) | ||
938 | { | ||
939 | writeByte( HL(), rotateRightCarry( readByte( HL() ) ) ); | ||
940 | } | ||
941 | |||
942 | void opcode_cb_0f() // RRC A | ||
943 | { | ||
944 | A = rotateLeftCarry( A ); | ||
945 | } | ||
946 | |||
947 | void opcode_cb_10() // RL B | ||
948 | { | ||
949 | B = rotateLeft( B ); | ||
950 | } | ||
951 | |||
952 | void opcode_cb_11() // RL C | ||
953 | { | ||
954 | C = rotateLeft( C ); | ||
955 | } | ||
956 | |||
957 | void opcode_cb_12() // RL D | ||
958 | { | ||
959 | D = rotateLeft( D ); | ||
960 | } | ||
961 | |||
962 | void opcode_cb_13() // RL E | ||
963 | { | ||
964 | E = rotateLeft( E ); | ||
965 | } | ||
966 | |||
967 | void opcode_cb_14() // RL H | ||
968 | { | ||
969 | H = rotateLeft( H ); | ||
970 | } | ||
971 | |||
972 | void opcode_cb_15() // RL L | ||
973 | { | ||
974 | L = rotateLeft( L ); | ||
975 | } | ||
976 | |||
977 | void opcode_cb_16() // RL (HL) | ||
978 | { | ||
979 | writeByte( HL(), rotateLeft( readByte( HL() ) ) ); | ||
980 | } | ||
981 | |||
982 | void opcode_cb_17() // RL A | ||
983 | { | ||
984 | A = rotateLeft( A ); | ||
985 | } | ||
986 | |||
987 | void opcode_cb_18() // RR B | ||
988 | { | ||
989 | B = rotateRight( B ); | ||
990 | } | ||
991 | |||
992 | void opcode_cb_19() // RR C | ||
993 | { | ||
994 | C = rotateRight( C ); | ||
995 | } | ||
996 | |||
997 | void opcode_cb_1a() // RR D | ||
998 | { | ||
999 | D = rotateRight( D ); | ||
1000 | } | ||
1001 | |||
1002 | void opcode_cb_1b() // RR E | ||
1003 | { | ||
1004 | E = rotateRight( E ); | ||
1005 | } | ||
1006 | |||
1007 | void opcode_cb_1c() // RR H | ||
1008 | { | ||
1009 | H = rotateRight( H ); | ||
1010 | } | ||
1011 | |||
1012 | void opcode_cb_1d() // RR L | ||
1013 | { | ||
1014 | L = rotateRight( L ); | ||
1015 | } | ||
1016 | |||
1017 | void opcode_cb_1e() // RR (HL) | ||
1018 | { | ||
1019 | writeByte( HL(), rotateRight( readByte( HL() ) ) ); | ||
1020 | } | ||
1021 | |||
1022 | void opcode_cb_1f() // RR A | ||
1023 | { | ||
1024 | A = rotateRight( A ); | ||
1025 | } | ||
1026 | |||
1027 | void opcode_cb_20() // SLA B | ||
1028 | { | ||
1029 | B = shiftLeft( B ); | ||
1030 | } | ||
1031 | |||
1032 | void opcode_cb_21() // SLA C | ||
1033 | { | ||
1034 | C = shiftLeft( C ); | ||
1035 | } | ||
1036 | |||
1037 | void opcode_cb_22() // SLA D | ||
1038 | { | ||
1039 | D = shiftLeft( D ); | ||
1040 | } | ||
1041 | |||
1042 | void opcode_cb_23() // SLA E | ||
1043 | { | ||
1044 | E = shiftLeft( E ); | ||
1045 | } | ||
1046 | |||
1047 | void opcode_cb_24() // SLA H | ||
1048 | { | ||
1049 | H = shiftLeft( H ); | ||
1050 | } | ||
1051 | |||
1052 | void opcode_cb_25() // SLA L | ||
1053 | { | ||
1054 | L = shiftLeft( L ); | ||
1055 | } | ||
1056 | |||
1057 | void opcode_cb_26() // SLA (HL) | ||
1058 | { | ||
1059 | writeByte( HL(), shiftLeft( readByte( HL() ) ) ); | ||
1060 | } | ||
1061 | |||
1062 | void opcode_cb_27() // SLA A | ||
1063 | { | ||
1064 | A = shiftLeft( A ); | ||
1065 | } | ||
1066 | |||
1067 | void opcode_cb_28() // SRA B | ||
1068 | { | ||
1069 | B = shiftRightArith( B ); | ||
1070 | } | ||
1071 | |||
1072 | void opcode_cb_29() // SRA C | ||
1073 | { | ||
1074 | C = shiftRightArith( C ); | ||
1075 | } | ||
1076 | |||
1077 | void opcode_cb_2a() // SRA D | ||
1078 | { | ||
1079 | D = shiftRightArith( D ); | ||
1080 | } | ||
1081 | |||
1082 | void opcode_cb_2b() // SRA E | ||
1083 | { | ||
1084 | E = shiftRightArith( E ); | ||
1085 | } | ||
1086 | |||
1087 | void opcode_cb_2c() // SRA H | ||
1088 | { | ||
1089 | H = shiftRightArith( H ); | ||
1090 | } | ||
1091 | |||
1092 | void opcode_cb_2d() // SRA L | ||
1093 | { | ||
1094 | L = shiftRightArith( L ); | ||
1095 | } | ||
1096 | |||
1097 | void opcode_cb_2e() // SRA (HL) | ||
1098 | { | ||
1099 | writeByte( HL(), shiftRightArith( readByte( HL() ) ) ); | ||
1100 | } | ||
1101 | |||
1102 | void opcode_cb_2f() // SRA A | ||
1103 | { | ||
1104 | A = shiftRightArith( A ); | ||
1105 | } | ||
1106 | |||
1107 | void opcode_cb_30() // SLL B | ||
1108 | { | ||
1109 | B = shiftLeft( B ) | 0x01; | ||
1110 | } | ||
1111 | |||
1112 | void opcode_cb_31() // SLL C | ||
1113 | { | ||
1114 | C = shiftLeft( C ) | 0x01; | ||
1115 | } | ||
1116 | |||
1117 | void opcode_cb_32() // SLL D | ||
1118 | { | ||
1119 | D = shiftLeft( D ) | 0x01; | ||
1120 | } | ||
1121 | |||
1122 | void opcode_cb_33() // SLL E | ||
1123 | { | ||
1124 | E = shiftLeft( E ) | 0x01; | ||
1125 | } | ||
1126 | |||
1127 | void opcode_cb_34() // SLL H | ||
1128 | { | ||
1129 | H = shiftLeft( H ) | 0x01; | ||
1130 | } | ||
1131 | |||
1132 | void opcode_cb_35() // SLL L | ||
1133 | { | ||
1134 | L = shiftLeft( L ) | 0x01; | ||
1135 | } | ||
1136 | |||
1137 | void opcode_cb_36() // SLL (HL) | ||
1138 | { | ||
1139 | writeByte( HL(), shiftLeft( readByte( HL() ) ) | 0x01 ); | ||
1140 | } | ||
1141 | |||
1142 | void opcode_cb_37() // SLL A | ||
1143 | { | ||
1144 | A = shiftLeft( A ) | 0x01; | ||
1145 | } | ||
1146 | |||
1147 | void opcode_cb_38() // SRL B | ||
1148 | { | ||
1149 | B = shiftRightLogical( B ); | ||
1150 | } | ||
1151 | |||
1152 | void opcode_cb_39() // SRL C | ||
1153 | { | ||
1154 | C = shiftRightLogical( C ); | ||
1155 | } | ||
1156 | |||
1157 | void opcode_cb_3a() // SRL D | ||
1158 | { | ||
1159 | D = shiftRightLogical( D ); | ||
1160 | } | ||
1161 | |||
1162 | void opcode_cb_3b() // SRL E | ||
1163 | { | ||
1164 | E = shiftRightLogical( E ); | ||
1165 | } | ||
1166 | |||
1167 | void opcode_cb_3c() // SRL H | ||
1168 | { | ||
1169 | H = shiftRightLogical( H ); | ||
1170 | } | ||
1171 | |||
1172 | void opcode_cb_3d() // SRL L | ||
1173 | { | ||
1174 | L = shiftRightLogical( L ); | ||
1175 | } | ||
1176 | |||
1177 | void opcode_cb_3e() // SRL (HL) | ||
1178 | { | ||
1179 | writeByte( HL(), shiftRightLogical( readByte( HL() ) ) ); | ||
1180 | } | ||
1181 | |||
1182 | void opcode_cb_3f() // SRL A | ||
1183 | { | ||
1184 | A = shiftRightLogical( A ); | ||
1185 | } | ||
1186 | |||
1187 | void opcode_cb_40() // BIT 0, B | ||
1188 | { | ||
1189 | testBit( 0, B ); | ||
1190 | } | ||
1191 | |||
1192 | void opcode_cb_41() // BIT 0, C | ||
1193 | { | ||
1194 | testBit( 0, C ); | ||
1195 | } | ||
1196 | |||
1197 | void opcode_cb_42() // BIT 0, D | ||
1198 | { | ||
1199 | testBit( 0, D ); | ||
1200 | } | ||
1201 | |||
1202 | void opcode_cb_43() // BIT 0, E | ||
1203 | { | ||
1204 | testBit( 0, E ); | ||
1205 | } | ||
1206 | |||
1207 | void opcode_cb_44() // BIT 0, H | ||
1208 | { | ||
1209 | testBit( 0, H ); | ||
1210 | } | ||
1211 | |||
1212 | void opcode_cb_45() // BIT 0, L | ||
1213 | { | ||
1214 | testBit( 0, L ); | ||
1215 | } | ||
1216 | |||
1217 | void opcode_cb_46() // BIT 0, (HL) | ||
1218 | { | ||
1219 | testBit( 0, readByte( HL() ) ); | ||
1220 | } | ||
1221 | |||
1222 | void opcode_cb_47() // BIT 0, A | ||
1223 | { | ||
1224 | testBit( 0, A ); | ||
1225 | } | ||
1226 | |||
1227 | void opcode_cb_48() // BIT 1, B | ||
1228 | { | ||
1229 | testBit( 1, B ); | ||
1230 | } | ||
1231 | |||
1232 | void opcode_cb_49() // BIT 1, C | ||
1233 | { | ||
1234 | testBit( 1, C ); | ||
1235 | } | ||
1236 | |||
1237 | void opcode_cb_4a() // BIT 1, D | ||
1238 | { | ||
1239 | testBit( 1, D ); | ||
1240 | } | ||
1241 | |||
1242 | void opcode_cb_4b() // BIT 1, E | ||
1243 | { | ||
1244 | testBit( 1, E ); | ||
1245 | } | ||
1246 | |||
1247 | void opcode_cb_4c() // BIT 1, H | ||
1248 | { | ||
1249 | testBit( 1, H ); | ||
1250 | } | ||
1251 | |||
1252 | void opcode_cb_4d() // BIT 1, L | ||
1253 | { | ||
1254 | testBit( 1, L ); | ||
1255 | } | ||
1256 | |||
1257 | void opcode_cb_4e() // BIT 1, (HL) | ||
1258 | { | ||
1259 | testBit( 1, readByte( HL() ) ); | ||
1260 | } | ||
1261 | |||
1262 | void opcode_cb_4f() // BIT 1, A | ||
1263 | { | ||
1264 | testBit( 1, A ); | ||
1265 | } | ||
1266 | |||
1267 | void opcode_cb_50() // BIT 2, B | ||
1268 | { | ||
1269 | testBit( 2, B ); | ||
1270 | } | ||
1271 | |||
1272 | void opcode_cb_51() // BIT 2, C | ||
1273 | { | ||
1274 | testBit( 2, C ); | ||
1275 | } | ||
1276 | |||
1277 | void opcode_cb_52() // BIT 2, D | ||
1278 | { | ||
1279 | testBit( 2, D ); | ||
1280 | } | ||
1281 | |||
1282 | void opcode_cb_53() // BIT 2, E | ||
1283 | { | ||
1284 | testBit( 2, E ); | ||
1285 | } | ||
1286 | |||
1287 | void opcode_cb_54() // BIT 2, H | ||
1288 | { | ||
1289 | testBit( 2, H ); | ||
1290 | } | ||
1291 | |||
1292 | void opcode_cb_55() // BIT 2, L | ||
1293 | { | ||
1294 | testBit( 2, L ); | ||
1295 | } | ||
1296 | |||
1297 | void opcode_cb_56() // BIT 2, (HL) | ||
1298 | { | ||
1299 | testBit( 2, readByte( HL() ) ); | ||
1300 | } | ||
1301 | |||
1302 | void opcode_cb_57() // BIT 2, A | ||
1303 | { | ||
1304 | testBit( 2, A ); | ||
1305 | } | ||
1306 | |||
1307 | void opcode_cb_58() // BIT 3, B | ||
1308 | { | ||
1309 | testBit( 3, B ); | ||
1310 | } | ||
1311 | |||
1312 | void opcode_cb_59() // BIT 3, C | ||
1313 | { | ||
1314 | testBit( 3, C ); | ||
1315 | } | ||
1316 | |||
1317 | void opcode_cb_5a() // BIT 3, D | ||
1318 | { | ||
1319 | testBit( 3, D ); | ||
1320 | } | ||
1321 | |||
1322 | void opcode_cb_5b() // BIT 3, E | ||
1323 | { | ||
1324 | testBit( 3, E ); | ||
1325 | } | ||
1326 | |||
1327 | void opcode_cb_5c() // BIT 3, H | ||
1328 | { | ||
1329 | testBit( 3, H ); | ||
1330 | } | ||
1331 | |||
1332 | void opcode_cb_5d() // BIT 3, L | ||
1333 | { | ||
1334 | testBit( 3, L ); | ||
1335 | } | ||
1336 | |||
1337 | void opcode_cb_5e() // BIT 3, (HL) | ||
1338 | { | ||
1339 | testBit( 3, readByte( HL() ) ); | ||
1340 | } | ||
1341 | |||
1342 | void opcode_cb_5f() // BIT 3, A | ||
1343 | { | ||
1344 | testBit( 3, A ); | ||
1345 | } | ||
1346 | |||
1347 | void opcode_cb_60() // BIT 4, B | ||
1348 | { | ||
1349 | testBit( 4, B ); | ||
1350 | } | ||
1351 | |||
1352 | void opcode_cb_61() // BIT 4, C | ||
1353 | { | ||
1354 | testBit( 4, C ); | ||
1355 | } | ||
1356 | |||
1357 | void opcode_cb_62() // BIT 4, D | ||
1358 | { | ||
1359 | testBit( 4, D ); | ||
1360 | } | ||
1361 | |||
1362 | void opcode_cb_63() // BIT 4, E | ||
1363 | { | ||
1364 | testBit( 4, E ); | ||
1365 | } | ||
1366 | |||
1367 | void opcode_cb_64() // BIT 4, H | ||
1368 | { | ||
1369 | testBit( 4, H ); | ||
1370 | } | ||
1371 | |||
1372 | void opcode_cb_65() // BIT 4, L | ||
1373 | { | ||
1374 | testBit( 4, L ); | ||
1375 | } | ||
1376 | |||
1377 | void opcode_cb_66() // BIT 4, (HL) | ||
1378 | { | ||
1379 | testBit( 4, readByte( HL() ) ); | ||
1380 | } | ||
1381 | |||
1382 | void opcode_cb_67() // BIT 4, A | ||
1383 | { | ||
1384 | testBit( 4, A ); | ||
1385 | } | ||
1386 | |||
1387 | void opcode_cb_68() // BIT 5, B | ||
1388 | { | ||
1389 | testBit( 5, B ); | ||
1390 | } | ||
1391 | |||
1392 | void opcode_cb_69() // BIT 5, C | ||
1393 | { | ||
1394 | testBit( 5, C ); | ||
1395 | } | ||
1396 | |||
1397 | void opcode_cb_6a() // BIT 5, D | ||
1398 | { | ||
1399 | testBit( 5, D ); | ||
1400 | } | ||
1401 | |||
1402 | void opcode_cb_6b() // BIT 5, E | ||
1403 | { | ||
1404 | testBit( 5, E ); | ||
1405 | } | ||
1406 | |||
1407 | void opcode_cb_6c() // BIT 5, H | ||
1408 | { | ||
1409 | testBit( 5, H ); | ||
1410 | } | ||
1411 | |||
1412 | void opcode_cb_6d() // BIT 5, L | ||
1413 | { | ||
1414 | testBit( 5, L ); | ||
1415 | } | ||
1416 | |||
1417 | void opcode_cb_6e() // BIT 5, (HL) | ||
1418 | { | ||
1419 | testBit( 5, readByte( HL() ) ); | ||
1420 | } | ||
1421 | |||
1422 | void opcode_cb_6f() // BIT 5, A | ||
1423 | { | ||
1424 | testBit( 5, A ); | ||
1425 | } | ||
1426 | |||
1427 | void opcode_cb_70() // BIT 6, B | ||
1428 | { | ||
1429 | testBit( 6, B ); | ||
1430 | } | ||
1431 | |||
1432 | void opcode_cb_71() // BIT 6, C | ||
1433 | { | ||
1434 | testBit( 6, C ); | ||
1435 | } | ||
1436 | |||
1437 | void opcode_cb_72() // BIT 6, D | ||
1438 | { | ||
1439 | testBit( 6, D ); | ||
1440 | } | ||
1441 | |||
1442 | void opcode_cb_73() // BIT 6, E | ||
1443 | { | ||
1444 | testBit( 6, E ); | ||
1445 | } | ||
1446 | |||
1447 | void opcode_cb_74() // BIT 6, H | ||
1448 | { | ||
1449 | testBit( 6, H ); | ||
1450 | } | ||
1451 | |||
1452 | void opcode_cb_75() // BIT 6, L | ||
1453 | { | ||
1454 | testBit( 6, L ); | ||
1455 | } | ||
1456 | |||
1457 | void opcode_cb_76() // BIT 6, (HL) | ||
1458 | { | ||
1459 | testBit( 6, readByte( HL() ) ); | ||
1460 | } | ||
1461 | |||
1462 | void opcode_cb_77() // BIT 6, A | ||
1463 | { | ||
1464 | testBit( 6, A ); | ||
1465 | } | ||
1466 | |||
1467 | void opcode_cb_78() // BIT 7, B | ||
1468 | { | ||
1469 | testBit( 7, B ); | ||
1470 | } | ||
1471 | |||
1472 | void opcode_cb_79() // BIT 7, C | ||
1473 | { | ||
1474 | testBit( 7, C ); | ||
1475 | } | ||
1476 | |||
1477 | void opcode_cb_7a() // BIT 7, D | ||
1478 | { | ||
1479 | testBit( 7, D ); | ||
1480 | } | ||
1481 | |||
1482 | void opcode_cb_7b() // BIT 7, E | ||
1483 | { | ||
1484 | testBit( 7, E ); | ||
1485 | } | ||
1486 | |||
1487 | void opcode_cb_7c() // BIT 7, H | ||
1488 | { | ||
1489 | testBit( 7, H ); | ||
1490 | } | ||
1491 | |||
1492 | void opcode_cb_7d() // BIT 7, L | ||
1493 | { | ||
1494 | testBit( 7, L ); | ||
1495 | } | ||
1496 | |||
1497 | void opcode_cb_7e() // BIT 7, (HL) | ||
1498 | { | ||
1499 | testBit( 7, readByte( HL() ) ); | ||
1500 | } | ||
1501 | |||
1502 | void opcode_cb_7f() // BIT 7, A | ||
1503 | { | ||
1504 | testBit( 7, A ); | ||
1505 | } | ||
1506 | |||
1507 | void opcode_cb_80() // RES 0, B | ||
1508 | { | ||
1509 | B &= ~(unsigned char) (1 << 0); | ||
1510 | } | ||
1511 | |||
1512 | void opcode_cb_81() // RES 0, C | ||
1513 | { | ||
1514 | C &= ~(unsigned char) (1 << 0); | ||
1515 | } | ||
1516 | |||
1517 | void opcode_cb_82() // RES 0, D | ||
1518 | { | ||
1519 | D &= ~(unsigned char) (1 << 0); | ||
1520 | } | ||
1521 | |||
1522 | void opcode_cb_83() // RES 0, E | ||
1523 | { | ||
1524 | E &= ~(unsigned char) (1 << 0); | ||
1525 | } | ||
1526 | |||
1527 | void opcode_cb_84() // RES 0, H | ||
1528 | { | ||
1529 | H &= ~(unsigned char) (1 << 0); | ||
1530 | } | ||
1531 | |||
1532 | void opcode_cb_85() // RES 0, L | ||
1533 | { | ||
1534 | L &= ~(unsigned char) (1 << 0); | ||
1535 | } | ||
1536 | |||
1537 | void opcode_cb_86() // RES 0, (HL) | ||
1538 | { | ||
1539 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 0) ); | ||
1540 | } | ||
1541 | |||
1542 | void opcode_cb_87() // RES 0, A | ||
1543 | { | ||
1544 | A &= ~(unsigned char) (1 << 0); | ||
1545 | } | ||
1546 | |||
1547 | void opcode_cb_88() // RES 1, B | ||
1548 | { | ||
1549 | B &= ~(unsigned char) (1 << 1); | ||
1550 | } | ||
1551 | |||
1552 | void opcode_cb_89() // RES 1, C | ||
1553 | { | ||
1554 | C &= ~(unsigned char) (1 << 1); | ||
1555 | } | ||
1556 | |||
1557 | void opcode_cb_8a() // RES 1, D | ||
1558 | { | ||
1559 | D &= ~(unsigned char) (1 << 1); | ||
1560 | } | ||
1561 | |||
1562 | void opcode_cb_8b() // RES 1, E | ||
1563 | { | ||
1564 | E &= ~(unsigned char) (1 << 1); | ||
1565 | } | ||
1566 | |||
1567 | void opcode_cb_8c() // RES 1, H | ||
1568 | { | ||
1569 | H &= ~(unsigned char) (1 << 1); | ||
1570 | } | ||
1571 | |||
1572 | void opcode_cb_8d() // RES 1, L | ||
1573 | { | ||
1574 | L &= ~(unsigned char) (1 << 1); | ||
1575 | } | ||
1576 | |||
1577 | void opcode_cb_8e() // RES 1, (HL) | ||
1578 | { | ||
1579 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 1) ); | ||
1580 | } | ||
1581 | |||
1582 | void opcode_cb_8f() // RES 1, A | ||
1583 | { | ||
1584 | A &= ~(unsigned char) (1 << 1); | ||
1585 | } | ||
1586 | |||
1587 | void opcode_cb_90() // RES 2, B | ||
1588 | { | ||
1589 | B &= ~(unsigned char) (1 << 2); | ||
1590 | } | ||
1591 | |||
1592 | void opcode_cb_91() // RES 2, C | ||
1593 | { | ||
1594 | C &= ~(unsigned char) (1 << 2); | ||
1595 | } | ||
1596 | |||
1597 | void opcode_cb_92() // RES 2, D | ||
1598 | { | ||
1599 | D &= ~(unsigned char) (1 << 2); | ||
1600 | } | ||
1601 | |||
1602 | void opcode_cb_93() // RES 2, E | ||
1603 | { | ||
1604 | E &= ~(unsigned char) (1 << 2); | ||
1605 | } | ||
1606 | |||
1607 | void opcode_cb_94() // RES 2, H | ||
1608 | { | ||
1609 | H &= ~(unsigned char) (1 << 2); | ||
1610 | } | ||
1611 | |||
1612 | void opcode_cb_95() // RES 2, L | ||
1613 | { | ||
1614 | L &= ~(unsigned char) (1 << 2); | ||
1615 | } | ||
1616 | |||
1617 | void opcode_cb_96() // RES 2, (HL) | ||
1618 | { | ||
1619 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 2) ); | ||
1620 | } | ||
1621 | |||
1622 | void opcode_cb_97() // RES 2, A | ||
1623 | { | ||
1624 | A &= ~(unsigned char) (1 << 2); | ||
1625 | } | ||
1626 | |||
1627 | void opcode_cb_98() // RES 3, B | ||
1628 | { | ||
1629 | B &= ~(unsigned char) (1 << 3); | ||
1630 | } | ||
1631 | |||
1632 | void opcode_cb_99() // RES 3, C | ||
1633 | { | ||
1634 | C &= ~(unsigned char) (1 << 3); | ||
1635 | } | ||
1636 | |||
1637 | void opcode_cb_9a() // RES 3, D | ||
1638 | { | ||
1639 | D &= ~(unsigned char) (1 << 3); | ||
1640 | } | ||
1641 | |||
1642 | void opcode_cb_9b() // RES 3, E | ||
1643 | { | ||
1644 | E &= ~(unsigned char) (1 << 3); | ||
1645 | } | ||
1646 | |||
1647 | void opcode_cb_9c() // RES 3, H | ||
1648 | { | ||
1649 | H &= ~(unsigned char) (1 << 3); | ||
1650 | } | ||
1651 | |||
1652 | void opcode_cb_9d() // RES 3, L | ||
1653 | { | ||
1654 | L &= ~(unsigned char) (1 << 3); | ||
1655 | } | ||
1656 | |||
1657 | void opcode_cb_9e() // RES 3, (HL) | ||
1658 | { | ||
1659 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 3) ); | ||
1660 | } | ||
1661 | |||
1662 | void opcode_cb_9f() // RES 3, A | ||
1663 | { | ||
1664 | A &= ~(unsigned char) (1 << 3); | ||
1665 | } | ||
1666 | |||
1667 | void opcode_cb_a0() // RES 4, B | ||
1668 | { | ||
1669 | B &= ~(unsigned char) (1 << 4); | ||
1670 | } | ||
1671 | |||
1672 | void opcode_cb_a1() // RES 4, C | ||
1673 | { | ||
1674 | C &= ~(unsigned char) (1 << 4); | ||
1675 | } | ||
1676 | |||
1677 | void opcode_cb_a2() // RES 4, D | ||
1678 | { | ||
1679 | D &= ~(unsigned char) (1 << 4); | ||
1680 | } | ||
1681 | |||
1682 | void opcode_cb_a3() // RES 4, E | ||
1683 | { | ||
1684 | E &= ~(unsigned char) (1 << 4); | ||
1685 | } | ||
1686 | |||
1687 | void opcode_cb_a4() // RES 4, H | ||
1688 | { | ||
1689 | H &= ~(unsigned char) (1 << 4); | ||
1690 | } | ||
1691 | |||
1692 | void opcode_cb_a5() // RES 4, L | ||
1693 | { | ||
1694 | L &= ~(unsigned char) (1 << 4); | ||
1695 | } | ||
1696 | |||
1697 | void opcode_cb_a6() // RES 4, (HL) | ||
1698 | { | ||
1699 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 4) ); | ||
1700 | } | ||
1701 | |||
1702 | void opcode_cb_a7() // RES 4, A | ||
1703 | { | ||
1704 | A &= ~(unsigned char) (1 << 4); | ||
1705 | } | ||
1706 | |||
1707 | void opcode_cb_a8() // RES 5, B | ||
1708 | { | ||
1709 | B &= ~(unsigned char) (1 << 5); | ||
1710 | } | ||
1711 | |||
1712 | void opcode_cb_a9() // RES 5, C | ||
1713 | { | ||
1714 | C &= ~(unsigned char) (1 << 5); | ||
1715 | } | ||
1716 | |||
1717 | void opcode_cb_aa() // RES 5, D | ||
1718 | { | ||
1719 | D &= ~(unsigned char) (1 << 5); | ||
1720 | } | ||
1721 | |||
1722 | void opcode_cb_ab() // RES 5, E | ||
1723 | { | ||
1724 | E &= ~(unsigned char) (1 << 5); | ||
1725 | } | ||
1726 | |||
1727 | void opcode_cb_ac() // RES 5, H | ||
1728 | { | ||
1729 | H &= ~(unsigned char) (1 << 5); | ||
1730 | } | ||
1731 | |||
1732 | void opcode_cb_ad() // RES 5, L | ||
1733 | { | ||
1734 | L &= ~(unsigned char) (1 << 5); | ||
1735 | } | ||
1736 | |||
1737 | void opcode_cb_ae() // RES 5, (HL) | ||
1738 | { | ||
1739 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 5) ); | ||
1740 | } | ||
1741 | |||
1742 | void opcode_cb_af() // RES 5, A | ||
1743 | { | ||
1744 | A &= ~(unsigned char) (1 << 5); | ||
1745 | } | ||
1746 | |||
1747 | void opcode_cb_b0() // RES 6, B | ||
1748 | { | ||
1749 | B &= ~(unsigned char) (1 << 6); | ||
1750 | } | ||
1751 | |||
1752 | void opcode_cb_b1() // RES 6, C | ||
1753 | { | ||
1754 | C &= ~(unsigned char) (1 << 6); | ||
1755 | } | ||
1756 | |||
1757 | void opcode_cb_b2() // RES 6, D | ||
1758 | { | ||
1759 | D &= ~(unsigned char) (1 << 6); | ||
1760 | } | ||
1761 | |||
1762 | void opcode_cb_b3() // RES 6, E | ||
1763 | { | ||
1764 | E &= ~(unsigned char) (1 << 6); | ||
1765 | } | ||
1766 | |||
1767 | void opcode_cb_b4() // RES 6, H | ||
1768 | { | ||
1769 | H &= ~(unsigned char) (1 << 6); | ||
1770 | } | ||
1771 | |||
1772 | void opcode_cb_b5() // RES 6, L | ||
1773 | { | ||
1774 | L &= ~(unsigned char) (1 << 6); | ||
1775 | } | ||
1776 | |||
1777 | void opcode_cb_b6() // RES 6, (HL) | ||
1778 | { | ||
1779 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 6) ); | ||
1780 | } | ||
1781 | |||
1782 | void opcode_cb_b7() // RES 6, A | ||
1783 | { | ||
1784 | A &= ~(unsigned char) (1 << 6); | ||
1785 | } | ||
1786 | |||
1787 | void opcode_cb_b8() // RES 7, B | ||
1788 | { | ||
1789 | B &= ~(unsigned char) (1 << 7); | ||
1790 | } | ||
1791 | |||
1792 | void opcode_cb_b9() // RES 7, C | ||
1793 | { | ||
1794 | C &= ~(unsigned char) (1 << 7); | ||
1795 | } | ||
1796 | |||
1797 | void opcode_cb_ba() // RES 7, D | ||
1798 | { | ||
1799 | D &= ~(unsigned char) (1 << 7); | ||
1800 | } | ||
1801 | |||
1802 | void opcode_cb_bb() // RES 7, E | ||
1803 | { | ||
1804 | E &= ~(unsigned char) (1 << 7); | ||
1805 | } | ||
1806 | |||
1807 | void opcode_cb_bc() // RES 7, H | ||
1808 | { | ||
1809 | H &= ~(unsigned char) (1 << 7); | ||
1810 | } | ||
1811 | |||
1812 | void opcode_cb_bd() // RES 7, L | ||
1813 | { | ||
1814 | L &= ~(unsigned char) (1 << 7); | ||
1815 | } | ||
1816 | |||
1817 | void opcode_cb_be() // RES 7, (HL) | ||
1818 | { | ||
1819 | writeByte( HL(), readByte( HL() ) & (unsigned char) ~(unsigned char) (1 << 7) ); | ||
1820 | } | ||
1821 | |||
1822 | void opcode_cb_bf() // RES 7, A | ||
1823 | { | ||
1824 | A &= ~(unsigned char) (1 << 7); | ||
1825 | } | ||
1826 | |||
1827 | void opcode_cb_c0() // SET 0, B | ||
1828 | { | ||
1829 | B |= (unsigned char) (1 << 0); | ||
1830 | } | ||
1831 | |||
1832 | void opcode_cb_c1() // SET 0, C | ||
1833 | { | ||
1834 | C |= (unsigned char) (1 << 0); | ||
1835 | } | ||
1836 | |||
1837 | void opcode_cb_c2() // SET 0, D | ||
1838 | { | ||
1839 | D |= (unsigned char) (1 << 0); | ||
1840 | } | ||
1841 | |||
1842 | void opcode_cb_c3() // SET 0, E | ||
1843 | { | ||
1844 | E |= (unsigned char) (1 << 0); | ||
1845 | } | ||
1846 | |||
1847 | void opcode_cb_c4() // SET 0, H | ||
1848 | { | ||
1849 | H |= (unsigned char) (1 << 0); | ||
1850 | } | ||
1851 | |||
1852 | void opcode_cb_c5() // SET 0, L | ||
1853 | { | ||
1854 | L |= (unsigned char) (1 << 0); | ||
1855 | } | ||
1856 | |||
1857 | void opcode_cb_c6() // SET 0, (HL) | ||
1858 | { | ||
1859 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 0) ); | ||
1860 | } | ||
1861 | |||
1862 | void opcode_cb_c7() // SET 0, A | ||
1863 | { | ||
1864 | A |= (unsigned char) (1 << 0); | ||
1865 | } | ||
1866 | |||
1867 | void opcode_cb_c8() // SET 1, B | ||
1868 | { | ||
1869 | B |= (unsigned char) (1 << 1); | ||
1870 | } | ||
1871 | |||
1872 | void opcode_cb_c9() // SET 1, C | ||
1873 | { | ||
1874 | C |= (unsigned char) (1 << 1); | ||
1875 | } | ||
1876 | |||
1877 | void opcode_cb_ca() // SET 1, D | ||
1878 | { | ||
1879 | D |= (unsigned char) (1 << 1); | ||
1880 | } | ||
1881 | |||
1882 | void opcode_cb_cb() // SET 1, E | ||
1883 | { | ||
1884 | E |= (unsigned char) (1 << 1); | ||
1885 | } | ||
1886 | |||
1887 | void opcode_cb_cc() // SET 1, H | ||
1888 | { | ||
1889 | H |= (unsigned char) (1 << 1); | ||
1890 | } | ||
1891 | |||
1892 | void opcode_cb_cd() // SET 1, L | ||
1893 | { | ||
1894 | L |= (unsigned char) (1 << 1); | ||
1895 | } | ||
1896 | |||
1897 | void opcode_cb_ce() // SET 1, (HL) | ||
1898 | { | ||
1899 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 1) ); | ||
1900 | } | ||
1901 | |||
1902 | void opcode_cb_cf() // SET 1, A | ||
1903 | { | ||
1904 | A |= (unsigned char) (1 << 1); | ||
1905 | } | ||
1906 | |||
1907 | void opcode_cb_d0() // SET 2, B | ||
1908 | { | ||
1909 | B |= (unsigned char) (1 << 2); | ||
1910 | } | ||
1911 | |||
1912 | void opcode_cb_d1() // SET 2, C | ||
1913 | { | ||
1914 | C |= (unsigned char) (1 << 2); | ||
1915 | } | ||
1916 | |||
1917 | void opcode_cb_d2() // SET 2, D | ||
1918 | { | ||
1919 | D |= (unsigned char) (1 << 2); | ||
1920 | } | ||
1921 | |||
1922 | void opcode_cb_d3() // SET 2, E | ||
1923 | { | ||
1924 | E |= (unsigned char) (1 << 2); | ||
1925 | } | ||
1926 | |||
1927 | void opcode_cb_d4() // SET 2, H | ||
1928 | { | ||
1929 | H |= (unsigned char) (1 << 2); | ||
1930 | } | ||
1931 | |||
1932 | void opcode_cb_d5() // SET 2, L | ||
1933 | { | ||
1934 | L |= (unsigned char) (1 << 2); | ||
1935 | } | ||
1936 | |||
1937 | void opcode_cb_d6() // SET 2, (HL) | ||
1938 | { | ||
1939 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 2) ); | ||
1940 | } | ||
1941 | |||
1942 | void opcode_cb_d7() // SET 2, A | ||
1943 | { | ||
1944 | A |= (unsigned char) (1 << 2); | ||
1945 | } | ||
1946 | |||
1947 | void opcode_cb_d8() // SET 3, B | ||
1948 | { | ||
1949 | B |= (unsigned char) (1 << 3); | ||
1950 | } | ||
1951 | |||
1952 | void opcode_cb_d9() // SET 3, C | ||
1953 | { | ||
1954 | C |= (unsigned char) (1 << 3); | ||
1955 | } | ||
1956 | |||
1957 | void opcode_cb_da() // SET 3, D | ||
1958 | { | ||
1959 | D |= (unsigned char) (1 << 3); | ||
1960 | } | ||
1961 | |||
1962 | void opcode_cb_db() // SET 3, E | ||
1963 | { | ||
1964 | E |= (unsigned char) (1 << 3); | ||
1965 | } | ||
1966 | |||
1967 | void opcode_cb_dc() // SET 3, H | ||
1968 | { | ||
1969 | H |= (unsigned char) (1 << 3); | ||
1970 | } | ||
1971 | |||
1972 | void opcode_cb_dd() // SET 3, L | ||
1973 | { | ||
1974 | L |= (unsigned char) (1 << 3); | ||
1975 | } | ||
1976 | |||
1977 | void opcode_cb_de() // SET 3, (HL) | ||
1978 | { | ||
1979 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 3) ); | ||
1980 | } | ||
1981 | |||
1982 | void opcode_cb_df() // SET 3, A | ||
1983 | { | ||
1984 | A |= (unsigned char) (1 << 3); | ||
1985 | } | ||
1986 | |||
1987 | void opcode_cb_e0() // SET 4, B | ||
1988 | { | ||
1989 | B |= (unsigned char) (1 << 4); | ||
1990 | } | ||
1991 | |||
1992 | void opcode_cb_e1() // SET 4, C | ||
1993 | { | ||
1994 | C |= (unsigned char) (1 << 4); | ||
1995 | } | ||
1996 | |||
1997 | void opcode_cb_e2() // SET 4, D | ||
1998 | { | ||
1999 | D |= (unsigned char) (1 << 4); | ||
2000 | } | ||
2001 | |||
2002 | void opcode_cb_e3() // SET 4, E | ||
2003 | { | ||
2004 | E |= (unsigned char) (1 << 4); | ||
2005 | } | ||
2006 | |||
2007 | void opcode_cb_e4() // SET 4, H | ||
2008 | { | ||
2009 | H |= (unsigned char) (1 << 4); | ||
2010 | } | ||
2011 | |||
2012 | void opcode_cb_e5() // SET 4, L | ||
2013 | { | ||
2014 | L |= (unsigned char) (1 << 4); | ||
2015 | } | ||
2016 | |||
2017 | void opcode_cb_e6() // SET 4, (HL) | ||
2018 | { | ||
2019 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 4) ); | ||
2020 | } | ||
2021 | |||
2022 | void opcode_cb_e7() // SET 4, A | ||
2023 | { | ||
2024 | A |= (unsigned char) (1 << 4); | ||
2025 | } | ||
2026 | |||
2027 | void opcode_cb_e8() // SET 5, B | ||
2028 | { | ||
2029 | B |= (unsigned char) (1 << 5); | ||
2030 | } | ||
2031 | |||
2032 | void opcode_cb_e9() // SET 5, C | ||
2033 | { | ||
2034 | C |= (unsigned char) (1 << 5); | ||
2035 | } | ||
2036 | |||
2037 | void opcode_cb_ea() // SET 5, D | ||
2038 | { | ||
2039 | D |= (unsigned char) (1 << 5); | ||
2040 | } | ||
2041 | |||
2042 | void opcode_cb_eb() // SET 5, E | ||
2043 | { | ||
2044 | E |= (unsigned char) (1 << 5); | ||
2045 | } | ||
2046 | |||
2047 | void opcode_cb_ec() // SET 5, H | ||
2048 | { | ||
2049 | H |= (unsigned char) (1 << 5); | ||
2050 | } | ||
2051 | |||
2052 | void opcode_cb_ed() // SET 5, L | ||
2053 | { | ||
2054 | L |= (unsigned char) (1 << 5); | ||
2055 | } | ||
2056 | |||
2057 | void opcode_cb_ee() // SET 5, (HL) | ||
2058 | { | ||
2059 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 5) ); | ||
2060 | } | ||
2061 | |||
2062 | void opcode_cb_ef() // SET 5, A | ||
2063 | { | ||
2064 | A |= (unsigned char) (1 << 5); | ||
2065 | } | ||
2066 | |||
2067 | void opcode_cb_f0() // SET 6, B | ||
2068 | { | ||
2069 | B |= (unsigned char) (1 << 6); | ||
2070 | } | ||
2071 | |||
2072 | void opcode_cb_f1() // SET 6, C | ||
2073 | { | ||
2074 | C |= (unsigned char) (1 << 6); | ||
2075 | } | ||
2076 | |||
2077 | void opcode_cb_f2() // SET 6, D | ||
2078 | { | ||
2079 | D |= (unsigned char) (1 << 6); | ||
2080 | } | ||
2081 | |||
2082 | void opcode_cb_f3() // SET 6, E | ||
2083 | { | ||
2084 | E |= (unsigned char) (1 << 6); | ||
2085 | } | ||
2086 | |||
2087 | void opcode_cb_f4() // SET 6, H | ||
2088 | { | ||
2089 | H |= (unsigned char) (1 << 6); | ||
2090 | } | ||
2091 | |||
2092 | void opcode_cb_f5() // SET 6, L | ||
2093 | { | ||
2094 | L |= (unsigned char) (1 << 6); | ||
2095 | } | ||
2096 | |||
2097 | void opcode_cb_f6() // SET 6, (HL) | ||
2098 | { | ||
2099 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 6) ); | ||
2100 | } | ||
2101 | |||
2102 | void opcode_cb_f7() // SET 6, A | ||
2103 | { | ||
2104 | A |= (unsigned char) (1 << 6); | ||
2105 | } | ||
2106 | |||
2107 | void opcode_cb_f8() // SET 7, B | ||
2108 | { | ||
2109 | B |= (unsigned char) (1 << 7); | ||
2110 | } | ||
2111 | |||
2112 | void opcode_cb_f9() // SET 7, C | ||
2113 | { | ||
2114 | C |= (unsigned char) (1 << 7); | ||
2115 | } | ||
2116 | |||
2117 | void opcode_cb_fa() // SET 7, D | ||
2118 | { | ||
2119 | D |= (unsigned char) (1 << 7); | ||
2120 | } | ||
2121 | |||
2122 | void opcode_cb_fb() // SET 7, E | ||
2123 | { | ||
2124 | E |= (unsigned char) (1 << 7); | ||
2125 | } | ||
2126 | |||
2127 | void opcode_cb_fc() // SET 7, H | ||
2128 | { | ||
2129 | H |= (unsigned char) (1 << 7); | ||
2130 | } | ||
2131 | |||
2132 | void opcode_cb_fd() // SET 7, L | ||
2133 | { | ||
2134 | L |= (unsigned char) (1 << 7); | ||
2135 | } | ||
2136 | |||
2137 | void opcode_cb_fe() // SET 7, (HL) | ||
2138 | { | ||
2139 | writeByte( HL(), readByte( HL() ) | (unsigned char) (1 << 7) ); | ||
2140 | } | ||
2141 | |||
2142 | void opcode_cb_ff() // SET 7, A | ||
2143 | { | ||
2144 | A |= (unsigned char) (1 << 7); | ||
2145 | } | ||
2146 | |||
2147 | OpcodeInfo OpInfoDD_[256] = { | ||
2148 | { 0, 0 }, // 0x00 | ||
2149 | { 0, 0 }, // 0x01 | ||
2150 | { 0, 0 }, // 0x02 | ||
2151 | { 0, 0 }, // 0x03 | ||
2152 | { 0, 0 }, // 0x04 | ||
2153 | { 0, 0 }, // 0x05 | ||
2154 | { 0, 0 }, // 0x06 | ||
2155 | { 0, 0 }, // 0x07 | ||
2156 | { 0, 0 }, // 0x08 | ||
2157 | { &opcode_dd_09, 15 }, // ADD IX, BC | ||
2158 | { 0, 0 }, // 0x0A | ||
2159 | { 0, 0 }, // 0x0B | ||
2160 | { 0, 0 }, // 0x0C | ||
2161 | { 0, 0 }, // 0x0D | ||
2162 | { 0, 0 }, // 0x0E | ||
2163 | { 0, 0 }, // 0x0F | ||
2164 | { 0, 0 }, // 0x10 | ||
2165 | { 0, 0 }, // 0x11 | ||
2166 | { 0, 0 }, // 0x12 | ||
2167 | { 0, 0 }, // 0x13 | ||
2168 | { 0, 0 }, // 0x14 | ||
2169 | { 0, 0 }, // 0x15 | ||
2170 | { 0, 0 }, // 0x16 | ||
2171 | { 0, 0 }, // 0x17 | ||
2172 | { 0, 0 }, // 0x18 | ||
2173 | { &opcode_dd_19, 15 }, // ADD IX, DE | ||
2174 | { 0, 0 }, // 0x1A | ||
2175 | { 0, 0 }, // 0x1B | ||
2176 | { 0, 0 }, // 0x1C | ||
2177 | { 0, 0 }, // 0x1D | ||
2178 | { 0, 0 }, // 0x1E | ||
2179 | { 0, 0 }, // 0x1F | ||
2180 | { 0, 0 }, // 0x20 | ||
2181 | { &opcode_dd_21, 14 }, // LD IX, nn | ||
2182 | { &opcode_dd_22, 20 }, // LD (nn), IX | ||
2183 | { &opcode_dd_23, 10 }, // INC IX | ||
2184 | { &opcode_dd_24, 9 }, // INC IXH | ||
2185 | { &opcode_dd_25, 9 }, // DEC IXH | ||
2186 | { &opcode_dd_26, 9 }, // LD IXH, n | ||
2187 | { 0, 0 }, // 0x27 | ||
2188 | { 0, 0 }, // 0x28 | ||
2189 | { &opcode_dd_29, 15 }, // ADD IX, IX | ||
2190 | { &opcode_dd_2a, 20 }, // LD IX, (nn) | ||
2191 | { &opcode_dd_2b, 10 }, // DEC IX | ||
2192 | { &opcode_dd_2c, 9 }, // INC IXL | ||
2193 | { &opcode_dd_2d, 9 }, // DEC IXL | ||
2194 | { &opcode_dd_2e, 9 }, // LD IXL, n | ||
2195 | { 0, 0 }, // 0x2F | ||
2196 | { 0, 0 }, // 0x30 | ||
2197 | { 0, 0 }, // 0x31 | ||
2198 | { 0, 0 }, // 0x32 | ||
2199 | { 0, 0 }, // 0x33 | ||
2200 | { &opcode_dd_34, 23 }, // INC (IX + d) | ||
2201 | { &opcode_dd_35, 23 }, // DEC (IX + d) | ||
2202 | { &opcode_dd_36, 19 }, // LD (IX + d), n | ||
2203 | { 0, 0 }, // 0x37 | ||
2204 | { 0, 0 }, // 0x38 | ||
2205 | { &opcode_dd_39, 15 }, // ADD IX, SP | ||
2206 | { 0, 0 }, // 0x3A | ||
2207 | { 0, 0 }, // 0x3B | ||
2208 | { 0, 0 }, // 0x3C | ||
2209 | { 0, 0 }, // 0x3D | ||
2210 | { 0, 0 }, // 0x3E | ||
2211 | { 0, 0 }, // 0x3F | ||
2212 | { 0, 0 }, // 0x40 | ||
2213 | { 0, 0 }, // 0x41 | ||
2214 | { 0, 0 }, // 0x42 | ||
2215 | { 0, 0 }, // 0x43 | ||
2216 | { &opcode_dd_44, 9 }, // LD B, IXH | ||
2217 | { &opcode_dd_45, 9 }, // LD B, IXL | ||
2218 | { &opcode_dd_46, 19 }, // LD B, (IX + d) | ||
2219 | { 0, 0 }, // 0x47 | ||
2220 | { 0, 0 }, // 0x48 | ||
2221 | { 0, 0 }, // 0x49 | ||
2222 | { 0, 0 }, // 0x4A | ||
2223 | { 0, 0 }, // 0x4B | ||
2224 | { &opcode_dd_4c, 9 }, // LD C, IXH | ||
2225 | { &opcode_dd_4d, 9 }, // LD C, IXL | ||
2226 | { &opcode_dd_4e, 19 }, // LD C, (IX + d) | ||
2227 | { 0, 0 }, // 0x4F | ||
2228 | { 0, 0 }, // 0x50 | ||
2229 | { 0, 0 }, // 0x51 | ||
2230 | { 0, 0 }, // 0x52 | ||
2231 | { 0, 0 }, // 0x53 | ||
2232 | { &opcode_dd_54, 9 }, // LD D, IXH | ||
2233 | { &opcode_dd_55, 9 }, // LD D, IXL | ||
2234 | { &opcode_dd_56, 19 }, // LD D, (IX + d) | ||
2235 | { 0, 0 }, // 0x57 | ||
2236 | { 0, 0 }, // 0x58 | ||
2237 | { 0, 0 }, // 0x59 | ||
2238 | { 0, 0 }, // 0x5A | ||
2239 | { 0, 0 }, // 0x5B | ||
2240 | { &opcode_dd_5c, 9 }, // LD E, IXH | ||
2241 | { &opcode_dd_5d, 9 }, // LD E, IXL | ||
2242 | { &opcode_dd_5e, 19 }, // LD E, (IX + d) | ||
2243 | { 0, 0 }, // 0x5F | ||
2244 | { &opcode_dd_60, 9 }, // LD IXH, B | ||
2245 | { &opcode_dd_61, 9 }, // LD IXH, C | ||
2246 | { &opcode_dd_62, 9 }, // LD IXH, D | ||
2247 | { &opcode_dd_63, 9 }, // LD IXH, E | ||
2248 | { &opcode_dd_64, 9 }, // LD IXH, IXH | ||
2249 | { &opcode_dd_65, 9 }, // LD IXH, IXL | ||
2250 | { &opcode_dd_66, 9 }, // LD H, (IX + d) | ||
2251 | { &opcode_dd_67, 9 }, // LD IXH, A | ||
2252 | { &opcode_dd_68, 9 }, // LD IXL, B | ||
2253 | { &opcode_dd_69, 9 }, // LD IXL, C | ||
2254 | { &opcode_dd_6a, 9 }, // LD IXL, D | ||
2255 | { &opcode_dd_6b, 9 }, // LD IXL, E | ||
2256 | { &opcode_dd_6c, 9 }, // LD IXL, IXH | ||
2257 | { &opcode_dd_6d, 9 }, // LD IXL, IXL | ||
2258 | { &opcode_dd_6e, 9 }, // LD L, (IX + d) | ||
2259 | { &opcode_dd_6f, 9 }, // LD IXL, A | ||
2260 | { &opcode_dd_70, 19 }, // LD (IX + d), B | ||
2261 | { &opcode_dd_71, 19 }, // LD (IX + d), C | ||
2262 | { &opcode_dd_72, 19 }, // LD (IX + d), D | ||
2263 | { &opcode_dd_73, 19 }, // LD (IX + d), E | ||
2264 | { &opcode_dd_74, 19 }, // LD (IX + d), H | ||
2265 | { &opcode_dd_75, 19 }, // LD (IX + d), L | ||
2266 | { 0,19 }, // 0x76 | ||
2267 | { &opcode_dd_77, 19 }, // LD (IX + d), A | ||
2268 | { 0, 0 }, // 0x78 | ||
2269 | { 0, 0 }, // 0x79 | ||
2270 | { 0, 0 }, // 0x7A | ||
2271 | { 0, 0 }, // 0x7B | ||
2272 | { &opcode_dd_7c, 9 }, // LD A, IXH | ||
2273 | { &opcode_dd_7d, 9 }, // LD A, IXL | ||
2274 | { &opcode_dd_7e, 19 }, // LD A, (IX + d) | ||
2275 | { 0, 0 }, // 0x7F | ||
2276 | { 0, 0 }, // 0x80 | ||
2277 | { 0, 0 }, // 0x81 | ||
2278 | { 0, 0 }, // 0x82 | ||
2279 | { 0, 0 }, // 0x83 | ||
2280 | { &opcode_dd_84, 9 }, // ADD A, IXH | ||
2281 | { &opcode_dd_85, 9 }, // ADD A, IXL | ||
2282 | { &opcode_dd_86, 19 }, // ADD A, (IX + d) | ||
2283 | { 0, 0 }, // 0x87 | ||
2284 | { 0, 0 }, // 0x88 | ||
2285 | { 0, 0 }, // 0x89 | ||
2286 | { 0, 0 }, // 0x8A | ||
2287 | { 0, 0 }, // 0x8B | ||
2288 | { &opcode_dd_8c, 9 }, // ADC A, IXH | ||
2289 | { &opcode_dd_8d, 9 }, // ADC A, IXL | ||
2290 | { &opcode_dd_8e, 19 }, // ADC A, (IX + d) | ||
2291 | { 0, 0 }, // 0x8F | ||
2292 | { 0, 0 }, // 0x90 | ||
2293 | { 0, 0 }, // 0x91 | ||
2294 | { 0, 0 }, // 0x92 | ||
2295 | { 0, 0 }, // 0x93 | ||
2296 | { &opcode_dd_94, 9 }, // SUB IXH | ||
2297 | { &opcode_dd_95, 9 }, // SUB IXL | ||
2298 | { &opcode_dd_96, 19 }, // SUB (IX + d) | ||
2299 | { 0, 0 }, // 0x97 | ||
2300 | { 0, 0 }, // 0x98 | ||
2301 | { 0, 0 }, // 0x99 | ||
2302 | { 0, 0 }, // 0x9A | ||
2303 | { 0, 0 }, // 0x9B | ||
2304 | { &opcode_dd_9c, 9 }, // SBC A, IXH | ||
2305 | { &opcode_dd_9d, 9 }, // SBC A, IXL | ||
2306 | { &opcode_dd_9e, 19 }, // SBC A, (IX + d) | ||
2307 | { 0, 0 }, // 0x9F | ||
2308 | { 0, 0 }, // 0xA0 | ||
2309 | { 0, 0 }, // 0xA1 | ||
2310 | { 0, 0 }, // 0xA2 | ||
2311 | { 0, 0 }, // 0xA3 | ||
2312 | { &opcode_dd_a4, 9 }, // AND IXH | ||
2313 | { &opcode_dd_a5, 9 }, // AND IXL | ||
2314 | { &opcode_dd_a6, 19 }, // AND (IX + d) | ||
2315 | { 0, 0 }, // 0xA7 | ||
2316 | { 0, 0 }, // 0xA8 | ||
2317 | { 0, 0 }, // 0xA9 | ||
2318 | { 0, 0 }, // 0xAA | ||
2319 | { 0, 0 }, // 0xAB | ||
2320 | { &opcode_dd_ac, 9 }, // XOR IXH | ||
2321 | { &opcode_dd_ad, 9 }, // XOR IXL | ||
2322 | { &opcode_dd_ae, 19 }, // XOR (IX + d) | ||
2323 | { 0, 0 }, // 0xAF | ||
2324 | { 0, 0 }, // 0xB0 | ||
2325 | { 0, 0 }, // 0xB1 | ||
2326 | { 0, 0 }, // 0xB2 | ||
2327 | { 0, 0 }, // 0xB3 | ||
2328 | { &opcode_dd_b4, 9 }, // OR IXH | ||
2329 | { &opcode_dd_b5, 9 }, // OR IXL | ||
2330 | { &opcode_dd_b6, 19 }, // OR (IX + d) | ||
2331 | { 0, 0 }, // 0xB7 | ||
2332 | { 0, 0 }, // 0xB8 | ||
2333 | { 0, 0 }, // 0xB9 | ||
2334 | { 0, 0 }, // 0xBA | ||
2335 | { 0, 0 }, // 0xBB | ||
2336 | { &opcode_dd_bc, 9 }, // CP IXH | ||
2337 | { &opcode_dd_bd, 9 }, // CP IXL | ||
2338 | { &opcode_dd_be, 19 }, // CP (IX + d) | ||
2339 | { 0, 0 }, // 0xBF | ||
2340 | { 0, 0 }, // 0xC0 | ||
2341 | { 0, 0 }, // 0xC1 | ||
2342 | { 0, 0 }, // 0xC2 | ||
2343 | { 0, 0 }, // 0xC3 | ||
2344 | { 0, 0 }, // 0xC4 | ||
2345 | { 0, 0 }, // 0xC5 | ||
2346 | { 0, 0 }, // 0xC6 | ||
2347 | { 0, 0 }, // 0xC7 | ||
2348 | { 0, 0 }, // 0xC8 | ||
2349 | { 0, 0 }, // 0xC9 | ||
2350 | { 0, 0 }, // 0xCA | ||
2351 | { &opcode_dd_cb, 0 }, // | ||
2352 | { 0, 0 }, // 0xCC | ||
2353 | { 0, 0 }, // 0xCD | ||
2354 | { 0, 0 }, // 0xCE | ||
2355 | { 0, 0 }, // 0xCF | ||
2356 | { 0, 0 }, // 0xD0 | ||
2357 | { 0, 0 }, // 0xD1 | ||
2358 | { 0, 0 }, // 0xD2 | ||
2359 | { 0, 0 }, // 0xD3 | ||
2360 | { 0, 0 }, // 0xD4 | ||
2361 | { 0, 0 }, // 0xD5 | ||
2362 | { 0, 0 }, // 0xD6 | ||
2363 | { 0, 0 }, // 0xD7 | ||
2364 | { 0, 0 }, // 0xD8 | ||
2365 | { 0, 0 }, // 0xD9 | ||
2366 | { 0, 0 }, // 0xDA | ||
2367 | { 0, 0 }, // 0xDB | ||
2368 | { 0, 0 }, // 0xDC | ||
2369 | { 0, 0 }, // 0xDD | ||
2370 | { 0, 0 }, // 0xDE | ||
2371 | { 0, 0 }, // 0xDF | ||
2372 | { 0, 0 }, // 0xE0 | ||
2373 | { &opcode_dd_e1, 14 }, // POP IX | ||
2374 | { 0, 0 }, // 0xE2 | ||
2375 | { &opcode_dd_e3, 23 }, // EX (SP), IX | ||
2376 | { 0, 0 }, // 0xE4 | ||
2377 | { &opcode_dd_e5, 15 }, // PUSH IX | ||
2378 | { 0, 0 }, // 0xE6 | ||
2379 | { 0, 0 }, // 0xE7 | ||
2380 | { 0, 0 }, // 0xE8 | ||
2381 | { &opcode_dd_e9, 8 }, // JP (IX) | ||
2382 | { 0, 0 }, // 0xEA | ||
2383 | { 0, 0 }, // 0xEB | ||
2384 | { 0, 0 }, // 0xEC | ||
2385 | { 0, 0 }, // 0xED | ||
2386 | { 0, 0 }, // 0xEE | ||
2387 | { 0, 0 }, // 0xEF | ||
2388 | { 0, 0 }, // 0xF0 | ||
2389 | { 0, 0 }, // 0xF1 | ||
2390 | { 0, 0 }, // 0xF2 | ||
2391 | { 0, 0 }, // 0xF3 | ||
2392 | { 0, 0 }, // 0xF4 | ||
2393 | { 0, 0 }, // 0xF5 | ||
2394 | { 0, 0 }, // 0xF6 | ||
2395 | { 0, 0 }, // 0xF7 | ||
2396 | { 0, 0 }, // 0xF8 | ||
2397 | { &opcode_dd_f9, 10 }, // LD SP, IX | ||
2398 | { 0, 0 }, // 0xFA | ||
2399 | { 0, 0 }, // 0xFB | ||
2400 | { 0, 0 }, // 0xFC | ||
2401 | { 0, 0 }, // 0xFD | ||
2402 | { 0, 0 }, // 0xFE | ||
2403 | { 0, 0 } // 0xFF | ||
2404 | }; | ||
2405 | |||
2406 | void opcode_dd_09() // ADD IX, BC | ||
2407 | { | ||
2408 | unsigned rr = BC(); | ||
2409 | |||
2410 | F &= (Zero | Sign | Parity); | ||
2411 | if( ((IX & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
2412 | IX += rr; | ||
2413 | if( IX & 0x10000 ) F |= Carry; | ||
2414 | } | ||
2415 | |||
2416 | void opcode_dd_19() // ADD IX, DE | ||
2417 | { | ||
2418 | unsigned rr = DE(); | ||
2419 | |||
2420 | F &= (Zero | Sign | Parity); | ||
2421 | if( ((IX & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
2422 | IX += rr; | ||
2423 | if( IX & 0x10000 ) F |= Carry; | ||
2424 | } | ||
2425 | |||
2426 | void opcode_dd_21() // LD IX, nn | ||
2427 | { | ||
2428 | IX = fetchWord(); | ||
2429 | } | ||
2430 | |||
2431 | void opcode_dd_22() // LD (nn), IX | ||
2432 | { | ||
2433 | writeWord( fetchWord(), IX ); | ||
2434 | } | ||
2435 | |||
2436 | void opcode_dd_23() // INC IX | ||
2437 | { | ||
2438 | IX++; | ||
2439 | } | ||
2440 | |||
2441 | void opcode_dd_24() // INC IXH | ||
2442 | { | ||
2443 | IX = (IX & 0xFF) | ((unsigned)incByte( IX >> 8 ) << 8); | ||
2444 | } | ||
2445 | |||
2446 | void opcode_dd_25() // DEC IXH | ||
2447 | { | ||
2448 | IX = (IX & 0xFF) | ((unsigned)decByte( IX >> 8 ) << 8); | ||
2449 | } | ||
2450 | |||
2451 | void opcode_dd_26() // LD IXH, n | ||
2452 | { | ||
2453 | IX = (IX & 0xFF) | ((unsigned)fetchByte() << 8); | ||
2454 | } | ||
2455 | |||
2456 | void opcode_dd_29() // ADD IX, IX | ||
2457 | { | ||
2458 | F &= (Zero | Sign | Parity); | ||
2459 | if( IX & 0x800 ) F |= Halfcarry; | ||
2460 | IX += IX; | ||
2461 | if( IX & 0x10000 ) F |= Carry; | ||
2462 | } | ||
2463 | |||
2464 | void opcode_dd_2a() // LD IX, (nn) | ||
2465 | { | ||
2466 | IX = readWord( fetchWord() ); | ||
2467 | } | ||
2468 | |||
2469 | void opcode_dd_2b() // DEC IX | ||
2470 | { | ||
2471 | IX--; | ||
2472 | } | ||
2473 | |||
2474 | void opcode_dd_2c() // INC IXL | ||
2475 | { | ||
2476 | IX = (IX & 0xFF00) | incByte( IX & 0xFF ); | ||
2477 | } | ||
2478 | |||
2479 | void opcode_dd_2d() // DEC IXL | ||
2480 | { | ||
2481 | IX = (IX & 0xFF00) | decByte( IX & 0xFF ); | ||
2482 | } | ||
2483 | |||
2484 | void opcode_dd_2e() // LD IXL, n | ||
2485 | { | ||
2486 | IX = (IX & 0xFF00) | fetchByte(); | ||
2487 | } | ||
2488 | |||
2489 | void opcode_dd_34() // INC (IX + d) | ||
2490 | { | ||
2491 | unsigned addr = addDispl( IX, fetchByte() ); | ||
2492 | |||
2493 | writeByte( addr, incByte( readByte( addr ) ) ); | ||
2494 | } | ||
2495 | |||
2496 | void opcode_dd_35() // DEC (IX + d) | ||
2497 | { | ||
2498 | unsigned addr = addDispl( IX, fetchByte() ); | ||
2499 | |||
2500 | writeByte( addr, decByte( readByte( addr ) ) ); | ||
2501 | } | ||
2502 | |||
2503 | void opcode_dd_36() // LD (IX + d), n | ||
2504 | { | ||
2505 | unsigned addr = addDispl( IX, fetchByte() ); | ||
2506 | |||
2507 | writeByte( addr, fetchByte() ); | ||
2508 | } | ||
2509 | |||
2510 | void opcode_dd_39() // ADD IX, SP | ||
2511 | { | ||
2512 | F &= (Zero | Sign | Parity); | ||
2513 | if( ((IX & 0xFFF)+(SP & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
2514 | IX += SP; | ||
2515 | if( IX & 0x10000 ) F |= Carry; | ||
2516 | } | ||
2517 | |||
2518 | void opcode_dd_44() // LD B, IXH | ||
2519 | { | ||
2520 | B = IX >> 8; | ||
2521 | } | ||
2522 | |||
2523 | void opcode_dd_45() // LD B, IXL | ||
2524 | { | ||
2525 | B = IX & 0xFF; | ||
2526 | } | ||
2527 | |||
2528 | void opcode_dd_46() // LD B, (IX + d) | ||
2529 | { | ||
2530 | B = readByte( addDispl(IX,fetchByte()) ); | ||
2531 | } | ||
2532 | |||
2533 | void opcode_dd_4c() // LD C, IXH | ||
2534 | { | ||
2535 | C = IX >> 8; | ||
2536 | } | ||
2537 | |||
2538 | void opcode_dd_4d() // LD C, IXL | ||
2539 | { | ||
2540 | C = IX & 0xFF; | ||
2541 | } | ||
2542 | |||
2543 | void opcode_dd_4e() // LD C, (IX + d) | ||
2544 | { | ||
2545 | C = readByte( addDispl(IX,fetchByte()) ); | ||
2546 | } | ||
2547 | |||
2548 | void opcode_dd_54() // LD D, IXH | ||
2549 | { | ||
2550 | D = IX >> 8; | ||
2551 | } | ||
2552 | |||
2553 | void opcode_dd_55() // LD D, IXL | ||
2554 | { | ||
2555 | D = IX & 0xFF; | ||
2556 | } | ||
2557 | |||
2558 | void opcode_dd_56() // LD D, (IX + d) | ||
2559 | { | ||
2560 | D = readByte( addDispl(IX,fetchByte()) ); | ||
2561 | } | ||
2562 | |||
2563 | void opcode_dd_5c() // LD E, IXH | ||
2564 | { | ||
2565 | E = IX >> 8; | ||
2566 | } | ||
2567 | |||
2568 | void opcode_dd_5d() // LD E, IXL | ||
2569 | { | ||
2570 | E = IX & 0xFF; | ||
2571 | } | ||
2572 | |||
2573 | void opcode_dd_5e() // LD E, (IX + d) | ||
2574 | { | ||
2575 | E = readByte( addDispl(IX,fetchByte()) ); | ||
2576 | } | ||
2577 | |||
2578 | void opcode_dd_60() // LD IXH, B | ||
2579 | { | ||
2580 | IX = (IX & 0xFF) | ((unsigned)B << 8); | ||
2581 | } | ||
2582 | |||
2583 | void opcode_dd_61() // LD IXH, C | ||
2584 | { | ||
2585 | IX = (IX & 0xFF) | ((unsigned)C << 8); | ||
2586 | } | ||
2587 | |||
2588 | void opcode_dd_62() // LD IXH, D | ||
2589 | { | ||
2590 | IX = (IX & 0xFF) | ((unsigned)D << 8); | ||
2591 | } | ||
2592 | |||
2593 | void opcode_dd_63() // LD IXH, E | ||
2594 | { | ||
2595 | IX = (IX & 0xFF) | ((unsigned)E << 8); | ||
2596 | } | ||
2597 | |||
2598 | void opcode_dd_64() // LD IXH, IXH | ||
2599 | { | ||
2600 | } | ||
2601 | |||
2602 | void opcode_dd_65() // LD IXH, IXL | ||
2603 | { | ||
2604 | IX = (IX & 0xFF) | ((IX << 8) & 0xFF00); | ||
2605 | } | ||
2606 | |||
2607 | void opcode_dd_66() // LD H, (IX + d) | ||
2608 | { | ||
2609 | H = readByte( addDispl(IX,fetchByte()) ); | ||
2610 | } | ||
2611 | |||
2612 | void opcode_dd_67() // LD IXH, A | ||
2613 | { | ||
2614 | IX = (IX & 0xFF) | ((unsigned)A << 8); | ||
2615 | } | ||
2616 | |||
2617 | void opcode_dd_68() // LD IXL, B | ||
2618 | { | ||
2619 | IX = (IX & 0xFF00) | B; | ||
2620 | } | ||
2621 | |||
2622 | void opcode_dd_69() // LD IXL, C | ||
2623 | { | ||
2624 | IX = (IX & 0xFF00) | C; | ||
2625 | } | ||
2626 | |||
2627 | void opcode_dd_6a() // LD IXL, D | ||
2628 | { | ||
2629 | IX = (IX & 0xFF00) | D; | ||
2630 | } | ||
2631 | |||
2632 | void opcode_dd_6b() // LD IXL, E | ||
2633 | { | ||
2634 | IX = (IX & 0xFF00) | E; | ||
2635 | } | ||
2636 | |||
2637 | void opcode_dd_6c() // LD IXL, IXH | ||
2638 | { | ||
2639 | IX = (IX & 0xFF00) | ((IX >> 8) & 0xFF); | ||
2640 | } | ||
2641 | |||
2642 | void opcode_dd_6d() // LD IXL, IXL | ||
2643 | { | ||
2644 | } | ||
2645 | |||
2646 | void opcode_dd_6e() // LD L, (IX + d) | ||
2647 | { | ||
2648 | L = readByte( addDispl(IX,fetchByte()) ); | ||
2649 | } | ||
2650 | |||
2651 | void opcode_dd_6f() // LD IXL, A | ||
2652 | { | ||
2653 | IX = (IX & 0xFF00) | A; | ||
2654 | } | ||
2655 | |||
2656 | void opcode_dd_70() // LD (IX + d), B | ||
2657 | { | ||
2658 | writeByte( addDispl(IX,fetchByte()), B ); | ||
2659 | } | ||
2660 | |||
2661 | void opcode_dd_71() // LD (IX + d), C | ||
2662 | { | ||
2663 | writeByte( addDispl(IX,fetchByte()), C ); | ||
2664 | } | ||
2665 | |||
2666 | void opcode_dd_72() // LD (IX + d), D | ||
2667 | { | ||
2668 | writeByte( addDispl(IX,fetchByte()), D ); | ||
2669 | } | ||
2670 | |||
2671 | void opcode_dd_73() // LD (IX + d), E | ||
2672 | { | ||
2673 | writeByte( addDispl(IX,fetchByte()), E ); | ||
2674 | } | ||
2675 | |||
2676 | void opcode_dd_74() // LD (IX + d), H | ||
2677 | { | ||
2678 | writeByte( addDispl(IX,fetchByte()), H ); | ||
2679 | } | ||
2680 | |||
2681 | void opcode_dd_75() // LD (IX + d), L | ||
2682 | { | ||
2683 | writeByte( addDispl(IX,fetchByte()), L ); | ||
2684 | } | ||
2685 | |||
2686 | void opcode_dd_77() // LD (IX + d), A | ||
2687 | { | ||
2688 | writeByte( addDispl(IX,fetchByte()), A ); | ||
2689 | } | ||
2690 | |||
2691 | void opcode_dd_7c() // LD A, IXH | ||
2692 | { | ||
2693 | A = IX >> 8; | ||
2694 | } | ||
2695 | |||
2696 | void opcode_dd_7d() // LD A, IXL | ||
2697 | { | ||
2698 | A = IX & 0xFF; | ||
2699 | } | ||
2700 | |||
2701 | void opcode_dd_7e() // LD A, (IX + d) | ||
2702 | { | ||
2703 | A = readByte( addDispl(IX,fetchByte()) ); | ||
2704 | } | ||
2705 | |||
2706 | void opcode_dd_84() // ADD A, IXH | ||
2707 | { | ||
2708 | addByte( IX >> 8, 0 ); | ||
2709 | } | ||
2710 | |||
2711 | void opcode_dd_85() // ADD A, IXL | ||
2712 | { | ||
2713 | addByte( IX & 0xFF, 0 ); | ||
2714 | } | ||
2715 | |||
2716 | void opcode_dd_86() // ADD A, (IX + d) | ||
2717 | { | ||
2718 | addByte( readByte( addDispl(IX,fetchByte()) ), 0 ); | ||
2719 | } | ||
2720 | |||
2721 | void opcode_dd_8c() // ADC A, IXH | ||
2722 | { | ||
2723 | addByte( IX >> 8, F & Carry ); | ||
2724 | } | ||
2725 | |||
2726 | void opcode_dd_8d() // ADC A, IXL | ||
2727 | { | ||
2728 | addByte( IX & 0xFF, F & Carry ); | ||
2729 | } | ||
2730 | |||
2731 | void opcode_dd_8e() // ADC A, (IX + d) | ||
2732 | { | ||
2733 | addByte( readByte( addDispl(IX,fetchByte()) ), F & Carry ); | ||
2734 | } | ||
2735 | |||
2736 | void opcode_dd_94() // SUB IXH | ||
2737 | { | ||
2738 | A = subByte( IX >> 8, 0 ); | ||
2739 | } | ||
2740 | |||
2741 | void opcode_dd_95() // SUB IXL | ||
2742 | { | ||
2743 | A = subByte( IX & 0xFF, 0 ); | ||
2744 | } | ||
2745 | |||
2746 | void opcode_dd_96() // SUB (IX + d) | ||
2747 | { | ||
2748 | A = subByte( readByte( addDispl(IX,fetchByte()) ), 0 ); | ||
2749 | } | ||
2750 | |||
2751 | void opcode_dd_9c() // SBC A, IXH | ||
2752 | { | ||
2753 | A = subByte( IX >> 8, F & Carry ); | ||
2754 | } | ||
2755 | |||
2756 | void opcode_dd_9d() // SBC A, IXL | ||
2757 | { | ||
2758 | A = subByte( IX & 0xFF, F & Carry ); | ||
2759 | } | ||
2760 | |||
2761 | void opcode_dd_9e() // SBC A, (IX + d) | ||
2762 | { | ||
2763 | A = subByte( readByte( addDispl(IX,fetchByte()) ), F & Carry ); | ||
2764 | } | ||
2765 | |||
2766 | void opcode_dd_a4() // AND IXH | ||
2767 | { | ||
2768 | A &= IX >> 8; | ||
2769 | setFlags35PSZ000(); | ||
2770 | F |= Halfcarry; | ||
2771 | } | ||
2772 | |||
2773 | void opcode_dd_a5() // AND IXL | ||
2774 | { | ||
2775 | A &= IX & 0xFF; | ||
2776 | setFlags35PSZ000(); | ||
2777 | F |= Halfcarry; | ||
2778 | } | ||
2779 | |||
2780 | void opcode_dd_a6() // AND (IX + d) | ||
2781 | { | ||
2782 | A &= readByte( addDispl(IX,fetchByte()) ); | ||
2783 | setFlags35PSZ000(); | ||
2784 | F |= Halfcarry; | ||
2785 | } | ||
2786 | |||
2787 | void opcode_dd_ac() // XOR IXH | ||
2788 | { | ||
2789 | A ^= IX >> 8; | ||
2790 | setFlags35PSZ000(); | ||
2791 | } | ||
2792 | |||
2793 | void opcode_dd_ad() // XOR IXL | ||
2794 | { | ||
2795 | A ^= IX & 0xFF; | ||
2796 | setFlags35PSZ000(); | ||
2797 | } | ||
2798 | |||
2799 | void opcode_dd_ae() // XOR (IX + d) | ||
2800 | { | ||
2801 | A ^= readByte( addDispl(IX,fetchByte()) ); | ||
2802 | setFlags35PSZ000(); | ||
2803 | } | ||
2804 | |||
2805 | void opcode_dd_b4() // OR IXH | ||
2806 | { | ||
2807 | A |= IX >> 8; | ||
2808 | setFlags35PSZ000(); | ||
2809 | } | ||
2810 | |||
2811 | void opcode_dd_b5() // OR IXL | ||
2812 | { | ||
2813 | A |= IX & 0xFF; | ||
2814 | setFlags35PSZ000(); | ||
2815 | } | ||
2816 | |||
2817 | void opcode_dd_b6() // OR (IX + d) | ||
2818 | { | ||
2819 | A |= readByte( addDispl(IX,fetchByte()) ); | ||
2820 | setFlags35PSZ000(); | ||
2821 | } | ||
2822 | |||
2823 | void opcode_dd_bc() // CP IXH | ||
2824 | { | ||
2825 | cmpByte( IX >> 8 ); | ||
2826 | } | ||
2827 | |||
2828 | void opcode_dd_bd() // CP IXL | ||
2829 | { | ||
2830 | cmpByte( IX & 0xFF ); | ||
2831 | } | ||
2832 | |||
2833 | void opcode_dd_be() // CP (IX + d) | ||
2834 | { | ||
2835 | cmpByte( readByte( addDispl(IX,fetchByte()) ) ); | ||
2836 | } | ||
2837 | |||
2838 | void opcode_dd_cb() // | ||
2839 | { | ||
2840 | do_opcode_xycb( IX ); | ||
2841 | } | ||
2842 | |||
2843 | void opcode_dd_e1() // POP IX | ||
2844 | { | ||
2845 | IX = readWord( SP ); | ||
2846 | SP += 2; | ||
2847 | } | ||
2848 | |||
2849 | void opcode_dd_e3() // EX (SP), IX | ||
2850 | { | ||
2851 | unsigned ix = IX; | ||
2852 | |||
2853 | IX = readWord( SP ); | ||
2854 | writeWord( SP, ix ); | ||
2855 | } | ||
2856 | |||
2857 | void opcode_dd_e5() // PUSH IX | ||
2858 | { | ||
2859 | SP -= 2; | ||
2860 | writeWord( SP, IX ); | ||
2861 | } | ||
2862 | |||
2863 | void opcode_dd_e9() // JP (IX) | ||
2864 | { | ||
2865 | PC = IX; | ||
2866 | } | ||
2867 | |||
2868 | void opcode_dd_f9() // LD SP, IX | ||
2869 | { | ||
2870 | SP = IX; | ||
2871 | } | ||
2872 | |||
2873 | OpcodeInfo OpInfoED_[256] = { | ||
2874 | { 0, 0 }, // 0x00 | ||
2875 | { 0, 0 }, // 0x01 | ||
2876 | { 0, 0 }, // 0x02 | ||
2877 | { 0, 0 }, // 0x03 | ||
2878 | { 0, 0 }, // 0x04 | ||
2879 | { 0, 0 }, // 0x05 | ||
2880 | { 0, 0 }, // 0x06 | ||
2881 | { 0, 0 }, // 0x07 | ||
2882 | { 0, 0 }, // 0x08 | ||
2883 | { 0, 0 }, // 0x09 | ||
2884 | { 0, 0 }, // 0x0A | ||
2885 | { 0, 0 }, // 0x0B | ||
2886 | { 0, 0 }, // 0x0C | ||
2887 | { 0, 0 }, // 0x0D | ||
2888 | { 0, 0 }, // 0x0E | ||
2889 | { 0, 0 }, // 0x0F | ||
2890 | { 0, 0 }, // 0x10 | ||
2891 | { 0, 0 }, // 0x11 | ||
2892 | { 0, 0 }, // 0x12 | ||
2893 | { 0, 0 }, // 0x13 | ||
2894 | { 0, 0 }, // 0x14 | ||
2895 | { 0, 0 }, // 0x15 | ||
2896 | { 0, 0 }, // 0x16 | ||
2897 | { 0, 0 }, // 0x17 | ||
2898 | { 0, 0 }, // 0x18 | ||
2899 | { 0, 0 }, // 0x19 | ||
2900 | { 0, 0 }, // 0x1A | ||
2901 | { 0, 0 }, // 0x1B | ||
2902 | { 0, 0 }, // 0x1C | ||
2903 | { 0, 0 }, // 0x1D | ||
2904 | { 0, 0 }, // 0x1E | ||
2905 | { 0, 0 }, // 0x1F | ||
2906 | { 0, 0 }, // 0x20 | ||
2907 | { 0, 0 }, // 0x21 | ||
2908 | { 0, 0 }, // 0x22 | ||
2909 | { 0, 0 }, // 0x23 | ||
2910 | { 0, 0 }, // 0x24 | ||
2911 | { 0, 0 }, // 0x25 | ||
2912 | { 0, 0 }, // 0x26 | ||
2913 | { 0, 0 }, // 0x27 | ||
2914 | { 0, 0 }, // 0x28 | ||
2915 | { 0, 0 }, // 0x29 | ||
2916 | { 0, 0 }, // 0x2A | ||
2917 | { 0, 0 }, // 0x2B | ||
2918 | { 0, 0 }, // 0x2C | ||
2919 | { 0, 0 }, // 0x2D | ||
2920 | { 0, 0 }, // 0x2E | ||
2921 | { 0, 0 }, // 0x2F | ||
2922 | { 0, 0 }, // 0x30 | ||
2923 | { 0, 0 }, // 0x31 | ||
2924 | { 0, 0 }, // 0x32 | ||
2925 | { 0, 0 }, // 0x33 | ||
2926 | { 0, 0 }, // 0x34 | ||
2927 | { 0, 0 }, // 0x35 | ||
2928 | { 0, 0 }, // 0x36 | ||
2929 | { 0, 0 }, // 0x37 | ||
2930 | { 0, 0 }, // 0x38 | ||
2931 | { 0, 0 }, // 0x39 | ||
2932 | { 0, 0 }, // 0x3A | ||
2933 | { 0, 0 }, // 0x3B | ||
2934 | { 0, 0 }, // 0x3C | ||
2935 | { 0, 0 }, // 0x3D | ||
2936 | { 0, 0 }, // 0x3E | ||
2937 | { 0, 0 }, // 0x3F | ||
2938 | { &opcode_ed_40, 12 }, // IN B, (C) | ||
2939 | { &opcode_ed_41, 12 }, // OUT (C), B | ||
2940 | { &opcode_ed_42, 15 }, // SBC HL, BC | ||
2941 | { &opcode_ed_43, 20 }, // LD (nn), BC | ||
2942 | { &opcode_ed_44, 8 }, // NEG | ||
2943 | { &opcode_ed_45, 14 }, // RETN | ||
2944 | { &opcode_ed_46, 8 }, // IM 0 | ||
2945 | { &opcode_ed_47, 9 }, // LD I, A | ||
2946 | { &opcode_ed_48, 12 }, // IN C, (C) | ||
2947 | { &opcode_ed_49, 12 }, // OUT (C), C | ||
2948 | { &opcode_ed_4a, 15 }, // ADC HL, BC | ||
2949 | { &opcode_ed_4b, 20 }, // LD BC, (nn) | ||
2950 | { &opcode_ed_4c, 8 }, // NEG | ||
2951 | { &opcode_ed_4d, 14 }, // RETI | ||
2952 | { &opcode_ed_4e, 8 }, // IM 0/1 | ||
2953 | { &opcode_ed_4f, 9 }, // LD R, A | ||
2954 | { &opcode_ed_50, 12 }, // IN D, (C) | ||
2955 | { &opcode_ed_51, 12 }, // OUT (C), D | ||
2956 | { &opcode_ed_52, 15 }, // SBC HL, DE | ||
2957 | { &opcode_ed_53, 20 }, // LD (nn), DE | ||
2958 | { &opcode_ed_54, 8 }, // NEG | ||
2959 | { &opcode_ed_55, 14 }, // RETN | ||
2960 | { &opcode_ed_56, 8 }, // IM 1 | ||
2961 | { &opcode_ed_57, 9 }, // LD A, I | ||
2962 | { &opcode_ed_58, 12 }, // IN E, (C) | ||
2963 | { &opcode_ed_59, 12 }, // OUT (C), E | ||
2964 | { &opcode_ed_5a, 15 }, // ADC HL, DE | ||
2965 | { &opcode_ed_5b, 20 }, // LD DE, (nn) | ||
2966 | { &opcode_ed_5c, 8 }, // NEG | ||
2967 | { &opcode_ed_5d, 14 }, // RETN | ||
2968 | { &opcode_ed_5e, 8 }, // IM 2 | ||
2969 | { &opcode_ed_5f, 9 }, // LD A, R | ||
2970 | { &opcode_ed_60, 12 }, // IN H, (C) | ||
2971 | { &opcode_ed_61, 12 }, // OUT (C), H | ||
2972 | { &opcode_ed_62, 15 }, // SBC HL, HL | ||
2973 | { &opcode_ed_63, 20 }, // LD (nn), HL | ||
2974 | { &opcode_ed_64, 8 }, // NEG | ||
2975 | { &opcode_ed_65, 14 }, // RETN | ||
2976 | { &opcode_ed_66, 8 }, // IM 0 | ||
2977 | { &opcode_ed_67, 18 }, // RRD | ||
2978 | { &opcode_ed_68, 12 }, // IN L, (C) | ||
2979 | { &opcode_ed_69, 12 }, // OUT (C), L | ||
2980 | { &opcode_ed_6a, 15 }, // ADC HL, HL | ||
2981 | { &opcode_ed_6b, 20 }, // LD HL, (nn) | ||
2982 | { &opcode_ed_6c, 8 }, // NEG | ||
2983 | { &opcode_ed_6d, 14 }, // RETN | ||
2984 | { &opcode_ed_6e, 8 }, // IM 0/1 | ||
2985 | { &opcode_ed_6f, 18 }, // RLD | ||
2986 | { &opcode_ed_70, 12 }, // IN (C) / IN F, (C) | ||
2987 | { &opcode_ed_71, 12 }, // OUT (C), 0 | ||
2988 | { &opcode_ed_72, 15 }, // SBC HL, SP | ||
2989 | { &opcode_ed_73, 20 }, // LD (nn), SP | ||
2990 | { &opcode_ed_74, 8 }, // NEG | ||
2991 | { &opcode_ed_75, 14 }, // RETN | ||
2992 | { &opcode_ed_76, 8 }, // IM 1 | ||
2993 | { 0, 0 }, // 0x77 | ||
2994 | { &opcode_ed_78, 12 }, // IN A, (C) | ||
2995 | { &opcode_ed_79, 12 }, // OUT (C), A | ||
2996 | { &opcode_ed_7a, 15 }, // ADC HL, SP | ||
2997 | { &opcode_ed_7b, 20 }, // LD SP, (nn) | ||
2998 | { &opcode_ed_7c, 8 }, // NEG | ||
2999 | { &opcode_ed_7d, 14 }, // RETN | ||
3000 | { &opcode_ed_7e, 8 }, // IM 2 | ||
3001 | { 0, 0 }, // 0x7F | ||
3002 | { 0, 0 }, // 0x80 | ||
3003 | { 0, 0 }, // 0x81 | ||
3004 | { 0, 0 }, // 0x82 | ||
3005 | { 0, 0 }, // 0x83 | ||
3006 | { 0, 0 }, // 0x84 | ||
3007 | { 0, 0 }, // 0x85 | ||
3008 | { 0, 0 }, // 0x86 | ||
3009 | { 0, 0 }, // 0x87 | ||
3010 | { 0, 0 }, // 0x88 | ||
3011 | { 0, 0 }, // 0x89 | ||
3012 | { 0, 0 }, // 0x8A | ||
3013 | { 0, 0 }, // 0x8B | ||
3014 | { 0, 0 }, // 0x8C | ||
3015 | { 0, 0 }, // 0x8D | ||
3016 | { 0, 0 }, // 0x8E | ||
3017 | { 0, 0 }, // 0x8F | ||
3018 | { 0, 0 }, // 0x90 | ||
3019 | { 0, 0 }, // 0x91 | ||
3020 | { 0, 0 }, // 0x92 | ||
3021 | { 0, 0 }, // 0x93 | ||
3022 | { 0, 0 }, // 0x94 | ||
3023 | { 0, 0 }, // 0x95 | ||
3024 | { 0, 0 }, // 0x96 | ||
3025 | { 0, 0 }, // 0x97 | ||
3026 | { 0, 0 }, // 0x98 | ||
3027 | { 0, 0 }, // 0x99 | ||
3028 | { 0, 0 }, // 0x9A | ||
3029 | { 0, 0 }, // 0x9B | ||
3030 | { 0, 0 }, // 0x9C | ||
3031 | { 0, 0 }, // 0x9D | ||
3032 | { 0, 0 }, // 0x9E | ||
3033 | { 0, 0 }, // 0x9F | ||
3034 | { &opcode_ed_a0, 16 }, // LDI | ||
3035 | { &opcode_ed_a1, 16 }, // CPI | ||
3036 | { &opcode_ed_a2, 16 }, // INI | ||
3037 | { &opcode_ed_a3, 16 }, // OUTI | ||
3038 | { 0, 0 }, // 0xA4 | ||
3039 | { 0, 0 }, // 0xA5 | ||
3040 | { 0, 0 }, // 0xA6 | ||
3041 | { 0, 0 }, // 0xA7 | ||
3042 | { &opcode_ed_a8, 16 }, // LDD | ||
3043 | { &opcode_ed_a9, 16 }, // CPD | ||
3044 | { &opcode_ed_aa, 16 }, // IND | ||
3045 | { &opcode_ed_ab, 16 }, // OUTD | ||
3046 | { 0, 0 }, // 0xAC | ||
3047 | { 0, 0 }, // 0xAD | ||
3048 | { 0, 0 }, // 0xAE | ||
3049 | { 0, 0 }, // 0xAF | ||
3050 | { &opcode_ed_b0, 0 }, // LDIR | ||
3051 | { &opcode_ed_b1, 0 }, // CPIR | ||
3052 | { &opcode_ed_b2, 0 }, // INIR | ||
3053 | { &opcode_ed_b3, 0 }, // OTIR | ||
3054 | { 0, 0 }, // 0xB4 | ||
3055 | { 0, 0 }, // 0xB5 | ||
3056 | { 0, 0 }, // 0xB6 | ||
3057 | { 0, 0 }, // 0xB7 | ||
3058 | { &opcode_ed_b8, 0 }, // LDDR | ||
3059 | { &opcode_ed_b9, 0 }, // CPDR | ||
3060 | { &opcode_ed_ba, 0 }, // INDR | ||
3061 | { &opcode_ed_bb, 0 }, // OTDR | ||
3062 | { 0, 0 }, // 0xBC | ||
3063 | { 0, 0 }, // 0xBD | ||
3064 | { 0, 0 }, // 0xBE | ||
3065 | { 0, 0 }, // 0xBF | ||
3066 | { 0, 0 }, // 0xC0 | ||
3067 | { 0, 0 }, // 0xC1 | ||
3068 | { 0, 0 }, // 0xC2 | ||
3069 | { 0, 0 }, // 0xC3 | ||
3070 | { 0, 0 }, // 0xC4 | ||
3071 | { 0, 0 }, // 0xC5 | ||
3072 | { 0, 0 }, // 0xC6 | ||
3073 | { 0, 0 }, // 0xC7 | ||
3074 | { 0, 0 }, // 0xC8 | ||
3075 | { 0, 0 }, // 0xC9 | ||
3076 | { 0, 0 }, // 0xCA | ||
3077 | { 0, 0 }, // 0xCB | ||
3078 | { 0, 0 }, // 0xCC | ||
3079 | { 0, 0 }, // 0xCD | ||
3080 | { 0, 0 }, // 0xCE | ||
3081 | { 0, 0 }, // 0xCF | ||
3082 | { 0, 0 }, // 0xD0 | ||
3083 | { 0, 0 }, // 0xD1 | ||
3084 | { 0, 0 }, // 0xD2 | ||
3085 | { 0, 0 }, // 0xD3 | ||
3086 | { 0, 0 }, // 0xD4 | ||
3087 | { 0, 0 }, // 0xD5 | ||
3088 | { 0, 0 }, // 0xD6 | ||
3089 | { 0, 0 }, // 0xD7 | ||
3090 | { 0, 0 }, // 0xD8 | ||
3091 | { 0, 0 }, // 0xD9 | ||
3092 | { 0, 0 }, // 0xDA | ||
3093 | { 0, 0 }, // 0xDB | ||
3094 | { 0, 0 }, // 0xDC | ||
3095 | { 0, 0 }, // 0xDD | ||
3096 | { 0, 0 }, // 0xDE | ||
3097 | { 0, 0 }, // 0xDF | ||
3098 | { 0, 0 }, // 0xE0 | ||
3099 | { 0, 0 }, // 0xE1 | ||
3100 | { 0, 0 }, // 0xE2 | ||
3101 | { 0, 0 }, // 0xE3 | ||
3102 | { 0, 0 }, // 0xE4 | ||
3103 | { 0, 0 }, // 0xE5 | ||
3104 | { 0, 0 }, // 0xE6 | ||
3105 | { 0, 0 }, // 0xE7 | ||
3106 | { 0, 0 }, // 0xE8 | ||
3107 | { 0, 0 }, // 0xE9 | ||
3108 | { 0, 0 }, // 0xEA | ||
3109 | { 0, 0 }, // 0xEB | ||
3110 | { 0, 0 }, // 0xEC | ||
3111 | { 0, 0 }, // 0xED | ||
3112 | { 0, 0 }, // 0xEE | ||
3113 | { 0, 0 }, // 0xEF | ||
3114 | { 0, 0 }, // 0xF0 | ||
3115 | { 0, 0 }, // 0xF1 | ||
3116 | { 0, 0 }, // 0xF2 | ||
3117 | { 0, 0 }, // 0xF3 | ||
3118 | { 0, 0 }, // 0xF4 | ||
3119 | { 0, 0 }, // 0xF5 | ||
3120 | { 0, 0 }, // 0xF6 | ||
3121 | { 0, 0 }, // 0xF7 | ||
3122 | { 0, 0 }, // 0xF8 | ||
3123 | { 0, 0 }, // 0xF9 | ||
3124 | { 0, 0 }, // 0xFA | ||
3125 | { 0, 0 }, // 0xFB | ||
3126 | { 0, 0 }, // 0xFC | ||
3127 | { 0, 0 }, // 0xFD | ||
3128 | { 0, 0 }, // 0xFE | ||
3129 | { 0, 0 } // 0xFF | ||
3130 | }; | ||
3131 | |||
3132 | void opcode_ed_40() // IN B, (C) | ||
3133 | { | ||
3134 | B = inpReg(); | ||
3135 | } | ||
3136 | |||
3137 | void opcode_ed_41() // OUT (C), B | ||
3138 | { | ||
3139 | writePort( C, B ); | ||
3140 | } | ||
3141 | |||
3142 | void opcode_ed_42() // SBC HL, BC | ||
3143 | { | ||
3144 | unsigned char a; | ||
3145 | |||
3146 | a = A; | ||
3147 | A = L; L = subByte( C, F & Carry ); | ||
3148 | A = H; H = subByte( B, F & Carry ); | ||
3149 | A = a; | ||
3150 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3151 | } | ||
3152 | |||
3153 | void opcode_ed_43() // LD (nn), BC | ||
3154 | { | ||
3155 | unsigned addr = fetchWord(); | ||
3156 | |||
3157 | writeByte( addr, C ); | ||
3158 | writeByte( addr+1, B ); | ||
3159 | } | ||
3160 | |||
3161 | void opcode_ed_44() // NEG | ||
3162 | { | ||
3163 | unsigned char a = A; | ||
3164 | |||
3165 | A = 0; | ||
3166 | A = subByte( a, 0 ); | ||
3167 | } | ||
3168 | |||
3169 | void opcode_ed_45() // RETN | ||
3170 | { | ||
3171 | retFromSub(); | ||
3172 | iflags_ &= ~IFF1; | ||
3173 | if( iflags_ & IFF2 ) iflags_ |= IFF1; | ||
3174 | } | ||
3175 | |||
3176 | void opcode_ed_46() // IM 0 | ||
3177 | { | ||
3178 | setInterruptMode( 0 ); | ||
3179 | } | ||
3180 | |||
3181 | void opcode_ed_47() // LD I, A | ||
3182 | { | ||
3183 | I = A; | ||
3184 | } | ||
3185 | |||
3186 | void opcode_ed_48() // IN C, (C) | ||
3187 | { | ||
3188 | C = inpReg(); | ||
3189 | } | ||
3190 | |||
3191 | void opcode_ed_49() // OUT (C), C | ||
3192 | { | ||
3193 | writePort( C, C ); | ||
3194 | } | ||
3195 | |||
3196 | void opcode_ed_4a() // ADC HL, BC | ||
3197 | { | ||
3198 | unsigned char a; | ||
3199 | |||
3200 | a = A; | ||
3201 | A = L; addByte( C, F & Carry ); L = A; | ||
3202 | A = H; addByte( B, F & Carry ); H = A; | ||
3203 | A = a; | ||
3204 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3205 | } | ||
3206 | |||
3207 | void opcode_ed_4b() // LD BC, (nn) | ||
3208 | { | ||
3209 | unsigned addr = fetchWord(); | ||
3210 | |||
3211 | C = readByte( addr ); | ||
3212 | B = readByte( addr+1 ); | ||
3213 | } | ||
3214 | |||
3215 | void opcode_ed_4c() // NEG | ||
3216 | { | ||
3217 | opcode_ed_44(); | ||
3218 | } | ||
3219 | |||
3220 | void opcode_ed_4d() // RETI | ||
3221 | { | ||
3222 | retFromSub(); | ||
3223 | //onReturnFromInterrupt(); | ||
3224 | } | ||
3225 | |||
3226 | void opcode_ed_4e() // IM 0/1 | ||
3227 | { | ||
3228 | setInterruptMode( 0 ); | ||
3229 | } | ||
3230 | |||
3231 | void opcode_ed_4f() // LD R, A | ||
3232 | { | ||
3233 | R = A; | ||
3234 | } | ||
3235 | |||
3236 | void opcode_ed_50() // IN D, (C) | ||
3237 | { | ||
3238 | D = inpReg(); | ||
3239 | } | ||
3240 | |||
3241 | void opcode_ed_51() // OUT (C), D | ||
3242 | { | ||
3243 | writePort( C, D ); | ||
3244 | } | ||
3245 | |||
3246 | void opcode_ed_52() // SBC HL, DE | ||
3247 | { | ||
3248 | unsigned char a; | ||
3249 | |||
3250 | a = A; | ||
3251 | A = L; L = subByte( E, F & Carry ); | ||
3252 | A = H; H = subByte( D, F & Carry ); | ||
3253 | A = a; | ||
3254 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3255 | } | ||
3256 | |||
3257 | void opcode_ed_53() // LD (nn), DE | ||
3258 | { | ||
3259 | unsigned addr = fetchWord(); | ||
3260 | |||
3261 | writeByte( addr, E ); | ||
3262 | writeByte( addr+1, D ); | ||
3263 | } | ||
3264 | |||
3265 | void opcode_ed_54() // NEG | ||
3266 | { | ||
3267 | opcode_ed_44(); | ||
3268 | } | ||
3269 | |||
3270 | void opcode_ed_55() // RETN | ||
3271 | { | ||
3272 | opcode_ed_45(); | ||
3273 | } | ||
3274 | |||
3275 | void opcode_ed_56() // IM 1 | ||
3276 | { | ||
3277 | setInterruptMode( 1 ); | ||
3278 | } | ||
3279 | |||
3280 | void opcode_ed_57() // LD A, I | ||
3281 | { | ||
3282 | A = I; | ||
3283 | setFlags35PSZ(); | ||
3284 | F &= ~(Halfcarry | Parity | AddSub); | ||
3285 | if( iflags_ & IFF2 ) F |= Parity; | ||
3286 | } | ||
3287 | |||
3288 | void opcode_ed_58() // IN E, (C) | ||
3289 | { | ||
3290 | E = inpReg(); | ||
3291 | } | ||
3292 | |||
3293 | void opcode_ed_59() // OUT (C), E | ||
3294 | { | ||
3295 | writePort( C, E ); | ||
3296 | } | ||
3297 | |||
3298 | void opcode_ed_5a() // ADC HL, DE | ||
3299 | { | ||
3300 | unsigned char a; | ||
3301 | |||
3302 | a = A; | ||
3303 | A = L; addByte( E, F & Carry ); L = A; | ||
3304 | A = H; addByte( D, F & Carry ); H = A; | ||
3305 | A = a; | ||
3306 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3307 | } | ||
3308 | |||
3309 | void opcode_ed_5b() // LD DE, (nn) | ||
3310 | { | ||
3311 | unsigned addr = fetchWord(); | ||
3312 | |||
3313 | E = readByte( addr ); | ||
3314 | D = readByte( addr+1 ); | ||
3315 | } | ||
3316 | |||
3317 | void opcode_ed_5c() // NEG | ||
3318 | { | ||
3319 | opcode_ed_44(); | ||
3320 | } | ||
3321 | |||
3322 | void opcode_ed_5d() // RETN | ||
3323 | { | ||
3324 | opcode_ed_45(); | ||
3325 | } | ||
3326 | |||
3327 | void opcode_ed_5e() // IM 2 | ||
3328 | { | ||
3329 | setInterruptMode( 2 ); | ||
3330 | } | ||
3331 | |||
3332 | void opcode_ed_5f() // LD A, R | ||
3333 | { | ||
3334 | A = R; | ||
3335 | setFlags35PSZ(); | ||
3336 | F &= ~(Halfcarry | Parity | AddSub); | ||
3337 | if( iflags_ & IFF2 ) F |= Parity; | ||
3338 | } | ||
3339 | |||
3340 | void opcode_ed_60() // IN H, (C) | ||
3341 | { | ||
3342 | H = inpReg(); | ||
3343 | } | ||
3344 | |||
3345 | void opcode_ed_61() // OUT (C), H | ||
3346 | { | ||
3347 | writePort( C, H ); | ||
3348 | } | ||
3349 | |||
3350 | void opcode_ed_62() // SBC HL, HL | ||
3351 | { | ||
3352 | unsigned char a; | ||
3353 | |||
3354 | a = A; | ||
3355 | A = L; L = subByte( L, F & Carry ); | ||
3356 | A = H; H = subByte( H, F & Carry ); | ||
3357 | A = a; | ||
3358 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3359 | } | ||
3360 | |||
3361 | void opcode_ed_63() // LD (nn), HL | ||
3362 | { | ||
3363 | unsigned addr = fetchWord(); | ||
3364 | |||
3365 | writeByte( addr, L ); | ||
3366 | writeByte( addr+1, H ); | ||
3367 | } | ||
3368 | |||
3369 | void opcode_ed_64() // NEG | ||
3370 | { | ||
3371 | opcode_ed_44(); | ||
3372 | } | ||
3373 | |||
3374 | void opcode_ed_65() // RETN | ||
3375 | { | ||
3376 | opcode_ed_45(); | ||
3377 | } | ||
3378 | |||
3379 | void opcode_ed_66() // IM 0 | ||
3380 | { | ||
3381 | setInterruptMode( 0 ); | ||
3382 | } | ||
3383 | |||
3384 | void opcode_ed_67() // RRD | ||
3385 | { | ||
3386 | unsigned char x = readByte( HL() ); | ||
3387 | |||
3388 | writeByte( HL(), (A << 4) | (x >> 4) ); | ||
3389 | A = (A & 0xF0) | (x & 0x0F); | ||
3390 | setFlags35PSZ(); | ||
3391 | F &= ~(Halfcarry | AddSub); | ||
3392 | } | ||
3393 | |||
3394 | void opcode_ed_68() // IN L, (C) | ||
3395 | { | ||
3396 | L = inpReg(); | ||
3397 | } | ||
3398 | |||
3399 | void opcode_ed_69() // OUT (C), L | ||
3400 | { | ||
3401 | writePort( C, L ); | ||
3402 | } | ||
3403 | |||
3404 | void opcode_ed_6a() // ADC HL, HL | ||
3405 | { | ||
3406 | unsigned char a; | ||
3407 | |||
3408 | a = A; | ||
3409 | A = L; addByte( L, F & Carry ); L = A; | ||
3410 | A = H; addByte( H, F & Carry ); H = A; | ||
3411 | A = a; | ||
3412 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3413 | } | ||
3414 | |||
3415 | void opcode_ed_6b() // LD HL, (nn) | ||
3416 | { | ||
3417 | unsigned addr = fetchWord(); | ||
3418 | |||
3419 | L = readByte( addr ); | ||
3420 | H = readByte( addr+1 ); | ||
3421 | } | ||
3422 | |||
3423 | void opcode_ed_6c() // NEG | ||
3424 | { | ||
3425 | opcode_ed_44(); | ||
3426 | } | ||
3427 | |||
3428 | void opcode_ed_6d() // RETN | ||
3429 | { | ||
3430 | opcode_ed_45(); | ||
3431 | } | ||
3432 | |||
3433 | void opcode_ed_6e() // IM 0/1 | ||
3434 | { | ||
3435 | setInterruptMode( 0 ); | ||
3436 | } | ||
3437 | |||
3438 | void opcode_ed_6f() // RLD | ||
3439 | { | ||
3440 | unsigned char x = readByte( HL() ); | ||
3441 | |||
3442 | writeByte( HL(), (x << 4) | (A & 0x0F) ); | ||
3443 | A = (A & 0xF0) | (x >> 4); | ||
3444 | setFlags35PSZ(); | ||
3445 | F &= ~(Halfcarry | AddSub); | ||
3446 | } | ||
3447 | |||
3448 | void opcode_ed_70() // IN (C) / IN F, (C) | ||
3449 | { | ||
3450 | inpReg(); | ||
3451 | } | ||
3452 | |||
3453 | void opcode_ed_71() // OUT (C), 0 | ||
3454 | { | ||
3455 | writePort( C, 0 ); | ||
3456 | } | ||
3457 | |||
3458 | void opcode_ed_72() // SBC HL, SP | ||
3459 | { | ||
3460 | unsigned char a; | ||
3461 | |||
3462 | a = A; | ||
3463 | A = L; L = subByte( SP & 0xFF, F & Carry ); | ||
3464 | A = H; H = subByte( (SP >> 8) & 0xFF, F & Carry ); | ||
3465 | A = a; | ||
3466 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3467 | } | ||
3468 | |||
3469 | void opcode_ed_73() // LD (nn), SP | ||
3470 | { | ||
3471 | writeWord( fetchWord(), SP ); | ||
3472 | } | ||
3473 | |||
3474 | void opcode_ed_74() // NEG | ||
3475 | { | ||
3476 | opcode_ed_44(); | ||
3477 | } | ||
3478 | |||
3479 | void opcode_ed_75() // RETN | ||
3480 | { | ||
3481 | opcode_ed_45(); | ||
3482 | } | ||
3483 | |||
3484 | void opcode_ed_76() // IM 1 | ||
3485 | { | ||
3486 | setInterruptMode( 1 ); | ||
3487 | } | ||
3488 | |||
3489 | void opcode_ed_78() // IN A, (C) | ||
3490 | { | ||
3491 | A = inpReg(); | ||
3492 | } | ||
3493 | |||
3494 | void opcode_ed_79() // OUT (C), A | ||
3495 | { | ||
3496 | writePort( C, A ); | ||
3497 | } | ||
3498 | |||
3499 | void opcode_ed_7a() // ADC HL, SP | ||
3500 | { | ||
3501 | unsigned char a; | ||
3502 | |||
3503 | a = A; | ||
3504 | A = L; addByte( SP & 0xFF, F & Carry ); L = A; | ||
3505 | A = H; addByte( (SP >> 8) & 0xFF, F & Carry ); H = A; | ||
3506 | A = a; | ||
3507 | if( HL() == 0 ) F |= Zero; else F &= ~Zero; | ||
3508 | } | ||
3509 | |||
3510 | void opcode_ed_7b() // LD SP, (nn) | ||
3511 | { | ||
3512 | SP = readWord( fetchWord() ); | ||
3513 | } | ||
3514 | |||
3515 | void opcode_ed_7c() // NEG | ||
3516 | { | ||
3517 | opcode_ed_44(); | ||
3518 | } | ||
3519 | |||
3520 | void opcode_ed_7d() // RETN | ||
3521 | { | ||
3522 | opcode_ed_45(); | ||
3523 | } | ||
3524 | |||
3525 | void opcode_ed_7e() // IM 2 | ||
3526 | { | ||
3527 | setInterruptMode( 2 ); | ||
3528 | } | ||
3529 | |||
3530 | void opcode_ed_a0() // LDI | ||
3531 | { | ||
3532 | writeByte( DE(), readByte( HL() ) ); | ||
3533 | if( ++L == 0 ) ++H; // HL++ | ||
3534 | if( ++E == 0 ) ++D; // DE++ | ||
3535 | if( C-- == 0 ) --B; // BC-- | ||
3536 | F &= ~(Halfcarry | Subtraction | Parity); | ||
3537 | if( BC() ) F |= Parity; | ||
3538 | } | ||
3539 | |||
3540 | void opcode_ed_a1() // CPI | ||
3541 | { | ||
3542 | unsigned char f = F; | ||
3543 | |||
3544 | cmpByte( readByte( HL() ) ); | ||
3545 | if( ++L == 0 ) ++H; // HL++ | ||
3546 | if( C-- == 0 ) --B; // BC-- | ||
3547 | F = (F & ~(Carry | Parity)) | (f & Carry); | ||
3548 | if( BC() ) F |= Parity; | ||
3549 | } | ||
3550 | |||
3551 | void opcode_ed_a2() // INI | ||
3552 | { | ||
3553 | writeByte( HL(), readPort( C ) ); | ||
3554 | if( ++L == 0 ) ++H; // HL++ | ||
3555 | B = decByte( B ); | ||
3556 | } | ||
3557 | |||
3558 | void opcode_ed_a3() // OUTI | ||
3559 | { | ||
3560 | writePort( C, readByte( HL() ) ); | ||
3561 | if( ++L == 0 ) ++H; // HL++ | ||
3562 | B = decByte( B ); | ||
3563 | } | ||
3564 | |||
3565 | void opcode_ed_a8() // LDD | ||
3566 | { | ||
3567 | writeByte( DE(), readByte( HL() ) ); | ||
3568 | if( L-- == 0 ) --H; // HL-- | ||
3569 | if( E-- == 0 ) --D; // DE-- | ||
3570 | if( C-- == 0 ) --B; // BC-- | ||
3571 | F &= ~(Halfcarry | Subtraction | Parity); | ||
3572 | if( BC() ) F |= Parity; | ||
3573 | } | ||
3574 | |||
3575 | void opcode_ed_a9() // CPD | ||
3576 | { | ||
3577 | unsigned char f = F; | ||
3578 | |||
3579 | cmpByte( readByte( HL() ) ); | ||
3580 | if( L-- == 0 ) --H; // HL-- | ||
3581 | if( C-- == 0 ) --B; // BC-- | ||
3582 | F = (F & ~(Carry | Parity)) | (f & Carry); | ||
3583 | if( BC() ) F |= Parity; | ||
3584 | } | ||
3585 | |||
3586 | void opcode_ed_aa() // IND | ||
3587 | { | ||
3588 | writeByte( HL(), readPort( C ) ); | ||
3589 | if( L-- == 0 ) --H; // HL-- | ||
3590 | B = decByte( B ); | ||
3591 | } | ||
3592 | |||
3593 | void opcode_ed_ab() // OUTD | ||
3594 | { | ||
3595 | writePort( C, readByte( HL() ) ); | ||
3596 | if( L-- == 0 ) --H; // HL-- | ||
3597 | B = decByte( B ); | ||
3598 | } | ||
3599 | |||
3600 | void opcode_ed_b0() // LDIR | ||
3601 | { | ||
3602 | opcode_ed_a0(); // LDI | ||
3603 | if( F & Parity ) { // After LDI, the Parity flag will be zero when BC=0 | ||
3604 | cycles_ += 5; | ||
3605 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3606 | } | ||
3607 | } | ||
3608 | |||
3609 | void opcode_ed_b1() // CPIR | ||
3610 | { | ||
3611 | opcode_ed_a1(); // CPI | ||
3612 | if( (F & Parity) && !(F & Zero) ) { // Parity clear when BC=0, Zero set when A=(HL) | ||
3613 | cycles_ += 5; | ||
3614 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3615 | } | ||
3616 | } | ||
3617 | |||
3618 | void opcode_ed_b2() // INIR | ||
3619 | { | ||
3620 | opcode_ed_a2(); // INI | ||
3621 | if( B != 0 ) { | ||
3622 | cycles_ += 5; | ||
3623 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3624 | } | ||
3625 | } | ||
3626 | |||
3627 | void opcode_ed_b3() // OTIR | ||
3628 | { | ||
3629 | opcode_ed_a3(); // OUTI | ||
3630 | if( B != 0 ) { | ||
3631 | cycles_ += 5; | ||
3632 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3633 | } | ||
3634 | } | ||
3635 | |||
3636 | void opcode_ed_b8() // LDDR | ||
3637 | { | ||
3638 | opcode_ed_a8(); // LDD | ||
3639 | if( F & Parity ) { // After LDD, the Parity flag will be zero when BC=0 | ||
3640 | cycles_ += 5; | ||
3641 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3642 | } | ||
3643 | } | ||
3644 | |||
3645 | void opcode_ed_b9() // CPDR | ||
3646 | { | ||
3647 | opcode_ed_a9(); // CPD | ||
3648 | if( (F & Parity) && !(F & Zero) ) { // Parity clear when BC=0, Zero set when A=(HL) | ||
3649 | cycles_ += 5; | ||
3650 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3651 | } | ||
3652 | } | ||
3653 | |||
3654 | void opcode_ed_ba() // INDR | ||
3655 | { | ||
3656 | opcode_ed_aa(); // IND | ||
3657 | if( B != 0 ) { | ||
3658 | cycles_ += 5; | ||
3659 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3660 | } | ||
3661 | } | ||
3662 | |||
3663 | void opcode_ed_bb() // OTDR | ||
3664 | { | ||
3665 | opcode_ed_ab(); // OUTD | ||
3666 | if( B != 0 ) { | ||
3667 | cycles_ += 5; | ||
3668 | PC -= 2; // Decrement PC so that instruction is re-executed at next step (this allows interrupts to occur) | ||
3669 | } | ||
3670 | } | ||
3671 | |||
3672 | OpcodeInfo OpInfoFD_[256] = { | ||
3673 | { 0, 0 }, // 0x00 | ||
3674 | { 0, 0 }, // 0x01 | ||
3675 | { 0, 0 }, // 0x02 | ||
3676 | { 0, 0 }, // 0x03 | ||
3677 | { 0, 0 }, // 0x04 | ||
3678 | { 0, 0 }, // 0x05 | ||
3679 | { 0, 0 }, // 0x06 | ||
3680 | { 0, 0 }, // 0x07 | ||
3681 | { 0, 0 }, // 0x08 | ||
3682 | { &opcode_fd_09, 15 }, // ADD IY, BC | ||
3683 | { 0, 0 }, // 0x0A | ||
3684 | { 0, 0 }, // 0x0B | ||
3685 | { 0, 0 }, // 0x0C | ||
3686 | { 0, 0 }, // 0x0D | ||
3687 | { 0, 0 }, // 0x0E | ||
3688 | { 0, 0 }, // 0x0F | ||
3689 | { 0, 0 }, // 0x10 | ||
3690 | { 0, 0 }, // 0x11 | ||
3691 | { 0, 0 }, // 0x12 | ||
3692 | { 0, 0 }, // 0x13 | ||
3693 | { 0, 0 }, // 0x14 | ||
3694 | { 0, 0 }, // 0x15 | ||
3695 | { 0, 0 }, // 0x16 | ||
3696 | { 0, 0 }, // 0x17 | ||
3697 | { 0, 0 }, // 0x18 | ||
3698 | { &opcode_fd_19, 15 }, // ADD IY, DE | ||
3699 | { 0, 0 }, // 0x1A | ||
3700 | { 0, 0 }, // 0x1B | ||
3701 | { 0, 0 }, // 0x1C | ||
3702 | { 0, 0 }, // 0x1D | ||
3703 | { 0, 0 }, // 0x1E | ||
3704 | { 0, 0 }, // 0x1F | ||
3705 | { 0, 0 }, // 0x20 | ||
3706 | { &opcode_fd_21, 14 }, // LD IY, nn | ||
3707 | { &opcode_fd_22, 20 }, // LD (nn), IY | ||
3708 | { &opcode_fd_23, 10 }, // INC IY | ||
3709 | { &opcode_fd_24, 9 }, // INC IYH | ||
3710 | { &opcode_fd_25, 9 }, // DEC IYH | ||
3711 | { &opcode_fd_26, 9 }, // LD IYH, n | ||
3712 | { 0, 0 }, // 0x27 | ||
3713 | { 0, 0 }, // 0x28 | ||
3714 | { &opcode_fd_29, 15 }, // ADD IY, IY | ||
3715 | { &opcode_fd_2a, 20 }, // LD IY, (nn) | ||
3716 | { &opcode_fd_2b, 10 }, // DEC IY | ||
3717 | { &opcode_fd_2c, 9 }, // INC IYL | ||
3718 | { &opcode_fd_2d, 9 }, // DEC IYL | ||
3719 | { &opcode_fd_2e, 9 }, // LD IYL, n | ||
3720 | { 0, 0 }, // 0x2F | ||
3721 | { 0, 0 }, // 0x30 | ||
3722 | { 0, 0 }, // 0x31 | ||
3723 | { 0, 0 }, // 0x32 | ||
3724 | { 0, 0 }, // 0x33 | ||
3725 | { &opcode_fd_34, 23 }, // INC (IY + d) | ||
3726 | { &opcode_fd_35, 23 }, // DEC (IY + d) | ||
3727 | { &opcode_fd_36, 19 }, // LD (IY + d), n | ||
3728 | { 0, 0 }, // 0x37 | ||
3729 | { 0, 0 }, // 0x38 | ||
3730 | { &opcode_fd_39, 15 }, // ADD IY, SP | ||
3731 | { 0, 0 }, // 0x3A | ||
3732 | { 0, 0 }, // 0x3B | ||
3733 | { 0, 0 }, // 0x3C | ||
3734 | { 0, 0 }, // 0x3D | ||
3735 | { 0, 0 }, // 0x3E | ||
3736 | { 0, 0 }, // 0x3F | ||
3737 | { 0, 0 }, // 0x40 | ||
3738 | { 0, 0 }, // 0x41 | ||
3739 | { 0, 0 }, // 0x42 | ||
3740 | { 0, 0 }, // 0x43 | ||
3741 | { &opcode_fd_44, 9 }, // LD B, IYH | ||
3742 | { &opcode_fd_45, 9 }, // LD B, IYL | ||
3743 | { &opcode_fd_46, 19 }, // LD B, (IY + d) | ||
3744 | { 0, 0 }, // 0x47 | ||
3745 | { 0, 0 }, // 0x48 | ||
3746 | { 0, 0 }, // 0x49 | ||
3747 | { 0, 0 }, // 0x4A | ||
3748 | { 0, 0 }, // 0x4B | ||
3749 | { &opcode_fd_4c, 9 }, // LD C, IYH | ||
3750 | { &opcode_fd_4d, 9 }, // LD C, IYL | ||
3751 | { &opcode_fd_4e, 19 }, // LD C, (IY + d) | ||
3752 | { 0, 0 }, // 0x4F | ||
3753 | { 0, 0 }, // 0x50 | ||
3754 | { 0, 0 }, // 0x51 | ||
3755 | { 0, 0 }, // 0x52 | ||
3756 | { 0, 0 }, // 0x53 | ||
3757 | { &opcode_fd_54, 9 }, // LD D, IYH | ||
3758 | { &opcode_fd_55, 9 }, // LD D, IYL | ||
3759 | { &opcode_fd_56, 19 }, // LD D, (IY + d) | ||
3760 | { 0, 0 }, // 0x57 | ||
3761 | { 0, 0 }, // 0x58 | ||
3762 | { 0, 0 }, // 0x59 | ||
3763 | { 0, 0 }, // 0x5A | ||
3764 | { 0, 0 }, // 0x5B | ||
3765 | { &opcode_fd_5c, 9 }, // LD E, IYH | ||
3766 | { &opcode_fd_5d, 9 }, // LD E, IYL | ||
3767 | { &opcode_fd_5e, 19 }, // LD E, (IY + d) | ||
3768 | { 0, 0 }, // 0x5F | ||
3769 | { &opcode_fd_60, 9 }, // LD IYH, B | ||
3770 | { &opcode_fd_61, 9 }, // LD IYH, C | ||
3771 | { &opcode_fd_62, 9 }, // LD IYH, D | ||
3772 | { &opcode_fd_63, 9 }, // LD IYH, E | ||
3773 | { &opcode_fd_64, 9 }, // LD IYH, IYH | ||
3774 | { &opcode_fd_65, 9 }, // LD IYH, IYL | ||
3775 | { &opcode_fd_66, 9 }, // LD H, (IY + d) | ||
3776 | { &opcode_fd_67, 9 }, // LD IYH, A | ||
3777 | { &opcode_fd_68, 9 }, // LD IYL, B | ||
3778 | { &opcode_fd_69, 9 }, // LD IYL, C | ||
3779 | { &opcode_fd_6a, 9 }, // LD IYL, D | ||
3780 | { &opcode_fd_6b, 9 }, // LD IYL, E | ||
3781 | { &opcode_fd_6c, 9 }, // LD IYL, IYH | ||
3782 | { &opcode_fd_6d, 9 }, // LD IYL, IYL | ||
3783 | { &opcode_fd_6e, 9 }, // LD L, (IY + d) | ||
3784 | { &opcode_fd_6f, 9 }, // LD IYL, A | ||
3785 | { &opcode_fd_70, 19 }, // LD (IY + d), B | ||
3786 | { &opcode_fd_71, 19 }, // LD (IY + d), C | ||
3787 | { &opcode_fd_72, 19 }, // LD (IY + d), D | ||
3788 | { &opcode_fd_73, 19 }, // LD (IY + d), E | ||
3789 | { &opcode_fd_74, 19 }, // LD (IY + d), H | ||
3790 | { &opcode_fd_75, 19 }, // LD (IY + d), L | ||
3791 | { 0,19 }, // 0x76 | ||
3792 | { &opcode_fd_77, 19 }, // LD (IY + d), A | ||
3793 | { 0, 0 }, // 0x78 | ||
3794 | { 0, 0 }, // 0x79 | ||
3795 | { 0, 0 }, // 0x7A | ||
3796 | { 0, 0 }, // 0x7B | ||
3797 | { &opcode_fd_7c, 9 }, // LD A, IYH | ||
3798 | { &opcode_fd_7d, 9 }, // LD A, IYL | ||
3799 | { &opcode_fd_7e, 19 }, // LD A, (IY + d) | ||
3800 | { 0, 0 }, // 0x7F | ||
3801 | { 0, 0 }, // 0x80 | ||
3802 | { 0, 0 }, // 0x81 | ||
3803 | { 0, 0 }, // 0x82 | ||
3804 | { 0, 0 }, // 0x83 | ||
3805 | { &opcode_fd_84, 9 }, // ADD A, IYH | ||
3806 | { &opcode_fd_85, 9 }, // ADD A, IYL | ||
3807 | { &opcode_fd_86, 19 }, // ADD A, (IY + d) | ||
3808 | { 0, 0 }, // 0x87 | ||
3809 | { 0, 0 }, // 0x88 | ||
3810 | { 0, 0 }, // 0x89 | ||
3811 | { 0, 0 }, // 0x8A | ||
3812 | { 0, 0 }, // 0x8B | ||
3813 | { &opcode_fd_8c, 9 }, // ADC A, IYH | ||
3814 | { &opcode_fd_8d, 9 }, // ADC A, IYL | ||
3815 | { &opcode_fd_8e, 19 }, // ADC A, (IY + d) | ||
3816 | { 0, 0 }, // 0x8F | ||
3817 | { 0, 0 }, // 0x90 | ||
3818 | { 0, 0 }, // 0x91 | ||
3819 | { 0, 0 }, // 0x92 | ||
3820 | { 0, 0 }, // 0x93 | ||
3821 | { &opcode_fd_94, 9 }, // SUB IYH | ||
3822 | { &opcode_fd_95, 9 }, // SUB IYL | ||
3823 | { &opcode_fd_96, 19 }, // SUB (IY + d) | ||
3824 | { 0, 0 }, // 0x97 | ||
3825 | { 0, 0 }, // 0x98 | ||
3826 | { 0, 0 }, // 0x99 | ||
3827 | { 0, 0 }, // 0x9A | ||
3828 | { 0, 0 }, // 0x9B | ||
3829 | { &opcode_fd_9c, 9 }, // SBC A, IYH | ||
3830 | { &opcode_fd_9d, 9 }, // SBC A, IYL | ||
3831 | { &opcode_fd_9e, 19 }, // SBC A, (IY + d) | ||
3832 | { 0, 0 }, // 0x9F | ||
3833 | { 0, 0 }, // 0xA0 | ||
3834 | { 0, 0 }, // 0xA1 | ||
3835 | { 0, 0 }, // 0xA2 | ||
3836 | { 0, 0 }, // 0xA3 | ||
3837 | { &opcode_fd_a4, 9 }, // AND IYH | ||
3838 | { &opcode_fd_a5, 9 }, // AND IYL | ||
3839 | { &opcode_fd_a6, 19 }, // AND (IY + d) | ||
3840 | { 0, 0 }, // 0xA7 | ||
3841 | { 0, 0 }, // 0xA8 | ||
3842 | { 0, 0 }, // 0xA9 | ||
3843 | { 0, 0 }, // 0xAA | ||
3844 | { 0, 0 }, // 0xAB | ||
3845 | { &opcode_fd_ac, 9 }, // XOR IYH | ||
3846 | { &opcode_fd_ad, 9 }, // XOR IYL | ||
3847 | { &opcode_fd_ae, 19 }, // XOR (IY + d) | ||
3848 | { 0, 0 }, // 0xAF | ||
3849 | { 0, 0 }, // 0xB0 | ||
3850 | { 0, 0 }, // 0xB1 | ||
3851 | { 0, 0 }, // 0xB2 | ||
3852 | { 0, 0 }, // 0xB3 | ||
3853 | { &opcode_fd_b4, 9 }, // OR IYH | ||
3854 | { &opcode_fd_b5, 9 }, // OR IYL | ||
3855 | { &opcode_fd_b6, 19 }, // OR (IY + d) | ||
3856 | { 0, 0 }, // 0xB7 | ||
3857 | { 0, 0 }, // 0xB8 | ||
3858 | { 0, 0 }, // 0xB9 | ||
3859 | { 0, 0 }, // 0xBA | ||
3860 | { 0, 0 }, // 0xBB | ||
3861 | { &opcode_fd_bc, 9 }, // CP IYH | ||
3862 | { &opcode_fd_bd, 9 }, // CP IYL | ||
3863 | { &opcode_fd_be, 19 }, // CP (IY + d) | ||
3864 | { 0, 0 }, // 0xBF | ||
3865 | { 0, 0 }, // 0xC0 | ||
3866 | { 0, 0 }, // 0xC1 | ||
3867 | { 0, 0 }, // 0xC2 | ||
3868 | { 0, 0 }, // 0xC3 | ||
3869 | { 0, 0 }, // 0xC4 | ||
3870 | { 0, 0 }, // 0xC5 | ||
3871 | { 0, 0 }, // 0xC6 | ||
3872 | { 0, 0 }, // 0xC7 | ||
3873 | { 0, 0 }, // 0xC8 | ||
3874 | { 0, 0 }, // 0xC9 | ||
3875 | { 0, 0 }, // 0xCA | ||
3876 | { &opcode_fd_cb, 0 }, // | ||
3877 | { 0, 0 }, // 0xCC | ||
3878 | { 0, 0 }, // 0xCD | ||
3879 | { 0, 0 }, // 0xCE | ||
3880 | { 0, 0 }, // 0xCF | ||
3881 | { 0, 0 }, // 0xD0 | ||
3882 | { 0, 0 }, // 0xD1 | ||
3883 | { 0, 0 }, // 0xD2 | ||
3884 | { 0, 0 }, // 0xD3 | ||
3885 | { 0, 0 }, // 0xD4 | ||
3886 | { 0, 0 }, // 0xD5 | ||
3887 | { 0, 0 }, // 0xD6 | ||
3888 | { 0, 0 }, // 0xD7 | ||
3889 | { 0, 0 }, // 0xD8 | ||
3890 | { 0, 0 }, // 0xD9 | ||
3891 | { 0, 0 }, // 0xDA | ||
3892 | { 0, 0 }, // 0xDB | ||
3893 | { 0, 0 }, // 0xDC | ||
3894 | { 0, 0 }, // 0xDD | ||
3895 | { 0, 0 }, // 0xDE | ||
3896 | { 0, 0 }, // 0xDF | ||
3897 | { 0, 0 }, // 0xE0 | ||
3898 | { &opcode_fd_e1, 14 }, // POP IY | ||
3899 | { 0, 0 }, // 0xE2 | ||
3900 | { &opcode_fd_e3, 23 }, // EX (SP), IY | ||
3901 | { 0, 0 }, // 0xE4 | ||
3902 | { &opcode_fd_e5, 15 }, // PUSH IY | ||
3903 | { 0, 0 }, // 0xE6 | ||
3904 | { 0, 0 }, // 0xE7 | ||
3905 | { 0, 0 }, // 0xE8 | ||
3906 | { &opcode_fd_e9, 8 }, // JP (IY) | ||
3907 | { 0, 0 }, // 0xEA | ||
3908 | { 0, 0 }, // 0xEB | ||
3909 | { 0, 0 }, // 0xEC | ||
3910 | { 0, 0 }, // 0xED | ||
3911 | { 0, 0 }, // 0xEE | ||
3912 | { 0, 0 }, // 0xEF | ||
3913 | { 0, 0 }, // 0xF0 | ||
3914 | { 0, 0 }, // 0xF1 | ||
3915 | { 0, 0 }, // 0xF2 | ||
3916 | { 0, 0 }, // 0xF3 | ||
3917 | { 0, 0 }, // 0xF4 | ||
3918 | { 0, 0 }, // 0xF5 | ||
3919 | { 0, 0 }, // 0xF6 | ||
3920 | { 0, 0 }, // 0xF7 | ||
3921 | { 0, 0 }, // 0xF8 | ||
3922 | { &opcode_fd_f9, 10 }, // LD SP, IY | ||
3923 | { 0, 0 }, // 0xFA | ||
3924 | { 0, 0 }, // 0xFB | ||
3925 | { 0, 0 }, // 0xFC | ||
3926 | { 0, 0 }, // 0xFD | ||
3927 | { 0, 0 }, // 0xFE | ||
3928 | { 0, 0 } // 0xFF | ||
3929 | }; | ||
3930 | |||
3931 | void opcode_fd_09() // ADD IY, BC | ||
3932 | { | ||
3933 | unsigned rr = BC(); | ||
3934 | |||
3935 | F &= (Zero | Sign | Parity); | ||
3936 | if( ((IY & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
3937 | IY += rr; | ||
3938 | if( IY & 0x10000 ) F |= Carry; | ||
3939 | } | ||
3940 | |||
3941 | void opcode_fd_19() // ADD IY, DE | ||
3942 | { | ||
3943 | unsigned rr = DE(); | ||
3944 | |||
3945 | F &= (Zero | Sign | Parity); | ||
3946 | if( ((IY & 0xFFF)+(rr & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
3947 | IY += rr; | ||
3948 | if( IY & 0x10000 ) F |= Carry; | ||
3949 | } | ||
3950 | |||
3951 | void opcode_fd_21() // LD IY, nn | ||
3952 | { | ||
3953 | IY = fetchWord(); | ||
3954 | } | ||
3955 | |||
3956 | void opcode_fd_22() // LD (nn), IY | ||
3957 | { | ||
3958 | writeWord( fetchWord(), IY ); | ||
3959 | } | ||
3960 | |||
3961 | void opcode_fd_23() // INC IY | ||
3962 | { | ||
3963 | IY++; | ||
3964 | } | ||
3965 | |||
3966 | void opcode_fd_24() // INC IYH | ||
3967 | { | ||
3968 | IY = (IY & 0xFF) | ((unsigned)incByte( IY >> 8 ) << 8); | ||
3969 | } | ||
3970 | |||
3971 | void opcode_fd_25() // DEC IYH | ||
3972 | { | ||
3973 | IY = (IY & 0xFF) | ((unsigned)decByte( IY >> 8 ) << 8); | ||
3974 | } | ||
3975 | |||
3976 | void opcode_fd_26() // LD IYH, n | ||
3977 | { | ||
3978 | IY = (IY & 0xFF) | ((unsigned)fetchByte() << 8); | ||
3979 | } | ||
3980 | |||
3981 | void opcode_fd_29() // ADD IY, IY | ||
3982 | { | ||
3983 | F &= (Zero | Sign | Parity); | ||
3984 | if( IY & 0x800 ) F |= Halfcarry; | ||
3985 | IY += IY; | ||
3986 | if( IY & 0x10000 ) F |= Carry; | ||
3987 | } | ||
3988 | |||
3989 | void opcode_fd_2a() // LD IY, (nn) | ||
3990 | { | ||
3991 | IY = readWord( fetchWord() ); | ||
3992 | } | ||
3993 | |||
3994 | void opcode_fd_2b() // DEC IY | ||
3995 | { | ||
3996 | IY--; | ||
3997 | } | ||
3998 | |||
3999 | void opcode_fd_2c() // INC IYL | ||
4000 | { | ||
4001 | IY = (IY & 0xFF00) | incByte( IY & 0xFF ); | ||
4002 | } | ||
4003 | |||
4004 | void opcode_fd_2d() // DEC IYL | ||
4005 | { | ||
4006 | IY = (IY & 0xFF00) | decByte( IY & 0xFF ); | ||
4007 | } | ||
4008 | |||
4009 | void opcode_fd_2e() // LD IYL, n | ||
4010 | { | ||
4011 | IY = (IY & 0xFF00) | fetchByte(); | ||
4012 | } | ||
4013 | |||
4014 | void opcode_fd_34() // INC (IY + d) | ||
4015 | { | ||
4016 | unsigned addr = addDispl( IY, fetchByte() ); | ||
4017 | |||
4018 | writeByte( addr, incByte( readByte( addr ) ) ); | ||
4019 | } | ||
4020 | |||
4021 | void opcode_fd_35() // DEC (IY + d) | ||
4022 | { | ||
4023 | unsigned addr = addDispl( IY, fetchByte() ); | ||
4024 | |||
4025 | writeByte( addr, decByte( readByte( addr ) ) ); | ||
4026 | } | ||
4027 | |||
4028 | void opcode_fd_36() // LD (IY + d), n | ||
4029 | { | ||
4030 | unsigned addr = addDispl( IY, fetchByte() ); | ||
4031 | |||
4032 | writeByte( addr, fetchByte() ); | ||
4033 | } | ||
4034 | |||
4035 | void opcode_fd_39() // ADD IY, SP | ||
4036 | { | ||
4037 | F &= (Zero | Sign | Parity); | ||
4038 | if( ((IY & 0xFFF)+(SP & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
4039 | IY += SP; | ||
4040 | if( IY & 0x10000 ) F |= Carry; | ||
4041 | } | ||
4042 | |||
4043 | void opcode_fd_44() // LD B, IYH | ||
4044 | { | ||
4045 | B = IY >> 8; | ||
4046 | } | ||
4047 | |||
4048 | void opcode_fd_45() // LD B, IYL | ||
4049 | { | ||
4050 | B = IY & 0xFF; | ||
4051 | } | ||
4052 | |||
4053 | void opcode_fd_46() // LD B, (IY + d) | ||
4054 | { | ||
4055 | B = readByte( addDispl(IY,fetchByte()) ); | ||
4056 | } | ||
4057 | |||
4058 | void opcode_fd_4c() // LD C, IYH | ||
4059 | { | ||
4060 | C = IY >> 8; | ||
4061 | } | ||
4062 | |||
4063 | void opcode_fd_4d() // LD C, IYL | ||
4064 | { | ||
4065 | C = IY & 0xFF; | ||
4066 | } | ||
4067 | |||
4068 | void opcode_fd_4e() // LD C, (IY + d) | ||
4069 | { | ||
4070 | C = readByte( addDispl(IY,fetchByte()) ); | ||
4071 | } | ||
4072 | |||
4073 | void opcode_fd_54() // LD D, IYH | ||
4074 | { | ||
4075 | D = IY >> 8; | ||
4076 | } | ||
4077 | |||
4078 | void opcode_fd_55() // LD D, IYL | ||
4079 | { | ||
4080 | D = IY & 0xFF; | ||
4081 | } | ||
4082 | |||
4083 | void opcode_fd_56() // LD D, (IY + d) | ||
4084 | { | ||
4085 | D = readByte( addDispl(IY,fetchByte()) ); | ||
4086 | } | ||
4087 | |||
4088 | void opcode_fd_5c() // LD E, IYH | ||
4089 | { | ||
4090 | E = IY >> 8; | ||
4091 | } | ||
4092 | |||
4093 | void opcode_fd_5d() // LD E, IYL | ||
4094 | { | ||
4095 | E = IY & 0xFF; | ||
4096 | } | ||
4097 | |||
4098 | void opcode_fd_5e() // LD E, (IY + d) | ||
4099 | { | ||
4100 | E = readByte( addDispl(IY,fetchByte()) ); | ||
4101 | } | ||
4102 | |||
4103 | void opcode_fd_60() // LD IYH, B | ||
4104 | { | ||
4105 | IY = (IY & 0xFF) | ((unsigned)B << 8); | ||
4106 | } | ||
4107 | |||
4108 | void opcode_fd_61() // LD IYH, C | ||
4109 | { | ||
4110 | IY = (IY & 0xFF) | ((unsigned)C << 8); | ||
4111 | } | ||
4112 | |||
4113 | void opcode_fd_62() // LD IYH, D | ||
4114 | { | ||
4115 | IY = (IY & 0xFF) | ((unsigned)D << 8); | ||
4116 | } | ||
4117 | |||
4118 | void opcode_fd_63() // LD IYH, E | ||
4119 | { | ||
4120 | IY = (IY & 0xFF) | ((unsigned)E << 8); | ||
4121 | } | ||
4122 | |||
4123 | void opcode_fd_64() // LD IYH, IYH | ||
4124 | { | ||
4125 | } | ||
4126 | |||
4127 | void opcode_fd_65() // LD IYH, IYL | ||
4128 | { | ||
4129 | IY = (IY & 0xFF) | ((IY << 8) & 0xFF00); | ||
4130 | } | ||
4131 | |||
4132 | void opcode_fd_66() // LD H, (IY + d) | ||
4133 | { | ||
4134 | H = readByte( addDispl(IY,fetchByte()) ); | ||
4135 | } | ||
4136 | |||
4137 | void opcode_fd_67() // LD IYH, A | ||
4138 | { | ||
4139 | IY = (IY & 0xFF) | ((unsigned)A << 8); | ||
4140 | } | ||
4141 | |||
4142 | void opcode_fd_68() // LD IYL, B | ||
4143 | { | ||
4144 | IY = (IY & 0xFF00) | B; | ||
4145 | } | ||
4146 | |||
4147 | void opcode_fd_69() // LD IYL, C | ||
4148 | { | ||
4149 | IY = (IY & 0xFF00) | C; | ||
4150 | } | ||
4151 | |||
4152 | void opcode_fd_6a() // LD IYL, D | ||
4153 | { | ||
4154 | IY = (IY & 0xFF00) | D; | ||
4155 | } | ||
4156 | |||
4157 | void opcode_fd_6b() // LD IYL, E | ||
4158 | { | ||
4159 | IY = (IY & 0xFF00) | E; | ||
4160 | } | ||
4161 | |||
4162 | void opcode_fd_6c() // LD IYL, IYH | ||
4163 | { | ||
4164 | IY = (IY & 0xFF00) | ((IY >> 8) & 0xFF); | ||
4165 | } | ||
4166 | |||
4167 | void opcode_fd_6d() // LD IYL, IYL | ||
4168 | { | ||
4169 | } | ||
4170 | |||
4171 | void opcode_fd_6e() // LD L, (IY + d) | ||
4172 | { | ||
4173 | L = readByte( addDispl(IY,fetchByte()) ); | ||
4174 | } | ||
4175 | |||
4176 | void opcode_fd_6f() // LD IYL, A | ||
4177 | { | ||
4178 | IY = (IY & 0xFF00) | A; | ||
4179 | } | ||
4180 | |||
4181 | void opcode_fd_70() // LD (IY + d), B | ||
4182 | { | ||
4183 | writeByte( addDispl(IY,fetchByte()), B ); | ||
4184 | } | ||
4185 | |||
4186 | void opcode_fd_71() // LD (IY + d), C | ||
4187 | { | ||
4188 | writeByte( addDispl(IY,fetchByte()), C ); | ||
4189 | } | ||
4190 | |||
4191 | void opcode_fd_72() // LD (IY + d), D | ||
4192 | { | ||
4193 | writeByte( addDispl(IY,fetchByte()), D ); | ||
4194 | } | ||
4195 | |||
4196 | void opcode_fd_73() // LD (IY + d), E | ||
4197 | { | ||
4198 | writeByte( addDispl(IY,fetchByte()), E ); | ||
4199 | } | ||
4200 | |||
4201 | void opcode_fd_74() // LD (IY + d), H | ||
4202 | { | ||
4203 | writeByte( addDispl(IY,fetchByte()), H ); | ||
4204 | } | ||
4205 | |||
4206 | void opcode_fd_75() // LD (IY + d), L | ||
4207 | { | ||
4208 | writeByte( addDispl(IY,fetchByte()), L ); | ||
4209 | } | ||
4210 | |||
4211 | void opcode_fd_77() // LD (IY + d), A | ||
4212 | { | ||
4213 | writeByte( addDispl(IY,fetchByte()), A ); | ||
4214 | } | ||
4215 | |||
4216 | void opcode_fd_7c() // LD A, IYH | ||
4217 | { | ||
4218 | A = IY >> 8; | ||
4219 | } | ||
4220 | |||
4221 | void opcode_fd_7d() // LD A, IYL | ||
4222 | { | ||
4223 | A = IY & 0xFF; | ||
4224 | } | ||
4225 | |||
4226 | void opcode_fd_7e() // LD A, (IY + d) | ||
4227 | { | ||
4228 | A = readByte( addDispl(IY,fetchByte()) ); | ||
4229 | } | ||
4230 | |||
4231 | void opcode_fd_84() // ADD A, IYH | ||
4232 | { | ||
4233 | addByte( IY >> 8, 0 ); | ||
4234 | } | ||
4235 | |||
4236 | void opcode_fd_85() // ADD A, IYL | ||
4237 | { | ||
4238 | addByte( IY & 0xFF, 0 ); | ||
4239 | } | ||
4240 | |||
4241 | void opcode_fd_86() // ADD A, (IY + d) | ||
4242 | { | ||
4243 | addByte( readByte( addDispl(IY,fetchByte()) ), 0 ); | ||
4244 | } | ||
4245 | |||
4246 | void opcode_fd_8c() // ADC A, IYH | ||
4247 | { | ||
4248 | addByte( IY >> 8, F & Carry ); | ||
4249 | } | ||
4250 | |||
4251 | void opcode_fd_8d() // ADC A, IYL | ||
4252 | { | ||
4253 | addByte( IY & 0xFF, F & Carry ); | ||
4254 | } | ||
4255 | |||
4256 | void opcode_fd_8e() // ADC A, (IY + d) | ||
4257 | { | ||
4258 | addByte( readByte( addDispl(IY,fetchByte()) ), F & Carry ); | ||
4259 | } | ||
4260 | |||
4261 | void opcode_fd_94() // SUB IYH | ||
4262 | { | ||
4263 | A = subByte( IY >> 8, 0 ); | ||
4264 | } | ||
4265 | |||
4266 | void opcode_fd_95() // SUB IYL | ||
4267 | { | ||
4268 | A = subByte( IY & 0xFF, 0 ); | ||
4269 | } | ||
4270 | |||
4271 | void opcode_fd_96() // SUB (IY + d) | ||
4272 | { | ||
4273 | A = subByte( readByte( addDispl(IY,fetchByte()) ), 0 ); | ||
4274 | } | ||
4275 | |||
4276 | void opcode_fd_9c() // SBC A, IYH | ||
4277 | { | ||
4278 | A = subByte( IY >> 8, F & Carry ); | ||
4279 | } | ||
4280 | |||
4281 | void opcode_fd_9d() // SBC A, IYL | ||
4282 | { | ||
4283 | A = subByte( IY & 0xFF, F & Carry ); | ||
4284 | } | ||
4285 | |||
4286 | void opcode_fd_9e() // SBC A, (IY + d) | ||
4287 | { | ||
4288 | A = subByte( readByte( addDispl(IY,fetchByte()) ), F & Carry ); | ||
4289 | } | ||
4290 | |||
4291 | void opcode_fd_a4() // AND IYH | ||
4292 | { | ||
4293 | A &= IY >> 8; | ||
4294 | setFlags35PSZ000(); | ||
4295 | F |= Halfcarry; | ||
4296 | } | ||
4297 | |||
4298 | void opcode_fd_a5() // AND IYL | ||
4299 | { | ||
4300 | A &= IY & 0xFF; | ||
4301 | setFlags35PSZ000(); | ||
4302 | F |= Halfcarry; | ||
4303 | } | ||
4304 | |||
4305 | void opcode_fd_a6() // AND (IY + d) | ||
4306 | { | ||
4307 | A &= readByte( addDispl(IY,fetchByte()) ); | ||
4308 | setFlags35PSZ000(); | ||
4309 | F |= Halfcarry; | ||
4310 | } | ||
4311 | |||
4312 | void opcode_fd_ac() // XOR IYH | ||
4313 | { | ||
4314 | A ^= IY >> 8; | ||
4315 | setFlags35PSZ000(); | ||
4316 | } | ||
4317 | |||
4318 | void opcode_fd_ad() // XOR IYL | ||
4319 | { | ||
4320 | A ^= IY & 0xFF; | ||
4321 | setFlags35PSZ000(); | ||
4322 | } | ||
4323 | |||
4324 | void opcode_fd_ae() // XOR (IY + d) | ||
4325 | { | ||
4326 | A ^= readByte( addDispl(IY,fetchByte()) ); | ||
4327 | setFlags35PSZ000(); | ||
4328 | } | ||
4329 | |||
4330 | void opcode_fd_b4() // OR IYH | ||
4331 | { | ||
4332 | A |= IY >> 8; | ||
4333 | setFlags35PSZ000(); | ||
4334 | } | ||
4335 | |||
4336 | void opcode_fd_b5() // OR IYL | ||
4337 | { | ||
4338 | A |= IY & 0xFF; | ||
4339 | setFlags35PSZ000(); | ||
4340 | } | ||
4341 | |||
4342 | void opcode_fd_b6() // OR (IY + d) | ||
4343 | { | ||
4344 | A |= readByte( addDispl(IY,fetchByte()) ); | ||
4345 | setFlags35PSZ000(); | ||
4346 | } | ||
4347 | |||
4348 | void opcode_fd_bc() // CP IYH | ||
4349 | { | ||
4350 | cmpByte( IY >> 8 ); | ||
4351 | } | ||
4352 | |||
4353 | void opcode_fd_bd() // CP IYL | ||
4354 | { | ||
4355 | cmpByte( IY & 0xFF ); | ||
4356 | } | ||
4357 | |||
4358 | void opcode_fd_be() // CP (IY + d) | ||
4359 | { | ||
4360 | cmpByte( readByte( addDispl(IY,fetchByte()) ) ); | ||
4361 | } | ||
4362 | |||
4363 | void opcode_fd_cb() // | ||
4364 | { | ||
4365 | do_opcode_xycb( IY ); | ||
4366 | } | ||
4367 | |||
4368 | void opcode_fd_e1() // POP IY | ||
4369 | { | ||
4370 | IY = readWord( SP ); | ||
4371 | SP += 2; | ||
4372 | } | ||
4373 | |||
4374 | void opcode_fd_e3() // EX (SP), IY | ||
4375 | { | ||
4376 | unsigned iy = IY; | ||
4377 | |||
4378 | IY = readWord( SP ); | ||
4379 | writeWord( SP, iy ); | ||
4380 | } | ||
4381 | |||
4382 | void opcode_fd_e5() // PUSH IY | ||
4383 | { | ||
4384 | SP -= 2; | ||
4385 | writeWord( SP, IY ); | ||
4386 | } | ||
4387 | |||
4388 | void opcode_fd_e9() // JP (IY) | ||
4389 | { | ||
4390 | PC = IY; | ||
4391 | } | ||
4392 | |||
4393 | void opcode_fd_f9() // LD SP, IY | ||
4394 | { | ||
4395 | SP = IY; | ||
4396 | } | ||
4397 | |||
4398 | OpcodeInfoXY OpInfoXYCB_[256] = { | ||
4399 | { &opcode_xycb_00, 20 }, // LD B, RLC (IX + d) | ||
4400 | { &opcode_xycb_01, 20 }, // LD C, RLC (IX + d) | ||
4401 | { &opcode_xycb_02, 20 }, // LD D, RLC (IX + d) | ||
4402 | { &opcode_xycb_03, 20 }, // LD E, RLC (IX + d) | ||
4403 | { &opcode_xycb_04, 20 }, // LD H, RLC (IX + d) | ||
4404 | { &opcode_xycb_05, 20 }, // LD L, RLC (IX + d) | ||
4405 | { &opcode_xycb_06, 20 }, // RLC (IX + d) | ||
4406 | { &opcode_xycb_07, 20 }, // LD A, RLC (IX + d) | ||
4407 | { &opcode_xycb_08, 20 }, // LD B, RRC (IX + d) | ||
4408 | { &opcode_xycb_09, 20 }, // LD C, RRC (IX + d) | ||
4409 | { &opcode_xycb_0a, 20 }, // LD D, RRC (IX + d) | ||
4410 | { &opcode_xycb_0b, 20 }, // LD E, RRC (IX + d) | ||
4411 | { &opcode_xycb_0c, 20 }, // LD H, RRC (IX + d) | ||
4412 | { &opcode_xycb_0d, 20 }, // LD L, RRC (IX + d) | ||
4413 | { &opcode_xycb_0e, 20 }, // RRC (IX + d) | ||
4414 | { &opcode_xycb_0f, 20 }, // LD A, RRC (IX + d) | ||
4415 | { &opcode_xycb_10, 20 }, // LD B, RL (IX + d) | ||
4416 | { &opcode_xycb_11, 20 }, // LD C, RL (IX + d) | ||
4417 | { &opcode_xycb_12, 20 }, // LD D, RL (IX + d) | ||
4418 | { &opcode_xycb_13, 20 }, // LD E, RL (IX + d) | ||
4419 | { &opcode_xycb_14, 20 }, // LD H, RL (IX + d) | ||
4420 | { &opcode_xycb_15, 20 }, // LD L, RL (IX + d) | ||
4421 | { &opcode_xycb_16, 20 }, // RL (IX + d) | ||
4422 | { &opcode_xycb_17, 20 }, // LD A, RL (IX + d) | ||
4423 | { &opcode_xycb_18, 20 }, // LD B, RR (IX + d) | ||
4424 | { &opcode_xycb_19, 20 }, // LD C, RR (IX + d) | ||
4425 | { &opcode_xycb_1a, 20 }, // LD D, RR (IX + d) | ||
4426 | { &opcode_xycb_1b, 20 }, // LD E, RR (IX + d) | ||
4427 | { &opcode_xycb_1c, 20 }, // LD H, RR (IX + d) | ||
4428 | { &opcode_xycb_1d, 20 }, // LD L, RR (IX + d) | ||
4429 | { &opcode_xycb_1e, 20 }, // RR (IX + d) | ||
4430 | { &opcode_xycb_1f, 20 }, // LD A, RR (IX + d) | ||
4431 | { &opcode_xycb_20, 20 }, // LD B, SLA (IX + d) | ||
4432 | { &opcode_xycb_21, 20 }, // LD C, SLA (IX + d) | ||
4433 | { &opcode_xycb_22, 20 }, // LD D, SLA (IX + d) | ||
4434 | { &opcode_xycb_23, 20 }, // LD E, SLA (IX + d) | ||
4435 | { &opcode_xycb_24, 20 }, // LD H, SLA (IX + d) | ||
4436 | { &opcode_xycb_25, 20 }, // LD L, SLA (IX + d) | ||
4437 | { &opcode_xycb_26, 20 }, // SLA (IX + d) | ||
4438 | { &opcode_xycb_27, 20 }, // LD A, SLA (IX + d) | ||
4439 | { &opcode_xycb_28, 20 }, // LD B, SRA (IX + d) | ||
4440 | { &opcode_xycb_29, 20 }, // LD C, SRA (IX + d) | ||
4441 | { &opcode_xycb_2a, 20 }, // LD D, SRA (IX + d) | ||
4442 | { &opcode_xycb_2b, 20 }, // LD E, SRA (IX + d) | ||
4443 | { &opcode_xycb_2c, 20 }, // LD H, SRA (IX + d) | ||
4444 | { &opcode_xycb_2d, 20 }, // LD L, SRA (IX + d) | ||
4445 | { &opcode_xycb_2e, 20 }, // SRA (IX + d) | ||
4446 | { &opcode_xycb_2f, 20 }, // LD A, SRA (IX + d) | ||
4447 | { &opcode_xycb_30, 20 }, // LD B, SLL (IX + d) | ||
4448 | { &opcode_xycb_31, 20 }, // LD C, SLL (IX + d) | ||
4449 | { &opcode_xycb_32, 20 }, // LD D, SLL (IX + d) | ||
4450 | { &opcode_xycb_33, 20 }, // LD E, SLL (IX + d) | ||
4451 | { &opcode_xycb_34, 20 }, // LD H, SLL (IX + d) | ||
4452 | { &opcode_xycb_35, 20 }, // LD L, SLL (IX + d) | ||
4453 | { &opcode_xycb_36, 20 }, // SLL (IX + d) | ||
4454 | { &opcode_xycb_37, 20 }, // LD A, SLL (IX + d) | ||
4455 | { &opcode_xycb_38, 20 }, // LD B, SRL (IX + d) | ||
4456 | { &opcode_xycb_39, 20 }, // LD C, SRL (IX + d) | ||
4457 | { &opcode_xycb_3a, 20 }, // LD D, SRL (IX + d) | ||
4458 | { &opcode_xycb_3b, 20 }, // LD E, SRL (IX + d) | ||
4459 | { &opcode_xycb_3c, 20 }, // LD H, SRL (IX + d) | ||
4460 | { &opcode_xycb_3d, 20 }, // LD L, SRL (IX + d) | ||
4461 | { &opcode_xycb_3e, 20 }, // SRL (IX + d) | ||
4462 | { &opcode_xycb_3f, 20 }, // LD A, SRL (IX + d) | ||
4463 | { &opcode_xycb_40, 20 }, // BIT 0, (IX + d) | ||
4464 | { &opcode_xycb_41, 20 }, // BIT 0, (IX + d) | ||
4465 | { &opcode_xycb_42, 20 }, // BIT 0, (IX + d) | ||
4466 | { &opcode_xycb_43, 20 }, // BIT 0, (IX + d) | ||
4467 | { &opcode_xycb_44, 20 }, // BIT 0, (IX + d) | ||
4468 | { &opcode_xycb_45, 20 }, // BIT 0, (IX + d) | ||
4469 | { &opcode_xycb_46, 20 }, // BIT 0, (IX + d) | ||
4470 | { &opcode_xycb_47, 20 }, // BIT 0, (IX + d) | ||
4471 | { &opcode_xycb_48, 20 }, // BIT 1, (IX + d) | ||
4472 | { &opcode_xycb_49, 20 }, // BIT 1, (IX + d) | ||
4473 | { &opcode_xycb_4a, 20 }, // BIT 1, (IX + d) | ||
4474 | { &opcode_xycb_4b, 20 }, // BIT 1, (IX + d) | ||
4475 | { &opcode_xycb_4c, 20 }, // BIT 1, (IX + d) | ||
4476 | { &opcode_xycb_4d, 20 }, // BIT 1, (IX + d) | ||
4477 | { &opcode_xycb_4e, 20 }, // BIT 1, (IX + d) | ||
4478 | { &opcode_xycb_4f, 20 }, // BIT 1, (IX + d) | ||
4479 | { &opcode_xycb_50, 20 }, // BIT 2, (IX + d) | ||
4480 | { &opcode_xycb_51, 20 }, // BIT 2, (IX + d) | ||
4481 | { &opcode_xycb_52, 20 }, // BIT 2, (IX + d) | ||
4482 | { &opcode_xycb_53, 20 }, // BIT 2, (IX + d) | ||
4483 | { &opcode_xycb_54, 20 }, // BIT 2, (IX + d) | ||
4484 | { &opcode_xycb_55, 20 }, // BIT 2, (IX + d) | ||
4485 | { &opcode_xycb_56, 20 }, // BIT 2, (IX + d) | ||
4486 | { &opcode_xycb_57, 20 }, // BIT 2, (IX + d) | ||
4487 | { &opcode_xycb_58, 20 }, // BIT 3, (IX + d) | ||
4488 | { &opcode_xycb_59, 20 }, // BIT 3, (IX + d) | ||
4489 | { &opcode_xycb_5a, 20 }, // BIT 3, (IX + d) | ||
4490 | { &opcode_xycb_5b, 20 }, // BIT 3, (IX + d) | ||
4491 | { &opcode_xycb_5c, 20 }, // BIT 3, (IX + d) | ||
4492 | { &opcode_xycb_5d, 20 }, // BIT 3, (IX + d) | ||
4493 | { &opcode_xycb_5e, 20 }, // BIT 3, (IX + d) | ||
4494 | { &opcode_xycb_5f, 20 }, // BIT 3, (IX + d) | ||
4495 | { &opcode_xycb_60, 20 }, // BIT 4, (IX + d) | ||
4496 | { &opcode_xycb_61, 20 }, // BIT 4, (IX + d) | ||
4497 | { &opcode_xycb_62, 20 }, // BIT 4, (IX + d) | ||
4498 | { &opcode_xycb_63, 20 }, // BIT 4, (IX + d) | ||
4499 | { &opcode_xycb_64, 20 }, // BIT 4, (IX + d) | ||
4500 | { &opcode_xycb_65, 20 }, // BIT 4, (IX + d) | ||
4501 | { &opcode_xycb_66, 20 }, // BIT 4, (IX + d) | ||
4502 | { &opcode_xycb_67, 20 }, // BIT 4, (IX + d) | ||
4503 | { &opcode_xycb_68, 20 }, // BIT 5, (IX + d) | ||
4504 | { &opcode_xycb_69, 20 }, // BIT 5, (IX + d) | ||
4505 | { &opcode_xycb_6a, 20 }, // BIT 5, (IX + d) | ||
4506 | { &opcode_xycb_6b, 20 }, // BIT 5, (IX + d) | ||
4507 | { &opcode_xycb_6c, 20 }, // BIT 5, (IX + d) | ||
4508 | { &opcode_xycb_6d, 20 }, // BIT 5, (IX + d) | ||
4509 | { &opcode_xycb_6e, 20 }, // BIT 5, (IX + d) | ||
4510 | { &opcode_xycb_6f, 20 }, // BIT 5, (IX + d) | ||
4511 | { &opcode_xycb_70, 20 }, // BIT 6, (IX + d) | ||
4512 | { &opcode_xycb_71, 20 }, // BIT 6, (IX + d) | ||
4513 | { &opcode_xycb_72, 20 }, // BIT 6, (IX + d) | ||
4514 | { &opcode_xycb_73, 20 }, // BIT 6, (IX + d) | ||
4515 | { &opcode_xycb_74, 20 }, // BIT 6, (IX + d) | ||
4516 | { &opcode_xycb_75, 20 }, // BIT 6, (IX + d) | ||
4517 | { &opcode_xycb_76, 20 }, // BIT 6, (IX + d) | ||
4518 | { &opcode_xycb_77, 20 }, // BIT 6, (IX + d) | ||
4519 | { &opcode_xycb_78, 20 }, // BIT 7, (IX + d) | ||
4520 | { &opcode_xycb_79, 20 }, // BIT 7, (IX + d) | ||
4521 | { &opcode_xycb_7a, 20 }, // BIT 7, (IX + d) | ||
4522 | { &opcode_xycb_7b, 20 }, // BIT 7, (IX + d) | ||
4523 | { &opcode_xycb_7c, 20 }, // BIT 7, (IX + d) | ||
4524 | { &opcode_xycb_7d, 20 }, // BIT 7, (IX + d) | ||
4525 | { &opcode_xycb_7e, 20 }, // BIT 7, (IX + d) | ||
4526 | { &opcode_xycb_7f, 20 }, // BIT 7, (IX + d) | ||
4527 | { &opcode_xycb_80, 20 }, // LD B, RES 0, (IX + d) | ||
4528 | { &opcode_xycb_81, 20 }, // LD C, RES 0, (IX + d) | ||
4529 | { &opcode_xycb_82, 20 }, // LD D, RES 0, (IX + d) | ||
4530 | { &opcode_xycb_83, 20 }, // LD E, RES 0, (IX + d) | ||
4531 | { &opcode_xycb_84, 20 }, // LD H, RES 0, (IX + d) | ||
4532 | { &opcode_xycb_85, 20 }, // LD L, RES 0, (IX + d) | ||
4533 | { &opcode_xycb_86, 20 }, // RES 0, (IX + d) | ||
4534 | { &opcode_xycb_87, 20 }, // LD A, RES 0, (IX + d) | ||
4535 | { &opcode_xycb_88, 20 }, // LD B, RES 1, (IX + d) | ||
4536 | { &opcode_xycb_89, 20 }, // LD C, RES 1, (IX + d) | ||
4537 | { &opcode_xycb_8a, 20 }, // LD D, RES 1, (IX + d) | ||
4538 | { &opcode_xycb_8b, 20 }, // LD E, RES 1, (IX + d) | ||
4539 | { &opcode_xycb_8c, 20 }, // LD H, RES 1, (IX + d) | ||
4540 | { &opcode_xycb_8d, 20 }, // LD L, RES 1, (IX + d) | ||
4541 | { &opcode_xycb_8e, 20 }, // RES 1, (IX + d) | ||
4542 | { &opcode_xycb_8f, 20 }, // LD A, RES 1, (IX + d) | ||
4543 | { &opcode_xycb_90, 20 }, // LD B, RES 2, (IX + d) | ||
4544 | { &opcode_xycb_91, 20 }, // LD C, RES 2, (IX + d) | ||
4545 | { &opcode_xycb_92, 20 }, // LD D, RES 2, (IX + d) | ||
4546 | { &opcode_xycb_93, 20 }, // LD E, RES 2, (IX + d) | ||
4547 | { &opcode_xycb_94, 20 }, // LD H, RES 2, (IX + d) | ||
4548 | { &opcode_xycb_95, 20 }, // LD L, RES 2, (IX + d) | ||
4549 | { &opcode_xycb_96, 20 }, // RES 2, (IX + d) | ||
4550 | { &opcode_xycb_97, 20 }, // LD A, RES 2, (IX + d) | ||
4551 | { &opcode_xycb_98, 20 }, // LD B, RES 3, (IX + d) | ||
4552 | { &opcode_xycb_99, 20 }, // LD C, RES 3, (IX + d) | ||
4553 | { &opcode_xycb_9a, 20 }, // LD D, RES 3, (IX + d) | ||
4554 | { &opcode_xycb_9b, 20 }, // LD E, RES 3, (IX + d) | ||
4555 | { &opcode_xycb_9c, 20 }, // LD H, RES 3, (IX + d) | ||
4556 | { &opcode_xycb_9d, 20 }, // LD L, RES 3, (IX + d) | ||
4557 | { &opcode_xycb_9e, 20 }, // RES 3, (IX + d) | ||
4558 | { &opcode_xycb_9f, 20 }, // LD A, RES 3, (IX + d) | ||
4559 | { &opcode_xycb_a0, 20 }, // LD B, RES 4, (IX + d) | ||
4560 | { &opcode_xycb_a1, 20 }, // LD C, RES 4, (IX + d) | ||
4561 | { &opcode_xycb_a2, 20 }, // LD D, RES 4, (IX + d) | ||
4562 | { &opcode_xycb_a3, 20 }, // LD E, RES 4, (IX + d) | ||
4563 | { &opcode_xycb_a4, 20 }, // LD H, RES 4, (IX + d) | ||
4564 | { &opcode_xycb_a5, 20 }, // LD L, RES 4, (IX + d) | ||
4565 | { &opcode_xycb_a6, 20 }, // RES 4, (IX + d) | ||
4566 | { &opcode_xycb_a7, 20 }, // LD A, RES 4, (IX + d) | ||
4567 | { &opcode_xycb_a8, 20 }, // LD B, RES 5, (IX + d) | ||
4568 | { &opcode_xycb_a9, 20 }, // LD C, RES 5, (IX + d) | ||
4569 | { &opcode_xycb_aa, 20 }, // LD D, RES 5, (IX + d) | ||
4570 | { &opcode_xycb_ab, 20 }, // LD E, RES 5, (IX + d) | ||
4571 | { &opcode_xycb_ac, 20 }, // LD H, RES 5, (IX + d) | ||
4572 | { &opcode_xycb_ad, 20 }, // LD L, RES 5, (IX + d) | ||
4573 | { &opcode_xycb_ae, 20 }, // RES 5, (IX + d) | ||
4574 | { &opcode_xycb_af, 20 }, // LD A, RES 5, (IX + d) | ||
4575 | { &opcode_xycb_b0, 20 }, // LD B, RES 6, (IX + d) | ||
4576 | { &opcode_xycb_b1, 20 }, // LD C, RES 6, (IX + d) | ||
4577 | { &opcode_xycb_b2, 20 }, // LD D, RES 6, (IX + d) | ||
4578 | { &opcode_xycb_b3, 20 }, // LD E, RES 6, (IX + d) | ||
4579 | { &opcode_xycb_b4, 20 }, // LD H, RES 6, (IX + d) | ||
4580 | { &opcode_xycb_b5, 20 }, // LD L, RES 6, (IX + d) | ||
4581 | { &opcode_xycb_b6, 20 }, // RES 6, (IX + d) | ||
4582 | { &opcode_xycb_b7, 20 }, // LD A, RES 6, (IX + d) | ||
4583 | { &opcode_xycb_b8, 20 }, // LD B, RES 7, (IX + d) | ||
4584 | { &opcode_xycb_b9, 20 }, // LD C, RES 7, (IX + d) | ||
4585 | { &opcode_xycb_ba, 20 }, // LD D, RES 7, (IX + d) | ||
4586 | { &opcode_xycb_bb, 20 }, // LD E, RES 7, (IX + d) | ||
4587 | { &opcode_xycb_bc, 20 }, // LD H, RES 7, (IX + d) | ||
4588 | { &opcode_xycb_bd, 20 }, // LD L, RES 7, (IX + d) | ||
4589 | { &opcode_xycb_be, 20 }, // RES 7, (IX + d) | ||
4590 | { &opcode_xycb_bf, 20 }, // LD A, RES 7, (IX + d) | ||
4591 | { &opcode_xycb_c0, 20 }, // LD B, SET 0, (IX + d) | ||
4592 | { &opcode_xycb_c1, 20 }, // LD C, SET 0, (IX + d) | ||
4593 | { &opcode_xycb_c2, 20 }, // LD D, SET 0, (IX + d) | ||
4594 | { &opcode_xycb_c3, 20 }, // LD E, SET 0, (IX + d) | ||
4595 | { &opcode_xycb_c4, 20 }, // LD H, SET 0, (IX + d) | ||
4596 | { &opcode_xycb_c5, 20 }, // LD L, SET 0, (IX + d) | ||
4597 | { &opcode_xycb_c6, 20 }, // SET 0, (IX + d) | ||
4598 | { &opcode_xycb_c7, 20 }, // LD A, SET 0, (IX + d) | ||
4599 | { &opcode_xycb_c8, 20 }, // LD B, SET 1, (IX + d) | ||
4600 | { &opcode_xycb_c9, 20 }, // LD C, SET 1, (IX + d) | ||
4601 | { &opcode_xycb_ca, 20 }, // LD D, SET 1, (IX + d) | ||
4602 | { &opcode_xycb_cb, 20 }, // LD E, SET 1, (IX + d) | ||
4603 | { &opcode_xycb_cc, 20 }, // LD H, SET 1, (IX + d) | ||
4604 | { &opcode_xycb_cd, 20 }, // LD L, SET 1, (IX + d) | ||
4605 | { &opcode_xycb_ce, 20 }, // SET 1, (IX + d) | ||
4606 | { &opcode_xycb_cf, 20 }, // LD A, SET 1, (IX + d) | ||
4607 | { &opcode_xycb_d0, 20 }, // LD B, SET 2, (IX + d) | ||
4608 | { &opcode_xycb_d1, 20 }, // LD C, SET 2, (IX + d) | ||
4609 | { &opcode_xycb_d2, 20 }, // LD D, SET 2, (IX + d) | ||
4610 | { &opcode_xycb_d3, 20 }, // LD E, SET 2, (IX + d) | ||
4611 | { &opcode_xycb_d4, 20 }, // LD H, SET 2, (IX + d) | ||
4612 | { &opcode_xycb_d5, 20 }, // LD L, SET 2, (IX + d) | ||
4613 | { &opcode_xycb_d6, 20 }, // SET 2, (IX + d) | ||
4614 | { &opcode_xycb_d7, 20 }, // LD A, SET 2, (IX + d) | ||
4615 | { &opcode_xycb_d8, 20 }, // LD B, SET 3, (IX + d) | ||
4616 | { &opcode_xycb_d9, 20 }, // LD C, SET 3, (IX + d) | ||
4617 | { &opcode_xycb_da, 20 }, // LD D, SET 3, (IX + d) | ||
4618 | { &opcode_xycb_db, 20 }, // LD E, SET 3, (IX + d) | ||
4619 | { &opcode_xycb_dc, 20 }, // LD H, SET 3, (IX + d) | ||
4620 | { &opcode_xycb_dd, 20 }, // LD L, SET 3, (IX + d) | ||
4621 | { &opcode_xycb_de, 20 }, // SET 3, (IX + d) | ||
4622 | { &opcode_xycb_df, 20 }, // LD A, SET 3, (IX + d) | ||
4623 | { &opcode_xycb_e0, 20 }, // LD B, SET 4, (IX + d) | ||
4624 | { &opcode_xycb_e1, 20 }, // LD C, SET 4, (IX + d) | ||
4625 | { &opcode_xycb_e2, 20 }, // LD D, SET 4, (IX + d) | ||
4626 | { &opcode_xycb_e3, 20 }, // LD E, SET 4, (IX + d) | ||
4627 | { &opcode_xycb_e4, 20 }, // LD H, SET 4, (IX + d) | ||
4628 | { &opcode_xycb_e5, 20 }, // LD L, SET 4, (IX + d) | ||
4629 | { &opcode_xycb_e6, 20 }, // SET 4, (IX + d) | ||
4630 | { &opcode_xycb_e7, 20 }, // LD A, SET 4, (IX + d) | ||
4631 | { &opcode_xycb_e8, 20 }, // LD B, SET 5, (IX + d) | ||
4632 | { &opcode_xycb_e9, 20 }, // LD C, SET 5, (IX + d) | ||
4633 | { &opcode_xycb_ea, 20 }, // LD D, SET 5, (IX + d) | ||
4634 | { &opcode_xycb_eb, 20 }, // LD E, SET 5, (IX + d) | ||
4635 | { &opcode_xycb_ec, 20 }, // LD H, SET 5, (IX + d) | ||
4636 | { &opcode_xycb_ed, 20 }, // LD L, SET 5, (IX + d) | ||
4637 | { &opcode_xycb_ee, 20 }, // SET 5, (IX + d) | ||
4638 | { &opcode_xycb_ef, 20 }, // LD A, SET 5, (IX + d) | ||
4639 | { &opcode_xycb_f0, 20 }, // LD B, SET 6, (IX + d) | ||
4640 | { &opcode_xycb_f1, 20 }, // LD C, SET 6, (IX + d) | ||
4641 | { &opcode_xycb_f2, 20 }, // LD D, SET 6, (IX + d) | ||
4642 | { &opcode_xycb_f3, 20 }, // LD E, SET 6, (IX + d) | ||
4643 | { &opcode_xycb_f4, 20 }, // LD H, SET 6, (IX + d) | ||
4644 | { &opcode_xycb_f5, 20 }, // LD L, SET 6, (IX + d) | ||
4645 | { &opcode_xycb_f6, 20 }, // SET 6, (IX + d) | ||
4646 | { &opcode_xycb_f7, 20 }, // LD A, SET 6, (IX + d) | ||
4647 | { &opcode_xycb_f8, 20 }, // LD B, SET 7, (IX + d) | ||
4648 | { &opcode_xycb_f9, 20 }, // LD C, SET 7, (IX + d) | ||
4649 | { &opcode_xycb_fa, 20 }, // LD D, SET 7, (IX + d) | ||
4650 | { &opcode_xycb_fb, 20 }, // LD E, SET 7, (IX + d) | ||
4651 | { &opcode_xycb_fc, 20 }, // LD H, SET 7, (IX + d) | ||
4652 | { &opcode_xycb_fd, 20 }, // LD L, SET 7, (IX + d) | ||
4653 | { &opcode_xycb_fe, 20 }, // SET 7, (IX + d) | ||
4654 | { &opcode_xycb_ff, 20 } // LD A, SET 7, (IX + d) | ||
4655 | }; | ||
4656 | |||
4657 | unsigned do_opcode_xycb( unsigned xy ) | ||
4658 | { | ||
4659 | xy = addDispl( xy, fetchByte() ); | ||
4660 | |||
4661 | unsigned op = fetchByte(); | ||
4662 | |||
4663 | cycles_ += OpInfoXYCB_[ op ].cycles; | ||
4664 | |||
4665 | OpInfoXYCB_[ op ].handler( xy ); | ||
4666 | |||
4667 | return xy; | ||
4668 | } | ||
4669 | |||
4670 | void opcode_xycb_00( unsigned xy ) // LD B, RLC (IX + d) | ||
4671 | { | ||
4672 | B = rotateLeftCarry( readByte(xy) ); | ||
4673 | writeByte( xy, B ); | ||
4674 | } | ||
4675 | |||
4676 | void opcode_xycb_01( unsigned xy ) // LD C, RLC (IX + d) | ||
4677 | { | ||
4678 | C = rotateLeftCarry( readByte(xy) ); | ||
4679 | writeByte( xy, C ); | ||
4680 | } | ||
4681 | |||
4682 | void opcode_xycb_02( unsigned xy ) // LD D, RLC (IX + d) | ||
4683 | { | ||
4684 | D = rotateLeftCarry( readByte(xy) ); | ||
4685 | writeByte( xy, D ); | ||
4686 | } | ||
4687 | |||
4688 | void opcode_xycb_03( unsigned xy ) // LD E, RLC (IX + d) | ||
4689 | { | ||
4690 | E = rotateLeftCarry( readByte(xy) ); | ||
4691 | writeByte( xy, E ); | ||
4692 | } | ||
4693 | |||
4694 | void opcode_xycb_04( unsigned xy ) // LD H, RLC (IX + d) | ||
4695 | { | ||
4696 | H = rotateLeftCarry( readByte(xy) ); | ||
4697 | writeByte( xy, H ); | ||
4698 | } | ||
4699 | |||
4700 | void opcode_xycb_05( unsigned xy ) // LD L, RLC (IX + d) | ||
4701 | { | ||
4702 | L = rotateLeftCarry( readByte(xy) ); | ||
4703 | writeByte( xy, L ); | ||
4704 | } | ||
4705 | |||
4706 | void opcode_xycb_06( unsigned xy ) // RLC (IX + d) | ||
4707 | { | ||
4708 | writeByte( xy, rotateLeftCarry( readByte(xy) ) ); | ||
4709 | } | ||
4710 | |||
4711 | void opcode_xycb_07( unsigned xy ) // LD A, RLC (IX + d) | ||
4712 | { | ||
4713 | A = rotateLeftCarry( readByte(xy) ); | ||
4714 | writeByte( xy, A ); | ||
4715 | } | ||
4716 | |||
4717 | void opcode_xycb_08( unsigned xy ) // LD B, RRC (IX + d) | ||
4718 | { | ||
4719 | B = rotateRightCarry( readByte(xy) ); | ||
4720 | writeByte( xy, B ); | ||
4721 | } | ||
4722 | |||
4723 | void opcode_xycb_09( unsigned xy ) // LD C, RRC (IX + d) | ||
4724 | { | ||
4725 | C = rotateRightCarry( readByte(xy) ); | ||
4726 | writeByte( xy, C ); | ||
4727 | } | ||
4728 | |||
4729 | void opcode_xycb_0a( unsigned xy ) // LD D, RRC (IX + d) | ||
4730 | { | ||
4731 | D = rotateRightCarry( readByte(xy) ); | ||
4732 | writeByte( xy, D ); | ||
4733 | } | ||
4734 | |||
4735 | void opcode_xycb_0b( unsigned xy ) // LD E, RRC (IX + d) | ||
4736 | { | ||
4737 | E = rotateRightCarry( readByte(xy) ); | ||
4738 | writeByte( xy, E ); | ||
4739 | } | ||
4740 | |||
4741 | void opcode_xycb_0c( unsigned xy ) // LD H, RRC (IX + d) | ||
4742 | { | ||
4743 | H = rotateRightCarry( readByte(xy) ); | ||
4744 | writeByte( xy, H ); | ||
4745 | } | ||
4746 | |||
4747 | void opcode_xycb_0d( unsigned xy ) // LD L, RRC (IX + d) | ||
4748 | { | ||
4749 | L = rotateRightCarry( readByte(xy) ); | ||
4750 | writeByte( xy, L ); | ||
4751 | } | ||
4752 | |||
4753 | void opcode_xycb_0e( unsigned xy ) // RRC (IX + d) | ||
4754 | { | ||
4755 | writeByte( xy, rotateRightCarry( readByte(xy) ) ); | ||
4756 | } | ||
4757 | |||
4758 | void opcode_xycb_0f( unsigned xy ) // LD A, RRC (IX + d) | ||
4759 | { | ||
4760 | A = rotateRightCarry( readByte(xy) ); | ||
4761 | writeByte( xy, A ); | ||
4762 | } | ||
4763 | |||
4764 | void opcode_xycb_10( unsigned xy ) // LD B, RL (IX + d) | ||
4765 | { | ||
4766 | B = rotateLeft( readByte(xy) ); | ||
4767 | writeByte( xy, B ); | ||
4768 | } | ||
4769 | |||
4770 | void opcode_xycb_11( unsigned xy ) // LD C, RL (IX + d) | ||
4771 | { | ||
4772 | C = rotateLeft( readByte(xy) ); | ||
4773 | writeByte( xy, C ); | ||
4774 | } | ||
4775 | |||
4776 | void opcode_xycb_12( unsigned xy ) // LD D, RL (IX + d) | ||
4777 | { | ||
4778 | D = rotateLeft( readByte(xy) ); | ||
4779 | writeByte( xy, D ); | ||
4780 | } | ||
4781 | |||
4782 | void opcode_xycb_13( unsigned xy ) // LD E, RL (IX + d) | ||
4783 | { | ||
4784 | E = rotateLeft( readByte(xy) ); | ||
4785 | writeByte( xy, E ); | ||
4786 | } | ||
4787 | |||
4788 | void opcode_xycb_14( unsigned xy ) // LD H, RL (IX + d) | ||
4789 | { | ||
4790 | H = rotateLeft( readByte(xy) ); | ||
4791 | writeByte( xy, H ); | ||
4792 | } | ||
4793 | |||
4794 | void opcode_xycb_15( unsigned xy ) // LD L, RL (IX + d) | ||
4795 | { | ||
4796 | L = rotateLeft( readByte(xy) ); | ||
4797 | writeByte( xy, L ); | ||
4798 | } | ||
4799 | |||
4800 | void opcode_xycb_16( unsigned xy ) // RL (IX + d) | ||
4801 | { | ||
4802 | writeByte( xy, rotateLeft( readByte(xy) ) ); | ||
4803 | } | ||
4804 | |||
4805 | void opcode_xycb_17( unsigned xy ) // LD A, RL (IX + d) | ||
4806 | { | ||
4807 | A = rotateLeft( readByte(xy) ); | ||
4808 | writeByte( xy, A ); | ||
4809 | } | ||
4810 | |||
4811 | void opcode_xycb_18( unsigned xy ) // LD B, RR (IX + d) | ||
4812 | { | ||
4813 | B = rotateRight( readByte(xy) ); | ||
4814 | writeByte( xy, B ); | ||
4815 | } | ||
4816 | |||
4817 | void opcode_xycb_19( unsigned xy ) // LD C, RR (IX + d) | ||
4818 | { | ||
4819 | C = rotateRight( readByte(xy) ); | ||
4820 | writeByte( xy, C ); | ||
4821 | } | ||
4822 | |||
4823 | void opcode_xycb_1a( unsigned xy ) // LD D, RR (IX + d) | ||
4824 | { | ||
4825 | D = rotateRight( readByte(xy) ); | ||
4826 | writeByte( xy, D ); | ||
4827 | } | ||
4828 | |||
4829 | void opcode_xycb_1b( unsigned xy ) // LD E, RR (IX + d) | ||
4830 | { | ||
4831 | E = rotateRight( readByte(xy) ); | ||
4832 | writeByte( xy, E ); | ||
4833 | } | ||
4834 | |||
4835 | void opcode_xycb_1c( unsigned xy ) // LD H, RR (IX + d) | ||
4836 | { | ||
4837 | H = rotateRight( readByte(xy) ); | ||
4838 | writeByte( xy, H ); | ||
4839 | } | ||
4840 | |||
4841 | void opcode_xycb_1d( unsigned xy ) // LD L, RR (IX + d) | ||
4842 | { | ||
4843 | L = rotateRight( readByte(xy) ); | ||
4844 | writeByte( xy, L ); | ||
4845 | } | ||
4846 | |||
4847 | void opcode_xycb_1e( unsigned xy ) // RR (IX + d) | ||
4848 | { | ||
4849 | writeByte( xy, rotateRight( readByte(xy) ) ); | ||
4850 | } | ||
4851 | |||
4852 | void opcode_xycb_1f( unsigned xy ) // LD A, RR (IX + d) | ||
4853 | { | ||
4854 | A = rotateRight( readByte(xy) ); | ||
4855 | writeByte( xy, A ); | ||
4856 | } | ||
4857 | |||
4858 | void opcode_xycb_20( unsigned xy ) // LD B, SLA (IX + d) | ||
4859 | { | ||
4860 | B = shiftLeft( readByte(xy) ); | ||
4861 | writeByte( xy, B ); | ||
4862 | } | ||
4863 | |||
4864 | void opcode_xycb_21( unsigned xy ) // LD C, SLA (IX + d) | ||
4865 | { | ||
4866 | C = shiftLeft( readByte(xy) ); | ||
4867 | writeByte( xy, C ); | ||
4868 | } | ||
4869 | |||
4870 | void opcode_xycb_22( unsigned xy ) // LD D, SLA (IX + d) | ||
4871 | { | ||
4872 | D = shiftLeft( readByte(xy) ); | ||
4873 | writeByte( xy, D ); | ||
4874 | } | ||
4875 | |||
4876 | void opcode_xycb_23( unsigned xy ) // LD E, SLA (IX + d) | ||
4877 | { | ||
4878 | E = shiftLeft( readByte(xy) ); | ||
4879 | writeByte( xy, E ); | ||
4880 | } | ||
4881 | |||
4882 | void opcode_xycb_24( unsigned xy ) // LD H, SLA (IX + d) | ||
4883 | { | ||
4884 | H = shiftLeft( readByte(xy) ); | ||
4885 | writeByte( xy, H ); | ||
4886 | } | ||
4887 | |||
4888 | void opcode_xycb_25( unsigned xy ) // LD L, SLA (IX + d) | ||
4889 | { | ||
4890 | L = shiftLeft( readByte(xy) ); | ||
4891 | writeByte( xy, L ); | ||
4892 | } | ||
4893 | |||
4894 | void opcode_xycb_26( unsigned xy ) // SLA (IX + d) | ||
4895 | { | ||
4896 | writeByte( xy, shiftLeft( readByte(xy) ) ); | ||
4897 | } | ||
4898 | |||
4899 | void opcode_xycb_27( unsigned xy ) // LD A, SLA (IX + d) | ||
4900 | { | ||
4901 | A = shiftLeft( readByte(xy) ); | ||
4902 | writeByte( xy, A ); | ||
4903 | } | ||
4904 | |||
4905 | void opcode_xycb_28( unsigned xy ) // LD B, SRA (IX + d) | ||
4906 | { | ||
4907 | B = shiftRightArith( readByte(xy) ); | ||
4908 | writeByte( xy, B ); | ||
4909 | } | ||
4910 | |||
4911 | void opcode_xycb_29( unsigned xy ) // LD C, SRA (IX + d) | ||
4912 | { | ||
4913 | C = shiftRightArith( readByte(xy) ); | ||
4914 | writeByte( xy, C ); | ||
4915 | } | ||
4916 | |||
4917 | void opcode_xycb_2a( unsigned xy ) // LD D, SRA (IX + d) | ||
4918 | { | ||
4919 | D = shiftRightArith( readByte(xy) ); | ||
4920 | writeByte( xy, D ); | ||
4921 | } | ||
4922 | |||
4923 | void opcode_xycb_2b( unsigned xy ) // LD E, SRA (IX + d) | ||
4924 | { | ||
4925 | E = shiftRightArith( readByte(xy) ); | ||
4926 | writeByte( xy, E ); | ||
4927 | } | ||
4928 | |||
4929 | void opcode_xycb_2c( unsigned xy ) // LD H, SRA (IX + d) | ||
4930 | { | ||
4931 | H = shiftRightArith( readByte(xy) ); | ||
4932 | writeByte( xy, H ); | ||
4933 | } | ||
4934 | |||
4935 | void opcode_xycb_2d( unsigned xy ) // LD L, SRA (IX + d) | ||
4936 | { | ||
4937 | L = shiftRightArith( readByte(xy) ); | ||
4938 | writeByte( xy, L ); | ||
4939 | } | ||
4940 | |||
4941 | void opcode_xycb_2e( unsigned xy ) // SRA (IX + d) | ||
4942 | { | ||
4943 | writeByte( xy, shiftRightArith( readByte(xy) ) ); | ||
4944 | } | ||
4945 | |||
4946 | void opcode_xycb_2f( unsigned xy ) // LD A, SRA (IX + d) | ||
4947 | { | ||
4948 | A = shiftRightArith( readByte(xy) ); | ||
4949 | writeByte( xy, A ); | ||
4950 | } | ||
4951 | |||
4952 | void opcode_xycb_30( unsigned xy ) // LD B, SLL (IX + d) | ||
4953 | { | ||
4954 | B = shiftLeft( readByte(xy) ) | 0x01; | ||
4955 | writeByte( xy, B ); | ||
4956 | } | ||
4957 | |||
4958 | void opcode_xycb_31( unsigned xy ) // LD C, SLL (IX + d) | ||
4959 | { | ||
4960 | C = shiftLeft( readByte(xy) ) | 0x01; | ||
4961 | writeByte( xy, C ); | ||
4962 | } | ||
4963 | |||
4964 | void opcode_xycb_32( unsigned xy ) // LD D, SLL (IX + d) | ||
4965 | { | ||
4966 | D = shiftLeft( readByte(xy) ) | 0x01; | ||
4967 | writeByte( xy, D ); | ||
4968 | } | ||
4969 | |||
4970 | void opcode_xycb_33( unsigned xy ) // LD E, SLL (IX + d) | ||
4971 | { | ||
4972 | E = shiftLeft( readByte(xy) ) | 0x01; | ||
4973 | writeByte( xy, E ); | ||
4974 | } | ||
4975 | |||
4976 | void opcode_xycb_34( unsigned xy ) // LD H, SLL (IX + d) | ||
4977 | { | ||
4978 | H = shiftLeft( readByte(xy) ) | 0x01; | ||
4979 | writeByte( xy, H ); | ||
4980 | } | ||
4981 | |||
4982 | void opcode_xycb_35( unsigned xy ) // LD L, SLL (IX + d) | ||
4983 | { | ||
4984 | L = shiftLeft( readByte(xy) ) | 0x01; | ||
4985 | writeByte( xy, L ); | ||
4986 | } | ||
4987 | |||
4988 | void opcode_xycb_36( unsigned xy ) // SLL (IX + d) | ||
4989 | { | ||
4990 | writeByte( xy, shiftLeft( readByte(xy) ) | 0x01 ); | ||
4991 | } | ||
4992 | |||
4993 | void opcode_xycb_37( unsigned xy ) // LD A, SLL (IX + d) | ||
4994 | { | ||
4995 | A = shiftLeft( readByte(xy) ) | 0x01; | ||
4996 | writeByte( xy, A ); | ||
4997 | } | ||
4998 | |||
4999 | void opcode_xycb_38( unsigned xy ) // LD B, SRL (IX + d) | ||
5000 | { | ||
5001 | B = shiftRightLogical( readByte(xy) ); | ||
5002 | writeByte( xy, B ); | ||
5003 | } | ||
5004 | |||
5005 | void opcode_xycb_39( unsigned xy ) // LD C, SRL (IX + d) | ||
5006 | { | ||
5007 | C = shiftRightLogical( readByte(xy) ); | ||
5008 | writeByte( xy, C ); | ||
5009 | } | ||
5010 | |||
5011 | void opcode_xycb_3a( unsigned xy ) // LD D, SRL (IX + d) | ||
5012 | { | ||
5013 | D = shiftRightLogical( readByte(xy) ); | ||
5014 | writeByte( xy, D ); | ||
5015 | } | ||
5016 | |||
5017 | void opcode_xycb_3b( unsigned xy ) // LD E, SRL (IX + d) | ||
5018 | { | ||
5019 | E = shiftRightLogical( readByte(xy) ); | ||
5020 | writeByte( xy, E ); | ||
5021 | } | ||
5022 | |||
5023 | void opcode_xycb_3c( unsigned xy ) // LD H, SRL (IX + d) | ||
5024 | { | ||
5025 | H = shiftRightLogical( readByte(xy) ); | ||
5026 | writeByte( xy, H ); | ||
5027 | } | ||
5028 | |||
5029 | void opcode_xycb_3d( unsigned xy ) // LD L, SRL (IX + d) | ||
5030 | { | ||
5031 | L = shiftRightLogical( readByte(xy) ); | ||
5032 | writeByte( xy, L ); | ||
5033 | } | ||
5034 | |||
5035 | void opcode_xycb_3e( unsigned xy ) // SRL (IX + d) | ||
5036 | { | ||
5037 | writeByte( xy, shiftRightLogical( readByte(xy) ) ); | ||
5038 | } | ||
5039 | |||
5040 | void opcode_xycb_3f( unsigned xy ) // LD A, SRL (IX + d) | ||
5041 | { | ||
5042 | A = shiftRightLogical( readByte(xy) ); | ||
5043 | writeByte( xy, A ); | ||
5044 | } | ||
5045 | |||
5046 | void opcode_xycb_40( unsigned xy ) // BIT 0, (IX + d) | ||
5047 | { | ||
5048 | testBit( 0, readByte( xy ) ); | ||
5049 | } | ||
5050 | |||
5051 | void opcode_xycb_41( unsigned xy ) // BIT 0, (IX + d) | ||
5052 | { | ||
5053 | testBit( 0, readByte( xy ) ); | ||
5054 | } | ||
5055 | |||
5056 | void opcode_xycb_42( unsigned xy ) // BIT 0, (IX + d) | ||
5057 | { | ||
5058 | testBit( 0, readByte( xy ) ); | ||
5059 | } | ||
5060 | |||
5061 | void opcode_xycb_43( unsigned xy ) // BIT 0, (IX + d) | ||
5062 | { | ||
5063 | testBit( 0, readByte( xy ) ); | ||
5064 | } | ||
5065 | |||
5066 | void opcode_xycb_44( unsigned xy ) // BIT 0, (IX + d) | ||
5067 | { | ||
5068 | testBit( 0, readByte( xy ) ); | ||
5069 | } | ||
5070 | |||
5071 | void opcode_xycb_45( unsigned xy ) // BIT 0, (IX + d) | ||
5072 | { | ||
5073 | testBit( 0, readByte( xy ) ); | ||
5074 | } | ||
5075 | |||
5076 | void opcode_xycb_46( unsigned xy ) // BIT 0, (IX + d) | ||
5077 | { | ||
5078 | testBit( 0, readByte( xy ) ); | ||
5079 | } | ||
5080 | |||
5081 | void opcode_xycb_47( unsigned xy ) // BIT 0, (IX + d) | ||
5082 | { | ||
5083 | testBit( 0, readByte( xy ) ); | ||
5084 | } | ||
5085 | |||
5086 | void opcode_xycb_48( unsigned xy ) // BIT 1, (IX + d) | ||
5087 | { | ||
5088 | testBit( 1, readByte( xy ) ); | ||
5089 | } | ||
5090 | |||
5091 | void opcode_xycb_49( unsigned xy ) // BIT 1, (IX + d) | ||
5092 | { | ||
5093 | testBit( 1, readByte( xy ) ); | ||
5094 | } | ||
5095 | |||
5096 | void opcode_xycb_4a( unsigned xy ) // BIT 1, (IX + d) | ||
5097 | { | ||
5098 | testBit( 1, readByte( xy ) ); | ||
5099 | } | ||
5100 | |||
5101 | void opcode_xycb_4b( unsigned xy ) // BIT 1, (IX + d) | ||
5102 | { | ||
5103 | testBit( 1, readByte( xy ) ); | ||
5104 | } | ||
5105 | |||
5106 | void opcode_xycb_4c( unsigned xy ) // BIT 1, (IX + d) | ||
5107 | { | ||
5108 | testBit( 1, readByte( xy ) ); | ||
5109 | } | ||
5110 | |||
5111 | void opcode_xycb_4d( unsigned xy ) // BIT 1, (IX + d) | ||
5112 | { | ||
5113 | testBit( 1, readByte( xy ) ); | ||
5114 | } | ||
5115 | |||
5116 | void opcode_xycb_4e( unsigned xy ) // BIT 1, (IX + d) | ||
5117 | { | ||
5118 | testBit( 1, readByte( xy ) ); | ||
5119 | } | ||
5120 | |||
5121 | void opcode_xycb_4f( unsigned xy ) // BIT 1, (IX + d) | ||
5122 | { | ||
5123 | testBit( 1, readByte( xy ) ); | ||
5124 | } | ||
5125 | |||
5126 | void opcode_xycb_50( unsigned xy ) // BIT 2, (IX + d) | ||
5127 | { | ||
5128 | testBit( 2, readByte( xy ) ); | ||
5129 | } | ||
5130 | |||
5131 | void opcode_xycb_51( unsigned xy ) // BIT 2, (IX + d) | ||
5132 | { | ||
5133 | testBit( 2, readByte( xy ) ); | ||
5134 | } | ||
5135 | |||
5136 | void opcode_xycb_52( unsigned xy ) // BIT 2, (IX + d) | ||
5137 | { | ||
5138 | testBit( 2, readByte( xy ) ); | ||
5139 | } | ||
5140 | |||
5141 | void opcode_xycb_53( unsigned xy ) // BIT 2, (IX + d) | ||
5142 | { | ||
5143 | testBit( 2, readByte( xy ) ); | ||
5144 | } | ||
5145 | |||
5146 | void opcode_xycb_54( unsigned xy ) // BIT 2, (IX + d) | ||
5147 | { | ||
5148 | testBit( 2, readByte( xy ) ); | ||
5149 | } | ||
5150 | |||
5151 | void opcode_xycb_55( unsigned xy ) // BIT 2, (IX + d) | ||
5152 | { | ||
5153 | testBit( 2, readByte( xy ) ); | ||
5154 | } | ||
5155 | |||
5156 | void opcode_xycb_56( unsigned xy ) // BIT 2, (IX + d) | ||
5157 | { | ||
5158 | testBit( 2, readByte( xy ) ); | ||
5159 | } | ||
5160 | |||
5161 | void opcode_xycb_57( unsigned xy ) // BIT 2, (IX + d) | ||
5162 | { | ||
5163 | testBit( 2, readByte( xy ) ); | ||
5164 | } | ||
5165 | |||
5166 | void opcode_xycb_58( unsigned xy ) // BIT 3, (IX + d) | ||
5167 | { | ||
5168 | testBit( 3, readByte( xy ) ); | ||
5169 | } | ||
5170 | |||
5171 | void opcode_xycb_59( unsigned xy ) // BIT 3, (IX + d) | ||
5172 | { | ||
5173 | testBit( 3, readByte( xy ) ); | ||
5174 | } | ||
5175 | |||
5176 | void opcode_xycb_5a( unsigned xy ) // BIT 3, (IX + d) | ||
5177 | { | ||
5178 | testBit( 3, readByte( xy ) ); | ||
5179 | } | ||
5180 | |||
5181 | void opcode_xycb_5b( unsigned xy ) // BIT 3, (IX + d) | ||
5182 | { | ||
5183 | testBit( 3, readByte( xy ) ); | ||
5184 | } | ||
5185 | |||
5186 | void opcode_xycb_5c( unsigned xy ) // BIT 3, (IX + d) | ||
5187 | { | ||
5188 | testBit( 3, readByte( xy ) ); | ||
5189 | } | ||
5190 | |||
5191 | void opcode_xycb_5d( unsigned xy ) // BIT 3, (IX + d) | ||
5192 | { | ||
5193 | testBit( 3, readByte( xy ) ); | ||
5194 | } | ||
5195 | |||
5196 | void opcode_xycb_5e( unsigned xy ) // BIT 3, (IX + d) | ||
5197 | { | ||
5198 | testBit( 3, readByte( xy ) ); | ||
5199 | } | ||
5200 | |||
5201 | void opcode_xycb_5f( unsigned xy ) // BIT 3, (IX + d) | ||
5202 | { | ||
5203 | testBit( 3, readByte( xy ) ); | ||
5204 | } | ||
5205 | |||
5206 | void opcode_xycb_60( unsigned xy ) // BIT 4, (IX + d) | ||
5207 | { | ||
5208 | testBit( 4, readByte( xy ) ); | ||
5209 | } | ||
5210 | |||
5211 | void opcode_xycb_61( unsigned xy ) // BIT 4, (IX + d) | ||
5212 | { | ||
5213 | testBit( 4, readByte( xy ) ); | ||
5214 | } | ||
5215 | |||
5216 | void opcode_xycb_62( unsigned xy ) // BIT 4, (IX + d) | ||
5217 | { | ||
5218 | testBit( 4, readByte( xy ) ); | ||
5219 | } | ||
5220 | |||
5221 | void opcode_xycb_63( unsigned xy ) // BIT 4, (IX + d) | ||
5222 | { | ||
5223 | testBit( 4, readByte( xy ) ); | ||
5224 | } | ||
5225 | |||
5226 | void opcode_xycb_64( unsigned xy ) // BIT 4, (IX + d) | ||
5227 | { | ||
5228 | testBit( 4, readByte( xy ) ); | ||
5229 | } | ||
5230 | |||
5231 | void opcode_xycb_65( unsigned xy ) // BIT 4, (IX + d) | ||
5232 | { | ||
5233 | testBit( 4, readByte( xy ) ); | ||
5234 | } | ||
5235 | |||
5236 | void opcode_xycb_66( unsigned xy ) // BIT 4, (IX + d) | ||
5237 | { | ||
5238 | testBit( 4, readByte( xy ) ); | ||
5239 | } | ||
5240 | |||
5241 | void opcode_xycb_67( unsigned xy ) // BIT 4, (IX + d) | ||
5242 | { | ||
5243 | testBit( 4, readByte( xy ) ); | ||
5244 | } | ||
5245 | |||
5246 | void opcode_xycb_68( unsigned xy ) // BIT 5, (IX + d) | ||
5247 | { | ||
5248 | testBit( 5, readByte( xy ) ); | ||
5249 | } | ||
5250 | |||
5251 | void opcode_xycb_69( unsigned xy ) // BIT 5, (IX + d) | ||
5252 | { | ||
5253 | testBit( 5, readByte( xy ) ); | ||
5254 | } | ||
5255 | |||
5256 | void opcode_xycb_6a( unsigned xy ) // BIT 5, (IX + d) | ||
5257 | { | ||
5258 | testBit( 5, readByte( xy ) ); | ||
5259 | } | ||
5260 | |||
5261 | void opcode_xycb_6b( unsigned xy ) // BIT 5, (IX + d) | ||
5262 | { | ||
5263 | testBit( 5, readByte( xy ) ); | ||
5264 | } | ||
5265 | |||
5266 | void opcode_xycb_6c( unsigned xy ) // BIT 5, (IX + d) | ||
5267 | { | ||
5268 | testBit( 5, readByte( xy ) ); | ||
5269 | } | ||
5270 | |||
5271 | void opcode_xycb_6d( unsigned xy ) // BIT 5, (IX + d) | ||
5272 | { | ||
5273 | testBit( 5, readByte( xy ) ); | ||
5274 | } | ||
5275 | |||
5276 | void opcode_xycb_6e( unsigned xy ) // BIT 5, (IX + d) | ||
5277 | { | ||
5278 | testBit( 5, readByte( xy ) ); | ||
5279 | } | ||
5280 | |||
5281 | void opcode_xycb_6f( unsigned xy ) // BIT 5, (IX + d) | ||
5282 | { | ||
5283 | testBit( 5, readByte( xy ) ); | ||
5284 | } | ||
5285 | |||
5286 | void opcode_xycb_70( unsigned xy ) // BIT 6, (IX + d) | ||
5287 | { | ||
5288 | testBit( 6, readByte( xy ) ); | ||
5289 | } | ||
5290 | |||
5291 | void opcode_xycb_71( unsigned xy ) // BIT 6, (IX + d) | ||
5292 | { | ||
5293 | testBit( 6, readByte( xy ) ); | ||
5294 | } | ||
5295 | |||
5296 | void opcode_xycb_72( unsigned xy ) // BIT 6, (IX + d) | ||
5297 | { | ||
5298 | testBit( 6, readByte( xy ) ); | ||
5299 | } | ||
5300 | |||
5301 | void opcode_xycb_73( unsigned xy ) // BIT 6, (IX + d) | ||
5302 | { | ||
5303 | testBit( 6, readByte( xy ) ); | ||
5304 | } | ||
5305 | |||
5306 | void opcode_xycb_74( unsigned xy ) // BIT 6, (IX + d) | ||
5307 | { | ||
5308 | testBit( 6, readByte( xy ) ); | ||
5309 | } | ||
5310 | |||
5311 | void opcode_xycb_75( unsigned xy ) // BIT 6, (IX + d) | ||
5312 | { | ||
5313 | testBit( 6, readByte( xy ) ); | ||
5314 | } | ||
5315 | |||
5316 | void opcode_xycb_76( unsigned xy ) // BIT 6, (IX + d) | ||
5317 | { | ||
5318 | testBit( 6, readByte( xy ) ); | ||
5319 | } | ||
5320 | |||
5321 | void opcode_xycb_77( unsigned xy ) // BIT 6, (IX + d) | ||
5322 | { | ||
5323 | testBit( 6, readByte( xy ) ); | ||
5324 | } | ||
5325 | |||
5326 | void opcode_xycb_78( unsigned xy ) // BIT 7, (IX + d) | ||
5327 | { | ||
5328 | testBit( 7, readByte( xy ) ); | ||
5329 | } | ||
5330 | |||
5331 | void opcode_xycb_79( unsigned xy ) // BIT 7, (IX + d) | ||
5332 | { | ||
5333 | testBit( 7, readByte( xy ) ); | ||
5334 | } | ||
5335 | |||
5336 | void opcode_xycb_7a( unsigned xy ) // BIT 7, (IX + d) | ||
5337 | { | ||
5338 | testBit( 7, readByte( xy ) ); | ||
5339 | } | ||
5340 | |||
5341 | void opcode_xycb_7b( unsigned xy ) // BIT 7, (IX + d) | ||
5342 | { | ||
5343 | testBit( 7, readByte( xy ) ); | ||
5344 | } | ||
5345 | |||
5346 | void opcode_xycb_7c( unsigned xy ) // BIT 7, (IX + d) | ||
5347 | { | ||
5348 | testBit( 7, readByte( xy ) ); | ||
5349 | } | ||
5350 | |||
5351 | void opcode_xycb_7d( unsigned xy ) // BIT 7, (IX + d) | ||
5352 | { | ||
5353 | testBit( 7, readByte( xy ) ); | ||
5354 | } | ||
5355 | |||
5356 | void opcode_xycb_7e( unsigned xy ) // BIT 7, (IX + d) | ||
5357 | { | ||
5358 | testBit( 7, readByte( xy ) ); | ||
5359 | } | ||
5360 | |||
5361 | void opcode_xycb_7f( unsigned xy ) // BIT 7, (IX + d) | ||
5362 | { | ||
5363 | testBit( 7, readByte( xy ) ); | ||
5364 | } | ||
5365 | |||
5366 | void opcode_xycb_80( unsigned xy ) // LD B, RES 0, (IX + d) | ||
5367 | { | ||
5368 | B = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5369 | writeByte( xy, B ); | ||
5370 | } | ||
5371 | |||
5372 | void opcode_xycb_81( unsigned xy ) // LD C, RES 0, (IX + d) | ||
5373 | { | ||
5374 | C = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5375 | writeByte( xy, C ); | ||
5376 | } | ||
5377 | |||
5378 | void opcode_xycb_82( unsigned xy ) // LD D, RES 0, (IX + d) | ||
5379 | { | ||
5380 | D = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5381 | writeByte( xy, D ); | ||
5382 | } | ||
5383 | |||
5384 | void opcode_xycb_83( unsigned xy ) // LD E, RES 0, (IX + d) | ||
5385 | { | ||
5386 | E = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5387 | writeByte( xy, E ); | ||
5388 | } | ||
5389 | |||
5390 | void opcode_xycb_84( unsigned xy ) // LD H, RES 0, (IX + d) | ||
5391 | { | ||
5392 | H = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5393 | writeByte( xy, H ); | ||
5394 | } | ||
5395 | |||
5396 | void opcode_xycb_85( unsigned xy ) // LD L, RES 0, (IX + d) | ||
5397 | { | ||
5398 | L = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5399 | writeByte( xy, L ); | ||
5400 | } | ||
5401 | |||
5402 | void opcode_xycb_86( unsigned xy ) // RES 0, (IX + d) | ||
5403 | { | ||
5404 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 0) ); | ||
5405 | } | ||
5406 | |||
5407 | void opcode_xycb_87( unsigned xy ) // LD A, RES 0, (IX + d) | ||
5408 | { | ||
5409 | A = readByte(xy) & (unsigned char) ~(1 << 0); | ||
5410 | writeByte( xy, A ); | ||
5411 | } | ||
5412 | |||
5413 | void opcode_xycb_88( unsigned xy ) // LD B, RES 1, (IX + d) | ||
5414 | { | ||
5415 | B = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5416 | writeByte( xy, B ); | ||
5417 | } | ||
5418 | |||
5419 | void opcode_xycb_89( unsigned xy ) // LD C, RES 1, (IX + d) | ||
5420 | { | ||
5421 | C = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5422 | writeByte( xy, C ); | ||
5423 | } | ||
5424 | |||
5425 | void opcode_xycb_8a( unsigned xy ) // LD D, RES 1, (IX + d) | ||
5426 | { | ||
5427 | D = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5428 | writeByte( xy, D ); | ||
5429 | } | ||
5430 | |||
5431 | void opcode_xycb_8b( unsigned xy ) // LD E, RES 1, (IX + d) | ||
5432 | { | ||
5433 | E = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5434 | writeByte( xy, E ); | ||
5435 | } | ||
5436 | |||
5437 | void opcode_xycb_8c( unsigned xy ) // LD H, RES 1, (IX + d) | ||
5438 | { | ||
5439 | H = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5440 | writeByte( xy, H ); | ||
5441 | } | ||
5442 | |||
5443 | void opcode_xycb_8d( unsigned xy ) // LD L, RES 1, (IX + d) | ||
5444 | { | ||
5445 | L = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5446 | writeByte( xy, L ); | ||
5447 | } | ||
5448 | |||
5449 | void opcode_xycb_8e( unsigned xy ) // RES 1, (IX + d) | ||
5450 | { | ||
5451 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 1) ); | ||
5452 | } | ||
5453 | |||
5454 | void opcode_xycb_8f( unsigned xy ) // LD A, RES 1, (IX + d) | ||
5455 | { | ||
5456 | A = readByte(xy) & (unsigned char) ~(1 << 1); | ||
5457 | writeByte( xy, A ); | ||
5458 | } | ||
5459 | |||
5460 | void opcode_xycb_90( unsigned xy ) // LD B, RES 2, (IX + d) | ||
5461 | { | ||
5462 | B = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5463 | writeByte( xy, B ); | ||
5464 | } | ||
5465 | |||
5466 | void opcode_xycb_91( unsigned xy ) // LD C, RES 2, (IX + d) | ||
5467 | { | ||
5468 | C = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5469 | writeByte( xy, C ); | ||
5470 | } | ||
5471 | |||
5472 | void opcode_xycb_92( unsigned xy ) // LD D, RES 2, (IX + d) | ||
5473 | { | ||
5474 | D = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5475 | writeByte( xy, D ); | ||
5476 | } | ||
5477 | |||
5478 | void opcode_xycb_93( unsigned xy ) // LD E, RES 2, (IX + d) | ||
5479 | { | ||
5480 | E = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5481 | writeByte( xy, E ); | ||
5482 | } | ||
5483 | |||
5484 | void opcode_xycb_94( unsigned xy ) // LD H, RES 2, (IX + d) | ||
5485 | { | ||
5486 | H = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5487 | writeByte( xy, H ); | ||
5488 | } | ||
5489 | |||
5490 | void opcode_xycb_95( unsigned xy ) // LD L, RES 2, (IX + d) | ||
5491 | { | ||
5492 | L = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5493 | writeByte( xy, L ); | ||
5494 | } | ||
5495 | |||
5496 | void opcode_xycb_96( unsigned xy ) // RES 2, (IX + d) | ||
5497 | { | ||
5498 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 2) ); | ||
5499 | } | ||
5500 | |||
5501 | void opcode_xycb_97( unsigned xy ) // LD A, RES 2, (IX + d) | ||
5502 | { | ||
5503 | A = readByte(xy) & (unsigned char) ~(1 << 2); | ||
5504 | writeByte( xy, A ); | ||
5505 | } | ||
5506 | |||
5507 | void opcode_xycb_98( unsigned xy ) // LD B, RES 3, (IX + d) | ||
5508 | { | ||
5509 | B = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5510 | writeByte( xy, B ); | ||
5511 | } | ||
5512 | |||
5513 | void opcode_xycb_99( unsigned xy ) // LD C, RES 3, (IX + d) | ||
5514 | { | ||
5515 | C = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5516 | writeByte( xy, C ); | ||
5517 | } | ||
5518 | |||
5519 | void opcode_xycb_9a( unsigned xy ) // LD D, RES 3, (IX + d) | ||
5520 | { | ||
5521 | D = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5522 | writeByte( xy, D ); | ||
5523 | } | ||
5524 | |||
5525 | void opcode_xycb_9b( unsigned xy ) // LD E, RES 3, (IX + d) | ||
5526 | { | ||
5527 | E = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5528 | writeByte( xy, E ); | ||
5529 | } | ||
5530 | |||
5531 | void opcode_xycb_9c( unsigned xy ) // LD H, RES 3, (IX + d) | ||
5532 | { | ||
5533 | H = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5534 | writeByte( xy, H ); | ||
5535 | } | ||
5536 | |||
5537 | void opcode_xycb_9d( unsigned xy ) // LD L, RES 3, (IX + d) | ||
5538 | { | ||
5539 | L = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5540 | writeByte( xy, L ); | ||
5541 | } | ||
5542 | |||
5543 | void opcode_xycb_9e( unsigned xy ) // RES 3, (IX + d) | ||
5544 | { | ||
5545 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 3) ); | ||
5546 | } | ||
5547 | |||
5548 | void opcode_xycb_9f( unsigned xy ) // LD A, RES 3, (IX + d) | ||
5549 | { | ||
5550 | A = readByte(xy) & (unsigned char) ~(1 << 3); | ||
5551 | writeByte( xy, A ); | ||
5552 | } | ||
5553 | |||
5554 | void opcode_xycb_a0( unsigned xy ) // LD B, RES 4, (IX + d) | ||
5555 | { | ||
5556 | B = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5557 | writeByte( xy, B ); | ||
5558 | } | ||
5559 | |||
5560 | void opcode_xycb_a1( unsigned xy ) // LD C, RES 4, (IX + d) | ||
5561 | { | ||
5562 | C = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5563 | writeByte( xy, C ); | ||
5564 | } | ||
5565 | |||
5566 | void opcode_xycb_a2( unsigned xy ) // LD D, RES 4, (IX + d) | ||
5567 | { | ||
5568 | D = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5569 | writeByte( xy, D ); | ||
5570 | } | ||
5571 | |||
5572 | void opcode_xycb_a3( unsigned xy ) // LD E, RES 4, (IX + d) | ||
5573 | { | ||
5574 | E = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5575 | writeByte( xy, E ); | ||
5576 | } | ||
5577 | |||
5578 | void opcode_xycb_a4( unsigned xy ) // LD H, RES 4, (IX + d) | ||
5579 | { | ||
5580 | H = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5581 | writeByte( xy, H ); | ||
5582 | } | ||
5583 | |||
5584 | void opcode_xycb_a5( unsigned xy ) // LD L, RES 4, (IX + d) | ||
5585 | { | ||
5586 | L = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5587 | writeByte( xy, L ); | ||
5588 | } | ||
5589 | |||
5590 | void opcode_xycb_a6( unsigned xy ) // RES 4, (IX + d) | ||
5591 | { | ||
5592 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 4) ); | ||
5593 | } | ||
5594 | |||
5595 | void opcode_xycb_a7( unsigned xy ) // LD A, RES 4, (IX + d) | ||
5596 | { | ||
5597 | A = readByte(xy) & (unsigned char) ~(1 << 4); | ||
5598 | writeByte( xy, A ); | ||
5599 | } | ||
5600 | |||
5601 | void opcode_xycb_a8( unsigned xy ) // LD B, RES 5, (IX + d) | ||
5602 | { | ||
5603 | B = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5604 | writeByte( xy, B ); | ||
5605 | } | ||
5606 | |||
5607 | void opcode_xycb_a9( unsigned xy ) // LD C, RES 5, (IX + d) | ||
5608 | { | ||
5609 | C = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5610 | writeByte( xy, C ); | ||
5611 | } | ||
5612 | |||
5613 | void opcode_xycb_aa( unsigned xy ) // LD D, RES 5, (IX + d) | ||
5614 | { | ||
5615 | D = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5616 | writeByte( xy, D ); | ||
5617 | } | ||
5618 | |||
5619 | void opcode_xycb_ab( unsigned xy ) // LD E, RES 5, (IX + d) | ||
5620 | { | ||
5621 | E = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5622 | writeByte( xy, E ); | ||
5623 | } | ||
5624 | |||
5625 | void opcode_xycb_ac( unsigned xy ) // LD H, RES 5, (IX + d) | ||
5626 | { | ||
5627 | H = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5628 | writeByte( xy, H ); | ||
5629 | } | ||
5630 | |||
5631 | void opcode_xycb_ad( unsigned xy ) // LD L, RES 5, (IX + d) | ||
5632 | { | ||
5633 | L = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5634 | writeByte( xy, L ); | ||
5635 | } | ||
5636 | |||
5637 | void opcode_xycb_ae( unsigned xy ) // RES 5, (IX + d) | ||
5638 | { | ||
5639 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 5) ); | ||
5640 | } | ||
5641 | |||
5642 | void opcode_xycb_af( unsigned xy ) // LD A, RES 5, (IX + d) | ||
5643 | { | ||
5644 | A = readByte(xy) & (unsigned char) ~(1 << 5); | ||
5645 | writeByte( xy, A ); | ||
5646 | } | ||
5647 | |||
5648 | void opcode_xycb_b0( unsigned xy ) // LD B, RES 6, (IX + d) | ||
5649 | { | ||
5650 | B = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5651 | writeByte( xy, B ); | ||
5652 | } | ||
5653 | |||
5654 | void opcode_xycb_b1( unsigned xy ) // LD C, RES 6, (IX + d) | ||
5655 | { | ||
5656 | C = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5657 | writeByte( xy, C ); | ||
5658 | } | ||
5659 | |||
5660 | void opcode_xycb_b2( unsigned xy ) // LD D, RES 6, (IX + d) | ||
5661 | { | ||
5662 | D = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5663 | writeByte( xy, D ); | ||
5664 | } | ||
5665 | |||
5666 | void opcode_xycb_b3( unsigned xy ) // LD E, RES 6, (IX + d) | ||
5667 | { | ||
5668 | E = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5669 | writeByte( xy, E ); | ||
5670 | } | ||
5671 | |||
5672 | void opcode_xycb_b4( unsigned xy ) // LD H, RES 6, (IX + d) | ||
5673 | { | ||
5674 | H = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5675 | writeByte( xy, H ); | ||
5676 | } | ||
5677 | |||
5678 | void opcode_xycb_b5( unsigned xy ) // LD L, RES 6, (IX + d) | ||
5679 | { | ||
5680 | L = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5681 | writeByte( xy, L ); | ||
5682 | } | ||
5683 | |||
5684 | void opcode_xycb_b6( unsigned xy ) // RES 6, (IX + d) | ||
5685 | { | ||
5686 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 6) ); | ||
5687 | } | ||
5688 | |||
5689 | void opcode_xycb_b7( unsigned xy ) // LD A, RES 6, (IX + d) | ||
5690 | { | ||
5691 | A = readByte(xy) & (unsigned char) ~(1 << 6); | ||
5692 | writeByte( xy, A ); | ||
5693 | } | ||
5694 | |||
5695 | void opcode_xycb_b8( unsigned xy ) // LD B, RES 7, (IX + d) | ||
5696 | { | ||
5697 | B = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5698 | writeByte( xy, B ); | ||
5699 | } | ||
5700 | |||
5701 | void opcode_xycb_b9( unsigned xy ) // LD C, RES 7, (IX + d) | ||
5702 | { | ||
5703 | C = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5704 | writeByte( xy, C ); | ||
5705 | } | ||
5706 | |||
5707 | void opcode_xycb_ba( unsigned xy ) // LD D, RES 7, (IX + d) | ||
5708 | { | ||
5709 | D = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5710 | writeByte( xy, D ); | ||
5711 | } | ||
5712 | |||
5713 | void opcode_xycb_bb( unsigned xy ) // LD E, RES 7, (IX + d) | ||
5714 | { | ||
5715 | E = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5716 | writeByte( xy, E ); | ||
5717 | } | ||
5718 | |||
5719 | void opcode_xycb_bc( unsigned xy ) // LD H, RES 7, (IX + d) | ||
5720 | { | ||
5721 | H = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5722 | writeByte( xy, H ); | ||
5723 | } | ||
5724 | |||
5725 | void opcode_xycb_bd( unsigned xy ) // LD L, RES 7, (IX + d) | ||
5726 | { | ||
5727 | L = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5728 | writeByte( xy, L ); | ||
5729 | } | ||
5730 | |||
5731 | void opcode_xycb_be( unsigned xy ) // RES 7, (IX + d) | ||
5732 | { | ||
5733 | writeByte( xy, readByte(xy) & (unsigned char) ~(1 << 7) ); | ||
5734 | } | ||
5735 | |||
5736 | void opcode_xycb_bf( unsigned xy ) // LD A, RES 7, (IX + d) | ||
5737 | { | ||
5738 | A = readByte(xy) & (unsigned char) ~(1 << 7); | ||
5739 | writeByte( xy, A ); | ||
5740 | } | ||
5741 | |||
5742 | void opcode_xycb_c0( unsigned xy ) // LD B, SET 0, (IX + d) | ||
5743 | { | ||
5744 | B = readByte(xy) | (unsigned char) (1 << 0); | ||
5745 | writeByte( xy, B ); | ||
5746 | } | ||
5747 | |||
5748 | void opcode_xycb_c1( unsigned xy ) // LD C, SET 0, (IX + d) | ||
5749 | { | ||
5750 | C = readByte(xy) | (unsigned char) (1 << 0); | ||
5751 | writeByte( xy, C ); | ||
5752 | } | ||
5753 | |||
5754 | void opcode_xycb_c2( unsigned xy ) // LD D, SET 0, (IX + d) | ||
5755 | { | ||
5756 | D = readByte(xy) | (unsigned char) (1 << 0); | ||
5757 | writeByte( xy, D ); | ||
5758 | } | ||
5759 | |||
5760 | void opcode_xycb_c3( unsigned xy ) // LD E, SET 0, (IX + d) | ||
5761 | { | ||
5762 | E = readByte(xy) | (unsigned char) (1 << 0); | ||
5763 | writeByte( xy, E ); | ||
5764 | } | ||
5765 | |||
5766 | void opcode_xycb_c4( unsigned xy ) // LD H, SET 0, (IX + d) | ||
5767 | { | ||
5768 | H = readByte(xy) | (unsigned char) (1 << 0); | ||
5769 | writeByte( xy, H ); | ||
5770 | } | ||
5771 | |||
5772 | void opcode_xycb_c5( unsigned xy ) // LD L, SET 0, (IX + d) | ||
5773 | { | ||
5774 | L = readByte(xy) | (unsigned char) (1 << 0); | ||
5775 | writeByte( xy, L ); | ||
5776 | } | ||
5777 | |||
5778 | void opcode_xycb_c6( unsigned xy ) // SET 0, (IX + d) | ||
5779 | { | ||
5780 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 0) ); | ||
5781 | } | ||
5782 | |||
5783 | void opcode_xycb_c7( unsigned xy ) // LD A, SET 0, (IX + d) | ||
5784 | { | ||
5785 | A = readByte(xy) | (unsigned char) (1 << 0); | ||
5786 | writeByte( xy, A ); | ||
5787 | } | ||
5788 | |||
5789 | void opcode_xycb_c8( unsigned xy ) // LD B, SET 1, (IX + d) | ||
5790 | { | ||
5791 | B = readByte(xy) | (unsigned char) (1 << 1); | ||
5792 | writeByte( xy, B ); | ||
5793 | } | ||
5794 | |||
5795 | void opcode_xycb_c9( unsigned xy ) // LD C, SET 1, (IX + d) | ||
5796 | { | ||
5797 | C = readByte(xy) | (unsigned char) (1 << 1); | ||
5798 | writeByte( xy, C ); | ||
5799 | } | ||
5800 | |||
5801 | void opcode_xycb_ca( unsigned xy ) // LD D, SET 1, (IX + d) | ||
5802 | { | ||
5803 | D = readByte(xy) | (unsigned char) (1 << 1); | ||
5804 | writeByte( xy, D ); | ||
5805 | } | ||
5806 | |||
5807 | void opcode_xycb_cb( unsigned xy ) // LD E, SET 1, (IX + d) | ||
5808 | { | ||
5809 | E = readByte(xy) | (unsigned char) (1 << 1); | ||
5810 | writeByte( xy, E ); | ||
5811 | } | ||
5812 | |||
5813 | void opcode_xycb_cc( unsigned xy ) // LD H, SET 1, (IX + d) | ||
5814 | { | ||
5815 | H = readByte(xy) | (unsigned char) (1 << 1); | ||
5816 | writeByte( xy, H ); | ||
5817 | } | ||
5818 | |||
5819 | void opcode_xycb_cd( unsigned xy ) // LD L, SET 1, (IX + d) | ||
5820 | { | ||
5821 | L = readByte(xy) | (unsigned char) (1 << 1); | ||
5822 | writeByte( xy, L ); | ||
5823 | } | ||
5824 | |||
5825 | void opcode_xycb_ce( unsigned xy ) // SET 1, (IX + d) | ||
5826 | { | ||
5827 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 1) ); | ||
5828 | } | ||
5829 | |||
5830 | void opcode_xycb_cf( unsigned xy ) // LD A, SET 1, (IX + d) | ||
5831 | { | ||
5832 | A = readByte(xy) | (unsigned char) (1 << 1); | ||
5833 | writeByte( xy, A ); | ||
5834 | } | ||
5835 | |||
5836 | void opcode_xycb_d0( unsigned xy ) // LD B, SET 2, (IX + d) | ||
5837 | { | ||
5838 | B = readByte(xy) | (unsigned char) (1 << 2); | ||
5839 | writeByte( xy, B ); | ||
5840 | } | ||
5841 | |||
5842 | void opcode_xycb_d1( unsigned xy ) // LD C, SET 2, (IX + d) | ||
5843 | { | ||
5844 | C = readByte(xy) | (unsigned char) (1 << 2); | ||
5845 | writeByte( xy, C ); | ||
5846 | } | ||
5847 | |||
5848 | void opcode_xycb_d2( unsigned xy ) // LD D, SET 2, (IX + d) | ||
5849 | { | ||
5850 | D = readByte(xy) | (unsigned char) (1 << 2); | ||
5851 | writeByte( xy, D ); | ||
5852 | } | ||
5853 | |||
5854 | void opcode_xycb_d3( unsigned xy ) // LD E, SET 2, (IX + d) | ||
5855 | { | ||
5856 | E = readByte(xy) | (unsigned char) (1 << 2); | ||
5857 | writeByte( xy, E ); | ||
5858 | } | ||
5859 | |||
5860 | void opcode_xycb_d4( unsigned xy ) // LD H, SET 2, (IX + d) | ||
5861 | { | ||
5862 | H = readByte(xy) | (unsigned char) (1 << 2); | ||
5863 | writeByte( xy, H ); | ||
5864 | } | ||
5865 | |||
5866 | void opcode_xycb_d5( unsigned xy ) // LD L, SET 2, (IX + d) | ||
5867 | { | ||
5868 | L = readByte(xy) | (unsigned char) (1 << 2); | ||
5869 | writeByte( xy, L ); | ||
5870 | } | ||
5871 | |||
5872 | void opcode_xycb_d6( unsigned xy ) // SET 2, (IX + d) | ||
5873 | { | ||
5874 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 2) ); | ||
5875 | } | ||
5876 | |||
5877 | void opcode_xycb_d7( unsigned xy ) // LD A, SET 2, (IX + d) | ||
5878 | { | ||
5879 | A = readByte(xy) | (unsigned char) (1 << 2); | ||
5880 | writeByte( xy, A ); | ||
5881 | } | ||
5882 | |||
5883 | void opcode_xycb_d8( unsigned xy ) // LD B, SET 3, (IX + d) | ||
5884 | { | ||
5885 | B = readByte(xy) | (unsigned char) (1 << 3); | ||
5886 | writeByte( xy, B ); | ||
5887 | } | ||
5888 | |||
5889 | void opcode_xycb_d9( unsigned xy ) // LD C, SET 3, (IX + d) | ||
5890 | { | ||
5891 | C = readByte(xy) | (unsigned char) (1 << 3); | ||
5892 | writeByte( xy, C ); | ||
5893 | } | ||
5894 | |||
5895 | void opcode_xycb_da( unsigned xy ) // LD D, SET 3, (IX + d) | ||
5896 | { | ||
5897 | D = readByte(xy) | (unsigned char) (1 << 3); | ||
5898 | writeByte( xy, D ); | ||
5899 | } | ||
5900 | |||
5901 | void opcode_xycb_db( unsigned xy ) // LD E, SET 3, (IX + d) | ||
5902 | { | ||
5903 | E = readByte(xy) | (unsigned char) (1 << 3); | ||
5904 | writeByte( xy, E ); | ||
5905 | } | ||
5906 | |||
5907 | void opcode_xycb_dc( unsigned xy ) // LD H, SET 3, (IX + d) | ||
5908 | { | ||
5909 | H = readByte(xy) | (unsigned char) (1 << 3); | ||
5910 | writeByte( xy, H ); | ||
5911 | } | ||
5912 | |||
5913 | void opcode_xycb_dd( unsigned xy ) // LD L, SET 3, (IX + d) | ||
5914 | { | ||
5915 | L = readByte(xy) | (unsigned char) (1 << 3); | ||
5916 | writeByte( xy, L ); | ||
5917 | } | ||
5918 | |||
5919 | void opcode_xycb_de( unsigned xy ) // SET 3, (IX + d) | ||
5920 | { | ||
5921 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 3) ); | ||
5922 | } | ||
5923 | |||
5924 | void opcode_xycb_df( unsigned xy ) // LD A, SET 3, (IX + d) | ||
5925 | { | ||
5926 | A = readByte(xy) | (unsigned char) (1 << 3); | ||
5927 | writeByte( xy, A ); | ||
5928 | } | ||
5929 | |||
5930 | void opcode_xycb_e0( unsigned xy ) // LD B, SET 4, (IX + d) | ||
5931 | { | ||
5932 | B = readByte(xy) | (unsigned char) (1 << 4); | ||
5933 | writeByte( xy, B ); | ||
5934 | } | ||
5935 | |||
5936 | void opcode_xycb_e1( unsigned xy ) // LD C, SET 4, (IX + d) | ||
5937 | { | ||
5938 | C = readByte(xy) | (unsigned char) (1 << 4); | ||
5939 | writeByte( xy, C ); | ||
5940 | } | ||
5941 | |||
5942 | void opcode_xycb_e2( unsigned xy ) // LD D, SET 4, (IX + d) | ||
5943 | { | ||
5944 | D = readByte(xy) | (unsigned char) (1 << 4); | ||
5945 | writeByte( xy, D ); | ||
5946 | } | ||
5947 | |||
5948 | void opcode_xycb_e3( unsigned xy ) // LD E, SET 4, (IX + d) | ||
5949 | { | ||
5950 | E = readByte(xy) | (unsigned char) (1 << 4); | ||
5951 | writeByte( xy, E ); | ||
5952 | } | ||
5953 | |||
5954 | void opcode_xycb_e4( unsigned xy ) // LD H, SET 4, (IX + d) | ||
5955 | { | ||
5956 | H = readByte(xy) | (unsigned char) (1 << 4); | ||
5957 | writeByte( xy, H ); | ||
5958 | } | ||
5959 | |||
5960 | void opcode_xycb_e5( unsigned xy ) // LD L, SET 4, (IX + d) | ||
5961 | { | ||
5962 | L = readByte(xy) | (unsigned char) (1 << 4); | ||
5963 | writeByte( xy, L ); | ||
5964 | } | ||
5965 | |||
5966 | void opcode_xycb_e6( unsigned xy ) // SET 4, (IX + d) | ||
5967 | { | ||
5968 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 4) ); | ||
5969 | } | ||
5970 | |||
5971 | void opcode_xycb_e7( unsigned xy ) // LD A, SET 4, (IX + d) | ||
5972 | { | ||
5973 | A = readByte(xy) | (unsigned char) (1 << 4); | ||
5974 | writeByte( xy, A ); | ||
5975 | } | ||
5976 | |||
5977 | void opcode_xycb_e8( unsigned xy ) // LD B, SET 5, (IX + d) | ||
5978 | { | ||
5979 | B = readByte(xy) | (unsigned char) (1 << 5); | ||
5980 | writeByte( xy, B ); | ||
5981 | } | ||
5982 | |||
5983 | void opcode_xycb_e9( unsigned xy ) // LD C, SET 5, (IX + d) | ||
5984 | { | ||
5985 | C = readByte(xy) | (unsigned char) (1 << 5); | ||
5986 | writeByte( xy, C ); | ||
5987 | } | ||
5988 | |||
5989 | void opcode_xycb_ea( unsigned xy ) // LD D, SET 5, (IX + d) | ||
5990 | { | ||
5991 | D = readByte(xy) | (unsigned char) (1 << 5); | ||
5992 | writeByte( xy, D ); | ||
5993 | } | ||
5994 | |||
5995 | void opcode_xycb_eb( unsigned xy ) // LD E, SET 5, (IX + d) | ||
5996 | { | ||
5997 | E = readByte(xy) | (unsigned char) (1 << 5); | ||
5998 | writeByte( xy, E ); | ||
5999 | } | ||
6000 | |||
6001 | void opcode_xycb_ec( unsigned xy ) // LD H, SET 5, (IX + d) | ||
6002 | { | ||
6003 | H = readByte(xy) | (unsigned char) (1 << 5); | ||
6004 | writeByte( xy, H ); | ||
6005 | } | ||
6006 | |||
6007 | void opcode_xycb_ed( unsigned xy ) // LD L, SET 5, (IX + d) | ||
6008 | { | ||
6009 | L = readByte(xy) | (unsigned char) (1 << 5); | ||
6010 | writeByte( xy, L ); | ||
6011 | } | ||
6012 | |||
6013 | void opcode_xycb_ee( unsigned xy ) // SET 5, (IX + d) | ||
6014 | { | ||
6015 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 5) ); | ||
6016 | } | ||
6017 | |||
6018 | void opcode_xycb_ef( unsigned xy ) // LD A, SET 5, (IX + d) | ||
6019 | { | ||
6020 | A = readByte(xy) | (unsigned char) (1 << 5); | ||
6021 | writeByte( xy, A ); | ||
6022 | } | ||
6023 | |||
6024 | void opcode_xycb_f0( unsigned xy ) // LD B, SET 6, (IX + d) | ||
6025 | { | ||
6026 | B = readByte(xy) | (unsigned char) (1 << 6); | ||
6027 | writeByte( xy, B ); | ||
6028 | } | ||
6029 | |||
6030 | void opcode_xycb_f1( unsigned xy ) // LD C, SET 6, (IX + d) | ||
6031 | { | ||
6032 | C = readByte(xy) | (unsigned char) (1 << 6); | ||
6033 | writeByte( xy, C ); | ||
6034 | } | ||
6035 | |||
6036 | void opcode_xycb_f2( unsigned xy ) // LD D, SET 6, (IX + d) | ||
6037 | { | ||
6038 | D = readByte(xy) | (unsigned char) (1 << 6); | ||
6039 | writeByte( xy, D ); | ||
6040 | } | ||
6041 | |||
6042 | void opcode_xycb_f3( unsigned xy ) // LD E, SET 6, (IX + d) | ||
6043 | { | ||
6044 | E = readByte(xy) | (unsigned char) (1 << 6); | ||
6045 | writeByte( xy, E ); | ||
6046 | } | ||
6047 | |||
6048 | void opcode_xycb_f4( unsigned xy ) // LD H, SET 6, (IX + d) | ||
6049 | { | ||
6050 | H = readByte(xy) | (unsigned char) (1 << 6); | ||
6051 | writeByte( xy, H ); | ||
6052 | } | ||
6053 | |||
6054 | void opcode_xycb_f5( unsigned xy ) // LD L, SET 6, (IX + d) | ||
6055 | { | ||
6056 | L = readByte(xy) | (unsigned char) (1 << 6); | ||
6057 | writeByte( xy, L ); | ||
6058 | } | ||
6059 | |||
6060 | void opcode_xycb_f6( unsigned xy ) // SET 6, (IX + d) | ||
6061 | { | ||
6062 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 6) ); | ||
6063 | } | ||
6064 | |||
6065 | void opcode_xycb_f7( unsigned xy ) // LD A, SET 6, (IX + d) | ||
6066 | { | ||
6067 | A = readByte(xy) | (unsigned char) (1 << 6); | ||
6068 | writeByte( xy, A ); | ||
6069 | } | ||
6070 | |||
6071 | void opcode_xycb_f8( unsigned xy ) // LD B, SET 7, (IX + d) | ||
6072 | { | ||
6073 | B = readByte(xy) | (unsigned char) (1 << 7); | ||
6074 | writeByte( xy, B ); | ||
6075 | } | ||
6076 | |||
6077 | void opcode_xycb_f9( unsigned xy ) // LD C, SET 7, (IX + d) | ||
6078 | { | ||
6079 | C = readByte(xy) | (unsigned char) (1 << 7); | ||
6080 | writeByte( xy, C ); | ||
6081 | } | ||
6082 | |||
6083 | void opcode_xycb_fa( unsigned xy ) // LD D, SET 7, (IX + d) | ||
6084 | { | ||
6085 | D = readByte(xy) | (unsigned char) (1 << 7); | ||
6086 | writeByte( xy, D ); | ||
6087 | } | ||
6088 | |||
6089 | void opcode_xycb_fb( unsigned xy ) // LD E, SET 7, (IX + d) | ||
6090 | { | ||
6091 | E = readByte(xy) | (unsigned char) (1 << 7); | ||
6092 | writeByte( xy, E ); | ||
6093 | } | ||
6094 | |||
6095 | void opcode_xycb_fc( unsigned xy ) // LD H, SET 7, (IX + d) | ||
6096 | { | ||
6097 | H = readByte(xy) | (unsigned char) (1 << 7); | ||
6098 | writeByte( xy, H ); | ||
6099 | } | ||
6100 | |||
6101 | void opcode_xycb_fd( unsigned xy ) // LD L, SET 7, (IX + d) | ||
6102 | { | ||
6103 | L = readByte(xy) | (unsigned char) (1 << 7); | ||
6104 | writeByte( xy, L ); | ||
6105 | } | ||
6106 | |||
6107 | void opcode_xycb_fe( unsigned xy ) // SET 7, (IX + d) | ||
6108 | { | ||
6109 | writeByte( xy, readByte(xy) | (unsigned char) (1 << 7) ); | ||
6110 | } | ||
6111 | |||
6112 | void opcode_xycb_ff( unsigned xy ) // LD A, SET 7, (IX + d) | ||
6113 | { | ||
6114 | A = readByte(xy) | (unsigned char) (1 << 7); | ||
6115 | writeByte( xy, A ); | ||
6116 | } | ||
6117 | |||
6118 | OpcodeInfo OpInfo_[256] = { | ||
6119 | { &opcode_00, 4 }, // NOP | ||
6120 | { &opcode_01, 10 }, // LD BC,nn | ||
6121 | { &opcode_02, 7 }, // LD (BC),A | ||
6122 | { &opcode_03, 6 }, // INC BC | ||
6123 | { &opcode_04, 4 }, // INC B | ||
6124 | { &opcode_05, 4 }, // DEC B | ||
6125 | { &opcode_06, 7 }, // LD B,n | ||
6126 | { &opcode_07, 4 }, // RLCA | ||
6127 | { &opcode_08, 4 }, // EX AF,AF' | ||
6128 | { &opcode_09, 11 }, // ADD HL,BC | ||
6129 | { &opcode_0a, 7 }, // LD A,(BC) | ||
6130 | { &opcode_0b, 6 }, // DEC BC | ||
6131 | { &opcode_0c, 4 }, // INC C | ||
6132 | { &opcode_0d, 4 }, // DEC C | ||
6133 | { &opcode_0e, 7 }, // LD C,n | ||
6134 | { &opcode_0f, 4 }, // RRCA | ||
6135 | { &opcode_10, 8 }, // DJNZ d | ||
6136 | { &opcode_11, 10 }, // LD DE,nn | ||
6137 | { &opcode_12, 7 }, // LD (DE),A | ||
6138 | { &opcode_13, 6 }, // INC DE | ||
6139 | { &opcode_14, 4 }, // INC D | ||
6140 | { &opcode_15, 4 }, // DEC D | ||
6141 | { &opcode_16, 7 }, // LD D,n | ||
6142 | { &opcode_17, 4 }, // RLA | ||
6143 | { &opcode_18, 12 }, // JR d | ||
6144 | { &opcode_19, 11 }, // ADD HL,DE | ||
6145 | { &opcode_1a, 7 }, // LD A,(DE) | ||
6146 | { &opcode_1b, 6 }, // DEC DE | ||
6147 | { &opcode_1c, 4 }, // INC E | ||
6148 | { &opcode_1d, 4 }, // DEC E | ||
6149 | { &opcode_1e, 7 }, // LD E,n | ||
6150 | { &opcode_1f, 4 }, // RRA | ||
6151 | { &opcode_20, 7 }, // JR NZ,d | ||
6152 | { &opcode_21, 10 }, // LD HL,nn | ||
6153 | { &opcode_22, 16 }, // LD (nn),HL | ||
6154 | { &opcode_23, 6 }, // INC HL | ||
6155 | { &opcode_24, 4 }, // INC H | ||
6156 | { &opcode_25, 4 }, // DEC H | ||
6157 | { &opcode_26, 7 }, // LD H,n | ||
6158 | { &opcode_27, 4 }, // DAA | ||
6159 | { &opcode_28, 7 }, // JR Z,d | ||
6160 | { &opcode_29, 11 }, // ADD HL,HL | ||
6161 | { &opcode_2a, 16 }, // LD HL,(nn) | ||
6162 | { &opcode_2b, 6 }, // DEC HL | ||
6163 | { &opcode_2c, 4 }, // INC L | ||
6164 | { &opcode_2d, 4 }, // DEC L | ||
6165 | { &opcode_2e, 7 }, // LD L,n | ||
6166 | { &opcode_2f, 4 }, // CPL | ||
6167 | { &opcode_30, 7 }, // JR NC,d | ||
6168 | { &opcode_31, 10 }, // LD SP,nn | ||
6169 | { &opcode_32, 13 }, // LD (nn),A | ||
6170 | { &opcode_33, 6 }, // INC SP | ||
6171 | { &opcode_34, 11 }, // INC (HL) | ||
6172 | { &opcode_35, 11 }, // DEC (HL) | ||
6173 | { &opcode_36, 10 }, // LD (HL),n | ||
6174 | { &opcode_37, 4 }, // SCF | ||
6175 | { &opcode_38, 7 }, // JR C,d | ||
6176 | { &opcode_39, 11 }, // ADD HL,SP | ||
6177 | { &opcode_3a, 13 }, // LD A,(nn) | ||
6178 | { &opcode_3b, 6 }, // DEC SP | ||
6179 | { &opcode_3c, 4 }, // INC A | ||
6180 | { &opcode_3d, 4 }, // DEC A | ||
6181 | { &opcode_3e, 7 }, // LD A,n | ||
6182 | { &opcode_3f, 4 }, // CCF | ||
6183 | { &opcode_40, 4 }, // LD B,B | ||
6184 | { &opcode_41, 4 }, // LD B,C | ||
6185 | { &opcode_42, 4 }, // LD B,D | ||
6186 | { &opcode_43, 4 }, // LD B,E | ||
6187 | { &opcode_44, 4 }, // LD B,H | ||
6188 | { &opcode_45, 4 }, // LD B,L | ||
6189 | { &opcode_46, 7 }, // LD B,(HL) | ||
6190 | { &opcode_47, 4 }, // LD B,A | ||
6191 | { &opcode_48, 4 }, // LD C,B | ||
6192 | { &opcode_49, 4 }, // LD C,C | ||
6193 | { &opcode_4a, 4 }, // LD C,D | ||
6194 | { &opcode_4b, 4 }, // LD C,E | ||
6195 | { &opcode_4c, 4 }, // LD C,H | ||
6196 | { &opcode_4d, 4 }, // LD C,L | ||
6197 | { &opcode_4e, 7 }, // LD C,(HL) | ||
6198 | { &opcode_4f, 4 }, // LD C,A | ||
6199 | { &opcode_50, 4 }, // LD D,B | ||
6200 | { &opcode_51, 4 }, // LD D,C | ||
6201 | { &opcode_52, 4 }, // LD D,D | ||
6202 | { &opcode_53, 4 }, // LD D,E | ||
6203 | { &opcode_54, 4 }, // LD D,H | ||
6204 | { &opcode_55, 4 }, // LD D,L | ||
6205 | { &opcode_56, 7 }, // LD D,(HL) | ||
6206 | { &opcode_57, 4 }, // LD D,A | ||
6207 | { &opcode_58, 4 }, // LD E,B | ||
6208 | { &opcode_59, 4 }, // LD E,C | ||
6209 | { &opcode_5a, 4 }, // LD E,D | ||
6210 | { &opcode_5b, 4 }, // LD E,E | ||
6211 | { &opcode_5c, 4 }, // LD E,H | ||
6212 | { &opcode_5d, 4 }, // LD E,L | ||
6213 | { &opcode_5e, 7 }, // LD E,(HL) | ||
6214 | { &opcode_5f, 4 }, // LD E,A | ||
6215 | { &opcode_60, 4 }, // LD H,B | ||
6216 | { &opcode_61, 4 }, // LD H,C | ||
6217 | { &opcode_62, 4 }, // LD H,D | ||
6218 | { &opcode_63, 4 }, // LD H,E | ||
6219 | { &opcode_64, 4 }, // LD H,H | ||
6220 | { &opcode_65, 4 }, // LD H,L | ||
6221 | { &opcode_66, 7 }, // LD H,(HL) | ||
6222 | { &opcode_67, 4 }, // LD H,A | ||
6223 | { &opcode_68, 4 }, // LD L,B | ||
6224 | { &opcode_69, 4 }, // LD L,C | ||
6225 | { &opcode_6a, 4 }, // LD L,D | ||
6226 | { &opcode_6b, 4 }, // LD L,E | ||
6227 | { &opcode_6c, 4 }, // LD L,H | ||
6228 | { &opcode_6d, 4 }, // LD L,L | ||
6229 | { &opcode_6e, 7 }, // LD L,(HL) | ||
6230 | { &opcode_6f, 4 }, // LD L,A | ||
6231 | { &opcode_70, 7 }, // LD (HL),B | ||
6232 | { &opcode_71, 7 }, // LD (HL),C | ||
6233 | { &opcode_72, 7 }, // LD (HL),D | ||
6234 | { &opcode_73, 7 }, // LD (HL),E | ||
6235 | { &opcode_74, 7 }, // LD (HL),H | ||
6236 | { &opcode_75, 7 }, // LD (HL),L | ||
6237 | { &opcode_76, 4 }, // HALT | ||
6238 | { &opcode_77, 7 }, // LD (HL),A | ||
6239 | { &opcode_78, 4 }, // LD A,B | ||
6240 | { &opcode_79, 4 }, // LD A,C | ||
6241 | { &opcode_7a, 4 }, // LD A,D | ||
6242 | { &opcode_7b, 4 }, // LD A,E | ||
6243 | { &opcode_7c, 4 }, // LD A,H | ||
6244 | { &opcode_7d, 4 }, // LD A,L | ||
6245 | { &opcode_7e, 7 }, // LD A,(HL) | ||
6246 | { &opcode_7f, 4 }, // LD A,A | ||
6247 | { &opcode_80, 4 }, // ADD A,B | ||
6248 | { &opcode_81, 4 }, // ADD A,C | ||
6249 | { &opcode_82, 4 }, // ADD A,D | ||
6250 | { &opcode_83, 4 }, // ADD A,E | ||
6251 | { &opcode_84, 4 }, // ADD A,H | ||
6252 | { &opcode_85, 4 }, // ADD A,L | ||
6253 | { &opcode_86, 7 }, // ADD A,(HL) | ||
6254 | { &opcode_87, 4 }, // ADD A,A | ||
6255 | { &opcode_88, 4 }, // ADC A,B | ||
6256 | { &opcode_89, 4 }, // ADC A,C | ||
6257 | { &opcode_8a, 4 }, // ADC A,D | ||
6258 | { &opcode_8b, 4 }, // ADC A,E | ||
6259 | { &opcode_8c, 4 }, // ADC A,H | ||
6260 | { &opcode_8d, 4 }, // ADC A,L | ||
6261 | { &opcode_8e, 7 }, // ADC A,(HL) | ||
6262 | { &opcode_8f, 4 }, // ADC A,A | ||
6263 | { &opcode_90, 4 }, // SUB B | ||
6264 | { &opcode_91, 4 }, // SUB C | ||
6265 | { &opcode_92, 4 }, // SUB D | ||
6266 | { &opcode_93, 4 }, // SUB E | ||
6267 | { &opcode_94, 4 }, // SUB H | ||
6268 | { &opcode_95, 4 }, // SUB L | ||
6269 | { &opcode_96, 7 }, // SUB (HL) | ||
6270 | { &opcode_97, 4 }, // SUB A | ||
6271 | { &opcode_98, 4 }, // SBC A,B | ||
6272 | { &opcode_99, 4 }, // SBC A,C | ||
6273 | { &opcode_9a, 4 }, // SBC A,D | ||
6274 | { &opcode_9b, 4 }, // SBC A,E | ||
6275 | { &opcode_9c, 4 }, // SBC A,H | ||
6276 | { &opcode_9d, 4 }, // SBC A,L | ||
6277 | { &opcode_9e, 7 }, // SBC A,(HL) | ||
6278 | { &opcode_9f, 4 }, // SBC A,A | ||
6279 | { &opcode_a0, 4 }, // AND B | ||
6280 | { &opcode_a1, 4 }, // AND C | ||
6281 | { &opcode_a2, 4 }, // AND D | ||
6282 | { &opcode_a3, 4 }, // AND E | ||
6283 | { &opcode_a4, 4 }, // AND H | ||
6284 | { &opcode_a5, 4 }, // AND L | ||
6285 | { &opcode_a6, 7 }, // AND (HL) | ||
6286 | { &opcode_a7, 4 }, // AND A | ||
6287 | { &opcode_a8, 4 }, // XOR B | ||
6288 | { &opcode_a9, 4 }, // XOR C | ||
6289 | { &opcode_aa, 4 }, // XOR D | ||
6290 | { &opcode_ab, 4 }, // XOR E | ||
6291 | { &opcode_ac, 4 }, // XOR H | ||
6292 | { &opcode_ad, 4 }, // XOR L | ||
6293 | { &opcode_ae, 7 }, // XOR (HL) | ||
6294 | { &opcode_af, 4 }, // XOR A | ||
6295 | { &opcode_b0, 4 }, // OR B | ||
6296 | { &opcode_b1, 4 }, // OR C | ||
6297 | { &opcode_b2, 4 }, // OR D | ||
6298 | { &opcode_b3, 4 }, // OR E | ||
6299 | { &opcode_b4, 4 }, // OR H | ||
6300 | { &opcode_b5, 4 }, // OR L | ||
6301 | { &opcode_b6, 7 }, // OR (HL) | ||
6302 | { &opcode_b7, 4 }, // OR A | ||
6303 | { &opcode_b8, 4 }, // CP B | ||
6304 | { &opcode_b9, 4 }, // CP C | ||
6305 | { &opcode_ba, 4 }, // CP D | ||
6306 | { &opcode_bb, 4 }, // CP E | ||
6307 | { &opcode_bc, 4 }, // CP H | ||
6308 | { &opcode_bd, 4 }, // CP L | ||
6309 | { &opcode_be, 7 }, // CP (HL) | ||
6310 | { &opcode_bf, 4 }, // CP A | ||
6311 | { &opcode_c0, 5 }, // RET NZ | ||
6312 | { &opcode_c1, 10 }, // POP BC | ||
6313 | { &opcode_c2, 10 }, // JP NZ,nn | ||
6314 | { &opcode_c3, 10 }, // JP nn | ||
6315 | { &opcode_c4, 10 }, // CALL NZ,nn | ||
6316 | { &opcode_c5, 11 }, // PUSH BC | ||
6317 | { &opcode_c6, 7 }, // ADD A,n | ||
6318 | { &opcode_c7, 11 }, // RST 0 | ||
6319 | { &opcode_c8, 5 }, // RET Z | ||
6320 | { &opcode_c9, 10 }, // RET | ||
6321 | { &opcode_ca, 10 }, // JP Z,nn | ||
6322 | { &opcode_cb, 0 }, // [Prefix] | ||
6323 | { &opcode_cc, 10 }, // CALL Z,nn | ||
6324 | { &opcode_cd, 17 }, // CALL nn | ||
6325 | { &opcode_ce, 7 }, // ADC A,n | ||
6326 | { &opcode_cf, 11 }, // RST 8 | ||
6327 | { &opcode_d0, 5 }, // RET NC | ||
6328 | { &opcode_d1, 10 }, // POP DE | ||
6329 | { &opcode_d2, 10 }, // JP NC,nn | ||
6330 | { &opcode_d3, 11 }, // OUT (n),A | ||
6331 | { &opcode_d4, 10 }, // CALL NC,nn | ||
6332 | { &opcode_d5, 11 }, // PUSH DE | ||
6333 | { &opcode_d6, 7 }, // SUB n | ||
6334 | { &opcode_d7, 11 }, // RST 10H | ||
6335 | { &opcode_d8, 5 }, // RET C | ||
6336 | { &opcode_d9, 4 }, // EXX | ||
6337 | { &opcode_da, 10 }, // JP C,nn | ||
6338 | { &opcode_db, 11 }, // IN A,(n) | ||
6339 | { &opcode_dc, 10 }, // CALL C,nn | ||
6340 | { &opcode_dd, 0 }, // [IX Prefix] | ||
6341 | { &opcode_de, 7 }, // SBC A,n | ||
6342 | { &opcode_df, 11 }, // RST 18H | ||
6343 | { &opcode_e0, 5 }, // RET PO | ||
6344 | { &opcode_e1, 10 }, // POP HL | ||
6345 | { &opcode_e2, 10 }, // JP PO,nn | ||
6346 | { &opcode_e3, 19 }, // EX (SP),HL | ||
6347 | { &opcode_e4, 10 }, // CALL PO,nn | ||
6348 | { &opcode_e5, 11 }, // PUSH HL | ||
6349 | { &opcode_e6, 7 }, // AND n | ||
6350 | { &opcode_e7, 11 }, // RST 20H | ||
6351 | { &opcode_e8, 5 }, // RET PE | ||
6352 | { &opcode_e9, 4 }, // JP (HL) | ||
6353 | { &opcode_ea, 10 }, // JP PE,nn | ||
6354 | { &opcode_eb, 4 }, // EX DE,HL | ||
6355 | { &opcode_ec, 10 }, // CALL PE,nn | ||
6356 | { &opcode_ed, 0 }, // [Prefix] | ||
6357 | { &opcode_ee, 7 }, // XOR n | ||
6358 | { &opcode_ef, 11 }, // RST 28H | ||
6359 | { &opcode_f0, 5 }, // RET P | ||
6360 | { &opcode_f1, 10 }, // POP AF | ||
6361 | { &opcode_f2, 10 }, // JP P,nn | ||
6362 | { &opcode_f3, 4 }, // DI | ||
6363 | { &opcode_f4, 10 }, // CALL P,nn | ||
6364 | { &opcode_f5, 11 }, // PUSH AF | ||
6365 | { &opcode_f6, 7 }, // OR n | ||
6366 | { &opcode_f7, 11 }, // RST 30H | ||
6367 | { &opcode_f8, 5 }, // RET M | ||
6368 | { &opcode_f9, 6 }, // LD SP,HL | ||
6369 | { &opcode_fa, 10 }, // JP M,nn | ||
6370 | { &opcode_fb, 4 }, // EI | ||
6371 | { &opcode_fc, 10 }, // CALL M,nn | ||
6372 | { &opcode_fd, 0 }, // [IY Prefix] | ||
6373 | { &opcode_fe, 7 }, // CP n | ||
6374 | { &opcode_ff, 11 } // RST 38H | ||
6375 | }; | ||
6376 | |||
6377 | void opcode_00() // NOP | ||
6378 | { | ||
6379 | } | ||
6380 | |||
6381 | void opcode_01() // LD BC,nn | ||
6382 | { | ||
6383 | C = fetchByte(); | ||
6384 | B = fetchByte(); | ||
6385 | } | ||
6386 | |||
6387 | void opcode_02() // LD (BC),A | ||
6388 | { | ||
6389 | writeByte( BC(), A ); | ||
6390 | } | ||
6391 | |||
6392 | void opcode_03() // INC BC | ||
6393 | { | ||
6394 | if( ++C == 0 ) ++B; | ||
6395 | } | ||
6396 | |||
6397 | void opcode_04() // INC B | ||
6398 | { | ||
6399 | B = incByte( B ); | ||
6400 | } | ||
6401 | |||
6402 | void opcode_05() // DEC B | ||
6403 | { | ||
6404 | B = decByte( B ); | ||
6405 | } | ||
6406 | |||
6407 | void opcode_06() // LD B,n | ||
6408 | { | ||
6409 | B = fetchByte(); | ||
6410 | } | ||
6411 | |||
6412 | void opcode_07() // RLCA | ||
6413 | { | ||
6414 | A = (A << 1) | (A >> 7); | ||
6415 | F = F & ~(AddSub | Halfcarry | Carry); | ||
6416 | if( A & 0x01 ) F |= Carry; | ||
6417 | } | ||
6418 | |||
6419 | void opcode_08() // EX AF,AF' | ||
6420 | { | ||
6421 | unsigned char x; | ||
6422 | |||
6423 | x = A; A = A1; A1 = x; | ||
6424 | x = F; F = F1; F1 = x; | ||
6425 | } | ||
6426 | |||
6427 | void opcode_09() // ADD HL,BC | ||
6428 | { | ||
6429 | unsigned hl = HL(); | ||
6430 | unsigned rp = BC(); | ||
6431 | unsigned x = hl + rp; | ||
6432 | |||
6433 | F &= Sign | Zero | Parity; | ||
6434 | if( x > 0xFFFF ) F |= Carry; | ||
6435 | if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
6436 | |||
6437 | L = x & 0xFF; | ||
6438 | H = (x >> 8) & 0xFF; | ||
6439 | } | ||
6440 | |||
6441 | void opcode_0a() // LD A,(BC) | ||
6442 | { | ||
6443 | A = readByte( BC() ); | ||
6444 | } | ||
6445 | |||
6446 | void opcode_0b() // DEC BC | ||
6447 | { | ||
6448 | if( C-- == 0 ) --B; | ||
6449 | } | ||
6450 | |||
6451 | void opcode_0c() // INC C | ||
6452 | { | ||
6453 | C = incByte( C ); | ||
6454 | } | ||
6455 | |||
6456 | void opcode_0d() // DEC C | ||
6457 | { | ||
6458 | C = decByte( C ); | ||
6459 | } | ||
6460 | |||
6461 | void opcode_0e() // LD C,n | ||
6462 | { | ||
6463 | C = fetchByte(); | ||
6464 | } | ||
6465 | |||
6466 | void opcode_0f() // RRCA | ||
6467 | { | ||
6468 | A = (A >> 1) | (A << 7); | ||
6469 | F = F & ~(AddSub | Halfcarry | Carry); | ||
6470 | if( A & 0x80 ) F |= Carry; | ||
6471 | } | ||
6472 | |||
6473 | void opcode_10() // DJNZ d | ||
6474 | { | ||
6475 | unsigned char o = fetchByte(); | ||
6476 | |||
6477 | if( --B != 0 ) relJump( o ); | ||
6478 | } | ||
6479 | |||
6480 | void opcode_11() // LD DE,nn | ||
6481 | { | ||
6482 | E = fetchByte(); | ||
6483 | D = fetchByte(); | ||
6484 | } | ||
6485 | |||
6486 | void opcode_12() // LD (DE),A | ||
6487 | { | ||
6488 | writeByte( DE(), A ); | ||
6489 | } | ||
6490 | |||
6491 | void opcode_13() // INC DE | ||
6492 | { | ||
6493 | if( ++E == 0 ) ++D; | ||
6494 | } | ||
6495 | |||
6496 | void opcode_14() // INC D | ||
6497 | { | ||
6498 | D = incByte( D ); | ||
6499 | } | ||
6500 | |||
6501 | void opcode_15() // DEC D | ||
6502 | { | ||
6503 | D = decByte( D ); | ||
6504 | } | ||
6505 | |||
6506 | void opcode_16() // LD D,n | ||
6507 | { | ||
6508 | D = fetchByte(); | ||
6509 | } | ||
6510 | |||
6511 | void opcode_17() // RLA | ||
6512 | { | ||
6513 | unsigned char a = A; | ||
6514 | |||
6515 | A <<= 1; | ||
6516 | if( F & Carry ) A |= 0x01; | ||
6517 | F = F & ~(AddSub | Halfcarry | Carry); | ||
6518 | if( a & 0x80 ) F |= Carry; | ||
6519 | } | ||
6520 | |||
6521 | void opcode_18() // JR d | ||
6522 | { | ||
6523 | relJump( fetchByte() ); | ||
6524 | } | ||
6525 | |||
6526 | void opcode_19() // ADD HL,DE | ||
6527 | { | ||
6528 | unsigned hl = HL(); | ||
6529 | unsigned rp = DE(); | ||
6530 | unsigned x = hl + rp; | ||
6531 | |||
6532 | F &= Sign | Zero | Parity; | ||
6533 | if( x > 0xFFFF ) F |= Carry; | ||
6534 | if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
6535 | |||
6536 | L = x & 0xFF; | ||
6537 | H = (x >> 8) & 0xFF; | ||
6538 | } | ||
6539 | |||
6540 | void opcode_1a() // LD A,(DE) | ||
6541 | { | ||
6542 | A = readByte( DE() ); | ||
6543 | } | ||
6544 | |||
6545 | void opcode_1b() // DEC DE | ||
6546 | { | ||
6547 | if( E-- == 0 ) --D; | ||
6548 | } | ||
6549 | |||
6550 | void opcode_1c() // INC E | ||
6551 | { | ||
6552 | E = incByte( E ); | ||
6553 | } | ||
6554 | |||
6555 | void opcode_1d() // DEC E | ||
6556 | { | ||
6557 | E = decByte( E ); | ||
6558 | } | ||
6559 | |||
6560 | void opcode_1e() // LD E,n | ||
6561 | { | ||
6562 | E = fetchByte(); | ||
6563 | } | ||
6564 | |||
6565 | void opcode_1f() // RRA | ||
6566 | { | ||
6567 | unsigned char a = A; | ||
6568 | |||
6569 | A >>= 1; | ||
6570 | if( F & Carry ) A |= 0x80; | ||
6571 | F = F & ~(AddSub | Halfcarry | Carry); | ||
6572 | if( a & 0x01 ) F |= Carry; | ||
6573 | } | ||
6574 | |||
6575 | void opcode_20() // JR NZ,d | ||
6576 | { | ||
6577 | unsigned char o = fetchByte(); | ||
6578 | |||
6579 | if( ! (F & Zero) ) relJump( o ); | ||
6580 | } | ||
6581 | |||
6582 | void opcode_21() // LD HL,nn | ||
6583 | { | ||
6584 | L = fetchByte(); | ||
6585 | H = fetchByte(); | ||
6586 | } | ||
6587 | |||
6588 | void opcode_22() // LD (nn),HL | ||
6589 | { | ||
6590 | unsigned x = fetchWord(); | ||
6591 | |||
6592 | writeByte( x , L ); | ||
6593 | writeByte( x+1, H ); | ||
6594 | } | ||
6595 | |||
6596 | void opcode_23() // INC HL | ||
6597 | { | ||
6598 | if( ++L == 0 ) ++H; | ||
6599 | } | ||
6600 | |||
6601 | void opcode_24() // INC H | ||
6602 | { | ||
6603 | H = incByte( H ); | ||
6604 | } | ||
6605 | |||
6606 | void opcode_25() // DEC H | ||
6607 | { | ||
6608 | H = decByte( H ); | ||
6609 | } | ||
6610 | |||
6611 | void opcode_26() // LD H,n | ||
6612 | { | ||
6613 | H = fetchByte(); | ||
6614 | } | ||
6615 | |||
6616 | /* | ||
6617 | DAA is computed using the following table to get a diff value | ||
6618 | that is added to or subtracted (according to the N flag) from A: | ||
6619 | |||
6620 | C Upper H Lower Diff | ||
6621 | -+-----+-+-----+---- | ||
6622 | 1 * 0 0-9 60 | ||
6623 | 1 * 1 0-9 66 | ||
6624 | 1 * * A-F 66 | ||
6625 | 0 0-9 0 0-9 00 | ||
6626 | 0 0-9 1 0-9 06 | ||
6627 | 0 0-8 * A-F 06 | ||
6628 | 0 A-F 0 0-9 60 | ||
6629 | 0 9-F * A-F 66 | ||
6630 | 0 A-F 1 0-9 66 | ||
6631 | |||
6632 | The carry and halfcarry flags are then updated using similar tables. | ||
6633 | |||
6634 | These tables were found by Stefano Donati of Ramsoft and are | ||
6635 | published in the "Undocumented Z80 Documented" paper by Sean Young, | ||
6636 | the following is an algorithmical implementation with no lookups. | ||
6637 | */ | ||
6638 | void opcode_27() // DAA | ||
6639 | { | ||
6640 | unsigned char diff; | ||
6641 | unsigned char hf = F & Halfcarry; | ||
6642 | unsigned char cf = F & Carry; | ||
6643 | unsigned char lower = A & 0x0F; | ||
6644 | |||
6645 | if( cf ) { | ||
6646 | diff = (lower >= 0x0A) || hf ? 0x66 : 0x60; | ||
6647 | } | ||
6648 | else { | ||
6649 | diff = (A >= 0x9A) ? 0x60 : 0x00; | ||
6650 | |||
6651 | if( hf || (lower >= 0x0A) ) diff += 0x06; | ||
6652 | } | ||
6653 | |||
6654 | if( A >= 0x9A ) cf = Carry; | ||
6655 | |||
6656 | if( F & Subtraction ) { | ||
6657 | A -= diff; | ||
6658 | F = PSZ_[A] | Subtraction | cf; | ||
6659 | if( hf && (lower <= 0x05) ) F |= Halfcarry; | ||
6660 | } | ||
6661 | else { | ||
6662 | A += diff; | ||
6663 | F = PSZ_[A] | cf; | ||
6664 | if( lower >= 0x0A ) F |= Halfcarry; | ||
6665 | } | ||
6666 | } | ||
6667 | |||
6668 | void opcode_28() // JR Z,d | ||
6669 | { | ||
6670 | unsigned char o = fetchByte(); | ||
6671 | |||
6672 | if( F & Zero ) relJump( o ); | ||
6673 | } | ||
6674 | |||
6675 | void opcode_29() // ADD HL,HL | ||
6676 | { | ||
6677 | unsigned hl = HL(); | ||
6678 | unsigned rp = hl; | ||
6679 | unsigned x = hl + rp; | ||
6680 | |||
6681 | F &= Sign | Zero | Parity; | ||
6682 | if( x > 0xFFFF ) F |= Carry; | ||
6683 | if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
6684 | |||
6685 | L = x & 0xFF; | ||
6686 | H = (x >> 8) & 0xFF; | ||
6687 | } | ||
6688 | |||
6689 | void opcode_2a() // LD HL,(nn) | ||
6690 | { | ||
6691 | unsigned x = fetchWord(); | ||
6692 | |||
6693 | L = readByte( x ); | ||
6694 | H = readByte( x+1 ); | ||
6695 | } | ||
6696 | |||
6697 | void opcode_2b() // DEC HL | ||
6698 | { | ||
6699 | if( L-- == 0 ) --H; | ||
6700 | } | ||
6701 | |||
6702 | void opcode_2c() // INC L | ||
6703 | { | ||
6704 | L = incByte( L ); | ||
6705 | } | ||
6706 | |||
6707 | void opcode_2d() // DEC L | ||
6708 | { | ||
6709 | L = decByte( L ); | ||
6710 | } | ||
6711 | |||
6712 | void opcode_2e() // LD L,n | ||
6713 | { | ||
6714 | L = fetchByte(); | ||
6715 | } | ||
6716 | |||
6717 | void opcode_2f() // CPL | ||
6718 | { | ||
6719 | A ^= 0xFF; | ||
6720 | F |= AddSub | Halfcarry; | ||
6721 | } | ||
6722 | |||
6723 | void opcode_30() // JR NC,d | ||
6724 | { | ||
6725 | unsigned char o = fetchByte(); | ||
6726 | |||
6727 | if( ! (F & Carry) ) relJump( o ); | ||
6728 | } | ||
6729 | |||
6730 | void opcode_31() // LD SP,nn | ||
6731 | { | ||
6732 | SP = fetchWord(); | ||
6733 | } | ||
6734 | |||
6735 | void opcode_32() // LD (nn),A | ||
6736 | { | ||
6737 | writeByte( fetchWord(), A ); | ||
6738 | } | ||
6739 | |||
6740 | void opcode_33() // INC SP | ||
6741 | { | ||
6742 | SP = (SP + 1) & 0xFFFF; | ||
6743 | } | ||
6744 | |||
6745 | void opcode_34() // INC (HL) | ||
6746 | { | ||
6747 | writeByte( HL(), incByte( readByte( HL() ) ) ); | ||
6748 | } | ||
6749 | |||
6750 | void opcode_35() // DEC (HL) | ||
6751 | { | ||
6752 | writeByte( HL(), decByte( readByte( HL() ) ) ); | ||
6753 | } | ||
6754 | |||
6755 | void opcode_36() // LD (HL),n | ||
6756 | { | ||
6757 | writeByte( HL(), fetchByte() ); | ||
6758 | } | ||
6759 | |||
6760 | void opcode_37() // SCF | ||
6761 | { | ||
6762 | F = (F & (Parity | Sign | Zero)) | Carry; | ||
6763 | } | ||
6764 | |||
6765 | void opcode_38() // JR C,d | ||
6766 | { | ||
6767 | unsigned char o = fetchByte(); | ||
6768 | |||
6769 | if( F & Carry ) relJump( o ); | ||
6770 | } | ||
6771 | |||
6772 | void opcode_39() // ADD HL,SP | ||
6773 | { | ||
6774 | unsigned hl = HL(); | ||
6775 | unsigned rp = SP; | ||
6776 | unsigned x = hl + rp; | ||
6777 | |||
6778 | F &= Sign | Zero | Parity; | ||
6779 | if( x > 0xFFFF ) F |= Carry; | ||
6780 | if( ((hl & 0xFFF) + (rp & 0xFFF)) > 0xFFF ) F |= Halfcarry; | ||
6781 | |||
6782 | L = x & 0xFF; | ||
6783 | H = (x >> 8) & 0xFF; | ||
6784 | } | ||
6785 | |||
6786 | void opcode_3a() // LD A,(nn) | ||
6787 | { | ||
6788 | A = readByte( fetchWord() ); | ||
6789 | } | ||
6790 | |||
6791 | void opcode_3b() // DEC SP | ||
6792 | { | ||
6793 | SP = (SP - 1) & 0xFFFF; | ||
6794 | } | ||
6795 | |||
6796 | void opcode_3c() // INC A | ||
6797 | { | ||
6798 | A = incByte( A ); | ||
6799 | } | ||
6800 | |||
6801 | void opcode_3d() // DEC A | ||
6802 | { | ||
6803 | A = decByte( A ); | ||
6804 | } | ||
6805 | |||
6806 | void opcode_3e() // LD A,n | ||
6807 | { | ||
6808 | A = fetchByte(); | ||
6809 | } | ||
6810 | |||
6811 | void opcode_3f() // CCF | ||
6812 | { | ||
6813 | if( F & Carry ) { | ||
6814 | F = (F & (Parity | Sign | Zero)) | Halfcarry; // Halfcarry holds previous carry | ||
6815 | } | ||
6816 | else { | ||
6817 | F = (F & (Parity | Sign | Zero)) | Carry; | ||
6818 | } | ||
6819 | } | ||
6820 | |||
6821 | void opcode_40() // LD B,B | ||
6822 | { | ||
6823 | } | ||
6824 | |||
6825 | void opcode_41() // LD B,C | ||
6826 | { | ||
6827 | B = C; | ||
6828 | } | ||
6829 | |||
6830 | void opcode_42() // LD B,D | ||
6831 | { | ||
6832 | B = D; | ||
6833 | } | ||
6834 | |||
6835 | void opcode_43() // LD B,E | ||
6836 | { | ||
6837 | B = E; | ||
6838 | } | ||
6839 | |||
6840 | void opcode_44() // LD B,H | ||
6841 | { | ||
6842 | B = H; | ||
6843 | } | ||
6844 | |||
6845 | void opcode_45() // LD B,L | ||
6846 | { | ||
6847 | B = L; | ||
6848 | } | ||
6849 | |||
6850 | void opcode_46() // LD B,(HL) | ||
6851 | { | ||
6852 | B = readByte( HL() ); | ||
6853 | } | ||
6854 | |||
6855 | void opcode_47() // LD B,A | ||
6856 | { | ||
6857 | B = A; | ||
6858 | } | ||
6859 | |||
6860 | void opcode_48() // LD C,B | ||
6861 | { | ||
6862 | C = B; | ||
6863 | } | ||
6864 | |||
6865 | void opcode_49() // LD C,C | ||
6866 | { | ||
6867 | } | ||
6868 | |||
6869 | void opcode_4a() // LD C,D | ||
6870 | { | ||
6871 | C = D; | ||
6872 | } | ||
6873 | |||
6874 | void opcode_4b() // LD C,E | ||
6875 | { | ||
6876 | C = E; | ||
6877 | } | ||
6878 | |||
6879 | void opcode_4c() // LD C,H | ||
6880 | { | ||
6881 | C = H; | ||
6882 | } | ||
6883 | |||
6884 | void opcode_4d() // LD C,L | ||
6885 | { | ||
6886 | C = L; | ||
6887 | } | ||
6888 | |||
6889 | void opcode_4e() // LD C,(HL) | ||
6890 | { | ||
6891 | C = readByte( HL() ); | ||
6892 | } | ||
6893 | |||
6894 | void opcode_4f() // LD C,A | ||
6895 | { | ||
6896 | C = A; | ||
6897 | } | ||
6898 | |||
6899 | void opcode_50() // LD D,B | ||
6900 | { | ||
6901 | D = B; | ||
6902 | } | ||
6903 | |||
6904 | void opcode_51() // LD D,C | ||
6905 | { | ||
6906 | D = C; | ||
6907 | } | ||
6908 | |||
6909 | void opcode_52() // LD D,D | ||
6910 | { | ||
6911 | } | ||
6912 | |||
6913 | void opcode_53() // LD D,E | ||
6914 | { | ||
6915 | D = E; | ||
6916 | } | ||
6917 | |||
6918 | void opcode_54() // LD D,H | ||
6919 | { | ||
6920 | D = H; | ||
6921 | } | ||
6922 | |||
6923 | void opcode_55() // LD D,L | ||
6924 | { | ||
6925 | D = L; | ||
6926 | } | ||
6927 | |||
6928 | void opcode_56() // LD D,(HL) | ||
6929 | { | ||
6930 | D = readByte( HL() ); | ||
6931 | } | ||
6932 | |||
6933 | void opcode_57() // LD D,A | ||
6934 | { | ||
6935 | D = A; | ||
6936 | } | ||
6937 | |||
6938 | void opcode_58() // LD E,B | ||
6939 | { | ||
6940 | E = B; | ||
6941 | } | ||
6942 | |||
6943 | void opcode_59() // LD E,C | ||
6944 | { | ||
6945 | E = C; | ||
6946 | } | ||
6947 | |||
6948 | void opcode_5a() // LD E,D | ||
6949 | { | ||
6950 | E = D; | ||
6951 | } | ||
6952 | |||
6953 | void opcode_5b() // LD E,E | ||
6954 | { | ||
6955 | } | ||
6956 | |||
6957 | void opcode_5c() // LD E,H | ||
6958 | { | ||
6959 | E = H; | ||
6960 | } | ||
6961 | |||
6962 | void opcode_5d() // LD E,L | ||
6963 | { | ||
6964 | E = L; | ||
6965 | } | ||
6966 | |||
6967 | void opcode_5e() // LD E,(HL) | ||
6968 | { | ||
6969 | E = readByte( HL() ); | ||
6970 | } | ||
6971 | |||
6972 | void opcode_5f() // LD E,A | ||
6973 | { | ||
6974 | E = A; | ||
6975 | } | ||
6976 | |||
6977 | void opcode_60() // LD H,B | ||
6978 | { | ||
6979 | H = B; | ||
6980 | } | ||
6981 | |||
6982 | void opcode_61() // LD H,C | ||
6983 | { | ||
6984 | H = C; | ||
6985 | } | ||
6986 | |||
6987 | void opcode_62() // LD H,D | ||
6988 | { | ||
6989 | H = D; | ||
6990 | } | ||
6991 | |||
6992 | void opcode_63() // LD H,E | ||
6993 | { | ||
6994 | H = E; | ||
6995 | } | ||
6996 | |||
6997 | void opcode_64() // LD H,H | ||
6998 | { | ||
6999 | } | ||
7000 | |||
7001 | void opcode_65() // LD H,L | ||
7002 | { | ||
7003 | H = L; | ||
7004 | } | ||
7005 | |||
7006 | void opcode_66() // LD H,(HL) | ||
7007 | { | ||
7008 | H = readByte( HL() ); | ||
7009 | } | ||
7010 | |||
7011 | void opcode_67() // LD H,A | ||
7012 | { | ||
7013 | H = A; | ||
7014 | } | ||
7015 | |||
7016 | void opcode_68() // LD L,B | ||
7017 | { | ||
7018 | L = B; | ||
7019 | } | ||
7020 | |||
7021 | void opcode_69() // LD L,C | ||
7022 | { | ||
7023 | L = C; | ||
7024 | } | ||
7025 | |||
7026 | void opcode_6a() // LD L,D | ||
7027 | { | ||
7028 | L = D; | ||
7029 | } | ||
7030 | |||
7031 | void opcode_6b() // LD L,E | ||
7032 | { | ||
7033 | L = E; | ||
7034 | } | ||
7035 | |||
7036 | void opcode_6c() // LD L,H | ||
7037 | { | ||
7038 | L = H; | ||
7039 | } | ||
7040 | |||
7041 | void opcode_6d() // LD L,L | ||
7042 | { | ||
7043 | } | ||
7044 | |||
7045 | void opcode_6e() // LD L,(HL) | ||
7046 | { | ||
7047 | L = readByte( HL() ); | ||
7048 | } | ||
7049 | |||
7050 | void opcode_6f() // LD L,A | ||
7051 | { | ||
7052 | L = A; | ||
7053 | } | ||
7054 | |||
7055 | void opcode_70() // LD (HL),B | ||
7056 | { | ||
7057 | writeByte( HL(), B ); | ||
7058 | } | ||
7059 | |||
7060 | void opcode_71() // LD (HL),C | ||
7061 | { | ||
7062 | writeByte( HL(), C ); | ||
7063 | } | ||
7064 | |||
7065 | void opcode_72() // LD (HL),D | ||
7066 | { | ||
7067 | writeByte( HL(), D ); | ||
7068 | } | ||
7069 | |||
7070 | void opcode_73() // LD (HL),E | ||
7071 | { | ||
7072 | writeByte( HL(), E ); | ||
7073 | } | ||
7074 | |||
7075 | void opcode_74() // LD (HL),H | ||
7076 | { | ||
7077 | writeByte( HL(), H ); | ||
7078 | } | ||
7079 | |||
7080 | void opcode_75() // LD (HL),L | ||
7081 | { | ||
7082 | writeByte( HL(), L ); | ||
7083 | } | ||
7084 | |||
7085 | void opcode_76() // HALT | ||
7086 | { | ||
7087 | iflags_ |= Halted; | ||
7088 | } | ||
7089 | |||
7090 | void opcode_77() // LD (HL),A | ||
7091 | { | ||
7092 | writeByte( HL(), A ); | ||
7093 | } | ||
7094 | |||
7095 | void opcode_78() // LD A,B | ||
7096 | { | ||
7097 | A = B; | ||
7098 | } | ||
7099 | |||
7100 | void opcode_79() // LD A,C | ||
7101 | { | ||
7102 | A = C; | ||
7103 | } | ||
7104 | |||
7105 | void opcode_7a() // LD A,D | ||
7106 | { | ||
7107 | A = D; | ||
7108 | } | ||
7109 | |||
7110 | void opcode_7b() // LD A,E | ||
7111 | { | ||
7112 | A = E; | ||
7113 | } | ||
7114 | |||
7115 | void opcode_7c() // LD A,H | ||
7116 | { | ||
7117 | A = H; | ||
7118 | } | ||
7119 | |||
7120 | void opcode_7d() // LD A,L | ||
7121 | { | ||
7122 | A = L; | ||
7123 | } | ||
7124 | |||
7125 | void opcode_7e() // LD A,(HL) | ||
7126 | { | ||
7127 | A = readByte( HL() ); | ||
7128 | } | ||
7129 | |||
7130 | void opcode_7f() // LD A,A | ||
7131 | { | ||
7132 | } | ||
7133 | |||
7134 | void opcode_80() // ADD A,B | ||
7135 | { | ||
7136 | addByte( B, 0 ); | ||
7137 | } | ||
7138 | |||
7139 | void opcode_81() // ADD A,C | ||
7140 | { | ||
7141 | addByte( C, 0 ); | ||
7142 | } | ||
7143 | |||
7144 | void opcode_82() // ADD A,D | ||
7145 | { | ||
7146 | addByte( D, 0 ); | ||
7147 | } | ||
7148 | |||
7149 | void opcode_83() // ADD A,E | ||
7150 | { | ||
7151 | addByte( E, 0 ); | ||
7152 | } | ||
7153 | |||
7154 | void opcode_84() // ADD A,H | ||
7155 | { | ||
7156 | addByte( H, 0 ); | ||
7157 | } | ||
7158 | |||
7159 | void opcode_85() // ADD A,L | ||
7160 | { | ||
7161 | addByte( L, 0 ); | ||
7162 | } | ||
7163 | |||
7164 | void opcode_86() // ADD A,(HL) | ||
7165 | { | ||
7166 | addByte( readByte( HL() ), 0 ); | ||
7167 | } | ||
7168 | |||
7169 | void opcode_87() // ADD A,A | ||
7170 | { | ||
7171 | addByte( A, 0 ); | ||
7172 | } | ||
7173 | |||
7174 | void opcode_88() // ADC A,B | ||
7175 | { | ||
7176 | addByte( B, F & Carry ); | ||
7177 | } | ||
7178 | |||
7179 | void opcode_89() // ADC A,C | ||
7180 | { | ||
7181 | addByte( C, F & Carry ); | ||
7182 | } | ||
7183 | |||
7184 | void opcode_8a() // ADC A,D | ||
7185 | { | ||
7186 | addByte( D, F & Carry ); | ||
7187 | } | ||
7188 | |||
7189 | void opcode_8b() // ADC A,E | ||
7190 | { | ||
7191 | addByte( E, F & Carry ); | ||
7192 | } | ||
7193 | |||
7194 | void opcode_8c() // ADC A,H | ||
7195 | { | ||
7196 | addByte( H, F & Carry ); | ||
7197 | } | ||
7198 | |||
7199 | void opcode_8d() // ADC A,L | ||
7200 | { | ||
7201 | addByte( L, F & Carry ); | ||
7202 | } | ||
7203 | |||
7204 | void opcode_8e() // ADC A,(HL) | ||
7205 | { | ||
7206 | addByte( readByte( HL() ), F & Carry ); | ||
7207 | } | ||
7208 | |||
7209 | void opcode_8f() // ADC A,A | ||
7210 | { | ||
7211 | addByte( A, F & Carry ); | ||
7212 | } | ||
7213 | |||
7214 | void opcode_90() // SUB B | ||
7215 | { | ||
7216 | A = subByte( B, 0 ); | ||
7217 | } | ||
7218 | |||
7219 | void opcode_91() // SUB C | ||
7220 | { | ||
7221 | A = subByte( C, 0 ); | ||
7222 | } | ||
7223 | |||
7224 | void opcode_92() // SUB D | ||
7225 | { | ||
7226 | A = subByte( D, 0 ); | ||
7227 | } | ||
7228 | |||
7229 | void opcode_93() // SUB E | ||
7230 | { | ||
7231 | A = subByte( E, 0 ); | ||
7232 | } | ||
7233 | |||
7234 | void opcode_94() // SUB H | ||
7235 | { | ||
7236 | A = subByte( H, 0 ); | ||
7237 | } | ||
7238 | |||
7239 | void opcode_95() // SUB L | ||
7240 | { | ||
7241 | A = subByte( L, 0 ); | ||
7242 | } | ||
7243 | |||
7244 | void opcode_96() // SUB (HL) | ||
7245 | { | ||
7246 | A = subByte( readByte( HL() ), 0 ); | ||
7247 | } | ||
7248 | |||
7249 | void opcode_97() // SUB A | ||
7250 | { | ||
7251 | A = subByte( A, 0 ); | ||
7252 | } | ||
7253 | |||
7254 | void opcode_98() // SBC A,B | ||
7255 | { | ||
7256 | A = subByte( B, F & Carry ); | ||
7257 | } | ||
7258 | |||
7259 | void opcode_99() // SBC A,C | ||
7260 | { | ||
7261 | A = subByte( C, F & Carry ); | ||
7262 | } | ||
7263 | |||
7264 | void opcode_9a() // SBC A,D | ||
7265 | { | ||
7266 | A = subByte( D, F & Carry ); | ||
7267 | } | ||
7268 | |||
7269 | void opcode_9b() // SBC A,E | ||
7270 | { | ||
7271 | A = subByte( E, F & Carry ); | ||
7272 | } | ||
7273 | |||
7274 | void opcode_9c() // SBC A,H | ||
7275 | { | ||
7276 | A = subByte( H, F & Carry ); | ||
7277 | } | ||
7278 | |||
7279 | void opcode_9d() // SBC A,L | ||
7280 | { | ||
7281 | A = subByte( L, F & Carry ); | ||
7282 | } | ||
7283 | |||
7284 | void opcode_9e() // SBC A,(HL) | ||
7285 | { | ||
7286 | A = subByte( readByte( HL() ), F & Carry ); | ||
7287 | } | ||
7288 | |||
7289 | void opcode_9f() // SBC A,A | ||
7290 | { | ||
7291 | A = subByte( A, F & Carry ); | ||
7292 | } | ||
7293 | |||
7294 | void opcode_a0() // AND B | ||
7295 | { | ||
7296 | A &= B; | ||
7297 | setFlagsPSZ(); | ||
7298 | } | ||
7299 | |||
7300 | void opcode_a1() // AND C | ||
7301 | { | ||
7302 | A &= C; | ||
7303 | setFlagsPSZ(); | ||
7304 | } | ||
7305 | |||
7306 | void opcode_a2() // AND D | ||
7307 | { | ||
7308 | A &= D; | ||
7309 | setFlagsPSZ(); | ||
7310 | } | ||
7311 | |||
7312 | void opcode_a3() // AND E | ||
7313 | { | ||
7314 | A &= E; | ||
7315 | setFlagsPSZ(); | ||
7316 | } | ||
7317 | |||
7318 | void opcode_a4() // AND H | ||
7319 | { | ||
7320 | A &= H; | ||
7321 | setFlagsPSZ(); | ||
7322 | } | ||
7323 | |||
7324 | void opcode_a5() // AND L | ||
7325 | { | ||
7326 | A &= L; | ||
7327 | setFlagsPSZ(); | ||
7328 | } | ||
7329 | |||
7330 | void opcode_a6() // AND (HL) | ||
7331 | { | ||
7332 | A &= readByte( HL() ); | ||
7333 | setFlagsPSZ(); | ||
7334 | } | ||
7335 | |||
7336 | void opcode_a7() // AND A | ||
7337 | { | ||
7338 | setFlagsPSZ(); | ||
7339 | } | ||
7340 | |||
7341 | void opcode_a8() // XOR B | ||
7342 | { | ||
7343 | A ^= B; | ||
7344 | setFlags35PSZ000(); | ||
7345 | } | ||
7346 | |||
7347 | void opcode_a9() // XOR C | ||
7348 | { | ||
7349 | A ^= C; | ||
7350 | setFlags35PSZ000(); | ||
7351 | } | ||
7352 | |||
7353 | void opcode_aa() // XOR D | ||
7354 | { | ||
7355 | A ^= D; | ||
7356 | setFlags35PSZ000(); | ||
7357 | } | ||
7358 | |||
7359 | void opcode_ab() // XOR E | ||
7360 | { | ||
7361 | A ^= E; | ||
7362 | setFlags35PSZ000(); | ||
7363 | } | ||
7364 | |||
7365 | void opcode_ac() // XOR H | ||
7366 | { | ||
7367 | A ^= H; | ||
7368 | setFlags35PSZ000(); | ||
7369 | } | ||
7370 | |||
7371 | void opcode_ad() // XOR L | ||
7372 | { | ||
7373 | A ^= L; | ||
7374 | setFlags35PSZ000(); | ||
7375 | } | ||
7376 | |||
7377 | void opcode_ae() // XOR (HL) | ||
7378 | { | ||
7379 | A ^= readByte( HL() ); | ||
7380 | setFlags35PSZ000(); | ||
7381 | } | ||
7382 | |||
7383 | void opcode_af() // XOR A | ||
7384 | { | ||
7385 | A = 0; | ||
7386 | setFlags35PSZ000(); | ||
7387 | } | ||
7388 | |||
7389 | void opcode_b0() // OR B | ||
7390 | { | ||
7391 | A |= B; | ||
7392 | setFlags35PSZ000(); | ||
7393 | } | ||
7394 | |||
7395 | void opcode_b1() // OR C | ||
7396 | { | ||
7397 | A |= C; | ||
7398 | setFlags35PSZ000(); | ||
7399 | } | ||
7400 | |||
7401 | void opcode_b2() // OR D | ||
7402 | { | ||
7403 | A |= D; | ||
7404 | setFlags35PSZ000(); | ||
7405 | } | ||
7406 | |||
7407 | void opcode_b3() // OR E | ||
7408 | { | ||
7409 | A |= E; | ||
7410 | setFlags35PSZ000(); | ||
7411 | } | ||
7412 | |||
7413 | void opcode_b4() // OR H | ||
7414 | { | ||
7415 | A |= H; | ||
7416 | setFlags35PSZ000(); | ||
7417 | } | ||
7418 | |||
7419 | void opcode_b5() // OR L | ||
7420 | { | ||
7421 | A |= L; | ||
7422 | setFlags35PSZ000(); | ||
7423 | } | ||
7424 | |||
7425 | void opcode_b6() // OR (HL) | ||
7426 | { | ||
7427 | A |= readByte( HL() ); | ||
7428 | setFlags35PSZ000(); | ||
7429 | } | ||
7430 | |||
7431 | void opcode_b7() // OR A | ||
7432 | { | ||
7433 | setFlags35PSZ000(); | ||
7434 | } | ||
7435 | |||
7436 | void opcode_b8() // CP B | ||
7437 | { | ||
7438 | cmpByte( B ); | ||
7439 | } | ||
7440 | |||
7441 | void opcode_b9() // CP C | ||
7442 | { | ||
7443 | cmpByte( C ); | ||
7444 | } | ||
7445 | |||
7446 | void opcode_ba() // CP D | ||
7447 | { | ||
7448 | cmpByte( D ); | ||
7449 | } | ||
7450 | |||
7451 | void opcode_bb() // CP E | ||
7452 | { | ||
7453 | cmpByte( E ); | ||
7454 | } | ||
7455 | |||
7456 | void opcode_bc() // CP H | ||
7457 | { | ||
7458 | cmpByte( H ); | ||
7459 | } | ||
7460 | |||
7461 | void opcode_bd() // CP L | ||
7462 | { | ||
7463 | cmpByte( L ); | ||
7464 | } | ||
7465 | |||
7466 | void opcode_be() // CP (HL) | ||
7467 | { | ||
7468 | cmpByte( readByte( HL() ) ); | ||
7469 | } | ||
7470 | |||
7471 | void opcode_bf() // CP A | ||
7472 | { | ||
7473 | cmpByte( A ); | ||
7474 | } | ||
7475 | |||
7476 | void opcode_c0() // RET NZ | ||
7477 | { | ||
7478 | if( ! (F & Zero) ) { | ||
7479 | retFromSub(); | ||
7480 | cycles_ += 2; | ||
7481 | } | ||
7482 | } | ||
7483 | |||
7484 | void opcode_c1() // POP BC | ||
7485 | { | ||
7486 | C = readByte( SP++ ); | ||
7487 | B = readByte( SP++ ); | ||
7488 | } | ||
7489 | |||
7490 | void opcode_c2() // JP NZ,nn | ||
7491 | { | ||
7492 | if( ! (F & Zero) ) | ||
7493 | PC = fetchWord(); | ||
7494 | else | ||
7495 | PC += 2; | ||
7496 | } | ||
7497 | |||
7498 | void opcode_c3() // JP nn | ||
7499 | { | ||
7500 | PC = readWord( PC ); | ||
7501 | } | ||
7502 | |||
7503 | void opcode_c4() // CALL NZ,nn | ||
7504 | { | ||
7505 | if( ! (F & Zero) ) { | ||
7506 | callSub( fetchWord() ); | ||
7507 | cycles_ += 2; | ||
7508 | } | ||
7509 | else { | ||
7510 | PC += 2; | ||
7511 | } | ||
7512 | } | ||
7513 | |||
7514 | void opcode_c5() // PUSH BC | ||
7515 | { | ||
7516 | writeByte( --SP, B ); | ||
7517 | writeByte( --SP, C ); | ||
7518 | } | ||
7519 | |||
7520 | void opcode_c6() // ADD A,n | ||
7521 | { | ||
7522 | addByte( fetchByte(), 0 ); | ||
7523 | } | ||
7524 | |||
7525 | void opcode_c7() // RST 0 | ||
7526 | { | ||
7527 | callSub( 0x00 ); | ||
7528 | } | ||
7529 | |||
7530 | void opcode_c8() // RET Z | ||
7531 | { | ||
7532 | if( F & Zero ) { | ||
7533 | retFromSub(); | ||
7534 | cycles_ += 2; | ||
7535 | } | ||
7536 | } | ||
7537 | |||
7538 | void opcode_c9() // RET | ||
7539 | { | ||
7540 | retFromSub(); | ||
7541 | } | ||
7542 | |||
7543 | void opcode_ca() // JP Z,nn | ||
7544 | { | ||
7545 | if( F & Zero ) | ||
7546 | PC = fetchWord(); | ||
7547 | else | ||
7548 | PC += 2; | ||
7549 | } | ||
7550 | |||
7551 | void opcode_cb() // [Prefix] | ||
7552 | { | ||
7553 | unsigned op = fetchByte(); | ||
7554 | |||
7555 | cycles_ += OpInfoCB_[ op ].cycles; | ||
7556 | OpInfoCB_[ op ].handler(); | ||
7557 | } | ||
7558 | |||
7559 | void opcode_cc() // CALL Z,nn | ||
7560 | { | ||
7561 | if( F & Zero ) { | ||
7562 | callSub( fetchWord() ); | ||
7563 | cycles_ += 2; | ||
7564 | } | ||
7565 | else { | ||
7566 | PC += 2; | ||
7567 | } | ||
7568 | } | ||
7569 | |||
7570 | void opcode_cd() // CALL nn | ||
7571 | { | ||
7572 | callSub( fetchWord() ); | ||
7573 | } | ||
7574 | |||
7575 | void opcode_ce() // ADC A,n | ||
7576 | { | ||
7577 | addByte( fetchByte(), F & Carry ); | ||
7578 | } | ||
7579 | |||
7580 | void opcode_cf() // RST 8 | ||
7581 | { | ||
7582 | callSub( 0x08 ); | ||
7583 | } | ||
7584 | |||
7585 | void opcode_d0() // RET NC | ||
7586 | { | ||
7587 | if( ! (F & Carry) ) { | ||
7588 | retFromSub(); | ||
7589 | cycles_ += 2; | ||
7590 | } | ||
7591 | } | ||
7592 | |||
7593 | void opcode_d1() // POP DE | ||
7594 | { | ||
7595 | E = readByte( SP++ ); | ||
7596 | D = readByte( SP++ ); | ||
7597 | } | ||
7598 | |||
7599 | void opcode_d2() // JP NC,nn | ||
7600 | { | ||
7601 | if( ! (F & Carry) ) | ||
7602 | PC = fetchWord(); | ||
7603 | else | ||
7604 | PC += 2; | ||
7605 | } | ||
7606 | |||
7607 | void opcode_d3() // OUT (n),A | ||
7608 | { | ||
7609 | writePort( fetchByte(), A ); | ||
7610 | } | ||
7611 | |||
7612 | void opcode_d4() // CALL NC,nn | ||
7613 | { | ||
7614 | if( ! (F & Carry) ) { | ||
7615 | callSub( fetchWord() ); | ||
7616 | cycles_ += 2; | ||
7617 | } | ||
7618 | else { | ||
7619 | PC += 2; | ||
7620 | } | ||
7621 | } | ||
7622 | |||
7623 | void opcode_d5() // PUSH DE | ||
7624 | { | ||
7625 | writeByte( --SP, D ); | ||
7626 | writeByte( --SP, E ); | ||
7627 | } | ||
7628 | |||
7629 | void opcode_d6() // SUB n | ||
7630 | { | ||
7631 | A = subByte( fetchByte(), 0 ); | ||
7632 | } | ||
7633 | |||
7634 | void opcode_d7() // RST 10H | ||
7635 | { | ||
7636 | callSub( 0x10 ); | ||
7637 | } | ||
7638 | |||
7639 | void opcode_d8() // RET C | ||
7640 | { | ||
7641 | if( F & Carry ) { | ||
7642 | retFromSub(); | ||
7643 | cycles_ += 2; | ||
7644 | } | ||
7645 | } | ||
7646 | |||
7647 | void opcode_d9() // EXX | ||
7648 | { | ||
7649 | unsigned char x; | ||
7650 | |||
7651 | x = B; B = B1; B1 = x; | ||
7652 | x = C; C = C1; C1 = x; | ||
7653 | x = D; D = D1; D1 = x; | ||
7654 | x = E; E = E1; E1 = x; | ||
7655 | x = H; H = H1; H1 = x; | ||
7656 | x = L; L = L1; L1 = x; | ||
7657 | } | ||
7658 | |||
7659 | void opcode_da() // JP C,nn | ||
7660 | { | ||
7661 | if( F & Carry ) | ||
7662 | PC = fetchWord(); | ||
7663 | else | ||
7664 | PC += 2; | ||
7665 | } | ||
7666 | |||
7667 | void opcode_db() // IN A,(n) | ||
7668 | { | ||
7669 | A = readPort( fetchByte() ); | ||
7670 | } | ||
7671 | |||
7672 | void opcode_dc() // CALL C,nn | ||
7673 | { | ||
7674 | if( F & Carry ) { | ||
7675 | callSub( fetchWord() ); | ||
7676 | cycles_ += 2; | ||
7677 | } | ||
7678 | else { | ||
7679 | PC += 2; | ||
7680 | } | ||
7681 | } | ||
7682 | |||
7683 | void opcode_dd() // [IX Prefix] | ||
7684 | { | ||
7685 | do_opcode_xy( OpInfoDD_ ); | ||
7686 | IX &= 0xFFFF; | ||
7687 | } | ||
7688 | |||
7689 | void opcode_de() // SBC A,n | ||
7690 | { | ||
7691 | A = subByte( fetchByte(), F & Carry ); | ||
7692 | } | ||
7693 | |||
7694 | void opcode_df() // RST 18H | ||
7695 | { | ||
7696 | callSub( 0x18 ); | ||
7697 | } | ||
7698 | |||
7699 | void opcode_e0() // RET PO | ||
7700 | { | ||
7701 | if( ! (F & Parity) ) { | ||
7702 | retFromSub(); | ||
7703 | cycles_ += 2; | ||
7704 | } | ||
7705 | } | ||
7706 | |||
7707 | void opcode_e1() // POP HL | ||
7708 | { | ||
7709 | L = readByte( SP++ ); | ||
7710 | H = readByte( SP++ ); | ||
7711 | } | ||
7712 | |||
7713 | void opcode_e2() // JP PO,nn | ||
7714 | { | ||
7715 | if( ! (F & Parity) ) | ||
7716 | PC = fetchWord(); | ||
7717 | else | ||
7718 | PC += 2; | ||
7719 | } | ||
7720 | |||
7721 | void opcode_e3() // EX (SP),HL | ||
7722 | { | ||
7723 | unsigned char x; | ||
7724 | |||
7725 | x = readByte( SP ); writeByte( SP, L ); L = x; | ||
7726 | x = readByte( SP+1 ); writeByte( SP+1, H ); H = x; | ||
7727 | } | ||
7728 | |||
7729 | void opcode_e4() // CALL PO,nn | ||
7730 | { | ||
7731 | if( ! (F & Parity) ) { | ||
7732 | callSub( fetchWord() ); | ||
7733 | cycles_ += 2; | ||
7734 | } | ||
7735 | else { | ||
7736 | PC += 2; | ||
7737 | } | ||
7738 | } | ||
7739 | |||
7740 | void opcode_e5() // PUSH HL | ||
7741 | { | ||
7742 | writeByte( --SP, H ); | ||
7743 | writeByte( --SP, L ); | ||
7744 | } | ||
7745 | |||
7746 | void opcode_e6() // AND n | ||
7747 | { | ||
7748 | A &= fetchByte(); | ||
7749 | setFlagsPSZ(); | ||
7750 | } | ||
7751 | |||
7752 | void opcode_e7() // RST 20H | ||
7753 | { | ||
7754 | callSub( 0x20 ); | ||
7755 | } | ||
7756 | |||
7757 | void opcode_e8() // RET PE | ||
7758 | { | ||
7759 | if( F & Parity ) { | ||
7760 | retFromSub(); | ||
7761 | cycles_ += 2; | ||
7762 | } | ||
7763 | } | ||
7764 | |||
7765 | void opcode_e9() // JP (HL) | ||
7766 | { | ||
7767 | PC = HL(); | ||
7768 | } | ||
7769 | |||
7770 | void opcode_ea() // JP PE,nn | ||
7771 | { | ||
7772 | if( F & Parity ) | ||
7773 | PC = fetchWord(); | ||
7774 | else | ||
7775 | PC += 2; | ||
7776 | } | ||
7777 | |||
7778 | void opcode_eb() // EX DE,HL | ||
7779 | { | ||
7780 | unsigned char x; | ||
7781 | |||
7782 | x = D; D = H; H = x; | ||
7783 | x = E; E = L; L = x; | ||
7784 | } | ||
7785 | |||
7786 | void opcode_ec() // CALL PE,nn | ||
7787 | { | ||
7788 | if( F & Parity ) { | ||
7789 | callSub( fetchWord() ); | ||
7790 | cycles_ += 2; | ||
7791 | } | ||
7792 | else { | ||
7793 | PC += 2; | ||
7794 | } | ||
7795 | } | ||
7796 | |||
7797 | void opcode_ed() // [Prefix] | ||
7798 | { | ||
7799 | unsigned op = fetchByte(); | ||
7800 | |||
7801 | if( OpInfoED_[ op ].handler ) { | ||
7802 | OpInfoED_[ op ].handler(); | ||
7803 | cycles_ += OpInfoED_[ op ].cycles; | ||
7804 | } | ||
7805 | else { | ||
7806 | cycles_ += OpInfo_[ 0 ].cycles; // NOP | ||
7807 | } | ||
7808 | } | ||
7809 | |||
7810 | void opcode_ee() // XOR n | ||
7811 | { | ||
7812 | A ^= fetchByte(); | ||
7813 | setFlags35PSZ000(); | ||
7814 | } | ||
7815 | |||
7816 | void opcode_ef() // RST 28H | ||
7817 | { | ||
7818 | callSub( 0x28 ); | ||
7819 | } | ||
7820 | |||
7821 | void opcode_f0() // RET P | ||
7822 | { | ||
7823 | if( ! (F & Sign) ) { | ||
7824 | retFromSub(); | ||
7825 | cycles_ += 2; | ||
7826 | } | ||
7827 | } | ||
7828 | |||
7829 | void opcode_f1() // POP AF | ||
7830 | { | ||
7831 | F = readByte( SP++ ); | ||
7832 | A = readByte( SP++ ); | ||
7833 | } | ||
7834 | |||
7835 | void opcode_f2() // JP P,nn | ||
7836 | { | ||
7837 | if( ! (F & Sign) ) | ||
7838 | PC = fetchWord(); | ||
7839 | else | ||
7840 | PC += 2; | ||
7841 | } | ||
7842 | |||
7843 | void opcode_f3() // DI | ||
7844 | { | ||
7845 | iflags_ &= ~(IFF1 | IFF2); | ||
7846 | } | ||
7847 | |||
7848 | void opcode_f4() // CALL P,nn | ||
7849 | { | ||
7850 | if( ! (F & Sign) ) { | ||
7851 | callSub( fetchWord() ); | ||
7852 | cycles_ += 2; | ||
7853 | } | ||
7854 | else { | ||
7855 | PC += 2; | ||
7856 | } | ||
7857 | } | ||
7858 | |||
7859 | void opcode_f5() // PUSH AF | ||
7860 | { | ||
7861 | writeByte( --SP, A ); | ||
7862 | writeByte( --SP, F ); | ||
7863 | } | ||
7864 | |||
7865 | void opcode_f6() // OR n | ||
7866 | { | ||
7867 | A |= fetchByte(); | ||
7868 | setFlags35PSZ000(); | ||
7869 | } | ||
7870 | |||
7871 | void opcode_f7() // RST 30H | ||
7872 | { | ||
7873 | callSub( 0x30 ); | ||
7874 | } | ||
7875 | |||
7876 | void opcode_f8() // RET M | ||
7877 | { | ||
7878 | if( F & Sign ) { | ||
7879 | retFromSub(); | ||
7880 | cycles_ += 2; | ||
7881 | } | ||
7882 | } | ||
7883 | |||
7884 | void opcode_f9() // LD SP,HL | ||
7885 | { | ||
7886 | SP = HL(); | ||
7887 | } | ||
7888 | |||
7889 | void opcode_fa() // JP M,nn | ||
7890 | { | ||
7891 | if( F & Sign ) | ||
7892 | PC = fetchWord(); | ||
7893 | else | ||
7894 | PC += 2; | ||
7895 | } | ||
7896 | |||
7897 | void opcode_fb() // EI | ||
7898 | { | ||
7899 | iflags_ |= IFF1 | IFF2; | ||
7900 | } | ||
7901 | |||
7902 | void opcode_fc() // CALL M,nn | ||
7903 | { | ||
7904 | if( F & Sign ) { | ||
7905 | callSub( fetchWord() ); | ||
7906 | cycles_ += 2; | ||
7907 | } | ||
7908 | else { | ||
7909 | PC += 2; | ||
7910 | } | ||
7911 | } | ||
7912 | |||
7913 | void opcode_fd() // [IY Prefix] | ||
7914 | { | ||
7915 | do_opcode_xy( OpInfoFD_ ); | ||
7916 | IY &= 0xFFFF; | ||
7917 | } | ||
7918 | |||
7919 | |||
7920 | void opcode_fe() // CP n | ||
7921 | { | ||
7922 | subByte( fetchByte(), 0 ); | ||
7923 | } | ||
7924 | |||
7925 | void opcode_ff() // RST 38H | ||
7926 | { | ||
7927 | callSub( 0x38 ); | ||
7928 | } | ||
7929 | |||
7930 | |||
7931 | /* Executes one instruction */ | ||
7932 | void step(void) | ||
7933 | { | ||
7934 | // Update memory refresh register (not strictly needed but...) | ||
7935 | R = (R+1) & 0x7F; | ||
7936 | |||
7937 | if( iflags_ & Halted ) { | ||
7938 | // CPU is halted, do a NOP instruction | ||
7939 | cycles_ += OpInfo_[0].cycles; // NOP | ||
7940 | } | ||
7941 | else { | ||
7942 | // Get the opcode to execute | ||
7943 | unsigned op = fetchByte(); | ||
7944 | |||
7945 | // Update the cycles counter with the number of cycles for this opcode | ||
7946 | cycles_ += OpInfo_[ op ].cycles; | ||
7947 | |||
7948 | // Execute the opcode handler | ||
7949 | OpInfo_[ op ].handler(); | ||
7950 | |||
7951 | // Update registers | ||
7952 | PC &= 0xFFFF; // Clip program counter | ||
7953 | SP &= 0xFFFF; // Clip stack pointer | ||
7954 | } | ||
7955 | } | ||
7956 | |||
7957 | /* | ||
7958 | Runs the CPU for the specified number of cycles. | ||
7959 | |||
7960 | Note: the memory refresh register is not updated! | ||
7961 | */ | ||
7962 | unsigned z80_run( unsigned runCycles ) | ||
7963 | { | ||
7964 | unsigned target_cycles = cycles_ + runCycles; | ||
7965 | |||
7966 | // Execute instructions until the specified number of | ||
7967 | // cycles has elapsed | ||
7968 | while( cycles_ < target_cycles ) { | ||
7969 | if( iflags_ & Halted ) { | ||
7970 | // CPU is halted, do NOPs for the rest of cycles | ||
7971 | // (this may be off by a few cycles) | ||
7972 | cycles_ = target_cycles; | ||
7973 | } | ||
7974 | else { | ||
7975 | // Get the opcode to execute | ||
7976 | unsigned op = fetchByte(); | ||
7977 | |||
7978 | // Update the cycles counter with the number of cycles for this opcode | ||
7979 | cycles_ += OpInfo_[ op ].cycles; | ||
7980 | |||
7981 | // Execute the opcode handler | ||
7982 | OpInfo_[ op ].handler(); | ||
7983 | } | ||
7984 | } | ||
7985 | |||
7986 | // Update registers | ||
7987 | PC &= 0xFFFF; // Clip program counter | ||
7988 | SP &= 0xFFFF; // Clip stack pointer | ||
7989 | |||
7990 | // Return the number of extra cycles executed | ||
7991 | return cycles_ - target_cycles; | ||
7992 | } | ||
7993 | |||
7994 | /* Interrupt */ | ||
7995 | void z80_interrupt( unsigned char data ) | ||
7996 | { | ||
7997 | // Execute interrupt only if interrupts are enabled | ||
7998 | if( iflags_ & IFF1 ) { | ||
7999 | // Disable maskable interrupts and restart the CPU if halted | ||
8000 | iflags_ &= ~(IFF1 | IFF2 | Halted); | ||
8001 | |||
8002 | switch( getInterruptMode() ) { | ||
8003 | case 0: | ||
8004 | OpInfo_[ data ].handler(); | ||
8005 | cycles_ += 11; | ||
8006 | break; | ||
8007 | case 1: | ||
8008 | callSub( 0x38 ); | ||
8009 | cycles_ += 11; | ||
8010 | break; | ||
8011 | case 2: | ||
8012 | callSub( readWord( ((unsigned)I) << 8 | (data & 0xFE) ) ); | ||
8013 | cycles_ += 19; | ||
8014 | break; | ||
8015 | } | ||
8016 | } | ||
8017 | } | ||
8018 | |||
8019 | /* Non-maskable interrupt */ | ||
8020 | void nmi(void) | ||
8021 | { | ||
8022 | // Disable maskable interrupts but preserve IFF2 (that is a copy of IFF1), | ||
8023 | // also restart the CPU if halted | ||
8024 | iflags_ &= ~(IFF1 | Halted); | ||
8025 | |||
8026 | callSub( 0x66 ); | ||
8027 | |||
8028 | cycles_ += 11; | ||
8029 | } | ||
8030 | |||
8031 | void do_opcode_xy( OpcodeInfo * info ) | ||
8032 | { | ||
8033 | unsigned op = fetchByte(); | ||
8034 | |||
8035 | if( (op == 0xDD) || (op == 0xFD) ) { | ||
8036 | // Exit now, to avoid possible infinite loops | ||
8037 | PC--; | ||
8038 | cycles_ += OpInfo_[ 0 ].cycles; // NOP | ||
8039 | } | ||
8040 | else if( op == 0xED ) { | ||
8041 | // IX or IY prefix is ignored for this opcode | ||
8042 | opcode_ed(); | ||
8043 | } | ||
8044 | else { | ||
8045 | // Handle IX or IY prefix if possible | ||
8046 | if( info[ op ].handler ) { | ||
8047 | // Extended opcode is valid | ||
8048 | cycles_ += info[ op ].cycles; | ||
8049 | info[ op ].handler(); | ||
8050 | } | ||
8051 | else { | ||
8052 | // Extended opcode not valid, fall back to standard opcode | ||
8053 | cycles_ += OpInfo_[ op ].cycles; | ||
8054 | OpInfo_[ op ].handler(); | ||
8055 | } | ||
8056 | } | ||
8057 | } | ||
8058 | |||
diff --git a/apps/plugins/pacbox/z80.h b/apps/plugins/pacbox/z80.h new file mode 100644 index 0000000000..b6288981d0 --- /dev/null +++ b/apps/plugins/pacbox/z80.h | |||
@@ -0,0 +1,160 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #ifndef Z80_H_ | ||
26 | #define Z80_H_ | ||
27 | |||
28 | /** | ||
29 | Environment for Z80 emulation. | ||
30 | |||
31 | This class implements all input/output functions for the Z80 emulator class, | ||
32 | that is it provides functions to access the system RAM, ROM and I/O ports. | ||
33 | |||
34 | An object of this class corresponds to a system that has no RAM, ROM or ports: | ||
35 | users of the Z80 emulator should provide the desired behaviour by writing a | ||
36 | descendant of this class. | ||
37 | |||
38 | @author Alessandro Scotti | ||
39 | @version 1.0 | ||
40 | */ | ||
41 | |||
42 | /** Sets the CPU cycle counter to the specified value. */ | ||
43 | void setCycles( unsigned value ); | ||
44 | |||
45 | void onReturnFromInterrupt(void); | ||
46 | |||
47 | |||
48 | /** | ||
49 | Z80 software emulator. | ||
50 | |||
51 | @author Alessandro Scotti | ||
52 | @version 1.1 | ||
53 | */ | ||
54 | /** CPU flags */ | ||
55 | enum { | ||
56 | Carry = 0x01, // C | ||
57 | AddSub = 0x02, Subtraction = AddSub, // N | ||
58 | Parity = 0x04, Overflow = Parity, // P/V, same bit used for parity and overflow | ||
59 | Flag3 = 0x08, // Aka XF, not used | ||
60 | Halfcarry = 0x10, // H | ||
61 | Flag5 = 0x20, // Aka YF, not used | ||
62 | Zero = 0x40, // Z | ||
63 | Sign = 0x80 // S | ||
64 | }; | ||
65 | |||
66 | /** | ||
67 | Constructor: creates a Z80 object with the specified environment. | ||
68 | */ | ||
69 | // Z80( Z80Environment & ); | ||
70 | |||
71 | /** | ||
72 | Copy constructor: creates a copy of the specified Z80 object. | ||
73 | */ | ||
74 | // Z80( const Z80 & ); | ||
75 | |||
76 | // /** Destructor. */ | ||
77 | // virtual ~Z80() { | ||
78 | |||
79 | /** | ||
80 | Resets the CPU to its initial state. | ||
81 | |||
82 | The stack pointer (SP) is set to F000h, all other registers are cleared. | ||
83 | */ | ||
84 | void z80_reset(void); | ||
85 | |||
86 | /** | ||
87 | Runs the CPU for the specified number of cycles. | ||
88 | |||
89 | Note that the number of CPU cycles performed by this function may be | ||
90 | actually a little more than the value specified. If that happens then the | ||
91 | function returns the number of extra cycles executed. | ||
92 | |||
93 | @param cycles number of cycles the CPU must execute | ||
94 | |||
95 | @return the number of extra cycles executed by the last instruction | ||
96 | */ | ||
97 | unsigned z80_run( unsigned cycles ); | ||
98 | |||
99 | /** | ||
100 | Executes one instruction. | ||
101 | */ | ||
102 | void z80_step(void); | ||
103 | |||
104 | /** | ||
105 | Invokes an interrupt. | ||
106 | |||
107 | If interrupts are enabled, the current program counter (PC) is saved on | ||
108 | the stack and assigned the specified address. When the interrupt handler | ||
109 | returns, execution resumes from the point where the interrupt occurred. | ||
110 | |||
111 | The actual interrupt address depends on the current interrupt mode and | ||
112 | on the interrupt type. For maskable interrupts, data is as follows: | ||
113 | - mode 0: data is an opcode that is executed (usually RST xxh); | ||
114 | - mode 1: data is ignored and a call is made to address 0x38; | ||
115 | - mode 2: a call is made to the 16 bit address given by (256*I + data). | ||
116 | */ | ||
117 | void z80_interrupt( unsigned char data ); | ||
118 | |||
119 | /** Forces a non-maskable interrupt. */ | ||
120 | void z80_nmi(void); | ||
121 | |||
122 | /** | ||
123 | Copies CPU register from one object to another. | ||
124 | |||
125 | Note that the environment is not copied, only registers. | ||
126 | */ | ||
127 | // Z80 & operator = ( const Z80 & ); | ||
128 | |||
129 | /** Returns the size of the buffer needed to take a snapshot of the CPU. */ | ||
130 | unsigned getSizeOfSnapshotBuffer(void); | ||
131 | |||
132 | /** | ||
133 | Takes a snapshot of the CPU. | ||
134 | |||
135 | A snapshot saves all of the CPU registers and internals. It can be | ||
136 | restored at any time to bring the CPU back to the exact status it | ||
137 | had when the snapshot was taken. | ||
138 | |||
139 | Note: the size of the snapshot buffer must be no less than the size | ||
140 | returned by the getSizeOfSnapshotBuffer() function. | ||
141 | |||
142 | @param buffer buffer where the snapshot data is stored | ||
143 | |||
144 | @return the number of bytes written into the buffer | ||
145 | */ | ||
146 | unsigned takeSnapshot( unsigned char * buffer ); | ||
147 | |||
148 | /** | ||
149 | Restores a snapshot taken with takeSnapshot(). | ||
150 | |||
151 | This function uses the data saved in the snapshot buffer to restore the | ||
152 | CPU status. | ||
153 | |||
154 | @param buffer buffer where the snapshot data is stored | ||
155 | |||
156 | @return the number of bytes read from the buffer | ||
157 | */ | ||
158 | unsigned restoreSnapshot( unsigned char * buffer ); | ||
159 | |||
160 | #endif // Z80_H_ | ||
diff --git a/apps/plugins/pacbox/z80_internal.h b/apps/plugins/pacbox/z80_internal.h new file mode 100644 index 0000000000..4e45aa7d7b --- /dev/null +++ b/apps/plugins/pacbox/z80_internal.h | |||
@@ -0,0 +1,1062 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Pacbox - a Pacman Emulator for Rockbox | ||
11 | * | ||
12 | * Based on PIE - Pacman Instructional Emulator | ||
13 | * | ||
14 | * Copyright (c) 1997-2003,2004 Alessandro Scotti | ||
15 | * http://www.ascotti.org/ | ||
16 | * | ||
17 | * All files in this archive are subject to the GNU General Public License. | ||
18 | * See the file COPYING in the source tree root for full license agreement. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #ifndef Z80_INTERNAL_H_ | ||
26 | #define Z80_INTERNAL_H_ | ||
27 | |||
28 | // Implementation of opcodes 0x00 to 0xFF | ||
29 | void opcode_00(void); // NOP | ||
30 | void opcode_01(void); // LD BC,nn | ||
31 | void opcode_02(void); // LD (BC),A | ||
32 | void opcode_03(void); // INC BC | ||
33 | void opcode_04(void); // INC B | ||
34 | void opcode_05(void); // DEC B | ||
35 | void opcode_06(void); // LD B,n | ||
36 | void opcode_07(void); // RLCA | ||
37 | void opcode_08(void); // EX AF,AF' | ||
38 | void opcode_09(void); // ADD HL,BC | ||
39 | void opcode_0a(void); // LD A,(BC) | ||
40 | void opcode_0b(void); // DEC BC | ||
41 | void opcode_0c(void); // INC C | ||
42 | void opcode_0d(void); // DEC C | ||
43 | void opcode_0e(void); // LD C,n | ||
44 | void opcode_0f(void); // RRCA | ||
45 | void opcode_10(void); // DJNZ d | ||
46 | void opcode_11(void); // LD DE,nn | ||
47 | void opcode_12(void); // LD (DE),A | ||
48 | void opcode_13(void); // INC DE | ||
49 | void opcode_14(void); // INC D | ||
50 | void opcode_15(void); // DEC D | ||
51 | void opcode_16(void); // LD D,n | ||
52 | void opcode_17(void); // RLA | ||
53 | void opcode_18(void); // JR d | ||
54 | void opcode_19(void); // ADD HL,DE | ||
55 | void opcode_1a(void); // LD A,(DE) | ||
56 | void opcode_1b(void); // DEC DE | ||
57 | void opcode_1c(void); // INC E | ||
58 | void opcode_1d(void); // DEC E | ||
59 | void opcode_1e(void); // LD E,n | ||
60 | void opcode_1f(void); // RRA | ||
61 | void opcode_20(void); // JR NZ,d | ||
62 | void opcode_21(void); // LD HL,nn | ||
63 | void opcode_22(void); // LD (nn),HL | ||
64 | void opcode_23(void); // INC HL | ||
65 | void opcode_24(void); // INC H | ||
66 | void opcode_25(void); // DEC H | ||
67 | void opcode_26(void); // LD H,n | ||
68 | void opcode_27(void); // DAA | ||
69 | void opcode_28(void); // JR Z,d | ||
70 | void opcode_29(void); // ADD HL,HL | ||
71 | void opcode_2a(void); // LD HL,(nn) | ||
72 | void opcode_2b(void); // DEC HL | ||
73 | void opcode_2c(void); // INC L | ||
74 | void opcode_2d(void); // DEC L | ||
75 | void opcode_2e(void); // LD L,n | ||
76 | void opcode_2f(void); // CPL | ||
77 | void opcode_30(void); // JR NC,d | ||
78 | void opcode_31(void); // LD SP,nn | ||
79 | void opcode_32(void); // LD (nn),A | ||
80 | void opcode_33(void); // INC SP | ||
81 | void opcode_34(void); // INC (HL) | ||
82 | void opcode_35(void); // DEC (HL) | ||
83 | void opcode_36(void); // LD (HL),n | ||
84 | void opcode_37(void); // SCF | ||
85 | void opcode_38(void); // JR C,d | ||
86 | void opcode_39(void); // ADD HL,SP | ||
87 | void opcode_3a(void); // LD A,(nn) | ||
88 | void opcode_3b(void); // DEC SP | ||
89 | void opcode_3c(void); // INC A | ||
90 | void opcode_3d(void); // DEC A | ||
91 | void opcode_3e(void); // LD A,n | ||
92 | void opcode_3f(void); // CCF | ||
93 | void opcode_40(void); // LD B,B | ||
94 | void opcode_41(void); // LD B,C | ||
95 | void opcode_42(void); // LD B,D | ||
96 | void opcode_43(void); // LD B,E | ||
97 | void opcode_44(void); // LD B,H | ||
98 | void opcode_45(void); // LD B,L | ||
99 | void opcode_46(void); // LD B,(HL) | ||
100 | void opcode_47(void); // LD B,A | ||
101 | void opcode_48(void); // LD C,B | ||
102 | void opcode_49(void); // LD C,C | ||
103 | void opcode_4a(void); // LD C,D | ||
104 | void opcode_4b(void); // LD C,E | ||
105 | void opcode_4c(void); // LD C,H | ||
106 | void opcode_4d(void); // LD C,L | ||
107 | void opcode_4e(void); // LD C,(HL) | ||
108 | void opcode_4f(void); // LD C,A | ||
109 | void opcode_50(void); // LD D,B | ||
110 | void opcode_51(void); // LD D,C | ||
111 | void opcode_52(void); // LD D,D | ||
112 | void opcode_53(void); // LD D,E | ||
113 | void opcode_54(void); // LD D,H | ||
114 | void opcode_55(void); // LD D,L | ||
115 | void opcode_56(void); // LD D,(HL) | ||
116 | void opcode_57(void); // LD D,A | ||
117 | void opcode_58(void); // LD E,B | ||
118 | void opcode_59(void); // LD E,C | ||
119 | void opcode_5a(void); // LD E,D | ||
120 | void opcode_5b(void); // LD E,E | ||
121 | void opcode_5c(void); // LD E,H | ||
122 | void opcode_5d(void); // LD E,L | ||
123 | void opcode_5e(void); // LD E,(HL) | ||
124 | void opcode_5f(void); // LD E,A | ||
125 | void opcode_60(void); // LD H,B | ||
126 | void opcode_61(void); // LD H,C | ||
127 | void opcode_62(void); // LD H,D | ||
128 | void opcode_63(void); // LD H,E | ||
129 | void opcode_64(void); // LD H,H | ||
130 | void opcode_65(void); // LD H,L | ||
131 | void opcode_66(void); // LD H,(HL) | ||
132 | void opcode_67(void); // LD H,A | ||
133 | void opcode_68(void); // LD L,B | ||
134 | void opcode_69(void); // LD L,C | ||
135 | void opcode_6a(void); // LD L,D | ||
136 | void opcode_6b(void); // LD L,E | ||
137 | void opcode_6c(void); // LD L,H | ||
138 | void opcode_6d(void); // LD L,L | ||
139 | void opcode_6e(void); // LD L,(HL) | ||
140 | void opcode_6f(void); // LD L,A | ||
141 | void opcode_70(void); // LD (HL),B | ||
142 | void opcode_71(void); // LD (HL),C | ||
143 | void opcode_72(void); // LD (HL),D | ||
144 | void opcode_73(void); // LD (HL),E | ||
145 | void opcode_74(void); // LD (HL),H | ||
146 | void opcode_75(void); // LD (HL),L | ||
147 | void opcode_76(void); // HALT | ||
148 | void opcode_77(void); // LD (HL),A | ||
149 | void opcode_78(void); // LD A,B | ||
150 | void opcode_79(void); // LD A,C | ||
151 | void opcode_7a(void); // LD A,D | ||
152 | void opcode_7b(void); // LD A,E | ||
153 | void opcode_7c(void); // LD A,H | ||
154 | void opcode_7d(void); // LD A,L | ||
155 | void opcode_7e(void); // LD A,(HL) | ||
156 | void opcode_7f(void); // LD A,A | ||
157 | void opcode_80(void); // ADD A,B | ||
158 | void opcode_81(void); // ADD A,C | ||
159 | void opcode_82(void); // ADD A,D | ||
160 | void opcode_83(void); // ADD A,E | ||
161 | void opcode_84(void); // ADD A,H | ||
162 | void opcode_85(void); // ADD A,L | ||
163 | void opcode_86(void); // ADD A,(HL) | ||
164 | void opcode_87(void); // ADD A,A | ||
165 | void opcode_88(void); // ADC A,B | ||
166 | void opcode_89(void); // ADC A,C | ||
167 | void opcode_8a(void); // ADC A,D | ||
168 | void opcode_8b(void); // ADC A,E | ||
169 | void opcode_8c(void); // ADC A,H | ||
170 | void opcode_8d(void); // ADC A,L | ||
171 | void opcode_8e(void); // ADC A,(HL) | ||
172 | void opcode_8f(void); // ADC A,A | ||
173 | void opcode_90(void); // SUB B | ||
174 | void opcode_91(void); // SUB C | ||
175 | void opcode_92(void); // SUB D | ||
176 | void opcode_93(void); // SUB E | ||
177 | void opcode_94(void); // SUB H | ||
178 | void opcode_95(void); // SUB L | ||
179 | void opcode_96(void); // SUB (HL) | ||
180 | void opcode_97(void); // SUB A | ||
181 | void opcode_98(void); // SBC A,B | ||
182 | void opcode_99(void); // SBC A,C | ||
183 | void opcode_9a(void); // SBC A,D | ||
184 | void opcode_9b(void); // SBC A,E | ||
185 | void opcode_9c(void); // SBC A,H | ||
186 | void opcode_9d(void); // SBC A,L | ||
187 | void opcode_9e(void); // SBC A,(HL) | ||
188 | void opcode_9f(void); // SBC A,A | ||
189 | void opcode_a0(void); // AND B | ||
190 | void opcode_a1(void); // AND C | ||
191 | void opcode_a2(void); // AND D | ||
192 | void opcode_a3(void); // AND E | ||
193 | void opcode_a4(void); // AND H | ||
194 | void opcode_a5(void); // AND L | ||
195 | void opcode_a6(void); // AND (HL) | ||
196 | void opcode_a7(void); // AND A | ||
197 | void opcode_a8(void); // XOR B | ||
198 | void opcode_a9(void); // XOR C | ||
199 | void opcode_aa(void); // XOR D | ||
200 | void opcode_ab(void); // XOR E | ||
201 | void opcode_ac(void); // XOR H | ||
202 | void opcode_ad(void); // XOR L | ||
203 | void opcode_ae(void); // XOR (HL) | ||
204 | void opcode_af(void); // XOR A | ||
205 | void opcode_b0(void); // OR B | ||
206 | void opcode_b1(void); // OR C | ||
207 | void opcode_b2(void); // OR D | ||
208 | void opcode_b3(void); // OR E | ||
209 | void opcode_b4(void); // OR H | ||
210 | void opcode_b5(void); // OR L | ||
211 | void opcode_b6(void); // OR (HL) | ||
212 | void opcode_b7(void); // OR A | ||
213 | void opcode_b8(void); // CP B | ||
214 | void opcode_b9(void); // CP C | ||
215 | void opcode_ba(void); // CP D | ||
216 | void opcode_bb(void); // CP E | ||
217 | void opcode_bc(void); // CP H | ||
218 | void opcode_bd(void); // CP L | ||
219 | void opcode_be(void); // CP (HL) | ||
220 | void opcode_bf(void); // CP A | ||
221 | void opcode_c0(void); // RET NZ | ||
222 | void opcode_c1(void); // POP BC | ||
223 | void opcode_c2(void); // JP NZ,nn | ||
224 | void opcode_c3(void); // JP nn | ||
225 | void opcode_c4(void); // CALL NZ,nn | ||
226 | void opcode_c5(void); // PUSH BC | ||
227 | void opcode_c6(void); // ADD A,n | ||
228 | void opcode_c7(void); // RST 0 | ||
229 | void opcode_c8(void); // RET Z | ||
230 | void opcode_c9(void); // RET | ||
231 | void opcode_ca(void); // JP Z,nn | ||
232 | void opcode_cb(void); // [Prefix] | ||
233 | void opcode_cc(void); // CALL Z,nn | ||
234 | void opcode_cd(void); // CALL nn | ||
235 | void opcode_ce(void); // ADC A,n | ||
236 | void opcode_cf(void); // RST 8 | ||
237 | void opcode_d0(void); // RET NC | ||
238 | void opcode_d1(void); // POP DE | ||
239 | void opcode_d2(void); // JP NC,nn | ||
240 | void opcode_d3(void); // OUT (n),A | ||
241 | void opcode_d4(void); // CALL NC,nn | ||
242 | void opcode_d5(void); // PUSH DE | ||
243 | void opcode_d6(void); // SUB n | ||
244 | void opcode_d7(void); // RST 10H | ||
245 | void opcode_d8(void); // RET C | ||
246 | void opcode_d9(void); // EXX | ||
247 | void opcode_da(void); // JP C,nn | ||
248 | void opcode_db(void); // IN A,(n) | ||
249 | void opcode_dc(void); // CALL C,nn | ||
250 | void opcode_dd(void); // [IX Prefix] | ||
251 | void opcode_de(void); // SBC A,n | ||
252 | void opcode_df(void); // RST 18H | ||
253 | void opcode_e0(void); // RET PO | ||
254 | void opcode_e1(void); // POP HL | ||
255 | void opcode_e2(void); // JP PO,nn | ||
256 | void opcode_e3(void); // EX (SP),HL | ||
257 | void opcode_e4(void); // CALL PO,nn | ||
258 | void opcode_e5(void); // PUSH HL | ||
259 | void opcode_e6(void); // AND n | ||
260 | void opcode_e7(void); // RST 20H | ||
261 | void opcode_e8(void); // RET PE | ||
262 | void opcode_e9(void); // JP (HL) | ||
263 | void opcode_ea(void); // JP PE,nn | ||
264 | void opcode_eb(void); // EX DE,HL | ||
265 | void opcode_ec(void); // CALL PE,nn | ||
266 | void opcode_ed(void); // [Prefix] | ||
267 | void opcode_ee(void); // XOR n | ||
268 | void opcode_ef(void); // RST 28H | ||
269 | void opcode_f0(void); // RET P | ||
270 | void opcode_f1(void); // POP AF | ||
271 | void opcode_f2(void); // JP P,nn | ||
272 | void opcode_f3(void); // DI | ||
273 | void opcode_f4(void); // CALL P,nn | ||
274 | void opcode_f5(void); // PUSH AF | ||
275 | void opcode_f6(void); // OR n | ||
276 | void opcode_f7(void); // RST 30H | ||
277 | void opcode_f8(void); // RET M | ||
278 | void opcode_f9(void); // LD SP,HL | ||
279 | void opcode_fa(void); // JP M,nn | ||
280 | void opcode_fb(void); // EI | ||
281 | void opcode_fc(void); // CALL M,nn | ||
282 | void opcode_fd(void); // [IY Prefix] | ||
283 | void opcode_fe(void); // CP n | ||
284 | void opcode_ff(void); // RST 38H | ||
285 | |||
286 | // Handlers for the 0xCB prefix | ||
287 | void opcode_cb_00(void); // RLC B | ||
288 | void opcode_cb_01(void); // RLC C | ||
289 | void opcode_cb_02(void); // RLC D | ||
290 | void opcode_cb_03(void); // RLC E | ||
291 | void opcode_cb_04(void); // RLC H | ||
292 | void opcode_cb_05(void); // RLC L | ||
293 | void opcode_cb_06(void); // RLC (HL) | ||
294 | void opcode_cb_07(void); // RLC A | ||
295 | void opcode_cb_08(void); // RRC B | ||
296 | void opcode_cb_09(void); // RRC C | ||
297 | void opcode_cb_0a(void); // RRC D | ||
298 | void opcode_cb_0b(void); // RRC E | ||
299 | void opcode_cb_0c(void); // RRC H | ||
300 | void opcode_cb_0d(void); // RRC L | ||
301 | void opcode_cb_0e(void); // RRC (HL) | ||
302 | void opcode_cb_0f(void); // RRC A | ||
303 | void opcode_cb_10(void); // RL B | ||
304 | void opcode_cb_11(void); // RL C | ||
305 | void opcode_cb_12(void); // RL D | ||
306 | void opcode_cb_13(void); // RL E | ||
307 | void opcode_cb_14(void); // RL H | ||
308 | void opcode_cb_15(void); // RL L | ||
309 | void opcode_cb_16(void); // RL (HL) | ||
310 | void opcode_cb_17(void); // RL A | ||
311 | void opcode_cb_18(void); // RR B | ||
312 | void opcode_cb_19(void); // RR C | ||
313 | void opcode_cb_1a(void); // RR D | ||
314 | void opcode_cb_1b(void); // RR E | ||
315 | void opcode_cb_1c(void); // RR H | ||
316 | void opcode_cb_1d(void); // RR L | ||
317 | void opcode_cb_1e(void); // RR (HL) | ||
318 | void opcode_cb_1f(void); // RR A | ||
319 | void opcode_cb_20(void); // SLA B | ||
320 | void opcode_cb_21(void); // SLA C | ||
321 | void opcode_cb_22(void); // SLA D | ||
322 | void opcode_cb_23(void); // SLA E | ||
323 | void opcode_cb_24(void); // SLA H | ||
324 | void opcode_cb_25(void); // SLA L | ||
325 | void opcode_cb_26(void); // SLA (HL) | ||
326 | void opcode_cb_27(void); // SLA A | ||
327 | void opcode_cb_28(void); // SRA B | ||
328 | void opcode_cb_29(void); // SRA C | ||
329 | void opcode_cb_2a(void); // SRA D | ||
330 | void opcode_cb_2b(void); // SRA E | ||
331 | void opcode_cb_2c(void); // SRA H | ||
332 | void opcode_cb_2d(void); // SRA L | ||
333 | void opcode_cb_2e(void); // SRA (HL) | ||
334 | void opcode_cb_2f(void); // SRA A | ||
335 | void opcode_cb_30(void); // SLL B [undocumented] | ||
336 | void opcode_cb_31(void); // SLL C [undocumented] | ||
337 | void opcode_cb_32(void); // SLL D [undocumented] | ||
338 | void opcode_cb_33(void); // SLL E [undocumented] | ||
339 | void opcode_cb_34(void); // SLL H [undocumented] | ||
340 | void opcode_cb_35(void); // SLL L [undocumented] | ||
341 | void opcode_cb_36(void); // SLL (HL) [undocumented] | ||
342 | void opcode_cb_37(void); // SLL A [undocumented] | ||
343 | void opcode_cb_38(void); // SRL B | ||
344 | void opcode_cb_39(void); // SRL C | ||
345 | void opcode_cb_3a(void); // SRL D | ||
346 | void opcode_cb_3b(void); // SRL E | ||
347 | void opcode_cb_3c(void); // SRL H | ||
348 | void opcode_cb_3d(void); // SRL L | ||
349 | void opcode_cb_3e(void); // SRL (HL) | ||
350 | void opcode_cb_3f(void); // SRL A | ||
351 | void opcode_cb_40(void); // BIT 0, B | ||
352 | void opcode_cb_41(void); // BIT 0, C | ||
353 | void opcode_cb_42(void); // BIT 0, D | ||
354 | void opcode_cb_43(void); // BIT 0, E | ||
355 | void opcode_cb_44(void); // BIT 0, H | ||
356 | void opcode_cb_45(void); // BIT 0, L | ||
357 | void opcode_cb_46(void); // BIT 0, (HL) | ||
358 | void opcode_cb_47(void); // BIT 0, A | ||
359 | void opcode_cb_48(void); // BIT 1, B | ||
360 | void opcode_cb_49(void); // BIT 1, C | ||
361 | void opcode_cb_4a(void); // BIT 1, D | ||
362 | void opcode_cb_4b(void); // BIT 1, E | ||
363 | void opcode_cb_4c(void); // BIT 1, H | ||
364 | void opcode_cb_4d(void); // BIT 1, L | ||
365 | void opcode_cb_4e(void); // BIT 1, (HL) | ||
366 | void opcode_cb_4f(void); // BIT 1, A | ||
367 | void opcode_cb_50(void); // BIT 2, B | ||
368 | void opcode_cb_51(void); // BIT 2, C | ||
369 | void opcode_cb_52(void); // BIT 2, D | ||
370 | void opcode_cb_53(void); // BIT 2, E | ||
371 | void opcode_cb_54(void); // BIT 2, H | ||
372 | void opcode_cb_55(void); // BIT 2, L | ||
373 | void opcode_cb_56(void); // BIT 2, (HL) | ||
374 | void opcode_cb_57(void); // BIT 2, A | ||
375 | void opcode_cb_58(void); // BIT 3, B | ||
376 | void opcode_cb_59(void); // BIT 3, C | ||
377 | void opcode_cb_5a(void); // BIT 3, D | ||
378 | void opcode_cb_5b(void); // BIT 3, E | ||
379 | void opcode_cb_5c(void); // BIT 3, H | ||
380 | void opcode_cb_5d(void); // BIT 3, L | ||
381 | void opcode_cb_5e(void); // BIT 3, (HL) | ||
382 | void opcode_cb_5f(void); // BIT 3, A | ||
383 | void opcode_cb_60(void); // BIT 4, B | ||
384 | void opcode_cb_61(void); // BIT 4, C | ||
385 | void opcode_cb_62(void); // BIT 4, D | ||
386 | void opcode_cb_63(void); // BIT 4, E | ||
387 | void opcode_cb_64(void); // BIT 4, H | ||
388 | void opcode_cb_65(void); // BIT 4, L | ||
389 | void opcode_cb_66(void); // BIT 4, (HL) | ||
390 | void opcode_cb_67(void); // BIT 4, A | ||
391 | void opcode_cb_68(void); // BIT 5, B | ||
392 | void opcode_cb_69(void); // BIT 5, C | ||
393 | void opcode_cb_6a(void); // BIT 5, D | ||
394 | void opcode_cb_6b(void); // BIT 5, E | ||
395 | void opcode_cb_6c(void); // BIT 5, H | ||
396 | void opcode_cb_6d(void); // BIT 5, L | ||
397 | void opcode_cb_6e(void); // BIT 5, (HL) | ||
398 | void opcode_cb_6f(void); // BIT 5, A | ||
399 | void opcode_cb_70(void); // BIT 6, B | ||
400 | void opcode_cb_71(void); // BIT 6, C | ||
401 | void opcode_cb_72(void); // BIT 6, D | ||
402 | void opcode_cb_73(void); // BIT 6, E | ||
403 | void opcode_cb_74(void); // BIT 6, H | ||
404 | void opcode_cb_75(void); // BIT 6, L | ||
405 | void opcode_cb_76(void); // BIT 6, (HL) | ||
406 | void opcode_cb_77(void); // BIT 6, A | ||
407 | void opcode_cb_78(void); // BIT 7, B | ||
408 | void opcode_cb_79(void); // BIT 7, C | ||
409 | void opcode_cb_7a(void); // BIT 7, D | ||
410 | void opcode_cb_7b(void); // BIT 7, E | ||
411 | void opcode_cb_7c(void); // BIT 7, H | ||
412 | void opcode_cb_7d(void); // BIT 7, L | ||
413 | void opcode_cb_7e(void); // BIT 7, (HL) | ||
414 | void opcode_cb_7f(void); // BIT 7, A | ||
415 | void opcode_cb_80(void); // RES 0, B | ||
416 | void opcode_cb_81(void); // RES 0, C | ||
417 | void opcode_cb_82(void); // RES 0, D | ||
418 | void opcode_cb_83(void); // RES 0, E | ||
419 | void opcode_cb_84(void); // RES 0, H | ||
420 | void opcode_cb_85(void); // RES 0, L | ||
421 | void opcode_cb_86(void); // RES 0, (HL) | ||
422 | void opcode_cb_87(void); // RES 0, A | ||
423 | void opcode_cb_88(void); // RES 1, B | ||
424 | void opcode_cb_89(void); // RES 1, C | ||
425 | void opcode_cb_8a(void); // RES 1, D | ||
426 | void opcode_cb_8b(void); // RES 1, E | ||
427 | void opcode_cb_8c(void); // RES 1, H | ||
428 | void opcode_cb_8d(void); // RES 1, L | ||
429 | void opcode_cb_8e(void); // RES 1, (HL) | ||
430 | void opcode_cb_8f(void); // RES 1, A | ||
431 | void opcode_cb_90(void); // RES 2, B | ||
432 | void opcode_cb_91(void); // RES 2, C | ||
433 | void opcode_cb_92(void); // RES 2, D | ||
434 | void opcode_cb_93(void); // RES 2, E | ||
435 | void opcode_cb_94(void); // RES 2, H | ||
436 | void opcode_cb_95(void); // RES 2, L | ||
437 | void opcode_cb_96(void); // RES 2, (HL) | ||
438 | void opcode_cb_97(void); // RES 2, A | ||
439 | void opcode_cb_98(void); // RES 3, B | ||
440 | void opcode_cb_99(void); // RES 3, C | ||
441 | void opcode_cb_9a(void); // RES 3, D | ||
442 | void opcode_cb_9b(void); // RES 3, E | ||
443 | void opcode_cb_9c(void); // RES 3, H | ||
444 | void opcode_cb_9d(void); // RES 3, L | ||
445 | void opcode_cb_9e(void); // RES 3, (HL) | ||
446 | void opcode_cb_9f(void); // RES 3, A | ||
447 | void opcode_cb_a0(void); // RES 4, B | ||
448 | void opcode_cb_a1(void); // RES 4, C | ||
449 | void opcode_cb_a2(void); // RES 4, D | ||
450 | void opcode_cb_a3(void); // RES 4, E | ||
451 | void opcode_cb_a4(void); // RES 4, H | ||
452 | void opcode_cb_a5(void); // RES 4, L | ||
453 | void opcode_cb_a6(void); // RES 4, (HL) | ||
454 | void opcode_cb_a7(void); // RES 4, A | ||
455 | void opcode_cb_a8(void); // RES 5, B | ||
456 | void opcode_cb_a9(void); // RES 5, C | ||
457 | void opcode_cb_aa(void); // RES 5, D | ||
458 | void opcode_cb_ab(void); // RES 5, E | ||
459 | void opcode_cb_ac(void); // RES 5, H | ||
460 | void opcode_cb_ad(void); // RES 5, L | ||
461 | void opcode_cb_ae(void); // RES 5, (HL) | ||
462 | void opcode_cb_af(void); // RES 5, A | ||
463 | void opcode_cb_b0(void); // RES 6, B | ||
464 | void opcode_cb_b1(void); // RES 6, C | ||
465 | void opcode_cb_b2(void); // RES 6, D | ||
466 | void opcode_cb_b3(void); // RES 6, E | ||
467 | void opcode_cb_b4(void); // RES 6, H | ||
468 | void opcode_cb_b5(void); // RES 6, L | ||
469 | void opcode_cb_b6(void); // RES 6, (HL) | ||
470 | void opcode_cb_b7(void); // RES 6, A | ||
471 | void opcode_cb_b8(void); // RES 7, B | ||
472 | void opcode_cb_b9(void); // RES 7, C | ||
473 | void opcode_cb_ba(void); // RES 7, D | ||
474 | void opcode_cb_bb(void); // RES 7, E | ||
475 | void opcode_cb_bc(void); // RES 7, H | ||
476 | void opcode_cb_bd(void); // RES 7, L | ||
477 | void opcode_cb_be(void); // RES 7, (HL) | ||
478 | void opcode_cb_bf(void); // RES 7, A | ||
479 | void opcode_cb_c0(void); // SET 0, B | ||
480 | void opcode_cb_c1(void); // SET 0, C | ||
481 | void opcode_cb_c2(void); // SET 0, D | ||
482 | void opcode_cb_c3(void); // SET 0, E | ||
483 | void opcode_cb_c4(void); // SET 0, H | ||
484 | void opcode_cb_c5(void); // SET 0, L | ||
485 | void opcode_cb_c6(void); // SET 0, (HL) | ||
486 | void opcode_cb_c7(void); // SET 0, A | ||
487 | void opcode_cb_c8(void); // SET 1, B | ||
488 | void opcode_cb_c9(void); // SET 1, C | ||
489 | void opcode_cb_ca(void); // SET 1, D | ||
490 | void opcode_cb_cb(void); // SET 1, E | ||
491 | void opcode_cb_cc(void); // SET 1, H | ||
492 | void opcode_cb_cd(void); // SET 1, L | ||
493 | void opcode_cb_ce(void); // SET 1, (HL) | ||
494 | void opcode_cb_cf(void); // SET 1, A | ||
495 | void opcode_cb_d0(void); // SET 2, B | ||
496 | void opcode_cb_d1(void); // SET 2, C | ||
497 | void opcode_cb_d2(void); // SET 2, D | ||
498 | void opcode_cb_d3(void); // SET 2, E | ||
499 | void opcode_cb_d4(void); // SET 2, H | ||
500 | void opcode_cb_d5(void); // SET 2, L | ||
501 | void opcode_cb_d6(void); // SET 2, (HL) | ||
502 | void opcode_cb_d7(void); // SET 2, A | ||
503 | void opcode_cb_d8(void); // SET 3, B | ||
504 | void opcode_cb_d9(void); // SET 3, C | ||
505 | void opcode_cb_da(void); // SET 3, D | ||
506 | void opcode_cb_db(void); // SET 3, E | ||
507 | void opcode_cb_dc(void); // SET 3, H | ||
508 | void opcode_cb_dd(void); // SET 3, L | ||
509 | void opcode_cb_de(void); // SET 3, (HL) | ||
510 | void opcode_cb_df(void); // SET 3, A | ||
511 | void opcode_cb_e0(void); // SET 4, B | ||
512 | void opcode_cb_e1(void); // SET 4, C | ||
513 | void opcode_cb_e2(void); // SET 4, D | ||
514 | void opcode_cb_e3(void); // SET 4, E | ||
515 | void opcode_cb_e4(void); // SET 4, H | ||
516 | void opcode_cb_e5(void); // SET 4, L | ||
517 | void opcode_cb_e6(void); // SET 4, (HL) | ||
518 | void opcode_cb_e7(void); // SET 4, A | ||
519 | void opcode_cb_e8(void); // SET 5, B | ||
520 | void opcode_cb_e9(void); // SET 5, C | ||
521 | void opcode_cb_ea(void); // SET 5, D | ||
522 | void opcode_cb_eb(void); // SET 5, E | ||
523 | void opcode_cb_ec(void); // SET 5, H | ||
524 | void opcode_cb_ed(void); // SET 5, L | ||
525 | void opcode_cb_ee(void); // SET 5, (HL) | ||
526 | void opcode_cb_ef(void); // SET 5, A | ||
527 | void opcode_cb_f0(void); // SET 6, B | ||
528 | void opcode_cb_f1(void); // SET 6, C | ||
529 | void opcode_cb_f2(void); // SET 6, D | ||
530 | void opcode_cb_f3(void); // SET 6, E | ||
531 | void opcode_cb_f4(void); // SET 6, H | ||
532 | void opcode_cb_f5(void); // SET 6, L | ||
533 | void opcode_cb_f6(void); // SET 6, (HL) | ||
534 | void opcode_cb_f7(void); // SET 6, A | ||
535 | void opcode_cb_f8(void); // SET 7, B | ||
536 | void opcode_cb_f9(void); // SET 7, C | ||
537 | void opcode_cb_fa(void); // SET 7, D | ||
538 | void opcode_cb_fb(void); // SET 7, E | ||
539 | void opcode_cb_fc(void); // SET 7, H | ||
540 | void opcode_cb_fd(void); // SET 7, L | ||
541 | void opcode_cb_fe(void); // SET 7, (HL) | ||
542 | void opcode_cb_ff(void); // SET 7, A | ||
543 | |||
544 | // Handlers for the 0xED prefix | ||
545 | void opcode_ed_40(void); // IN B, (C) | ||
546 | void opcode_ed_41(void); // OUT (C), B | ||
547 | void opcode_ed_42(void); // SBC HL, BC | ||
548 | void opcode_ed_43(void); // LD (nn), BC | ||
549 | void opcode_ed_44(void); // NEG | ||
550 | void opcode_ed_45(void); // RETN | ||
551 | void opcode_ed_46(void); // IM 0 | ||
552 | void opcode_ed_47(void); // LD I, A | ||
553 | void opcode_ed_48(void); // IN C, (C) | ||
554 | void opcode_ed_49(void); // OUT (C), C | ||
555 | void opcode_ed_4a(void); // ADC HL, BC | ||
556 | void opcode_ed_4b(void); // LD BC, (nn) | ||
557 | void opcode_ed_4c(void); // NEG [undocumented] | ||
558 | void opcode_ed_4d(void); // RETI | ||
559 | void opcode_ed_4e(void); // IM 0/1 [undocumented] | ||
560 | void opcode_ed_4f(void); // LD R, A | ||
561 | void opcode_ed_50(void); // IN D, (C) | ||
562 | void opcode_ed_51(void); // OUT (C), D | ||
563 | void opcode_ed_52(void); // SBC HL, DE | ||
564 | void opcode_ed_53(void); // LD (nn), DE | ||
565 | void opcode_ed_54(void); // NEG [undocumented] | ||
566 | void opcode_ed_55(void); // RETN [undocumented] | ||
567 | void opcode_ed_56(void); // IM 1 | ||
568 | void opcode_ed_57(void); // LD A, I | ||
569 | void opcode_ed_58(void); // IN E, (C) | ||
570 | void opcode_ed_59(void); // OUT (C), E | ||
571 | void opcode_ed_5a(void); // ADC HL, DE | ||
572 | void opcode_ed_5b(void); // LD DE, (nn) | ||
573 | void opcode_ed_5c(void); // NEG [undocumented] | ||
574 | void opcode_ed_5d(void); // RETN [undocumented] | ||
575 | void opcode_ed_5e(void); // IM 2 | ||
576 | void opcode_ed_5f(void); // LD A, R | ||
577 | void opcode_ed_60(void); // IN H, (C) | ||
578 | void opcode_ed_61(void); // OUT (C), H | ||
579 | void opcode_ed_62(void); // SBC HL, HL | ||
580 | void opcode_ed_63(void); // LD (nn), HL | ||
581 | void opcode_ed_64(void); // NEG [undocumented] | ||
582 | void opcode_ed_65(void); // RETN [undocumented] | ||
583 | void opcode_ed_66(void); // IM 0 [undocumented] | ||
584 | void opcode_ed_67(void); // RRD | ||
585 | void opcode_ed_68(void); // IN L, (C) | ||
586 | void opcode_ed_69(void); // OUT (C), L | ||
587 | void opcode_ed_6a(void); // ADC HL, HL | ||
588 | void opcode_ed_6b(void); // LD HL, (nn) | ||
589 | void opcode_ed_6c(void); // NEG [undocumented] | ||
590 | void opcode_ed_6d(void); // RETN [undocumented] | ||
591 | void opcode_ed_6e(void); // IM 0/1 [undocumented] | ||
592 | void opcode_ed_6f(void); // RLD | ||
593 | void opcode_ed_70(void); // IN (C)/IN F, (C) [undocumented] | ||
594 | void opcode_ed_71(void); // OUT (C), 0 [undocumented] | ||
595 | void opcode_ed_72(void); // SBC HL, SP | ||
596 | void opcode_ed_73(void); // LD (nn), SP | ||
597 | void opcode_ed_74(void); // NEG [undocumented] | ||
598 | void opcode_ed_75(void); // RETN [undocumented] | ||
599 | void opcode_ed_76(void); // IM 1 [undocumented] | ||
600 | void opcode_ed_78(void); // IN A, (C) | ||
601 | void opcode_ed_79(void); // OUT (C), A | ||
602 | void opcode_ed_7a(void); // ADC HL, SP | ||
603 | void opcode_ed_7b(void); // nLD SP, (nn) | ||
604 | void opcode_ed_7c(void); // NEG [undocumented] | ||
605 | void opcode_ed_7d(void); // RETN [undocumented] | ||
606 | void opcode_ed_7e(void); // IM 2 [undocumented] | ||
607 | void opcode_ed_a0(void); // LDI | ||
608 | void opcode_ed_a1(void); // CPI | ||
609 | void opcode_ed_a2(void); // INI | ||
610 | void opcode_ed_a3(void); // OUTI | ||
611 | void opcode_ed_a8(void); // LDD | ||
612 | void opcode_ed_a9(void); // CPD | ||
613 | void opcode_ed_aa(void); // IND | ||
614 | void opcode_ed_ab(void); // OUTD | ||
615 | void opcode_ed_b0(void); // LDIR | ||
616 | void opcode_ed_b1(void); // CPIR | ||
617 | void opcode_ed_b2(void); // INIR | ||
618 | void opcode_ed_b3(void); // OTIR | ||
619 | void opcode_ed_b8(void); // LDDR | ||
620 | void opcode_ed_b9(void); // CPDR | ||
621 | void opcode_ed_ba(void); // INDR | ||
622 | void opcode_ed_bb(void); // OTDR | ||
623 | |||
624 | // Handlers for the 0xDD prefix (IX) | ||
625 | void opcode_dd_09(void); // ADD IX, BC | ||
626 | void opcode_dd_19(void); // ADD IX, DE | ||
627 | void opcode_dd_21(void); // LD IX, nn | ||
628 | void opcode_dd_22(void); // LD (nn), IX | ||
629 | void opcode_dd_23(void); // INC IX | ||
630 | void opcode_dd_24(void); // INC IXH [undocumented] | ||
631 | void opcode_dd_25(void); // DEC IXH [undocumented] | ||
632 | void opcode_dd_26(void); // LD IXH, n [undocumented] | ||
633 | void opcode_dd_29(void); // ADD IX, IX | ||
634 | void opcode_dd_2a(void); // LD IX, (nn) | ||
635 | void opcode_dd_2b(void); // DEC IX | ||
636 | void opcode_dd_2c(void); // INC IXL [undocumented] | ||
637 | void opcode_dd_2d(void); // DEC IXL [undocumented] | ||
638 | void opcode_dd_2e(void); // LD IXL, n [undocumented] | ||
639 | void opcode_dd_34(void); // INC (IX + d) | ||
640 | void opcode_dd_35(void); // DEC (IX + d) | ||
641 | void opcode_dd_36(void); // LD (IX + d), n | ||
642 | void opcode_dd_39(void); // ADD IX, SP | ||
643 | void opcode_dd_44(void); // LD B, IXH [undocumented] | ||
644 | void opcode_dd_45(void); // LD B, IXL [undocumented] | ||
645 | void opcode_dd_46(void); // LD B, (IX + d) | ||
646 | void opcode_dd_4c(void); // LD C, IXH [undocumented] | ||
647 | void opcode_dd_4d(void); // LD C, IXL [undocumented] | ||
648 | void opcode_dd_4e(void); // LD C, (IX + d) | ||
649 | void opcode_dd_54(void); // LD D, IXH [undocumented] | ||
650 | void opcode_dd_55(void); // LD D, IXL [undocumented] | ||
651 | void opcode_dd_56(void); // LD D, (IX + d) | ||
652 | void opcode_dd_5c(void); // LD E, IXH [undocumented] | ||
653 | void opcode_dd_5d(void); // LD E, IXL [undocumented] | ||
654 | void opcode_dd_5e(void); // LD E, (IX + d) | ||
655 | void opcode_dd_60(void); // LD IXH, B [undocumented] | ||
656 | void opcode_dd_61(void); // LD IXH, C [undocumented] | ||
657 | void opcode_dd_62(void); // LD IXH, D [undocumented] | ||
658 | void opcode_dd_63(void); // LD IXH, E [undocumented] | ||
659 | void opcode_dd_64(void); // LD IXH, IXH [undocumented] | ||
660 | void opcode_dd_65(void); // LD IXH, IXL [undocumented] | ||
661 | void opcode_dd_66(void); // LD H, (IX + d) | ||
662 | void opcode_dd_67(void); // LD IXH, A [undocumented] | ||
663 | void opcode_dd_68(void); // LD IXL, B [undocumented] | ||
664 | void opcode_dd_69(void); // LD IXL, C [undocumented] | ||
665 | void opcode_dd_6a(void); // LD IXL, D [undocumented] | ||
666 | void opcode_dd_6b(void); // LD IXL, E [undocumented] | ||
667 | void opcode_dd_6c(void); // LD IXL, IXH [undocumented] | ||
668 | void opcode_dd_6d(void); // LD IXL, IXL [undocumented] | ||
669 | void opcode_dd_6e(void); // LD L, (IX + d) | ||
670 | void opcode_dd_6f(void); // LD IXL, A [undocumented] | ||
671 | void opcode_dd_70(void); // LD (IX + d), B | ||
672 | void opcode_dd_71(void); // LD (IX + d), C | ||
673 | void opcode_dd_72(void); // LD (IX + d), D | ||
674 | void opcode_dd_73(void); // LD (IX + d), E | ||
675 | void opcode_dd_74(void); // LD (IX + d), H | ||
676 | void opcode_dd_75(void); // LD (IX + d), L | ||
677 | void opcode_dd_77(void); // LD (IX + d), A | ||
678 | void opcode_dd_7c(void); // LD A, IXH [undocumented] | ||
679 | void opcode_dd_7d(void); // LD A, IXL [undocumented] | ||
680 | void opcode_dd_7e(void); // LD A, (IX + d) | ||
681 | void opcode_dd_84(void); // ADD A, IXH [undocumented] | ||
682 | void opcode_dd_85(void); // ADD A, IXL [undocumented] | ||
683 | void opcode_dd_86(void); // ADD A, (IX + d) | ||
684 | void opcode_dd_8c(void); // ADC A, IXH [undocumented] | ||
685 | void opcode_dd_8d(void); // ADC A, IXL [undocumented] | ||
686 | void opcode_dd_8e(void); // ADC A, (IX + d) | ||
687 | void opcode_dd_94(void); // SUB IXH [undocumented] | ||
688 | void opcode_dd_95(void); // SUB IXL [undocumented] | ||
689 | void opcode_dd_96(void); // SUB (IX + d) | ||
690 | void opcode_dd_9c(void); // SBC A, IXH [undocumented] | ||
691 | void opcode_dd_9d(void); // SBC A, IXL [undocumented] | ||
692 | void opcode_dd_9e(void); // SBC A, (IX + d) | ||
693 | void opcode_dd_a4(void); // AND IXH [undocumented] | ||
694 | void opcode_dd_a5(void); // AND IXL [undocumented] | ||
695 | void opcode_dd_a6(void); // AND (IX + d) | ||
696 | void opcode_dd_ac(void); // XOR IXH [undocumented] | ||
697 | void opcode_dd_ad(void); // XOR IXL [undocumented] | ||
698 | void opcode_dd_ae(void); // XOR (IX + d) | ||
699 | void opcode_dd_b4(void); // OR IXH [undocumented] | ||
700 | void opcode_dd_b5(void); // OR IXL [undocumented] | ||
701 | void opcode_dd_b6(void); // OR (IX + d) | ||
702 | void opcode_dd_bc(void); // CP IXH [undocumented] | ||
703 | void opcode_dd_bd(void); // CP IXL [undocumented] | ||
704 | void opcode_dd_be(void); // CP (IX + d) | ||
705 | void opcode_dd_cb(void); // | ||
706 | void opcode_dd_e1(void); // POP IX | ||
707 | void opcode_dd_e3(void); // EX (SP), IX | ||
708 | void opcode_dd_e5(void); // PUSH IX | ||
709 | void opcode_dd_e9(void); // JP (IX) | ||
710 | void opcode_dd_f9(void); // LD SP, IX | ||
711 | |||
712 | // Handlers for the 0xFD prefix (IY) | ||
713 | void opcode_fd_09(void); // ADD IY, BC | ||
714 | void opcode_fd_19(void); // ADD IY, DE | ||
715 | void opcode_fd_21(void); // LD IY, nn | ||
716 | void opcode_fd_22(void); // LD (nn), IY | ||
717 | void opcode_fd_23(void); // INC IY | ||
718 | void opcode_fd_24(void); // INC IYH [undocumented] | ||
719 | void opcode_fd_25(void); // DEC IYH [undocumented] | ||
720 | void opcode_fd_26(void); // LD IYH, n [undocumented] | ||
721 | void opcode_fd_29(void); // ADD IY, IY | ||
722 | void opcode_fd_2a(void); // LD IY, (nn) | ||
723 | void opcode_fd_2b(void); // DEC IY | ||
724 | void opcode_fd_2c(void); // INC IYL [undocumented] | ||
725 | void opcode_fd_2d(void); // DEC IYL [undocumented] | ||
726 | void opcode_fd_2e(void); // LD IYL, n [undocumented] | ||
727 | void opcode_fd_34(void); // INC (IY + d) | ||
728 | void opcode_fd_35(void); // DEC (IY + d) | ||
729 | void opcode_fd_36(void); // LD (IY + d), n | ||
730 | void opcode_fd_39(void); // ADD IY, SP | ||
731 | void opcode_fd_44(void); // LD B, IYH [undocumented] | ||
732 | void opcode_fd_45(void); // LD B, IYL [undocumented] | ||
733 | void opcode_fd_46(void); // LD B, (IY + d) | ||
734 | void opcode_fd_4c(void); // LD C, IYH [undocumented] | ||
735 | void opcode_fd_4d(void); // LD C, IYL [undocumented] | ||
736 | void opcode_fd_4e(void); // LD C, (IY + d) | ||
737 | void opcode_fd_54(void); // LD D, IYH [undocumented] | ||
738 | void opcode_fd_55(void); // LD D, IYL [undocumented] | ||
739 | void opcode_fd_56(void); // LD D, (IY + d) | ||
740 | void opcode_fd_5c(void); // LD E, IYH [undocumented] | ||
741 | void opcode_fd_5d(void); // LD E, IYL [undocumented] | ||
742 | void opcode_fd_5e(void); // LD E, (IY + d) | ||
743 | void opcode_fd_60(void); // LD IYH, B [undocumented] | ||
744 | void opcode_fd_61(void); // LD IYH, C [undocumented] | ||
745 | void opcode_fd_62(void); // LD IYH, D [undocumented] | ||
746 | void opcode_fd_63(void); // LD IYH, E [undocumented] | ||
747 | void opcode_fd_64(void); // LD IYH, IYH [undocumented] | ||
748 | void opcode_fd_65(void); // LD IYH, IYL [undocumented] | ||
749 | void opcode_fd_66(void); // LD H, (IY + d) | ||
750 | void opcode_fd_67(void); // LD IYH, A [undocumented] | ||
751 | void opcode_fd_68(void); // LD IYL, B [undocumented] | ||
752 | void opcode_fd_69(void); // LD IYL, C [undocumented] | ||
753 | void opcode_fd_6a(void); // LD IYL, D [undocumented] | ||
754 | void opcode_fd_6b(void); // LD IYL, E [undocumented] | ||
755 | void opcode_fd_6c(void); // LD IYL, IYH [undocumented] | ||
756 | void opcode_fd_6d(void); // LD IYL, IYL [undocumented] | ||
757 | void opcode_fd_6e(void); // LD L, (IY + d) | ||
758 | void opcode_fd_6f(void); // LD IYL, A [undocumented] | ||
759 | void opcode_fd_70(void); // LD (IY + d), B | ||
760 | void opcode_fd_71(void); // LD (IY + d), C | ||
761 | void opcode_fd_72(void); // LD (IY + d), D | ||
762 | void opcode_fd_73(void); // LD (IY + d), E | ||
763 | void opcode_fd_74(void); // LD (IY + d), H | ||
764 | void opcode_fd_75(void); // LD (IY + d), L | ||
765 | void opcode_fd_77(void); // LD (IY + d), A | ||
766 | void opcode_fd_7c(void); // LD A, IYH [undocumented] | ||
767 | void opcode_fd_7d(void); // LD A, IYL [undocumented] | ||
768 | void opcode_fd_7e(void); // LD A, (IY + d) | ||
769 | void opcode_fd_84(void); // ADD A, IYH [undocumented] | ||
770 | void opcode_fd_85(void); // ADD A, IYL [undocumented] | ||
771 | void opcode_fd_86(void); // ADD A, (IY + d) | ||
772 | void opcode_fd_8c(void); // ADC A, IYH [undocumented] | ||
773 | void opcode_fd_8d(void); // ADC A, IYL [undocumented] | ||
774 | void opcode_fd_8e(void); // ADC A, (IY + d) | ||
775 | void opcode_fd_94(void); // SUB IYH [undocumented] | ||
776 | void opcode_fd_95(void); // SUB IYL [undocumented] | ||
777 | void opcode_fd_96(void); // SUB (IY + d) | ||
778 | void opcode_fd_9c(void); // SBC A, IYH [undocumented] | ||
779 | void opcode_fd_9d(void); // SBC A, IYL [undocumented] | ||
780 | void opcode_fd_9e(void); // SBC A, (IY + d) | ||
781 | void opcode_fd_a4(void); // AND IYH [undocumented] | ||
782 | void opcode_fd_a5(void); // AND IYL [undocumented] | ||
783 | void opcode_fd_a6(void); // AND (IY + d) | ||
784 | void opcode_fd_ac(void); // XOR IYH [undocumented] | ||
785 | void opcode_fd_ad(void); // XOR IYL [undocumented] | ||
786 | void opcode_fd_ae(void); // XOR (IY + d) | ||
787 | void opcode_fd_b4(void); // OR IYH [undocumented] | ||
788 | void opcode_fd_b5(void); // OR IYL [undocumented] | ||
789 | void opcode_fd_b6(void); // OR (IY + d) | ||
790 | void opcode_fd_bc(void); // CP IYH [undocumented] | ||
791 | void opcode_fd_bd(void); // CP IYL [undocumented] | ||
792 | void opcode_fd_be(void); // CP (IY + d) | ||
793 | void opcode_fd_cb(void); // | ||
794 | void opcode_fd_e1(void); // POP IY | ||
795 | void opcode_fd_e3(void); // EX (SP), IY | ||
796 | void opcode_fd_e5(void); // PUSH IY | ||
797 | void opcode_fd_e9(void); // JP (IY) | ||
798 | void opcode_fd_f9(void); // LD SP, IY | ||
799 | |||
800 | // Handlers for 0xDDCB and 0xFDCB prefixes | ||
801 | void opcode_xycb_00( unsigned ); // LD B, RLC (IX + d) [undocumented] | ||
802 | void opcode_xycb_01( unsigned ); // LD C, RLC (IX + d) [undocumented] | ||
803 | void opcode_xycb_02( unsigned ); // LD D, RLC (IX + d) [undocumented] | ||
804 | void opcode_xycb_03( unsigned ); // LD E, RLC (IX + d) [undocumented] | ||
805 | void opcode_xycb_04( unsigned ); // LD H, RLC (IX + d) [undocumented] | ||
806 | void opcode_xycb_05( unsigned ); // LD L, RLC (IX + d) [undocumented] | ||
807 | void opcode_xycb_06( unsigned ); // RLC (IX + d) | ||
808 | void opcode_xycb_07( unsigned ); // LD A, RLC (IX + d) [undocumented] | ||
809 | void opcode_xycb_08( unsigned ); // LD B, RRC (IX + d) [undocumented] | ||
810 | void opcode_xycb_09( unsigned ); // LD C, RRC (IX + d) [undocumented] | ||
811 | void opcode_xycb_0a( unsigned ); // LD D, RRC (IX + d) [undocumented] | ||
812 | void opcode_xycb_0b( unsigned ); // LD E, RRC (IX + d) [undocumented] | ||
813 | void opcode_xycb_0c( unsigned ); // LD H, RRC (IX + d) [undocumented] | ||
814 | void opcode_xycb_0d( unsigned ); // LD L, RRC (IX + d) [undocumented] | ||
815 | void opcode_xycb_0e( unsigned ); // RRC (IX + d) | ||
816 | void opcode_xycb_0f( unsigned ); // LD A, RRC (IX + d) [undocumented] | ||
817 | void opcode_xycb_10( unsigned ); // LD B, RL (IX + d) [undocumented] | ||
818 | void opcode_xycb_11( unsigned ); // LD C, RL (IX + d) [undocumented] | ||
819 | void opcode_xycb_12( unsigned ); // LD D, RL (IX + d) [undocumented] | ||
820 | void opcode_xycb_13( unsigned ); // LD E, RL (IX + d) [undocumented] | ||
821 | void opcode_xycb_14( unsigned ); // LD H, RL (IX + d) [undocumented] | ||
822 | void opcode_xycb_15( unsigned ); // LD L, RL (IX + d) [undocumented] | ||
823 | void opcode_xycb_16( unsigned ); // RL (IX + d) | ||
824 | void opcode_xycb_17( unsigned ); // LD A, RL (IX + d) [undocumented] | ||
825 | void opcode_xycb_18( unsigned ); // LD B, RR (IX + d) [undocumented] | ||
826 | void opcode_xycb_19( unsigned ); // LD C, RR (IX + d) [undocumented] | ||
827 | void opcode_xycb_1a( unsigned ); // LD D, RR (IX + d) [undocumented] | ||
828 | void opcode_xycb_1b( unsigned ); // LD E, RR (IX + d) [undocumented] | ||
829 | void opcode_xycb_1c( unsigned ); // LD H, RR (IX + d) [undocumented] | ||
830 | void opcode_xycb_1d( unsigned ); // LD L, RR (IX + d) [undocumented] | ||
831 | void opcode_xycb_1e( unsigned ); // RR (IX + d) | ||
832 | void opcode_xycb_1f( unsigned ); // LD A, RR (IX + d) [undocumented] | ||
833 | void opcode_xycb_20( unsigned ); // LD B, SLA (IX + d) [undocumented] | ||
834 | void opcode_xycb_21( unsigned ); // LD C, SLA (IX + d) [undocumented] | ||
835 | void opcode_xycb_22( unsigned ); // LD D, SLA (IX + d) [undocumented] | ||
836 | void opcode_xycb_23( unsigned ); // LD E, SLA (IX + d) [undocumented] | ||
837 | void opcode_xycb_24( unsigned ); // LD H, SLA (IX + d) [undocumented] | ||
838 | void opcode_xycb_25( unsigned ); // LD L, SLA (IX + d) [undocumented] | ||
839 | void opcode_xycb_26( unsigned ); // SLA (IX + d) | ||
840 | void opcode_xycb_27( unsigned ); // LD A, SLA (IX + d) [undocumented] | ||
841 | void opcode_xycb_28( unsigned ); // LD B, SRA (IX + d) [undocumented] | ||
842 | void opcode_xycb_29( unsigned ); // LD C, SRA (IX + d) [undocumented] | ||
843 | void opcode_xycb_2a( unsigned ); // LD D, SRA (IX + d) [undocumented] | ||
844 | void opcode_xycb_2b( unsigned ); // LD E, SRA (IX + d) [undocumented] | ||
845 | void opcode_xycb_2c( unsigned ); // LD H, SRA (IX + d) [undocumented] | ||
846 | void opcode_xycb_2d( unsigned ); // LD L, SRA (IX + d) [undocumented] | ||
847 | void opcode_xycb_2e( unsigned ); // SRA (IX + d) | ||
848 | void opcode_xycb_2f( unsigned ); // LD A, SRA (IX + d) [undocumented] | ||
849 | void opcode_xycb_30( unsigned ); // LD B, SLL (IX + d) [undocumented] | ||
850 | void opcode_xycb_31( unsigned ); // LD C, SLL (IX + d) [undocumented] | ||
851 | void opcode_xycb_32( unsigned ); // LD D, SLL (IX + d) [undocumented] | ||
852 | void opcode_xycb_33( unsigned ); // LD E, SLL (IX + d) [undocumented] | ||
853 | void opcode_xycb_34( unsigned ); // LD H, SLL (IX + d) [undocumented] | ||
854 | void opcode_xycb_35( unsigned ); // LD L, SLL (IX + d) [undocumented] | ||
855 | void opcode_xycb_36( unsigned ); // SLL (IX + d) [undocumented] | ||
856 | void opcode_xycb_37( unsigned ); // LD A, SLL (IX + d) [undocumented] | ||
857 | void opcode_xycb_38( unsigned ); // LD B, SRL (IX + d) [undocumented] | ||
858 | void opcode_xycb_39( unsigned ); // LD C, SRL (IX + d) [undocumented] | ||
859 | void opcode_xycb_3a( unsigned ); // LD D, SRL (IX + d) [undocumented] | ||
860 | void opcode_xycb_3b( unsigned ); // LD E, SRL (IX + d) [undocumented] | ||
861 | void opcode_xycb_3c( unsigned ); // LD H, SRL (IX + d) [undocumented] | ||
862 | void opcode_xycb_3d( unsigned ); // LD L, SRL (IX + d) [undocumented] | ||
863 | void opcode_xycb_3e( unsigned ); // SRL (IX + d) | ||
864 | void opcode_xycb_3f( unsigned ); // LD A, SRL (IX + d) [undocumented] | ||
865 | void opcode_xycb_40( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
866 | void opcode_xycb_41( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
867 | void opcode_xycb_42( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
868 | void opcode_xycb_43( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
869 | void opcode_xycb_44( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
870 | void opcode_xycb_45( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
871 | void opcode_xycb_46( unsigned ); // BIT 0, (IX + d) | ||
872 | void opcode_xycb_47( unsigned ); // BIT 0, (IX + d) [undocumented] | ||
873 | void opcode_xycb_48( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
874 | void opcode_xycb_49( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
875 | void opcode_xycb_4a( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
876 | void opcode_xycb_4b( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
877 | void opcode_xycb_4c( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
878 | void opcode_xycb_4d( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
879 | void opcode_xycb_4e( unsigned ); // BIT 1, (IX + d) | ||
880 | void opcode_xycb_4f( unsigned ); // BIT 1, (IX + d) [undocumented] | ||
881 | void opcode_xycb_50( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
882 | void opcode_xycb_51( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
883 | void opcode_xycb_52( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
884 | void opcode_xycb_53( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
885 | void opcode_xycb_54( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
886 | void opcode_xycb_55( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
887 | void opcode_xycb_56( unsigned ); // BIT 2, (IX + d) | ||
888 | void opcode_xycb_57( unsigned ); // BIT 2, (IX + d) [undocumented] | ||
889 | void opcode_xycb_58( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
890 | void opcode_xycb_59( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
891 | void opcode_xycb_5a( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
892 | void opcode_xycb_5b( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
893 | void opcode_xycb_5c( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
894 | void opcode_xycb_5d( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
895 | void opcode_xycb_5e( unsigned ); // BIT 3, (IX + d) | ||
896 | void opcode_xycb_5f( unsigned ); // BIT 3, (IX + d) [undocumented] | ||
897 | void opcode_xycb_60( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
898 | void opcode_xycb_61( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
899 | void opcode_xycb_62( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
900 | void opcode_xycb_63( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
901 | void opcode_xycb_64( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
902 | void opcode_xycb_65( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
903 | void opcode_xycb_66( unsigned ); // BIT 4, (IX + d) | ||
904 | void opcode_xycb_67( unsigned ); // BIT 4, (IX + d) [undocumented] | ||
905 | void opcode_xycb_68( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
906 | void opcode_xycb_69( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
907 | void opcode_xycb_6a( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
908 | void opcode_xycb_6b( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
909 | void opcode_xycb_6c( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
910 | void opcode_xycb_6d( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
911 | void opcode_xycb_6e( unsigned ); // BIT 5, (IX + d) | ||
912 | void opcode_xycb_6f( unsigned ); // BIT 5, (IX + d) [undocumented] | ||
913 | void opcode_xycb_70( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
914 | void opcode_xycb_71( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
915 | void opcode_xycb_72( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
916 | void opcode_xycb_73( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
917 | void opcode_xycb_74( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
918 | void opcode_xycb_75( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
919 | void opcode_xycb_76( unsigned ); // BIT 6, (IX + d) | ||
920 | void opcode_xycb_77( unsigned ); // BIT 6, (IX + d) [undocumented] | ||
921 | void opcode_xycb_78( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
922 | void opcode_xycb_79( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
923 | void opcode_xycb_7a( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
924 | void opcode_xycb_7b( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
925 | void opcode_xycb_7c( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
926 | void opcode_xycb_7d( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
927 | void opcode_xycb_7e( unsigned ); // BIT 7, (IX + d) | ||
928 | void opcode_xycb_7f( unsigned ); // BIT 7, (IX + d) [undocumented] | ||
929 | void opcode_xycb_80( unsigned ); // LD B, RES 0, (IX + d) [undocumented] | ||
930 | void opcode_xycb_81( unsigned ); // LD C, RES 0, (IX + d) [undocumented] | ||
931 | void opcode_xycb_82( unsigned ); // LD D, RES 0, (IX + d) [undocumented] | ||
932 | void opcode_xycb_83( unsigned ); // LD E, RES 0, (IX + d) [undocumented] | ||
933 | void opcode_xycb_84( unsigned ); // LD H, RES 0, (IX + d) [undocumented] | ||
934 | void opcode_xycb_85( unsigned ); // LD L, RES 0, (IX + d) [undocumented] | ||
935 | void opcode_xycb_86( unsigned ); // RES 0, (IX + d) | ||
936 | void opcode_xycb_87( unsigned ); // LD A, RES 0, (IX + d) [undocumented] | ||
937 | void opcode_xycb_88( unsigned ); // LD B, RES 1, (IX + d) [undocumented] | ||
938 | void opcode_xycb_89( unsigned ); // LD C, RES 1, (IX + d) [undocumented] | ||
939 | void opcode_xycb_8a( unsigned ); // LD D, RES 1, (IX + d) [undocumented] | ||
940 | void opcode_xycb_8b( unsigned ); // LD E, RES 1, (IX + d) [undocumented] | ||
941 | void opcode_xycb_8c( unsigned ); // LD H, RES 1, (IX + d) [undocumented] | ||
942 | void opcode_xycb_8d( unsigned ); // LD L, RES 1, (IX + d) [undocumented] | ||
943 | void opcode_xycb_8e( unsigned ); // RES 1, (IX + d) | ||
944 | void opcode_xycb_8f( unsigned ); // LD A, RES 1, (IX + d) [undocumented] | ||
945 | void opcode_xycb_90( unsigned ); // LD B, RES 2, (IX + d) [undocumented] | ||
946 | void opcode_xycb_91( unsigned ); // LD C, RES 2, (IX + d) [undocumented] | ||
947 | void opcode_xycb_92( unsigned ); // LD D, RES 2, (IX + d) [undocumented] | ||
948 | void opcode_xycb_93( unsigned ); // LD E, RES 2, (IX + d) [undocumented] | ||
949 | void opcode_xycb_94( unsigned ); // LD H, RES 2, (IX + d) [undocumented] | ||
950 | void opcode_xycb_95( unsigned ); // LD L, RES 2, (IX + d) [undocumented] | ||
951 | void opcode_xycb_96( unsigned ); // RES 2, (IX + d) | ||
952 | void opcode_xycb_97( unsigned ); // LD A, RES 2, (IX + d) [undocumented] | ||
953 | void opcode_xycb_98( unsigned ); // LD B, RES 3, (IX + d) [undocumented] | ||
954 | void opcode_xycb_99( unsigned ); // LD C, RES 3, (IX + d) [undocumented] | ||
955 | void opcode_xycb_9a( unsigned ); // LD D, RES 3, (IX + d) [undocumented] | ||
956 | void opcode_xycb_9b( unsigned ); // LD E, RES 3, (IX + d) [undocumented] | ||
957 | void opcode_xycb_9c( unsigned ); // LD H, RES 3, (IX + d) [undocumented] | ||
958 | void opcode_xycb_9d( unsigned ); // LD L, RES 3, (IX + d) [undocumented] | ||
959 | void opcode_xycb_9e( unsigned ); // RES 3, (IX + d) | ||
960 | void opcode_xycb_9f( unsigned ); // LD A, RES 3, (IX + d) [undocumented] | ||
961 | void opcode_xycb_a0( unsigned ); // LD B, RES 4, (IX + d) [undocumented] | ||
962 | void opcode_xycb_a1( unsigned ); // LD C, RES 4, (IX + d) [undocumented] | ||
963 | void opcode_xycb_a2( unsigned ); // LD D, RES 4, (IX + d) [undocumented] | ||
964 | void opcode_xycb_a3( unsigned ); // LD E, RES 4, (IX + d) [undocumented] | ||
965 | void opcode_xycb_a4( unsigned ); // LD H, RES 4, (IX + d) [undocumented] | ||
966 | void opcode_xycb_a5( unsigned ); // LD L, RES 4, (IX + d) [undocumented] | ||
967 | void opcode_xycb_a6( unsigned ); // RES 4, (IX + d) | ||
968 | void opcode_xycb_a7( unsigned ); // LD A, RES 4, (IX + d) [undocumented] | ||
969 | void opcode_xycb_a8( unsigned ); // LD B, RES 5, (IX + d) [undocumented] | ||
970 | void opcode_xycb_a9( unsigned ); // LD C, RES 5, (IX + d) [undocumented] | ||
971 | void opcode_xycb_aa( unsigned ); // LD D, RES 5, (IX + d) [undocumented] | ||
972 | void opcode_xycb_ab( unsigned ); // LD E, RES 5, (IX + d) [undocumented] | ||
973 | void opcode_xycb_ac( unsigned ); // LD H, RES 5, (IX + d) [undocumented] | ||
974 | void opcode_xycb_ad( unsigned ); // LD L, RES 5, (IX + d) [undocumented] | ||
975 | void opcode_xycb_ae( unsigned ); // RES 5, (IX + d) | ||
976 | void opcode_xycb_af( unsigned ); // LD A, RES 5, (IX + d) [undocumented] | ||
977 | void opcode_xycb_b0( unsigned ); // LD B, RES 6, (IX + d) [undocumented] | ||
978 | void opcode_xycb_b1( unsigned ); // LD C, RES 6, (IX + d) [undocumented] | ||
979 | void opcode_xycb_b2( unsigned ); // LD D, RES 6, (IX + d) [undocumented] | ||
980 | void opcode_xycb_b3( unsigned ); // LD E, RES 6, (IX + d) [undocumented] | ||
981 | void opcode_xycb_b4( unsigned ); // LD H, RES 6, (IX + d) [undocumented] | ||
982 | void opcode_xycb_b5( unsigned ); // LD L, RES 6, (IX + d) [undocumented] | ||
983 | void opcode_xycb_b6( unsigned ); // RES 6, (IX + d) | ||
984 | void opcode_xycb_b7( unsigned ); // LD A, RES 6, (IX + d) [undocumented] | ||
985 | void opcode_xycb_b8( unsigned ); // LD B, RES 7, (IX + d) [undocumented] | ||
986 | void opcode_xycb_b9( unsigned ); // LD C, RES 7, (IX + d) [undocumented] | ||
987 | void opcode_xycb_ba( unsigned ); // LD D, RES 7, (IX + d) [undocumented] | ||
988 | void opcode_xycb_bb( unsigned ); // LD E, RES 7, (IX + d) [undocumented] | ||
989 | void opcode_xycb_bc( unsigned ); // LD H, RES 7, (IX + d) [undocumented] | ||
990 | void opcode_xycb_bd( unsigned ); // LD L, RES 7, (IX + d) [undocumented] | ||
991 | void opcode_xycb_be( unsigned ); // RES 7, (IX + d) | ||
992 | void opcode_xycb_bf( unsigned ); // LD A, RES 7, (IX + d) [undocumented] | ||
993 | void opcode_xycb_c0( unsigned ); // LD B, SET 0, (IX + d) [undocumented] | ||
994 | void opcode_xycb_c1( unsigned ); // LD C, SET 0, (IX + d) [undocumented] | ||
995 | void opcode_xycb_c2( unsigned ); // LD D, SET 0, (IX + d) [undocumented] | ||
996 | void opcode_xycb_c3( unsigned ); // LD E, SET 0, (IX + d) [undocumented] | ||
997 | void opcode_xycb_c4( unsigned ); // LD H, SET 0, (IX + d) [undocumented] | ||
998 | void opcode_xycb_c5( unsigned ); // LD L, SET 0, (IX + d) [undocumented] | ||
999 | void opcode_xycb_c6( unsigned ); // SET 0, (IX + d) | ||
1000 | void opcode_xycb_c7( unsigned ); // LD A, SET 0, (IX + d) [undocumented] | ||
1001 | void opcode_xycb_c8( unsigned ); // LD B, SET 1, (IX + d) [undocumented] | ||
1002 | void opcode_xycb_c9( unsigned ); // LD C, SET 1, (IX + d) [undocumented] | ||
1003 | void opcode_xycb_ca( unsigned ); // LD D, SET 1, (IX + d) [undocumented] | ||
1004 | void opcode_xycb_cb( unsigned ); // LD E, SET 1, (IX + d) [undocumented] | ||
1005 | void opcode_xycb_cc( unsigned ); // LD H, SET 1, (IX + d) [undocumented] | ||
1006 | void opcode_xycb_cd( unsigned ); // LD L, SET 1, (IX + d) [undocumented] | ||
1007 | void opcode_xycb_ce( unsigned ); // SET 1, (IX + d) | ||
1008 | void opcode_xycb_cf( unsigned ); // LD A, SET 1, (IX + d) [undocumented] | ||
1009 | void opcode_xycb_d0( unsigned ); // LD B, SET 2, (IX + d) [undocumented] | ||
1010 | void opcode_xycb_d1( unsigned ); // LD C, SET 2, (IX + d) [undocumented] | ||
1011 | void opcode_xycb_d2( unsigned ); // LD D, SET 2, (IX + d) [undocumented] | ||
1012 | void opcode_xycb_d3( unsigned ); // LD E, SET 2, (IX + d) [undocumented] | ||
1013 | void opcode_xycb_d4( unsigned ); // LD H, SET 2, (IX + d) [undocumented] | ||
1014 | void opcode_xycb_d5( unsigned ); // LD L, SET 2, (IX + d) [undocumented] | ||
1015 | void opcode_xycb_d6( unsigned ); // SET 2, (IX + d) | ||
1016 | void opcode_xycb_d7( unsigned ); // LD A, SET 2, (IX + d) [undocumented] | ||
1017 | void opcode_xycb_d8( unsigned ); // LD B, SET 3, (IX + d) [undocumented] | ||
1018 | void opcode_xycb_d9( unsigned ); // LD C, SET 3, (IX + d) [undocumented] | ||
1019 | void opcode_xycb_da( unsigned ); // LD D, SET 3, (IX + d) [undocumented] | ||
1020 | void opcode_xycb_db( unsigned ); // LD E, SET 3, (IX + d) [undocumented] | ||
1021 | void opcode_xycb_dc( unsigned ); // LD H, SET 3, (IX + d) [undocumented] | ||
1022 | void opcode_xycb_dd( unsigned ); // LD L, SET 3, (IX + d) [undocumented] | ||
1023 | void opcode_xycb_de( unsigned ); // SET 3, (IX + d) | ||
1024 | void opcode_xycb_df( unsigned ); // LD A, SET 3, (IX + d) [undocumented] | ||
1025 | void opcode_xycb_e0( unsigned ); // LD B, SET 4, (IX + d) [undocumented] | ||
1026 | void opcode_xycb_e1( unsigned ); // LD C, SET 4, (IX + d) [undocumented] | ||
1027 | void opcode_xycb_e2( unsigned ); // LD D, SET 4, (IX + d) [undocumented] | ||
1028 | void opcode_xycb_e3( unsigned ); // LD E, SET 4, (IX + d) [undocumented] | ||
1029 | void opcode_xycb_e4( unsigned ); // LD H, SET 4, (IX + d) [undocumented] | ||
1030 | void opcode_xycb_e5( unsigned ); // LD L, SET 4, (IX + d) [undocumented] | ||
1031 | void opcode_xycb_e6( unsigned ); // SET 4, (IX + d) | ||
1032 | void opcode_xycb_e7( unsigned ); // LD A, SET 4, (IX + d) [undocumented] | ||
1033 | void opcode_xycb_e8( unsigned ); // LD B, SET 5, (IX + d) [undocumented] | ||
1034 | void opcode_xycb_e9( unsigned ); // LD C, SET 5, (IX + d) [undocumented] | ||
1035 | void opcode_xycb_ea( unsigned ); // LD D, SET 5, (IX + d) [undocumented] | ||
1036 | void opcode_xycb_eb( unsigned ); // LD E, SET 5, (IX + d) [undocumented] | ||
1037 | void opcode_xycb_ec( unsigned ); // LD H, SET 5, (IX + d) [undocumented] | ||
1038 | void opcode_xycb_ed( unsigned ); // LD L, SET 5, (IX + d) [undocumented] | ||
1039 | void opcode_xycb_ee( unsigned ); // SET 5, (IX + d) | ||
1040 | void opcode_xycb_ef( unsigned ); // LD A, SET 5, (IX + d) [undocumented] | ||
1041 | void opcode_xycb_f0( unsigned ); // LD B, SET 6, (IX + d) [undocumented] | ||
1042 | void opcode_xycb_f1( unsigned ); // LD C, SET 6, (IX + d) [undocumented] | ||
1043 | void opcode_xycb_f2( unsigned ); // LD D, SET 6, (IX + d) [undocumented] | ||
1044 | void opcode_xycb_f3( unsigned ); // LD E, SET 6, (IX + d) [undocumented] | ||
1045 | void opcode_xycb_f4( unsigned ); // LD H, SET 6, (IX + d) [undocumented] | ||
1046 | void opcode_xycb_f5( unsigned ); // LD L, SET 6, (IX + d) [undocumented] | ||
1047 | void opcode_xycb_f6( unsigned ); // SET 6, (IX + d) | ||
1048 | void opcode_xycb_f7( unsigned ); // LD A, SET 6, (IX + d) [undocumented] | ||
1049 | void opcode_xycb_f8( unsigned ); // LD B, SET 7, (IX + d) [undocumented] | ||
1050 | void opcode_xycb_f9( unsigned ); // LD C, SET 7, (IX + d) [undocumented] | ||
1051 | void opcode_xycb_fa( unsigned ); // LD D, SET 7, (IX + d) [undocumented] | ||
1052 | void opcode_xycb_fb( unsigned ); // LD E, SET 7, (IX + d) [undocumented] | ||
1053 | void opcode_xycb_fc( unsigned ); // LD H, SET 7, (IX + d) [undocumented] | ||
1054 | void opcode_xycb_fd( unsigned ); // LD L, SET 7, (IX + d) [undocumented] | ||
1055 | void opcode_xycb_fe( unsigned ); // SET 7, (IX + d) | ||
1056 | void opcode_xycb_ff( unsigned ); // LD A, SET 7, (IX + d) [undocumented] | ||
1057 | |||
1058 | // Trivia: there are 1018 opcode_xxx() functions in this class, | ||
1059 | // for a total of 1274 emulated opcodes. Fortunately, most of them | ||
1060 | // were automatically generated by custom made programs and scripts. | ||
1061 | |||
1062 | #endif | ||