mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
sh2 drc, make B/W read functions signed (reduces generated code size)
This commit is contained in:
parent
ed7e915078
commit
aa4c4cb951
7 changed files with 85 additions and 60 deletions
|
@ -795,6 +795,8 @@ static inline void emith_pool_check(void)
|
||||||
emith_read_r_r_offs_c(cond, r, rs, offs)
|
emith_read_r_r_offs_c(cond, r, rs, offs)
|
||||||
#define emith_read_r_r_r_c(cond, r, rs, rm) \
|
#define emith_read_r_r_r_c(cond, r, rs, rm) \
|
||||||
EOP_LDR_REG_LSL(cond, r, rs, rm, 0)
|
EOP_LDR_REG_LSL(cond, r, rs, rm, 0)
|
||||||
|
#define emith_read_r_r_offs(r, rs, offs) \
|
||||||
|
emith_read_r_r_offs_c(A_COND_AL, r, rs, offs)
|
||||||
#define emith_read_r_r_r(r, rs, rm) \
|
#define emith_read_r_r_r(r, rs, rm) \
|
||||||
EOP_LDR_REG_LSL(A_COND_AL, r, rs, rm, 0)
|
EOP_LDR_REG_LSL(A_COND_AL, r, rs, rm, 0)
|
||||||
|
|
||||||
|
@ -802,28 +804,37 @@ static inline void emith_pool_check(void)
|
||||||
EOP_LDRB_IMM2(cond, r, rs, offs)
|
EOP_LDRB_IMM2(cond, r, rs, offs)
|
||||||
#define emith_read8_r_r_r_c(cond, r, rs, rm) \
|
#define emith_read8_r_r_r_c(cond, r, rs, rm) \
|
||||||
EOP_LDRB_REG_LSL(cond, r, rs, rm, 0)
|
EOP_LDRB_REG_LSL(cond, r, rs, rm, 0)
|
||||||
|
#define emith_read8_r_r_offs(r, rs, offs) \
|
||||||
|
emith_read8_r_r_offs_c(A_COND_AL, r, rs, offs)
|
||||||
#define emith_read8_r_r_r(r, rs, rm) \
|
#define emith_read8_r_r_r(r, rs, rm) \
|
||||||
EOP_LDRB_REG_LSL(A_COND_AL, r, rs, rm, 0)
|
emith_read8_r_r_r_c(A_COND_AL, r, rs, rm)
|
||||||
|
|
||||||
#define emith_read16_r_r_offs_c(cond, r, rs, offs) \
|
#define emith_read16_r_r_offs_c(cond, r, rs, offs) \
|
||||||
EOP_LDRH_IMM2(cond, r, rs, offs)
|
EOP_LDRH_IMM2(cond, r, rs, offs)
|
||||||
#define emith_read16_r_r_r_c(cond, r, rs, rm) \
|
#define emith_read16_r_r_r_c(cond, r, rs, rm) \
|
||||||
EOP_LDRH_REG2(cond, r, rs, rm)
|
EOP_LDRH_REG2(cond, r, rs, rm)
|
||||||
#define emith_read16_r_r_r(r, rs, rm) \
|
|
||||||
EOP_LDRH_REG2(A_COND_AL, r, rs, rm)
|
|
||||||
|
|
||||||
#define emith_read_r_r_offs(r, rs, offs) \
|
|
||||||
emith_read_r_r_offs_c(A_COND_AL, r, rs, offs)
|
|
||||||
|
|
||||||
#define emith_read8s_r_r_offs(r, rs, offs) \
|
|
||||||
EOP_LDRSB_IMM2(A_COND_AL, r, rs, offs)
|
|
||||||
#define emith_read8_r_r_offs(r, rs, offs) \
|
|
||||||
emith_read8_r_r_offs_c(A_COND_AL, r, rs, offs)
|
|
||||||
|
|
||||||
#define emith_read16s_r_r_offs(r, rs, offs) \
|
|
||||||
EOP_LDRSH_IMM2(A_COND_AL, r, rs, offs)
|
|
||||||
#define emith_read16_r_r_offs(r, rs, offs) \
|
#define emith_read16_r_r_offs(r, rs, offs) \
|
||||||
emith_read16_r_r_offs_c(A_COND_AL, r, rs, offs)
|
emith_read16_r_r_offs_c(A_COND_AL, r, rs, offs)
|
||||||
|
#define emith_read16_r_r_r(r, rs, rm) \
|
||||||
|
emith_read16_r_r_r_c(A_COND_AL, r, rs, rm)
|
||||||
|
|
||||||
|
#define emith_read8s_r_r_offs_c(cond, r, rs, offs) \
|
||||||
|
EOP_LDRSB_IMM2(cond, r, rs, offs)
|
||||||
|
#define emith_read8s_r_r_r_c(cond, r, rs, rm) \
|
||||||
|
EOP_LDRSB_REG2(cond, r, rs, rm)
|
||||||
|
#define emith_read8s_r_r_offs(r, rs, offs) \
|
||||||
|
emith_read8s_r_r_offs_c(A_COND_AL, r, rs, offs)
|
||||||
|
#define emith_read8s_r_r_r(r, rs, rm) \
|
||||||
|
emith_read8s_r_r_r_c(A_COND_AL, r, rs, rm)
|
||||||
|
|
||||||
|
#define emith_read16s_r_r_offs_c(cond, r, rs, offs) \
|
||||||
|
EOP_LDRSH_IMM2(cond, r, rs, offs)
|
||||||
|
#define emith_read16s_r_r_r_c(cond, r, rs, rm) \
|
||||||
|
EOP_LDRSH_REG2(cond, r, rs, rm)
|
||||||
|
#define emith_read16s_r_r_offs(r, rs, offs) \
|
||||||
|
emith_read16s_r_r_offs_c(A_COND_AL, r, rs, offs)
|
||||||
|
#define emith_read16s_r_r_r(r, rs, rm) \
|
||||||
|
emith_read16s_r_r_r_c(A_COND_AL, r, rs, rm)
|
||||||
|
|
||||||
#define emith_write_r_r_offs_c(cond, r, rs, offs) \
|
#define emith_write_r_r_offs_c(cond, r, rs, offs) \
|
||||||
EOP_STR_IMM2(cond, r, rs, offs)
|
EOP_STR_IMM2(cond, r, rs, offs)
|
||||||
|
@ -945,6 +956,11 @@ static inline void emith_pool_check(void)
|
||||||
#define emith_call(target) \
|
#define emith_call(target) \
|
||||||
emith_call_cond(A_COND_AL, target)
|
emith_call_cond(A_COND_AL, target)
|
||||||
|
|
||||||
|
#define emith_call_reg(r) { \
|
||||||
|
emith_move_r_r(14, 15); \
|
||||||
|
EOP_C_BX(A_COND_AL, r); \
|
||||||
|
}
|
||||||
|
|
||||||
#define emith_call_ctx(offs) { \
|
#define emith_call_ctx(offs) { \
|
||||||
emith_move_r_r(14, 15); \
|
emith_move_r_r(14, 15); \
|
||||||
emith_jump_ctx(offs); \
|
emith_jump_ctx(offs); \
|
||||||
|
@ -1091,9 +1107,7 @@ static inline void emith_pool_check(void)
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* mh:ml += rn*rm, does saturation if required by S bit. rn, rm must be TEMP */
|
/* mh:ml += rn*rm, does saturation if required by S bit. rn, rm must be TEMP */
|
||||||
#define emith_sh2_macw(ml, mh, rn, rm, sr) do { \
|
#define emith_sh2_macw(ml, mh, rn, rm, sr) do { \
|
||||||
emith_sext(rn, rn, 16); \
|
|
||||||
emith_sext(rm, rm, 16); \
|
|
||||||
emith_tst_r_imm(sr, S); \
|
emith_tst_r_imm(sr, S); \
|
||||||
EMITH_SJMP2_START(DCOND_NE); \
|
EMITH_SJMP2_START(DCOND_NE); \
|
||||||
emith_mula_s64_c(DCOND_EQ, ml, mh, rn, rm); \
|
emith_mula_s64_c(DCOND_EQ, ml, mh, rn, rm); \
|
||||||
|
|
|
@ -397,8 +397,12 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
||||||
|
|
||||||
#define emith_read8_r_r_r_c(cond, r, rs, rm) \
|
#define emith_read8_r_r_r_c(cond, r, rs, rm) \
|
||||||
emith_read8_r_r_r(r, rs, rm)
|
emith_read8_r_r_r(r, rs, rm)
|
||||||
|
#define emith_read8s_r_r_r_c(cond, r, rs, rm) \
|
||||||
|
emith_read8s_r_r_r(r, rs, rm)
|
||||||
#define emith_read16_r_r_r_c(cond, r, rs, rm) \
|
#define emith_read16_r_r_r_c(cond, r, rs, rm) \
|
||||||
emith_read16_r_r_r(r, rs, rm)
|
emith_read16_r_r_r(r, rs, rm)
|
||||||
|
#define emith_read16s_r_r_r_c(cond, r, rs, rm) \
|
||||||
|
emith_read16s_r_r_r(r, rs, rm)
|
||||||
#define emith_read_r_r_r_c(cond, r, rs, rm) \
|
#define emith_read_r_r_r_c(cond, r, rs, rm) \
|
||||||
emith_read_r_r_r(r, rs, rm)
|
emith_read_r_r_r(r, rs, rm)
|
||||||
|
|
||||||
|
@ -684,12 +688,24 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
||||||
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define emith_read8s_r_r_r(r, rs, rm) do { \
|
||||||
|
EMIT(0x0f, u8); \
|
||||||
|
EMIT_OP_MODRM(0xbe, 0, r, 4); \
|
||||||
|
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define emith_read16_r_r_r(r, rs, rm) do { \
|
#define emith_read16_r_r_r(r, rs, rm) do { \
|
||||||
EMIT(0x0f, u8); \
|
EMIT(0x0f, u8); \
|
||||||
EMIT_OP_MODRM(0xb7, 0, r, 4); \
|
EMIT_OP_MODRM(0xb7, 0, r, 4); \
|
||||||
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define emith_read16s_r_r_r(r, rs, rm) do { \
|
||||||
|
EMIT(0x0f, u8); \
|
||||||
|
EMIT_OP_MODRM(0xbf, 0, r, 4); \
|
||||||
|
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define emith_read_r_r_r(r, rs, rm) do { \
|
#define emith_read_r_r_r(r, rs, rm) do { \
|
||||||
EMIT_OP_MODRM(0x8b, 0, r, 4); \
|
EMIT_OP_MODRM(0x8b, 0, r, 4); \
|
||||||
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
EMIT_SIB(0, rs, rm); /* mov r, [rm + rs * 1] */ \
|
||||||
|
@ -785,9 +801,11 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
||||||
EMIT(offs, u32); \
|
EMIT(offs, u32); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define emith_push_ret()
|
#define emith_push_ret() \
|
||||||
|
emith_push(xSI); /* to align */
|
||||||
|
|
||||||
#define emith_pop_and_ret() \
|
#define emith_pop_and_ret() \
|
||||||
|
emith_pop(xSI); \
|
||||||
emith_ret()
|
emith_ret()
|
||||||
|
|
||||||
#define EMITH_JMP_START(cond) { \
|
#define EMITH_JMP_START(cond) { \
|
||||||
|
@ -1080,8 +1098,6 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI };
|
||||||
|
|
||||||
/* mh:ml += rn*rm, does saturation if required by S bit. rn, rm must be TEMP */
|
/* mh:ml += rn*rm, does saturation if required by S bit. rn, rm must be TEMP */
|
||||||
#define emith_sh2_macw(ml, mh, rn, rm, sr) do { \
|
#define emith_sh2_macw(ml, mh, rn, rm, sr) do { \
|
||||||
emith_sext(rn, rn, 16); \
|
|
||||||
emith_sext(rm, rm, 16); \
|
|
||||||
emith_tst_r_imm(sr, S); \
|
emith_tst_r_imm(sr, S); \
|
||||||
EMITH_SJMP_START(DCOND_EQ); \
|
EMITH_SJMP_START(DCOND_EQ); \
|
||||||
/* XXX: MACH should be untouched when S is set? */ \
|
/* XXX: MACH should be untouched when S is set? */ \
|
||||||
|
|
|
@ -2354,17 +2354,15 @@ static int emit_memhandler_read_rr(SH2 *sh2, sh2_reg_e rd, sh2_reg_e rs, u32 off
|
||||||
hr2 = hr;
|
hr2 = hr;
|
||||||
else
|
else
|
||||||
#if REMAP_REGISTER
|
#if REMAP_REGISTER
|
||||||
hr2 = rcache_map_reg(rd, hr, size != 2 ? RC_GR_RMW : RC_GR_WRITE);
|
hr2 = rcache_map_reg(rd, hr, RC_GR_WRITE);
|
||||||
#else
|
#else
|
||||||
hr2 = rcache_get_reg(rd, RC_GR_WRITE, NULL);
|
hr2 = rcache_get_reg(rd, RC_GR_WRITE, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (rd != SHR_TMP && size != 2) { // 16, 8
|
if (hr != hr2) {
|
||||||
emith_sext(hr2, hr, size ? 16 : 8);
|
|
||||||
} else if (hr != hr2) // 32
|
|
||||||
emith_move_r_r(hr2, hr);
|
emith_move_r_r(hr2, hr);
|
||||||
if (hr != hr2)
|
|
||||||
rcache_free_tmp(hr);
|
rcache_free_tmp(hr);
|
||||||
|
}
|
||||||
return hr2;
|
return hr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2422,21 +2420,19 @@ static int emit_indirect_indexed_read(SH2 *sh2, sh2_reg_e rd, sh2_reg_e rx, sh2_
|
||||||
hr = emit_memhandler_read(size);
|
hr = emit_memhandler_read(size);
|
||||||
|
|
||||||
size &= MF_SIZEMASK;
|
size &= MF_SIZEMASK;
|
||||||
if (rd != SHR_TMP)
|
if (rd == SHR_TMP)
|
||||||
|
hr2 = hr;
|
||||||
|
else
|
||||||
#if REMAP_REGISTER
|
#if REMAP_REGISTER
|
||||||
hr2 = rcache_map_reg(rd, hr, size != 2 ? RC_GR_RMW : RC_GR_WRITE);
|
hr2 = rcache_map_reg(rd, hr, RC_GR_WRITE);
|
||||||
#else
|
#else
|
||||||
hr2 = rcache_get_reg(rd, RC_GR_WRITE, NULL);
|
hr2 = rcache_get_reg(rd, RC_GR_WRITE, NULL);
|
||||||
#endif
|
#endif
|
||||||
else
|
|
||||||
hr2 = hr;
|
|
||||||
|
|
||||||
if (rd != SHR_TMP && size != 2) { // 16, 8
|
if (hr != hr2) {
|
||||||
emith_sext(hr2, hr, size ? 16 : 8);
|
|
||||||
} else if (hr != hr2) // 32
|
|
||||||
emith_move_r_r(hr2, hr);
|
emith_move_r_r(hr2, hr);
|
||||||
if (hr != hr2)
|
|
||||||
rcache_free_tmp(hr);
|
rcache_free_tmp(hr);
|
||||||
|
}
|
||||||
return hr2;
|
return hr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2991,16 +2987,14 @@ static void REGPARM(2) *sh2_translate(SH2 *sh2, int tcache_id)
|
||||||
}
|
}
|
||||||
tmp2 = emit_memhandler_read(opd->size);
|
tmp2 = emit_memhandler_read(opd->size);
|
||||||
#if REMAP_REGISTER
|
#if REMAP_REGISTER
|
||||||
tmp3 = rcache_map_reg(GET_Rn(), tmp2, opd->size != 2 ? RC_GR_RMW : RC_GR_WRITE);
|
tmp3 = rcache_map_reg(GET_Rn(), tmp2, RC_GR_WRITE);
|
||||||
#else
|
#else
|
||||||
tmp3 = rcache_get_reg(GET_Rn(), RC_GR_WRITE, NULL);
|
tmp3 = rcache_get_reg(GET_Rn(), RC_GR_WRITE, NULL);
|
||||||
#endif
|
#endif
|
||||||
if (opd->size != 2) {
|
if (tmp3 != tmp2) {
|
||||||
emith_sext(tmp3, tmp2, 16);
|
|
||||||
} else if (tmp3 != tmp2)
|
|
||||||
emith_move_r_r(tmp3, tmp2);
|
emith_move_r_r(tmp3, tmp2);
|
||||||
if (tmp3 != tmp2)
|
|
||||||
rcache_free_tmp(tmp2);
|
rcache_free_tmp(tmp2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
goto end_op;
|
goto end_op;
|
||||||
|
|
||||||
|
@ -4025,7 +4019,7 @@ static void sh2_generate_utils(void)
|
||||||
EMITH_SJMP_START(DCOND_CS);
|
EMITH_SJMP_START(DCOND_CS);
|
||||||
emith_and_r_r_c(DCOND_CC, arg0, arg3);
|
emith_and_r_r_c(DCOND_CC, arg0, arg3);
|
||||||
emith_eor_r_imm_c(DCOND_CC, arg0, 1);
|
emith_eor_r_imm_c(DCOND_CC, arg0, 1);
|
||||||
emith_read8_r_r_r_c(DCOND_CC, RET_REG, arg0, arg2);
|
emith_read8s_r_r_r_c(DCOND_CC, RET_REG, arg0, arg2);
|
||||||
emith_ret_c(DCOND_CC);
|
emith_ret_c(DCOND_CC);
|
||||||
EMITH_SJMP_END(DCOND_CS);
|
EMITH_SJMP_END(DCOND_CS);
|
||||||
emith_move_r_r_ptr(arg1, CONTEXT_REG);
|
emith_move_r_r_ptr(arg1, CONTEXT_REG);
|
||||||
|
@ -4037,7 +4031,7 @@ static void sh2_generate_utils(void)
|
||||||
emith_sh2_rcall(arg0, arg1, arg2, arg3);
|
emith_sh2_rcall(arg0, arg1, arg2, arg3);
|
||||||
EMITH_SJMP_START(DCOND_CS);
|
EMITH_SJMP_START(DCOND_CS);
|
||||||
emith_and_r_r_c(DCOND_CC, arg0, arg3);
|
emith_and_r_r_c(DCOND_CC, arg0, arg3);
|
||||||
emith_read16_r_r_r_c(DCOND_CC, RET_REG, arg0, arg2);
|
emith_read16s_r_r_r_c(DCOND_CC, RET_REG, arg0, arg2);
|
||||||
emith_ret_c(DCOND_CC);
|
emith_ret_c(DCOND_CC);
|
||||||
EMITH_SJMP_END(DCOND_CS);
|
EMITH_SJMP_END(DCOND_CS);
|
||||||
emith_move_r_r_ptr(arg1, CONTEXT_REG);
|
emith_move_r_r_ptr(arg1, CONTEXT_REG);
|
||||||
|
|
|
@ -44,10 +44,10 @@ unsigned short scan_block(unsigned int base_pc, int is_slave,
|
||||||
#define _DRC_DECLARE_SR(SR) __DRC_DECLARE_SR(SR)
|
#define _DRC_DECLARE_SR(SR) __DRC_DECLARE_SR(SR)
|
||||||
#define DRC_DECLARE_SR _DRC_DECLARE_SR(DRC_SR_REG)
|
#define DRC_DECLARE_SR _DRC_DECLARE_SR(DRC_SR_REG)
|
||||||
#define DRC_SAVE_SR(sh2) \
|
#define DRC_SAVE_SR(sh2) \
|
||||||
if ((sh2->state & (SH2_STATE_RUN)) == SH2_STATE_RUN) \
|
if ((sh2->state & (SH2_STATE_RUN|SH2_STATE_SLEEP)) == SH2_STATE_RUN) \
|
||||||
sh2->sr = sh2_sr;
|
sh2->sr = sh2_sr;
|
||||||
#define DRC_RESTORE_SR(sh2) \
|
#define DRC_RESTORE_SR(sh2) \
|
||||||
if ((sh2->state & (SH2_STATE_RUN)) == SH2_STATE_RUN) \
|
if ((sh2->state & (SH2_STATE_RUN|SH2_STATE_SLEEP)) == SH2_STATE_RUN) \
|
||||||
sh2_sr = sh2->sr;
|
sh2_sr = sh2->sr;
|
||||||
#else
|
#else
|
||||||
#define DRC_DECLARE_SR
|
#define DRC_DECLARE_SR
|
||||||
|
|
|
@ -372,7 +372,7 @@ INLINE void BRA(sh2_state *sh2, UINT32 d)
|
||||||
#if BUSY_LOOP_HACKS
|
#if BUSY_LOOP_HACKS
|
||||||
if (disp == -2)
|
if (disp == -2)
|
||||||
{
|
{
|
||||||
UINT32 next_opcode = RW( sh2, sh2->ppc & AM );
|
UINT32 next_opcode = (UINT32)(UINT16)RW( sh2, sh2->ppc & AM );
|
||||||
/* BRA $
|
/* BRA $
|
||||||
* NOP
|
* NOP
|
||||||
*/
|
*/
|
||||||
|
@ -802,7 +802,7 @@ INLINE void DT(sh2_state *sh2, UINT32 n)
|
||||||
sh2->sr &= ~T;
|
sh2->sr &= ~T;
|
||||||
#if BUSY_LOOP_HACKS
|
#if BUSY_LOOP_HACKS
|
||||||
{
|
{
|
||||||
UINT32 next_opcode = RW( sh2, sh2->ppc & AM );
|
UINT32 next_opcode = (UINT32)(UINT16)RW( sh2, sh2->ppc & AM );
|
||||||
/* DT Rn
|
/* DT Rn
|
||||||
* BF $-2
|
* BF $-2
|
||||||
*/
|
*/
|
||||||
|
@ -1049,12 +1049,12 @@ INLINE void MAC_W(sh2_state *sh2, UINT32 m, UINT32 n)
|
||||||
INT32 tempm, tempn, dest, src, ans;
|
INT32 tempm, tempn, dest, src, ans;
|
||||||
UINT32 templ;
|
UINT32 templ;
|
||||||
|
|
||||||
tempn = (INT32) RW( sh2, sh2->r[n] );
|
tempn = (INT32)(INT16) RW( sh2, sh2->r[n] );
|
||||||
sh2->r[n] += 2;
|
sh2->r[n] += 2;
|
||||||
tempm = (INT32) RW( sh2, sh2->r[m] );
|
tempm = (INT32)(INT16) RW( sh2, sh2->r[m] );
|
||||||
sh2->r[m] += 2;
|
sh2->r[m] += 2;
|
||||||
templ = sh2->macl;
|
templ = sh2->macl;
|
||||||
tempm = ((INT32) (short) tempn * (INT32) (short) tempm);
|
tempm = (tempn * tempm);
|
||||||
if ((INT32) sh2->macl >= 0)
|
if ((INT32) sh2->macl >= 0)
|
||||||
dest = 0;
|
dest = 0;
|
||||||
else
|
else
|
||||||
|
|
|
@ -121,7 +121,7 @@ int sh2_execute_interpreter(SH2 *sh2, int cycles)
|
||||||
if (sh2->delay)
|
if (sh2->delay)
|
||||||
{
|
{
|
||||||
sh2->ppc = sh2->delay;
|
sh2->ppc = sh2->delay;
|
||||||
opcode = RW(sh2, sh2->delay);
|
opcode = (UINT32)(UINT16)RW(sh2, sh2->delay);
|
||||||
|
|
||||||
// TODO: more branch types
|
// TODO: more branch types
|
||||||
if ((opcode >> 13) == 5) { // BRA/BSR
|
if ((opcode >> 13) == 5) { // BRA/BSR
|
||||||
|
@ -139,7 +139,7 @@ int sh2_execute_interpreter(SH2 *sh2, int cycles)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sh2->ppc = sh2->pc;
|
sh2->ppc = sh2->pc;
|
||||||
opcode = RW(sh2, sh2->pc);
|
opcode = (UINT32)(UINT16)RW(sh2, sh2->pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
sh2->delay = 0;
|
sh2->delay = 0;
|
||||||
|
@ -232,13 +232,13 @@ int sh2_execute_interpreter(SH2 *sh2, int cycles)
|
||||||
if (sh2->delay)
|
if (sh2->delay)
|
||||||
{
|
{
|
||||||
sh2->ppc = sh2->delay;
|
sh2->ppc = sh2->delay;
|
||||||
opcode = RW(sh2, sh2->delay);
|
opcode = (UINT32)(UINT16)RW(sh2, sh2->delay);
|
||||||
sh2->pc -= 2;
|
sh2->pc -= 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sh2->ppc = sh2->pc;
|
sh2->ppc = sh2->pc;
|
||||||
opcode = RW(sh2, sh2->pc);
|
opcode = (UINT32)(UINT16)RW(sh2, sh2->pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
sh2->delay = 0;
|
sh2->delay = 0;
|
||||||
|
|
|
@ -1279,19 +1279,19 @@ out:
|
||||||
elprintf_sh2(sh2, EL_32X, "r8 [%08x] %02x @%06x",
|
elprintf_sh2(sh2, EL_32X, "r8 [%08x] %02x @%06x",
|
||||||
a, d, sh2_pc(sh2));
|
a, d, sh2_pc(sh2));
|
||||||
DRC_RESTORE_SR(sh2);
|
DRC_RESTORE_SR(sh2);
|
||||||
return d;
|
return (s8)d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 REGPARM(2) sh2_read8_da(u32 a, SH2 *sh2)
|
static u32 REGPARM(2) sh2_read8_da(u32 a, SH2 *sh2)
|
||||||
{
|
{
|
||||||
return sh2->data_array[(a & 0xfff) ^ 1];
|
return (s8)sh2->data_array[(a & 0xfff) ^ 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// for ssf2
|
// for ssf2
|
||||||
static u32 REGPARM(2) sh2_read8_rom(u32 a, SH2 *sh2)
|
static u32 REGPARM(2) sh2_read8_rom(u32 a, SH2 *sh2)
|
||||||
{
|
{
|
||||||
u32 bank = carthw_ssf2_banks[(a >> 19) & 7] << 19;
|
u32 bank = carthw_ssf2_banks[(a >> 19) & 7] << 19;
|
||||||
u8 *p = sh2->p_rom;
|
s8 *p = sh2->p_rom;
|
||||||
return p[(bank + (a & 0x7ffff)) ^ 1];
|
return p[(bank + (a & 0x7ffff)) ^ 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1340,18 +1340,18 @@ out:
|
||||||
a, d, sh2_pc(sh2));
|
a, d, sh2_pc(sh2));
|
||||||
out_noprint:
|
out_noprint:
|
||||||
DRC_RESTORE_SR(sh2);
|
DRC_RESTORE_SR(sh2);
|
||||||
return d;
|
return (s16)d;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 REGPARM(2) sh2_read16_da(u32 a, SH2 *sh2)
|
static u32 REGPARM(2) sh2_read16_da(u32 a, SH2 *sh2)
|
||||||
{
|
{
|
||||||
return ((u16 *)sh2->data_array)[(a & 0xffe) / 2];
|
return ((s16 *)sh2->data_array)[(a & 0xffe) / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 REGPARM(2) sh2_read16_rom(u32 a, SH2 *sh2)
|
static u32 REGPARM(2) sh2_read16_rom(u32 a, SH2 *sh2)
|
||||||
{
|
{
|
||||||
u32 bank = carthw_ssf2_banks[(a >> 19) & 7] << 19;
|
u32 bank = carthw_ssf2_banks[(a >> 19) & 7] << 19;
|
||||||
u16 *p = sh2->p_rom;
|
s16 *p = sh2->p_rom;
|
||||||
return p[(bank + (a & 0x7fffe)) / 2];
|
return p[(bank + (a & 0x7fffe)) / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1364,7 +1364,8 @@ static u32 REGPARM(2) sh2_read32_unmapped(u32 a, SH2 *sh2)
|
||||||
|
|
||||||
static u32 REGPARM(2) sh2_read32_cs0(u32 a, SH2 *sh2)
|
static u32 REGPARM(2) sh2_read32_cs0(u32 a, SH2 *sh2)
|
||||||
{
|
{
|
||||||
return (sh2_read16_cs0(a, sh2) << 16) | sh2_read16_cs0(a + 2, sh2);
|
u32 d1 = sh2_read16_cs0(a, sh2) << 16, d2 = sh2_read16_cs0(a + 2, sh2) << 16;
|
||||||
|
return d1 | (d2 >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 REGPARM(2) sh2_read32_da(u32 a, SH2 *sh2)
|
static u32 REGPARM(2) sh2_read32_da(u32 a, SH2 *sh2)
|
||||||
|
@ -1631,7 +1632,7 @@ u32 REGPARM(2) p32x_sh2_read8(u32 a, SH2 *sh2)
|
||||||
if (map_flag_set(p))
|
if (map_flag_set(p))
|
||||||
return ((sh2_read_handler *)(p << 1))(a, sh2);
|
return ((sh2_read_handler *)(p << 1))(a, sh2);
|
||||||
else
|
else
|
||||||
return *(u8 *)((p << 1) + ((a & sh2_map->mask) ^ 1));
|
return *(s8 *)((p << 1) + ((a & sh2_map->mask) ^ 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 REGPARM(2) p32x_sh2_read16(u32 a, SH2 *sh2)
|
u32 REGPARM(2) p32x_sh2_read16(u32 a, SH2 *sh2)
|
||||||
|
@ -1644,7 +1645,7 @@ u32 REGPARM(2) p32x_sh2_read16(u32 a, SH2 *sh2)
|
||||||
if (map_flag_set(p))
|
if (map_flag_set(p))
|
||||||
return ((sh2_read_handler *)(p << 1))(a, sh2);
|
return ((sh2_read_handler *)(p << 1))(a, sh2);
|
||||||
else
|
else
|
||||||
return *(u16 *)((p << 1) + (a & sh2_map->mask));
|
return *(s16 *)((p << 1) + (a & sh2_map->mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 REGPARM(2) p32x_sh2_read32(u32 a, SH2 *sh2)
|
u32 REGPARM(2) p32x_sh2_read32(u32 a, SH2 *sh2)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue