Core/HW/GBACore: Avoid global System accessor.
This commit is contained in:
parent
c3b8aa1fe5
commit
f7a9ea9d7e
|
@ -149,7 +149,8 @@ static std::array<u8, 20> GetROMHash(VFile* rom)
|
||||||
return digest;
|
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);
|
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, 0), m_core->frequency(m_core), SAMPLE_RATE);
|
||||||
blip_set_rates(m_core->getAudioChannel(m_core, 1), 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 = m_system.GetSoundStream();
|
||||||
SoundStream* sound_stream = system.GetSoundStream();
|
|
||||||
sound_stream->GetMixer()->SetGBAInputSampleRateDivisors(
|
sound_stream->GetMixer()->SetGBAInputSampleRateDivisors(
|
||||||
m_device_number, Mixer::FIXED_SAMPLE_RATE_DIVIDEND / SAMPLE_RATE);
|
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(left, &buffer[0], SAMPLES, 1);
|
||||||
blip_read_samples(right, &buffer[1], SAMPLES, 1);
|
blip_read_samples(right, &buffer[1], SAMPLES, 1);
|
||||||
|
|
||||||
auto& system = ::Core::System::GetInstance();
|
SoundStream* sound_stream = core->m_system.GetSoundStream();
|
||||||
SoundStream* sound_stream = system.GetSoundStream();
|
|
||||||
sound_stream->GetMixer()->PushGBASamples(core->m_device_number, &buffer[0], SAMPLES);
|
sound_stream->GetMixer()->PushGBASamples(core->m_device_number, &buffer[0], SAMPLES);
|
||||||
};
|
};
|
||||||
m_core->setAVStream(m_core, &m_stream);
|
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)
|
if (static_cast<s64>(gc_ticks - m_last_gc_ticks) <= 0)
|
||||||
return;
|
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);
|
const u32 core_frequency = GetCoreFrequency(m_core);
|
||||||
|
|
||||||
mTimingSchedule(m_core->timing, &m_event,
|
mTimingSchedule(m_core->timing, &m_event,
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
|
|
||||||
class GBAHostInterface;
|
class GBAHostInterface;
|
||||||
class PointerWrap;
|
class PointerWrap;
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
namespace HW::GBA
|
namespace HW::GBA
|
||||||
{
|
{
|
||||||
|
@ -50,7 +54,11 @@ struct CoreInfo
|
||||||
class Core final
|
class Core final
|
||||||
{
|
{
|
||||||
public:
|
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();
|
~Core();
|
||||||
|
|
||||||
bool Start(u64 gc_ticks);
|
bool Start(u64 gc_ticks);
|
||||||
|
@ -135,5 +143,7 @@ private:
|
||||||
std::condition_variable m_response_cv;
|
std::condition_variable m_response_cv;
|
||||||
bool m_response_ready = false;
|
bool m_response_ready = false;
|
||||||
std::vector<u8> m_response;
|
std::vector<u8> m_response;
|
||||||
|
|
||||||
|
::Core::System& m_system;
|
||||||
};
|
};
|
||||||
} // namespace HW::GBA
|
} // namespace HW::GBA
|
||||||
|
|
|
@ -30,7 +30,7 @@ static s64 GetSyncInterval(const SystemTimers::SystemTimersManager& timers)
|
||||||
CSIDevice_GBAEmu::CSIDevice_GBAEmu(Core::System& system, SIDevices device, int device_number)
|
CSIDevice_GBAEmu::CSIDevice_GBAEmu(Core::System& system, SIDevices device, int device_number)
|
||||||
: ISIDevice(system, device, 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_core->Start(system.GetCoreTiming().GetTicks());
|
||||||
m_gbahost = Host_CreateGBAHost(m_core);
|
m_gbahost = Host_CreateGBAHost(m_core);
|
||||||
m_core->SetHost(m_gbahost);
|
m_core->SetHost(m_gbahost);
|
||||||
|
|
Loading…
Reference in New Issue