summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMai <mai.iam2048@gmail.com>2024-01-12 02:05:57 -0500
committerGitHub <noreply@github.com>2024-01-12 02:05:57 -0500
commitab3655fbeafe77bb9c4307fb0dd208b372a6b701 (patch)
tree4b160f0c6622352fc2262998dd19871af598f584 /Source
parentbca5b10fafd141e10dfbcade6fe2f4e61868e99a (diff)
parentf7a9ea9d7e82dfe609b17799599686c714d4d1b1 (diff)
Merge pull request #12496 from AdmiralCurtiss/globals-gba
Core/HW/GBACore: Avoid global System accessor.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/GBACore.cpp11
-rw-r--r--Source/Core/Core/HW/GBACore.h12
-rw-r--r--Source/Core/Core/HW/SI/SI_DeviceGBAEmu.cpp2
3 files changed, 17 insertions, 8 deletions
diff --git a/Source/Core/Core/HW/GBACore.cpp b/Source/Core/Core/HW/GBACore.cpp
index 887982d03d..6bb39776a3 100644
--- a/Source/Core/Core/HW/GBACore.cpp
+++ b/Source/Core/Core/HW/GBACore.cpp
@@ -149,7 +149,8 @@ static std::array<u8, 20> GetROMHash(VFile* rom)
return digest;
}
-Core::Core(int device_number) : m_device_number(device_number)
+Core::Core(::Core::System& system, int device_number)
+ : m_device_number(device_number), m_system(system)
{
mLogSetDefaultLogger(&s_stub_logger);
}
@@ -405,8 +406,7 @@ void Core::SetSampleRates()
blip_set_rates(m_core->getAudioChannel(m_core, 0), m_core->frequency(m_core), SAMPLE_RATE);
blip_set_rates(m_core->getAudioChannel(m_core, 1), m_core->frequency(m_core), SAMPLE_RATE);
- auto& system = ::Core::System::GetInstance();
- SoundStream* sound_stream = system.GetSoundStream();
+ SoundStream* sound_stream = m_system.GetSoundStream();
sound_stream->GetMixer()->SetGBAInputSampleRateDivisors(
m_device_number, Mixer::FIXED_SAMPLE_RATE_DIVIDEND / SAMPLE_RATE);
}
@@ -441,8 +441,7 @@ void Core::SetAVStream()
blip_read_samples(left, &buffer[0], SAMPLES, 1);
blip_read_samples(right, &buffer[1], SAMPLES, 1);
- auto& system = ::Core::System::GetInstance();
- SoundStream* sound_stream = system.GetSoundStream();
+ SoundStream* sound_stream = core->m_system.GetSoundStream();
sound_stream->GetMixer()->PushGBASamples(core->m_device_number, &buffer[0], SAMPLES);
};
m_core->setAVStream(m_core, &m_stream);
@@ -568,7 +567,7 @@ void Core::RunUntil(u64 gc_ticks)
if (static_cast<s64>(gc_ticks - m_last_gc_ticks) <= 0)
return;
- const u64 gc_frequency = ::Core::System::GetInstance().GetSystemTimers().GetTicksPerSecond();
+ const u64 gc_frequency = m_system.GetSystemTimers().GetTicksPerSecond();
const u32 core_frequency = GetCoreFrequency(m_core);
mTimingSchedule(m_core->timing, &m_event,
diff --git a/Source/Core/Core/HW/GBACore.h b/Source/Core/Core/HW/GBACore.h
index 79f522bd9d..3a149a54fd 100644
--- a/Source/Core/Core/HW/GBACore.h
+++ b/Source/Core/Core/HW/GBACore.h
@@ -23,6 +23,10 @@
class GBAHostInterface;
class PointerWrap;
+namespace Core
+{
+class System;
+}
namespace HW::GBA
{
@@ -50,7 +54,11 @@ struct CoreInfo
class Core final
{
public:
- explicit Core(int device_number);
+ explicit Core(::Core::System& system, int device_number);
+ Core(const Core&) = delete;
+ Core(Core&&) = delete;
+ Core& operator=(const Core&) = delete;
+ Core& operator=(Core&&) = delete;
~Core();
bool Start(u64 gc_ticks);
@@ -135,5 +143,7 @@ private:
std::condition_variable m_response_cv;
bool m_response_ready = false;
std::vector<u8> m_response;
+
+ ::Core::System& m_system;
};
} // namespace HW::GBA
diff --git a/Source/Core/Core/HW/SI/SI_DeviceGBAEmu.cpp b/Source/Core/Core/HW/SI/SI_DeviceGBAEmu.cpp
index 791b587156..4bb0e69617 100644
--- a/Source/Core/Core/HW/SI/SI_DeviceGBAEmu.cpp
+++ b/Source/Core/Core/HW/SI/SI_DeviceGBAEmu.cpp
@@ -30,7 +30,7 @@ static s64 GetSyncInterval(const SystemTimers::SystemTimersManager& timers)
CSIDevice_GBAEmu::CSIDevice_GBAEmu(Core::System& system, SIDevices device, int device_number)
: ISIDevice(system, device, device_number)
{
- m_core = std::make_shared<HW::GBA::Core>(m_device_number);
+ m_core = std::make_shared<HW::GBA::Core>(system, m_device_number);
m_core->Start(system.GetCoreTiming().GetTicks());
m_gbahost = Host_CreateGBAHost(m_core);
m_core->SetHost(m_gbahost);