Way simpler turbo implementation

This commit is contained in:
Ilari Liusvaara 2012-03-26 20:57:48 +03:00
parent 71491a8207
commit 34b6e55dc3

View file

@ -111,53 +111,23 @@ namespace
} targetfps;
bool turboed = false;
bool turbo_saved_nominal;
bool turbo_saved_infinite;
double turbo_saved_fps;
void turbo_emulator()
{
if(turboed)
return;
turbo_saved_nominal = target_nominal;
turbo_saved_infinite = target_infinite;
turbo_saved_fps = target_fps;
target_infinite = true;
target_nominal = false;
turboed = true;
}
void unturbo_emulator()
{
if(!turboed)
return;
if(target_infinite) {
target_nominal = turbo_saved_nominal;
target_infinite = turbo_saved_infinite;
target_fps = turbo_saved_fps;
}
turboed = false;
return;
}
function_ptr_command<> tturbo("toggle-turbo", "Toggle turbo",
"Syntax: toggle-turbo\nToggle turbo mode.\n",
[]() throw(std::bad_alloc, std::runtime_error) {
if(turboed)
unturbo_emulator();
else
turbo_emulator();
turboed = !turboed;
});
function_ptr_command<> pturbo("+turbo", "Activate turbo",
"Syntax: +turbo\nActivate turbo mode.\n",
[]() throw(std::bad_alloc, std::runtime_error) {
turbo_emulator();
turboed = true;
});
function_ptr_command<> nturbo("-turbo", "Deactivate turbo",
"Syntax: -turbo\nDeactivate turbo mode.\n",
[]() throw(std::bad_alloc, std::runtime_error) {
unturbo_emulator();
turboed = false;
});
inverse_key turboh("+turbo", "Turbo on hold");
@ -199,7 +169,7 @@ void ack_frame_tick(uint64_t usec) throw()
uint64_t to_wait_frame(uint64_t usec) throw()
{
if(!frame_number || target_infinite)
if(!frame_number || target_infinite || turboed)
return 0;
uint64_t lintime = get_time(usec, true);
uint64_t frame_lasted = lintime - frame_start_times[0];