diff --git a/controls.cpp b/controls.cpp index e81eeaf6..030a7b8c 100644 --- a/controls.cpp +++ b/controls.cpp @@ -3320,12 +3320,6 @@ void S9xControlEOF (void) do_polling(POLL_ALL); S9xMovieUpdate(); - - if(!pad_read) - IPPU.PadIgnoredFrames++; - - pad_read_last = pad_read; - pad_read = false; } void S9xSetControllerCrosshair (enum crosscontrols ctl, int8 idx, const char *fg, const char *bg) diff --git a/cpuexec.cpp b/cpuexec.cpp index 58d9f9fc..8607523d 100644 --- a/cpuexec.cpp +++ b/cpuexec.cpp @@ -188,11 +188,15 @@ #include "missing.h" #endif +static inline void StartS9xMainLoop (void); +static inline void EndS9xMainLoop (void); static inline void S9xReschedule (void); void S9xMainLoop (void) { + StartS9xMainLoop(); + for (;;) { if (CPU.NMILine) @@ -308,6 +312,26 @@ void S9xMainLoop (void) S9xSyncSpeed(); CPU.Flags &= ~SCAN_KEYS_FLAG; } + + EndS9xMainLoop(); +} + +static inline void StartS9xMainLoop (void) +{ + extern bool8 pad_read, pad_read_last; + pad_read_last = pad_read; + pad_read = FALSE; + + IPPU.InMainLoop = TRUE; +} + +static inline void EndS9xMainLoop (void) +{ + extern bool8 pad_read; + if(!pad_read) + IPPU.PadIgnoredFrames++; + + IPPU.InMainLoop = FALSE; } static inline void S9xReschedule (void) diff --git a/ppu.h b/ppu.h index d437a6cc..e471b438 100644 --- a/ppu.h +++ b/ppu.h @@ -238,6 +238,7 @@ struct InternalPPU uint32 SkippedFrames; uint32 FrameSkip; uint32 PadIgnoredFrames; + bool8 InMainLoop; }; struct SOBJ