GPU: Hook up vblank interrupt

This commit is contained in:
Connor McLaughlin 2019-09-18 00:22:41 +10:00
parent a84b3d7a2b
commit 0a8bce8936
6 changed files with 14 additions and 14 deletions

View File

@ -1,8 +1,8 @@
#include "gpu.h" #include "gpu.h"
#include "YBaseLib/Log.h" #include "YBaseLib/Log.h"
#include "bus.h"
#include "common/state_wrapper.h" #include "common/state_wrapper.h"
#include "dma.h" #include "dma.h"
#include "interrupt_controller.h"
#include "system.h" #include "system.h"
Log_SetChannel(GPU); Log_SetChannel(GPU);
@ -10,11 +10,11 @@ GPU::GPU() = default;
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_system = system;
m_bus = bus;
m_dma = dma; m_dma = dma;
m_interrupt_controller = interrupt_controller;
return true; 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; m_crtc_state.in_vblank = m_crtc_state.current_scanline >= m_crtc_state.visible_vertical_resolution;
if (m_crtc_state.in_vblank && !old_vblank) if (m_crtc_state.in_vblank && !old_vblank)
{ {
// TODO: trigger vblank interrupt Log_DebugPrintf("Now in v-blank");
Log_WarningPrint("VBlank interrupt would go here"); m_interrupt_controller->InterruptRequest(InterruptController::IRQ::VBLANK);
} }
// past the end of vblank? // past the end of vblank?

View File

@ -8,8 +8,8 @@
class StateWrapper; class StateWrapper;
class System; class System;
class Bus;
class DMA; class DMA;
class InterruptController;
class GPU class GPU
{ {
@ -17,7 +17,7 @@ public:
GPU(); GPU();
virtual ~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 void Reset();
virtual bool DoState(StateWrapper& sw); virtual bool DoState(StateWrapper& sw);
@ -141,8 +141,8 @@ protected:
virtual void FlushRender(); virtual void FlushRender();
System* m_system = nullptr; System* m_system = nullptr;
Bus* m_bus = nullptr;
DMA* m_dma = nullptr; DMA* m_dma = nullptr;
InterruptController* m_interrupt_controller = nullptr;
union GPUSTAT union GPUSTAT
{ {

View File

@ -12,9 +12,9 @@ GPU_HW_OpenGL::~GPU_HW_OpenGL()
DestroyFramebuffer(); 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; return false;
CreateFramebuffer(); CreateFramebuffer();

View File

@ -13,7 +13,7 @@ public:
GPU_HW_OpenGL(); GPU_HW_OpenGL();
~GPU_HW_OpenGL() override; ~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; void Reset() override;
protected: protected:

View File

@ -48,7 +48,7 @@ public:
private: private:
static constexpr u32 REGISTER_WRITE_MASK = (u32(1) << NUM_IRQS) - 1; 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(); void UpdateCPUInterruptRequest();

View File

@ -1,12 +1,12 @@
#include "system.h" #include "system.h"
#include "YBaseLib/ByteStream.h" #include "YBaseLib/ByteStream.h"
#include "bus.h" #include "bus.h"
#include "cdrom.h"
#include "common/state_wrapper.h" #include "common/state_wrapper.h"
#include "cpu_core.h" #include "cpu_core.h"
#include "dma.h" #include "dma.h"
#include "gpu.h" #include "gpu.h"
#include "interrupt_controller.h" #include "interrupt_controller.h"
#include "cdrom.h"
System::System(HostInterface* host_interface) : m_host_interface(host_interface) 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())) if (!m_interrupt_controller->Initialize(m_cpu.get()))
return false; 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; return false;
if (!m_cdrom->Initialize(m_dma.get(), m_interrupt_controller.get())) if (!m_cdrom->Initialize(m_dma.get(), m_interrupt_controller.get()))