From 96995c700490b3306deb05359a4bdba26f46af3b Mon Sep 17 00:00:00 2001 From: Lol Bozo Date: Sun, 11 Aug 2024 18:12:05 -0400 Subject: [PATCH 1/3] AddLife and Update Flash added --- config/symbol_addrs.txt | 3 +++ include/alo.h | 7 +++++++ include/coin.h | 16 ++++++++++++++++ src/P2/coin.c | 15 ++++++++++++++- src/P2/flash.c | 9 ++++++++- 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/config/symbol_addrs.txt b/config/symbol_addrs.txt index 7babc13f..aaa470b2 100644 --- a/config/symbol_addrs.txt +++ b/config/symbol_addrs.txt @@ -77,6 +77,7 @@ snd_SendIOPCommandNoWait = 0x11e8c8; // type:func // P2/alo.c //////////////////////////////////////////////////////////////// InitAlo__FP3ALO = 0x123ED0; // type:func +UpdateAlo__FP3ALOf = 0x124FC0; // type:func //////////////////////////////////////////////////////////////// // P2/binoc.c @@ -351,6 +352,8 @@ CollectLifetkn__FP7LIFETKN = 0x148FF0; // type:func FUN_00149168 = 0x149168; // type:func break_bottle = 0x149190; // type:func +s_asnipDprize = 0x2619A0; // size:0x3c + //////////////////////////////////////////////////////////////// // P2/difficulty.c //////////////////////////////////////////////////////////////// diff --git a/include/alo.h b/include/alo.h index 56938c32..3cfd41c2 100644 --- a/include/alo.h +++ b/include/alo.h @@ -56,4 +56,11 @@ struct ALO : public LO */ void InitAlo(ALO *palo); +/** + * @brief Updates an ALO + * + * @param palo ALO to initialize + */ +void UpdateAlo(ALO *palo, float dt); + #endif // ALO_H diff --git a/include/coin.h b/include/coin.h index cad16028..346ca186 100644 --- a/include/coin.h +++ b/include/coin.h @@ -18,6 +18,16 @@ struct COIN; struct KEY; struct CHARM; +/** + * @brief Unknown +*/ +struct SNIP +{ + int grfsnip; + OID oid; + int ib; +}; + /** * @brief DPRIZE state. * @@ -122,6 +132,12 @@ void InitDprize(DPRIZE *pdprize); */ void InitCoin(COIN *pcoin); +/** + * @brief Add a life + * + */ +void AddLife(void *ptr); + /** * @brief Initializes a Charm * diff --git a/src/P2/coin.c b/src/P2/coin.c index de613f45..5081eb0c 100644 --- a/src/P2/coin.c +++ b/src/P2/coin.c @@ -1,5 +1,6 @@ #include #include +#include void InitDprize(DPRIZE *pdprize) { @@ -61,7 +62,19 @@ INCLUDE_ASM(const s32, "P2/coin", UpdateCoin__FP4COINf); INCLUDE_ASM(const s32, "P2/coin", CreateSwCharm__FP2SW); -INCLUDE_ASM(const s32, "P2/coin", AddLife__FPv); +void AddLife(void *ptr) +{ + int new_clife; + int capped_clife; + + new_clife = g_pgsCur->clife + 1; + capped_clife = 99; + if (new_clife < 99) + { + capped_clife = new_clife; + } + g_pgsCur->clife = capped_clife; +} INCLUDE_ASM(const s32, "P2/coin", OnCoinSmack__FP4COIN); diff --git a/src/P2/flash.c b/src/P2/flash.c index b8fc4ce1..feefc69e 100644 --- a/src/P2/flash.c +++ b/src/P2/flash.c @@ -1,10 +1,17 @@ #include +#include + +extern CLOCK g_clock; INCLUDE_ASM(const s32, "P2/flash", InitFlash__FP5FLASH); INCLUDE_ASM(const s32, "P2/flash", LoadFlashFromBrx__FP5FLASHP18CBinaryInputStream); -INCLUDE_ASM(const s32, "P2/flash", UpdateFlash__FP5FLASHf); +void UpdateFlash(FLASH *pflash,float dt) +{ + UpdateAlo((ALO *)pflash,dt); + pflash->gScaleCur = GSmooth(pflash->gScaleCur, pflash->gScaleTarget, g_clock.dt, &pflash->smpScale, 0); +} INCLUDE_ASM(const s32, "P2/flash", RenderFlashSelf__FP5FLASHP2CMP2RO); From 76546e5fca2e8071a1b77e05a78dce21bc7597fa Mon Sep 17 00:00:00 2001 From: Lol Bozo Date: Sun, 11 Aug 2024 19:46:25 -0400 Subject: [PATCH 2/3] LoadDprizeFromBrx added --- config/symbol_addrs.txt | 3 +++ include/alo.h | 29 +++++++++++++++++++++++++++++ include/coin.h | 21 +++++++++++---------- src/P2/coin.c | 7 ++++++- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/config/symbol_addrs.txt b/config/symbol_addrs.txt index aaa470b2..3481b08c 100644 --- a/config/symbol_addrs.txt +++ b/config/symbol_addrs.txt @@ -77,7 +77,10 @@ snd_SendIOPCommandNoWait = 0x11e8c8; // type:func // P2/alo.c //////////////////////////////////////////////////////////////// InitAlo__FP3ALO = 0x123ED0; // type:func +SnipAloObjects__FP3ALOiP4SNIP = 0x124DF8; // type:func UpdateAlo__FP3ALOf = 0x124FC0; // type:func +LoadAloFromBrx__FP3ALOP18CBinaryInputStream = 0x1289C0; // type:func +SetAloTargetHitTest__FP3ALOi = 0x12AA28; // type:func //////////////////////////////////////////////////////////////// // P2/binoc.c diff --git a/include/alo.h b/include/alo.h index 3cfd41c2..28c80765 100644 --- a/include/alo.h +++ b/include/alo.h @@ -8,6 +8,9 @@ #include #include +// Forward +struct CBinaryInputStream; + struct FICG { uchar grficSweep; @@ -17,6 +20,16 @@ struct FICG uchar grficShock; }; +/** + * @brief Unknown +*/ +struct SNIP +{ + int grfsnip; + OID oid; + int ib; +}; + /** * @brief "Lightweight" * @@ -56,6 +69,12 @@ struct ALO : public LO */ void InitAlo(ALO *palo); +/** + * @brief unknown + * + */ +void SnipAloObjects(ALO *palo, int csnip, SNIP *asnip); + /** * @brief Updates an ALO * @@ -63,4 +82,14 @@ void InitAlo(ALO *palo); */ void UpdateAlo(ALO *palo, float dt); +/** + * @brief unknown + */ +void LoadAloFromBrx(ALO *palo, CBinaryInputStream *pbis); + +/** + * @brief unknown + */ +void SetAloTargetHitTest(ALO *palo, int fHitTest); + #endif // ALO_H diff --git a/include/coin.h b/include/coin.h index 346ca186..427c4f44 100644 --- a/include/coin.h +++ b/include/coin.h @@ -18,16 +18,6 @@ struct COIN; struct KEY; struct CHARM; -/** - * @brief Unknown -*/ -struct SNIP -{ - int grfsnip; - OID oid; - int ib; -}; - /** * @brief DPRIZE state. * @@ -125,6 +115,14 @@ struct CHARM : public DPRIZE */ void InitDprize(DPRIZE *pdprize); +/** + * @brief Loads a DPrize from an Input Stream + * + * @param pdprize DPrize to initialize + * @param pbis Input Stream + */ +void LoadDprizeFromBrx(DPRIZE *pdprize, CBinaryInputStream *pbis); + /** * @brief Initializes a DPrize * @@ -152,4 +150,7 @@ void InitCharm(CHARM *pcharm); */ void InitKey(KEY *pkey); + +extern SNIP s_asnipDprize[5]; + #endif // COIN_H diff --git a/src/P2/coin.c b/src/P2/coin.c index 5081eb0c..208d7b07 100644 --- a/src/P2/coin.c +++ b/src/P2/coin.c @@ -18,7 +18,12 @@ void InitDprize(DPRIZE *pdprize) pdprize->fLastBounce = 1; } -INCLUDE_ASM(const s32, "P2/coin", LoadDprizeFromBrx__FP6DPRIZEP18CBinaryInputStream); +void LoadDprizeFromBrx(DPRIZE *pdprize, CBinaryInputStream *pbis) +{ + SetAloTargetHitTest(pdprize, 1); + LoadAloFromBrx(pdprize, pbis); + SnipAloObjects(pdprize, 5, s_asnipDprize); +} INCLUDE_ASM(const s32, "P2/coin", CloneDprize__FP6DPRIZET0); From a29f3e05184f396ffa341eb0f8f126fdcc8de876 Mon Sep 17 00:00:00 2001 From: Lol Bozo Date: Sun, 25 Aug 2024 21:42:00 -0400 Subject: [PATCH 3/3] Prescale Clq matched --- config/symbol_addrs.txt | 2 +- src/P2/util.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config/symbol_addrs.txt b/config/symbol_addrs.txt index 3481b08c..301df985 100644 --- a/config/symbol_addrs.txt +++ b/config/symbol_addrs.txt @@ -795,7 +795,7 @@ GRandInRange__Fff = 0x1EAAE0; // type:func GRandGaussian = 0x1EAB48; // type:func FFloatsNear__Ffff = 0x1EAC68; // type:func CSolveQuadratic = 0x1EACA0; // type:func -PrescaleClq = 0x1EAD30; // type:func +PrescaleClq__FP3CLQffT0 = 0x1EAD30; // type:func CalculateSinCos__FfPfT1 = 0x1EAD88; // type:func GTrunc = 0x1EAE78; // type:func GTrunc1 = 0x1EAF28; // type:func diff --git a/src/P2/util.c b/src/P2/util.c index be73c27e..9ebe1d7e 100644 --- a/src/P2/util.c +++ b/src/P2/util.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -103,7 +104,12 @@ int FFloatsNear(float g1,float g2,float gEpsilon) INCLUDE_ASM(const s32, "P2/util", CSolveQuadratic); -INCLUDE_ASM(const s32, "P2/util", PrescaleClq); +void PrescaleClq(CLQ *pclqSrc, float ru, float du, CLQ *pclqDst) +{ + pclqDst->w = pclqSrc->w * ru * ru; + pclqDst->v = (pclqSrc->w + pclqSrc->w) * ru * du + pclqSrc->v * ru; + pclqDst->u = pclqSrc->w * du * du + pclqSrc->v * du + pclqSrc->u; +} INCLUDE_ASM(const s32, "P2/util", CalculateSinCos__FfPfT1);