diff --git a/source-code/source/plugins/TLAC/Components/ComponentsManager.cpp b/source-code/source/plugins/TLAC/Components/ComponentsManager.cpp index 99ccff2..4a63456 100644 --- a/source-code/source/plugins/TLAC/Components/ComponentsManager.cpp +++ b/source-code/source/plugins/TLAC/Components/ComponentsManager.cpp @@ -143,6 +143,14 @@ namespace TLAC::Components } } + void ComponentsManager::UpdatePostDraw() + { + for (auto& component : components) + { + component->UpdatePostDraw(); + } + } + void ComponentsManager::OnFocusGain() { for (auto& component : components) diff --git a/source-code/source/plugins/TLAC/Components/ComponentsManager.h b/source-code/source/plugins/TLAC/Components/ComponentsManager.h index c263f37..1057940 100644 --- a/source-code/source/plugins/TLAC/Components/ComponentsManager.h +++ b/source-code/source/plugins/TLAC/Components/ComponentsManager.h @@ -28,6 +28,7 @@ namespace TLAC::Components void Update(); void UpdateInput(); void UpdatePostInput(); + void UpdatePostDraw(); void OnFocusGain(); void OnFocusLost(); void Dispose(); diff --git a/source-code/source/plugins/TLAC/Components/EmulatorComponent.h b/source-code/source/plugins/TLAC/Components/EmulatorComponent.h index 6b940a6..20955ae 100644 --- a/source-code/source/plugins/TLAC/Components/EmulatorComponent.h +++ b/source-code/source/plugins/TLAC/Components/EmulatorComponent.h @@ -17,6 +17,7 @@ namespace TLAC::Components virtual void UpdateInput() {}; virtual void UpdatePostInput() {}; + virtual void UpdatePostDraw() {}; virtual void OnFocusGain() {}; virtual void OnFocusLost() {}; diff --git a/source-code/source/plugins/TLAC/Components/Pause.cpp b/source-code/source/plugins/TLAC/Components/Pause.cpp index fb349a4..9903377 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.cpp +++ b/source-code/source/plugins/TLAC/Components/Pause.cpp @@ -2,11 +2,16 @@ #include "../Constants.h" #include "GameState.h" #include "Input/InputState.h" +#include "GL\glut.h" #include #include namespace TLAC::Components { + bool Pause::isPaused = false; + std::vector Pause::origAetMovOp; + std::vector Pause::streamPlayStates; + Pause::Pause() { } @@ -42,8 +47,20 @@ namespace TLAC::Components } else { - // swallow all button inputs if paused InputState* inputState = (InputState*)(*(uint64_t*)INPUT_STATE_PTR_ADDRESS); + + if (inputState->Tapped.Buttons & JVS_SQUARE) + showUI = !showUI; + + if (inputState->Tapped.Buttons & JVS_L) + menuPos -= 1; + + if (inputState->Tapped.Buttons & JVS_R) + menuPos += 1; + + menuPos %= menuItems.size(); + + // swallow all button inputs if paused inputState->Tapped.Buttons = JVS_NONE; inputState->DoubleTapped.Buttons = JVS_NONE; inputState->Down.Buttons = JVS_NONE; @@ -65,6 +82,61 @@ namespace TLAC::Components } } + void Pause::UpdatePostDraw() + { + if (isPaused && showUI) + { + // this isn't imgui code, but I probably wouldn't have gotten this working properly if I didn't reference it, so... umm... yeah lol + glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_TRANSFORM_BIT); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_CULL_FACE); + glDisable(GL_DEPTH_TEST); + glDisable(GL_LIGHTING); + glDisable(GL_COLOR_MATERIAL); + + int width = glutGet(GLUT_WINDOW_WIDTH); + int height = glutGet(GLUT_WINDOW_HEIGHT); + + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0, 1280, 720, 0, -1.0f, +1.0f); + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + + glBegin(GL_QUADS); + glBindTexture(GL_TEXTURE_2D, 0); + + glColor4ub(0, 0, 0, 127); + glVertex2i(0, 0); + glVertex2i(1280, 0); + glVertex2i(1280, 720); + glVertex2i(0, 720); + + glColor4ub(255, 255, 255, 127); + glVertex2i(560, 250); + glVertex2i(620, 250); + glVertex2i(620, 470); + glVertex2i(560, 470); + glVertex2i(660, 250); + glVertex2i(720, 250); + glVertex2i(720, 470); + glVertex2i(660, 470); + + glEnd(); + + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + glMatrixMode(GL_PROJECTION); + glPopMatrix(); + glPopAttrib(); + } + } + bool Pause::isPauseKeyTapped() { return ((InputState*)(*(uint64_t*)INPUT_STATE_PTR_ADDRESS))->Tapped.Buttons & JVS_START; diff --git a/source-code/source/plugins/TLAC/Components/Pause.h b/source-code/source/plugins/TLAC/Components/Pause.h index 762845a..0825cb9 100644 --- a/source-code/source/plugins/TLAC/Components/Pause.h +++ b/source-code/source/plugins/TLAC/Components/Pause.h @@ -15,15 +15,24 @@ namespace TLAC::Components virtual void Initialize(ComponentsManager*) override; virtual void Update() override; virtual void UpdatePostInput() override; + virtual void UpdatePostDraw() override; + static bool isPaused; private: - bool isPaused; - bool isPauseKeyTapped(); - void setPaused(bool pause); - std::vector streamPlayStates; - void InjectCode(void* address, const std::vector data); + // this is a mess of static so that menuItems can work + static bool isPauseKeyTapped(); + static void setPaused(bool pause); + static std::vector streamPlayStates; + static void InjectCode(void* address, const std::vector data); - std::vector origAetMovOp; - uint8_t* aetMovPatchAddress = (uint8_t*)0x1401703b3; + static std::vector origAetMovOp; + static constexpr uint8_t* aetMovPatchAddress = (uint8_t*)0x1401703b3; + + bool showUI = true; + unsigned int menuPos = 0; + static void unpause() { setPaused(false); }; + std::vector> menuItems = { + std::pair(std::string("RESUME"), &unpause), + }; }; } diff --git a/source-code/source/plugins/TLAC/Constants.h b/source-code/source/plugins/TLAC/Constants.h index 6f51f6f..84ec16d 100644 --- a/source-code/source/plugins/TLAC/Constants.h +++ b/source-code/source/plugins/TLAC/Constants.h @@ -8,6 +8,7 @@ constexpr uint8_t JNE_OPCODE = 0x85; //constexpr uint64_t ENGINE_UPDATE_HOOK_TARGET_ADDRESS = 0x000000014018CC40; constexpr uint64_t ENGINE_UPDATE_INPUT_ADDRESS = 0x000000014018CBB0; +constexpr uint64_t ENGINE_FINISH_DRAW_ADDRESS = 0x0000000140192730; constexpr uint64_t CURRENT_GAME_STATE_ADDRESS = 0x0000000140EDA810; constexpr uint64_t CURRENT_GAME_SUB_STATE_ADDRESS = 0x0000000140EDA82C; diff --git a/source-code/source/plugins/TLAC/dllmain.cpp b/source-code/source/plugins/TLAC/dllmain.cpp index 1b474ef..32c0b79 100644 --- a/source-code/source/plugins/TLAC/dllmain.cpp +++ b/source-code/source/plugins/TLAC/dllmain.cpp @@ -19,6 +19,7 @@ #pragma comment(lib, "detours.lib") void(__cdecl* divaEngineUpdate)() = (void(__cdecl*)())0x14018CC40; +void(__cdecl* divaEngineFinishDraw)() = (void(__cdecl*)())ENGINE_FINISH_DRAW_ADDRESS; LRESULT CALLBACK MessageWindowProcessCallback(HWND, UINT, WPARAM, LPARAM); DWORD WINAPI WindowMessageDispatcher(LPVOID); @@ -126,6 +127,11 @@ namespace TLAC ComponentsManager.OnFocusLost(); } + void UpdatePostDraw() + { + ComponentsManager.UpdatePostDraw(); + } + void InitializeExtraSettings() { const LPCTSTR RESOLUTION_CONFIG_FILE_NAME = _T(".\\config.ini"); @@ -342,6 +348,12 @@ void hookedEngineUpdate() //divaEngineUpdate(); } +void hookedEngineFinishDraw() +{ + TLAC::UpdatePostDraw(); + divaEngineFinishDraw(); +} + BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { HWND consoleHandle = GetConsoleWindow(); @@ -362,6 +374,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser DetourUpdateThread(GetCurrentThread()); DetourAttach(&(PVOID&)divaEngineUpdate, hookedEngineUpdate); DetourTransactionCommit(); + DetourTransactionBegin(); + DetourUpdateThread(GetCurrentThread()); + DetourAttach(&(PVOID&)divaEngineFinishDraw, hookedEngineFinishDraw); + DetourTransactionCommit(); TLAC::InitializeExtraSettings();