Mesen-X/Core/Console.h

78 lines
1.7 KiB
C
Raw Normal View History

#pragma once
2014-06-14 11:27:55 -04:00
#include "stdafx.h"
#include "CPU.h"
#include "PPU.h"
#include "APU.h"
2014-06-14 11:27:55 -04:00
#include "MemoryManager.h"
2014-06-21 15:43:41 -04:00
#include "ControlManager.h"
#include "../Utilities/SimpleLock.h"
2014-06-14 11:27:55 -04:00
2014-06-21 19:03:13 -04:00
enum EmulationFlags
{
LimitFPS = 0x01,
Paused = 0x02,
2014-06-21 19:03:13 -04:00
};
class Debugger;
class BaseMapper;
2014-06-14 11:27:55 -04:00
class Console
{
private:
static shared_ptr<Console> Instance;
2014-06-21 19:03:13 -04:00
static uint32_t Flags;
2014-06-23 16:38:01 -04:00
static uint32_t CurrentFPS;
SimpleLock _pauseLock;
SimpleLock _runLock;
SimpleLock _stopLock;
2014-06-21 19:03:13 -04:00
shared_ptr<CPU> _cpu;
shared_ptr<PPU> _ppu;
unique_ptr<APU> _apu;
shared_ptr<BaseMapper> _mapper;
2014-06-21 15:43:41 -04:00
unique_ptr<ControlManager> _controlManager;
shared_ptr<MemoryManager> _memoryManager;
2014-06-14 11:27:55 -04:00
wstring _romFilepath;
2014-06-22 08:38:42 -04:00
bool _stop = false;
bool _reset = false;
bool _initialized = false;
void ResetComponents(bool softReset);
void Initialize(wstring filename);
2014-06-14 11:27:55 -04:00
public:
Console();
2014-06-14 11:27:55 -04:00
~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();
2014-06-21 19:03:13 -04:00
shared_ptr<Debugger> Console::GetDebugger();
static void SaveState(ostream &saveStream);
static void LoadState(istream &loadStream);
static void LoadState(uint8_t *buffer, uint32_t bufferSize);
2014-06-25 21:52:37 -04:00
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();
2014-06-21 19:03:13 -04:00
static bool CheckFlag(int flag);
static void SetFlags(int flags);
static void ClearFlags(int flags);
2014-06-23 16:38:01 -04:00
static uint32_t GetFPS();
static shared_ptr<Console> GetInstance();
2014-06-14 11:27:55 -04:00
};