Mesen/Core/Console.h

92 lines
2.2 KiB
C
Raw Normal View History

#pragma once
2014-06-14 15:27:55 +00:00
#include "stdafx.h"
2016-12-11 15:56:23 +00:00
#include <atomic>
2014-06-14 15:27:55 +00:00
#include "CPU.h"
#include "PPU.h"
#include "APU.h"
2014-06-14 15:27:55 +00:00
#include "MemoryManager.h"
2014-06-21 19:43:41 +00:00
#include "ControlManager.h"
#include "../Utilities/SimpleLock.h"
#include "AutoSaveManager.h"
2014-06-14 15:27:55 +00:00
class Debugger;
class BaseMapper;
2014-06-14 15:27:55 +00:00
class Console
{
private:
static shared_ptr<Console> Instance;
SimpleLock _pauseLock;
SimpleLock _runLock;
SimpleLock _stopLock;
2014-06-21 23:03:13 +00:00
shared_ptr<CPU> _cpu;
shared_ptr<PPU> _ppu;
unique_ptr<APU> _apu;
shared_ptr<Debugger> _debugger;
2016-07-31 18:31:44 +00:00
SimpleLock _debuggerLock;
shared_ptr<BaseMapper> _mapper;
2014-06-21 19:43:41 +00:00
unique_ptr<ControlManager> _controlManager;
shared_ptr<MemoryManager> _memoryManager;
2014-06-14 15:27:55 +00:00
unique_ptr<AutoSaveManager> _autoSaveManager;
NesModel _model;
string _romFilepath;
2014-06-22 12:38:42 +00:00
bool _stop = false;
bool _reset = false;
2016-06-26 00:46:54 +00:00
2016-12-11 15:56:23 +00:00
atomic<bool> _resetRequested;
2016-07-10 22:22:37 +00:00
atomic<uint32_t> _lagCounter;
bool _initialized = false;
void ResetComponents(bool softReset);
void Initialize(string filename, stringstream *filestream = nullptr, string ipsFilename = "", int32_t archiveFileIndex = -1);
void UpdateNesModel(bool sendNotification);
double GetFrameDelay();
2014-06-14 15:27:55 +00:00
public:
Console();
2014-06-14 15:27:55 +00:00
~Console();
void Run();
void Stop();
2016-06-26 00:46:54 +00:00
static void RequestReset();
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 23:03:13 +00:00
std::shared_ptr<Debugger> GetDebugger(bool autoStart = true);
void StopDebugger();
static NesModel GetNesModel();
static void SaveState(ostream &saveStream);
static void LoadState(istream &loadStream);
static void LoadState(uint8_t *buffer, uint32_t bufferSize);
2014-06-26 01:52:37 +00:00
static void LoadROM(string filepath, stringstream *filestream = nullptr, int32_t archiveFileIndex = -1, string ipsFile = "");
static bool LoadROM(string romName, uint32_t crc32Hash);
static string GetROMPath();
static string GetRomName();
2016-01-29 01:47:16 +00:00
static uint32_t GetCrc32();
static uint32_t GetPrgCrc32();
2016-07-02 03:54:31 +00:00
static NesModel GetModel();
2016-07-10 22:22:37 +00:00
static uint32_t GetLagCounter();
static void ResetLagCounter();
static bool IsRunning();
static bool IsDebuggerAttached();
static shared_ptr<Console> GetInstance();
static void Release();
2014-06-14 15:27:55 +00:00
};