Mesen/Core/Console.h

86 lines
2.2 KiB
C
Raw Normal View History

#pragma once
2014-06-14 15:27:55 +00:00
#include "stdafx.h"
#include "CPU.h"
#include "PPU.h"
#include "APU.h"
2014-06-14 15:27:55 +00:00
#include "BaseMapper.h"
#include "MemoryManager.h"
2014-06-21 19:43:41 +00:00
#include "ControlManager.h"
#include "../Utilities/SimpleLock.h"
#include "IMessageManager.h"
#include "INotificationListener.h"
2014-06-14 15:27:55 +00:00
2014-06-21 23:03:13 +00:00
enum EmulationFlags
{
LimitFPS = 0x01,
Paused = 0x02,
2014-06-21 23:03:13 +00:00
};
2014-06-14 15:27:55 +00:00
class Console
{
private:
static Console* Instance;
2014-06-21 23:03:13 +00:00
static uint32_t Flags;
2014-06-23 20:38:01 +00:00
static uint32_t CurrentFPS;
static SimpleLock PauseLock;
static SimpleLock RunningLock;
static IMessageManager* MessageManager;
static list<INotificationListener*> NotificationListeners;
2014-06-21 23:03:13 +00:00
2014-06-14 15:27:55 +00:00
unique_ptr<CPU> _cpu;
2014-06-16 01:45:36 +00:00
unique_ptr<PPU> _ppu;
unique_ptr<APU> _apu;
shared_ptr<BaseMapper> _mapper;
2014-06-21 19:43:41 +00:00
unique_ptr<ControlManager> _controlManager;
unique_ptr<MemoryManager> _memoryManager;
2014-06-14 15:27:55 +00:00
wstring _romFilepath;
2014-06-22 12:38:42 +00:00
bool _stop = false;
bool _reset = false;
void ResetComponents(bool softReset);
void Initialize(wstring filename);
2014-06-14 15:27:55 +00:00
public:
Console(wstring filename);
2014-06-14 15:27:55 +00:00
~Console();
void Run();
void Stop();
static void Reset();
//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 23:03:13 +00:00
2014-06-22 12:38:42 +00:00
bool RunTest(uint8_t* expectedResult);
void SaveTestResult();
static void SaveState(wstring filename);
static void SaveState(ostream &saveStream);
static bool LoadState(wstring filename);
static void LoadState(istream &loadStream);
static void LoadState(uint8_t *buffer, uint32_t bufferSize);
2014-06-26 01:52:37 +00:00
static void LoadROM(wstring filename);
static bool AttemptLoadROM(wstring filename, uint32_t crc32Hash);
static wstring GetROMPath();
2014-06-21 23:03:13 +00:00
static bool CheckFlag(int flag);
static void SetFlags(int flags);
static void ClearFlags(int flags);
2014-06-23 20:38:01 +00:00
static uint32_t GetFPS();
static void RegisterMessageManager(IMessageManager* messageManager);
static void DisplayMessage(wstring message);
static void RegisterNotificationListener(INotificationListener* notificationListener);
static void UnregisterNotificationListener(INotificationListener* notificationListener);
static void SendNotification(ConsoleNotificationType type);
static Console* GetInstance();
2014-06-14 15:27:55 +00:00
};