From e0a0cd744284a0b15998cf5865f0f7a5626b3e47 Mon Sep 17 00:00:00 2001 From: CreateSource Date: Fri, 26 Jan 2024 21:49:19 -0500 Subject: [PATCH 1/4] questionable solutions... --- include/game/board/player.h | 2 + src/game/board/player.c | 162 ++++++++++++++++++++++++++++++++++-- src/game/hsfdraw.c | 1 + 3 files changed, 159 insertions(+), 6 deletions(-) diff --git a/include/game/board/player.h b/include/game/board/player.h index 2acc9a20..6e4d7678 100644 --- a/include/game/board/player.h +++ b/include/game/board/player.h @@ -14,6 +14,7 @@ #include "game/gamework_data.h" #include "game/board/main.h" #include "game/board/space.h" +#include "game/board/ui.h" extern s16 boardPlayerMdl[4]; @@ -152,5 +153,6 @@ void BoardPlayerMoveAwayStartCurr(s16, s32); void BoardBowserSuitMotionSetWalk(void); s16 BoardBowserSuitModelGet(void); void UpdateDiceDigit2D(omObjData*); +void MoveAwayObjFunc(omObjData*); #endif diff --git a/src/game/board/player.c b/src/game/board/player.c index a2f5f0c3..15b17ece 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -85,7 +85,9 @@ static s32 (*preTurnHook[4])(); s16 boardPlayerMdl[4]; static s16 playerMot[4]; static s8 rollType; +static s8 moveAwayPlayer[4]; static s16 junctionArrowRot[4]; +static omObjData* moveAwayObj; static omObjData* diceDigit2DObj; static omObjData* junctionObj; static s32 junctionMask; @@ -1029,7 +1031,7 @@ static void InitJunction(s32 arg0, s32 arg1, f32 arg8) { s32 var_r22; f32 angle; - if (junctionObj == 0) { + if (!junctionObj) { for (var_r20 = 0; var_r20 < 4; var_r20++) { junctionArrowRot[var_r20] = -1; } @@ -1351,7 +1353,7 @@ static inline f32 JunctionArrowRotGetCurr(void) { bitcopy* juncObj; f32 ret; - if (junctionObj == 0) { + if (!junctionObj) { return 0.0f; } else { juncObj = (bitcopy*) junctionObj->work; @@ -1365,7 +1367,7 @@ static inline s32 CheckArrowRot(float value) s32 sp58; bitcopy* sp5C; s16 spE; - if (junctionObj == 0) { + if (!junctionObj) { return 0; } else { sp5C = (bitcopy*) junctionObj->work; @@ -1428,7 +1430,7 @@ static s32 ExecJunction(s32 arg0, s16* arg1) { for (var_r28 = 0; var_r28 < var_r21; var_r28++) { sp88 = BoardSpaceGet(0, spD0[var_r28]); - if (sp88 == 0) { + if (!sp88) { spD0[var_r28] = 0; } else { PSVECSubtract(&sp88->pos, &spAC, &spB8); @@ -1731,7 +1733,7 @@ void BoardPlayerDiceJumpStart(s32 arg0) { } s32 BoardPlayerDiceJumpCheck(s32 arg0) { - if (diceJumpObj[arg0] == 0) { + if (!diceJumpObj[arg0]) { return 0; } if (diceJumpObj[arg0]->work[1] == 0) { @@ -1939,7 +1941,7 @@ typedef struct bitcopy3 { u8 field00_bit5 : 2; u8 field00_bit7 : 1; }; - u8 unk_01; + s8 unk_01; s8 unk_02; s8 unk_03; s16 unk_04; @@ -2040,6 +2042,154 @@ static void UpdateDiceDigitSprite(omObjData* arg0) { } } +static void UpdateDiceDigit2D(omObjData* arg0) { + f32 var_f30; + bitcopy3* temp_r30; + + temp_r30 = (bitcopy3*) diceDigit2DObj->work; + if ((temp_r30->field00_bit0 != 0) || (BoardIsKill() != 0)) { + if (temp_r30->unk_04 != -1) { + HuSprGrpKill(temp_r30->unk_04); + temp_r30->unk_04 = -1; + } + diceDigit2DObj = NULL; + omDelObjEx(HuPrcCurrentGet(), arg0); + return; + } + if (temp_r30->unk_03 == 0) { + temp_r30->unk_01 += 4; + if (temp_r30->unk_01 >= 0x5A) { + temp_r30->unk_03 = 1; + } + + OSs8tof32(&temp_r30->unk_01, &var_f30); + var_f30 *= 2.0f; + if (var_f30 >= 90.0f) { + var_f30 -= 90.0f; + } + } + + { // hack until the compiler does what we want + f32 sp1C[2]; + f32 spC[2] = { 320.0f, 256.0f }; + s32 sp14[2]; + s32 var_r30; + s32 temp_r29; + bitcopy3* temp_r31; + + temp_r31 = (bitcopy3*) arg0->work; + temp_r29 = GWPlayer[temp_r31->unk_02].roll; + if (temp_r29 != 0) { + sp14[0] = temp_r29 % 10; + sp14[1] = temp_r29 / 10; + } else { + temp_r31->field00_bit0 = 1; + } + + for (var_r30 = 0; var_r30 < 2; var_r30++) { + if (((var_r30 == 1) && (sp14[1] == 0)) || (temp_r31->field00_bit1 == 0)) { + HuSprAttrSet(temp_r31->unk_04, var_r30, 4); + } else { + if ((sp14[1] == 0) && (var_r30 == 0)) { + sp1C[0] = 288.0f; + } else { + sp1C[0] = spC[var_r30]; + } + sp1C[1] = 176.0f; + HuSprAttrReset(temp_r31->unk_04, var_r30, 4); + HuSprBankSet(temp_r31->unk_04, var_r30, sp14[var_r30]); + HuSprPosSet(temp_r31->unk_04, var_r30, sp1C[0], sp1C[1]); + } + } + } +} + +void BoardPlayerBtnDownWait(s32 arg0, u32 arg1) { + s32 spC; + s32 sp8; + s32 temp_r31; + + temp_r31 = GWPlayer[arg0].port; + while (1) { + if ((HuPadBtnDown[temp_r31] & arg1) != 0) return; + HuPrcVSleep(); + } +} + +void BoardPlayerAutoSizeSet(s32 player, s32 value) { + PlayerState* temp_r28; + + temp_r28 = BoardPlayerGet(player); + if ((temp_r28->auto_size != 0) || (value == 0)) { + BoardStatusHammerKill(player); + } + temp_r28->auto_size = value; + if (value != 0) { + BoardStatusHammerCreate(player); + } +} + +s32 BoardPlayerAutoSizeGet(s32 arg0) { + PlayerState* temp_r30 = BoardPlayerGet(arg0); + + if (temp_r30 != 0 ) { + arg0 = temp_r30->auto_size; + } + return arg0; +} + +u32 BoardPlayerMoveAwayIsDone(void) { + if (!moveAwayObj) { + return 0; + } + return 1; +} + +void BoardPlayerMoveAwayStart(s32 arg0, s32 arg1, s32 arg2) { + bitcopy3* temp_r25; + Point3d sp28; + Point3d sp1C; + Point3d sp10; + s32 temp_r29; + s32 var_r30; + s32 var_r31; + s32 var_r28; + s32 var_r27; + + moveAwayPlayer[0] = moveAwayPlayer[1] = moveAwayPlayer[2] = moveAwayPlayer[3] = -1; + var_r30 = arg0 + 1; + + var_r27 = 0; + // hack + for (var_r28 = var_r28 = var_r27; var_r27 < 4; var_r27++, var_r30++) { + var_r30 &= 3; + + for (var_r31 = 0; var_r31 < 4; var_r31++) { + if ((var_r31 == var_r30) && (arg1 == GWPlayer[var_r31].space_curr)) { + moveAwayPlayer[var_r28++] = var_r31; + } + } + } + BoardSpaceRotGet(0, arg1, &sp28); + + for (var_r31 = 0; var_r31 < var_r28; var_r31++) { + BoardSpaceCornerPosGet(arg1, var_r31, &sp1C); + temp_r29 = moveAwayPlayer[var_r31]; + if (arg2 != 0) { + BoardPlayerPosSetV(temp_r29, &sp1C); + moveAwayPlayer[var_r31] = -1; + } else { + BoardPlayerPosGet(temp_r29, &sp10); + BoardPlayerPosLerpStart(temp_r29, &sp10, &sp1C, 0x19); + } + } + if (arg2 == 0) { + moveAwayObj = omAddObjEx(boardObjMan, 0x100, 0U, 0U, -1, &MoveAwayObjFunc); + temp_r25 = (bitcopy3*) moveAwayObj->work; + temp_r25->field00_bit0 = 0; + } +} + // ... void BoardPlayerCopyMat(s32 arg0) { diff --git a/src/game/hsfdraw.c b/src/game/hsfdraw.c index 5d360457..fc130c03 100755 --- a/src/game/hsfdraw.c +++ b/src/game/hsfdraw.c @@ -441,6 +441,7 @@ static void FaceDraw(HsfdrawStruct00 *arg0, HsfdrawStruct02 *arg1) { s16 var_r24; s16 var_r31; s16 var_r17; + s16 var_r6; u32 temp_r19; HsfConstData *temp_r20; HsfMaterial *temp_r30; From 2257e6b63d877f6f02c466cbb7dc621752f7888a Mon Sep 17 00:00:00 2001 From: CreateSource Date: Sat, 24 Feb 2024 20:10:37 -0500 Subject: [PATCH 2/4] small player update --- include/game/board/player.h | 2 +- src/game/board/player.c | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/include/game/board/player.h b/include/game/board/player.h index 6e4d7678..4d75f4e4 100644 --- a/include/game/board/player.h +++ b/include/game/board/player.h @@ -149,7 +149,7 @@ void BoardDiceDigit2DShowSet(s32); s32 DoSparkSpace(s32, s16*); s32 MegaPlayerPassFunc(s32, s16); s32 BoardPlayerMotBlendCheck(s32); -void BoardPlayerMoveAwayStartCurr(s16, s32); +void BoardPlayerMoveAwayStartCurr(s32, s32); void BoardBowserSuitMotionSetWalk(void); s16 BoardBowserSuitModelGet(void); void UpdateDiceDigit2D(omObjData*); diff --git a/src/game/board/player.c b/src/game/board/player.c index 15b17ece..1ffdb54c 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -2139,7 +2139,7 @@ s32 BoardPlayerAutoSizeGet(s32 arg0) { } u32 BoardPlayerMoveAwayIsDone(void) { - if (!moveAwayObj) { + if (moveAwayObj) { return 0; } return 1; @@ -2190,6 +2190,31 @@ void BoardPlayerMoveAwayStart(s32 arg0, s32 arg1, s32 arg2) { } } +void BoardPlayerMoveAwayStartCurr(s32 arg0, s32 arg1) { + BoardPlayerMoveAwayStart(GWSystem.player_curr, arg0, arg1); +} + +static void MoveAwayObjFunc(omObjData* arg0) { + s32 var_r31; + bitcopy3* temp_r30; + + temp_r30 = (bitcopy3*) arg0->work; + if ((temp_r30->field00_bit0 != 0) || (BoardIsKill() != 0)) { + moveAwayObj = 0; + omDelObjEx(HuPrcCurrentGet(), arg0); + return; + } + + for (var_r31 = 0; var_r31 < 4; var_r31++) { + if (moveAwayPlayer[var_r31] != -1) { + if (GWPlayer[moveAwayPlayer[var_r31]].moving != 0) return; + BoardPlayerMotBlendSet(moveAwayPlayer[var_r31], 0, 15); + moveAwayPlayer[var_r31] = -1; + } + } + temp_r30->field00_bit0 = 1; +} + // ... void BoardPlayerCopyMat(s32 arg0) { From c47d2d5c1ecd7c9d209bacb44bc9197b6f9f126c Mon Sep 17 00:00:00 2001 From: CreateSource Date: Sat, 24 Feb 2024 21:09:19 -0500 Subject: [PATCH 3/4] another small player update --- include/game/board/player.h | 1 + src/game/board/player.c | 72 +++++++++++++++++++++++++++++++++++-- 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/include/game/board/player.h b/include/game/board/player.h index 0bf9e1d8..66df59c1 100644 --- a/include/game/board/player.h +++ b/include/game/board/player.h @@ -155,5 +155,6 @@ void BoardBowserSuitMotionSetWalk(void); s16 BoardBowserSuitModelGet(void); void UpdateDiceDigit2D(omObjData*); void MoveAwayObjFunc(omObjData*); +void UpdateBowserSuit(omObjData*); #endif diff --git a/src/game/board/player.c b/src/game/board/player.c index fc8420ce..acaa3a31 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -65,6 +65,7 @@ static omObjData* moveAwayObj; static omObjData* diceDigit2DObj; static omObjData* junctionObj; static s32 junctionMask; +static omObjData* bowserSuitObj; static s32 rollResized; static s16 suitMdl = -1; @@ -1023,8 +1024,8 @@ static void InitJunction(s32 arg0, s32 arg1, f32 arg8) { temp_r29->unk_01 = 0; var_r28->scale.x = var_r28->scale.y = var_r28->scale.z = 3.0f; HuWinMesMaxSizeGet(1, &sp3C, 0x90003); - var_f27 = 304.0f; - var_f28 = -10000.0f; + var_f27 = -10000.0f; + var_f28 = 304.0f; temp_r29->unk_04 = HuWinCreate(var_f27, var_f28, sp3C, sp40, 0); HuWinBGTPLvlSet(temp_r29->unk_04, 0.0f); HuWinMesSpeedSet(temp_r29->unk_04, 0); @@ -1743,7 +1744,7 @@ static void DiceJumpFunc(omObjData* arg0) { temp_f31 = BoardPlayerMotionTimeGet(temp_r31->field00_bit1); if (BoardPlayerSizeGet(temp_r31->field00_bit1) == 1) { BoardPlayerPosGet(temp_r31->field00_bit1, &sp38); - sp38.y += 10.0f + (-(49.0f/2400.0f) * temp_r31->unk_08 * temp_r31->unk_08); + sp38.y += 10.0f + (-0.020416668f * temp_r31->unk_08 * temp_r31->unk_08); temp_r31->unk_08 += 1.0f; if (sp38.y < temp_r31->unk_0C) { sp38.y = temp_r31->unk_0C; @@ -2204,3 +2205,68 @@ void BoardPlayerCopyMat(s32 arg0) { memcpy(temp_r3, temp_r31->material, temp_r31->materialCnt * 0x3C); playerMatCopy[arg0] = temp_r3; } + +void BoardBowserSuitInit(s32 arg0) { + omObjData* temp_r3; + s32 temp_r27; + s32 var_r29; + s32 temp; + bitcopy3* temp_r31; + + + for (var_r29 = 0; var_r29 < 4; var_r29++) { + } + temp_r27 = GWPlayer[arg0].character; + temp = BoardDataDirReadAsync(0x40000); + BoardDataAsyncWait(temp); + suitMdl = BoardModelCreate(0x40018, NULL, 0); + BoardModelScaleSet(suitMdl, 1.2f, 1.2f, 1.2f); + suitPlayerMdl = BoardModelCreate(bowserSuitCharMdlTbl[temp_r27], NULL, 0); + GWPlayer[arg0].bowser_suit = 1; + temp_r3 = omAddObjEx(boardObjMan, 0x100, 0U, 0U, -1, &UpdateBowserSuit); + bowserSuitObj = temp_r3; + temp_r31 = (bitcopy3 *) temp_r3->work; + temp_r31->field00_bit0 = 0; + temp_r31->unk_01 = arg0; + temp_r31->unk_02 = 0; + BoardModelVoiceEnableSet(BoardPlayerModelGet(arg0), 3, 0); + BoardModelVoiceEnableSet(BoardPlayerModelGet(arg0), 4, 0); +} + +void BoardBowserSuitKill(s32 arg0) { + bitcopy3* temp; + + if (bowserSuitObj != 0) { + ((bitcopy3*) bowserSuitObj->work)->field00_bit0 = 1; + } + GWPlayer[arg0].bowser_suit = 0; + BoardModelVoiceEnableSet(BoardPlayerModelGet(arg0), 3, 1); + BoardModelVoiceEnableSet(BoardPlayerModelGet(arg0), 4, 1); + if (suitMdl != -1) { + BoardModelKill(suitMdl); + suitMdl = -1; + } + if (suitPlayerMdl != -1) { + BoardModelKill(suitPlayerMdl); + suitPlayerMdl = -1; + } + HuDataDirClose(0x40000); +} + +s16 BoardBowserSuitModelGet(void) { + return suitMdl; +} + +s16 BoardBowserSuitPlayerModelGet(void) { + return suitPlayerMdl; +} + +void BoardBowserSuitMotionCreate(void) { + s32 var_r31; + + + for (var_r31 = 0; var_r31 < 5; var_r31++) { + bowserSuitMot[var_r31] = (s16) BoardModelMotionCreate(suitMdl, bowserSuitMotTbl[var_r31]); + } + suitCurrMot = -1; +} From 063ab58382ae4ac7551ed6d5e22926ce92457090 Mon Sep 17 00:00:00 2001 From: CreateSource Date: Sat, 24 Feb 2024 22:00:15 -0500 Subject: [PATCH 4/4] another small player update --- include/game/board/player.h | 12 +++++- src/game/board/player.c | 85 ++++++++++++++++++++++++++++++------- 2 files changed, 80 insertions(+), 17 deletions(-) diff --git a/include/game/board/player.h b/include/game/board/player.h index 66df59c1..2cbabee4 100644 --- a/include/game/board/player.h +++ b/include/game/board/player.h @@ -131,7 +131,17 @@ s32 BoardPlayerDiceJumpCheck(s32); static void DiceJumpFunc(omObjData*); void BoardRotateDiceNumbers(s32); void BoardPlayerMotBlendSet(s32 arg0, s16 arg1, s16 arg2); -void UpdateDiceDigitSprite(omObjData*); +static void UpdateDiceDigitSprite(omObjData*); +static void UpdateDiceDigit2D(omObjData*); +void BoardPlayerBtnDownWait(s32, u32); +void BoardPlayerAutoSizeSet(s32, s32); +s32 BoardPlayerAutoSizeGet(s32); +u32 BoardPlayerMoveAwayIsDone(void); +void BoardPlayerMoveAwayStart(s32, s32, s32); +void BoardPlayerMoveAwayStartCurr(s32, s32); +static void MoveAwayObjFunc(omObjData*); +void BoardPlayerCopyMat(s32); +void BoardBowserSuitMotionSetJump(void); //... void BoardPlayerMotBlendExec(omObjData*); s32 BoardPlayerAutoSizeGet(s32); diff --git a/src/game/board/player.c b/src/game/board/player.c index acaa3a31..49e45eed 100644 --- a/src/game/board/player.c +++ b/src/game/board/player.c @@ -2190,22 +2190,6 @@ static void MoveAwayObjFunc(omObjData* arg0) { temp_r30->field00_bit0 = 1; } -// ... - -void BoardPlayerCopyMat(s32 arg0) { - s16 modelID; - ModelData *model; - void* temp_r3; - HsfData* temp_r31; - - modelID = BoardModelIDGet(GetBoardPlayer(arg0)); - model = &Hu3DData[modelID]; - temp_r31 = model->hsfData; - temp_r3 = HuMemDirectMallocNum(HEAP_SYSTEM, temp_r31->materialCnt * 0x3C, 0x10000000U); - memcpy(temp_r3, temp_r31->material, temp_r31->materialCnt * 0x3C); - playerMatCopy[arg0] = temp_r3; -} - void BoardBowserSuitInit(s32 arg0) { omObjData* temp_r3; s32 temp_r27; @@ -2270,3 +2254,72 @@ void BoardBowserSuitMotionCreate(void) { } suitCurrMot = -1; } + +void BoardBowserSuitMotionSetWait(void) { + if (suitCurrMot != 0) { + BoardModelMotionShiftSet(suitMdl, bowserSuitMot[0], 0.0f, 4.0f, 0x40000001); + suitCurrMot = 0; + } +} + +void BoardBowserSuitMotionSetWalk(void) { + if (suitCurrMot != 1) { + BoardModelMotionStart(suitMdl, bowserSuitMot[1], 0x40000001); + suitCurrMot = 1; + } +} + +void BoardBowserSuitMotionSetWin(void) { + BoardModelMotionShiftSet(suitMdl, bowserSuitMot[3], 0.0f, 4.0f, 0); + suitCurrMot = 3; +} + +void BoardBowserSuitMotionSetJump(void) { + BoardModelMotionShiftSet(suitMdl, bowserSuitMot[2], 0.0f, 4.0f, 0); + suitCurrMot = 2; +} + +void BoardBowserSuitPlayerModelKill(void) { + if (suitPlayerMdl != -1) { + BoardModelMotionStart(suitPlayerMdl, 1, 0); + BoardModelMotionSpeedSet(suitPlayerMdl, 0.0f); + } +} + +void UpdateBowserSuit(omObjData* arg0) { + s16 temp_r30; + bitcopy3* temp_r31; + + temp_r31 = (bitcopy3*) arg0->work; + if ((temp_r31->field00_bit0 != 0) || (BoardIsKill() != 0)) { + bowserSuitObj = NULL; + omDelObjEx(HuPrcCurrentGet(), arg0); + return; + } + if ((suitMdl != -1) && (suitCurrMot == 1)) { + temp_r30 = BoardModelMotionTimeGet(suitMdl); + if ((temp_r31->unk_02 == 0) && (((temp_r30 < 15.0f) && (temp_r30 >= 13.0f)) || ((temp_r30 < 40.0f) && (temp_r30 >= 38.0f)))) { + HuAudFXPlay(0x328); + temp_r31->unk_02 = 1; + } + if ((temp_r31->unk_02 != 0) && ((temp_r30 >= 20.0f) || (temp_r30 >= 49.0f))) { + temp_r31->unk_02 = 0; + } + } +} + +// ... + +void BoardPlayerCopyMat(s32 arg0) { + s16 modelID; + ModelData *model; + void* temp_r3; + HsfData* temp_r31; + + modelID = BoardModelIDGet(GetBoardPlayer(arg0)); + model = &Hu3DData[modelID]; + temp_r31 = model->hsfData; + temp_r3 = HuMemDirectMallocNum(HEAP_SYSTEM, temp_r31->materialCnt * 0x3C, 0x10000000U); + memcpy(temp_r3, temp_r31->material, temp_r31->materialCnt * 0x3C); + playerMatCopy[arg0] = temp_r3; +}