sh2, fix for interpreter crash if drc is compiled in too

This commit is contained in:
kub 2020-07-09 08:40:35 +02:00
parent 1426b7569e
commit b1ccc27109
3 changed files with 7 additions and 3 deletions

View file

@ -5392,7 +5392,10 @@ int sh2_execute_drc(SH2 *sh2c, int cycles)
// others are usual SH2 flags // others are usual SH2 flags
sh2c->sr &= 0x3f3; sh2c->sr &= 0x3f3;
sh2c->sr |= cycles << 12; sh2c->sr |= cycles << 12;
sh2c->state |= SH2_IN_DRC;
sh2_drc_entry(sh2c); sh2_drc_entry(sh2c);
sh2c->state &= ~SH2_IN_DRC;
// TODO: irq cycles // TODO: irq cycles
ret_cycles = (int32_t)sh2c->sr >> 12; ret_cycles = (int32_t)sh2c->sr >> 12;

View file

@ -72,11 +72,11 @@ extern void REGPARM(1) (*sh2_drc_restore_sr)(SH2 *sh2);
#define DRC_DECLARE_SR register long _sh2_sr asm(DRC_SR_REG) #define DRC_DECLARE_SR register long _sh2_sr asm(DRC_SR_REG)
#endif #endif
#define DRC_SAVE_SR(sh2) \ #define DRC_SAVE_SR(sh2) \
if (likely((sh2->state&(SH2_STATE_RUN|SH2_STATE_SLEEP)) == SH2_STATE_RUN)) \ if (likely(sh2->state & SH2_IN_DRC)) \
sh2->sr = (s32)_sh2_sr sh2->sr = (s32)_sh2_sr
// sh2_drc_save_sr(sh2) // sh2_drc_save_sr(sh2)
#define DRC_RESTORE_SR(sh2) \ #define DRC_RESTORE_SR(sh2) \
if (likely((sh2->state&(SH2_STATE_RUN|SH2_STATE_SLEEP)) == SH2_STATE_RUN)) \ if (likely(sh2->state & SH2_IN_DRC)) \
_sh2_sr = (s32)sh2->sr _sh2_sr = (s32)sh2->sr
// sh2_drc_restore_sr(sh2) // sh2_drc_restore_sr(sh2)
#else #else

View file

@ -48,7 +48,8 @@ typedef struct SH2_
#define SH2_STATE_CPOLL (1 << 2) // polling comm regs #define SH2_STATE_CPOLL (1 << 2) // polling comm regs
#define SH2_STATE_VPOLL (1 << 3) // polling VDP #define SH2_STATE_VPOLL (1 << 3) // polling VDP
#define SH2_STATE_RPOLL (1 << 4) // polling address in SDRAM #define SH2_STATE_RPOLL (1 << 4) // polling address in SDRAM
#define SH2_TIMER_RUN (1 << 8) // SOC WDT timer is running #define SH2_TIMER_RUN (1 << 7) // SOC WDT timer is running
#define SH2_IN_DRC (1 << 8) // DRC in use
unsigned int state; unsigned int state;
uint32_t poll_addr; uint32_t poll_addr;
int poll_cycles; int poll_cycles;