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-09-30 14:07:07 -04:00
|
|
|
#include "VirtualFile.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;
|
2017-06-28 19:00:08 -04:00
|
|
|
class HdPackBuilder;
|
2017-08-19 16:46:57 -04:00
|
|
|
class HdAudioDevice;
|
2017-07-25 19:46:25 -04:00
|
|
|
struct HdPackData;
|
2017-04-29 08:29:56 -04:00
|
|
|
enum class NesModel;
|
2017-06-28 19:00:08 -04:00
|
|
|
enum class ScaleFilterType;
|
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;
|
2017-08-30 18:31:27 -04:00
|
|
|
shared_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;
|
|
|
|
|
2017-06-28 19:00:08 -04:00
|
|
|
shared_ptr<HdPackBuilder> _hdPackBuilder;
|
|
|
|
unique_ptr<HdPackData> _hdData;
|
2017-08-19 16:46:57 -04:00
|
|
|
unique_ptr<HdAudioDevice> _hdAudioDevice;
|
2017-06-28 19:00:08 -04:00
|
|
|
|
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;
|
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
|
|
|
|
2017-07-30 09:03:54 -04:00
|
|
|
void LoadHdPack(VirtualFile &romFile, VirtualFile &patchFile);
|
2017-06-28 19:00:08 -04:00
|
|
|
|
2014-06-25 13:30:02 -04:00
|
|
|
void ResetComponents(bool softReset);
|
2017-07-30 09:03:54 -04:00
|
|
|
bool Initialize(VirtualFile &romFile, VirtualFile &patchFile);
|
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
|
|
|
|
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-07-30 09:03:54 -04:00
|
|
|
static bool LoadROM(VirtualFile romFile, VirtualFile patchFile = {});
|
2017-04-22 13:19:21 -04:00
|
|
|
static bool LoadROM(string romName, HashInfo hashInfo);
|
2017-08-19 19:40:02 -04:00
|
|
|
static VirtualFile GetRomPath();
|
2016-06-17 20:53:05 -04:00
|
|
|
static string GetRomName();
|
2017-06-28 19:00:08 -04:00
|
|
|
static bool IsChrRam();
|
2017-03-04 22:24:41 -05:00
|
|
|
static RomFormat GetRomFormat();
|
2017-07-30 09:03:54 -04:00
|
|
|
static HashInfo GetHashInfo();
|
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();
|
|
|
|
|
2017-06-28 19:00:08 -04:00
|
|
|
static HdPackData* GetHdData();
|
2017-08-19 17:51:36 -04:00
|
|
|
static bool IsHdPpu();
|
2017-06-28 19:00:08 -04:00
|
|
|
|
|
|
|
static void StartRecordingHdPack(string saveFolder, ScaleFilterType filterType, uint32_t scale, uint32_t flags, uint32_t chrRamBankSize);
|
|
|
|
static void StopRecordingHdPack();
|
|
|
|
|
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
|
|
|
};
|