From b8e8df1199647a82388151aa506597480526775f Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 19:52:04 -0300 Subject: [PATCH 01/14] decomp marioGetDashSpd --- include/mario/mario.h | 8 ++++++-- include/mot/mot_walk.h | 3 +++ src/motion/mot_walk.c | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 include/mot/mot_walk.h create mode 100644 src/motion/mot_walk.c diff --git a/include/mario/mario.h b/include/mario/mario.h index 6d8ec9f..598cae3 100644 --- a/include/mario/mario.h +++ b/include/mario/mario.h @@ -148,14 +148,18 @@ typedef struct MarioWork { Vec wPlayerCollisionBox; //0x1B4 JP, 0x1B8 US u8 field_0x1C0[0x1D8 - 0x1C0]; //0x1C0 s32 field_0x1D8; //0x1D8 - u8 field_0x1DC[0x228 - 0x1DC]; //0x1DC + u8 field_0x1DC[0x224 - 0x1DC]; //0x1DC + f32 playerGravity; //0x224 JP, 228 US s32 paperAnimGroupId[3]; //0x228 JP, 0x22C US u8 field_0x234[0x23C - 0x234]; //0x234 s32 paperPoseId; //0x23C JP, 0x240 US u8 field_0x240[0x241 - 0x240]; //0x240 s8 currPartySlotId[2]; //0x241 JP, 0x245 US s8 prevPartyMemberId[2]; //0x243 JP, 0x247 US - u8 field_0x245[0x288 - 0x245]; //0x245 + u8 field_0x245[0x24E - 0x245]; //0x245 + u8 wStickDir1; //0x24E JP, 0x252 US + u8 wStickDir2; //0x24F JP, 0x253 US + u8 field_0x250[0x288 - 0x250]; //0x250 void* motStruct; //0x288, motion userdata, TODO rename? u8 field_0x28C[0x2A8 - 0x28C]; //0x28C f32 wCamVal1; //0x2A8, TODO: double check diff --git a/include/mot/mot_walk.h b/include/mot/mot_walk.h new file mode 100644 index 0000000..d416cd6 --- /dev/null +++ b/include/mot/mot_walk.h @@ -0,0 +1,3 @@ +#include "dolphin/types.h" + +f32 marioGetDashSpd(void); diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c new file mode 100644 index 0000000..5ddf1f6 --- /dev/null +++ b/src/motion/mot_walk.c @@ -0,0 +1,26 @@ +#include "dolphin/types.h" +#include "mario/mario.h" + +f32 marioGetDashSpd(void) { + MarioWork* mario; + f32 dashSpeed; + u8 stickDir2; + u8 stickDir1; + + mario = marioGetPtr(); + dashSpeed = mario->mBaseDashSpeed; + if (mario->flags & MARIO_FLAG_PAPER_MODE) { + stickDir1 = mario->wStickDir1; + stickDir2 = mario->wStickDir2; + dashSpeed = mario->mBaseWalkSpeed; + + if (((s8)stickDir1 * (s8)stickDir1) + ((s8)stickDir2 * (s8)stickDir2) <= 0xBD1) { + dashSpeed *= 0.5f; + } + } else if (marioBgmodeChk() == 1) { + dashSpeed *= 0.5f; + } + + dashSpeed *= mario->playerGravity; + return dashSpeed; +} From ab130819e6a1ae7958c7df83050670f06980a37e Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 19:53:07 -0300 Subject: [PATCH 02/14] add commented out m2c output --- src/motion/mot_walk.c | 326 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 326 insertions(+) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 5ddf1f6..4020ca1 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -1,6 +1,249 @@ #include "dolphin/types.h" #include "mario/mario.h" +// void mot_dash(void) { +// f32 var_f31; +// s32 temp_r3_3; +// s32 var_r0; +// s32 var_r4; +// u8 temp_r0; +// u8 temp_r0_2; +// u8 temp_r0_3; +// u8 temp_r3_5; +// u8 temp_r3_6; +// void* temp_r3; +// void* temp_r3_2; +// void* temp_r3_4; + +// temp_r3 = marioGetPtr(); +// temp_r0 = temp_r3->unk3C; +// if ((s8) temp_r0 == 2) { +// kpa_dash(); +// return; +// } +// if ((s8) temp_r0 == 1) { +// peach_dash(); +// return; +// } +// if ((u32) temp_r3->unk1EC == 0U) { +// var_r0 = 0; +// } else { +// temp_r3_2 = caseCheckHitObj(); +// if ((temp_r3_2 != NULL) && ((s32) temp_r3_2->unk4 == 0xA)) { +// var_r0 = 1; +// } else { +// var_r0 = 0; +// } +// } +// if ((var_r0 == 0) && ((u32) temp_r3->unk1EC == 0U)) { +// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFFF7FFF); +// if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { +// marioChgPose("M_R_1"); +// } +// } +// temp_r3_3 = temp_r3->unkC; +// if (temp_r3_3 & 1) { +// temp_r3->unkC = (s32) (temp_r3_3 & 0xFFFFFFFE); +// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFF0FFFF); +// marioResetCamFollowRate(); +// if (temp_r3->unk0 & 0x100000) { +// motSlitContinue(); +// } +// if (temp_r3->unk224 == 1.0f) { +// if (temp_r3->unk0 & 0x8000) { +// if (marioChkPushAnime() == 0) { +// marioChgPose("M_O_1"); +// } +// } else if (marioBgmodeChk() == 0) { +// marioChgPose("M_R_1"); +// } +// } else if (temp_r3->unk0 & 0x8000) { +// if (marioChkPushAnime() == 0) { +// marioChgPose("M_O_1"); +// } +// } else { +// marioChgPose("M_W_1"); +// } +// if ((s16) temp_r3->unk4E == 0) { +// temp_r3_4 = marioGetPtr(); +// var_f31 = temp_r3_4->unk188; +// if (temp_r3_4->unk0 & 0x100000) { +// temp_r3_5 = temp_r3_4->unk24E; +// temp_r0_2 = temp_r3_4->unk24F; +// var_f31 = temp_r3_4->unk184; +// if ((s32) (((s8) temp_r3_5 * (s8) temp_r3_5) + ((s8) temp_r0_2 * (s8) temp_r0_2)) <= 0xBD1) { +// var_f31 *= 0.5f; +// } +// } else if (marioBgmodeChk() == 1) { +// var_f31 *= 0.5f; +// } +// temp_r3->unk180 = (f32) (var_f31 * temp_r3_4->unk224); +// } +// } +// if (!(temp_r3->unk0 & 0x2000) && ((strcmp(temp_r3->unk18, "M_I_Y") == 0) || ((s8) temp_r3->unk40 > 0xA))) { +// marioChgMot(0); +// return; +// } +// if (temp_r3->unk0 & 0x2000) { +// marioChgMot(1); +// return; +// } +// if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { +// marioChgMot(0x15); +// return; +// } +// if (marioChkItemMotion() == 0) { +// marioChkJump(); +// marioChkTransform(); +// if ((u32) temp_r3->unk1E4 != 0U) { +// if (temp_r3->unk224 == 1.0f) { +// var_r4 = 0x14; +// } else { +// var_r4 = 0x28; +// } +// marioWalkDashSe(var_r4); +// } +// temp_r3->unk48 = (s32) (temp_r3->unk48 + 1); +// if (!(temp_r3->unk0 & 0x20)) { +// temp_r3_6 = temp_r3->unk24E; +// temp_r0_3 = temp_r3->unk24F; +// if ((s32) (((s8) temp_r3_6 * (s8) temp_r3_6) + ((s8) temp_r0_3 * (s8) temp_r0_3)) <= 0xBD1) { +// marioChgMot(1); +// return; +// } +// temp_r3->unk1A0 = (f32) temp_r3->unk194; +// if ((temp_r3->unk0 & 0x8000) && (marioChkPushAnime() == 0)) { +// marioChgPose("M_O_1"); +// } +// if (temp_r3->unk190 == 0.0f) { +// marioChgMot(0); +// } +// } +// } +// } + +// void mot_walk(void) { +// f32 var_f31; +// s32 temp_r3_3; +// s32 temp_r3_6; +// s32 var_r0; +// u8 temp_r0; +// u8 temp_r0_2; +// u8 temp_r0_3; +// u8 temp_r3_5; +// u8 temp_r3_7; +// void* temp_r3; +// void* temp_r3_2; +// void* temp_r3_4; + +// temp_r3 = marioGetPtr(); +// temp_r0 = temp_r3->unk3C; +// if ((s8) temp_r0 == 2) { +// kpa_walk(); +// return; +// } +// if ((s8) temp_r0 == 1) { +// peach_walk(); +// return; +// } +// if (temp_r3->unk0 & 0x8000) { +// if ((u32) temp_r3->unk1EC == 0U) { +// var_r0 = 0; +// } else { +// temp_r3_2 = caseCheckHitObj(); +// if ((temp_r3_2 != NULL) && ((s32) temp_r3_2->unk4 == 0xA)) { +// var_r0 = 1; +// } else { +// var_r0 = 0; +// } +// } +// if (var_r0 == 0) { +// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFFF7FFF); +// if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { +// marioChgPose("M_W_1"); +// } +// } +// } +// temp_r3_3 = temp_r3->unkC; +// if (temp_r3_3 & 1) { +// temp_r3->unkC = (s32) (temp_r3_3 & 0xFFFFFFFE); +// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFF0FFFF); +// marioResetCamFollowRate(); +// if (temp_r3->unk0 & 0x100000) { +// motSlitContinue(); +// } +// if ((s16) temp_r3->unk4E == 0) { +// temp_r3_4 = marioGetPtr(); +// var_f31 = temp_r3_4->unk184; +// if (temp_r3_4->unk0 & 0x100000) { +// temp_r3_5 = temp_r3_4->unk24E; +// temp_r0_2 = temp_r3_4->unk24F; +// if ((s32) (((s8) temp_r3_5 * (s8) temp_r3_5) + ((s8) temp_r0_2 * (s8) temp_r0_2)) <= 0xBD1) { +// var_f31 *= 0.5f; +// } +// } else if (marioBgmodeChk() == 1) { +// var_f31 *= 0.5f; +// } +// temp_r3->unk180 = (f32) (var_f31 * temp_r3_4->unk224); +// } +// temp_r3_6 = temp_r3->unk0; +// if (temp_r3_6 & 0x2000) { +// marioChgPose("M_W_7"); +// } else if (temp_r3_6 & 0x8000) { +// if (marioChkPushAnime() == 0) { +// marioChgPose("M_O_1"); +// } +// } else if (marioBgmodeChk() == 0) { +// marioChgPose("M_W_1"); +// } +// if (!(temp_r3->unk4 & 0x01000000)) { +// temp_r3->unk44 = 0; +// } +// temp_r3->unk48 = 0; +// } +// if (!(temp_r3->unk0 & 0x2000) && ((strcmp(temp_r3->unk18, "M_I_Y") == 0) || ((s8) temp_r3->unk40 > 0xA))) { +// marioChgMot(0); +// return; +// } +// if (temp_r3->unk0 & 0x2000) { +// temp_r3->unk1A0 = (f32) temp_r3->unk194; +// if (temp_r3->unk190 == 0.0f) { +// marioChgMot(0); +// } +// } else { +// if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { +// marioChgMot(0x15); +// return; +// } +// if (marioChkItemMotion() == 0) { +// marioChkJump(); +// marioChkTransform(); +// if (pouchEquipCheckBadge(0x143) == 0) { +// temp_r3_7 = temp_r3->unk24E; +// temp_r0_3 = temp_r3->unk24F; +// if ((s32) (((s8) temp_r3_7 * (s8) temp_r3_7) + ((s8) temp_r0_3 * (s8) temp_r0_3)) > 0xBD1) { +// marioChgMot(2); +// return; +// } +// } +// temp_r3->unk1A0 = (f32) temp_r3->unk194; +// if ((u32) temp_r3->unk1E4 != 0U) { +// if (temp_r3->unk224 == 1.0f) { + +// } +// marioWalkDashSe(0x28); +// } +// temp_r3->unk48 = (s32) (temp_r3->unk48 + 1); +// if ((temp_r3->unk0 & 0x8000) && (marioChkPushAnime() == 0)) { +// marioChgPose("M_O_1"); +// } +// if (temp_r3->unk190 == 0.0f) { +// marioChgMot(0); +// } +// } +// } +// } + f32 marioGetDashSpd(void) { MarioWork* mario; f32 dashSpeed; @@ -24,3 +267,86 @@ f32 marioGetDashSpd(void) { dashSpeed *= mario->playerGravity; return dashSpeed; } + +// f32 marioGetWalkSpd(void) { +// f32 var_f31; +// u8 temp_r0; +// u8 temp_r3_2; +// void* temp_r3; + +// temp_r3 = marioGetPtr(); +// var_f31 = temp_r3->unk184; +// if (temp_r3->unk0 & 0x100000) { +// temp_r3_2 = temp_r3->unk24E; +// temp_r0 = temp_r3->unk24F; +// if ((s32) (((s8) temp_r3_2 * (s8) temp_r3_2) + ((s8) temp_r0 * (s8) temp_r0)) <= 0xBD1) { +// var_f31 *= 0.5f; +// } +// } else if (marioBgmodeChk() == 1) { +// var_f31 *= 0.5f; +// } +// return var_f31 * temp_r3->unk224; +// } + +// void marioWalkDashSe(s32 arg0, u32 arg1) { +// s32 temp_r3; +// void* temp_r31; + +// temp_r31 = marioGetPtr(); +// temp_r3 = hitGetAttr(arg0); +// if ((temp_r31->unk48 % arg1) == 0) { +// if (temp_r3 & 0x100) { +// psndSFXOn_3D(0x143, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x200000) { +// psndSFXOn_3D(0x145, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x100000) { +// psndSFXOn_3D(0x147, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x1000) { +// if (strncmp(gp + 0x12C, "mri", 3) != 0) { +// psndSFXOn_3D(0x149, temp_r31 + 0x8C); +// return; +// } +// psndSFXOn_3D(0x143, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x400000) { +// psndSFXOn_3D(0x14B, temp_r31 + 0x8C); +// return; +// } +// psndSFXOn_3D(0x141, temp_r31 + 0x8C); +// return; +// } +// if ((temp_r31->unk48 % (arg1 >> 1U)) == 0) { +// if (temp_r3 & 0x100) { +// psndSFXOn_3D(0x142, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x200000) { +// psndSFXOn_3D(0x144, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x100000) { +// psndSFXOn_3D(0x146, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x1000) { +// if (strncmp(gp + 0x12C, "mri", 3) != 0) { +// psndSFXOn_3D(0x148, temp_r31 + 0x8C); +// return; +// } +// psndSFXOn_3D(0x142, temp_r31 + 0x8C); +// return; +// } +// if (temp_r3 & 0x400000) { +// psndSFXOn_3D(0x14A, temp_r31 + 0x8C); +// return; +// } +// psndSFXOn_3D(0x140, temp_r31 + 0x8C); +// } +// } From fa2cc74da9dcf10a0d1a22c7e79171205a296214 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 19:55:21 -0300 Subject: [PATCH 03/14] marioGetWalkSpd --- src/motion/mot_walk.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 4020ca1..2b5397c 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -268,25 +268,27 @@ f32 marioGetDashSpd(void) { return dashSpeed; } -// f32 marioGetWalkSpd(void) { -// f32 var_f31; -// u8 temp_r0; -// u8 temp_r3_2; -// void* temp_r3; +f32 marioGetWalkSpd(void) { + f32 walkSpeed; + u8 stickDir2; + u8 stickDir1; + MarioWork* mario; -// temp_r3 = marioGetPtr(); -// var_f31 = temp_r3->unk184; -// if (temp_r3->unk0 & 0x100000) { -// temp_r3_2 = temp_r3->unk24E; -// temp_r0 = temp_r3->unk24F; -// if ((s32) (((s8) temp_r3_2 * (s8) temp_r3_2) + ((s8) temp_r0 * (s8) temp_r0)) <= 0xBD1) { -// var_f31 *= 0.5f; -// } -// } else if (marioBgmodeChk() == 1) { -// var_f31 *= 0.5f; -// } -// return var_f31 * temp_r3->unk224; -// } + mario = marioGetPtr(); + walkSpeed = mario->mBaseWalkSpeed; + if (mario->flags & MARIO_FLAG_PAPER_MODE) { + stickDir1 = mario->wStickDir1; + stickDir2 = mario->wStickDir2; + if (((s8) stickDir1 * (s8) stickDir1) + ((s8) stickDir2 * (s8) stickDir2) <= 0xBD1) { + walkSpeed *= 0.5f; + } + } else if (marioBgmodeChk() == 1) { + walkSpeed *= 0.5f; + } + + walkSpeed *= mario->playerGravity; + return walkSpeed; +} // void marioWalkDashSe(s32 arg0, u32 arg1) { // s32 temp_r3; From 38d2d8aa867bfed951ad0cddc4402169202fe112 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 20:33:54 -0300 Subject: [PATCH 04/14] matching marioWalkDashSe --- include/pmario_sound.h | 1 + src/motion/mot_walk.c | 126 +++++++++++++++++++++-------------------- src/pmario_sound.c | 2 +- 3 files changed, 67 insertions(+), 62 deletions(-) diff --git a/include/pmario_sound.h b/include/pmario_sound.h index 507493f..1718fdc 100644 --- a/include/pmario_sound.h +++ b/include/pmario_sound.h @@ -113,6 +113,7 @@ void psndSFXAllOff(void); void psndSFXOn(const char* name); +void psndSFXOn_3D(const char* name, Vec* position); BOOL psndBGMOff_f_d(s32 flags, u16 fadetime, BOOL someswitch); diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 2b5397c..351fb7b 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -1,6 +1,10 @@ #include "dolphin/types.h" +#include "driver/hitdrv.h" +#include "pmario_sound.h" #include "mario/mario.h" +extern s32 gp; // m2c + // void mot_dash(void) { // f32 var_f31; // s32 temp_r3_3; @@ -290,65 +294,65 @@ f32 marioGetWalkSpd(void) { return walkSpeed; } -// void marioWalkDashSe(s32 arg0, u32 arg1) { -// s32 temp_r3; -// void* temp_r31; +void marioWalkDashSe(HitObj* hitObj, u32 arg1) { + s32 hitAttr; + MarioWork* mario; -// temp_r31 = marioGetPtr(); -// temp_r3 = hitGetAttr(arg0); -// if ((temp_r31->unk48 % arg1) == 0) { -// if (temp_r3 & 0x100) { -// psndSFXOn_3D(0x143, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x200000) { -// psndSFXOn_3D(0x145, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x100000) { -// psndSFXOn_3D(0x147, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x1000) { -// if (strncmp(gp + 0x12C, "mri", 3) != 0) { -// psndSFXOn_3D(0x149, temp_r31 + 0x8C); -// return; -// } -// psndSFXOn_3D(0x143, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x400000) { -// psndSFXOn_3D(0x14B, temp_r31 + 0x8C); -// return; -// } -// psndSFXOn_3D(0x141, temp_r31 + 0x8C); -// return; -// } -// if ((temp_r31->unk48 % (arg1 >> 1U)) == 0) { -// if (temp_r3 & 0x100) { -// psndSFXOn_3D(0x142, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x200000) { -// psndSFXOn_3D(0x144, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x100000) { -// psndSFXOn_3D(0x146, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x1000) { -// if (strncmp(gp + 0x12C, "mri", 3) != 0) { -// psndSFXOn_3D(0x148, temp_r31 + 0x8C); -// return; -// } -// psndSFXOn_3D(0x142, temp_r31 + 0x8C); -// return; -// } -// if (temp_r3 & 0x400000) { -// psndSFXOn_3D(0x14A, temp_r31 + 0x8C); -// return; -// } -// psndSFXOn_3D(0x140, temp_r31 + 0x8C); -// } -// } + mario = marioGetPtr(); + hitAttr = hitGetAttr(hitObj); + if ((mario->multiTimer % arg1) == 0) { + if (hitAttr & 0x100) { + psndSFXOn_3D((char*)0x143, &mario->position); + return; + } + if (hitAttr & 0x200000) { + psndSFXOn_3D((char*)0x145, &mario->position); + return; + } + if (hitAttr & 0x100000) { + psndSFXOn_3D((char*)0x147, &mario->position); + return; + } + if (hitAttr & 0x1000) { + if (strncmp((char*)(gp + 0x12C), "mri", 3) != 0) { + psndSFXOn_3D((char*)0x149, &mario->position); + return; + } + psndSFXOn_3D((char*)0x143, &mario->position); + return; + } + if (hitAttr & 0x400000) { + psndSFXOn_3D((char*)0x14B, &mario->position); + return; + } + psndSFXOn_3D((char*)0x141, &mario->position); + return; + } + if ((mario->multiTimer % (arg1 >> 1U)) == 0) { + if (hitAttr & 0x100) { + psndSFXOn_3D((char*)0x142, &mario->position); + return; + } + if (hitAttr & 0x200000) { + psndSFXOn_3D((char*)0x144, &mario->position); + return; + } + if (hitAttr & 0x100000) { + psndSFXOn_3D((char*)0x146, &mario->position); + return; + } + if (hitAttr & 0x1000) { + if (strncmp((char*)(gp + 0x12C), "mri", 3) != 0) { + psndSFXOn_3D((char*)0x148, &mario->position); + return; + } + psndSFXOn_3D((char*)0x142, &mario->position); + return; + } + if (hitAttr & 0x400000) { + psndSFXOn_3D((char*)0x14A, &mario->position); + return; + } + psndSFXOn_3D((char*)0x140, &mario->position); + } +} diff --git a/src/pmario_sound.c b/src/pmario_sound.c index 71a3723..b9dec26 100644 --- a/src/pmario_sound.c +++ b/src/pmario_sound.c @@ -4571,6 +4571,6 @@ void psndSetPosDirListener(Vec* position, f32 direction) { //1:1 psnd.direction = direction; } -s32 psndSFXOn_3D(const char* name, Vec* position) { +void psndSFXOn_3D(const char* name, Vec* position) { } From e9e0b6eadef2f8a28c4184e7f8d1efa81b8f77d6 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 21:33:42 -0300 Subject: [PATCH 05/14] matching mot_dash --- include/driver/casedrv.h | 17 +- include/mario/mario.h | 22 ++- src/driver/casedrv.c | 14 -- src/motion/mot_walk.c | 366 ++++++++++++++++++++------------------- 4 files changed, 217 insertions(+), 202 deletions(-) diff --git a/include/driver/casedrv.h b/include/driver/casedrv.h index 661927a..6242a2d 100644 --- a/include/driver/casedrv.h +++ b/include/driver/casedrv.h @@ -14,8 +14,23 @@ typedef struct CaseSetup { s32 priority; //0x58 } CaseSetup; +typedef struct CaseEntry { + u16 flags; //0x0 + u8 pad_2[2]; //0x2 + s32 activeConditionId; //0x4, TODO rename + char hitObjName[0x40]; //0x8 + s32 caseId; //0x48 + u32 swFlag; //0x4C + void* activeFunc; //0x50 + s32 lwData[16]; //0x54 + u8 field_0x94[4]; //0x94 + void* evtCode; //0x98, TODO re-type + s32 priority; //0x9C +} CaseEntry; + void caseInit(void); void caseReInit(void); s32 caseEntry(CaseSetup* setup); void caseDelete(s32 caseId); -void caseMain(void); \ No newline at end of file +void caseMain(void); +CaseEntry* caseCheckHitObj(void); diff --git a/include/mario/mario.h b/include/mario/mario.h index 598cae3..8cf41a0 100644 --- a/include/mario/mario.h +++ b/include/mario/mario.h @@ -103,10 +103,13 @@ typedef struct MarioWork { u8 field_0x32[0x3C - 0x32]; //0x32 s8 characterId; //0x3C s8 colorId; //0x3D - u8 field_0x3E[0x44 - 0x3E]; //0x3E + u8 field_0x3E[0x40 - 0x3E]; //0x3E + u8 wMotionTimer; //0x40 + u8 field_0x41[0x44 - 0x41]; //0x41 u32 currSubMotionId; //0x44 u32 multiTimer; //0x48, ??? - u8 field_0x4C[0x50 - 0x4C]; //0x4C + u16 unk4C; // 0x4C + s16 forceMoveTimer; //0x4E s16 airTimer; // 0x50 u8 field_0x52[0x5C - 0x52]; //0x52 s16 unk5C; //0x5C @@ -138,17 +141,26 @@ typedef struct MarioWork { s32 unk168; //0x168 s32 unk16C; //0x16C u8 unk170[0x184 - 0x170]; //0x170 + f32 baseSpeed; // 0x180, same on US f32 mBaseWalkSpeed; //0x184 f32 mBaseDashSpeed; //0x188, same on US - u8 unk18C[0x198 - 0x18C]; //0x18C + u8 unk18C[0x190 - 0x18C]; //0x18C + f32 controlStickSensitivity; //0x190 + f32 controlStickAngle; //0x194 f32 targetYaw; //0x198 - u8 unk19C[0x1A8 - 0x19C]; //0x19C + u8 unk19C[0x1A0 - 0x19C]; //0x19C + f32 directionView; //0x1A0 + f32 forceDirection; //0x1A4 f32 unk1A8; //0x1A8 u8 unk1AC[0x1B4 - 0x1AC]; //0x1AC Vec wPlayerCollisionBox; //0x1B4 JP, 0x1B8 US u8 field_0x1C0[0x1D8 - 0x1C0]; //0x1C0 s32 field_0x1D8; //0x1D8 - u8 field_0x1DC[0x224 - 0x1DC]; //0x1DC + u8 field_0x1DC[0x1E4 - 0x1DC]; //0x1DC + void* hitobjStandOn; //0x1E4, 0x1E8 US HitEntry + void* hitobjJumpFrom; //0x1E8, 0x1EC US HitEntry + void* hitobjPush; //0x1EC JP, 0x1F0 US HitEntry + u8 field_0x1F0[0x224 - 0x1F0]; //0x1F0 f32 playerGravity; //0x224 JP, 228 US s32 paperAnimGroupId[3]; //0x228 JP, 0x22C US u8 field_0x234[0x23C - 0x234]; //0x234 diff --git a/src/driver/casedrv.c b/src/driver/casedrv.c index f76c221..64aa47a 100644 --- a/src/driver/casedrv.c +++ b/src/driver/casedrv.c @@ -2,20 +2,6 @@ #include "memory.h" #include -typedef struct CaseEntry { - u16 flags; //0x0 - u8 pad_2[2]; //0x2 - s32 activeConditionId; //0x4, TODO rename - char hitObjName[0x40]; //0x8 - s32 caseId; //0x48 - u32 swFlag; //0x4C - void* activeFunc; //0x50 - s32 lwData[16]; //0x54 - u8 field_0x94[4]; //0x94 - void* evtCode; //0x98, TODO re-type - s32 priority; //0x9C -} CaseEntry; - typedef struct CaseWork { s32 count; //0x0 CaseEntry* entries; //0x4 diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 351fb7b..d27bb27 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -2,129 +2,194 @@ #include "driver/hitdrv.h" #include "pmario_sound.h" #include "mario/mario.h" +#include "driver/casedrv.h" extern s32 gp; // m2c -// void mot_dash(void) { -// f32 var_f31; -// s32 temp_r3_3; -// s32 var_r0; -// s32 var_r4; -// u8 temp_r0; -// u8 temp_r0_2; -// u8 temp_r0_3; -// u8 temp_r3_5; -// u8 temp_r3_6; -// void* temp_r3; -// void* temp_r3_2; -// void* temp_r3_4; +void marioWalkDashSe(HitObj* hitObj, u32 arg1) { + s32 hitAttr; + MarioWork* mario; -// temp_r3 = marioGetPtr(); -// temp_r0 = temp_r3->unk3C; -// if ((s8) temp_r0 == 2) { -// kpa_dash(); -// return; -// } -// if ((s8) temp_r0 == 1) { -// peach_dash(); -// return; -// } -// if ((u32) temp_r3->unk1EC == 0U) { -// var_r0 = 0; -// } else { -// temp_r3_2 = caseCheckHitObj(); -// if ((temp_r3_2 != NULL) && ((s32) temp_r3_2->unk4 == 0xA)) { -// var_r0 = 1; -// } else { -// var_r0 = 0; -// } -// } -// if ((var_r0 == 0) && ((u32) temp_r3->unk1EC == 0U)) { -// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFFF7FFF); -// if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { -// marioChgPose("M_R_1"); -// } -// } -// temp_r3_3 = temp_r3->unkC; -// if (temp_r3_3 & 1) { -// temp_r3->unkC = (s32) (temp_r3_3 & 0xFFFFFFFE); -// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFF0FFFF); -// marioResetCamFollowRate(); -// if (temp_r3->unk0 & 0x100000) { -// motSlitContinue(); -// } -// if (temp_r3->unk224 == 1.0f) { -// if (temp_r3->unk0 & 0x8000) { -// if (marioChkPushAnime() == 0) { -// marioChgPose("M_O_1"); -// } -// } else if (marioBgmodeChk() == 0) { -// marioChgPose("M_R_1"); -// } -// } else if (temp_r3->unk0 & 0x8000) { -// if (marioChkPushAnime() == 0) { -// marioChgPose("M_O_1"); -// } -// } else { -// marioChgPose("M_W_1"); -// } -// if ((s16) temp_r3->unk4E == 0) { -// temp_r3_4 = marioGetPtr(); -// var_f31 = temp_r3_4->unk188; -// if (temp_r3_4->unk0 & 0x100000) { -// temp_r3_5 = temp_r3_4->unk24E; -// temp_r0_2 = temp_r3_4->unk24F; -// var_f31 = temp_r3_4->unk184; -// if ((s32) (((s8) temp_r3_5 * (s8) temp_r3_5) + ((s8) temp_r0_2 * (s8) temp_r0_2)) <= 0xBD1) { -// var_f31 *= 0.5f; -// } -// } else if (marioBgmodeChk() == 1) { -// var_f31 *= 0.5f; -// } -// temp_r3->unk180 = (f32) (var_f31 * temp_r3_4->unk224); -// } -// } -// if (!(temp_r3->unk0 & 0x2000) && ((strcmp(temp_r3->unk18, "M_I_Y") == 0) || ((s8) temp_r3->unk40 > 0xA))) { -// marioChgMot(0); -// return; -// } -// if (temp_r3->unk0 & 0x2000) { -// marioChgMot(1); -// return; -// } -// if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { -// marioChgMot(0x15); -// return; -// } -// if (marioChkItemMotion() == 0) { -// marioChkJump(); -// marioChkTransform(); -// if ((u32) temp_r3->unk1E4 != 0U) { -// if (temp_r3->unk224 == 1.0f) { -// var_r4 = 0x14; -// } else { -// var_r4 = 0x28; -// } -// marioWalkDashSe(var_r4); -// } -// temp_r3->unk48 = (s32) (temp_r3->unk48 + 1); -// if (!(temp_r3->unk0 & 0x20)) { -// temp_r3_6 = temp_r3->unk24E; -// temp_r0_3 = temp_r3->unk24F; -// if ((s32) (((s8) temp_r3_6 * (s8) temp_r3_6) + ((s8) temp_r0_3 * (s8) temp_r0_3)) <= 0xBD1) { -// marioChgMot(1); -// return; -// } -// temp_r3->unk1A0 = (f32) temp_r3->unk194; -// if ((temp_r3->unk0 & 0x8000) && (marioChkPushAnime() == 0)) { -// marioChgPose("M_O_1"); -// } -// if (temp_r3->unk190 == 0.0f) { -// marioChgMot(0); -// } -// } -// } -// } + mario = marioGetPtr(); + hitAttr = hitGetAttr(hitObj); + if ((mario->multiTimer % arg1) == 0) { + if (hitAttr & 0x100) { + psndSFXOn_3D((char*)0x143, &mario->position); + return; + } + if (hitAttr & 0x200000) { + psndSFXOn_3D((char*)0x145, &mario->position); + return; + } + if (hitAttr & 0x100000) { + psndSFXOn_3D((char*)0x147, &mario->position); + return; + } + if (hitAttr & 0x1000) { + if (strncmp((char*)(gp + 0x12C), "mri", 3) != 0) { + psndSFXOn_3D((char*)0x149, &mario->position); + return; + } + psndSFXOn_3D((char*)0x143, &mario->position); + return; + } + if (hitAttr & 0x400000) { + psndSFXOn_3D((char*)0x14B, &mario->position); + return; + } + psndSFXOn_3D((char*)0x141, &mario->position); + return; + } + if ((mario->multiTimer % (arg1 >> 1U)) == 0) { + if (hitAttr & 0x100) { + psndSFXOn_3D((char*)0x142, &mario->position); + return; + } + if (hitAttr & 0x200000) { + psndSFXOn_3D((char*)0x144, &mario->position); + return; + } + if (hitAttr & 0x100000) { + psndSFXOn_3D((char*)0x146, &mario->position); + return; + } + if (hitAttr & 0x1000) { + if (strncmp((char*)(gp + 0x12C), "mri", 3) != 0) { + psndSFXOn_3D((char*)0x148, &mario->position); + return; + } + psndSFXOn_3D((char*)0x142, &mario->position); + return; + } + if (hitAttr & 0x400000) { + psndSFXOn_3D((char*)0x14A, &mario->position); + return; + } + psndSFXOn_3D((char*)0x140, &mario->position); + } +} + + +void mot_dash(void) { + f32 dashSpeed; + s32 temp_r3_3; + s32 var_r0; + s32 var_r4; + u8 characterId; + u8 stickDir2; + u8 _stickDir2; + u8 stickDir1; + u8 _stickDir1; + MarioWork* player; + CaseEntry* caseEntry; + MarioWork* _player; + + player = marioGetPtr(); + characterId = player->characterId; + if ((s8) characterId == 2) { + kpa_dash(); + return; + } + if ((s8) characterId == 1) { + peach_dash(); + return; + } + if (player->hitobjPush == NULL) { + var_r0 = 0; + } else { + caseEntry = caseCheckHitObj(); + if ((caseEntry != NULL) && ((s32) caseEntry->activeConditionId == 0xA)) { + var_r0 = 1; + } else { + var_r0 = 0; + } + } + if ((var_r0 == 0) && ((u32) player->hitobjPush == 0U)) { + player->flags = (s32) (player->flags & 0xFFFF7FFF); + if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { + marioChgPose("M_R_1"); + } + } + temp_r3_3 = player->trigFlags; + if (temp_r3_3 & 1) { + player->trigFlags = (s32) (temp_r3_3 & 0xFFFFFFFE); + player->flags = (s32) (player->flags & 0xFFF0FFFF); + marioResetCamFollowRate(); + if (player->flags & 0x100000) { + motSlitContinue(); + } + if (player->playerGravity == 1.0f) { + if (player->flags & 0x8000) { + if (marioChkPushAnime() == 0) { + marioChgPose("M_O_1"); + } + } else if (marioBgmodeChk() == 0) { + marioChgPose("M_R_1"); + } + } else if (player->flags & 0x8000) { + if (marioChkPushAnime() == 0) { + marioChgPose("M_O_1"); + } + } else { + marioChgPose("M_W_1"); + } + if ((s16) player->forceMoveTimer == 0) { + _player = marioGetPtr(); + dashSpeed = _player->mBaseDashSpeed; + if (_player->flags & 0x100000) { + stickDir1 = _player->wStickDir1; + stickDir2 = _player->wStickDir2; + dashSpeed = _player->mBaseWalkSpeed; + if ((s32) (((s8) stickDir1 * (s8) stickDir1) + ((s8) stickDir2 * (s8) stickDir2)) <= 0xBD1) { + dashSpeed *= 0.5f; + } + } else if (marioBgmodeChk() == 1) { + dashSpeed *= 0.5f; + } + player->baseSpeed = (f32) (dashSpeed * _player->playerGravity); + } + } + if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && ((strcmp(player->animName, "M_I_Y") == 0) || ((s8) player->wMotionTimer > 0xA))) { + marioChgMot(0); + return; + } + if (player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) { + marioChgMot(1); + return; + } + if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { + marioChgMot(0x15); + return; + } + if (marioChkItemMotion() == 0) { + marioChkJump(); + marioChkTransform(); + if ((u32) player->multiTimer != 0U) { + if (player->playerGravity == 1.0f) { + var_r4 = 0x14; + } else { + var_r4 = 0x28; + } + marioWalkDashSe(player->hitobjStandOn, var_r4); + } + player->multiTimer = (s32) (player->multiTimer + 1); + if (!(player->flags & 0x20)) { + _stickDir1 = player->wStickDir1; + _stickDir2 = player->wStickDir2; + if (((s8) _stickDir1 * (s8) _stickDir1) + ((s8) _stickDir2 * (s8) _stickDir2) <= 0xBD1) { + marioChgMot(1); + return; + } + player->directionView = (f32) player->controlStickAngle; + if ((player->flags & 0x8000) && (marioChkPushAnime() == 0)) { + marioChgPose("M_O_1"); + } + if (player->controlStickSensitivity == 0.0f) { + marioChgMot(0); + } + } + } +} // void mot_walk(void) { // f32 var_f31; @@ -293,66 +358,3 @@ f32 marioGetWalkSpd(void) { walkSpeed *= mario->playerGravity; return walkSpeed; } - -void marioWalkDashSe(HitObj* hitObj, u32 arg1) { - s32 hitAttr; - MarioWork* mario; - - mario = marioGetPtr(); - hitAttr = hitGetAttr(hitObj); - if ((mario->multiTimer % arg1) == 0) { - if (hitAttr & 0x100) { - psndSFXOn_3D((char*)0x143, &mario->position); - return; - } - if (hitAttr & 0x200000) { - psndSFXOn_3D((char*)0x145, &mario->position); - return; - } - if (hitAttr & 0x100000) { - psndSFXOn_3D((char*)0x147, &mario->position); - return; - } - if (hitAttr & 0x1000) { - if (strncmp((char*)(gp + 0x12C), "mri", 3) != 0) { - psndSFXOn_3D((char*)0x149, &mario->position); - return; - } - psndSFXOn_3D((char*)0x143, &mario->position); - return; - } - if (hitAttr & 0x400000) { - psndSFXOn_3D((char*)0x14B, &mario->position); - return; - } - psndSFXOn_3D((char*)0x141, &mario->position); - return; - } - if ((mario->multiTimer % (arg1 >> 1U)) == 0) { - if (hitAttr & 0x100) { - psndSFXOn_3D((char*)0x142, &mario->position); - return; - } - if (hitAttr & 0x200000) { - psndSFXOn_3D((char*)0x144, &mario->position); - return; - } - if (hitAttr & 0x100000) { - psndSFXOn_3D((char*)0x146, &mario->position); - return; - } - if (hitAttr & 0x1000) { - if (strncmp((char*)(gp + 0x12C), "mri", 3) != 0) { - psndSFXOn_3D((char*)0x148, &mario->position); - return; - } - psndSFXOn_3D((char*)0x142, &mario->position); - return; - } - if (hitAttr & 0x400000) { - psndSFXOn_3D((char*)0x14A, &mario->position); - return; - } - psndSFXOn_3D((char*)0x140, &mario->position); - } -} From 7d578744cf215a66ce6a5427e594b9ebbb4f5bce Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 21:42:29 -0300 Subject: [PATCH 06/14] mot_dash inital cleanup (also wasn't matching) --- src/motion/mot_walk.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index d27bb27..fbb1dae 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -73,7 +73,7 @@ void marioWalkDashSe(HitObj* hitObj, u32 arg1) { void mot_dash(void) { f32 dashSpeed; s32 temp_r3_3; - s32 var_r0; + s32 conditionActive; s32 var_r4; u8 characterId; u8 stickDir2; @@ -95,17 +95,17 @@ void mot_dash(void) { return; } if (player->hitobjPush == NULL) { - var_r0 = 0; + conditionActive = FALSE; } else { caseEntry = caseCheckHitObj(); - if ((caseEntry != NULL) && ((s32) caseEntry->activeConditionId == 0xA)) { - var_r0 = 1; + if (caseEntry != NULL && caseEntry->activeConditionId == 0xA) { + conditionActive = TRUE; } else { - var_r0 = 0; + conditionActive = FALSE; } } - if ((var_r0 == 0) && ((u32) player->hitobjPush == 0U)) { - player->flags = (s32) (player->flags & 0xFFFF7FFF); + if (conditionActive == 0 && player->hitobjPush == NULL) { + player->flags = player->flags & 0xFFFF7FFF; if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { marioChgPose("M_R_1"); } From f9b2f26567b2b255d5168499453036ecb3983b7d Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Sun, 7 Jun 2026 23:07:15 -0300 Subject: [PATCH 07/14] match and cleaned mot_dash --- include/driver/casedrv.h | 2 +- include/mario/mario.h | 25 ++++++++++- src/motion/mot_walk.c | 94 ++++++++++++++++++++-------------------- 3 files changed, 73 insertions(+), 48 deletions(-) diff --git a/include/driver/casedrv.h b/include/driver/casedrv.h index 6242a2d..1c7e18f 100644 --- a/include/driver/casedrv.h +++ b/include/driver/casedrv.h @@ -33,4 +33,4 @@ void caseReInit(void); s32 caseEntry(CaseSetup* setup); void caseDelete(s32 caseId); void caseMain(void); -CaseEntry* caseCheckHitObj(void); +CaseEntry* caseCheckHitObj(void* obj); // Takes HitEntry diff --git a/include/mario/mario.h b/include/mario/mario.h index 8cf41a0..1633ba9 100644 --- a/include/mario/mario.h +++ b/include/mario/mario.h @@ -85,6 +85,29 @@ typedef enum MarioFlags { } MarioFlags; #pragma enumsalwaysint on +#pragma enumsalwaysint off +typedef enum MarioTrigFlags { + MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION = (1 << 0), + MARIO_TRIG_FLAG_USE_PARTNER = (1 << 1), + MARIO_TRIG_FLAG_SHIP_PLANE_EVT_ON = (1 << 2), + MARIO_TRIG_FLAG_DISP_DIR_CORRECTION = (1 << 8), + MARIO_TRIG_FLAG_DISP_DIR_LEFT = (1 << 9), + MARIO_TRIG_FLAG_DISP_DIR_RIGHT = (1 << 10), + MARIO_TRIG_FLAG_CHG_ANIM = (1 << 12), + MARIO_TRIG_FLAG_CHG_PAPER_ANIM = (1 << 14), + MARIO_TRIG_FLAG_SET_JUMP_PARAMS = (1 << 16), + MARIO_TRIG_FLAG_DISABLE_JUMP_KEMURI = (1 << 17), + MARIO_TRIG_FLAG_JABARA_CHK = (1 << 20), + MARIO_TRIG_FLAG_JABARA_MOVE_CHK = (1 << 21), + MARIO_TRIG_FLAG_START_JABARA_SPIN = (1 << 22), + MARIO_TRIG_FLAG_DISABLE_UNUSED_INPUT = (1 << 24), + MARIO_TRIG_FLAG_DISABLE_TRIGGERS = (1 << 25), + MARIO_TRIG_FLAG_DISABLE_SUB_STICK = (1 << 26), + MARIO_TRIG_FLAG_DISABLE_STICK = (1 << 27), + MARIO_TRIG_FLAG_DISABLE_PARTY_SLIT = (1 << 30) +} MarioTrigFlags; +#pragma enumsalwaysint on + //TODO: US struct is bigger, 0x2F8 vs 0x2E0 typedef struct MarioWork { u32 flags; //0x0 @@ -140,7 +163,7 @@ typedef struct MarioWork { u8 unk160[0x168 - 0x160]; //0x160 s32 unk168; //0x168 s32 unk16C; //0x16C - u8 unk170[0x184 - 0x170]; //0x170 + u8 unk170[0x180 - 0x170]; //0x170 f32 baseSpeed; // 0x180, same on US f32 mBaseWalkSpeed; //0x184 f32 mBaseDashSpeed; //0x188, same on US diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index fbb1dae..c27d887 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -72,120 +72,122 @@ void marioWalkDashSe(HitObj* hitObj, u32 arg1) { void mot_dash(void) { f32 dashSpeed; - s32 temp_r3_3; - s32 conditionActive; - s32 var_r4; - u8 characterId; - u8 stickDir2; - u8 _stickDir2; - u8 stickDir1; - u8 _stickDir1; + u32 trigFlags; + BOOL unkConditionActive; + s32 unkArgMarioWalkDashSe; + s8 characterId; + s8 stickDir2; + s8 _stickDir2; + s8 stickDir1; + s8 _stickDir1; MarioWork* player; CaseEntry* caseEntry; MarioWork* _player; + void* hitobjPush; player = marioGetPtr(); characterId = player->characterId; - if ((s8) characterId == 2) { + if (characterId == 2) { kpa_dash(); return; } - if ((s8) characterId == 1) { + if (characterId == 1) { peach_dash(); return; } if (player->hitobjPush == NULL) { - conditionActive = FALSE; + unkConditionActive = FALSE; } else { - caseEntry = caseCheckHitObj(); + caseEntry = caseCheckHitObj(player->hitobjPush); if (caseEntry != NULL && caseEntry->activeConditionId == 0xA) { - conditionActive = TRUE; + unkConditionActive = TRUE; } else { - conditionActive = FALSE; + unkConditionActive = FALSE; } } - if (conditionActive == 0 && player->hitobjPush == NULL) { - player->flags = player->flags & 0xFFFF7FFF; - if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { + if (!unkConditionActive && player->hitobjPush == NULL) { + player->flags = player->flags & ~MARIO_FLAG_IS_PUSHING; + if (marioChkPushAnime() && !marioBgmodeChk()) { marioChgPose("M_R_1"); } } - temp_r3_3 = player->trigFlags; - if (temp_r3_3 & 1) { - player->trigFlags = (s32) (temp_r3_3 & 0xFFFFFFFE); - player->flags = (s32) (player->flags & 0xFFF0FFFF); + trigFlags = player->trigFlags; + if (trigFlags & MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION) { + player->trigFlags = trigFlags & ~MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION; + player->flags = player->flags & ~(MARIO_FLAG_HAS_INPUT_JUMP | MARIO_FLAG_IS_JUMPING | MARIO_FLAG_IS_FALLING | MARIO_FLAG_IS_STEPPING); marioResetCamFollowRate(); - if (player->flags & 0x100000) { + if (player->flags & MARIO_FLAG_PAPER_MODE) { motSlitContinue(); } if (player->playerGravity == 1.0f) { - if (player->flags & 0x8000) { - if (marioChkPushAnime() == 0) { + if (player->flags & MARIO_FLAG_IS_PUSHING) { + if (!marioChkPushAnime()) { marioChgPose("M_O_1"); } - } else if (marioBgmodeChk() == 0) { + } else if (!marioBgmodeChk()) { marioChgPose("M_R_1"); } - } else if (player->flags & 0x8000) { - if (marioChkPushAnime() == 0) { + } else if (player->flags & MARIO_FLAG_IS_PUSHING) { + if (!marioChkPushAnime()) { marioChgPose("M_O_1"); } } else { marioChgPose("M_W_1"); } - if ((s16) player->forceMoveTimer == 0) { + if (player->forceMoveTimer == 0) { _player = marioGetPtr(); dashSpeed = _player->mBaseDashSpeed; - if (_player->flags & 0x100000) { + if (_player->flags & MARIO_FLAG_PAPER_MODE) { stickDir1 = _player->wStickDir1; stickDir2 = _player->wStickDir2; dashSpeed = _player->mBaseWalkSpeed; - if ((s32) (((s8) stickDir1 * (s8) stickDir1) + ((s8) stickDir2 * (s8) stickDir2)) <= 0xBD1) { + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { dashSpeed *= 0.5f; } } else if (marioBgmodeChk() == 1) { dashSpeed *= 0.5f; } - player->baseSpeed = (f32) (dashSpeed * _player->playerGravity); + dashSpeed *= _player->playerGravity; + player->baseSpeed = dashSpeed; } } if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && ((strcmp(player->animName, "M_I_Y") == 0) || ((s8) player->wMotionTimer > 0xA))) { - marioChgMot(0); + marioChgMot(MARIO_MOTION_STAY); return; } if (player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) { - marioChgMot(1); + marioChgMot(MARIO_MOTION_WALK); return; } if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { - marioChgMot(0x15); + marioChgMot(MARIO_MOTION_SLIT); return; } if (marioChkItemMotion() == 0) { marioChkJump(); marioChkTransform(); - if ((u32) player->multiTimer != 0U) { + if (player->hitobjStandOn != NULL) { if (player->playerGravity == 1.0f) { - var_r4 = 0x14; + unkArgMarioWalkDashSe = 0x14; } else { - var_r4 = 0x28; + unkArgMarioWalkDashSe = 0x28; } - marioWalkDashSe(player->hitobjStandOn, var_r4); + marioWalkDashSe(player->hitobjStandOn, unkArgMarioWalkDashSe); } - player->multiTimer = (s32) (player->multiTimer + 1); - if (!(player->flags & 0x20)) { + player->multiTimer = player->multiTimer + 1; + if (!(player->flags & MARIO_FLAG_FORCED_MOVEMENT)) { _stickDir1 = player->wStickDir1; _stickDir2 = player->wStickDir2; - if (((s8) _stickDir1 * (s8) _stickDir1) + ((s8) _stickDir2 * (s8) _stickDir2) <= 0xBD1) { - marioChgMot(1); + if ((_stickDir1 * _stickDir1) + (_stickDir2 * _stickDir2) <= 0xBD1) { + marioChgMot(MARIO_MOTION_WALK); return; } - player->directionView = (f32) player->controlStickAngle; - if ((player->flags & 0x8000) && (marioChkPushAnime() == 0)) { + player->directionView = player->controlStickAngle; + if ((player->flags & MARIO_FLAG_IS_PUSHING) && !marioChkPushAnime()) { marioChgPose("M_O_1"); } - if (player->controlStickSensitivity == 0.0f) { - marioChgMot(0); + if (!player->controlStickSensitivity) { + marioChgMot(MARIO_MOTION_STAY); } } } From 05fa70a3575a4845ee52048c35ef248e56609ad0 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 11:08:22 -0300 Subject: [PATCH 08/14] add header declarations for functions used in mot_dash --- include/koopa_motion.h | 1 + include/mario/mario_cam.h | 1 + include/mario/mario_motion.h | 7 +++++++ include/mot/mot_slit.h | 5 +++++ include/peach.h | 1 + src/motion/mot_walk.c | 11 ++++++++--- 6 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 include/koopa_motion.h create mode 100644 include/mario/mario_motion.h create mode 100644 include/mot/mot_slit.h create mode 100644 include/peach.h diff --git a/include/koopa_motion.h b/include/koopa_motion.h new file mode 100644 index 0000000..e3ad9ac --- /dev/null +++ b/include/koopa_motion.h @@ -0,0 +1 @@ +void kpa_dash(void); diff --git a/include/mario/mario_cam.h b/include/mario/mario_cam.h index 6b4e18e..db7cd57 100644 --- a/include/mario/mario_cam.h +++ b/include/mario/mario_cam.h @@ -4,3 +4,4 @@ s32 marioGetCamId(void); void marioCamZoomOffReq2(s32); +void marioResetCamFollowRate(void); diff --git a/include/mario/mario_motion.h b/include/mario/mario_motion.h new file mode 100644 index 0000000..d365dcb --- /dev/null +++ b/include/mario/mario_motion.h @@ -0,0 +1,7 @@ +#include "dolphin/types.h" +#include "mario/mario.h" + +void marioChgMot(MarioMotion); +BOOL marioChkItemMotion(void); +BOOL marioChkJump(void); +BOOL marioChkTransform(void); diff --git a/include/mot/mot_slit.h b/include/mot/mot_slit.h new file mode 100644 index 0000000..d007e30 --- /dev/null +++ b/include/mot/mot_slit.h @@ -0,0 +1,5 @@ +#include "dolphin/types.h" + +BOOL marioSlitAbilityChk(void); +s32 marioSlitButton(void); +void motSlitContinue(void); diff --git a/include/peach.h b/include/peach.h new file mode 100644 index 0000000..1f0efc3 --- /dev/null +++ b/include/peach.h @@ -0,0 +1 @@ +void peach_dash(void); diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index c27d887..61dc102 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -3,6 +3,11 @@ #include "pmario_sound.h" #include "mario/mario.h" #include "driver/casedrv.h" +#include "mot/mot_slit.h" +#include "mario/mario_cam.h" +#include "mario/mario_motion.h" +#include "koopa_motion.h" +#include "peach.h" extern s32 gp; // m2c @@ -151,7 +156,7 @@ void mot_dash(void) { player->baseSpeed = dashSpeed; } } - if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && ((strcmp(player->animName, "M_I_Y") == 0) || ((s8) player->wMotionTimer > 0xA))) { + if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && (strcmp(player->animName, "M_I_Y") == 0 || (s8) player->wMotionTimer > 0xA)) { marioChgMot(MARIO_MOTION_STAY); return; } @@ -159,11 +164,11 @@ void mot_dash(void) { marioChgMot(MARIO_MOTION_WALK); return; } - if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { + if (marioSlitAbilityChk() && marioSlitButton() == 1) { marioChgMot(MARIO_MOTION_SLIT); return; } - if (marioChkItemMotion() == 0) { + if (!marioChkItemMotion()) { marioChkJump(); marioChkTransform(); if (player->hitobjStandOn != NULL) { From feda267b204103292ebaf932929ca695cb56b790 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 12:51:49 -0300 Subject: [PATCH 09/14] matching mot_walk --- include/koopa_motion.h | 1 + include/peach.h | 1 + src/motion/mot_walk.c | 246 +++++++++++++++++++++-------------------- 3 files changed, 128 insertions(+), 120 deletions(-) diff --git a/include/koopa_motion.h b/include/koopa_motion.h index e3ad9ac..de47b64 100644 --- a/include/koopa_motion.h +++ b/include/koopa_motion.h @@ -1 +1,2 @@ void kpa_dash(void); +void kpa_walk(void); diff --git a/include/peach.h b/include/peach.h index 1f0efc3..a346bf3 100644 --- a/include/peach.h +++ b/include/peach.h @@ -1 +1,2 @@ void peach_dash(void); +void peach_walk(void); diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 61dc102..18a55f6 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -8,6 +8,7 @@ #include "mario/mario_motion.h" #include "koopa_motion.h" #include "peach.h" +#include "mario/mario_pouch.h" extern s32 gp; // m2c @@ -198,127 +199,132 @@ void mot_dash(void) { } } -// void mot_walk(void) { -// f32 var_f31; -// s32 temp_r3_3; -// s32 temp_r3_6; -// s32 var_r0; -// u8 temp_r0; -// u8 temp_r0_2; -// u8 temp_r0_3; -// u8 temp_r3_5; -// u8 temp_r3_7; -// void* temp_r3; -// void* temp_r3_2; -// void* temp_r3_4; - -// temp_r3 = marioGetPtr(); -// temp_r0 = temp_r3->unk3C; -// if ((s8) temp_r0 == 2) { -// kpa_walk(); -// return; -// } -// if ((s8) temp_r0 == 1) { -// peach_walk(); -// return; -// } -// if (temp_r3->unk0 & 0x8000) { -// if ((u32) temp_r3->unk1EC == 0U) { -// var_r0 = 0; -// } else { -// temp_r3_2 = caseCheckHitObj(); -// if ((temp_r3_2 != NULL) && ((s32) temp_r3_2->unk4 == 0xA)) { -// var_r0 = 1; -// } else { -// var_r0 = 0; -// } -// } -// if (var_r0 == 0) { -// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFFF7FFF); -// if ((marioChkPushAnime() != 0) && (marioBgmodeChk() == 0)) { -// marioChgPose("M_W_1"); -// } -// } -// } -// temp_r3_3 = temp_r3->unkC; -// if (temp_r3_3 & 1) { -// temp_r3->unkC = (s32) (temp_r3_3 & 0xFFFFFFFE); -// temp_r3->unk0 = (s32) (temp_r3->unk0 & 0xFFF0FFFF); -// marioResetCamFollowRate(); -// if (temp_r3->unk0 & 0x100000) { -// motSlitContinue(); -// } -// if ((s16) temp_r3->unk4E == 0) { -// temp_r3_4 = marioGetPtr(); -// var_f31 = temp_r3_4->unk184; -// if (temp_r3_4->unk0 & 0x100000) { -// temp_r3_5 = temp_r3_4->unk24E; -// temp_r0_2 = temp_r3_4->unk24F; -// if ((s32) (((s8) temp_r3_5 * (s8) temp_r3_5) + ((s8) temp_r0_2 * (s8) temp_r0_2)) <= 0xBD1) { -// var_f31 *= 0.5f; -// } -// } else if (marioBgmodeChk() == 1) { -// var_f31 *= 0.5f; -// } -// temp_r3->unk180 = (f32) (var_f31 * temp_r3_4->unk224); -// } -// temp_r3_6 = temp_r3->unk0; -// if (temp_r3_6 & 0x2000) { -// marioChgPose("M_W_7"); -// } else if (temp_r3_6 & 0x8000) { -// if (marioChkPushAnime() == 0) { -// marioChgPose("M_O_1"); -// } -// } else if (marioBgmodeChk() == 0) { -// marioChgPose("M_W_1"); -// } -// if (!(temp_r3->unk4 & 0x01000000)) { -// temp_r3->unk44 = 0; -// } -// temp_r3->unk48 = 0; -// } -// if (!(temp_r3->unk0 & 0x2000) && ((strcmp(temp_r3->unk18, "M_I_Y") == 0) || ((s8) temp_r3->unk40 > 0xA))) { -// marioChgMot(0); -// return; -// } -// if (temp_r3->unk0 & 0x2000) { -// temp_r3->unk1A0 = (f32) temp_r3->unk194; -// if (temp_r3->unk190 == 0.0f) { -// marioChgMot(0); -// } -// } else { -// if ((marioSlitAbilityChk() != 0) && (marioSlitButton() == 1)) { -// marioChgMot(0x15); -// return; -// } -// if (marioChkItemMotion() == 0) { -// marioChkJump(); -// marioChkTransform(); -// if (pouchEquipCheckBadge(0x143) == 0) { -// temp_r3_7 = temp_r3->unk24E; -// temp_r0_3 = temp_r3->unk24F; -// if ((s32) (((s8) temp_r3_7 * (s8) temp_r3_7) + ((s8) temp_r0_3 * (s8) temp_r0_3)) > 0xBD1) { -// marioChgMot(2); -// return; -// } -// } -// temp_r3->unk1A0 = (f32) temp_r3->unk194; -// if ((u32) temp_r3->unk1E4 != 0U) { -// if (temp_r3->unk224 == 1.0f) { +void mot_walk(void) { + f32 walkSpeed; + s32 trigFlags; + s32 flags; + BOOL unkConditionActive; + s32 unkArgMarioWalkDashSe; + s8 characterId; + s8 _stickDir2; + s8 stickDir2; + s8 _stickDir1; + s8 stickDir1; + MarioWork* player; + CaseEntry* caseEntry; + MarioWork* _player; -// } -// marioWalkDashSe(0x28); -// } -// temp_r3->unk48 = (s32) (temp_r3->unk48 + 1); -// if ((temp_r3->unk0 & 0x8000) && (marioChkPushAnime() == 0)) { -// marioChgPose("M_O_1"); -// } -// if (temp_r3->unk190 == 0.0f) { -// marioChgMot(0); -// } -// } -// } -// } + player = marioGetPtr(); + characterId = player->characterId; + if (characterId == 2) { + kpa_walk(); + return; + } + if (characterId == 1) { + peach_walk(); + return; + } + if (player->flags & MARIO_FLAG_IS_PUSHING) { + if (player->hitobjPush == NULL) { + unkConditionActive = FALSE; + } else { + caseEntry = caseCheckHitObj(player->hitobjPush); + if (caseEntry != NULL && caseEntry->activeConditionId == 0xA) { + unkConditionActive = TRUE; + } else { + unkConditionActive = FALSE; + } + } + if (!unkConditionActive) { + player->flags = player->flags & ~MARIO_FLAG_IS_PUSHING; + if (marioChkPushAnime() && !marioBgmodeChk()) { + marioChgPose("M_W_1"); + } + } + } + trigFlags = player->trigFlags; + if (trigFlags & MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION) { + player->trigFlags = trigFlags & ~MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION; + player->flags = player->flags & ~(MARIO_FLAG_HAS_INPUT_JUMP | MARIO_FLAG_IS_JUMPING | MARIO_FLAG_IS_FALLING | MARIO_FLAG_IS_STEPPING); + marioResetCamFollowRate(); + if (player->flags & MARIO_FLAG_PAPER_MODE) { + motSlitContinue(); + } + if (player->forceMoveTimer == 0) { + _player = marioGetPtr(); + walkSpeed = _player->mBaseWalkSpeed; + if (_player->flags & MARIO_FLAG_PAPER_MODE) { + _stickDir1 = _player->wStickDir1; + _stickDir2 = _player->wStickDir2; + if ((_stickDir1 * _stickDir1) + (_stickDir2 * _stickDir2) <= 0xBD1) { + walkSpeed *= 0.5f; + } + } else if (marioBgmodeChk() == 1) { + walkSpeed *= 0.5f; + } + walkSpeed *= _player->playerGravity; + player->baseSpeed = walkSpeed; + } + flags = player->flags; + if (flags & MARIO_FLAG_IS_CARRYING_BOBBERY) { + marioChgPose("M_W_7"); + } else if (flags & MARIO_FLAG_IS_PUSHING) { + if (!marioChkPushAnime()) { + marioChgPose("M_O_1"); + } + } else if (!marioBgmodeChk()) { + marioChgPose("M_W_1"); + } + if (!(player->dispFlags & (1 << 24))) { + player->currSubMotionId = 0; + } + player->multiTimer = 0; + } + if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && (strcmp(player->animName, "M_I_Y") == 0 || (s8) player->wMotionTimer > 0xA)) { + marioChgMot(MARIO_MOTION_STAY); + return; + } + if (player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) { + player->directionView = player->controlStickAngle; + if (!player->controlStickSensitivity) { + marioChgMot(MARIO_MOTION_STAY); + } + } else { + if (marioSlitAbilityChk() && marioSlitButton() == 1) { + marioChgMot(MARIO_MOTION_SLIT); + return; + } + if (!marioChkItemMotion()) { + marioChkJump(); + marioChkTransform(); + if (pouchEquipCheckBadge(0x143) == 0) { + stickDir1 = player->wStickDir1; + stickDir2 = player->wStickDir2; + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) > 0xBD1) { + marioChgMot(MARIO_MOTION_DASH); + return; + } + } + player->directionView = (f32) player->controlStickAngle ; + if ((u32) player->hitobjStandOn != 0U) { + // Redundant, but doesn't match otherwise + if (player->playerGravity == 1.0f) { + unkArgMarioWalkDashSe = 0x28; + } else { + unkArgMarioWalkDashSe = 0x28; + } + marioWalkDashSe(player->hitobjStandOn, unkArgMarioWalkDashSe); + } + player->multiTimer = (s32) (player->multiTimer + 1); + if (player->flags & MARIO_FLAG_IS_PUSHING && !marioChkPushAnime()) { + marioChgPose("M_O_1"); + } + if (!player->controlStickSensitivity) { + marioChgMot(MARIO_MOTION_STAY); + } + } + } +} f32 marioGetDashSpd(void) { MarioWork* mario; From 445f52ea1c725d0f068c528fbf5a8fe6849d84cc Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 12:54:07 -0300 Subject: [PATCH 10/14] clean up casting --- src/motion/mot_walk.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 18a55f6..ee42a64 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -329,8 +329,8 @@ void mot_walk(void) { f32 marioGetDashSpd(void) { MarioWork* mario; f32 dashSpeed; - u8 stickDir2; - u8 stickDir1; + s8 stickDir2; + s8 stickDir1; mario = marioGetPtr(); dashSpeed = mario->mBaseDashSpeed; @@ -339,7 +339,7 @@ f32 marioGetDashSpd(void) { stickDir2 = mario->wStickDir2; dashSpeed = mario->mBaseWalkSpeed; - if (((s8)stickDir1 * (s8)stickDir1) + ((s8)stickDir2 * (s8)stickDir2) <= 0xBD1) { + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { dashSpeed *= 0.5f; } } else if (marioBgmodeChk() == 1) { @@ -352,8 +352,8 @@ f32 marioGetDashSpd(void) { f32 marioGetWalkSpd(void) { f32 walkSpeed; - u8 stickDir2; - u8 stickDir1; + s8 stickDir2; + s8 stickDir1; MarioWork* mario; mario = marioGetPtr(); @@ -361,7 +361,7 @@ f32 marioGetWalkSpd(void) { if (mario->flags & MARIO_FLAG_PAPER_MODE) { stickDir1 = mario->wStickDir1; stickDir2 = mario->wStickDir2; - if (((s8) stickDir1 * (s8) stickDir1) + ((s8) stickDir2 * (s8) stickDir2) <= 0xBD1) { + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { walkSpeed *= 0.5f; } } else if (marioBgmodeChk() == 1) { From fbed346dee8602258452707cc4844c2056ac19b1 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 13:15:37 -0300 Subject: [PATCH 11/14] run clang format --- include/mario/mario.h | 2 +- src/motion/mot_walk.c | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/include/mario/mario.h b/include/mario/mario.h index 1633ba9..7ef4f84 100644 --- a/include/mario/mario.h +++ b/include/mario/mario.h @@ -127,7 +127,7 @@ typedef struct MarioWork { s8 characterId; //0x3C s8 colorId; //0x3D u8 field_0x3E[0x40 - 0x3E]; //0x3E - u8 wMotionTimer; //0x40 + s8 wMotionTimer; //0x40 u8 field_0x41[0x44 - 0x41]; //0x41 u32 currSubMotionId; //0x44 u32 multiTimer; //0x48, ??? diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index ee42a64..8659b2f 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -75,7 +75,6 @@ void marioWalkDashSe(HitObj* hitObj, u32 arg1) { } } - void mot_dash(void) { f32 dashSpeed; u32 trigFlags; @@ -120,7 +119,8 @@ void mot_dash(void) { trigFlags = player->trigFlags; if (trigFlags & MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION) { player->trigFlags = trigFlags & ~MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION; - player->flags = player->flags & ~(MARIO_FLAG_HAS_INPUT_JUMP | MARIO_FLAG_IS_JUMPING | MARIO_FLAG_IS_FALLING | MARIO_FLAG_IS_STEPPING); + player->flags = player->flags & ~(MARIO_FLAG_HAS_INPUT_JUMP | MARIO_FLAG_IS_JUMPING | MARIO_FLAG_IS_FALLING | + MARIO_FLAG_IS_STEPPING); marioResetCamFollowRate(); if (player->flags & MARIO_FLAG_PAPER_MODE) { motSlitContinue(); @@ -157,7 +157,8 @@ void mot_dash(void) { player->baseSpeed = dashSpeed; } } - if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && (strcmp(player->animName, "M_I_Y") == 0 || (s8) player->wMotionTimer > 0xA)) { + if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && + (strcmp(player->animName, "M_I_Y") == 0 || player->wMotionTimer > 0xA)) { marioChgMot(MARIO_MOTION_STAY); return; } @@ -245,7 +246,8 @@ void mot_walk(void) { trigFlags = player->trigFlags; if (trigFlags & MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION) { player->trigFlags = trigFlags & ~MARIO_TRIG_FLAG_IS_STARTING_NEW_MOTION; - player->flags = player->flags & ~(MARIO_FLAG_HAS_INPUT_JUMP | MARIO_FLAG_IS_JUMPING | MARIO_FLAG_IS_FALLING | MARIO_FLAG_IS_STEPPING); + player->flags = player->flags & ~(MARIO_FLAG_HAS_INPUT_JUMP | MARIO_FLAG_IS_JUMPING | MARIO_FLAG_IS_FALLING | + MARIO_FLAG_IS_STEPPING); marioResetCamFollowRate(); if (player->flags & MARIO_FLAG_PAPER_MODE) { motSlitContinue(); @@ -280,7 +282,8 @@ void mot_walk(void) { } player->multiTimer = 0; } - if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && (strcmp(player->animName, "M_I_Y") == 0 || (s8) player->wMotionTimer > 0xA)) { + if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && + (strcmp(player->animName, "M_I_Y") == 0 || player->wMotionTimer > 0xA)) { marioChgMot(MARIO_MOTION_STAY); return; } @@ -305,17 +308,17 @@ void mot_walk(void) { return; } } - player->directionView = (f32) player->controlStickAngle ; - if ((u32) player->hitobjStandOn != 0U) { + player->directionView = player->controlStickAngle; + if (player->hitobjStandOn != 0) { // Redundant, but doesn't match otherwise if (player->playerGravity == 1.0f) { unkArgMarioWalkDashSe = 0x28; - } else { + } else { unkArgMarioWalkDashSe = 0x28; } marioWalkDashSe(player->hitobjStandOn, unkArgMarioWalkDashSe); } - player->multiTimer = (s32) (player->multiTimer + 1); + player->multiTimer = player->multiTimer + 1; if (player->flags & MARIO_FLAG_IS_PUSHING && !marioChkPushAnime()) { marioChgPose("M_O_1"); } @@ -367,7 +370,7 @@ f32 marioGetWalkSpd(void) { } else if (marioBgmodeChk() == 1) { walkSpeed *= 0.5f; } - + walkSpeed *= mario->playerGravity; return walkSpeed; } From 131b8ed70af05e22e48e161806495df0e4a974f6 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 13:16:43 -0300 Subject: [PATCH 12/14] remove unused variable --- src/motion/mot_walk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 8659b2f..f4daf50 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -88,7 +88,6 @@ void mot_dash(void) { MarioWork* player; CaseEntry* caseEntry; MarioWork* _player; - void* hitobjPush; player = marioGetPtr(); characterId = player->characterId; From d65cb419ee9ff8087675dbc37314e99b5f8a50e9 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 15:08:46 -0300 Subject: [PATCH 13/14] change BOOL comps to use TRUE not 1 --- src/motion/mot_walk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index f4daf50..94cdffd 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -149,7 +149,7 @@ void mot_dash(void) { if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { dashSpeed *= 0.5f; } - } else if (marioBgmodeChk() == 1) { + } else if (marioBgmodeChk() == TRUE) { dashSpeed *= 0.5f; } dashSpeed *= _player->playerGravity; @@ -260,7 +260,7 @@ void mot_walk(void) { if ((_stickDir1 * _stickDir1) + (_stickDir2 * _stickDir2) <= 0xBD1) { walkSpeed *= 0.5f; } - } else if (marioBgmodeChk() == 1) { + } else if (marioBgmodeChk() == TRUE) { walkSpeed *= 0.5f; } walkSpeed *= _player->playerGravity; @@ -344,7 +344,7 @@ f32 marioGetDashSpd(void) { if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { dashSpeed *= 0.5f; } - } else if (marioBgmodeChk() == 1) { + } else if (marioBgmodeChk() == TRUE) { dashSpeed *= 0.5f; } @@ -366,7 +366,7 @@ f32 marioGetWalkSpd(void) { if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { walkSpeed *= 0.5f; } - } else if (marioBgmodeChk() == 1) { + } else if (marioBgmodeChk() == TRUE) { walkSpeed *= 0.5f; } From 0584d8569e3c165371363d43628a946bc5361d74 Mon Sep 17 00:00:00 2001 From: Ilwyd Date: Mon, 8 Jun 2026 16:02:53 -0300 Subject: [PATCH 14/14] clean up some inlined functions --- src/motion/mot_walk.c | 133 ++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 82 deletions(-) diff --git a/src/motion/mot_walk.c b/src/motion/mot_walk.c index 94cdffd..7453089 100644 --- a/src/motion/mot_walk.c +++ b/src/motion/mot_walk.c @@ -12,6 +12,52 @@ extern s32 gp; // m2c +f32 marioGetDashSpd(void) { + MarioWork* mario; + f32 dashSpeed; + s8 stickDir2; + s8 stickDir1; + + mario = marioGetPtr(); + dashSpeed = mario->mBaseDashSpeed; + if (mario->flags & MARIO_FLAG_PAPER_MODE) { + stickDir1 = mario->wStickDir1; + stickDir2 = mario->wStickDir2; + dashSpeed = mario->mBaseWalkSpeed; + + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { + dashSpeed *= 0.5f; + } + } else if (marioBgmodeChk() == TRUE) { + dashSpeed *= 0.5f; + } + + dashSpeed *= mario->playerGravity; + return dashSpeed; +} + +f32 marioGetWalkSpd(void) { + f32 walkSpeed; + s8 stickDir2; + s8 stickDir1; + MarioWork* mario; + + mario = marioGetPtr(); + walkSpeed = mario->mBaseWalkSpeed; + if (mario->flags & MARIO_FLAG_PAPER_MODE) { + stickDir1 = mario->wStickDir1; + stickDir2 = mario->wStickDir2; + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { + walkSpeed *= 0.5f; + } + } else if (marioBgmodeChk() == TRUE) { + walkSpeed *= 0.5f; + } + + walkSpeed *= mario->playerGravity; + return walkSpeed; +} + void marioWalkDashSe(HitObj* hitObj, u32 arg1) { s32 hitAttr; MarioWork* mario; @@ -82,12 +128,9 @@ void mot_dash(void) { s32 unkArgMarioWalkDashSe; s8 characterId; s8 stickDir2; - s8 _stickDir2; s8 stickDir1; - s8 _stickDir1; MarioWork* player; CaseEntry* caseEntry; - MarioWork* _player; player = marioGetPtr(); characterId = player->characterId; @@ -140,20 +183,7 @@ void mot_dash(void) { marioChgPose("M_W_1"); } if (player->forceMoveTimer == 0) { - _player = marioGetPtr(); - dashSpeed = _player->mBaseDashSpeed; - if (_player->flags & MARIO_FLAG_PAPER_MODE) { - stickDir1 = _player->wStickDir1; - stickDir2 = _player->wStickDir2; - dashSpeed = _player->mBaseWalkSpeed; - if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { - dashSpeed *= 0.5f; - } - } else if (marioBgmodeChk() == TRUE) { - dashSpeed *= 0.5f; - } - dashSpeed *= _player->playerGravity; - player->baseSpeed = dashSpeed; + player->baseSpeed = marioGetDashSpd(); } } if (!(player->flags & MARIO_FLAG_IS_CARRYING_BOBBERY) && @@ -182,9 +212,9 @@ void mot_dash(void) { } player->multiTimer = player->multiTimer + 1; if (!(player->flags & MARIO_FLAG_FORCED_MOVEMENT)) { - _stickDir1 = player->wStickDir1; - _stickDir2 = player->wStickDir2; - if ((_stickDir1 * _stickDir1) + (_stickDir2 * _stickDir2) <= 0xBD1) { + stickDir1 = player->wStickDir1; + stickDir2 = player->wStickDir2; + if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { marioChgMot(MARIO_MOTION_WALK); return; } @@ -206,13 +236,10 @@ void mot_walk(void) { BOOL unkConditionActive; s32 unkArgMarioWalkDashSe; s8 characterId; - s8 _stickDir2; s8 stickDir2; - s8 _stickDir1; s8 stickDir1; MarioWork* player; CaseEntry* caseEntry; - MarioWork* _player; player = marioGetPtr(); characterId = player->characterId; @@ -252,19 +279,7 @@ void mot_walk(void) { motSlitContinue(); } if (player->forceMoveTimer == 0) { - _player = marioGetPtr(); - walkSpeed = _player->mBaseWalkSpeed; - if (_player->flags & MARIO_FLAG_PAPER_MODE) { - _stickDir1 = _player->wStickDir1; - _stickDir2 = _player->wStickDir2; - if ((_stickDir1 * _stickDir1) + (_stickDir2 * _stickDir2) <= 0xBD1) { - walkSpeed *= 0.5f; - } - } else if (marioBgmodeChk() == TRUE) { - walkSpeed *= 0.5f; - } - walkSpeed *= _player->playerGravity; - player->baseSpeed = walkSpeed; + player->baseSpeed = marioGetWalkSpd(); } flags = player->flags; if (flags & MARIO_FLAG_IS_CARRYING_BOBBERY) { @@ -327,49 +342,3 @@ void mot_walk(void) { } } } - -f32 marioGetDashSpd(void) { - MarioWork* mario; - f32 dashSpeed; - s8 stickDir2; - s8 stickDir1; - - mario = marioGetPtr(); - dashSpeed = mario->mBaseDashSpeed; - if (mario->flags & MARIO_FLAG_PAPER_MODE) { - stickDir1 = mario->wStickDir1; - stickDir2 = mario->wStickDir2; - dashSpeed = mario->mBaseWalkSpeed; - - if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { - dashSpeed *= 0.5f; - } - } else if (marioBgmodeChk() == TRUE) { - dashSpeed *= 0.5f; - } - - dashSpeed *= mario->playerGravity; - return dashSpeed; -} - -f32 marioGetWalkSpd(void) { - f32 walkSpeed; - s8 stickDir2; - s8 stickDir1; - MarioWork* mario; - - mario = marioGetPtr(); - walkSpeed = mario->mBaseWalkSpeed; - if (mario->flags & MARIO_FLAG_PAPER_MODE) { - stickDir1 = mario->wStickDir1; - stickDir2 = mario->wStickDir2; - if ((stickDir1 * stickDir1) + (stickDir2 * stickDir2) <= 0xBD1) { - walkSpeed *= 0.5f; - } - } else if (marioBgmodeChk() == TRUE) { - walkSpeed *= 0.5f; - } - - walkSpeed *= mario->playerGravity; - return walkSpeed; -}