1 /************************************************************************/ 2 /* */ 3 /* ���ڥ������̽��� */ 4 /* */ 5 /************************************************************************/ 6 7 8 /* 8�ӥå�ž��̿�� */ 9 10 case LD_A_A: z80->ACC=z80->ACC; break; 11 case LD_A_B: z80->ACC=z80->BC.B.h; break; 12 case LD_A_C: z80->ACC=z80->BC.B.l; break; 13 case LD_A_D: z80->ACC=z80->DE.B.h; break; 14 case LD_A_E: z80->ACC=z80->DE.B.l; break; 15 case LD_A_H: z80->ACC=z80->HL.B.h; break; 16 case LD_A_L: z80->ACC=z80->HL.B.l; break; 17 case LD_A_xHL: z80->ACC=M_RDMEM(z80->HL.W); break; 18 case LD_A_8: z80->ACC=M_RDMEM(z80->PC.W++); break; 19 20 case LD_B_A: z80->BC.B.h=z80->ACC; break; 21 case LD_B_B: z80->BC.B.h=z80->BC.B.h; break; 22 case LD_B_C: z80->BC.B.h=z80->BC.B.l; break; 23 case LD_B_D: z80->BC.B.h=z80->DE.B.h; break; 24 case LD_B_E: z80->BC.B.h=z80->DE.B.l; break; 25 case LD_B_H: z80->BC.B.h=z80->HL.B.h; break; 26 case LD_B_L: z80->BC.B.h=z80->HL.B.l; break; 27 case LD_B_xHL: z80->BC.B.h=M_RDMEM(z80->HL.W); break; 28 case LD_B_8: z80->BC.B.h=M_RDMEM(z80->PC.W++); break; 29 30 case LD_C_A: z80->BC.B.l=z80->ACC; break; 31 case LD_C_B: z80->BC.B.l=z80->BC.B.h; break; 32 case LD_C_C: z80->BC.B.l=z80->BC.B.l; break; 33 case LD_C_D: z80->BC.B.l=z80->DE.B.h; break; 34 case LD_C_E: z80->BC.B.l=z80->DE.B.l; break; 35 case LD_C_H: z80->BC.B.l=z80->HL.B.h; break; 36 case LD_C_L: z80->BC.B.l=z80->HL.B.l; break; 37 case LD_C_xHL: z80->BC.B.l=M_RDMEM(z80->HL.W); break; 38 case LD_C_8: z80->BC.B.l=M_RDMEM(z80->PC.W++); break; 39 40 case LD_D_A: z80->DE.B.h=z80->ACC; break; 41 case LD_D_B: z80->DE.B.h=z80->BC.B.h; break; 42 case LD_D_C: z80->DE.B.h=z80->BC.B.l; break; 43 case LD_D_D: z80->DE.B.h=z80->DE.B.h; break; 44 case LD_D_E: z80->DE.B.h=z80->DE.B.l; break; 45 case LD_D_H: z80->DE.B.h=z80->HL.B.h; break; 46 case LD_D_L: z80->DE.B.h=z80->HL.B.l; break; 47 case LD_D_xHL: z80->DE.B.h=M_RDMEM(z80->HL.W); break; 48 case LD_D_8: z80->DE.B.h=M_RDMEM(z80->PC.W++); break; 49 50 case LD_E_A: z80->DE.B.l=z80->ACC; break; 51 case LD_E_B: z80->DE.B.l=z80->BC.B.h; break; 52 case LD_E_C: z80->DE.B.l=z80->BC.B.l; break; 53 case LD_E_D: z80->DE.B.l=z80->DE.B.h; break; 54 case LD_E_E: z80->DE.B.l=z80->DE.B.l; break; 55 case LD_E_H: z80->DE.B.l=z80->HL.B.h; break; 56 case LD_E_L: z80->DE.B.l=z80->HL.B.l; break; 57 case LD_E_xHL: z80->DE.B.l=M_RDMEM(z80->HL.W); break; 58 case LD_E_8: z80->DE.B.l=M_RDMEM(z80->PC.W++); break; 59 60 case LD_H_A: z80->HL.B.h=z80->ACC; break; 61 case LD_H_B: z80->HL.B.h=z80->BC.B.h; break; 62 case LD_H_C: z80->HL.B.h=z80->BC.B.l; break; 63 case LD_H_D: z80->HL.B.h=z80->DE.B.h; break; 64 case LD_H_E: z80->HL.B.h=z80->DE.B.l; break; 65 case LD_H_H: z80->HL.B.h=z80->HL.B.h; break; 66 case LD_H_L: z80->HL.B.h=z80->HL.B.l; break; 67 case LD_H_xHL: z80->HL.B.h=M_RDMEM(z80->HL.W); break; 68 case LD_H_8: z80->HL.B.h=M_RDMEM(z80->PC.W++); break; 69 70 case LD_L_A: z80->HL.B.l=z80->ACC; break; 71 case LD_L_B: z80->HL.B.l=z80->BC.B.h; break; 72 case LD_L_C: z80->HL.B.l=z80->BC.B.l; break; 73 case LD_L_D: z80->HL.B.l=z80->DE.B.h; break; 74 case LD_L_E: z80->HL.B.l=z80->DE.B.l; break; 75 case LD_L_H: z80->HL.B.l=z80->HL.B.h; break; 76 case LD_L_L: z80->HL.B.l=z80->HL.B.l; break; 77 case LD_L_xHL: z80->HL.B.l=M_RDMEM(z80->HL.W); break; 78 case LD_L_8: z80->HL.B.l=M_RDMEM(z80->PC.W++); break; 79 80 case LD_xHL_A: M_WRMEM(z80->HL.W,z80->ACC); break; 81 case LD_xHL_B: M_WRMEM(z80->HL.W,z80->BC.B.h); break; 82 case LD_xHL_C: M_WRMEM(z80->HL.W,z80->BC.B.l); break; 83 case LD_xHL_D: M_WRMEM(z80->HL.W,z80->DE.B.h); break; 84 case LD_xHL_E: M_WRMEM(z80->HL.W,z80->DE.B.l); break; 85 case LD_xHL_H: M_WRMEM(z80->HL.W,z80->HL.B.h); break; 86 case LD_xHL_L: M_WRMEM(z80->HL.W,z80->HL.B.l); break; 87 case LD_xHL_8: M_WRMEM(z80->HL.W,M_RDMEM(z80->PC.W++)); break; 88 89 case LD_A_xBC: z80->ACC=M_RDMEM(z80->BC.W); break; 90 case LD_A_xDE: z80->ACC=M_RDMEM(z80->DE.W); break; 91 case LD_A_x16: 92 J.B.l = M_RDMEM(z80->PC.W++); 93 J.B.h = M_RDMEM(z80->PC.W++); 94 z80->ACC = M_RDMEM(J.W); 95 break; 96 97 case LD_xBC_A: M_WRMEM(z80->BC.W,z80->ACC); break; 98 case LD_xDE_A: M_WRMEM(z80->DE.W,z80->ACC); break; 99 case LD_x16_A: 100 J.B.l = M_RDMEM(z80->PC.W++); 101 J.B.h = M_RDMEM(z80->PC.W++); 102 M_WRMEM(J.W,z80->ACC); 103 break; 104 105 106 /* 16�ӥå�ž��̿�� */ 107 108 case LD_BC_16: M_LDWORD(BC); break; 109 case LD_DE_16: M_LDWORD(DE); break; 110 case LD_HL_16: M_LDWORD(HL); break; 111 case LD_SP_16: M_LDWORD(SP); break; 112 113 case LD_SP_HL: z80->SP.W=z80->HL.W; break; 114 115 case LD_x16_HL: 116 J.B.l = M_RDMEM(z80->PC.W++); 117 J.B.h = M_RDMEM(z80->PC.W++); 118 M_WRMEM(J.W++,z80->HL.B.l); 119 M_WRMEM(J.W, z80->HL.B.h); 120 break; 121 case LD_HL_x16: 122 J.B.l = M_RDMEM(z80->PC.W++); 123 J.B.h = M_RDMEM(z80->PC.W++); 124 z80->HL.B.l = M_RDMEM(J.W++); 125 z80->HL.B.h = M_RDMEM(J.W); 126 break; 127 128 case PUSH_BC: M_PUSH(BC); break; 129 case PUSH_DE: M_PUSH(DE); break; 130 case PUSH_HL: M_PUSH(HL); break; 131 case PUSH_AF: M_PUSH(AF); break; 132 133 case POP_BC: M_POP(BC); break; 134 case POP_DE: M_POP(DE); break; 135 case POP_HL: M_POP(HL); break; 136 case POP_AF: M_POP(AF); break; 137 138 139 /* 8�ӥåȻ��������黻̿�� */ 140 141 case ADD_A_A: M_ADD_A(z80->ACC); break; 142 case ADD_A_B: M_ADD_A(z80->BC.B.h); break; 143 case ADD_A_C: M_ADD_A(z80->BC.B.l); break; 144 case ADD_A_D: M_ADD_A(z80->DE.B.h); break; 145 case ADD_A_E: M_ADD_A(z80->DE.B.l); break; 146 case ADD_A_H: M_ADD_A(z80->HL.B.h); break; 147 case ADD_A_L: M_ADD_A(z80->HL.B.l); break; 148 case ADD_A_xHL:I=M_RDMEM(z80->HL.W); M_ADD_A(I); break; 149 case ADD_A_8: I=M_RDMEM(z80->PC.W++); M_ADD_A(I); break; 150 151 case ADC_A_A: M_ADC_A(z80->ACC); break; 152 case ADC_A_B: M_ADC_A(z80->BC.B.h); break; 153 case ADC_A_C: M_ADC_A(z80->BC.B.l); break; 154 case ADC_A_D: M_ADC_A(z80->DE.B.h); break; 155 case ADC_A_E: M_ADC_A(z80->DE.B.l); break; 156 case ADC_A_H: M_ADC_A(z80->HL.B.h); break; 157 case ADC_A_L: M_ADC_A(z80->HL.B.l); break; 158 case ADC_A_xHL:I=M_RDMEM(z80->HL.W); M_ADC_A(I); break; 159 case ADC_A_8: I=M_RDMEM(z80->PC.W++); M_ADC_A(I); break; 160 161 case SUB_A: M_SUB(z80->ACC); break; 162 case SUB_B: M_SUB(z80->BC.B.h); break; 163 case SUB_C: M_SUB(z80->BC.B.l); break; 164 case SUB_D: M_SUB(z80->DE.B.h); break; 165 case SUB_E: M_SUB(z80->DE.B.l); break; 166 case SUB_H: M_SUB(z80->HL.B.h); break; 167 case SUB_L: M_SUB(z80->HL.B.l); break; 168 case SUB_xHL: I=M_RDMEM(z80->HL.W); M_SUB(I); break; 169 case SUB_8: I=M_RDMEM(z80->PC.W++); M_SUB(I); break; 170 171 case SBC_A_A: M_SBC_A(z80->ACC); break; 172 case SBC_A_B: M_SBC_A(z80->BC.B.h); break; 173 case SBC_A_C: M_SBC_A(z80->BC.B.l); break; 174 case SBC_A_D: M_SBC_A(z80->DE.B.h); break; 175 case SBC_A_E: M_SBC_A(z80->DE.B.l); break; 176 case SBC_A_H: M_SBC_A(z80->HL.B.h); break; 177 case SBC_A_L: M_SBC_A(z80->HL.B.l); break; 178 case SBC_A_xHL:I=M_RDMEM(z80->HL.W); M_SBC_A(I); break; 179 case SBC_A_8: I=M_RDMEM(z80->PC.W++); M_SBC_A(I); break; 180 181 case AND_A: M_AND(z80->ACC); break; 182 case AND_B: M_AND(z80->BC.B.h); break; 183 case AND_C: M_AND(z80->BC.B.l); break; 184 case AND_D: M_AND(z80->DE.B.h); break; 185 case AND_E: M_AND(z80->DE.B.l); break; 186 case AND_H: M_AND(z80->HL.B.h); break; 187 case AND_L: M_AND(z80->HL.B.l); break; 188 case AND_xHL: I=M_RDMEM(z80->HL.W); M_AND(I); break; 189 case AND_8: I=M_RDMEM(z80->PC.W++); M_AND(I); break; 190 191 case OR_A: M_OR(z80->ACC); break; 192 case OR_B: M_OR(z80->BC.B.h); break; 193 case OR_C: M_OR(z80->BC.B.l); break; 194 case OR_D: M_OR(z80->DE.B.h); break; 195 case OR_E: M_OR(z80->DE.B.l); break; 196 case OR_H: M_OR(z80->HL.B.h); break; 197 case OR_L: M_OR(z80->HL.B.l); break; 198 case OR_xHL: I=M_RDMEM(z80->HL.W); M_OR(I); break; 199 case OR_8: I=M_RDMEM(z80->PC.W++); M_OR(I); break; 200 201 case XOR_A: M_XOR(z80->ACC); break; 202 case XOR_B: M_XOR(z80->BC.B.h); break; 203 case XOR_C: M_XOR(z80->BC.B.l); break; 204 case XOR_D: M_XOR(z80->DE.B.h); break; 205 case XOR_E: M_XOR(z80->DE.B.l); break; 206 case XOR_H: M_XOR(z80->HL.B.h); break; 207 case XOR_L: M_XOR(z80->HL.B.l); break; 208 case XOR_xHL: I=M_RDMEM(z80->HL.W); M_XOR(I); break; 209 case XOR_8: I=M_RDMEM(z80->PC.W++); M_XOR(I); break; 210 211 case CP_A: M_CP(z80->ACC); break; 212 case CP_B: M_CP(z80->BC.B.h); break; 213 case CP_C: M_CP(z80->BC.B.l); break; 214 case CP_D: M_CP(z80->DE.B.h); break; 215 case CP_E: M_CP(z80->DE.B.l); break; 216 case CP_H: M_CP(z80->HL.B.h); break; 217 case CP_L: M_CP(z80->HL.B.l); break; 218 case CP_xHL: I=M_RDMEM(z80->HL.W); M_CP(I); break; 219 case CP_8: I=M_RDMEM(z80->PC.W++); M_CP(I); break; 220 221 case INC_A: M_INC(z80->ACC); break; 222 case INC_B: M_INC(z80->BC.B.h); break; 223 case INC_C: M_INC(z80->BC.B.l); break; 224 case INC_D: M_INC(z80->DE.B.h); break; 225 case INC_E: M_INC(z80->DE.B.l); break; 226 case INC_H: M_INC(z80->HL.B.h); break; 227 case INC_L: M_INC(z80->HL.B.l); break; 228 case INC_xHL: 229 I=M_RDMEM(z80->HL.W); M_INC(I); M_WRMEM(z80->HL.W,I); break; 230 231 case DEC_A: M_DEC(z80->ACC); break; 232 case DEC_B: M_DEC(z80->BC.B.h); break; 233 case DEC_C: M_DEC(z80->BC.B.l); break; 234 case DEC_D: M_DEC(z80->DE.B.h); break; 235 case DEC_E: M_DEC(z80->DE.B.l); break; 236 case DEC_H: M_DEC(z80->HL.B.h); break; 237 case DEC_L: M_DEC(z80->HL.B.l); break; 238 case DEC_xHL: 239 I=M_RDMEM(z80->HL.W); M_DEC(I); M_WRMEM(z80->HL.W,I); break; 240 241 /* 16�ӥåȻ��ѱ黻̿�� */ 242 243 case ADD_HL_BC: M_ADDW(z80->HL.W,z80->BC.W); break; 244 case ADD_HL_DE: M_ADDW(z80->HL.W,z80->DE.W); break; 245 case ADD_HL_HL: M_ADDW(z80->HL.W,z80->HL.W); break; 246 case ADD_HL_SP: M_ADDW(z80->HL.W,z80->SP.W); break; 247 248 case INC_BC: z80->BC.W++; break; 249 case INC_DE: z80->DE.W++; break; 250 case INC_HL: z80->HL.W++; break; 251 case INC_SP: z80->SP.W++; break; 252 253 case DEC_BC: z80->BC.W--; break; 254 case DEC_DE: z80->DE.W--; break; 255 case DEC_HL: z80->HL.W--; break; 256 case DEC_SP: z80->SP.W--; break; 257 258 259 /* �쥸������̿�� */ 260 261 case EX_AF_AF: 262 J.W=z80->AF.W; z80->AF.W=z80->AF1.W; z80->AF1.W=J.W; 263 break; 264 case EX_DE_HL: 265 J.W=z80->DE.W; z80->DE.W=z80->HL.W; z80->HL.W=J.W; 266 break; 267 case EX_xSP_HL: 268 J.B.l = M_RDMEM(z80->SP.W); M_WRMEM(z80->SP.W++,z80->HL.B.l); 269 J.B.h = M_RDMEM(z80->SP.W); M_WRMEM(z80->SP.W--,z80->HL.B.h); 270 z80->HL.W = J.W; 271 break; 272 case EXX: 273 J.W=z80->BC.W; z80->BC.W=z80->BC1.W; z80->BC1.W=J.W; 274 J.W=z80->DE.W; z80->DE.W=z80->DE1.W; z80->DE1.W=J.W; 275 J.W=z80->HL.W; z80->HL.W=z80->HL1.W; z80->HL1.W=J.W; 276 break; 277 278 279 /* ʬ��̿�� */ 280 281 case JP: M_JP(); break; 282 case JP_NZ: 283 if( M_NZ() ) M_JP(); else M_JP_SKIP(); break; 284 case JP_NC: 285 if( M_NC() ) M_JP(); else M_JP_SKIP(); break; 286 case JP_PO: 287 if( M_PO() ) M_JP(); else M_JP_SKIP(); break; 288 case JP_P: 289 if( M_P() ) M_JP(); else M_JP_SKIP(); break; 290 case JP_Z: 291 if( M_Z() ) M_JP(); else M_JP_SKIP(); break; 292 case JP_C: 293 if( M_C() ) M_JP(); else M_JP_SKIP(); break; 294 case JP_PE: 295 if( M_PE() ) M_JP(); else M_JP_SKIP(); break; 296 case JP_M: 297 if( M_M() ) M_JP(); else M_JP_SKIP(); break; 298 299 case JR: M_JR(); break; 300 case JR_NZ: 301 if( M_NZ() ) M_JR(); else M_JR_SKIP(); break; 302 case JR_NC: 303 if( M_NC() ) M_JR(); else M_JR_SKIP(); break; 304 case JR_Z: 305 if( M_Z() ) M_JR(); else M_JR_SKIP(); break; 306 case JR_C: 307 if( M_C() ) M_JR(); else M_JR_SKIP(); break; 308 309 case CALL: M_CALL(); break; 310 case CALL_NZ: 311 if( M_NZ() ) M_CALL(); else M_CALL_SKIP(); break; 312 case CALL_NC: 313 if( M_NC() ) M_CALL(); else M_CALL_SKIP(); break; 314 case CALL_PO: 315 if( M_PO() ) M_CALL(); else M_CALL_SKIP(); break; 316 case CALL_P: 317 if( M_P() ) M_CALL(); else M_CALL_SKIP(); break; 318 case CALL_Z: 319 if( M_Z() ) M_CALL(); else M_CALL_SKIP(); break; 320 case CALL_C: 321 if( M_C() ) M_CALL(); else M_CALL_SKIP(); break; 322 case CALL_PE: 323 if( M_PE() ) M_CALL(); else M_CALL_SKIP(); break; 324 case CALL_M: 325 if( M_M() ) M_CALL(); else M_CALL_SKIP(); break; 326 327 case RET: M_RET(); break; 328 case RET_NZ: 329 if( M_NZ() ) M_RET(); else M_RET_SKIP(); break; 330 case RET_NC: 331 if( M_NC() ) M_RET(); else M_RET_SKIP(); break; 332 case RET_PO: 333 if( M_PO() ) M_RET(); else M_RET_SKIP(); break; 334 case RET_P: 335 if( M_P() ) M_RET(); else M_RET_SKIP(); break; 336 case RET_Z: 337 if( M_Z() ) M_RET(); else M_RET_SKIP(); break; 338 case RET_C: 339 if( M_C() ) M_RET(); else M_RET_SKIP(); break; 340 case RET_PE: 341 if( M_PE() ) M_RET(); else M_RET_SKIP(); break; 342 case RET_M: 343 if( M_M() ) M_RET(); else M_RET_SKIP(); break; 344 345 case JP_xHL: z80->PC.W = z80->HL.W; break; 346 case DJNZ: 347 if( --z80->BC.B.h ) M_JR(); 348 else M_JR_SKIP(); break; 349 350 case RST00: M_RST(0x0000); break; 351 case RST08: M_RST(0x0008); break; 352 case RST10: M_RST(0x0010); break; 353 case RST18: M_RST(0x0018); break; 354 case RST20: M_RST(0x0020); break; 355 case RST28: M_RST(0x0028); break; 356 case RST30: M_RST(0x0030); break; 357 case RST38: M_RST(0x0038); break; 358 359 360 /* ���ơ��ȡ����ե�̿�� */ 361 362 case RLCA: 363 I = z80->ACC>>7; 364 z80->ACC = (z80->ACC<<1)|I; 365 z80->FLAG = (z80->FLAG&~(H_FLAG|N_FLAG|C_FLAG))|I; 366 break; 367 case RLA: 368 I = z80->ACC>>7; 369 z80->ACC = (z80->ACC<<1)|(z80->FLAG&C_FLAG); 370 z80->FLAG = (z80->FLAG&~(H_FLAG|N_FLAG|C_FLAG))|I; 371 break; 372 case RRCA: 373 I = z80->ACC&0x01; 374 z80->ACC = (z80->ACC>>1)|(I<<7); 375 z80->FLAG = (z80->FLAG&~(H_FLAG|N_FLAG|C_FLAG))|I; 376 break; 377 case RRA: 378 I = z80->ACC&0x01; 379 z80->ACC = (z80->ACC>>1)|(z80->FLAG<<7); 380 z80->FLAG = (z80->FLAG&~(H_FLAG|N_FLAG|C_FLAG))|I; 381 break; 382 383 384 /* ������̿�� */ 385 386 case IN_A_x8: 387 I = M_RDIO( M_RDMEM(z80->PC.W++) ); 388 z80->ACC = I; 389 break; 390 case OUT_x8_A: 391 M_WRIO( M_RDMEM(z80->PC.W++), z80->ACC ); 392 break; 393 394 395 /* ����¾��̿�� */ 396 397 case NOP: break; 398 399 case DI: 400 z80->IFF = INT_DISABLE; 401 break; 402 case EI: 403 z80->IFF = INT_ENABLE; 404 if( z80->state0 < z80_state_intchk ){ /* �ޤ���¦�롼��ȴ���ʤ����*/ 405 if( z80->INT_active ){ /* ��α���������� */ 406 z80->skip_intr_chk = TRUE; /* ������ȴ���� */ 407 z80_state_intchk = 0; 408 } 409 }else{ /* �⤦ȴ������ */ 410 z80->skip_intr_chk = TRUE; 411 z80_state_intchk = 0; 412 } 413 break; 414 415 case SCF: 416 z80->FLAG = (z80->FLAG&~(H_FLAG|N_FLAG))|C_FLAG; 417 break; 418 case CCF: 419 z80->FLAG ^= C_FLAG; 420 z80->FLAG = (z80->FLAG&~(H_FLAG|N_FLAG))|(z80->FLAG&C_FLAG? 0:H_FLAG); 421 break; 422 423 case CPL: 424 z80->ACC = ~z80->ACC; 425 z80->FLAG |= (H_FLAG|N_FLAG); 426 break; 427 case DAA: 428 J.W = z80->ACC; 429 if( z80->FLAG & C_FLAG ) J.W |= 256; 430 if( z80->FLAG & H_FLAG ) J.W |= 512; 431 if( z80->FLAG & N_FLAG ) J.W |= 1024; 432 z80->AF.W = DAA_table[ J.W ]; 433 break; 434 435 case HALT: 436 z80->HALT = TRUE; 437 z80->PC.W --; 438 if( z80->INT_active ) z80_state_intchk = 0; 439 if( z80->break_if_halt ) z80_state_intchk = 0; 440 break; 441 442 443