mirror of https://github.com/stella-emu/stella.git
added emulation speed hotkeys
This commit is contained in:
parent
70fe5981f2
commit
5c9a73c530
|
@ -1767,7 +1767,17 @@
|
|||
<td>Backspace</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Toggle 'Turbo' mode</td>
|
||||
<td><i>Decrease</i> emulation speed (disables 'Turbo' mode)</td>
|
||||
<td>Shift-Control + s</td>
|
||||
<td>Shift-Control + s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i>Increase</i> emulation speed (disables 'Turbo' mode)</td>
|
||||
<td>Control + s</td>
|
||||
<td>Control + s</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Toggle 'Turbo' mode (maximum emulation speed)</td>
|
||||
<td>Control + t</td>
|
||||
<td>Control + t</td>
|
||||
</tr>
|
||||
|
|
|
@ -525,6 +525,8 @@ PhysicalKeyboardHandler::EventMappingArray PhysicalKeyboardHandler::DefaultCommo
|
|||
{Event::SettingIncrease, KBDK_KP_9, KBDM_CTRL},
|
||||
|
||||
{Event::ToggleInter, KBDK_I, KBDM_CTRL},
|
||||
{Event::DecreaseSpeed, KBDK_S, KBDM_SHIFT | KBDM_CTRL},
|
||||
{Event::IncreaseSpeed, KBDK_S, KBDM_CTRL },
|
||||
{Event::ToggleTurbo, KBDK_T, KBDM_CTRL},
|
||||
{Event::ToggleJitter, KBDK_J, MOD3},
|
||||
{Event::ToggleFrameStats, KBDK_L, MOD3},
|
||||
|
|
|
@ -73,6 +73,45 @@
|
|||
|
||||
#include "Console.hxx"
|
||||
|
||||
namespace {
|
||||
// Emulation speed is a positive float that multiplies the framerate. However, the UI controls
|
||||
// adjust speed in terms of a speedup factor (1/10, 1/9 .. 1/2, 1, 2, 3, .., 10). The following
|
||||
// mapping and formatting functions implement this conversion. The speedup factor is represented
|
||||
// by an integer value between -900 and 900 (0 means no speedup).
|
||||
|
||||
constexpr int MAX_SPEED = 900;
|
||||
constexpr int MIN_SPEED = -900;
|
||||
constexpr int SPEED_STEP = 10;
|
||||
|
||||
int mapSpeed(float speed)
|
||||
{
|
||||
speed = std::abs(speed);
|
||||
|
||||
return BSPF::clamp(
|
||||
static_cast<int>(round(100 * (speed >= 1 ? speed - 1 : -1 / speed + 1))),
|
||||
MIN_SPEED, MAX_SPEED
|
||||
);
|
||||
}
|
||||
|
||||
float unmapSpeed(int speed)
|
||||
{
|
||||
float f_speed = static_cast<float>(speed) / 100;
|
||||
|
||||
return speed < 0 ? -1 / (f_speed - 1) : 1 + f_speed;
|
||||
}
|
||||
|
||||
string formatSpeed(int speed) {
|
||||
stringstream ss;
|
||||
|
||||
ss
|
||||
<< std::setw(3) << std::fixed << std::setprecision(0)
|
||||
<< (unmapSpeed(speed) * 100);
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
||||
const Properties& props, AudioSettings& audioSettings)
|
||||
|
@ -503,6 +542,31 @@ void Console::toggleTurbo()
|
|||
myOSystem.frameBuffer().showMessage(ss.str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::changeSpeed(int direction)
|
||||
{
|
||||
int speed = mapSpeed(myOSystem.settings().getFloat("speed"));
|
||||
bool turbo = myOSystem.settings().getBool("turbo");
|
||||
|
||||
speed = BSPF::clamp(speed + direction * SPEED_STEP, MIN_SPEED, MAX_SPEED);
|
||||
myOSystem.settings().setValue("speed", unmapSpeed(speed));
|
||||
|
||||
// update rate
|
||||
initializeAudio();
|
||||
|
||||
if(turbo)
|
||||
{
|
||||
myOSystem.settings().setValue("turbo", false);
|
||||
// update VSync
|
||||
initializeVideo();
|
||||
}
|
||||
|
||||
ostringstream val;
|
||||
|
||||
val << formatSpeed(speed) << "%";
|
||||
myOSystem.frameBuffer().showMessage("Emulation speed", val.str(), speed, MIN_SPEED, MAX_SPEED);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Console::togglePhosphor()
|
||||
{
|
||||
|
@ -890,9 +954,8 @@ void Console::changeAutoFireRate(int direction)
|
|||
if(rate)
|
||||
val << rate << " Hz";
|
||||
else
|
||||
{
|
||||
val << "Off";
|
||||
}
|
||||
|
||||
myOSystem.frameBuffer().showMessage("Autofire rate", val.str(), rate, 0, isNTSC ? 30 : 25);
|
||||
}
|
||||
|
||||
|
|
|
@ -213,6 +213,12 @@ class Console : public Serializable, public ConsoleIO
|
|||
*/
|
||||
void toggleTurbo();
|
||||
|
||||
/**
|
||||
Change emulation speed
|
||||
|
||||
@param direction +1 indicates increase, -1 indicates decrease.
|
||||
*/
|
||||
void changeSpeed(int direction = +1);
|
||||
|
||||
/**
|
||||
Toggles phosphor effect.
|
||||
|
|
|
@ -127,6 +127,7 @@ class Event
|
|||
PreviousSettingGroup, NextSettingGroup,
|
||||
TogglePlayBackMode,
|
||||
DecreaseAutoFire, IncreaseAutoFire,
|
||||
DecreaseSpeed, IncreaseSpeed,
|
||||
|
||||
LastType
|
||||
};
|
||||
|
|
|
@ -1220,6 +1220,14 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Misc events
|
||||
|
||||
case Event::DecreaseSpeed:
|
||||
if(pressed) myOSystem.console().changeSpeed(-1);
|
||||
return;
|
||||
|
||||
case Event::IncreaseSpeed:
|
||||
if(pressed) myOSystem.console().changeSpeed(+1);
|
||||
return;
|
||||
|
||||
case Event::ToggleTurbo:
|
||||
if (pressed && !repeated) myOSystem.console().toggleTurbo();
|
||||
return;
|
||||
|
@ -2403,7 +2411,9 @@ EventHandler::EmulActionList EventHandler::ourEmulActionList = { {
|
|||
{ Event::TogglePauseMode, "Toggle Pause mode", "" },
|
||||
{ Event::StartPauseMode, "Start Pause mode", "" },
|
||||
{ Event::Fry, "Fry cartridge", "" },
|
||||
{ Event::ToggleTurbo, "Toggle Turbo mode", "" },
|
||||
{ Event::DecreaseSpeed, "Decrease emulation speed", "" },
|
||||
{ Event::IncreaseSpeed, "Increase emulation speed", "" },
|
||||
{ Event::ToggleTurbo, "Toggle 'Turbo' mode", "" },
|
||||
{ Event::DebuggerMode, "Toggle Debugger mode", "" },
|
||||
|
||||
{ Event::ConsoleSelect, "Select", "" },
|
||||
|
@ -2634,7 +2644,7 @@ EventHandler::MenuActionList EventHandler::ourMenuActionList = { {
|
|||
const Event::EventSet EventHandler::MiscEvents = {
|
||||
Event::Quit, Event::ReloadConsole, Event::Fry, Event::StartPauseMode,
|
||||
Event::TogglePauseMode, Event::OptionsMenuMode, Event::CmdMenuMode, Event::ExitMode,
|
||||
Event::ToggleTurbo,
|
||||
Event::ToggleTurbo, Event::DecreaseSpeed, Event::IncreaseSpeed,
|
||||
Event::TakeSnapshot, Event::ToggleContSnapshots, Event::ToggleContSnapshotsFrame,
|
||||
// Event::MouseAxisXMove, Event::MouseAxisYMove,
|
||||
// Event::MouseButtonLeftValue, Event::MouseButtonRightValue,
|
||||
|
|
|
@ -558,7 +558,7 @@ class EventHandler
|
|||
#else
|
||||
REFRESH_SIZE = 0,
|
||||
#endif
|
||||
EMUL_ACTIONLIST_SIZE = 162 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
|
||||
EMUL_ACTIONLIST_SIZE = 164 + PNG_SIZE + COMBO_SIZE + REFRESH_SIZE,
|
||||
MENU_ACTIONLIST_SIZE = 18
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in New Issue