mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 11:18:36 +12:00
* replace GetThreadID with std::this_thread.getId() * name all anonymous structs and unions that contain non-trivially constructable objects * made default constructor for big endian type noexcept to make it work with std::atomic * move instantiated specialized template function members ouside of the class definition to comply with the standard * added default instantiation for template parameter "=nullptr" * used the C++11 standardized thread_local instead of the __declspec(thread) * added transitional definitions to bridge the microsoft specific calls (compare and exchange and aligned alloc) * removed cyclic dependency between Emulator->CPUThreadManager->CPUThread->SMutex->Emulator->... * fixed some instances of indentation by space instead of tabs * surrounded some unused code with an #if 0 block to make sure it doesn't compile
168 lines
4.1 KiB
C++
168 lines
4.1 KiB
C++
#pragma once
|
|
|
|
#include <atomic>
|
|
#include "Gui/MemoryViewer.h"
|
|
#include "Emu/CPU/CPUThreadManager.h"
|
|
#include "Emu/Io/Pad.h"
|
|
#include "Emu/Io/Keyboard.h"
|
|
#include "Emu/Io/Mouse.h"
|
|
#include "Emu/GS/GSManager.h"
|
|
#include "Emu/Audio/AudioManager.h"
|
|
#include "Emu/FS/VFS.h"
|
|
#include "Emu/DbgConsole.h"
|
|
#include "Loader/Loader.h"
|
|
#include "SysCalls/Callback.h"
|
|
|
|
class EventManager;
|
|
extern void UnloadModules();
|
|
|
|
struct EmuInfo
|
|
{
|
|
private:
|
|
u64 tls_addr;
|
|
u64 tls_filesz;
|
|
u64 tls_memsz;
|
|
|
|
sys_process_param_info proc_param;
|
|
|
|
public:
|
|
EmuInfo() { Reset(); }
|
|
|
|
sys_process_param_info& GetProcParam() { return proc_param; }
|
|
|
|
void Reset()
|
|
{
|
|
SetTLSData(0, 0, 0);
|
|
memset(&proc_param, 0, sizeof(sys_process_param_info));
|
|
|
|
proc_param.malloc_pagesize = 0x100000;
|
|
proc_param.sdk_version = 0x360001;
|
|
//TODO
|
|
}
|
|
|
|
void SetTLSData(const u64 addr, const u64 filesz, const u64 memsz)
|
|
{
|
|
tls_addr = addr;
|
|
tls_filesz = filesz;
|
|
tls_memsz = memsz;
|
|
}
|
|
|
|
u64 GetTLSAddr() const { return tls_addr; }
|
|
u64 GetTLSFilesz() const { return tls_filesz; }
|
|
u64 GetTLSMemsz() const { return tls_memsz; }
|
|
};
|
|
|
|
class ModuleInitializer
|
|
{
|
|
public:
|
|
ModuleInitializer();
|
|
|
|
virtual void Init() = 0;
|
|
};
|
|
|
|
class Emulator
|
|
{
|
|
enum Mode
|
|
{
|
|
DisAsm,
|
|
InterpreterDisAsm,
|
|
Interpreter,
|
|
};
|
|
|
|
volatile uint m_status;
|
|
uint m_mode;
|
|
|
|
u32 m_rsx_callback;
|
|
u32 m_ppu_thr_exit;
|
|
MemoryViewerPanel* m_memory_viewer;
|
|
//ArrayF<CPUThread> m_cpu_threads;
|
|
ArrayF<ModuleInitializer> m_modules_init;
|
|
|
|
Array<u64> m_break_points;
|
|
Array<u64> m_marked_points;
|
|
|
|
CPUThreadManager m_thread_manager;
|
|
PadManager m_pad_manager;
|
|
KeyboardManager m_keyboard_manager;
|
|
MouseManager m_mouse_manager;
|
|
IdManager m_id_manager;
|
|
DbgConsole* m_dbg_console;
|
|
GSManager m_gs_manager;
|
|
AudioManager m_audio_manager;
|
|
CallbackManager m_callback_manager;
|
|
CPUThread* m_ppu_callback_thr;
|
|
EventManager &m_event_manager;
|
|
|
|
VFS m_vfs;
|
|
|
|
EmuInfo m_info;
|
|
|
|
public:
|
|
wxString m_path;
|
|
wxString m_elf_path;
|
|
wxString m_title_id;
|
|
|
|
Emulator();
|
|
|
|
void Init();
|
|
void SetPath(const wxString& path, const wxString& elf_path = wxEmptyString);
|
|
void SetTitleID(const wxString& id);
|
|
|
|
CPUThreadManager& GetCPU() { return m_thread_manager; }
|
|
PadManager& GetPadManager() { return m_pad_manager; }
|
|
KeyboardManager& GetKeyboardManager() { return m_keyboard_manager; }
|
|
MouseManager& GetMouseManager() { return m_mouse_manager; }
|
|
IdManager& GetIdManager() { return m_id_manager; }
|
|
DbgConsole& GetDbgCon() { return *m_dbg_console; }
|
|
GSManager& GetGSManager() { return m_gs_manager; }
|
|
AudioManager& GetAudioManager() { return m_audio_manager; }
|
|
CallbackManager& GetCallbackManager() { return m_callback_manager; }
|
|
VFS& GetVFS() { return m_vfs; }
|
|
Array<u64>& GetBreakPoints() { return m_break_points; }
|
|
Array<u64>& GetMarkedPoints() { return m_marked_points; }
|
|
CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; }
|
|
EventManager& GetEventManager() { return m_event_manager; }
|
|
|
|
void AddModuleInit(ModuleInitializer* m)
|
|
{
|
|
m_modules_init.Add(m);
|
|
}
|
|
|
|
void SetTLSData(const u64 addr, const u64 filesz, const u64 memsz)
|
|
{
|
|
m_info.SetTLSData(addr, filesz, memsz);
|
|
}
|
|
|
|
EmuInfo& GetInfo() { return m_info; }
|
|
|
|
u64 GetTLSAddr() const { return m_info.GetTLSAddr(); }
|
|
u64 GetTLSFilesz() const { return m_info.GetTLSFilesz(); }
|
|
u64 GetTLSMemsz() const { return m_info.GetTLSMemsz(); }
|
|
|
|
u32 GetMallocPageSize() { return m_info.GetProcParam().malloc_pagesize; }
|
|
|
|
u32 GetRSXCallback() const { return m_rsx_callback; }
|
|
u32 GetPPUThreadExit() const { return m_ppu_thr_exit; }
|
|
|
|
void CheckStatus();
|
|
|
|
bool IsSelf(const std::string& path);
|
|
bool DecryptSelf(const std::string& elf, const std::string& self);
|
|
bool BootGame(const std::string& path);
|
|
|
|
void Load();
|
|
void Run();
|
|
void Pause();
|
|
void Resume();
|
|
void Stop();
|
|
|
|
void SavePoints(const std::string& path);
|
|
void LoadPoints(const std::string& path);
|
|
|
|
__forceinline bool IsRunning() const { return m_status == Running; }
|
|
__forceinline bool IsPaused() const { return m_status == Paused; }
|
|
__forceinline bool IsStopped() const { return m_status == Stopped; }
|
|
__forceinline bool IsReady() const { return m_status == Ready; }
|
|
};
|
|
|
|
extern Emulator Emu;
|