For Qt GUI, implemented a new method of timing frame advance hold delay so that the delay time is more constant with changing emulation speed.
This commit is contained in:
parent
4352fd8da0
commit
e0f9754e80
|
@ -4162,6 +4162,11 @@ void consoleWin_t::loadMostRecentROM(void)
|
|||
fceuWrapperUnLock();
|
||||
}
|
||||
|
||||
int consoleWin_t::getPeriodicInterval(void)
|
||||
{
|
||||
return gameTimer->interval();
|
||||
}
|
||||
|
||||
void consoleWin_t::transferVideoBuffer(void)
|
||||
{
|
||||
if ( nes_shm->blitUpdated )
|
||||
|
|
|
@ -175,6 +175,8 @@ class consoleWin_t : public QMainWindow
|
|||
|
||||
void OpenHelpWindow(std::string subpage = "");
|
||||
|
||||
int getPeriodicInterval(void);
|
||||
|
||||
protected:
|
||||
consoleMenuBar *menubar;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
int NoWaiting = 0;
|
||||
extern Config *g_config;
|
||||
extern bool bindSavestate, frameAdvanceLagSkip, lagCounterDisplay;
|
||||
unsigned int frameAdvHoldTimer = 0;
|
||||
|
||||
/* UsrInputType[] is user-specified. CurInputType[] is current
|
||||
(game loading can override user settings)
|
||||
|
@ -989,10 +990,15 @@ static void KeyboardCommands(void)
|
|||
{
|
||||
if (frameAdvancing == false)
|
||||
{
|
||||
frameAdvHoldTimer = 0;
|
||||
FCEUI_FrameAdvance();
|
||||
frameAdvancing = true;
|
||||
//printf("Frame Advance Start\n");
|
||||
}
|
||||
if ( consoleWindow )
|
||||
{
|
||||
frameAdvHoldTimer += consoleWindow->getPeriodicInterval();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1000,6 +1006,7 @@ static void KeyboardCommands(void)
|
|||
{
|
||||
FCEUI_FrameAdvanceEnd();
|
||||
frameAdvancing = false;
|
||||
frameAdvHoldTimer = 0;
|
||||
//printf("Frame Advance End\n");
|
||||
}
|
||||
}
|
||||
|
|
13
src/fceu.cpp
13
src/fceu.cpp
|
@ -717,8 +717,7 @@ void UpdateAutosave(void);
|
|||
|
||||
|
||||
#ifdef __QT_DRIVER__
|
||||
double getFrameRate(void);
|
||||
double getBaseFrameRate(void);
|
||||
extern unsigned int frameAdvHoldTimer;
|
||||
#endif
|
||||
|
||||
///Emulates a single frame.
|
||||
|
@ -733,18 +732,20 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
|||
if (frameAdvanceRequested)
|
||||
{
|
||||
#ifdef __QT_DRIVER__
|
||||
double baseFrameRatio = getFrameRate() / getBaseFrameRate();
|
||||
|
||||
int32_t frameAdvanceDelayScaled = (int32_t)( (double)frameAdvance_Delay * baseFrameRatio);
|
||||
uint32_t frameAdvanceDelayScaled = frameAdvance_Delay * (PAL ? 20 : 16);
|
||||
|
||||
if ( frameAdvanceDelayScaled < 1 )
|
||||
{
|
||||
frameAdvanceDelayScaled = 1;
|
||||
}
|
||||
if (frameAdvance_Delay_count == 0 || frameAdvance_Delay_count >= frameAdvanceDelayScaled)
|
||||
if ( (frameAdvance_Delay_count == 0) || (frameAdvHoldTimer >= frameAdvanceDelayScaled) )
|
||||
{
|
||||
EmulationPaused = EMULATIONPAUSED_FA;
|
||||
}
|
||||
if (frameAdvance_Delay_count < frameAdvanceDelayScaled)
|
||||
{
|
||||
frameAdvance_Delay_count++;
|
||||
}
|
||||
#else
|
||||
if (frameAdvance_Delay_count == 0 || frameAdvance_Delay_count >= frameAdvance_Delay)
|
||||
EmulationPaused = EMULATIONPAUSED_FA;
|
||||
|
|
Loading…
Reference in New Issue