mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
fixes for idle and other stuff
This commit is contained in:
parent
8ad1d2adf2
commit
0219d379de
6 changed files with 26 additions and 14 deletions
2
Makefile
2
Makefile
|
@ -7,7 +7,7 @@ endif
|
||||||
#CFLAGS += -DEVT_LOG
|
#CFLAGS += -DEVT_LOG
|
||||||
#CFLAGS += -DDRC_CMP
|
#CFLAGS += -DDRC_CMP
|
||||||
#cpu_cmp = 1
|
#cpu_cmp = 1
|
||||||
#drc_debug = 3
|
#drc_debug = 7
|
||||||
#profile = 1
|
#profile = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1f9661c5a2919ba91c0f4b89985e0712871e5762
|
Subproject commit 7ddcd35c8b2a8248257bd89ef989095639c29c08
|
|
@ -40012,20 +40012,18 @@ RET(8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern int SekIsIdleReady(void);
|
||||||
extern int SekIsIdleCode(unsigned short *dst, int bytes);
|
extern int SekIsIdleCode(unsigned short *dst, int bytes);
|
||||||
extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx);
|
extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx);
|
||||||
|
|
||||||
OPCODE(idle_detector_bcc8)
|
OPCODE(idle_detector_bcc8)
|
||||||
{
|
{
|
||||||
extern int idledet_start_frame;
|
|
||||||
extern char Pico[];
|
|
||||||
int frame_count, cond_true, bytes, ret, newop;
|
int frame_count, cond_true, bytes, ret, newop;
|
||||||
u16 *dest_pc;
|
u16 *dest_pc;
|
||||||
|
|
||||||
dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1);
|
dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1);
|
||||||
|
|
||||||
frame_count = *(int *)(Pico+0x22208+0x1c); // Pico.m.frame_count
|
if (!SekIsIdleReady())
|
||||||
if (frame_count < idledet_start_frame)
|
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
bytes = 0 - (s8)(Opcode & 0xFE) - 2;
|
bytes = 0 - (s8)(Opcode & 0xFE) - 2;
|
||||||
|
|
|
@ -3126,6 +3126,7 @@ int sh2_execute(SH2 *sh2c, int cycles)
|
||||||
if (ret_cycles > 0)
|
if (ret_cycles > 0)
|
||||||
dbg(1, "warning: drc returned with cycles: %d", ret_cycles);
|
dbg(1, "warning: drc returned with cycles: %d", ret_cycles);
|
||||||
|
|
||||||
|
sh2c->sr &= 0x3f3;
|
||||||
return sh2c->cycles_timeslice - ret_cycles;
|
return sh2c->cycles_timeslice - ret_cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -353,7 +353,7 @@ struct Pico
|
||||||
unsigned short vsram[0x40]; // 0x22180
|
unsigned short vsram[0x40]; // 0x22180
|
||||||
|
|
||||||
unsigned char *rom; // 0x22200
|
unsigned char *rom; // 0x22200
|
||||||
unsigned int romsize; // 0x22204
|
unsigned int romsize; // 0x22204 (on 32bits)
|
||||||
|
|
||||||
struct PicoMisc m;
|
struct PicoMisc m;
|
||||||
struct PicoVideo video;
|
struct PicoVideo video;
|
||||||
|
|
27
pico/sek.c
27
pico/sek.c
|
@ -268,7 +268,7 @@ PICO_INTERNAL void SekUnpackCpu(const unsigned char *cpu, int is_sub)
|
||||||
|
|
||||||
static unsigned short **idledet_ptrs = NULL;
|
static unsigned short **idledet_ptrs = NULL;
|
||||||
static int idledet_count = 0, idledet_bads = 0;
|
static int idledet_count = 0, idledet_bads = 0;
|
||||||
int idledet_start_frame = 0;
|
static int idledet_start_frame = 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define IDLE_STATS 1
|
#define IDLE_STATS 1
|
||||||
|
@ -312,6 +312,11 @@ void SekInitIdleDet(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SekIsIdleReady(void)
|
||||||
|
{
|
||||||
|
return (Pico.m.frame_count >= idledet_start_frame);
|
||||||
|
}
|
||||||
|
|
||||||
int SekIsIdleCode(unsigned short *dst, int bytes)
|
int SekIsIdleCode(unsigned short *dst, int bytes)
|
||||||
{
|
{
|
||||||
// printf("SekIsIdleCode %04x %i\n", *dst, bytes);
|
// printf("SekIsIdleCode %04x %i\n", *dst, bytes);
|
||||||
|
@ -322,11 +327,16 @@ int SekIsIdleCode(unsigned short *dst, int bytes)
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX) // there should be no need to wait
|
if ( (*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w); tas ($xxxx.w)
|
||||||
(*dst & 0xfff8) == 0x4a28 || // tst.b ($xxxx,a0) // for byte change anywhere
|
(*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX
|
||||||
(*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w); tas ($xxxx.w)
|
(*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX
|
||||||
(*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX
|
return 1;
|
||||||
(*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX
|
if (PicoAHW & (PAHW_MCD|PAHW_32X))
|
||||||
|
break;
|
||||||
|
// with no addons, there should be no need to wait
|
||||||
|
// for byte change anywhere
|
||||||
|
if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX)
|
||||||
|
(*dst & 0xfff8) == 0x4a28) // tst.b ($xxxx,a0)
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
|
@ -348,7 +358,9 @@ int SekIsIdleCode(unsigned short *dst, int bytes)
|
||||||
return 1;
|
return 1;
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
if ((*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX
|
if (PicoAHW & (PAHW_MCD|PAHW_32X))
|
||||||
|
break;
|
||||||
|
if ( (*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX
|
||||||
(dst[1]&0xf100) == 0x0000 && // arithmetic
|
(dst[1]&0xf100) == 0x0000 && // arithmetic
|
||||||
(dst[3]&0xf100) == 0x0000) // arithmetic
|
(dst[3]&0xf100) == 0x0000) // arithmetic
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -372,6 +384,7 @@ int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx)
|
||||||
is_main68k = ctx == &PicoCpuFM68k;
|
is_main68k = ctx == &PicoCpuFM68k;
|
||||||
#endif
|
#endif
|
||||||
pc &= ~0xff000000;
|
pc &= ~0xff000000;
|
||||||
|
if (!(newop&0x200))
|
||||||
elprintf(EL_IDLE, "idle: patch %06x %04x %04x %c %c #%i", pc, oldop, newop,
|
elprintf(EL_IDLE, "idle: patch %06x %04x %04x %c %c #%i", pc, oldop, newop,
|
||||||
(newop&0x200)?'n':'y', is_main68k?'m':'s', idledet_count);
|
(newop&0x200)?'n':'y', is_main68k?'m':'s', idledet_count);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue