openMSX
ThrottleManager.cc
Go to the documentation of this file.
1#include "ThrottleManager.hh"
2
3namespace openmsx {
4
5// class ThrottleManager:
6
8 : throttleSetting(
9 commandController, "throttle",
10 "controls speed throttling", true, Setting::Save::NO)
11 , fullSpeedLoadingSetting(
12 commandController, "fullspeedwhenloading",
13 "sets openMSX to full speed when the MSX is loading", false)
14{
15 throttleSetting .attach(*this);
16 fullSpeedLoadingSetting.attach(*this);
17}
18
20{
21 throttleSetting .detach(*this);
22 fullSpeedLoadingSetting.detach(*this);
23}
24
25void ThrottleManager::updateStatus()
26{
27 bool newThrottle = throttleSetting.getBoolean() &&
28 (!loading || !fullSpeedLoadingSetting.getBoolean());
29 if (throttle != newThrottle) {
30 throttle = newThrottle;
31 notify();
32 }
33}
34
35void ThrottleManager::indicateLoadingState(bool state)
36{
37 if (state) {
38 ++loading;
39 } else {
40 --loading;
41 }
42 assert(loading >= 0);
43 updateStatus();
44}
45
46void ThrottleManager::update(const Setting& /*setting*/) noexcept
47{
48 updateStatus();
49}
50
51
52// class LoadingIndicator:
53
55 : throttleManager(throttleManager_)
56{
57}
58
63
64void LoadingIndicator::update(bool newState)
65{
66 if (isLoading != newState) {
67 isLoading = newState;
68 throttleManager.indicateLoadingState(isLoading);
69 }
70}
71
72} // namespace openmsx
bool getBoolean() const noexcept
LoadingIndicator(ThrottleManager &throttleManager)
void update(bool newState)
Called by the device to indicate its loading state may have changed.
void detach(Observer< T > &observer)
Definition Subject.hh:60
void attach(Observer< T > &observer)
Definition Subject.hh:54
Manages the throttle state of openMSX.
ThrottleManager(CommandController &commandController)
This file implemented 3 utility functions:
Definition Autofire.cc:11