X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FSek.c;h=73b7b7cb6b92fa55aff04e6c0e83005ad0a876e2;hb=5f9a0d16309e732ad09b4f5827422cf658bed8c2;hp=cb76ea8337f6a19db7270f5a4dce9e8ff7a37118;hpb=2aa27095f2dbf5b38950fcb1f856d5ffc6a70361;p=picodrive.git diff --git a/Pico/Sek.c b/Pico/Sek.c index cb76ea8..73b7b7c 100644 --- a/Pico/Sek.c +++ b/Pico/Sek.c @@ -163,6 +163,21 @@ PICO_INTERNAL int SekReset(void) return 0; } +void SekStepM68k(void) +{ + SekCycleAim=SekCycleCnt+1; +#if defined(EMU_CORE_DEBUG) + SekCycleCnt+=CM_compareRun(1, 0); +#elif defined(EMU_C68K) + PicoCpuCM68k.cycles=1; + CycloneRun(&PicoCpuCM68k); + SekCycleCnt+=1-PicoCpuCM68k.cycles; +#elif defined(EMU_M68K) + SekCycleCnt+=m68k_execute(1); +#elif defined(EMU_F68K) + SekCycleCnt+=fm68k_emulate(1, 0); +#endif +} PICO_INTERNAL void SekSetRealTAS(int use_real) { @@ -174,6 +189,7 @@ PICO_INTERNAL void SekSetRealTAS(int use_real) #endif } + /* idle loop detection, not to be used in CD mode */ #ifdef EMU_C68K #include "cpu/Cyclone/tools/idle.h" @@ -183,8 +199,6 @@ static int *idledet_addrs = NULL; static int idledet_count = 0, idledet_bads = 0; int idledet_start_frame = 0; -static unsigned char *rom_verify = NULL; - void SekInitIdleDet(void) { void *tmp = realloc(idledet_addrs, 0x200*4); @@ -197,44 +211,49 @@ void SekInitIdleDet(void) idledet_count = idledet_bads = 0; idledet_start_frame = Pico.m.frame_count + 360; - rom_verify = realloc(rom_verify, Pico.romsize); - memcpy(rom_verify, Pico.rom, Pico.romsize); #ifdef EMU_C68K CycloneInitIdle(); #endif +#ifdef EMU_F68K + fm68k_emulate(0, 0, 1); +#endif } int SekIsIdleCode(unsigned short *dst, int bytes) { - printf("SekIsIdleCode %04x %i\n", *dst, bytes); + // printf("SekIsIdleCode %04x %i\n", *dst, bytes); switch (bytes) { case 4: - if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX) // where should be no need to wait - (*dst & 0xfff8) == 0x4a28 || // tst.b ($xxxx,a0) // for byte change anywhere - (*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w), tas ($xxxx.w) + if ( (*dst & 0xfff8) == 0x4a10 || // tst.b ($aX) // there should be no need to wait + (*dst & 0xfff8) == 0x4a28 || // tst.b ($xxxx,a0) // for byte change anywhere + (*dst & 0xff3f) == 0x4a38 || // tst.x ($xxxx.w); tas ($xxxx.w) (*dst & 0xc1ff) == 0x0038 || // move.x ($xxxx.w), dX (*dst & 0xf13f) == 0xb038) // cmp.x ($xxxx.w), dX return 1; break; case 6: - if ( ((dst[1] & 0xe0) == 0xe0 && ( // RAM - *dst == 0x4a39 || // tst.b ($xxxxxxxx) - *dst == 0x4a79 || // tst.w ($xxxxxxxx) - *dst == 0x4ab9)) || // tst.l ($xxxxxxxx) - *dst == 0x0838) // btst $X, ($xxxx.w) [6 byte op] + if ( ((dst[1] & 0xe0) == 0xe0 && ( // RAM and + *dst == 0x4a39 || // tst.b ($xxxxxxxx) + *dst == 0x4a79 || // tst.w ($xxxxxxxx) + *dst == 0x4ab9 || // tst.l ($xxxxxxxx) + (*dst & 0xc1ff) == 0x0039 || // move.x ($xxxxxxxx), dX + (*dst & 0xf13f) == 0xb039))||// cmp.x ($xxxxxxxx), dX + *dst == 0x0838 || // btst $X, ($xxxx.w) [6 byte op] + (*dst & 0xffbf) == 0x0c38) // cmpi.{b,w} $X, ($xxxx.w) return 1; break; case 8: - if ( (dst[2] & 0xe0) == 0xe0 && ( // RAM - *dst == 0x0839 || // btst $X, ($xxxxxxxx.w) [8 byte op] - (*dst & 0xffbf) == 0x0c39)) // cmpi.{b,w} $X, ($xxxxxxxx) + if ( ((dst[2] & 0xe0) == 0xe0 && ( // RAM and + *dst == 0x0839 || // btst $X, ($xxxxxxxx.w) [8 byte op] + (*dst & 0xffbf) == 0x0c39))||// cmpi.{b,w} $X, ($xxxxxxxx) + *dst == 0x0cb8) // cmpi.l $X, ($xxxx.w) return 1; break; case 12: if ((*dst & 0xf1f8) == 0x3010 && // move.w (aX), dX - (dst[1]&0xf100) == 0x0000 && // arithmetic - (dst[3]&0xf100) == 0x0000) // arithmetic + (dst[1]&0xf100) == 0x0000 && // arithmetic + (dst[3]&0xf100) == 0x0000) // arithmetic return 1; break; } @@ -249,7 +268,7 @@ int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop) #endif pc &= ~0xff000000; elprintf(EL_IDLE, "idle: patch %06x %04x %04x #%i", pc, oldop, newop, idledet_count); - if (pc > Pico.romsize) { + if (pc > Pico.romsize && !(PicoAHW & PAHW_SVP)) { if (++idledet_bads > 128) return 2; // remove detector return 1; // don't patch } @@ -260,15 +279,19 @@ int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop) idledet_addrs = tmp; } - idledet_addrs[idledet_count++] = pc; + if (pc < Pico.romsize) + idledet_addrs[idledet_count++] = pc; + return 0; } void SekFinishIdleDet(void) { - int done_something = idledet_count > 0; #ifdef EMU_C68K CycloneFinishIdle(); +#endif +#ifdef EMU_F68K + fm68k_emulate(0, 0, 2); #endif while (idledet_count > 0) { @@ -282,14 +305,6 @@ void SekFinishIdleDet(void) else elprintf(EL_STATUS|EL_IDLE, "idle: don't know how to restore %04x", *op); } - - if (done_something) - { - int i; - for (i = 0; i < Pico.romsize; i++) - if (rom_verify[i] != Pico.rom[i]) - printf("ROM corruption @ %06x!\n", i), exit(1); - } }