2014-06-20 21:48:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "CPU.h"
|
|
|
|
#include "PPU.h"
|
2014-06-22 22:15:35 -04:00
|
|
|
#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"
|
2014-07-06 19:54:47 -04:00
|
|
|
#include "../Utilities/SimpleLock.h"
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2015-07-01 23:17:14 -04:00
|
|
|
class Debugger;
|
|
|
|
class BaseMapper;
|
|
|
|
|
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
|
|
|
|
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;
|
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-02-05 23:14:27 -05:00
|
|
|
NesModel _model;
|
|
|
|
|
2015-07-11 08:27:22 -04:00
|
|
|
string _romFilepath;
|
2014-06-22 08:38:42 -04:00
|
|
|
|
2014-06-20 21:48:55 -04:00
|
|
|
bool _stop = false;
|
2014-06-23 13:52:53 -04:00
|
|
|
bool _reset = false;
|
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);
|
2015-12-27 18:41:38 -05:00
|
|
|
void Initialize(string filename, stringstream *filestream = nullptr, string ipsFilename = "");
|
2016-02-10 21:41:51 -05:00
|
|
|
double UpdateNesModel(bool sendNotification);
|
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();
|
2015-07-05 19:35:38 -04:00
|
|
|
static void Reset(bool softReset = true);
|
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-06-04 08:55:52 -04:00
|
|
|
std::shared_ptr<Debugger> GetDebugger();
|
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
|
|
|
|
2015-12-26 17:11:00 -05:00
|
|
|
static void LoadROM(string filepath, stringstream *filestream = nullptr);
|
2015-07-11 08:27:22 -04:00
|
|
|
static bool LoadROM(string romName, uint32_t crc32Hash);
|
2015-12-27 18:41:38 -05:00
|
|
|
static void ApplyIpsPatch(string ipsFilename);
|
2015-07-11 08:27:22 -04:00
|
|
|
static string GetROMPath();
|
2016-01-28 20:47:16 -05:00
|
|
|
static uint32_t GetCrc32();
|
2014-07-09 18:29:07 -04:00
|
|
|
|
2016-02-14 12:58:35 -05:00
|
|
|
static bool IsRunning();
|
|
|
|
|
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
|
|
|
};
|