diff --git a/src/core/core.cpp b/src/core/core.cpp index 37c3d1ac3b..dc5c6236fc 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -189,7 +189,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { cpu_core = std::make_unique(USER32MODE); } - dsp_core = std::make_unique(); + dsp_core = std::make_unique(*memory); dsp_core->SetSink(Settings::values.sink_id, Settings::values.audio_device_id); dsp_core->EnableStretching(Settings::values.enable_audio_stretching); @@ -202,7 +202,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { service_manager = std::make_shared(*this); archive_manager = std::make_unique(*this); - HW::Init(); + HW::Init(*memory); Service::Init(*this); GDBStub::Init(); diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 47bb852f80..34ecc08a5d 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -27,6 +27,7 @@ namespace GPU { Regs g_regs; +Memory::MemorySystem* g_memory; /// 268MHz CPU clocks / 60Hz frames per second const u64 frame_ticks = static_cast(BASE_CLOCK_RATE_ARM11 / SCREEN_REFRESH_RATE); @@ -526,7 +527,8 @@ static void VBlankCallback(u64 userdata, s64 cycles_late) { } /// Initialize hardware -void Init() { +void Init(Memory::MemorySystem& memory) { + g_memory = &memory; memset(&g_regs, 0, sizeof(g_regs)); auto& framebuffer_top = g_regs.framebuffer_config[0]; diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 8184066da8..606ab95040 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -11,6 +11,10 @@ #include "common/common_funcs.h" #include "common/common_types.h" +namespace Memory { +class MemorySystem; +} + namespace GPU { constexpr float SCREEN_REFRESH_RATE = 60; @@ -326,7 +330,7 @@ template void Write(u32 addr, const T data); /// Initialize hardware -void Init(); +void Init(Memory::MemorySystem& memory); /// Shutdown hardware void Shutdown(); diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp index 4d31b3c80f..e7d80a5c73 100644 --- a/src/core/hw/hw.cpp +++ b/src/core/hw/hw.cpp @@ -86,9 +86,9 @@ template void Write(u32 addr, const u8 data); void Update() {} /// Initialize hardware -void Init() { +void Init(Memory::MemorySystem& memory) { AES::InitKeys(); - GPU::Init(); + GPU::Init(memory); LCD::Init(); LOG_DEBUG(HW, "initialized OK"); } diff --git a/src/core/hw/hw.h b/src/core/hw/hw.h index 5890d2b5c0..cc7b04294e 100644 --- a/src/core/hw/hw.h +++ b/src/core/hw/hw.h @@ -6,6 +6,10 @@ #include "common/common_types.h" +namespace Memory { +class MemorySystem; +} + namespace HW { /// Beginnings of IO register regions, in the user VA space. @@ -42,7 +46,7 @@ void Write(u32 addr, const T data); void Update(); /// Initialize hardware -void Init(); +void Init(Memory::MemorySystem& memory); /// Shutdown hardware void Shutdown();