Duckstation/src/core/system.h

94 lines
2.2 KiB
C
Raw Normal View History

2019-09-09 07:01:26 +00:00
#pragma once
#include "settings.h"
2019-09-09 07:01:26 +00:00
#include "types.h"
#include <memory>
2019-09-09 07:01:26 +00:00
2019-09-14 10:28:47 +00:00
class ByteStream;
class StateWrapper;
2019-09-12 14:18:13 +00:00
class HostInterface;
namespace CPU {
2019-09-12 02:53:04 +00:00
class Core;
}
class Bus;
class DMA;
2019-09-17 06:26:00 +00:00
class InterruptController;
2019-09-12 02:53:04 +00:00
class GPU;
2019-09-17 09:22:39 +00:00
class CDROM;
class Pad;
class PadDevice;
2019-09-20 13:40:19 +00:00
class Timers;
class SPU;
2019-09-29 02:51:34 +00:00
class MDEC;
2019-09-12 02:53:04 +00:00
2019-09-09 07:01:26 +00:00
class System
{
public:
System(HostInterface* host_interface, const Settings& settings);
2019-09-09 07:01:26 +00:00
~System();
2019-09-12 14:18:13 +00:00
HostInterface* GetHostInterface() const { return m_host_interface; }
CPU::Core* GetCPU() const { return m_cpu.get(); }
Bus* GetBus() const { return m_bus.get(); }
GPU* GetGPU() const { return m_gpu.get(); }
2019-10-10 16:20:21 +00:00
SPU* GetSPU() const { return m_spu.get(); }
2019-09-12 14:18:13 +00:00
u32 GetFrameNumber() const { return m_frame_number; }
u32 GetInternalFrameNumber() const { return m_internal_frame_number; }
2019-10-04 10:48:29 +00:00
u32 GetGlobalTickCounter() const { return m_global_tick_counter; }
void IncrementFrameNumber() { m_frame_number++; }
void IncrementInternalFrameNumber() { m_internal_frame_number++; }
Settings& GetSettings() { return m_settings; }
void UpdateSettings();
2019-09-09 07:01:26 +00:00
bool Initialize();
void Reset();
2019-09-14 10:28:47 +00:00
bool LoadState(ByteStream* state);
bool SaveState(ByteStream* state);
2019-09-09 07:01:26 +00:00
void RunFrame();
bool LoadEXE(const char* filename);
2019-09-22 15:28:00 +00:00
bool SetExpansionROM(const char* filename);
void SetDowncount(TickCount downcount);
void Synchronize();
2019-09-17 04:25:25 +00:00
// Adds ticks to the global tick counter, simulating the CPU being stalled.
void StallCPU(TickCount ticks);
2019-09-29 15:07:38 +00:00
void SetController(u32 slot, std::shared_ptr<PadDevice> dev);
void SetMemoryCard(u32 slot, std::shared_ptr<PadDevice> dev);
2019-09-20 10:14:00 +00:00
bool HasMedia() const;
bool InsertMedia(const char* path);
void RemoveMedia();
2019-10-12 12:15:38 +00:00
void DrawDebugMenus();
void DrawDebugWindows();
2019-09-09 07:01:26 +00:00
private:
2019-09-14 10:28:47 +00:00
bool DoState(StateWrapper& sw);
2019-09-12 14:18:13 +00:00
HostInterface* m_host_interface;
2019-09-12 02:53:04 +00:00
std::unique_ptr<CPU::Core> m_cpu;
std::unique_ptr<Bus> m_bus;
std::unique_ptr<DMA> m_dma;
2019-09-17 06:26:00 +00:00
std::unique_ptr<InterruptController> m_interrupt_controller;
2019-09-12 02:53:04 +00:00
std::unique_ptr<GPU> m_gpu;
2019-09-17 09:22:39 +00:00
std::unique_ptr<CDROM> m_cdrom;
std::unique_ptr<Pad> m_pad;
2019-09-20 13:40:19 +00:00
std::unique_ptr<Timers> m_timers;
std::unique_ptr<SPU> m_spu;
2019-09-29 02:51:34 +00:00
std::unique_ptr<MDEC> m_mdec;
u32 m_frame_number = 1;
u32 m_internal_frame_number = 1;
2019-10-04 10:48:29 +00:00
u32 m_global_tick_counter = 0;
Settings m_settings;
2019-09-09 07:01:26 +00:00
};