Duckstation/src/pse/system.cpp

47 lines
881 B
C++
Raw Normal View History

2019-09-09 07:01:26 +00:00
#include "system.h"
2019-09-12 02:53:04 +00:00
#include "bus.h"
#include "cpu_core.h"
#include "dma.h"
#include "gpu.h"
2019-09-09 07:01:26 +00:00
2019-09-12 14:18:13 +00:00
System::System(HostInterface* host_interface) : m_host_interface(host_interface)
2019-09-12 02:53:04 +00:00
{
m_cpu = std::make_unique<CPU::Core>();
m_bus = std::make_unique<Bus>();
m_dma = std::make_unique<DMA>();
2019-09-12 14:18:13 +00:00
// m_gpu = std::make_unique<GPU>();
m_gpu = GPU::CreateHardwareOpenGLRenderer();
2019-09-12 02:53:04 +00:00
}
2019-09-09 07:01:26 +00:00
System::~System() = default;
bool System::Initialize()
{
2019-09-12 02:53:04 +00:00
if (!m_cpu->Initialize(m_bus.get()))
2019-09-09 07:01:26 +00:00
return false;
2019-09-12 02:53:04 +00:00
if (!m_bus->Initialize(this, m_dma.get(), m_gpu.get()))
2019-09-09 07:01:26 +00:00
return false;
2019-09-12 02:53:04 +00:00
if (!m_dma->Initialize(m_bus.get(), m_gpu.get()))
return false;
2019-09-12 14:18:13 +00:00
if (!m_gpu->Initialize(this, m_bus.get(), m_dma.get()))
2019-09-09 07:01:26 +00:00
return false;
return true;
}
void System::Reset()
{
2019-09-12 02:53:04 +00:00
m_cpu->Reset();
m_bus->Reset();
m_dma->Reset();
m_gpu->Reset();
2019-09-09 07:01:26 +00:00
}
void System::RunFrame()
{
2019-09-12 02:53:04 +00:00
m_cpu->Execute();
2019-09-09 07:01:26 +00:00
}