Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit 1537301

Browse files
committed
Refactoring - removed statics from EmulationSettings
1 parent 57e509c commit 1537301

File tree

131 files changed

+1235
-1249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1235
-1249
lines changed

Core/APU.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ APU::APU(shared_ptr<Console> console)
1717

1818
_console = console;
1919
_mixer = _console->GetSoundMixer();
20+
_settings = _console->GetSettings();
2021

2122
_squareChannel[0].reset(new SquareChannel(AudioChannel::Square1, _console, _mixer.get(), true));
2223
_squareChannel[1].reset(new SquareChannel(AudioChannel::Square2, _console, _mixer.get(), false));
@@ -197,10 +198,10 @@ void APU::EndFrame()
197198
void APU::ProcessCpuClock()
198199
{
199200
if(_apuEnabled) {
200-
if(EmulationSettings::GetOverclockRate() == 100 || !EmulationSettings::GetOverclockAdjustApu()) {
201+
if(_settings->GetOverclockRate() == 100 || !_settings->GetOverclockAdjustApu()) {
201202
Exec();
202203
} else {
203-
_cyclesNeeded += 1.0 / ((double)EmulationSettings::GetOverclockRate() / 100.0);
204+
_cyclesNeeded += 1.0 / ((double)_settings->GetOverclockRate() / 100.0);
204205
while(_cyclesNeeded >= 1.0) {
205206
Exec();
206207
_cyclesNeeded--;

Core/APU.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class APU : public Snapshotable, public IMemoryHandler
3636

3737
shared_ptr<Console> _console;
3838
shared_ptr<SoundMixer> _mixer;
39+
EmulationSettings* _settings;
3940

4041
NesModel _nesModel;
4142

Core/ArkanoidController.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class ArkanoidController : public BaseControlDevice
2323

2424
void InternalSetStateFromInput() override
2525
{
26-
if(EmulationSettings::InputEnabled()) {
26+
if(_console->GetSettings()->InputEnabled()) {
2727
SetPressedState(Buttons::Fire, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
28-
SetMovement(KeyManager::GetMouseMovement(EmulationSettings::GetMouseSensitivity(MouseDevice::ArkanoidController)));
28+
SetMovement(KeyManager::GetMouseMovement(_console->GetSettings()->GetMouseSensitivity(MouseDevice::ArkanoidController)));
2929
}
3030
}
3131

@@ -50,7 +50,7 @@ class ArkanoidController : public BaseControlDevice
5050
}
5151

5252
public:
53-
ArkanoidController(uint8_t port) : BaseControlDevice(port)
53+
ArkanoidController(shared_ptr<Console> console, uint8_t port) : BaseControlDevice(console, port)
5454
{
5555
}
5656

Core/AsciiTurboFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AsciiTurboFile : public BaseControlDevice, public IBattery
2424
}
2525

2626
public:
27-
AsciiTurboFile() : BaseControlDevice(BaseControlDevice::ExpDevicePort)
27+
AsciiTurboFile(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
2828
{
2929
BatteryManager::LoadBattery(".tf", _data, AsciiTurboFile::FileSize);
3030
}

Core/AutoSaveManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ AutoSaveManager::AutoSaveManager(shared_ptr<Console> console)
1111
_autoSaveThread = std::thread([=]() {
1212
while(!_stopThread) {
1313
bool showMessage = false;
14-
uint32_t autoSaveDelay = EmulationSettings::GetAutoSaveDelay(showMessage) * 60 * 1000;
14+
uint32_t autoSaveDelay = console->GetSettings()->GetAutoSaveDelay(showMessage) * 60 * 1000;
1515
if(autoSaveDelay > 0) {
1616
if(_timer.GetElapsedMS() > autoSaveDelay) {
1717
if(!console->IsDebuggerAttached()) {

Core/AutomaticRomTest.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,26 @@ void AutomaticRomTest::ProcessNotification(ConsoleNotificationType type, void* p
103103

104104
int32_t AutomaticRomTest::Run(string filename)
105105
{
106-
EmulationSettings::SetMasterVolume(0);
107106
_console.reset(new Console());
107+
EmulationSettings* settings = _console->GetSettings();
108+
settings->SetMasterVolume(0);
108109
_console->GetNotificationManager()->RegisterNotificationListener(shared_from_this());
109110
if(_console->Initialize(filename)) {
110111
_console->GetControlManager()->RegisterInputProvider(this);
111112

112-
EmulationSettings::SetFlags(EmulationFlags::ForceMaxSpeed);
113-
EmulationSettings::ClearFlags(EmulationFlags::Paused);
113+
settings->SetFlags(EmulationFlags::ForceMaxSpeed);
114+
settings->ClearFlags(EmulationFlags::Paused);
114115
_signal.Wait();
115116

116-
EmulationSettings::SetFlags(EmulationFlags::Paused);
117+
settings->SetFlags(EmulationFlags::Paused);
117118

118119
if(_console->GetFrameCount() < 1800) {
119120
//Finished early
120121
_errorCode |= 0x10;
121122
}
122123

123-
EmulationSettings::ClearFlags(EmulationFlags::ForceMaxSpeed);
124-
EmulationSettings::SetMasterVolume(1.0);
124+
settings->ClearFlags(EmulationFlags::ForceMaxSpeed);
125+
settings->SetMasterVolume(1.0);
125126

126127
_console->GetControlManager()->UnregisterInputProvider(this);
127128
_console->Stop();

Core/AviRecorder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ AviRecorder::~AviRecorder()
2929
uint32_t AviRecorder::GetFps()
3030
{
3131
if(_console->GetModel() == NesModel::NTSC) {
32-
return EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode) ? 60000000 : 60098812;
32+
return _console->GetSettings()->CheckFlag(EmulationFlags::IntegerFpsMode) ? 60000000 : 60098812;
3333
} else {
34-
return EmulationSettings::CheckFlag(EmulationFlags::IntegerFpsMode) ? 50000000 : 50006978;
34+
return _console->GetSettings()->CheckFlag(EmulationFlags::IntegerFpsMode) ? 50000000 : 50006978;
3535
}
3636
}
3737

Core/BandaiHyperShot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class BandaiHyperShot : public StandardController
2525
{
2626
StandardController::InternalSetStateFromInput();
2727

28-
if(EmulationSettings::InputEnabled()) {
28+
if(_console->GetSettings()->InputEnabled()) {
2929
SetPressedState(ZapperButtons::Fire, KeyManager::IsMouseButtonPressed(MouseButton::LeftButton));
3030

3131
MousePosition pos = KeyManager::GetMousePosition();

Core/BandaiKaraoke.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class BandaiKaraoke : public BaseMapper
2323
SelectPRGPage(1, 0x07);
2424
SelectCHRPage(0, 0);
2525

26-
_mapperControlDevice.reset(new BandaiMicrophone(_console, EmulationSettings::GetControllerKeys(0)));
26+
_mapperControlDevice.reset(new BandaiMicrophone(_console, _console->GetSettings()->GetControllerKeys(0)));
2727
}
2828

2929
uint8_t ReadRegister(uint16_t addr) override

Core/BandaiMicrophone.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
class BandaiMicrophone : public BaseControlDevice
77
{
88
protected:
9-
shared_ptr<Console> _console;
10-
119
enum Buttons { A, B, Microphone };
1210

1311
string GetKeyNames() override
@@ -18,7 +16,7 @@ class BandaiMicrophone : public BaseControlDevice
1816
void InternalSetStateFromInput() override
1917
{
2018
//Make sure the key bindings are properly updated (not ideal, but good enough)
21-
_keyMappings = EmulationSettings::GetControllerKeys(0).GetKeyMappingArray();
19+
_keyMappings = _console->GetSettings()->GetControllerKeys(0).GetKeyMappingArray();
2220

2321
for(KeyMapping keyMapping : _keyMappings) {
2422
SetPressedState(Buttons::A, keyMapping.BandaiMicrophoneButtons[0]);
@@ -31,7 +29,7 @@ class BandaiMicrophone : public BaseControlDevice
3129
}
3230

3331
public:
34-
BandaiMicrophone(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(BaseControlDevice::MapperInputPort, keyMappings)
32+
BandaiMicrophone(shared_ptr<Console> console, KeyMappingSet keyMappings) : BaseControlDevice(console, BaseControlDevice::MapperInputPort, keyMappings)
3533
{
3634
}
3735

0 commit comments

Comments
 (0)