From 0a8bce8936385489c4a74912256ef1c92cacb6be Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 18 Sep 2019 00:22:41 +1000 Subject: [PATCH] GPU: Hook up vblank interrupt --- src/pse/gpu.cpp | 10 +++++----- src/pse/gpu.h | 6 +++--- src/pse/gpu_hw_opengl.cpp | 4 ++-- src/pse/gpu_hw_opengl.h | 2 +- src/pse/interrupt_controller.h | 2 +- src/pse/system.cpp | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/pse/gpu.cpp b/src/pse/gpu.cpp index e1afdb42d..0958cec23 100644 --- a/src/pse/gpu.cpp +++ b/src/pse/gpu.cpp @@ -1,8 +1,8 @@ #include "gpu.h" #include "YBaseLib/Log.h" -#include "bus.h" #include "common/state_wrapper.h" #include "dma.h" +#include "interrupt_controller.h" #include "system.h" Log_SetChannel(GPU); @@ -10,11 +10,11 @@ GPU::GPU() = default; GPU::~GPU() = default; -bool GPU::Initialize(System* system, Bus* bus, DMA* dma) +bool GPU::Initialize(System* system, DMA* dma, InterruptController* interrupt_controller) { m_system = system; - m_bus = bus; m_dma = dma; + m_interrupt_controller = interrupt_controller; return true; } @@ -278,8 +278,8 @@ void GPU::Execute(TickCount ticks) m_crtc_state.in_vblank = m_crtc_state.current_scanline >= m_crtc_state.visible_vertical_resolution; if (m_crtc_state.in_vblank && !old_vblank) { - // TODO: trigger vblank interrupt - Log_WarningPrint("VBlank interrupt would go here"); + Log_DebugPrintf("Now in v-blank"); + m_interrupt_controller->InterruptRequest(InterruptController::IRQ::VBLANK); } // past the end of vblank? diff --git a/src/pse/gpu.h b/src/pse/gpu.h index 2930b516c..b8022f5dc 100644 --- a/src/pse/gpu.h +++ b/src/pse/gpu.h @@ -8,8 +8,8 @@ class StateWrapper; class System; -class Bus; class DMA; +class InterruptController; class GPU { @@ -17,7 +17,7 @@ public: GPU(); virtual ~GPU(); - virtual bool Initialize(System* system, Bus* bus, DMA* dma); + virtual bool Initialize(System* system, DMA* dma, InterruptController* interrupt_controller); virtual void Reset(); virtual bool DoState(StateWrapper& sw); @@ -141,8 +141,8 @@ protected: virtual void FlushRender(); System* m_system = nullptr; - Bus* m_bus = nullptr; DMA* m_dma = nullptr; + InterruptController* m_interrupt_controller = nullptr; union GPUSTAT { diff --git a/src/pse/gpu_hw_opengl.cpp b/src/pse/gpu_hw_opengl.cpp index 0b14b5cd3..bc752d80a 100644 --- a/src/pse/gpu_hw_opengl.cpp +++ b/src/pse/gpu_hw_opengl.cpp @@ -12,9 +12,9 @@ GPU_HW_OpenGL::~GPU_HW_OpenGL() DestroyFramebuffer(); } -bool GPU_HW_OpenGL::Initialize(System* system, Bus* bus, DMA* dma) +bool GPU_HW_OpenGL::Initialize(System* system, DMA* dma, InterruptController* interrupt_controller) { - if (!GPU_HW::Initialize(system, bus, dma)) + if (!GPU_HW::Initialize(system, dma, interrupt_controller)) return false; CreateFramebuffer(); diff --git a/src/pse/gpu_hw_opengl.h b/src/pse/gpu_hw_opengl.h index bdfdb0f81..98f5ea7a3 100644 --- a/src/pse/gpu_hw_opengl.h +++ b/src/pse/gpu_hw_opengl.h @@ -13,7 +13,7 @@ public: GPU_HW_OpenGL(); ~GPU_HW_OpenGL() override; - bool Initialize(System* system, Bus* bus, DMA* dma) override; + bool Initialize(System* system, DMA* dma, InterruptController* interrupt_controller) override; void Reset() override; protected: diff --git a/src/pse/interrupt_controller.h b/src/pse/interrupt_controller.h index 1fc52a5a1..d6a4ec6c8 100644 --- a/src/pse/interrupt_controller.h +++ b/src/pse/interrupt_controller.h @@ -48,7 +48,7 @@ public: private: static constexpr u32 REGISTER_WRITE_MASK = (u32(1) << NUM_IRQS) - 1; - static constexpr u32 DEFAULT_INTERRUPT_MASK = (u32(1) << NUM_IRQS) - 1; + static constexpr u32 DEFAULT_INTERRUPT_MASK = 0; //(u32(1) << NUM_IRQS) - 1; void UpdateCPUInterruptRequest(); diff --git a/src/pse/system.cpp b/src/pse/system.cpp index 9ce65542a..224dcf241 100644 --- a/src/pse/system.cpp +++ b/src/pse/system.cpp @@ -1,12 +1,12 @@ #include "system.h" #include "YBaseLib/ByteStream.h" #include "bus.h" +#include "cdrom.h" #include "common/state_wrapper.h" #include "cpu_core.h" #include "dma.h" #include "gpu.h" #include "interrupt_controller.h" -#include "cdrom.h" System::System(HostInterface* host_interface) : m_host_interface(host_interface) { @@ -35,7 +35,7 @@ bool System::Initialize() if (!m_interrupt_controller->Initialize(m_cpu.get())) return false; - if (!m_gpu->Initialize(this, m_bus.get(), m_dma.get())) + if (!m_gpu->Initialize(this, m_dma.get(), m_interrupt_controller.get())) return false; if (!m_cdrom->Initialize(m_dma.get(), m_interrupt_controller.get()))