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 "BaseMapper.h"
|
|
|
|
#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"
|
|
|
|
#include "IMessageManager.h"
|
2014-07-09 19:05:07 -04:00
|
|
|
#include "INotificationListener.h"
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2014-06-21 19:03:13 -04:00
|
|
|
enum EmulationFlags
|
|
|
|
{
|
|
|
|
LimitFPS = 0x01,
|
|
|
|
};
|
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
class Console
|
|
|
|
{
|
|
|
|
private:
|
2014-07-01 12:44:01 -04:00
|
|
|
static Console* Instance;
|
2014-06-21 19:03:13 -04:00
|
|
|
static uint32_t Flags;
|
2014-06-23 16:38:01 -04:00
|
|
|
static uint32_t CurrentFPS;
|
2014-07-06 19:54:47 -04:00
|
|
|
static SimpleLock PauseLock;
|
|
|
|
static SimpleLock RunningLock;
|
|
|
|
static IMessageManager* MessageManager;
|
2014-07-09 18:29:07 -04:00
|
|
|
static list<INotificationListener*> NotificationListeners;
|
2014-06-21 19:03:13 -04:00
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
unique_ptr<CPU> _cpu;
|
2014-06-15 21:45:36 -04:00
|
|
|
unique_ptr<PPU> _ppu;
|
2014-06-22 22:15:35 -04:00
|
|
|
unique_ptr<APU> _apu;
|
2014-06-24 02:47:32 -04:00
|
|
|
shared_ptr<BaseMapper> _mapper;
|
2014-06-21 15:43:41 -04:00
|
|
|
unique_ptr<ControlManager> _controlManager;
|
2014-06-19 19:58:15 -04:00
|
|
|
unique_ptr<MemoryManager> _memoryManager;
|
2014-06-14 11:27:55 -04:00
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
wstring _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;
|
2014-06-20 21:48:55 -04:00
|
|
|
|
2014-06-25 13:30:02 -04:00
|
|
|
void ResetComponents(bool softReset);
|
2014-07-09 18:29:07 -04:00
|
|
|
void Initialize(wstring filename);
|
2014-06-24 02:47:32 -04:00
|
|
|
|
2014-06-14 11:27:55 -04:00
|
|
|
public:
|
2014-06-20 21:48:55 -04:00
|
|
|
Console(wstring filename);
|
2014-06-14 11:27:55 -04:00
|
|
|
~Console();
|
|
|
|
void Run();
|
2014-06-20 21:48:55 -04:00
|
|
|
void Stop();
|
2014-07-01 12:44:01 -04:00
|
|
|
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 19:03:13 -04:00
|
|
|
|
2014-06-22 08:38:42 -04:00
|
|
|
bool RunTest(uint8_t* expectedResult);
|
|
|
|
void SaveTestResult();
|
|
|
|
|
2014-07-01 12:44:01 -04:00
|
|
|
static void SaveState(wstring filename);
|
|
|
|
static void SaveState(ostream &saveStream);
|
|
|
|
static bool LoadState(wstring filename);
|
|
|
|
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
|
|
|
|
2014-07-09 18:29:07 -04:00
|
|
|
static void LoadROM(wstring filename);
|
|
|
|
static bool AttemptLoadROM(wstring filename, uint32_t crc32Hash);
|
|
|
|
static wstring GetROMPath();
|
|
|
|
|
2014-06-21 19:03:13 -04:00
|
|
|
static bool CheckFlag(int flag);
|
|
|
|
static void SetFlags(int flags);
|
|
|
|
static void ClearFlags(int flags);
|
2014-06-23 16:38:01 -04:00
|
|
|
static uint32_t GetFPS();
|
2014-07-06 19:54:47 -04:00
|
|
|
|
|
|
|
static void RegisterMessageManager(IMessageManager* messageManager);
|
|
|
|
static void DisplayMessage(wstring message);
|
2014-07-09 18:29:07 -04:00
|
|
|
|
|
|
|
static void RegisterNotificationListener(INotificationListener* notificationListener);
|
|
|
|
static void UnregisterNotificationListener(INotificationListener* notificationListener);
|
|
|
|
static void SendNotification(ConsoleNotificationType type);
|
|
|
|
|
|
|
|
static Console* GetInstance();
|
2014-06-14 11:27:55 -04:00
|
|
|
};
|