This repository was archived by the owner on Sep 11, 2023. It is now read-only.
forked from SourMesen/Mesen
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathConsole.h
More file actions
153 lines (115 loc) · 3.91 KB
/
Console.h
File metadata and controls
153 lines (115 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#pragma once
#include "stdafx.h"
#include <atomic>
#include "../Utilities/SimpleLock.h"
#include "VirtualFile.h"
#include "RomData.h"
#include "SaveStateManager.h"
class Debugger;
class BaseMapper;
class RewindManager;
class APU;
class CPU;
class PPU;
class MemoryManager;
class ControlManager;
class AutoSaveManager;
class HdPackBuilder;
class HdAudioDevice;
class SystemActionManager;
class Timer;
struct HdPackData;
enum class NesModel;
enum class ScaleFilterType;
enum class ConsoleFeatures;
enum class DebugMemoryType;
class Console
{
private:
static shared_ptr<Console> Instance;
SimpleLock _pauseLock;
SimpleLock _runLock;
SimpleLock _stopLock;
SimpleLock _debuggerLock;
shared_ptr<RewindManager> _rewindManager;
shared_ptr<CPU> _cpu;
shared_ptr<PPU> _ppu;
shared_ptr<APU> _apu;
shared_ptr<Debugger> _debugger;
shared_ptr<BaseMapper> _mapper;
shared_ptr<ControlManager> _controlManager;
shared_ptr<MemoryManager> _memoryManager;
shared_ptr<SystemActionManager> _systemActionManager;
unique_ptr<AutoSaveManager> _autoSaveManager;
shared_ptr<HdPackBuilder> _hdPackBuilder;
unique_ptr<HdPackData> _hdData;
unique_ptr<HdAudioDevice> _hdAudioDevice;
NesModel _model;
string _romFilepath;
string _patchFilename;
bool _stop = false;
bool _running = false;
int32_t _stopCode = 0;
bool _disableOcNextFrame = false;
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 DisplayDebugInformation(Timer &clockTimer, Timer &lastFrameTimer, double &lastFrameMin, double &lastFrameMax, double *timeLagData);
public:
Console();
~Console();
void SaveBatteries();
void Run();
void Stop(int stopCode = 0);
int32_t GetStopCode();
void RunSingleFrame();
bool UpdateHdPackMode();
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);
void LoadTapeFile(string filepath);
void StartRecordingTapeFile(string filepath);
void StopRecordingTapeFile();
bool IsRecordingTapeFile();
static std::thread::id GetEmulationThreadId();
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();
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);
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 VirtualFile GetPatchFile();
static MapperInfo GetMapperInfo();
static NesModel GetModel();
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();
uint8_t* GetRamBuffer(DebugMemoryType memoryType, uint32_t &size, int32_t &startAddr);
};