From 3171dc8266d8503badd3238be4e066c3ab65b9da Mon Sep 17 00:00:00 2001 From: "Skyth (Asilkan)" <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Thu, 30 Jan 2025 12:53:24 +0300 Subject: [PATCH] Pick correct bullet particles in Tornado Defense depending on controller icons. (#241) --- UnleashedRecomp/patches/object_patches.cpp | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/UnleashedRecomp/patches/object_patches.cpp b/UnleashedRecomp/patches/object_patches.cpp index 54c391b..39a038a 100644 --- a/UnleashedRecomp/patches/object_patches.cpp +++ b/UnleashedRecomp/patches/object_patches.cpp @@ -1,5 +1,6 @@ #include #include +#include // CObjFlame::CObjFlame // A field is not zero initialized, @@ -67,3 +68,33 @@ void ObjBigBarrelSetPositionMidAsmHook(PPCRegister& r3, PPCRegister& r4) position->Z = position->Z - characterProxy->m_Velocity.Z * factor; } } + +// Tornado Defense bullet particles are colored by the button prompt, which differs on PlayStation 3. +// Luckily, the PS3 particles are left in the files, and they get spawned by name when a bullet gets created. + +// SWA::CExBullet::AddCallback +PPC_FUNC_IMPL(__imp__sub_82B14CC0); +PPC_FUNC(sub_82B14CC0) +{ + auto isPlayStation = Config::ControllerIcons == EControllerIcons::PlayStation; + + if (Config::ControllerIcons == EControllerIcons::Auto) + isPlayStation = hid::g_inputDeviceController == hid::EInputDevice::PlayStation; + + if (isPlayStation) + { + PPC_STORE_U8(0x820C2A0B, 'b'); // Cross + PPC_STORE_U8(0x820C29C3, 'r'); // Circle + PPC_STORE_U8(0x820C29DB, 'p'); // Square + PPC_STORE_U8(0x820C29F3, 'g'); // Triangle + } + else + { + PPC_STORE_U8(0x820C2A0B, 'g'); // A + PPC_STORE_U8(0x820C29C3, 'r'); // B + PPC_STORE_U8(0x820C29DB, 'b'); // X + PPC_STORE_U8(0x820C29F3, 'o'); // Y + } + + __imp__sub_82B14CC0(ctx, base); +}