Mesen-X/Core/Console.h

141 lines
3.5 KiB
C
Raw Normal View History

#pragma once
2014-06-14 11:27:55 -04:00
#include "stdafx.h"
2016-12-11 10:56:23 -05:00
#include <atomic>
#include "../Utilities/SimpleLock.h"
#include "VirtualFile.h"
#include "RomData.h"
#include "SaveStateManager.h"
2014-06-14 11:27:55 -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;
class HdPackBuilder;
2017-08-19 16:46:57 -04:00
class HdAudioDevice;
class SystemActionManager;
struct HdPackData;
2017-04-29 08:29:56 -04:00
enum class NesModel;
enum class ScaleFilterType;
enum class ConsoleFeatures;
2014-06-14 11:27:55 -04:00
class Console
{
private:
static shared_ptr<Console> Instance;
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;
shared_ptr<CPU> _cpu;
shared_ptr<PPU> _ppu;
2017-08-30 18:31:27 -04:00
shared_ptr<APU> _apu;
shared_ptr<Debugger> _debugger;
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
shared_ptr<SystemActionManager> _systemActionManager;
unique_ptr<AutoSaveManager> _autoSaveManager;
shared_ptr<HdPackBuilder> _hdPackBuilder;
unique_ptr<HdPackData> _hdData;
2017-08-19 16:46:57 -04:00
unique_ptr<HdAudioDevice> _hdAudioDevice;
NesModel _model;
string _romFilepath;
string _patchFilename;
2014-06-22 08:38:42 -04:00
bool _stop = false;
2016-06-25 20:46:54 -04:00
bool _disableOcNextFrame = false;
2016-12-11 10:56:23 -05:00
atomic<bool> _resetRequested;
bool _initialized = false;
std::thread::id _emulationThreadId;
void LoadHdPack(VirtualFile &romFile, VirtualFile &patchFile);
bool Initialize(VirtualFile &romFile, VirtualFile &patchFile);
void UpdateNesModel(bool sendNotification);
double GetFrameDelay();
void SaveBatteries();
2014-06-14 11:27:55 -04:00
public:
Console();
2014-06-14 11:27:55 -04:00
~Console();
void Run();
void Stop();
shared_ptr<SystemActionManager> GetSystemActionManager();
template<typename T>
shared_ptr<T> GetSystemActionManager()
{
return std::dynamic_pointer_cast<T>(_systemActionManager);
}
ConsoleFeatures GetAvailableFeatures();
void InputBarcode(uint64_t barcode, uint32_t digitCount);
static std::thread::id GetEmulationThreadId();
2016-06-25 20:46:54 -04:00
static void RequestReset();
static void Reset(bool softReset = true);
void PowerCycle();
void ResetComponents(bool softReset);
//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> GetDebugger(bool autoStart = true);
void StopDebugger();
static void SaveState(ostream &saveStream);
static void LoadState(istream &loadStream, uint32_t stateVersion = SaveStateManager::FileFormatVersion);
static void LoadState(uint8_t *buffer, uint32_t bufferSize);
2014-06-25 21:52:37 -04:00
static bool LoadROM(VirtualFile romFile, VirtualFile patchFile = {});
static bool LoadROM(string romName, HashInfo hashInfo);
static string FindMatchingRom(string romName, HashInfo hashInfo);
static VirtualFile GetRomPath();
static string GetRomName();
static VirtualFile GetPatchFile();
static bool IsChrRam();
static RomFormat GetRomFormat();
static HashInfo GetHashInfo();
2016-07-01 23:54:31 -04:00
static NesModel GetModel();
2016-07-10 18:22:37 -04:00
static uint32_t GetLagCounter();
static void ResetLagCounter();
static bool IsRunning();
bool IsPaused();
static void SetNextFrameOverclockStatus(bool disabled);
static bool IsDebuggerAttached();
static HdPackData* GetHdData();
static bool IsHdPpu();
static void StartRecordingHdPack(string saveFolder, ScaleFilterType filterType, uint32_t scale, uint32_t flags, uint32_t chrRamBankSize);
static void StopRecordingHdPack();
static shared_ptr<Console> GetInstance();
static void Release();
2014-06-14 11:27:55 -04:00
};