From f6bf4d6f2a0dec657578e9d596273867ed165bf1 Mon Sep 17 00:00:00 2001 From: NovaSquirrel Date: Wed, 7 Oct 2020 00:47:24 -0400 Subject: [PATCH] Make history viewer sort of work --- InteropDLL/EmuApiWrapper.cpp | 34 ++++++++++++++++++++++++----- InteropDLL/HistoryViewerWrapper.cpp | 2 +- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/InteropDLL/EmuApiWrapper.cpp b/InteropDLL/EmuApiWrapper.cpp index 4479c89..52db82b 100644 --- a/InteropDLL/EmuApiWrapper.cpp +++ b/InteropDLL/EmuApiWrapper.cpp @@ -50,6 +50,28 @@ struct InteropRomInfo static string _romPath; static string _patchPath; +extern shared_ptr _historyConsole; + +enum class ConsoleId +{ + Main = 0, + HistoryViewer = 1 +}; + +shared_ptr GetConsoleById(ConsoleId consoleId) +{ + shared_ptr console; + switch (consoleId) { + case ConsoleId::Main: console = _console; break; + case ConsoleId::HistoryViewer: console = _historyConsole; break; + } + + if (!console) { + //Otherwise return the main CPU + console = _console; + } + return console; +} extern "C" { DllExport bool __stdcall TestDll() @@ -164,23 +186,23 @@ extern "C" { _console->Stop(true); } - DllExport void __stdcall Pause() + DllExport void __stdcall Pause(ConsoleId consoleId) { if(!GameClient::Connected()) { - _console->Pause(); + GetConsoleById(consoleId)->Pause(); } } - DllExport void __stdcall Resume() + DllExport void __stdcall Resume(ConsoleId consoleId) { if(!GameClient::Connected()) { - _console->Resume(); + GetConsoleById(consoleId)->Resume(); } } - DllExport bool __stdcall IsPaused() + DllExport bool __stdcall IsPaused(ConsoleId consoleId) { - shared_ptr console = _console; + shared_ptr console = GetConsoleById(consoleId); if(console) { return console->IsPaused(); } diff --git a/InteropDLL/HistoryViewerWrapper.cpp b/InteropDLL/HistoryViewerWrapper.cpp index 072e104..828d3bd 100644 --- a/InteropDLL/HistoryViewerWrapper.cpp +++ b/InteropDLL/HistoryViewerWrapper.cpp @@ -45,7 +45,7 @@ extern "C" #ifdef _WIN32 _historyRenderer.reset(new Renderer(_historyConsole, (HWND)viewerHandle, false)); - _historySoundManager.reset(new SoundManager(_historyConsole, (HWND)windowHandle)); +// _historySoundManager.reset(new SoundManager(_historyConsole, (HWND)windowHandle)); #else _historyRenderer.reset(new SdlRenderer(_historyConsole, viewerHandle, false)); _historySoundManager.reset(new SdlSoundManager(_historyConsole));