Added a preliminary implementation for the SLEEP opcode in SH-4 cpu. This fixes Quiz Keitai Q Mode booting [Angelo Salese]

This commit is contained in:
Angelo Salese 2009-03-24 14:00:22 +00:00
parent af6522fe8a
commit 6b27889b99
3 changed files with 16 additions and 3 deletions

View File

@ -1546,9 +1546,17 @@ INLINE void SHLR16(SH4 *sh4, UINT32 n)
/* SLEEP */
INLINE void SLEEP(SH4 *sh4)
{
/* 0 = normal mode */
/* 1 = enters into power-down mode */
/* 2 = go out the power-down mode after an exception */
if(sh4->sleep_mode != 2)
sh4->pc -= 2;
sh4->sh4_icount -= 2;
/* Wait_for_exception; */
if(sh4->sleep_mode == 0)
sh4->sleep_mode = 1;
else if(sh4->sleep_mode == 2)
sh4->sleep_mode = 0;
}
/* STC SR,Rn */
@ -3317,6 +3325,7 @@ static CPU_RESET( sh4 )
sh4->internal_irq_level = -1;
sh4->irln = 15;
sh4->sleep_mode = 0;
}
/* Execute cycles - returns number of cycles actually run */

View File

@ -212,6 +212,8 @@ void sh4_exception(SH4 *sh4, const char *message, int exception) // handle excep
/* fetch PC */
sh4->pc = sh4->vbr + vector;
/* wake up if a sleep opcode is triggered */
if(sh4->sleep_mode == 1) { sh4->sleep_mode = 2; }
}
static UINT32 compute_ticks_refresh_timer(emu_timer *timer, int hertz, int base, int divisor)

View File

@ -68,6 +68,8 @@ typedef struct
UINT32 *m;
INT8 nmi_line_state;
UINT8 sleep_mode;
int frt_input;
int irln;
int internal_irq_level;