openMSX
SpeedManager.cc
Go to the documentation of this file.
1 #include "SpeedManager.hh"
2 
3 #include "CommandController.hh"
4 
5 
6 namespace openmsx {
7 
8 // class SpeedManager:
9 
11  : speedSetting(commandController, "speed",
12  "controls the emulation speed: higher is faster, 100 is normal",
13  100, 1, 10000, Setting::DONT_SAVE)
14  , fastforwardSpeedSetting(commandController, "fastforwardspeed",
15  "controls the emulation speed in fastforward mode: "
16  "higher is faster, 100 is normal",
17  2000, 1, 10000)
18  , fastforwardSetting(commandController, "fastforward",
19  "select emulation speed:\n"
20  " on -> fastforward speed ('fastforwardspeed' setting)\n"
21  " off -> normal speed ('speed' setting)",
22  false, Setting::DONT_SAVE)
23 {
24  speedSetting.attach(*this);
25  fastforwardSpeedSetting.attach(*this);
26  fastforwardSetting.attach(*this);
27 }
28 
30 {
31  fastforwardSetting.detach(*this);
32  fastforwardSpeedSetting.detach(*this);
33  speedSetting.detach(*this);
34 }
35 
36 void SpeedManager::updateSpeed()
37 {
38  speed = (fastforwardSetting.getBoolean() ? fastforwardSpeedSetting : speedSetting)
39  .getInt() / 100.0;
40  notify();
41 }
42 
43 void SpeedManager::update(const Setting& /*setting*/)
44 {
45  updateSpeed();
46 }
47 
48 } // namespace openmsx
openmsx::SpeedManager::~SpeedManager
~SpeedManager()
Definition: SpeedManager.cc:29
openmsx::Subject::detach
void detach(Observer< T > &observer)
Definition: Subject.hh:56
openmsx::CommandController
Definition: CommandController.hh:18
openmsx::Subject::attach
void attach(Observer< T > &observer)
Definition: Subject.hh:50
openmsx::Setting
Definition: Setting.hh:120
CommandController.hh
openmsx::SpeedManager::SpeedManager
SpeedManager(CommandController &commandController)
Definition: SpeedManager.cc:10
openmsx::Subject< SpeedManager >::notify
void notify() const
Definition: Subject.hh:67
SpeedManager.hh
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::BooleanSetting::getBoolean
bool getBoolean() const noexcept
Definition: BooleanSetting.hh:17