comparison z80inst.c @ 651:103d5cabbe14

Fix flags for rra, rrca, rla and rlca. Fix timing for rr, rrc, rl and rlc when using IX or IY. Fix access to I and R registers (R still needs to be made 7-bit though). Fix flags for ld a, i. The fix for access to I fixes PCM playback in Titan Overdrive and music playback in Crackdown.
author Michael Pavone <pavone@retrodev.com>
date Tue, 16 Dec 2014 01:10:54 -0800
parents 140af5509ce7
children 1625555e346e
comparison
equal deleted inserted replaced
650:55b550fe8891 651:103d5cabbe14
1 /* 1 /*
2 Copyright 2013 Michael Pavone 2 Copyright 2013 Michael Pavone
3 This file is part of BlastEm. 3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text. 4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5 */ 5 */
6 #include "z80inst.h" 6 #include "z80inst.h"
7 #include <string.h> 7 #include <string.h>
8 #include <stdio.h> 8 #include <stdio.h>
431 {op, Z80_E, Z80_UNUSED, Z80_UNUSED, 1},\ 431 {op, Z80_E, Z80_UNUSED, Z80_UNUSED, 1},\
432 {op, Z80_H, Z80_UNUSED, Z80_UNUSED, 1},\ 432 {op, Z80_H, Z80_UNUSED, Z80_UNUSED, 1},\
433 {op, Z80_L, Z80_UNUSED, Z80_UNUSED, 1},\ 433 {op, Z80_L, Z80_UNUSED, Z80_UNUSED, 1},\
434 {op, Z80_UNUSED, Z80_REG_INDIRECT, Z80_HL, 1},\ 434 {op, Z80_UNUSED, Z80_REG_INDIRECT, Z80_HL, 1},\
435 {op, Z80_A, Z80_UNUSED, Z80_UNUSED, 1} 435 {op, Z80_A, Z80_UNUSED, Z80_UNUSED, 1}
436 436
437 #define BIT_BLOCK(op, bit) \ 437 #define BIT_BLOCK(op, bit) \
438 {op, Z80_USE_IMMED, Z80_REG, Z80_B, bit},\ 438 {op, Z80_USE_IMMED, Z80_REG, Z80_B, bit},\
439 {op, Z80_USE_IMMED, Z80_REG, Z80_C, bit},\ 439 {op, Z80_USE_IMMED, Z80_REG, Z80_C, bit},\
440 {op, Z80_USE_IMMED, Z80_REG, Z80_D, bit},\ 440 {op, Z80_USE_IMMED, Z80_REG, Z80_D, bit},\
441 {op, Z80_USE_IMMED, Z80_REG, Z80_E, bit},\ 441 {op, Z80_USE_IMMED, Z80_REG, Z80_E, bit},\
769 NOP2, 769 NOP2,
770 NOP2 770 NOP2
771 }; 771 };
772 772
773 #define SHIFT_BLOCK_IX(op) \ 773 #define SHIFT_BLOCK_IX(op) \
774 {op, Z80_B, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 774 {op, Z80_B, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
775 {op, Z80_C, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 775 {op, Z80_C, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
776 {op, Z80_D, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 776 {op, Z80_D, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
777 {op, Z80_E, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 777 {op, Z80_E, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
778 {op, Z80_H, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 778 {op, Z80_H, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
779 {op, Z80_L, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 779 {op, Z80_L, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
780 {op, Z80_UNUSED, Z80_IX_DISPLACE | Z80_DIR, 0, 0},\ 780 {op, Z80_UNUSED, Z80_IX_DISPLACE | Z80_DIR, 0, 1},\
781 {op, Z80_A, Z80_IX_DISPLACE | Z80_DIR, 0, 0} 781 {op, Z80_A, Z80_IX_DISPLACE | Z80_DIR, 0, 1}
782 782
783 #define BIT_BLOCK_IX(bit) \ 783 #define BIT_BLOCK_IX(bit) \
784 {Z80_BIT, Z80_USE_IMMED, Z80_IX_DISPLACE, 0, bit},\ 784 {Z80_BIT, Z80_USE_IMMED, Z80_IX_DISPLACE, 0, bit},\
785 {Z80_BIT, Z80_USE_IMMED, Z80_IX_DISPLACE, 0, bit},\ 785 {Z80_BIT, Z80_USE_IMMED, Z80_IX_DISPLACE, 0, bit},\
786 {Z80_BIT, Z80_USE_IMMED, Z80_IX_DISPLACE, 0, bit},\ 786 {Z80_BIT, Z80_USE_IMMED, Z80_IX_DISPLACE, 0, bit},\
1127 {Z80_NOP, Z80_UNUSED, Z80_UNUSED, Z80_UNUSED, 42} 1127 {Z80_NOP, Z80_UNUSED, Z80_UNUSED, Z80_UNUSED, 42}
1128 //NOP2 1128 //NOP2
1129 }; 1129 };
1130 1130
1131 #define SHIFT_BLOCK_IY(op) \ 1131 #define SHIFT_BLOCK_IY(op) \
1132 {op, Z80_B, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1132 {op, Z80_B, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1133 {op, Z80_C, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1133 {op, Z80_C, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1134 {op, Z80_D, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1134 {op, Z80_D, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1135 {op, Z80_E, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1135 {op, Z80_E, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1136 {op, Z80_H, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1136 {op, Z80_H, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1137 {op, Z80_L, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1137 {op, Z80_L, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1138 {op, Z80_UNUSED, Z80_IY_DISPLACE | Z80_DIR, 0, 0},\ 1138 {op, Z80_UNUSED, Z80_IY_DISPLACE | Z80_DIR, 0, 1},\
1139 {op, Z80_A, Z80_IY_DISPLACE | Z80_DIR, 0, 0} 1139 {op, Z80_A, Z80_IY_DISPLACE | Z80_DIR, 0, 1}
1140 1140
1141 #define BIT_BLOCK_IY(bit) \ 1141 #define BIT_BLOCK_IY(bit) \
1142 {Z80_BIT, Z80_USE_IMMED, Z80_IY_DISPLACE, 0, bit},\ 1142 {Z80_BIT, Z80_USE_IMMED, Z80_IY_DISPLACE, 0, bit},\
1143 {Z80_BIT, Z80_USE_IMMED, Z80_IY_DISPLACE, 0, bit},\ 1143 {Z80_BIT, Z80_USE_IMMED, Z80_IY_DISPLACE, 0, bit},\
1144 {Z80_BIT, Z80_USE_IMMED, Z80_IY_DISPLACE, 0, bit},\ 1144 {Z80_BIT, Z80_USE_IMMED, Z80_IY_DISPLACE, 0, bit},\
1248 decoded->ea_reg = *(++istream); 1248 decoded->ea_reg = *(++istream);
1249 } 1249 }
1250 } 1250 }
1251 } else { 1251 } else {
1252 memcpy(decoded, z80_tbl_a + *istream, sizeof(z80inst)); 1252 memcpy(decoded, z80_tbl_a + *istream, sizeof(z80inst));
1253 1253
1254 } 1254 }
1255 if ((decoded->addr_mode & 0x1F) == Z80_IMMED && decoded->op != Z80_RST && decoded->op != Z80_IM) { 1255 if ((decoded->addr_mode & 0x1F) == Z80_IMMED && decoded->op != Z80_RST && decoded->op != Z80_IM) {
1256 decoded->immed = *(++istream); 1256 decoded->immed = *(++istream);
1257 if ((decoded->reg >= Z80_BC && decoded->reg < Z80_UNUSED) || decoded->op == Z80_CALL || decoded->op == Z80_CALLCC || decoded->op == Z80_JP || decoded->op == Z80_JPCC) { 1257 if ((decoded->reg >= Z80_BC && decoded->reg < Z80_UNUSED) || decoded->op == Z80_CALL || decoded->op == Z80_CALLCC || decoded->op == Z80_JP || decoded->op == Z80_JPCC) {
1258 decoded->immed |= *(++istream) << 8; 1258 decoded->immed |= *(++istream) << 8;