From 030255e41f59a0f2e0232d41b928ec5d2e39ad2a Mon Sep 17 00:00:00 2001 From: roblabla <1069318+roblabla@users.noreply.github.com> Date: Sun, 1 Dec 2024 12:25:57 +0000 Subject: [PATCH 1/3] Update mapping to latest ghidra changes --- config/mapping.csv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/mapping.csv b/config/mapping.csv index 6ebd8f49..ecc84c38 100644 --- a/config/mapping.csv +++ b/config/mapping.csv @@ -270,11 +270,11 @@ th06::MidiOutput::FadeOutSetVolume,0x423260,0xce,__thiscall,,void,MidiOutput*,i3 th06::AnmManager::~AnmManager,0x423330,0xb,__thiscall,,void,AnmManager* th06::Supervisor::OnUpdate,0x42333b,0x44a,__stdcall,,ChainCallbackResult,Supervisor* th06::Supervisor::OnDraw,0x423785,0x7c,__stdcall,,ChainCallbackResult,Supervisor* -th06::Controller::ControllerCallback,0x423801,0x6a,__stdcall,,u8,DIDEVICEOBJECTINSTANCEA* +th06::Supervisor::ControllerCallback,0x423801,0x6a,__stdcall,,u8,DIDEVICEOBJECTINSTANCEA* th06::Supervisor::RegisterChain,0x42386b,0x9f,__stdcall,,ZunResult th06::Supervisor::AddedCallback,0x42390a,0x20a,__stdcall,,ZunResult,Supervisor* th06::Supervisor::SetupDInput,0x423b14,0x28c,__stdcall,,ZunResult,Supervisor* -th06::Controller::EnumGameControllersCb,0x423da0,0x3f,__stdcall,,u32,i32 +th06::Supervisor::EnumGameControllersCb,0x423da0,0x3f,__stdcall,,u32,i32 th06::Supervisor::DeletedCallback,0x423ddf,0x160,default,,ZunResult,Supervisor* th06::Supervisor::DrawFpsCounter,0x423f3f,0x1b1,__stdcall,,void th06::AnmManager::ReleaseVertexBuffer,0x4240f0,0x37,__thiscall,,void,AnmManager* @@ -301,7 +301,7 @@ th06::MusicRoom::OnDraw,0x42545a,0x1f2,__cdecl,,ChainCallbackResult,MusicRoom* th06::MusicRoom::AddedCallback,0x42564c,0x74b,__cdecl,,ZunResult,MusicRoom* th06::MusicRoom::DeletedCallback,0x425d97,0x6c,__cdecl,,ZunResult,MusicRoom* th06::Player::Player,0x425e10,0x1e8,__thiscall,,Player*,Player* -th06::PlayerInner::PlayerInner,0x426000,0xc2,__thiscall,,PlayerBombInfo*,PlayerInner* +th06::PlayerBombInfo::PlayerBombInfo,0x426000,0xc2,__thiscall,,PlayerBombInfo*,PlayerBombInfo* th06::Player::FireBulletReimuA,0x4260d0,0x22,default,,FireBulletResult,Player*,PlayerBullet*,u32,u32 th06::Player::FireSingleBullet,0x426100,0x31b,default,,FireBulletResult,Player*,PlayerBullet*,i32,i32,CharacterPowerData* th06::Player::FireBulletReimuB,0x426420,0x22,default,,FireBulletResult,Player*,PlayerBullet*,u32,u32 @@ -421,7 +421,7 @@ th06::AnmManager::TakeScreenshot,0x435670,0xed,__thiscall,,void,AnmManager*,i32, th06::MainMenu::MainMenu,0x43575d,0x42,__thiscall,,void,MainMenu* th06::MainMenu::OnUpdate,0x43579f,0x1d31,__stdcall,,ChainCallbackResult,MainMenu* th06::MainMenu::MoveCursor,0x43753c,0x136,default,,i32,MainMenu*,i32 -th06::MainMenu::SelectRelated,0x437672,0x131,default,,void,MainMenu*,u16,u16,i32 +th06::MainMenu::SwapMapping,0x437672,0x131,default,,void,MainMenu*,u16,u16,i32 th06::MainMenu::DrawMenuItem,0x4377a3,0xff,__stdcall,,void,AnmVm*,i32,i32,unsigned long,unsigned long,i32 th06::MainMenu::BeginStartup,0x4378a2,0x142,__thiscall,,ZunResult,MainMenu* th06::MainMenu::WeirdSecondInputCheck,0x4379e4,0x15d,__thiscall,,i32,MainMenu* From abd51ba7fbad286d99e3ea584b20f2e695464570 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sun, 1 Dec 2024 01:04:27 +0100 Subject: [PATCH 2/3] Move ControllerCallback and EnumGameControllersCb to Supervisor ns --- config/implemented.csv | 4 ++-- src/Supervisor.cpp | 8 ++++---- src/Supervisor.hpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config/implemented.csv b/config/implemented.csv index b0c87644..88b1eb69 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -91,8 +91,8 @@ th06::Controller::SetButtonFromDirectInputJoystate th06::Controller::GetControllerInput th06::Controller::GetInput th06::Controller::ResetKeyboard -th06::Controller::ControllerCallback -th06::Controller::EnumGameControllersCb +th06::Supervisor::ControllerCallback +th06::Supervisor::EnumGameControllersCb th06::EclManager::CallEclSub th06::EclManager::Load th06::EclManager::RunEcl diff --git a/src/Supervisor.cpp b/src/Supervisor.cpp index 037440e6..5acd6973 100644 --- a/src/Supervisor.cpp +++ b/src/Supervisor.cpp @@ -698,7 +698,7 @@ ZunResult Supervisor::SetupDInput(Supervisor *supervisor) supervisor->keyboard->Acquire(); GameErrorContext::Log(&g_GameErrorContext, TH_ERR_DIRECTINPUT_INITIALIZED); - supervisor->dinputIface->EnumDevices(DI8DEVCLASS_GAMECTRL, Controller::EnumGameControllersCb, NULL, + supervisor->dinputIface->EnumDevices(DI8DEVCLASS_GAMECTRL, Supervisor::EnumGameControllersCb, NULL, DIEDFL_ATTACHEDONLY); if (supervisor->controller) { @@ -708,7 +708,7 @@ ZunResult Supervisor::SetupDInput(Supervisor *supervisor) g_Supervisor.controllerCaps.dwSize = sizeof(g_Supervisor.controllerCaps); supervisor->controller->GetCapabilities(&g_Supervisor.controllerCaps); - supervisor->controller->EnumObjects(Controller::ControllerCallback, NULL, DIDFT_ALL); + supervisor->controller->EnumObjects(Supervisor::ControllerCallback, NULL, DIDFT_ALL); GameErrorContext::Log(&g_GameErrorContext, TH_ERR_PAD_FOUND); } @@ -1047,7 +1047,7 @@ u16 Controller::GetInput(void) #pragma optimize("s", on) #pragma var_order(diprange, pvRefBackup) -BOOL CALLBACK Controller::ControllerCallback(LPCDIDEVICEOBJECTINSTANCEA lpddoi, LPVOID pvRef) +BOOL CALLBACK Supervisor::ControllerCallback(LPCDIDEVICEOBJECTINSTANCEA lpddoi, LPVOID pvRef) { LPVOID pvRefBackup; DIPROPRANGE diprange; @@ -1072,7 +1072,7 @@ BOOL CALLBACK Controller::ControllerCallback(LPCDIDEVICEOBJECTINSTANCEA lpddoi, #pragma optimize("", on) #pragma optimize("s", on) -BOOL CALLBACK Controller::EnumGameControllersCb(LPCDIDEVICEINSTANCEA pdidInstance, LPVOID pContext) +BOOL CALLBACK Supervisor::EnumGameControllersCb(LPCDIDEVICEINSTANCEA pdidInstance, LPVOID pContext) { HRESULT result; diff --git a/src/Supervisor.hpp b/src/Supervisor.hpp index f4eaac65..025340a3 100644 --- a/src/Supervisor.hpp +++ b/src/Supervisor.hpp @@ -118,6 +118,8 @@ struct Supervisor ZunResult FadeOutMusic(f32 fadeOutSeconds); static ZunResult SetupDInput(Supervisor *s); + static BOOL CALLBACK ControllerCallback(LPCDIDEVICEOBJECTINSTANCEA lpddoi, LPVOID pvRef); + static BOOL CALLBACK EnumGameControllersCb(LPCDIDEVICEINSTANCEA pdidInstance, LPVOID pContext); i32 LoadPbg3(i32 pbg3FileIdx, char *filename); void ReleasePbg3(i32 pbg3FileIdx); @@ -228,8 +230,6 @@ unsigned int SetButtonFromDirectInputJoystate(u16 *outButtons, i16 controllerBut u16 GetControllerInput(u16 buttons); u8 *GetControllerState(); u16 GetInput(void); -BOOL CALLBACK ControllerCallback(LPCDIDEVICEOBJECTINSTANCEA lpddoi, LPVOID pvRef); -BOOL CALLBACK EnumGameControllersCb(LPCDIDEVICEINSTANCEA pdidInstance, LPVOID pContext); void ResetKeyboard(void); }; // namespace Controller From a0ac5cfb9b5a40f67d026fdb1cb68e24e966845d Mon Sep 17 00:00:00 2001 From: roblabla Date: Sun, 1 Dec 2024 13:29:02 +0100 Subject: [PATCH 3/3] Rename MainMenu::SelectRelated to MainMenu::SwapMapping --- config/implemented.csv | 2 +- src/MainMenu.cpp | 20 ++++++++++---------- src/MainMenu.hpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/implemented.csv b/config/implemented.csv index 88b1eb69..d1f3edf3 100644 --- a/config/implemented.csv +++ b/config/implemented.csv @@ -249,7 +249,7 @@ th06::MainMenu::WeirdSecondInputCheck th06::MainMenu::OnUpdateOptionsMenu th06::MainMenu::ColorMenuItem th06::MainMenu::LoadReplayMenu -th06::MainMenu::SelectRelated +th06::MainMenu::SwapMapping th06::MidiDevice::MidiDevice th06::MidiDevice::Close th06::MidiDevice::OpenDevice diff --git a/src/MainMenu.cpp b/src/MainMenu.cpp index a4ad9ac2..5fd8db90 100644 --- a/src/MainMenu.cpp +++ b/src/MainMenu.cpp @@ -205,39 +205,39 @@ ChainCallbackResult MainMenu::OnUpdate(MainMenu *menu) switch (menu->cursor) { case 0: - SelectRelated(menu, sVar1, menu->controlMapping[0], 1); + SwapMapping(menu, sVar1, menu->controlMapping[0], 1); menu->controlMapping[0] = sVar1; break; case 1: - SelectRelated(menu, sVar1, menu->controlMapping[1], 0); + SwapMapping(menu, sVar1, menu->controlMapping[1], 0); menu->controlMapping[1] = sVar1; break; case 2: - SelectRelated(menu, sVar1, menu->controlMapping[2], 1); + SwapMapping(menu, sVar1, menu->controlMapping[2], 1); menu->controlMapping[2] = sVar1; break; case 3: - SelectRelated(menu, sVar1, menu->controlMapping[3], 0); + SwapMapping(menu, sVar1, menu->controlMapping[3], 0); menu->controlMapping[3] = sVar1; break; case 4: - SelectRelated(menu, sVar1, menu->controlMapping[4], 0); + SwapMapping(menu, sVar1, menu->controlMapping[4], 0); menu->controlMapping[4] = sVar1; break; case 5: - SelectRelated(menu, sVar1, menu->controlMapping[5], 0); + SwapMapping(menu, sVar1, menu->controlMapping[5], 0); menu->controlMapping[5] = sVar1; break; case 6: - SelectRelated(menu, sVar1, menu->controlMapping[6], 0); + SwapMapping(menu, sVar1, menu->controlMapping[6], 0); menu->controlMapping[6] = sVar1; break; case 7: - SelectRelated(menu, sVar1, menu->controlMapping[7], 0); + SwapMapping(menu, sVar1, menu->controlMapping[7], 0); menu->controlMapping[7] = sVar1; break; case 8: - SelectRelated(menu, sVar1, menu->controlMapping[8], 0); + SwapMapping(menu, sVar1, menu->controlMapping[8], 0); menu->controlMapping[8] = sVar1; } } @@ -925,7 +925,7 @@ CursorMovement MainMenu::MoveCursor(MainMenu *menu, i32 menuLength) #pragma optimize("", on) #pragma optimize("s", on) -void MainMenu::SelectRelated(MainMenu *menu, i16 btnPressed, i16 oldMapping, ZunBool unk) +void MainMenu::SwapMapping(MainMenu *menu, i16 btnPressed, i16 oldMapping, ZunBool unk) { if (unk == 0 && menu->controlMapping[0] == btnPressed) { diff --git a/src/MainMenu.hpp b/src/MainMenu.hpp index 8fd9705d..084c9f08 100644 --- a/src/MainMenu.hpp +++ b/src/MainMenu.hpp @@ -68,7 +68,7 @@ struct MainMenu static CursorMovement MoveCursor(MainMenu *menu, i32 menuLength); static void DrawMenuItem(AnmVm *vm, i32 itemNumber, i32 cursor, D3DCOLOR activeItemColor, D3DCOLOR inactiveItemColor, i32 spriteIdx /* I think*/); - static void SelectRelated(MainMenu *menu, i16 btnPressed, i16 oldMapping, ZunBool unk); + static void SwapMapping(MainMenu *menu, i16 btnPressed, i16 oldMapping, ZunBool unk); i32 ReplayHandling(); static ZunResult LoadReplayMenu(MainMenu *menu);