From 1117ef0af1634ec561254ef42b4ed00fe73177ac Mon Sep 17 00:00:00 2001 From: sozud <122322823+sozud@users.noreply.github.com> Date: Wed, 2 Oct 2024 12:10:44 -0700 Subject: [PATCH] Dedupe PrizeDropFall (#1714) Progress towards fixing CEN HD --- config/symbols.hd.stcen.txt | 2 +- config/symbols.pspeu.stwrp.txt | 2 +- config/symbols.us.borbo3.txt | 2 +- config/symbols.us.stno0.txt | 2 +- src/boss/rbo3/us.c | 3 ++- src/st/cen/e_collect.c | 2 +- src/st/e_collect.h | 22 +++------------------- src/st/no0/e_collect.c | 3 ++- src/st/prize_drop_fall.h | 18 ++++++++++++++++++ src/st/wrp/header.c | 2 +- src/st/wrp_psp/e_collect.c | 22 +++------------------- 11 files changed, 34 insertions(+), 46 deletions(-) create mode 100644 src/st/prize_drop_fall.h diff --git a/config/symbols.hd.stcen.txt b/config/symbols.hd.stcen.txt index 5d2060b75..0571e3af5 100644 --- a/config/symbols.hd.stcen.txt +++ b/config/symbols.hd.stcen.txt @@ -71,7 +71,7 @@ SetStep = 0x80194DF8; InitializeEntity = 0x80194EC8; CheckFieldCollision = 0x80195114; GetPlayerCollisionWith = 0x8019526C; -func_8018CAB0 = 0x80195668; +PrizeDropFall = 0x80195668; func_8018CB34 = 0x801956EC; CollectHeart = 0x80195848; CollectGold = 0x801958C8; diff --git a/config/symbols.pspeu.stwrp.txt b/config/symbols.pspeu.stwrp.txt index 7dee74a2d..e666e8e51 100644 --- a/config/symbols.pspeu.stwrp.txt +++ b/config/symbols.pspeu.stwrp.txt @@ -22,7 +22,7 @@ UpdateStageEntities = 0x0923ac50; EntitySoulStealOrb = 0x0923b780; EntityEnemyBlood = 0x0923bce0; BlitChar = 0x0923c3d0; -func_8018CAB0 = 0x0923c988; +PrizeDropFall = 0x0923c988; func_8018CB34 = 0x0923ca60; CollectHeart = 0x0923cbe0; CollectGold = 0x0923cc80; diff --git a/config/symbols.us.borbo3.txt b/config/symbols.us.borbo3.txt index d63e990c4..d17152029 100644 --- a/config/symbols.us.borbo3.txt +++ b/config/symbols.us.borbo3.txt @@ -51,7 +51,7 @@ UnkCollisionFunc = 0x801973E4; CheckFieldCollision = 0x8019750C; GetPlayerCollisionWith = 0x80197664; ReplaceBreakableWithItemDrop = 0x801979A8; -func_8018CAB0 = 0x80197A60; +PrizeDropFall = 0x80197A60; func_8018CB34 = 0x80197AE4; CollectHeart = 0x80197C40; CollectGold = 0x80197CC0; diff --git a/config/symbols.us.stno0.txt b/config/symbols.us.stno0.txt index 2f5330231..3e56f3c9a 100644 --- a/config/symbols.us.stno0.txt +++ b/config/symbols.us.stno0.txt @@ -110,7 +110,7 @@ UnkCollisionFunc = 0x801C8634; CheckFieldCollision = 0x801C875C; GetPlayerCollisionWith = 0x801C88B4; ReplaceBreakableWithItemDrop = 0x801C8BF8; -func_8018CAB0 = 0x801C8CB0; +PrizeDropFall = 0x801C8CB0; func_8018CB34 = 0x801C8D34; CollectHeart = 0x801C8E90; CollectGold = 0x801C8F10; diff --git a/src/boss/rbo3/us.c b/src/boss/rbo3/us.c index 2619997fa..ffa88b6d0 100644 --- a/src/boss/rbo3/us.c +++ b/src/boss/rbo3/us.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later #include "common.h" +#include "stage.h" INCLUDE_ASM("boss/rbo3/nonmatchings/us", func_801A7D64); @@ -138,7 +139,7 @@ INCLUDE_ASM("boss/rbo3/nonmatchings/us", GetPlayerCollisionWith); INCLUDE_ASM("boss/rbo3/nonmatchings/us", ReplaceBreakableWithItemDrop); -INCLUDE_ASM("boss/rbo3/nonmatchings/us", func_8018CAB0); +#include "../../st/prize_drop_fall.h" INCLUDE_ASM("boss/rbo3/nonmatchings/us", func_8018CB34); diff --git a/src/st/cen/e_collect.c b/src/st/cen/e_collect.c index 3aeccbb2b..06de5b7a0 100644 --- a/src/st/cen/e_collect.c +++ b/src/st/cen/e_collect.c @@ -9,7 +9,7 @@ // e_collect -INCLUDE_ASM("st/cen/nonmatchings/e_collect", func_8018CAB0); +#include "../prize_drop_fall.h" INCLUDE_ASM("st/cen/nonmatchings/e_collect", func_8018CB34); diff --git a/src/st/e_collect.h b/src/st/e_collect.h index 50f84084f..ff203e909 100644 --- a/src/st/e_collect.h +++ b/src/st/e_collect.h @@ -142,23 +142,7 @@ static u8* g_ExplosionAnimations[] = { // from another file extern u16 g_InitializeData0[]; -static void func_8018CAB0(void) { - if (g_CurrentEntity->velocityY >= 0) { - g_CurrentEntity->ext.equipItemDrop.fallSpeed += - g_CurrentEntity->ext.equipItemDrop.gravity; - g_CurrentEntity->velocityX = - g_CurrentEntity->ext.equipItemDrop.fallSpeed; - if (g_CurrentEntity->velocityX == FIX(1) || - g_CurrentEntity->velocityX == FIX(-1)) { - g_CurrentEntity->ext.equipItemDrop.gravity = - -g_CurrentEntity->ext.equipItemDrop.gravity; - } - } - - if (g_CurrentEntity->velocityY < FIX(0.25)) { - g_CurrentEntity->velocityY += FIX(0.125); - } -} +#include "prize_drop_fall.h" static void func_8018CB34(u16 arg0) { Collider collider; @@ -192,7 +176,7 @@ static void func_8018CB34(u16 arg0) { } else { if (!(collider.effects & EFFECT_NOTHROUGH)) { MoveEntity(); - func_8018CAB0(); + PrizeDropFall(); } } } @@ -414,7 +398,7 @@ void EntityPrizeDrop(Entity* self) { self->ext.equipItemDrop.aliveTimer = 0x60; self->step++; } else { - func_8018CAB0(); + PrizeDropFall(); } break; case 3: diff --git a/src/st/no0/e_collect.c b/src/st/no0/e_collect.c index c749d25da..25f74fc43 100644 --- a/src/st/no0/e_collect.c +++ b/src/st/no0/e_collect.c @@ -1,7 +1,8 @@ // SPDX-License-Identifier: AGPL-3.0-or-later #include "common.h" +#include "stage.h" -INCLUDE_ASM("st/no0/nonmatchings/e_collect", func_8018CAB0); +#include "../prize_drop_fall.h" INCLUDE_ASM("st/no0/nonmatchings/e_collect", func_8018CB34); diff --git a/src/st/prize_drop_fall.h b/src/st/prize_drop_fall.h new file mode 100644 index 000000000..02bd4efc9 --- /dev/null +++ b/src/st/prize_drop_fall.h @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +static void PrizeDropFall(void) { + if (g_CurrentEntity->velocityY >= 0) { + g_CurrentEntity->ext.equipItemDrop.fallSpeed += + g_CurrentEntity->ext.equipItemDrop.gravity; + g_CurrentEntity->velocityX = + g_CurrentEntity->ext.equipItemDrop.fallSpeed; + if (g_CurrentEntity->velocityX == FIX(1) || + g_CurrentEntity->velocityX == FIX(-1)) { + g_CurrentEntity->ext.equipItemDrop.gravity = + -g_CurrentEntity->ext.equipItemDrop.gravity; + } + } + + if (g_CurrentEntity->velocityY < FIX(0.25)) { + g_CurrentEntity->velocityY += FIX(0.125); + } +} diff --git a/src/st/wrp/header.c b/src/st/wrp/header.c index 2e82c6711..83d91342e 100644 --- a/src/st/wrp/header.c +++ b/src/st/wrp/header.c @@ -6,7 +6,7 @@ void HitDetection(void); void CreateEntityWhenInHorizontalRange(LayoutEntity*); void func_8018A520(s16); void UpdateRoomPosition(void); -void func_8018CAB0(void); +void PrizeDropFall(void); void InitRoomEntities(s32 objLayoutId); void PlaySfxPositional(u16); void BottomCornerText(u8*, u8); diff --git a/src/st/wrp_psp/e_collect.c b/src/st/wrp_psp/e_collect.c index af52ce621..d3345954d 100644 --- a/src/st/wrp_psp/e_collect.c +++ b/src/st/wrp_psp/e_collect.c @@ -98,23 +98,7 @@ static s8 c_HeartPrizes[] = {1, 5}; static s32 g_ExplosionYVelocities[] = { FIX(-1.0), FIX(-1.5), FIX(-1.5), FIX(-1.5), FIX(-3.0)}; -static void func_8018CAB0(void) { - if (g_CurrentEntity->velocityY >= 0) { - g_CurrentEntity->ext.equipItemDrop.fallSpeed += - g_CurrentEntity->ext.equipItemDrop.gravity; - g_CurrentEntity->velocityX = - g_CurrentEntity->ext.equipItemDrop.fallSpeed; - if (g_CurrentEntity->velocityX == FIX(1) || - g_CurrentEntity->velocityX == FIX(-1)) { - g_CurrentEntity->ext.equipItemDrop.gravity = - -g_CurrentEntity->ext.equipItemDrop.gravity; - } - } - - if (g_CurrentEntity->velocityY < FIX(0.25)) { - g_CurrentEntity->velocityY += FIX(0.125); - } -} +#include "../prize_drop_fall.h" static void func_8018CB34(u16 arg0) { Collider collider; @@ -151,7 +135,7 @@ static void func_8018CB34(u16 arg0) { if (!(collider.effects & EFFECT_NOTHROUGH)) { MoveEntity(); - func_8018CAB0(); + PrizeDropFall(); } } @@ -350,7 +334,7 @@ void EntityPrizeDrop(Entity* self) { self->ext.equipItemDrop.aliveTimer = 0x60; self->step++; } else { - func_8018CAB0(); + PrizeDropFall(); } break; case 3: