fiddle around with sdl frameadvance throttle
This commit is contained in:
parent
aa90b868a1
commit
7bcc8a67f3
|
@ -11,7 +11,9 @@ static const double Normal = 1.0; // 1x speed (around 60 fps on NTSC)
|
|||
static uint64 Lasttime, Nexttime;
|
||||
static long double desired_frametime;
|
||||
static int InFrame;
|
||||
double g_fpsScale = Normal; // used by sdl.cpp
|
||||
double fps_scale = Normal; // used by sdl.cpp
|
||||
double fps_scale_frameadvance = Normal;
|
||||
double fps_scale_unpaused = Normal;
|
||||
bool MaxSpeed = false;
|
||||
|
||||
/* LOGMUL = exp(log(2) / 3)
|
||||
|
@ -31,7 +33,7 @@ void
|
|||
RefreshThrottleFPS()
|
||||
{
|
||||
uint64 fps = FCEUI_GetDesiredFPS(); // Do >> 24 to get in Hz
|
||||
desired_frametime = 16777216.0l / (fps * g_fpsScale);
|
||||
desired_frametime = 16777216.0l / (fps * fps_scale);
|
||||
|
||||
Lasttime=0;
|
||||
Nexttime=0;
|
||||
|
@ -44,7 +46,7 @@ RefreshThrottleFPS()
|
|||
int
|
||||
SpeedThrottle()
|
||||
{
|
||||
if(g_fpsScale >= 32)
|
||||
if(fps_scale >= 32)
|
||||
{
|
||||
return 0; /* Done waiting */
|
||||
}
|
||||
|
@ -92,13 +94,15 @@ SpeedThrottle()
|
|||
*/
|
||||
void IncreaseEmulationSpeed(void)
|
||||
{
|
||||
g_fpsScale *= LOGMUL;
|
||||
fps_scale_unpaused *= LOGMUL;
|
||||
|
||||
if(g_fpsScale > Fastest) g_fpsScale = Fastest;
|
||||
if(fps_scale_unpaused > Fastest) fps_scale_unpaused = Fastest;
|
||||
|
||||
fps_scale = fps_scale_unpaused;
|
||||
|
||||
RefreshThrottleFPS();
|
||||
|
||||
FCEU_DispMessage("Emulation speed %.1f%%",0, g_fpsScale*100.0);
|
||||
FCEU_DispMessage("Emulation speed %.1f%%",0, fps_scale*100.0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,9 +110,11 @@ void IncreaseEmulationSpeed(void)
|
|||
*/
|
||||
void DecreaseEmulationSpeed(void)
|
||||
{
|
||||
g_fpsScale /= LOGMUL;
|
||||
if(g_fpsScale < Slowest)
|
||||
g_fpsScale = Slowest;
|
||||
fps_scale_unpaused /= LOGMUL;
|
||||
if(fps_scale_unpaused < Slowest)
|
||||
fps_scale_unpaused = Slowest;
|
||||
|
||||
fps_scale = fps_scale_unpaused;
|
||||
|
||||
RefreshThrottleFPS();
|
||||
|
||||
|
@ -125,19 +131,19 @@ FCEUD_SetEmulationSpeed(int cmd)
|
|||
|
||||
switch(cmd) {
|
||||
case EMUSPEED_SLOWEST:
|
||||
g_fpsScale = Slowest;
|
||||
fps_scale_unpaused = Slowest;
|
||||
break;
|
||||
case EMUSPEED_SLOWER:
|
||||
DecreaseEmulationSpeed();
|
||||
break;
|
||||
case EMUSPEED_NORMAL:
|
||||
g_fpsScale = Normal;
|
||||
fps_scale_unpaused = Normal;
|
||||
break;
|
||||
case EMUSPEED_FASTER:
|
||||
IncreaseEmulationSpeed();
|
||||
break;
|
||||
case EMUSPEED_FASTEST:
|
||||
g_fpsScale = Fastest;
|
||||
fps_scale_unpaused = Fastest;
|
||||
MaxSpeed = true;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -48,8 +48,9 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
extern double g_fpsScale;
|
||||
extern double fps_scale;
|
||||
extern double fps_scale_frameadvance;
|
||||
extern double fps_scale_unpaused;
|
||||
|
||||
extern bool MaxSpeed;
|
||||
|
||||
|
@ -402,14 +403,14 @@ FCEUD_Update(uint8 *XBuf,
|
|||
|
||||
int ocount = Count;
|
||||
// apply frame scaling to Count
|
||||
Count = (int)(Count / g_fpsScale);
|
||||
Count = (int)(Count / fps_scale);
|
||||
if(Count) {
|
||||
int32 can=GetWriteSound();
|
||||
static int uflow=0;
|
||||
int32 tmpcan;
|
||||
|
||||
// don't underflow when scaling fps
|
||||
if(can >= GetMaxSound() && g_fpsScale==1.0) uflow=1; /* Go into massive underflow mode. */
|
||||
if(can >= GetMaxSound() && fps_scale==1.0) uflow=1; /* Go into massive underflow mode. */
|
||||
|
||||
if(can > Count) can=Count;
|
||||
else uflow=0;
|
||||
|
@ -422,7 +423,7 @@ FCEUD_Update(uint8 *XBuf,
|
|||
//if(uflow) puts("Underflow");
|
||||
tmpcan = GetWriteSound();
|
||||
// don't underflow when scaling fps
|
||||
if(g_fpsScale>1.0 || ((tmpcan < Count*0.90) && !uflow)) {
|
||||
if(fps_scale>1.0 || ((tmpcan < Count*0.90) && !uflow)) {
|
||||
if(XBuf && (inited&4) && !(NoWaiting & 2))
|
||||
BlitScreen(XBuf);
|
||||
Buffer+=can;
|
||||
|
|
|
@ -52,11 +52,11 @@ extern void CDLoggerROMChanged();
|
|||
extern void ResetDebugStatisticsCounters();
|
||||
extern void SetMainWindowText();
|
||||
extern bool isTaseditorRecording();
|
||||
#endif
|
||||
|
||||
extern int32 fps_scale;
|
||||
extern int32 fps_scale_unpaused;
|
||||
extern int32 fps_scale_frameadvance;
|
||||
#endif
|
||||
extern void RefreshThrottleFPS();
|
||||
|
||||
#ifdef _S9XLUA_H
|
||||
|
@ -643,24 +643,20 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
|||
// the user is holding Frame Advance key
|
||||
// clear paused flag temporarily
|
||||
EmulationPaused &= ~EMULATIONPAUSED_PAUSED;
|
||||
#ifdef WIN32
|
||||
// different emulation speed when holding Frame Advance
|
||||
if (fps_scale_frameadvance > 0)
|
||||
{
|
||||
fps_scale = fps_scale_frameadvance;
|
||||
RefreshThrottleFPS();
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (fps_scale_frameadvance > 0)
|
||||
{
|
||||
// restore emulation speed when Frame Advance is not held
|
||||
fps_scale = fps_scale_unpaused;
|
||||
RefreshThrottleFPS();
|
||||
}
|
||||
#endif
|
||||
if (EmulationPaused & EMULATIONPAUSED_PAUSED)
|
||||
{
|
||||
// emulator is paused
|
||||
|
|
Loading…
Reference in New Issue