2014-06-20 21:48:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
#include "stdafx.h"
|
2016-12-11 10:56:23 -05:00
|
|
|
#include <atomic>
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2017-03-04 22:24:41 -05:00
|
|
|
#include "RomData.h"
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
class Debugger;
|
|
|
|
class BaseMapper;
|
2017-04-28 19:54:58 -04:00
|
|
|
class RewindManager;
|
2017-04-29 08:29:56 -04:00
|
|
|
class APU;
|
|
|
|
class CPU;
|
|
|
|
class PPU;
|
|
|
|
class MemoryManager;
|
|
|
|
class ControlManager;
|
|
|
|
class AutoSaveManager;
|
|
|
|
enum class NesModel;
|
2015-07-01 23:17:14 -04:00
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
class Console
|
|
|
|
{
|
|
|
|
private:
|
2015-07-01 23:17:14 -04:00
|
|
|
static shared_ptr<Console> Instance;
|
2015-07-05 19:05:33 -04:00
|
|
|
SimpleLock _pauseLock;
|
|
|
|
SimpleLock _runLock;
|
|
|
|
SimpleLock _stopLock;
|
2014-06-21 19:03:13 -04:00
|
|
|
|
2017-04-28 19:54:58 -04:00
|
|
|
shared_ptr<RewindManager> _rewindManager;
|
2015-06-24 19:26:19 -04:00
|
|
|
shared_ptr<CPU> _cpu;
|
2015-07-01 23:17:14 -04:00
|
|
|
shared_ptr<PPU> _ppu;
|
2014-06-22 22:15:35 -04:00
|
|
|
unique_ptr<APU> _apu;
|
2015-08-21 22:42:44 -04:00
|
|
|
shared_ptr<Debugger> _debugger;
|
2016-07-31 14:31:44 -04:00
|
|
|
SimpleLock _debuggerLock;
|
2014-06-24 02:47:32 -04:00
|
|
|
shared_ptr<BaseMapper> _mapper;
|
2014-06-21 15:43:41 -04:00
|
|
|
unique_ptr<ControlManager> _controlManager;
|
2015-06-24 19:26:19 -04:00
|
|
|
shared_ptr<MemoryManager> _memoryManager;
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2016-08-31 20:54:38 -04:00
|
|
|
unique_ptr<AutoSaveManager> _autoSaveManager;
|
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
NesModel _model;
|
|
|
|
|
2015-07-11 08:27:22 -04:00
|
|
|
string _romFilepath;
|
2017-05-02 23:31:06 -04:00
|
|
|
string _patchFilename;
|
|
|
|
int32_t _archiveFileIndex;
|
2014-06-22 08:38:42 -04:00
|
|
|
|
2014-06-20 21:48:55 -04:00
|
|
|
bool _stop = false;
|
2016-06-25 20:46:54 -04:00
|
|
|
|
2016-12-23 13:56:45 -05:00
|
|
|
bool _disableOcNextFrame = false;
|
|
|
|
|
2016-12-11 10:56:23 -05:00
|
|
|
atomic<bool> _resetRequested;
|
2016-07-10 18:22:37 -04:00
|
|
|
atomic<uint32_t> _lagCounter;
|
2015-07-05 22:23:44 -04:00
|
|
|
|
|
|
|
bool _initialized = false;
|
2014-06-20 21:48:55 -04:00
|
|
|
|
2014-06-25 13:30:02 -04:00
|
|
|
void ResetComponents(bool softReset);
|
2017-04-23 18:47:28 -04:00
|
|
|
bool Initialize(string filename, stringstream *filestream = nullptr, string patchFilename = "", int32_t archiveFileIndex = -1);
|
2016-07-10 19:15:00 -04:00
|
|
|
void UpdateNesModel(bool sendNotification);
|
|
|
|
double GetFrameDelay();
|
2014-06-24 02:47:32 -04:00
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
public:
|
2015-07-05 22:23:44 -04:00
|
|
|
Console();
|
2014-06-14 11:27:55 -04:00
|
|
|
~Console();
|
|
|
|
void Run();
|
2014-06-20 21:48:55 -04:00
|
|
|
void Stop();
|
2016-06-25 20:46:54 -04:00
|
|
|
static void RequestReset();
|
2015-07-05 19:35:38 -04:00
|
|
|
static void Reset(bool softReset = true);
|
2017-05-02 23:31:06 -04:00
|
|
|
static void PowerCycle();
|
2014-07-01 12:44:01 -04:00
|
|
|
|
|
|
|
//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
|
|
|
|
2016-08-25 19:02:33 -04:00
|
|
|
std::shared_ptr<Debugger> GetDebugger(bool autoStart = true);
|
2015-08-21 22:42:44 -04:00
|
|
|
void StopDebugger();
|
2015-06-24 19:26:19 -04:00
|
|
|
|
2016-02-05 23:14:27 -05:00
|
|
|
static NesModel GetNesModel();
|
2014-07-01 12:44:01 -04:00
|
|
|
static void SaveState(ostream &saveStream);
|
|
|
|
static void LoadState(istream &loadStream);
|
2014-07-06 19:54:47 -04:00
|
|
|
static void LoadState(uint8_t *buffer, uint32_t bufferSize);
|
2014-06-25 21:52:37 -04:00
|
|
|
|
2017-04-23 18:47:28 -04:00
|
|
|
static bool LoadROM(string filepath, stringstream *filestream = nullptr, int32_t archiveFileIndex = -1, string patchFilepath = "");
|
2017-04-22 13:19:21 -04:00
|
|
|
static bool LoadROM(string romName, HashInfo hashInfo);
|
2015-07-11 08:27:22 -04:00
|
|
|
static bool LoadROM(string romName, uint32_t crc32Hash);
|
2017-04-22 13:19:21 -04:00
|
|
|
static bool LoadROM(string romName, string sha1Hash);
|
2015-07-11 08:27:22 -04:00
|
|
|
static string GetROMPath();
|
2016-06-17 20:53:05 -04:00
|
|
|
static string GetRomName();
|
2017-03-04 22:24:41 -05:00
|
|
|
static RomFormat GetRomFormat();
|
2016-01-28 20:47:16 -05:00
|
|
|
static uint32_t GetCrc32();
|
2016-07-10 09:05:41 -04:00
|
|
|
static uint32_t GetPrgCrc32();
|
2016-07-01 23:54:31 -04:00
|
|
|
static NesModel GetModel();
|
2014-07-09 18:29:07 -04:00
|
|
|
|
2016-07-10 18:22:37 -04:00
|
|
|
static uint32_t GetLagCounter();
|
|
|
|
static void ResetLagCounter();
|
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
static bool IsRunning();
|
|
|
|
|
2017-04-29 16:11:22 -04:00
|
|
|
static void SetNextFrameOverclockStatus(bool disabled);
|
2016-12-23 13:56:45 -05:00
|
|
|
|
2016-11-26 18:04:09 -05:00
|
|
|
static bool IsDebuggerAttached();
|
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
static shared_ptr<Console> GetInstance();
|
2015-07-20 23:20:41 -04:00
|
|
|
static void Release();
|
2014-06-14 11:27:55 -04:00
|
|
|
};
|