diff --git a/src/drivers/libretro/libretro.c b/src/drivers/libretro/libretro.c index df196b4..d236d9f 100644 --- a/src/drivers/libretro/libretro.c +++ b/src/drivers/libretro/libretro.c @@ -55,6 +55,7 @@ unsigned overclocked = 0; unsigned skip_7bit_overclocking = 1; unsigned normal_scanlines = 240; unsigned extrascanlines = 0; +unsigned overclock_state = -1; int FCEUnetplay; #ifdef PSP @@ -823,7 +824,6 @@ static const keymap bindmap[] = { static void check_variables(bool startup) { - static int overclock_state = -1; struct retro_variable var = {0}; struct retro_system_av_info av_info; bool geometry_update = false; diff --git a/src/fceu.c b/src/fceu.c index 124971f..638f2c7 100644 --- a/src/fceu.c +++ b/src/fceu.c @@ -462,7 +462,7 @@ void FCEU_ResetVidSys(void) PAL = w ? 1 : 0; - totalscanlines = normal_scanlines + (overclocked ? extrascanlines : 0); + totalscanlines = normal_scanlines + (overclock_state ? extrascanlines : 0); FCEUPPU_SetVideoSystem(w); SetSoundVariables(); diff --git a/src/fceu.h b/src/fceu.h index 1b398db..d6d6eca 100644 --- a/src/fceu.h +++ b/src/fceu.h @@ -5,6 +5,7 @@ extern int fceuindbg; +extern unsigned overclock_state; extern unsigned overclocked; extern unsigned skip_7bit_overclocking; extern unsigned DMC_7bit; diff --git a/src/ppu.c b/src/ppu.c index 7a48547..908f5a6 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -1216,14 +1216,28 @@ int FCEUPPU_Loop(int skip) { if (DMC_7bit && skip_7bit_overclocking) totalscanlines = normal_scanlines; else - totalscanlines = normal_scanlines + (overclocked ? extrascanlines : 0); + totalscanlines = normal_scanlines + (overclock_state ? extrascanlines : 0); for (scanline = 0; scanline < totalscanlines; ) { //scanline is incremented in DoLine. Evil. :/ deempcnt[deemp]++; if ((PPUViewer) && (scanline == PPUViewScanline)) UpdatePPUView(1); DoLine(); + if (scanline < normal_scanlines || scanline == totalscanlines) + overclocked = 0; + else + { + if (DMC_7bit && skip_7bit_overclocking) /* 7bit sample started after 240th line */ + break; + overclocked = 1; + } } - + /* For Debugging + * FCEU_printf("Overclock State:%d DMC+7bit:%d Skip_7bit_OC:%d\n", + * overclock_state,DMC_7bit,skip_7bit_overclocking); + * FCEU_printf("SL:%d N_SL:%d, T_SL:%d Overclocked(for FCEU_SoundCPUHook):%d\n\n", + * scanline,normal_scanlines,totalscanlines,overclocked); + */ + DMC_7bit = 0; if (MMC5Hack && (ScreenON || SpriteON)) MMC5_hb(scanline); for (x = 1, max = 0, maxref = 0; x < 7; x++) { if (deempcnt[x] > max) { diff --git a/src/x6502.c b/src/x6502.c index 3415744..2143181 100644 --- a/src/x6502.c +++ b/src/x6502.c @@ -606,7 +606,8 @@ void X6502_Run(int32 cycles) temp = _tcount; _tcount = 0; if (MapIRQHook) MapIRQHook(temp); - FCEU_SoundCPUHook(temp); + if (!overclocked) + FCEU_SoundCPUHook(temp); X.PC = pbackus; _PC++; switch (b1) {