revert last 3 commits, experiment failed. its always there if it proves helpful.

This commit is contained in:
zeromus 2015-06-16 06:53:43 +00:00
parent c990bb3798
commit e71e32ceb7
3 changed files with 33 additions and 42 deletions

View File

@ -11,9 +11,7 @@ static const double Normal = 1.0; // 1x speed (around 60 fps on NTSC)
static uint64 Lasttime, Nexttime; static uint64 Lasttime, Nexttime;
static long double desired_frametime; static long double desired_frametime;
static int InFrame; static int InFrame;
double fps_scale = Normal; // used by sdl.cpp double g_fpsScale = Normal; // used by sdl.cpp
double fps_scale_frameadvance = Normal;
double fps_scale_unpaused = Normal;
bool MaxSpeed = false; bool MaxSpeed = false;
/* LOGMUL = exp(log(2) / 3) /* LOGMUL = exp(log(2) / 3)
@ -33,7 +31,7 @@ void
RefreshThrottleFPS() RefreshThrottleFPS()
{ {
uint64 fps = FCEUI_GetDesiredFPS(); // Do >> 24 to get in Hz uint64 fps = FCEUI_GetDesiredFPS(); // Do >> 24 to get in Hz
desired_frametime = 16777216.0l / (fps * fps_scale); desired_frametime = 16777216.0l / (fps * g_fpsScale);
Lasttime=0; Lasttime=0;
Nexttime=0; Nexttime=0;
@ -46,7 +44,7 @@ RefreshThrottleFPS()
int int
SpeedThrottle() SpeedThrottle()
{ {
if(fps_scale >= 32) if(g_fpsScale >= 32)
{ {
return 0; /* Done waiting */ return 0; /* Done waiting */
} }
@ -94,15 +92,13 @@ SpeedThrottle()
*/ */
void IncreaseEmulationSpeed(void) void IncreaseEmulationSpeed(void)
{ {
fps_scale_unpaused *= LOGMUL; g_fpsScale *= LOGMUL;
if(fps_scale_unpaused > Fastest) fps_scale_unpaused = Fastest; if(g_fpsScale > Fastest) g_fpsScale = Fastest;
fps_scale = fps_scale_unpaused;
RefreshThrottleFPS(); RefreshThrottleFPS();
FCEU_DispMessage("Emulation speed %.1f%%",0, fps_scale*100.0); FCEU_DispMessage("Emulation speed %.1f%%",0, g_fpsScale*100.0);
} }
/** /**
@ -110,15 +106,13 @@ void IncreaseEmulationSpeed(void)
*/ */
void DecreaseEmulationSpeed(void) void DecreaseEmulationSpeed(void)
{ {
fps_scale_unpaused /= LOGMUL; g_fpsScale /= LOGMUL;
if(fps_scale_unpaused < Slowest) if(g_fpsScale < Slowest)
fps_scale_unpaused = Slowest; g_fpsScale = Slowest;
fps_scale = fps_scale_unpaused;
RefreshThrottleFPS(); RefreshThrottleFPS();
FCEU_DispMessage("Emulation speed %.1f%%",0, fps_scale*100.0); FCEU_DispMessage("Emulation speed %.1f%%",0, g_fpsScale*100.0);
} }
/** /**
@ -131,19 +125,19 @@ FCEUD_SetEmulationSpeed(int cmd)
switch(cmd) { switch(cmd) {
case EMUSPEED_SLOWEST: case EMUSPEED_SLOWEST:
fps_scale_unpaused = Slowest; g_fpsScale = Slowest;
break; break;
case EMUSPEED_SLOWER: case EMUSPEED_SLOWER:
DecreaseEmulationSpeed(); DecreaseEmulationSpeed();
break; break;
case EMUSPEED_NORMAL: case EMUSPEED_NORMAL:
fps_scale_unpaused = Normal; g_fpsScale = Normal;
break; break;
case EMUSPEED_FASTER: case EMUSPEED_FASTER:
IncreaseEmulationSpeed(); IncreaseEmulationSpeed();
break; break;
case EMUSPEED_FASTEST: case EMUSPEED_FASTEST:
fps_scale_unpaused = Fastest; g_fpsScale = Fastest;
MaxSpeed = true; MaxSpeed = true;
break; break;
default: default:
@ -152,5 +146,5 @@ FCEUD_SetEmulationSpeed(int cmd)
RefreshThrottleFPS(); RefreshThrottleFPS();
FCEU_DispMessage("Emulation speed %.1f%%",0, fps_scale*100.0); FCEU_DispMessage("Emulation speed %.1f%%",0, g_fpsScale*100.0);
} }

View File

@ -48,9 +48,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
extern double fps_scale;
extern double fps_scale_frameadvance; extern double g_fpsScale;
extern double fps_scale_unpaused;
extern bool MaxSpeed; extern bool MaxSpeed;
@ -403,14 +402,14 @@ FCEUD_Update(uint8 *XBuf,
int ocount = Count; int ocount = Count;
// apply frame scaling to Count // apply frame scaling to Count
Count = (int)(Count / fps_scale); Count = (int)(Count / g_fpsScale);
if(Count) { if(Count) {
int32 can=GetWriteSound(); int32 can=GetWriteSound();
static int uflow=0; static int uflow=0;
int32 tmpcan; int32 tmpcan;
// don't underflow when scaling fps // don't underflow when scaling fps
if(can >= GetMaxSound() && fps_scale==1.0) uflow=1; /* Go into massive underflow mode. */ if(can >= GetMaxSound() && g_fpsScale==1.0) uflow=1; /* Go into massive underflow mode. */
if(can > Count) can=Count; if(can > Count) can=Count;
else uflow=0; else uflow=0;
@ -423,7 +422,7 @@ FCEUD_Update(uint8 *XBuf,
//if(uflow) puts("Underflow"); //if(uflow) puts("Underflow");
tmpcan = GetWriteSound(); tmpcan = GetWriteSound();
// don't underflow when scaling fps // don't underflow when scaling fps
if(fps_scale>1.0 || ((tmpcan < Count*0.90) && !uflow)) { if(g_fpsScale>1.0 || ((tmpcan < Count*0.90) && !uflow)) {
if(XBuf && (inited&4) && !(NoWaiting & 2)) if(XBuf && (inited&4) && !(NoWaiting & 2))
BlitScreen(XBuf); BlitScreen(XBuf);
Buffer+=can; Buffer+=can;

View File

@ -43,26 +43,20 @@
#include "file.h" #include "file.h"
#include "vsuni.h" #include "vsuni.h"
#include "ines.h" #include "ines.h"
#ifdef WIN32 #ifdef WIN32
#include "drivers/win/pref.h" #include "drivers/win/pref.h"
#include "utils/xstring.h" #include "utils/xstring.h"
extern void CDLoggerROMClosed(); extern void CDLoggerROMClosed();
extern void CDLoggerROMChanged(); extern void CDLoggerROMChanged();
extern void ResetDebugStatisticsCounters(); extern void ResetDebugStatisticsCounters();
extern void SetMainWindowText(); extern void SetMainWindowText();
extern bool isTaseditorRecording(); extern bool isTaseditorRecording();
extern int32 fps_scale; extern int32 fps_scale;
extern int32 fps_scale_unpaused; extern int32 fps_scale_unpaused;
extern int32 fps_scale_frameadvance; extern int32 fps_scale_frameadvance;
#else
extern int32 fps_scale;
extern int32 fps_scale_unpaused;
extern int32 fps_scale_frameadvance;
#endif #endif
extern void RefreshThrottleFPS(); extern void RefreshThrottleFPS();
#ifdef _S9XLUA_H #ifdef _S9XLUA_H
@ -649,20 +643,24 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
// the user is holding Frame Advance key // the user is holding Frame Advance key
// clear paused flag temporarily // clear paused flag temporarily
EmulationPaused &= ~EMULATIONPAUSED_PAUSED; EmulationPaused &= ~EMULATIONPAUSED_PAUSED;
#ifdef WIN32
// different emulation speed when holding Frame Advance // different emulation speed when holding Frame Advance
if (fps_scale_frameadvance > 0) if (fps_scale_frameadvance > 0)
{ {
fps_scale = fps_scale_frameadvance; fps_scale = fps_scale_frameadvance;
RefreshThrottleFPS(); RefreshThrottleFPS();
} }
#endif
} else } else
{ {
#ifdef WIN32
if (fps_scale_frameadvance > 0) if (fps_scale_frameadvance > 0)
{ {
// restore emulation speed when Frame Advance is not held // restore emulation speed when Frame Advance is not held
fps_scale = fps_scale_unpaused; fps_scale = fps_scale_unpaused;
RefreshThrottleFPS(); RefreshThrottleFPS();
} }
#endif
if (EmulationPaused & EMULATIONPAUSED_PAUSED) if (EmulationPaused & EMULATIONPAUSED_PAUSED)
{ {
// emulator is paused // emulator is paused