mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-10-24 08:05:42 +00:00
50 lines
999 B
C++
50 lines
999 B
C++
#include "system.h"
|
|
#include "bus.h"
|
|
#include "cpu_core.h"
|
|
#include "dma.h"
|
|
#include "gpu.h"
|
|
|
|
System::System(HostInterface* host_interface) : m_host_interface(host_interface)
|
|
{
|
|
m_cpu = std::make_unique<CPU::Core>();
|
|
m_bus = std::make_unique<Bus>();
|
|
m_dma = std::make_unique<DMA>();
|
|
// m_gpu = std::make_unique<GPU>();
|
|
m_gpu = GPU::CreateHardwareOpenGLRenderer();
|
|
}
|
|
|
|
System::~System() = default;
|
|
|
|
bool System::Initialize()
|
|
{
|
|
if (!m_cpu->Initialize(m_bus.get()))
|
|
return false;
|
|
|
|
if (!m_bus->Initialize(this, m_dma.get(), m_gpu.get()))
|
|
return false;
|
|
|
|
if (!m_dma->Initialize(m_bus.get(), m_gpu.get()))
|
|
return false;
|
|
|
|
if (!m_gpu->Initialize(this, m_bus.get(), m_dma.get()))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void System::Reset()
|
|
{
|
|
m_cpu->Reset();
|
|
m_bus->Reset();
|
|
m_dma->Reset();
|
|
m_gpu->Reset();
|
|
m_frame_number = 1;
|
|
}
|
|
|
|
void System::RunFrame()
|
|
{
|
|
u32 current_frame_number = m_frame_number;
|
|
while (current_frame_number == m_frame_number)
|
|
m_cpu->Execute();
|
|
}
|