Way simpler turbo implementation
This commit is contained in:
parent
71491a8207
commit
34b6e55dc3
1 changed files with 4 additions and 34 deletions
|
@ -111,53 +111,23 @@ namespace
|
||||||
} targetfps;
|
} targetfps;
|
||||||
|
|
||||||
bool turboed = false;
|
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",
|
function_ptr_command<> tturbo("toggle-turbo", "Toggle turbo",
|
||||||
"Syntax: toggle-turbo\nToggle turbo mode.\n",
|
"Syntax: toggle-turbo\nToggle turbo mode.\n",
|
||||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||||
if(turboed)
|
turboed = !turboed;
|
||||||
unturbo_emulator();
|
|
||||||
else
|
|
||||||
turbo_emulator();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function_ptr_command<> pturbo("+turbo", "Activate turbo",
|
function_ptr_command<> pturbo("+turbo", "Activate turbo",
|
||||||
"Syntax: +turbo\nActivate turbo mode.\n",
|
"Syntax: +turbo\nActivate turbo mode.\n",
|
||||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||||
turbo_emulator();
|
turboed = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
function_ptr_command<> nturbo("-turbo", "Deactivate turbo",
|
function_ptr_command<> nturbo("-turbo", "Deactivate turbo",
|
||||||
"Syntax: -turbo\nDeactivate turbo mode.\n",
|
"Syntax: -turbo\nDeactivate turbo mode.\n",
|
||||||
[]() throw(std::bad_alloc, std::runtime_error) {
|
[]() throw(std::bad_alloc, std::runtime_error) {
|
||||||
unturbo_emulator();
|
turboed = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
inverse_key turboh("+turbo", "Turbo on hold");
|
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()
|
uint64_t to_wait_frame(uint64_t usec) throw()
|
||||||
{
|
{
|
||||||
if(!frame_number || target_infinite)
|
if(!frame_number || target_infinite || turboed)
|
||||||
return 0;
|
return 0;
|
||||||
uint64_t lintime = get_time(usec, true);
|
uint64_t lintime = get_time(usec, true);
|
||||||
uint64_t frame_lasted = lintime - frame_start_times[0];
|
uint64_t frame_lasted = lintime - frame_start_times[0];
|
||||||
|
|
Loading…
Add table
Reference in a new issue