#pragma once #include "stdafx.h" #include "CPU.h" #include "PPU.h" #include "APU.h" #include "MemoryManager.h" #include "ControlManager.h" #include "../Utilities/SimpleLock.h" enum EmulationFlags { LimitFPS = 0x01, Paused = 0x02, }; class Debugger; class BaseMapper; class Console { private: static shared_ptr Instance; static uint32_t Flags; static uint32_t CurrentFPS; SimpleLock _pauseLock; SimpleLock _runLock; SimpleLock _stopLock; shared_ptr _cpu; shared_ptr _ppu; unique_ptr _apu; shared_ptr _mapper; unique_ptr _controlManager; shared_ptr _memoryManager; wstring _romFilepath; bool _stop = false; bool _reset = false; bool _initialized = false; void ResetComponents(bool softReset); void Initialize(wstring filename); public: Console(); ~Console(); void Run(); void Stop(); static void Reset(bool softReset = true); //Used to pause the emu loop to perform thread-safe operations static void Pause(); //Used to resume the emu loop after calling Pause() static void Resume(); shared_ptr Console::GetDebugger(); static void SaveState(ostream &saveStream); static void LoadState(istream &loadStream); static void LoadState(uint8_t *buffer, uint32_t bufferSize); static void LoadROM(wstring filepath); static bool LoadROM(wstring romName, uint32_t crc32Hash); static wstring FindMatchingRomInFolder(wstring folder, wstring romFilename, uint32_t crc32Hash); static wstring GetROMPath(); static bool CheckFlag(int flag); static void SetFlags(int flags); static void ClearFlags(int flags); static uint32_t GetFPS(); static shared_ptr GetInstance(); };