diff --git a/include/core2/core2.h b/include/core2/core2.h index 0c401741..7fe1faca 100644 --- a/include/core2/core2.h +++ b/include/core2/core2.h @@ -8,7 +8,7 @@ void func_80351A04(Struct68s *arg0, s32 arg1); void func_80351A14(Struct68s *arg0, Struct68DrawMethod arg1); -void func_8035179C(Struct68s* arg0, f32 arg1[3]); +void func_8035179C_copyPosition(Struct68s* arg0, f32 arg1[3]); void func_80351814(Struct68s *arg0, f32 arg1[3]); f32 func_80351830(Struct68s *arg0); diff --git a/include/enums.h b/include/enums.h index 819f7c9a..0c482964 100644 --- a/include/enums.h +++ b/include/enums.h @@ -1246,7 +1246,7 @@ enum sfx_e SFX_12C_FF_QUESTION_START, SFX_12D_CAMERA_ZOOM_CLOSEST, SFX_12E_CAMERA_ZOOM_MEDIUM, - SFX_12F_FUUUCK_YOUUU, + SFX_12F_THAAANK_YOOOUUU, // from her final fall SFX_130_GRUNTY_ECHOING_CRY = 0x0130, SFX_131_GRUNTY_WEEEGH, @@ -2427,6 +2427,17 @@ enum ttc_specific_flags { TTC_SPECIFIC_FLAG_7_NIPPER_FIRST_MEET_TEXT_SHOWN = 0x7 }; +enum mmm_specific_flags { + MMM_SPECIFIC_FLAG_0_UNKNOWN, + MMM_SPECIFIC_FLAG_TUMBLAR_BROKEN, + MMM_SPECIFIC_FLAG_2_UNKNOWN, + MMM_SPECIFIC_FLAG_3_UNKNOWN, + MMM_SPECIFIC_FLAG_4_UNKNOWN, + MMM_SPECIFIC_FLAG_5_UNKNOWN, + MMM_SPECIFIC_FLAG_6_UNKNOWN, + MMM_SPECIFIC_FLAG_7_UNKNOWN +}; + enum item_e { ITEM_0_HOURGLASS_TIMER = 0x0, @@ -4159,7 +4170,16 @@ enum asset_e ASSET_A84_DIALOG_TURBOTRAINERS_LEARN, ASSET_A85_DIALOG_TURBOTRAINERS_REFRESHER, - ASSET_ADE_TEXT_LOGGO_AS_BEAR = 0xade, + ASSET_AD3_TEXT_UNKNOWN = 0xad3, + ASSET_AD4_TEXT_UNKNOWN, + ASSET_AD5_TEXT_UNKNOWN, + ASSET_AD6_TEXT_UNKNOWN, + + ASSET_ADA_TEXT_UNKNOWN = 0xada, + ASSET_ADB_TEXT_UNKNOWN, + + ASSET_ADD_TEXT_UNKNOWN = 0xadd, + ASSET_ADE_TEXT_LOGGO_AS_BEAR, ASSET_ADF_TEXT_ENTER_LOGGO, ASSET_AE0_TEXT_EXIT_LOGGO, @@ -4711,8 +4731,8 @@ enum marker_e{ MARKER_AB_RUBEES_EGG_POT, MARKER_AD_SLAPPA = 0xAD, - - MARKER_AF_MAGIC_CARPET_SHADOW = 0xAF, + MARKER_AE_UNKNOWN, + MARKER_AF_MAGIC_CARPET_SHADOW, MARKER_B0_MAGIC_CARPET_2, MARKER_B1_SIR_SLUSH, MARKER_B2_SNOWBALL, @@ -4724,8 +4744,8 @@ enum marker_e{ MARKER_B9_FP_SNOWMAN_BUTTON = 0xB9, MARKER_BA_XMAS_TREE, - - MARKER_BC_GOBI_1 = 0xBC, + MARKER_BB_UNKNOWN, + MARKER_BC_GOBI_1, MARKER_BD_GOBI_ROPE, MARKER_BE_GOBI_ROCK, MARKER_BF_GOBI_2, diff --git a/include/functions.h b/include/functions.h index 561e36a0..9e8d51eb 100644 --- a/include/functions.h +++ b/include/functions.h @@ -406,7 +406,7 @@ int func_80328A2C(Actor *, f32, s32, f32); void subaddie_set_state(Actor *, u32); ActorMarker *func_8032B16C(enum jiggy_e jiggy_id); int subaddie_maybe_set_state(Actor *, s32, f32); -void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 arg2, s32 direction); +void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 anim_start_position, s32 direction); bool subaddie_maybe_set_state_position_direction(Actor *, s32, f32, s32, f32 ); void func_80328CEC(Actor *, s32, s32, s32); void func_80328FB0(Actor *, f32); diff --git a/include/structs.h b/include/structs.h index ceec68ea..a6bcd9cc 100644 --- a/include/structs.h +++ b/include/structs.h @@ -593,7 +593,7 @@ typedef struct struct_68_s{ Struct68DrawMethod unk8; BKModelBin *unkC; u8 pad10[0x4]; - f32 unk14[3]; //position + f32 position[3]; f32 unk20[3]; //rotation f32 unk2C; //scale u8 unk30; diff --git a/src/CC/code_13C0.c b/src/CC/code_13C0.c index 6607692c..3723775d 100644 --- a/src/CC/code_13C0.c +++ b/src/CC/code_13C0.c @@ -121,7 +121,7 @@ void CC_func_80387A40(Struct_CC_13C0_1* arg0, Struct68s* arg1, f32 arg2) { } } if ((arg0->unk4 == 0) || (arg0->unk4 == 1)) { - func_8035179C(arg1, sp38); + func_8035179C_copyPosition(arg1, sp38); func_80351814(arg1, sp2C); sp44[0] = 0.0f; sp44[1] = 0.0f; diff --git a/src/CCW/code_2270.c b/src/CCW/code_2270.c index 6fbccf57..06901e73 100644 --- a/src/CCW/code_2270.c +++ b/src/CCW/code_2270.c @@ -140,7 +140,7 @@ void chGobiCCW_update(Actor *this) { this->has_met_before = FALSE; local->unk4 = skeletalAnim_new(); local->spit_model = assetcache_get(ASSET_3F3_MODEL_GOBI_SPIT); - marker_setCollisionScripts(this->marker, 0, func_8038894C, 0); + marker_setCollisionScripts(this->marker, NULL, func_8038894C, NULL); if(!jiggyscore_isSpawned(JIGGY_4D_CCW_FLOWER)) { fileProgressFlag_set(FILEPROG_E5_CCW_FLOWER_AUTUMN, FALSE); } diff --git a/src/CCW/code_2B00.c b/src/CCW/code_2B00.c index 8e9af7de..92aed154 100644 --- a/src/CCW/code_2B00.c +++ b/src/CCW/code_2B00.c @@ -90,7 +90,7 @@ void func_80388FD4(Actor *this) { subaddie_set_state_with_direction(this, 4, 0.999f, 1); actor_collisionOff(this); } else { - marker_setCollisionScripts(this->marker, 0, &func_80388F50, 0); + marker_setCollisionScripts(this->marker, NULL, &func_80388F50, NULL); } this->unk38_0 = FALSE; this->volatile_initialized = TRUE; diff --git a/src/CCW/code_7120.c b/src/CCW/code_7120.c index 4c26f172..962f2dde 100644 --- a/src/CCW/code_7120.c +++ b/src/CCW/code_7120.c @@ -105,7 +105,7 @@ void func_8038D85C(Actor *this) { if (!this->volatile_initialized) { this->marker->propPtr->unk8_3 = TRUE; this->volatile_initialized = TRUE; - marker_setCollisionScripts(this->marker, 0, &func_8038D81C, 0); + marker_setCollisionScripts(this->marker, NULL, &func_8038D81C, NULL); func_8038D6D8(this, 1); if (jiggyscore_isCollected(JIGGY_4B_CCW_GNAWTY) != FALSE) { diff --git a/src/MMM/ch/loggo.c b/src/MMM/ch/loggo.c index 9f1010ef..3513d7f0 100644 --- a/src/MMM/ch/loggo.c +++ b/src/MMM/ch/loggo.c @@ -2,11 +2,18 @@ #include "functions.h" #include "variables.h" +/* extern functions */ extern void ml_vec3f_assign(f32[3], f32, f32, f32); +/* public functions */ void chLoggo_update(Actor *this); /* .data */ +enum chLoggo_state_e { + LOGGO_STATE_1_IDLE = 1, + LOGGO_STATE_2_FLUSHING +}; + ActorAnimationInfo chLoggoAnimations[] = { {0, 0.0f}, {ASSET_238_ANIM_LOGGO_IDLE, 0.8f}, @@ -14,61 +21,66 @@ ActorAnimationInfo chLoggoAnimations[] = { }; ActorInfo chLoggo = { - MARKER_252_LOGGO, ACTOR_37F_LOGGO, ASSET_519_MODEL_LOGGO, - 0x1, chLoggoAnimations, - chLoggo_update, actor_update_func_80326224, actor_draw, + MARKER_252_LOGGO, ACTOR_37F_LOGGO, ASSET_519_MODEL_LOGGO, + 0x1, chLoggoAnimations, + chLoggo_update, actor_update_func_80326224, actor_draw, 1000, 0, 0.0f, 0 }; /* .code */ -void __chLoggo_flush(ActorMarker* marker) { - Actor* actor = marker_getActor(marker); +void __chLoggo_flush(ActorMarker *marker) { + Actor *actor = marker_getActor(marker); func_8028F918(2); - subaddie_set_state_with_direction(actor, 2, 0.01, 1); + subaddie_set_state_with_direction(actor, LOGGO_STATE_2_FLUSHING, 0.01, 1); actor_playAnimationOnce(actor); actor->lifetime_value = 3.2f; } -void __chLoggo_textCallback(ActorMarker* caller, enum asset_e text_id, s32 arg3) { +void __chLoggo_textCallback(ActorMarker *caller, enum asset_e text_id, s32 arg3) { __chLoggo_flush(caller); } -void __chLoggo_collide(ActorMarker* this_marker, ActorMarker *other_marker) { +void __chLoggo_collide(ActorMarker *this_marker, ActorMarker *other_marker) { Actor *this = marker_getActor(this_marker); + if ((player_getTransformation() == TRANSFORM_3_PUMPKIN) && !fileProgressFlag_get(FILEPROG_89_ENTERED_LOGGO_AS_PUMPKIN)) { if (gcdialog_showText(ASSET_ADF_TEXT_ENTER_LOGGO, 0x2B, this->position, this->marker, &__chLoggo_textCallback, 0) != 0) { actor_collisionOff(this); - fileProgressFlag_set(FILEPROG_89_ENTERED_LOGGO_AS_PUMPKIN, TRUE); } return; } + if ((player_getTransformation() == TRANSFORM_3_PUMPKIN) && fileProgressFlag_get(FILEPROG_89_ENTERED_LOGGO_AS_PUMPKIN)) { actor_collisionOff(this); __chLoggo_flush(this_marker); return; } - if ((player_getTransformation() == TRANSFORM_1_BANJO) && !fileProgressFlag_get(FILEPROG_88_TRIED_LOGGO_AS_BEAR)){ - if(gcdialog_showText(ASSET_ADE_TEXT_LOGGO_AS_BEAR, 0x2A, this->position, NULL, NULL, NULL)) { + if ((player_getTransformation() == TRANSFORM_1_BANJO) && !fileProgressFlag_get(FILEPROG_88_TRIED_LOGGO_AS_BEAR)) { + if (gcdialog_showText(ASSET_ADE_TEXT_LOGGO_AS_BEAR, 0x2A, this->position, NULL, NULL, NULL)) { fileProgressFlag_set(FILEPROG_88_TRIED_LOGGO_AS_BEAR, TRUE); } } } -void chLoggo_update(Actor *this){ - f32 sp44; - f32 sp38[3]; +void chLoggo_update(Actor *this) { + f32 tick; + f32 position[3]; s32 sp34; - sp44 = time_getDelta(); - if(!this->volatile_initialized){ + tick = time_getDelta(); + + if (!this->volatile_initialized) { this->volatile_initialized = TRUE; this->marker->propPtr->unk8_3 = TRUE; + actor_collisionOn(this); marker_setCollisionScripts(this->marker, __chLoggo_collide, NULL, NULL); - subaddie_set_state_with_direction(this, 1, 0.01f, 1); + + subaddie_set_state_with_direction(this, LOGGO_STATE_1_IDLE, 0.01f, 1); actor_loopAnimation(this); + this->lifetime_value = 0.0f; if (!fileProgressFlag_get(FILEPROG_8A_EXITED_LOGGO) && levelSpecificFlags_get(LEVEL_FLAG_33_MMM_UNKNOWN)) { @@ -78,45 +90,44 @@ void chLoggo_update(Actor *this){ } } - switch(this->state){ - case 1: + switch (this->state) { + case LOGGO_STATE_1_IDLE: sp34 = func_803114B0() ? 12000 : 0; - if(actor_animationIsAt(this, 0.09f)){ + if (actor_animationIsAt(this, 0.09f)) { func_8030E878(SFX_109_LOGGO_LID_CLAP, randf2(0.975f, 1.025f), MAX(0, 22000 - sp34), this->position, 400.0f, 1000.0f); break; } - if(actor_animationIsAt(this, 0.37f)){ + if (actor_animationIsAt(this, 0.37f)) { func_8030E878(SFX_20_METAL_CLANK_1, randf2(1.675f, 1.725f), MAX(0, 12000 - sp34), this->position, 400.0f, 1000.0f); break; } - if(actor_animationIsAt(this, 0.6f)){ + if (actor_animationIsAt(this, 0.6f)) { func_8030E878(SFX_3F_CAULDRON_SQEAK_1, randf2(0.975f, 1.025f), MAX(0, 7000 - sp34), this->position, 400.0f, 1000.0f); break; } - - if(actor_animationIsAt(this, 0.16f)){ + + if (actor_animationIsAt(this, 0.16f)) { func_8030E878(SFX_40_CAULDRON_SQEAK_2, randf2(0.975f, 1.025f), MAX(0, 7000 - sp34), this->position, 400.0f, 1000.0f); break; } - break; - case 2: - if(actor_animationIsAt(this, 0.46f)){ + case LOGGO_STATE_2_FLUSHING: + if (actor_animationIsAt(this, 0.46f)) { this->marker->propPtr->unk8_3 = FALSE; FUNC_8030E8B4(SFX_92_TOILET_FLUSH, 1.0f, 32000, this->position, 600, 1500); levelSpecificFlags_set(LEVEL_FLAG_33_MMM_UNKNOWN, TRUE); - ml_vec3f_assign(sp38, this->position_x - 50.0f, this->position_y + 50.0f, this->position_z); - func_8028F6E4(BS_INTR_2F_LOGGO, sp38); + ml_vec3f_assign(position, this->position_x - 50.0f, this->position_y + 50.0f, this->position_z); + func_8028F6E4(BS_INTR_2F_LOGGO, position); } - if(0.0 < this->lifetime_value){ - this->lifetime_value -= sp44; + if (0.0 < this->lifetime_value) { + this->lifetime_value -= tick; } - else{ + else { warp_mmmEnterLoggo(0, 0); } break; diff --git a/src/MMM/ch/motzhand.c b/src/MMM/ch/motzhand.c index c366b1d5..04a4b09b 100644 --- a/src/MMM/ch/motzhand.c +++ b/src/MMM/ch/motzhand.c @@ -2,22 +2,32 @@ #include "functions.h" #include "variables.h" -typedef struct{ +typedef struct { f32 alpha; //motzhand_alpha u8 *pattern_ptr; u8 unk8; //pattern_id u8 unk9; //end_current seq? f32 unkC[3]; -}ActorLocal_Motzhand; +} ActorLocal_Motzhand; -void chmotzhand_update(Actor *this); +/* public functions */ +void chMotzhand_update(Actor *this); Actor *chMotzhand_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); /* .data */ +enum chMotzhand_state_e { + MOTZHAND_STATE_0_INIT, + MOTZHAND_STATE_1_UNKNOWN, + MOTZHAND_STATE_2_UNKNOWN, + MOTZHAND_STATE_3_UNKNOWN, + MOTZHAND_STATE_4_UNKNOWN, + MOTZHAND_STATE_5_UNKNOWN +}; + ActorInfo chMotzhand = { MARKER_49_MOTZHAND, ACTOR_3A_MOTZHAND, ASSET_88C_MODEL_MOTZHAND, 0x0, NULL, - chmotzhand_update, actor_update_func_80326224, chMotzhand_draw, + chMotzhand_update, actor_update_func_80326224, chMotzhand_draw, 0, 0, 0.0f, 0 }; @@ -25,53 +35,54 @@ u8 sMotzhandPattern1[] = {7, 14, 13, 9, 17, 0xFF}; u8 sMotzhandPattern2[] = {10, 18, 15, 9, 14, 13, 9, 17, 11, 15, 0xFF}; /* .code */ -void func_80387410(f32 dst[3]){ +void func_80387410(f32 dst[3]) { dst[0] = 0.0f; dst[1] = 1500.0f; dst[2] = -2400.0f; } -void chMotzhand_setState(Actor *this, s32 next_state){ - ActorLocal_Motzhand * local = (ActorLocal_Motzhand *) &this->local; +void chMotzhand_setState(Actor *this, s32 next_state) { + ActorLocal_Motzhand *local = (ActorLocal_Motzhand *) &this->local; - if(next_state == 1 && this->state == 0){ + if (next_state == MOTZHAND_STATE_1_UNKNOWN && this->state == MOTZHAND_STATE_0_INIT) { skeletalAnim_set(this->unk148, ASSET_A7_ANIM_MOTZHAND_IDLE, 0.0f, 1.8f); func_80387410(this->position); } - if(next_state == 2){ + if (next_state == MOTZHAND_STATE_2_UNKNOWN) { skeletalAnim_set(this->unk148, ASSET_A7_ANIM_MOTZHAND_IDLE, 0.9f, 1.8f); } - if(next_state == 3){ + if (next_state == MOTZHAND_STATE_3_UNKNOWN) { skeletalAnim_set(this->unk148, ASSET_A8_ANIM_MOTZHAND_PLAY, 0.9f, 1.8f); } - if(next_state == 4){ + if (next_state == MOTZHAND_STATE_4_UNKNOWN) { local->alpha = 1.0f; } - if(next_state == 5){ + if (next_state == MOTZHAND_STATE_5_UNKNOWN) { marker_despawn(this->marker); } this->state = next_state; } -Actor *chMotzhand_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ +Actor *chMotzhand_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { Actor *this = marker_getActor(marker); - ActorLocal_Motzhand * local = (ActorLocal_Motzhand *) &this->local; + ActorLocal_Motzhand *local = (ActorLocal_Motzhand *) &this->local; f32 sp3C[3]; - if(this->state == 0 || this->state == 5) + if (this->state == MOTZHAND_STATE_0_INIT || this->state == MOTZHAND_STATE_5_UNKNOWN) { return this; - - modelRender_setBoneTransformList(skeletalAnim_getBoneTransformList(this->unk148)); - - if(this->state == 4){ - modelRender_setAlpha((s32) (local->alpha * 255.0f)); } - else{ + + modelRender_setBoneTransformList(skeletalAnim_getBoneTransformList(this->unk148)); + + if (this->state == MOTZHAND_STATE_4_UNKNOWN) { + modelRender_setAlpha((s32)(local->alpha * 255.0f)); + } + else { modelRender_setAlpha((s32) 255); } @@ -84,119 +95,124 @@ Actor *chMotzhand_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ } -void func_80387654(ActorMarker* marker) { - Actor* actor = marker_getActor(marker); +void func_80387654(ActorMarker *marker) { + Actor *actor = marker_getActor(marker); - if ((actor->state != 4) && (actor->state != 5)) { - chMotzhand_setState(actor, 4); + if ((actor->state != MOTZHAND_STATE_4_UNKNOWN) && (actor->state != MOTZHAND_STATE_5_UNKNOWN)) { + chMotzhand_setState(actor, MOTZHAND_STATE_4_UNKNOWN); } } bool func_8038769C(ActorMarker *marker) { - return marker_getActor(marker)->state == 1; + return marker_getActor(marker)->state == MOTZHAND_STATE_1_UNKNOWN; } // chMotzhand_startPattern -void func_803876C8(ActorMarker *marker, s32 arg1){ +void func_803876C8(ActorMarker *marker, s32 arg1) { Actor *this = marker_getActor(marker); - ActorLocal_Motzhand * local = (ActorLocal_Motzhand *) &this->local; - + ActorLocal_Motzhand *local = (ActorLocal_Motzhand *) &this->local; + local->unk8 = arg1; - if(arg1 == TRUE){ + if (arg1 == TRUE) { local->pattern_ptr = sMotzhandPattern1; } - else{ + else { local->pattern_ptr = sMotzhandPattern2; } - chMotzhand_setState(this, 2); + chMotzhand_setState(this, MOTZHAND_STATE_2_UNKNOWN); } void func_80387720(ActorMarker *marker) { - Actor * this = marker_getActor(marker); - ActorLocal_Motzhand * local = (ActorLocal_Motzhand *) &this->local; + Actor *this = marker_getActor(marker); + ActorLocal_Motzhand *local = (ActorLocal_Motzhand *) &this->local; local->unk9 = TRUE; } -void chmotzhand_update(Actor *this){ - ActorLocal_Motzhand * local = (ActorLocal_Motzhand *) &this->local; - f32 sp48; - f32 sp3C[3]; +void chMotzhand_update(Actor *this) { + ActorLocal_Motzhand *local = (ActorLocal_Motzhand *) &this->local; + f32 tick; + f32 diff[3]; f32 sp30[3]; - sp48 = time_getDelta(); + tick = time_getDelta(); - if(!this->volatile_initialized){ + if (!this->volatile_initialized) { this->volatile_initialized = TRUE; - if(jiggyscore_isSpawned(JIGGY_60_MMM_MOTZHAND)){ + + if (jiggyscore_isSpawned(JIGGY_60_MMM_MOTZHAND)) { marker_despawn(this->marker); return; } + local->unk8 = FALSE; local->unk9 = FALSE; local->unkC[0] = this->position_x; local->unkC[1] = this->position_y; local->unkC[2] = this->position_z; - chMotzhand_setState(this, 1); + + chMotzhand_setState(this, MOTZHAND_STATE_1_UNKNOWN); }//L803877CC - if(this->state == 2){ - if(local->unk9){ - while(*local->pattern_ptr != 0xff){ + if (this->state == MOTZHAND_STATE_2_UNKNOWN) { + if (local->unk9) { + while (*local->pattern_ptr != 0xff) { *local->pattern_ptr++; //find_seq end } local->unk9 = FALSE; }//L80387820 - if(0xff == *local->pattern_ptr){ + if (0xff == *local->pattern_ptr) { func_80387410(sp30); } - else{ + else { organMinigame_getKeyPosition(*local->pattern_ptr, sp30); - sp30[0] += local->unkC[0]; - sp30[1] += local->unkC[1]; - sp30[2] += local->unkC[2]; + TUPLE_ADD(sp30, local->unkC) }//L80387880 - sp3C[0] = sp30[0] - this->position_x; - sp3C[1] = sp30[1] - this->position_y; - sp3C[2] = sp30[2] - this->position_z; - if(LENGTH_VEC3F(sp3C) < 5.0f){ - if(*local->pattern_ptr == 0xff){ - chMotzhand_setState(this, 1); + diff[0] = sp30[0] - this->position_x; + diff[1] = sp30[1] - this->position_y; + diff[2] = sp30[2] - this->position_z; + + if (LENGTH_VEC3F(diff) < 5.0f) { + if (*local->pattern_ptr == 0xff) { + chMotzhand_setState(this, MOTZHAND_STATE_1_UNKNOWN); } - else{ - chMotzhand_setState(this, 3); + else { + chMotzhand_setState(this, MOTZHAND_STATE_3_UNKNOWN); } } - else{//L80387930 - ml_vec3f_set_length(sp3C, ((local->unk8 == TRUE) ? 150.0f : 225.0f)*sp48); - this->position_x = sp3C[0] + this->position_x; - this->position_y = sp3C[1] + this->position_y; - this->position_z = sp3C[2] + this->position_z; + else {//L80387930 + ml_vec3f_set_length(diff, ((local->unk8 == TRUE) ? 150.0f : 225.0f) * tick); + this->position_x = diff[0] + this->position_x; + this->position_y = diff[1] + this->position_y; + this->position_z = diff[2] + this->position_z; } }//L803879A4 - if(this->state == 3){ - if(skeletalAnim_getLoopCount(this->unk148) > 0){ + if (this->state == MOTZHAND_STATE_3_UNKNOWN) { + if (skeletalAnim_getLoopCount(this->unk148) > 0) { func_80389D9C(*local->pattern_ptr); - if(local->unk9){ - while(*local->pattern_ptr != 0xff){ + + if (local->unk9) { + while (*local->pattern_ptr != 0xff) { *local->pattern_ptr++; //find_seq end } local->unk9 = FALSE; } - else{//L80387A18 + else {//L80387A18 *local->pattern_ptr++; } - chMotzhand_setState(this, 2); + + chMotzhand_setState(this, MOTZHAND_STATE_2_UNKNOWN); } }//L80387A2C - if(this->state == 4){ - local->alpha -= 0.25*sp48; - if(local->alpha <= 0.0f){ - chMotzhand_setState(this, 5); + if (this->state == MOTZHAND_STATE_4_UNKNOWN) { + local->alpha -= 0.25 * tick; + + if (local->alpha <= 0.0f) { + chMotzhand_setState(this, MOTZHAND_STATE_5_UNKNOWN); } } } diff --git a/src/MMM/code_16B0.c b/src/MMM/code_16B0.c index 669ff195..8ac7db39 100644 --- a/src/MMM/code_16B0.c +++ b/src/MMM/code_16B0.c @@ -2,91 +2,109 @@ #include "functions.h" #include "variables.h" -extern void func_80389484(ActorMarker *, f32); +/* extern functions */ +extern void chPortrait_break(ActorMarker *, f32); typedef struct { - f32 unk0; -}ActorLocal_PortraitChompa; + f32 timer; +} ActorLocal_PortraitChompa; -void func_80388028(Actor *this); -Actor *func_80387AA0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); +/* public functions */ +void chChompa_update(Actor *this); +Actor *chChompa_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); /* .data */ -ActorInfo D_8038BAD0 = { - MARKER_254_PORTRAIT_CHOMPA_A, ACTOR_381_PORTRAIT_CHOMPA, ASSET_521_MODEL_PORTRAIT_CHOMPA, +enum chChompa_state_e { + CHOMPA_STATE_0_INIT, + CHOMPA_STATE_1_IDLE, + CHOMPA_STATE_2_GROWLING, + CHOMPA_STATE_3_WAITING_TO_BITE, + CHOMPA_STATE_4_BITING, + CHOMPA_STATE_5_DYING, + CHOMPA_STATE_6_DEAD +}; + +ActorInfo D_8038BAD0 = { + MARKER_254_PORTRAIT_CHOMPA_A, ACTOR_381_PORTRAIT_CHOMPA, ASSET_521_MODEL_PORTRAIT_CHOMPA, 0x0, NULL, - func_80388028, NULL, func_80387AA0, + chChompa_update, NULL, chChompa_draw, 0, 0, 0.0f, 0 }; /* .code */ -Actor *func_80387AA0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { - Actor* actor = marker_getActor(marker); - if ((actor->state == 0) || (actor->state == 1) || (actor->state == 6) || (actor->state == 2)) { +Actor *chChompa_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { + Actor *actor = marker_getActor(marker); + + if (actor->state == CHOMPA_STATE_0_INIT || actor->state == CHOMPA_STATE_1_IDLE || actor->state == CHOMPA_STATE_6_DEAD || actor->state == CHOMPA_STATE_2_GROWLING) { return actor; } + return actor_draw(marker, gfx, mtx, vtx); } -void func_80387B14(Actor *this, s32 next_state){ +void chChompa_setState(Actor *this, s32 next_state) { ActorLocal_PortraitChompa *local = (ActorLocal_PortraitChompa *) &this->local; f32 tmp = 2.5f; this->marker->id = 0x1d1; - if(next_state == 1 || next_state == 2){ + if (next_state == CHOMPA_STATE_1_IDLE || next_state == CHOMPA_STATE_2_GROWLING) { skeletalAnim_set(this->unk148, 0x23e, 0.0f, 2.5f); skeletalAnim_setProgress(this->unk148, 0.99f); skeletalAnim_setBehavior(this->unk148, SKELETAL_ANIM_4_STOPPED); - if(this->state == 4){ - local->unk0 = randf2(0.5f, 1.0f); + + if (this->state == CHOMPA_STATE_4_BITING) { + local->timer = randf2(0.5f, 1.0f); } - else{ - local->unk0 = 0.0f; + else { + local->timer = 0.0f; } }//L80387BD0 - if(this->state == 1 && next_state == 2){ + if (this->state == CHOMPA_STATE_1_IDLE && next_state == CHOMPA_STATE_2_GROWLING) { FUNC_8030E624(SFX_3EF, 0.9f, 32675); } - if(next_state == 3){ - local->unk0 = 0.2f; + if (next_state == CHOMPA_STATE_3_WAITING_TO_BITE) { + local->timer = 0.2f; } - if(next_state == 4){ + if (next_state == CHOMPA_STATE_4_BITING) { this->marker->id = MARKER_254_PORTRAIT_CHOMPA_A; skeletalAnim_set(this->unk148, 0x23e, 0.0f, 2.5f); skeletalAnim_setBehavior(this->unk148, SKELETAL_ANIM_2_ONCE); - if(this->unk100){ - func_80389484(this->unk100, tmp + 0.55); + + if (this->unk100) { + chPortrait_break(this->unk100, tmp + 0.55); } + FUNC_8030E624(SFX_3EF, 1.1f, 25000); FUNC_8030E624(SFX_3EF, 1.1f, 25000); }//L80387CAC - if(next_state == 5){ + if (next_state == CHOMPA_STATE_5_DYING) { func_8030E6D4(SFX_1E_HITTING_AN_ENEMY_2); actor_collisionOff(this); } + this->state = next_state; } -void MMM_func_80387CF4(ActorMarker *this_marker, ActorMarker *other_marker) { - func_8030E6D4(0x1E); +void __chChompa_hit(ActorMarker *this_marker, ActorMarker *other_marker) { + func_8030E6D4(SFX_1E_HITTING_AN_ENEMY_2); } -void func_80387D1C(ActorMarker* this_marker, ActorMarker *other_marker) { +void __chChompa_die(ActorMarker *this_marker, ActorMarker *other_marker) { Actor *this = marker_getActor(this_marker); - func_80387B14(this, 5); + chChompa_setState(this, CHOMPA_STATE_5_DYING); } -void func_80387D48(ActorMarker *marker){ +void __chChompa_spwanPortrait(ActorMarker *marker) { Actor *this = marker_getActor(reinterpret_cast(ActorMarker *, marker)); enum asset_e portrait_id; Actor *portrait; - switch(this->unkF4_8){ + switch (this->unkF4_8) { case 0x32: portrait_id = ACTOR_382_PORTRAIT_OF_GRUNTY; break; @@ -109,13 +127,14 @@ void func_80387D48(ActorMarker *marker){ portrait_id = ACTOR_382_PORTRAIT_OF_GRUNTY; break; } + portrait = spawn_child_actor(portrait_id, &this); portrait->yaw = this->yaw; this->unk100 = portrait->marker; portrait->unk10_1 = FALSE; } -void func_80387DF8(f32 position[3], s32 count, enum asset_e sprite_id) { +void __chChompa_emitDust(f32 position[3], s32 count, enum asset_e sprite_id) { static s32 D_8038BAF4[3] = {0xB4, 0xFF, 0x8C}; static ParticleScaleAndLifetimeRanges D_8038BB00 = {{0.2f, 0.4f}, {1.8f, 2.8f}, {0.0f, 0.15f}, {0.7f, 1.2f}, 0.0f, 0.01f}; static ParticleSettingsVelocityAccelerationPosition D_8038BB28 = { @@ -123,9 +142,8 @@ void func_80387DF8(f32 position[3], s32 count, enum asset_e sprite_id) { {{ 0.0f, -600.0f, 0.0f}, { 0.0f, -600.0f, 0.0f}}, {{ -50.0f, -50.0f, -50.0f}, { 50.0f, 50.0f, 50.0f}} }; - ParticleEmitter *pCtrl; - pCtrl = partEmitMgr_newEmitter(count); + ParticleEmitter *pCtrl = partEmitMgr_newEmitter(count); particleEmitter_setRGB(pCtrl, D_8038BAF4); particleEmitter_setSprite(pCtrl, sprite_id); particleEmitter_setPosition(pCtrl, position); @@ -134,16 +152,15 @@ void func_80387DF8(f32 position[3], s32 count, enum asset_e sprite_id) { particleEmitter_emitN(pCtrl, count); } -void func_80387E84(f32 position[3], s32 count, enum asset_e model_id) { +void __chChompa_emitBones(f32 position[3], s32 count, enum asset_e model_id) { static ParticleScaleAndLifetimeRanges D_8038BB70 = {{1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}, {3.2f, 3.2f}, 0.0f, 0.45f}; static ParticleSettingsVelocityAccelerationPosition D_8038BB98 = { {{-90.0f, 300.0f, -90.0f}, {90.0f, 660.0f, 90.0f}}, {{ 0.0f, -1200.0f, 0.0f}, { 0.0f, -1200.0f, 0.0f}}, {{-50.0f, 0.0f, -50.0f}, {50.0f, 50.0f, 50.0f}} }; - ParticleEmitter *pCtrl; - pCtrl = partEmitMgr_newEmitter(count); + ParticleEmitter *pCtrl = partEmitMgr_newEmitter(count); particleEmitter_setModel(pCtrl, model_id); particleEmitter_setPosition(pCtrl, position); particleEmitter_setVelocityAccelerationAndPositionRanges(pCtrl, &D_8038BB98); @@ -157,97 +174,103 @@ void func_80387E84(f32 position[3], s32 count, enum asset_e model_id) { particleEmitter_emitN(pCtrl, count); } -void func_80387F7C(Actor *this){ +void __chChompa_emitDeathEffects(Actor *this) { f32 sp2C[3]; f32 sp20[3]; - if(!this->marker->unk14_21) return; + if (!this->marker->unk14_21) { + return; + } func_8034A174(this->marker->unk44, 5, sp2C); func_8034A174(this->marker->unk44, 6, sp20); - func_80387E84(sp2C, 1, ASSET_523_MODEL_PORTRAIT_CHOMPA_TEETH); - func_80387E84(sp2C, 1, ASSET_524_MODEL_PORTRAIT_CHOMPA_HEAD); - func_80387E84(sp20, 6, ASSET_525_MODEL_PORTRAIT_CHOMPA_PART); - func_80387DF8(sp2C, 2, ASSET_700_SPRITE_DUST); - func_80387DF8(sp20, 2, ASSET_700_SPRITE_DUST); + + __chChompa_emitBones(sp2C, 1, ASSET_523_MODEL_PORTRAIT_CHOMPA_TEETH); + __chChompa_emitBones(sp2C, 1, ASSET_524_MODEL_PORTRAIT_CHOMPA_HEAD); + __chChompa_emitBones(sp20, 6, ASSET_525_MODEL_PORTRAIT_CHOMPA_PART); + + __chChompa_emitDust(sp2C, 2, ASSET_700_SPRITE_DUST); + __chChompa_emitDust(sp20, 2, ASSET_700_SPRITE_DUST); } -void func_80388028(Actor *this){ +void chChompa_update(Actor *this) { ActorLocal_PortraitChompa *local = (ActorLocal_PortraitChompa *) &this->local; - f32 sp58 = time_getDelta(); + f32 tick = time_getDelta(); f32 plyr_position[3]; f32 plyr_dist; - f32 sp44; - f32 sp40; + f32 anim_prev_progress; + f32 anim_progress; - if(!this->volatile_initialized){ + if (!this->volatile_initialized) { this->volatile_initialized = TRUE; this->unk16C_0 = TRUE; - marker_setCollisionScripts(this->marker, NULL, MMM_func_80387CF4, func_80387D1C); - __spawnQueue_add_1((GenFunction_1)func_80387D48, reinterpret_cast(s32, this->marker)); - func_80387B14(this, (this->state < 5) ? 1 : 6); + marker_setCollisionScripts(this->marker, NULL, __chChompa_hit, __chChompa_die); + __spawnQueue_add_1((GenFunction_1) __chChompa_spwanPortrait, reinterpret_cast(s32, this->marker)); + chChompa_setState(this, this->state < CHOMPA_STATE_5_DYING ? CHOMPA_STATE_1_IDLE : CHOMPA_STATE_6_DEAD); }//L803880B4 player_getPosition(plyr_position); plyr_dist = ml_distance_vec3f(this->position, plyr_position); - if(this->state == 4) + if (this->state == CHOMPA_STATE_4_BITING) { actor_collisionOn(this); - else + } + else { actor_collisionOff(this); - - - if(this->state == 1 && plyr_dist < this->scale*400.0f){ - func_80387B14(this, 2); } - if(this->state == 2){ - if(0.0f < local->unk0){ - local->unk0 -= sp58; + if (this->state == CHOMPA_STATE_1_IDLE && plyr_dist < this->scale * 400.0f) { + chChompa_setState(this, CHOMPA_STATE_2_GROWLING); + } + + if (this->state == CHOMPA_STATE_2_GROWLING) { + if (0.0f < local->timer) { + local->timer -= tick; } - else if(plyr_dist < this->scale*300.0f){ - func_80387B14(this, 3); + else if (plyr_dist < this->scale * 300.0f) { + chChompa_setState(this, CHOMPA_STATE_3_WAITING_TO_BITE); } - else if(this->scale*500.0f < plyr_dist){ - func_80387B14(this, 1); + else if (this->scale * 500.0f < plyr_dist) { + chChompa_setState(this, CHOMPA_STATE_1_IDLE); } }//L80388204 - if(this->state == 3){ - if(ml_timer_update(&local->unk0, sp58)){ - func_80387B14(this, 4); + if (this->state == CHOMPA_STATE_3_WAITING_TO_BITE) { + if (ml_timer_update(&local->timer, tick)) { + chChompa_setState(this, CHOMPA_STATE_4_BITING); } } - if(this->state == 4){ - skeletalAnim_getProgressRange(this->unk148, &sp44, &sp40); - if(sp44 < 0.56 && 0.56 <= sp40){ + if (this->state == CHOMPA_STATE_4_BITING) { + skeletalAnim_getProgressRange(this->unk148, &anim_prev_progress, &anim_progress); + + if (anim_prev_progress < 0.56 && 0.56 <= anim_progress) { this->marker->id = 0x1d1; } - if(sp44 < 0.5 && 0.5 <= sp40){ + if (anim_prev_progress < 0.5 && 0.5 <= anim_progress) { FUNC_8030E624(SFX_2_CLAW_SWIPE, 0.9f, 32000); } - if( (sp44 < 0.11 && 0.11 <= sp40) - || (sp44 < 0.32 && 0.32 <= sp40) - || (sp44 < 0.53 && 0.53 <= sp40) - ){ + if ((anim_prev_progress < 0.11 && 0.11 <= anim_progress) || + (anim_prev_progress < 0.32 && 0.32 <= anim_progress) || + (anim_prev_progress < 0.53 && 0.53 <= anim_progress) + ) { func_8030E6A4(SFX_6D_CROC_BITE, randf2(0.95f, 1.05f), 32000); } - if(sp44 < 0.9 && 0.9 <= sp40){ + if (anim_prev_progress < 0.9 && 0.9 <= anim_progress) { func_8030E6D4(SFX_2_CLAW_SWIPE); } - if(skeletalAnim_getLoopCount(this->unk148) > 0){ - func_80387B14(this, 2); + + if (skeletalAnim_getLoopCount(this->unk148) > 0) { + chChompa_setState(this, CHOMPA_STATE_2_GROWLING); } } - if(this->state == 5){ + if (this->state == CHOMPA_STATE_5_DYING) { func_8030E6D4(SFX_D7_GRABBA_DEATH); - func_80387F7C(this); - func_80387B14(this, 6); + __chChompa_emitDeathEffects(this); + chChompa_setState(this, CHOMPA_STATE_6_DEAD); } - } diff --git a/src/MMM/code_2040.c b/src/MMM/code_2040.c index 38026fc5..763dfc70 100644 --- a/src/MMM/code_2040.c +++ b/src/MMM/code_2040.c @@ -287,7 +287,7 @@ void func_80388BDC(Actor *this) { f64 phi_f0; func_802D3D74(this); - mapSpecificFlags_set(1, BOOL((this->yaw > 260.0f) && (this->yaw < 330.0f))); + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_TUMBLAR_BROKEN, BOOL((this->yaw > 260.0f) && (this->yaw < 330.0f))); if (!this->volatile_initialized) { if (this->yaw != 0.0f) { this->lifetime_value = 0.5f; @@ -304,11 +304,11 @@ void func_80388BDC(Actor *this) { switch (this->state) { case 1: this->yaw = 0.0f; - if(mapSpecificFlags_get(0)) { + if(mapSpecificFlags_get(MMM_SPECIFIC_FLAG_0_UNKNOWN)) { func_802BAFE4(0x21); subaddie_set_state(this, 6); func_80244BB0(0, 0x6A, 0x7FF8, 0.3f); - mapSpecificFlags_set(2, 0); + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_2_UNKNOWN, FALSE); func_8025A6EC(COMUSIC_4_MMM_CLOCK_VERSION, -1); func_8025AE0C(2000, 3.0f); } @@ -350,7 +350,7 @@ void func_80388BDC(Actor *this) { subaddie_set_state(this, 1U); this->yaw = 0.0f; func_8030E540(SFX_7F_HEAVYDOOR_SLAM); - mapSpecificFlags_set(0, 0); + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_0_UNKNOWN, FALSE); func_80244C78(0); if (!this->unk38_31) { func_8025A6EC(COMUSIC_3C_MINIGAME_LOSS, 0x7FF8); diff --git a/src/MMM/code_2F60.c b/src/MMM/code_2F60.c index 8c184381..cad28d33 100644 --- a/src/MMM/code_2F60.c +++ b/src/MMM/code_2F60.c @@ -2,11 +2,17 @@ #include "functions.h" #include "variables.h" -Actor *func_80389350(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); -void func_803893A4(Actor *this); +/* public functions */ +Actor *chPortrait_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); +void chPortrait_update(Actor *this); /* .data */ -ActorAnimationInfo D_8038BE30[] ={ +enum chPortrait_state_e { + PORTRAIT_STATE_1_IDLE = 1, + PORTRAIT_STATE_2_BROKEN +}; + +ActorAnimationInfo D_8038BE30[] = { {0x000, 0.0f}, {0x23F, 10000000.0f}, {0x23F, 2.0f}, @@ -14,68 +20,69 @@ ActorAnimationInfo D_8038BE30[] ={ ActorInfo D_8038BE48 = { MARKER_255_PORTRAIT_OF_GRUNTY, ACTOR_382_PORTRAIT_OF_GRUNTY, ASSET_522_MODEL_PORTRAIT_OF_GRUNTY, - 0x1, D_8038BE30, - func_803893A4, actor_update_func_80326224, func_80389350, + 0x1, D_8038BE30, + chPortrait_update, actor_update_func_80326224, chPortrait_draw, 0, 0, 0.0f, 0 }; ActorInfo D_8038BE6C = { MARKER_257_PORTRAIT_OF_BLACKEYE, ACTOR_384_PORTRAIT_OF_BLACKEYE, ASSET_527_MODEL_PORTRAIT_OF_BLACKEYE, - 0x1, D_8038BE30, - func_803893A4, actor_update_func_80326224, func_80389350, + 0x1, D_8038BE30, + chPortrait_update, actor_update_func_80326224, chPortrait_draw, 0, 0, 0.0f, 0 }; ActorInfo D_8038BE90 = { MARKER_258_PORTRAIT_OF_TOWER, ACTOR_385_PORTRAIT_OF_TOWER, ASSET_528_MODEL_PORTRAIT_OF_TOWER, - 0x1, D_8038BE30, - func_803893A4, actor_update_func_80326224, func_80389350, + 0x1, D_8038BE30, + chPortrait_update, actor_update_func_80326224, chPortrait_draw, 0, 0, 0.0f, 0 }; ActorInfo D_8038BEB4 = { MARKER_259_PORTRAIT_OF_TREE_AND_MOON, ACTOR_386_PORTRAIT_OF_TREE_AND_MOON, ASSET_529_MODEL_PORTRAIT_OF_TREE_AND_MOON, - 0x1, D_8038BE30, - func_803893A4, actor_update_func_80326224, func_80389350, + 0x1, D_8038BE30, + chPortrait_update, actor_update_func_80326224, chPortrait_draw, 0, 0, 0.0f, 0 }; ActorInfo D_8038BED8 = { MARKER_25A_PORTRAIT_OF_TEEHEE, ACTOR_387_PORTRAIT_OF_TEEHEE, ASSET_52A_MODEL_PORTRAIT_OF_TEEHEE, - 0x1, D_8038BE30, - func_803893A4, actor_update_func_80326224, func_80389350, + 0x1, D_8038BE30, + chPortrait_update, actor_update_func_80326224, chPortrait_draw, 0, 0, 0.0f, 0 }; ActorInfo D_8038BEFC = { MARKER_25B_PORTRAIT_OF_MINION, ACTOR_388_PORTRAIT_OF_MINION, ASSET_52B_MODEL_PORTRAIT_OF_MINION, - 0x1, D_8038BE30, - func_803893A4, actor_update_func_80326224, func_80389350, + 0x1, D_8038BE30, + chPortrait_update, actor_update_func_80326224, chPortrait_draw, 0, 0, 0.0f, 0 }; - /* .code */ -Actor *func_80389350(ActorMarker* marker, Gfx** graphics, Mtx** matrix, Vtx** vertex) { +Actor *chPortrait_draw(ActorMarker *marker, Gfx **graphics, Mtx **matrix, Vtx **vertex) { func_8033A45C(3, marker_getActor(marker)->unk38_31); return actor_draw(marker, graphics, matrix, vertex); } -void func_803893A4(Actor *this){ - if(!this->volatile_initialized){ +void chPortrait_update(Actor *this) { + if (!this->volatile_initialized) { this->volatile_initialized = TRUE; + this->marker->propPtr->unk8_3 = TRUE; actor_collisionOff(this); this->unk38_31 = 2; } - switch(this->state){ - case 1: + switch (this->state) { + case PORTRAIT_STATE_1_IDLE: animctrl_setAnimTimer(this->animctrl, 0.0f); break; - case 2: - if(actor_animationIsAt(this, 0.999f)){ - subaddie_set_state_with_direction(this, 1, 0.001f, 0); + + case PORTRAIT_STATE_2_BROKEN: + if (actor_animationIsAt(this, 0.999f)) { + subaddie_set_state_with_direction(this, PORTRAIT_STATE_1_IDLE, 0.001f, 0); actor_playAnimationOnce(this); this->unk38_31 = 2; } @@ -83,10 +90,10 @@ void func_803893A4(Actor *this){ } } -void func_80389484(ActorMarker * marker, f32 anim_duration){ +void chPortrait_break(ActorMarker *marker, f32 anim_duration) { Actor *this = marker_getActor(marker); - subaddie_set_state_with_direction(this, 2, 0.001f, 1); + subaddie_set_state_with_direction(this, PORTRAIT_STATE_2_BROKEN, 0.001f, 1); actor_playAnimationOnce(this); animctrl_setDuration(this->animctrl, anim_duration); this->unk38_31 = 1; diff --git a/src/MMM/code_3420.c b/src/MMM/code_3420.c index 9abbb008..2a15e7f9 100644 --- a/src/MMM/code_3420.c +++ b/src/MMM/code_3420.c @@ -2,6 +2,7 @@ #include "functions.h" #include "variables.h" +/* extern functions */ extern void MMM_func_8038B6D4(f32* arg0, s32 arg1); /* internal definitions */ @@ -15,6 +16,7 @@ typedef struct { u8 unk1; } Struct_MMM_3420_1; +/* public functions */ void organMinigame_setState(s32 arg0); /* .data */ @@ -175,7 +177,7 @@ void func_803898EC() { } void func_80389910() { - gcdialog_showText(0xAD5, 0xE, NULL, NULL, MMM_func_80389810, NULL); + gcdialog_showText(ASSET_AD5_TEXT_UNKNOWN, 0xE, NULL, NULL, MMM_func_80389810, NULL); timedFunc_set_2(0.0f, func_8025A6EC, COMUSIC_2D_PUZZLE_SOLVED_FANFARE, 0x7FFF); timed_setStaticCameraToNode(2.0f, 0); timedFunc_set_0(2.1f, MMM_func_803898A0); @@ -192,13 +194,14 @@ void func_803899BC(void){ void organMinigame_setState(s32 next_state){ func_8028F8F8(1, FALSE); - if(next_state == 2){ - if(D_8038C4F0.pattern == 0){ + + if (next_state == 2) { + if (D_8038C4F0.pattern == 0) { D_8038C4F0.pattern = 1; - gcdialog_showText(0xad3, 4, NULL, NULL, MMM_func_80389810, NULL); + gcdialog_showText(ASSET_AD3_TEXT_UNKNOWN, 4, NULL, NULL, MMM_func_80389810, NULL); } - else{//L80389A84 - gcdialog_showText(0xad6, 4, NULL, NULL, MMM_func_80389810, NULL); + else {//L80389A84 + gcdialog_showText(ASSET_AD6_TEXT_UNKNOWN, 4, NULL, NULL, MMM_func_80389810, NULL); } }//L80389A9C @@ -215,13 +218,13 @@ void organMinigame_setState(s32 next_state){ }//L80389AF4 if(next_state == 4){ - gcdialog_showText(0xadd, 4, NULL, NULL, MMM_func_80389810, NULL); + gcdialog_showText(ASSET_ADD_TEXT_UNKNOWN, 4, NULL, NULL, MMM_func_80389810, NULL); func_80387720(D_8038C4F0.motzhand_marker); } if(next_state == 5){ D_8038C4F0.pattern++; - gcdialog_showText(0xad4, 4, NULL, NULL, MMM_func_80389810, NULL); + gcdialog_showText(ASSET_AD4_TEXT_UNKNOWN, 4, NULL, NULL, MMM_func_80389810, NULL); func_80387720(D_8038C4F0.motzhand_marker); } @@ -246,17 +249,22 @@ void organMinigame_getKeyPosition(s32 key_indx, f32 position[3]) { position[0] = -145.0f; position[1] = 0.0f; position[2] = 0.0f; + for (iPtr = &D_8038C198[0]; iPtr <= &D_8038C198[key_indx]; iPtr++) { is_black_key = (iPtr->unk0 == 2 || iPtr->unk0 == 4); + if (is_black_key != 0) { position[0] += 67.0f; position[1] += 12.5; position[2] += -230.0f; - } else { + } + else { position[0] += 170.0f; } - if (iPtr == &D_8038C198[key_indx]) + + if (iPtr == &D_8038C198[key_indx]) { break; + } if (is_black_key != 0) { position[0] -= 67.0f; @@ -309,30 +317,39 @@ void code3420_handleOrganGame(s32 arg0, s32 arg1) { D_8038C4F0.unk8 = &D_8038BF20; func_80250170(0, 0x6A, 0); D_8038C4F0.state = 0; + if ((map_get() == MAP_1C_MMM_CHURCH) && (arg1 == 2)) { D_8038C4F0.motzhand_marker = NULL; D_8038C4F0.pattern = 0; + key_position[0] = -1345.0f; key_position[1] = 1150.0f; key_position[2] = -2300.0f; - for(iPtr = &D_8038C198[0]; iPtr->unk0; iPtr++){ - is_black_key = (iPtr->unk0 == 2 || iPtr->unk0 == 4); - if (is_black_key) { - key_position[0] += 122.0f; - key_position[1] += 12.5; - } else { - key_position[0] += 170.0f; - } - iPtr->unk1 = func_80351838(key_position, iPtr->unk0, iPtr - &D_8038C198[0]); - if (is_black_key) { - key_position[0] -= 122.0f; - key_position[1] -= 12.5; - } + + for (iPtr = &D_8038C198[0]; iPtr->unk0; iPtr++) { + is_black_key = iPtr->unk0 == 2 || iPtr->unk0 == 4; + + if (is_black_key) { + key_position[0] += 122.0f; + key_position[1] += 12.5; + } + else { + key_position[0] += 170.0f; + } + + iPtr->unk1 = func_80351838(key_position, iPtr->unk0, iPtr - &D_8038C198[0]); + + if (is_black_key) { + key_position[0] -= 122.0f; + key_position[1] -= 12.5; + } } + if (jiggyscore_isSpawned(JIGGY_60_MMM_MOTZHAND)) { organMinigame_setState(7); return; } + organMinigame_setState(1); } } @@ -346,8 +363,9 @@ void organMinigame_update(void){ f32 plyr_pos[3]; Actor *motzhand_2; - - if(D_8038C4F0.state == 0) return; + if (D_8038C4F0.state == 0) { + return; + } if(func_802501A0(0, 0x6A, &sp4C)){ func_80250170(0, 0x6A, 0); diff --git a/src/MMM/code_3D50.c b/src/MMM/code_3D50.c index a3978e6c..a44d294e 100644 --- a/src/MMM/code_3D50.c +++ b/src/MMM/code_3D50.c @@ -72,21 +72,21 @@ void func_8038A140(UNK_TYPE(s32) arg0) { if (arg0 == 2) { func_80324E38(0.3f, 3); timed_setStaticCameraToNode(0.3f, 1); - timedFunc_set_2(0.3f, mapSpecificFlags_set, 3, 1); + timedFunc_set_2(0.3f, mapSpecificFlags_set, MMM_SPECIFIC_FLAG_3_UNKNOWN, TRUE); func_80324E38(3.0f, 0); timed_exitStaticCamera(3.0f); timedFunc_set_1(3.0f, func_8038A140, 3); } if (arg0 == 3) { if (MMM_D_8038C510.unk8 == 1) { - mapSpecificFlags_set(3, 1); + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_3_UNKNOWN, 1); } item_set(ITEM_0_HOURGLASS_TIMER, 75*60 - 1); item_set(6, 1); } if (MMM_D_8038C510.unk8 == 3) { item_set(6, 0); - mapSpecificFlags_set(4, 1); + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_4_UNKNOWN, 1); } if (arg0 == 4) { func_8028F66C(BS_INTR_F); @@ -181,7 +181,7 @@ void func_8038A82C(Struct_MMM_3D50_0 * arg0){ if(arg0->unk2 == 'X'){ MMM_func_8038A54C(arg0, 1); player_getPosition(sp44); - func_8038AD10(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10, sp38); + chTumblar_copyPosition(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10, sp38); sp38[1] = sp44[1]; func_8028F620(sp38, 300.0f, -1500.0f); return; @@ -192,7 +192,7 @@ void func_8038A82C(Struct_MMM_3D50_0 * arg0){ MMM_func_8038A54C(arg0, 3); if( iPtr->unk0[iPtr->unk4] == 0){ func_8038A140(5); - func_8038AF3C(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10); + chTumblar_congratulate(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10); func_8025A6EC(COMUSIC_2D_PUZZLE_SOLVED_FANFARE, 32000); } else{ @@ -249,7 +249,7 @@ void func_8038AA44(void){ func_8038A750(); if( MMM_D_8038C510.unk8 == 1 && MMM_D_8038C510.unkC != NULL - && func_8038AD4C(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10) + && chTumblar_isBanjoAbove(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10) ){ if (!levelSpecificFlags_get(LEVEL_FLAG_2F_MMM_UNKNOWN)) { levelSpecificFlags_set(LEVEL_FLAG_2F_MMM_UNKNOWN, TRUE); @@ -265,9 +265,9 @@ void func_8038AA44(void){ func_8038A140(4); } else if( MMM_D_8038C510.unkC != NULL - && func_8038AD4C(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10) + && chTumblar_isBanjoAbove(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10) ){ - func_8038AD10(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10, sp28); + chTumblar_copyPosition(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10, sp28); tmp_v0 = func_8033F3C0(MMM_D_8038C510.unk0, sp28); if(tmp_v0){ sp24 = func_8038A26C(tmp_v0); @@ -286,7 +286,7 @@ void func_8038AA44(void){ }//L8038AB7C if( MMM_D_8038C510.unk8 == 5 - && func_8038AD38(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10) + && chTumblar_isDisappeared(MMM_D_8038C510.unkC, MMM_D_8038C510.unk10) ){ func_8038A140(6); } diff --git a/src/MMM/code_47D0.c b/src/MMM/code_47D0.c index 19a66baf..b2d971d2 100644 --- a/src/MMM/code_47D0.c +++ b/src/MMM/code_47D0.c @@ -3,16 +3,25 @@ #include "variables.h" #include +/* extern functions */ extern void sfxsource_setSampleRate(u8, s32); -extern f32 func_80258640(f32[3], f32[3]); +extern f32 ml_vec3f_horizontal_distance_zero_likely(f32[3], f32[3]); + +/* data */ +enum chTumblar_state_e { + TUMBLAR_STATE_0_IDLE, + TUMBLAR_STATE_1_CONGRATULATING, + TUMBLAR_STATE_2_BREAKING, + TUMBLAR_STATE_3_DISAPPEARED +}; typedef struct { - ActorMarker *unk0; - u8 unk4; - u8 pad5[3]; - f32 unk8; - f32 unkC[3]; -}Struct_MMM_47D0_0; + ActorMarker *jiggy_marker; + u8 state; + u8 unused[3]; + f32 timer; + f32 velocity[3]; +} Struct_MMM_47D0_0; /* .code */ void MMM_func_8038ABC0(s32 arg0) { @@ -21,172 +30,198 @@ void MMM_func_8038ABC0(s32 arg0) { } } -void func_8038AC04(void){ - if((*(u32*)PHYS_TO_K1(0x1D0)) - 0x356BAAAE){ +void func_8038AC04(void) { + if ((*(u32 *) PHYS_TO_K1(0x1D0)) - 0x356BAAAE) { MMM_func_8038ABC0(0x820); } } -//BREAK???========== -void func_8038AC40(Struct_MMM_47D0_0 *arg0, struct struct_68_s *arg1, f32 position[3], f32 rotation[3], f32 scale, BKModelBin *model_bin, Gfx **gfx, Mtx **mtx, Vtx **vtx){ - u8 temp_v0; - - if (arg0->unk4 != 3) { - if ((arg0->unk4 == 0) || (arg0->unk4 == 1)) { +void chTumblar_draw(Struct_MMM_47D0_0 *arg0, struct struct_68_s *arg1, f32 position[3], f32 rotation[3], f32 scale, BKModelBin *model_bin, Gfx **gfx, Mtx **mtx, Vtx **vtx) { + if (arg0->state != TUMBLAR_STATE_3_DISAPPEARED) { + if (arg0->state == TUMBLAR_STATE_0_IDLE || arg0->state == TUMBLAR_STATE_1_CONGRATULATING) { modelRender_setAlpha(0xFF); - } else if (arg0->unk4 == 2) { - modelRender_setAlpha((s32)((1 - ((f64)arg0->unk8 * 1)) * 255.0)); } + else if (arg0->state == TUMBLAR_STATE_2_BREAKING) { + modelRender_setAlpha((s32)((1 - ((f64) arg0->timer * 1)) * 255.0)); + } + modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); modelRender_draw(gfx, mtx, position, rotation, scale, NULL, model_bin); } } -void func_8038AD10(s32 arg0, s32 arg1, f32 arg2[3]) { - func_8035179C(arg1, arg2); +void chTumblar_copyPosition(s32 arg0, s32 arg1, f32 arg2[3]) { + func_8035179C_copyPosition(arg1, arg2); } -bool func_8038AD38(Struct_MMM_47D0_0 *arg0, s32 arg1){ - return arg0->unk4 == 3; +bool chTumblar_isDisappeared(Struct_MMM_47D0_0 *arg0, s32 arg1) { + return arg0->state == TUMBLAR_STATE_3_DISAPPEARED; } -bool func_8038AD4C(s32 arg0, s32 arg1) { +bool chTumblar_isBanjoAbove(s32 arg0, s32 arg1) { f32 plyr_pos[3]; - f32 sp18[3]; + f32 position[3]; player_getPosition(plyr_pos); - func_8035179C(arg1, sp18); - return func_803518D4(arg1) - && (func_80258640(sp18, plyr_pos) < 40.0f) - && (player_getTransformation() == TRANSFORM_1_BANJO) - && (func_8028ECAC() == 0); + func_8035179C_copyPosition(arg1, position); + + return func_803518D4(arg1) && + ml_vec3f_horizontal_distance_zero_likely(position, plyr_pos) < 40.0f && + player_getTransformation() == TRANSFORM_1_BANJO && + func_8028ECAC() == 0; } -void MMM_func_8038ADF0(Struct_MMM_47D0_0 *arg0, Struct68s *arg1) { - u8 sp3F; - f32 sp38; +void chTumblar_init(Struct_MMM_47D0_0 *arg0, Struct68s *arg1) { + u8 sfxsource_index; + f32 distance_to_jiggy; Actor *jiggy; - f32 sp28[3]; + f32 position[3]; + + arg0->state = TUMBLAR_STATE_0_IDLE; + arg0->timer = 0.0f; + + arg0->velocity[0] = 0.0f; + arg0->velocity[1] = 0.0f; + arg0->velocity[2] = 0.0f; - arg0->unk4 = 0; - arg0->unk8 = 0.0f; - arg0->unkC[0] = 0.0f; - arg0->unkC[1] = 0.0f; - arg0->unkC[2] = 0.0f; func_8038AA30(arg0, arg1); - func_80351A14(arg1, (Struct68DrawMethod)func_8038AC40); - sp3F = func_80351758(arg1); - sfxsource_setSfxId(sp3F, SFX_3EC_CCW_DOOR_OPENING); - func_8030DD14(sp3F, 3); - sfxsource_playSfxAtVolume(sp3F, 0.6f); - sfxsource_setSampleRate(sp3F, 0); - func_8030E2C4(sp3F); - func_8035179C(arg1, sp28); - sp38 = 500.0f; - jiggy = actorArray_findClosestActorFromActorId(sp28, ACTOR_46_JIGGY, -1, &sp38); + func_80351A14(arg1, (Struct68DrawMethod) chTumblar_draw); + + sfxsource_index = func_80351758_getSfxsourceIndex(arg1); + sfxsource_setSfxId(sfxsource_index, SFX_3EC_CCW_DOOR_OPENING); + func_8030DD14(sfxsource_index, 3); + sfxsource_playSfxAtVolume(sfxsource_index, 0.6f); + sfxsource_setSampleRate(sfxsource_index, 0); + func_8030E2C4(sfxsource_index); + + func_8035179C_copyPosition(arg1, position); + distance_to_jiggy = 500.0f; + jiggy = actorArray_findClosestActorFromActorId(position, ACTOR_46_JIGGY, -1, &distance_to_jiggy); + if (jiggy != NULL) { - arg0->unk0 = jiggy->marker; - } else { - arg0->unk0 = NULL; + arg0->jiggy_marker = jiggy->marker; + } + else { + arg0->jiggy_marker = NULL; } - if (arg0->unk0 != NULL) { - arg0->unk0->collidable = FALSE; + if (arg0->jiggy_marker != NULL) { + arg0->jiggy_marker->collidable = FALSE; } + if (jiggyscore_isCollected(JIGGY_62_MMM_TUMBLAR)) { func_80351A04(arg1, 1); - arg0->unk4 = 3; + arg0->state = TUMBLAR_STATE_3_DISAPPEARED; } } -void func_8038AF0C(ActorMarker *marker, enum asset_e text_id, s32 arg2) { - mapSpecificFlags_set(1, 1); +void __chTumblar_congratulationTextCallback(ActorMarker *marker, enum asset_e text_id, s32 arg2) { + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_TUMBLAR_BROKEN, TRUE); } -void func_8038AF3C(Struct_MMM_47D0_0 *arg0, s32 arg1) { - gcdialog_showText(0xADB, 4, NULL, arg0->unk0, func_8038AF0C, NULL); - arg0->unk4 = 1; +void chTumblar_congratulate(Struct_MMM_47D0_0 *arg0, s32 arg1) { + gcdialog_showText(ASSET_ADB_TEXT_UNKNOWN, 4, NULL, arg0->jiggy_marker, __chTumblar_congratulationTextCallback, NULL); + arg0->state = TUMBLAR_STATE_1_CONGRATULATING; } -void func_8038AF90(Struct_MMM_47D0_0 *arg0, Struct68s *arg1, f32 arg2) { - f32 sp7C[3]; - f32 sp70[3]; - f32 sp64[3]; - Actor *temp_v0_2; - f32 sp54[3]; - f32 sp48[3]; - f32 sp40[2]; - s32 sp3C; - u8 sp38; +void chTumblar_update(Struct_MMM_47D0_0 *arg0, Struct68s *arg1, f32 tick) { + f32 viewport_position[3]; + f32 viewport_rotation[3]; + f32 direction[3]; + Actor *jiggy; + f32 position[3]; + f32 plyr_pos[3]; + f32 joystick[2]; + s32 is_banjo_above; + u8 sfxsource_index; + arg0->timer += tick; - arg0->unk8 += arg2; - if (arg0->unk4 == 0) { - func_8035179C(arg1, sp54); - func_8024E71C(0, sp40); - sp3C = func_8038AD4C(arg0, arg1); - if (sp3C) { + if (arg0->state == TUMBLAR_STATE_0_IDLE) { + func_8035179C_copyPosition(arg1, position); + controller_getJoystick(0, joystick); + is_banjo_above = chTumblar_isBanjoAbove(arg0, arg1); + + if (is_banjo_above) { func_8028F66C(BS_INTR_D_SURF); } - if (sp3C && ((sp40[0] != 0.0f) || (sp40[1] != 0.0f))) { - viewport_getRotation_vec3f(sp70); - sp64[0] = sp40[0]; - sp64[1] = 0.0f; - sp64[2] = -sp40[1]; - ml_vec3f_yaw_rotate_copy(sp64, sp64, sp70[1]); - arg0->unkC[0] += sp64[0] * 2500.0f * arg2; - arg0->unkC[2] += sp64[2] * 2500.0f * arg2; - } else { - arg0->unkC[0] *= 0.7; - arg0->unkC[2] *= 0.7; + + if (is_banjo_above && (joystick[0] != 0.0f || joystick[1] != 0.0f)) { + viewport_getRotation_vec3f(viewport_rotation); + + direction[0] = joystick[0]; + direction[1] = 0.0f; + direction[2] = -joystick[1]; + + ml_vec3f_yaw_rotate_copy(direction, direction, viewport_rotation[1]); + arg0->velocity[0] += direction[0] * 2500.0f * tick; + arg0->velocity[2] += direction[2] * 2500.0f * tick; } - if (LENGTH_VEC3F(arg0->unkC) > 400.0f) { - ml_vec3f_set_length(arg0->unkC, 400.0f); + else { + arg0->velocity[0] *= 0.7; + arg0->velocity[2] *= 0.7; } - sp54[0] += arg0->unkC[0] * arg2; - sp54[2] += arg0->unkC[2] * arg2; - func_80351B28(arg1, sp54); - func_8035179C(arg1, sp54); - if (arg0->unk0 != NULL) { - viewport_getPosition_vec3f(sp7C); - sp64[0] = sp54[0] - sp7C[0]; - sp64[2] = sp54[2] - sp7C[2]; - sp64[1] = 0.0f; - ml_vec3f_normalize(sp64); - temp_v0_2 = marker_getActor(arg0->unk0); - temp_v0_2->position[0] = sp54[0] + (sp64[0] * 20.0f); - temp_v0_2->position[2] = sp54[2] + (sp64[2] * 20.0f); + + if (LENGTH_VEC3F(arg0->velocity) > 400.0f) { + ml_vec3f_set_length(arg0->velocity, 400.0f); } - } else if (arg0->unk4 == 2) { - if (arg0->unk8 >= 1.0f) { - arg0->unk4 = 3U; - if (arg0->unk0 != NULL) { - arg0->unk0->collidable = TRUE; + + position[0] += arg0->velocity[0] * tick; + position[2] += arg0->velocity[2] * tick; + + func_80351B28(arg1, position); + func_8035179C_copyPosition(arg1, position); + + if (arg0->jiggy_marker != NULL) { + viewport_getPosition_vec3f(viewport_position); + + direction[0] = position[0] - viewport_position[0]; + direction[2] = position[2] - viewport_position[2]; + direction[1] = 0.0f; + ml_vec3f_normalize(direction); + + jiggy = marker_getActor(arg0->jiggy_marker); + jiggy->position[0] = position[0] + (direction[0] * 20.0f); + jiggy->position[2] = position[2] + (direction[2] * 20.0f); + } + } + else if (arg0->state == TUMBLAR_STATE_2_BREAKING) { + if (arg0->timer >= 1.0f) { + arg0->state = TUMBLAR_STATE_3_DISAPPEARED; + + if (arg0->jiggy_marker != NULL) { + arg0->jiggy_marker->collidable = TRUE; } + func_80351A04(arg1, 1); } - arg0->unkC[0] *= 0.7; - arg0->unkC[2] *= 0.7; + + arg0->velocity[0] *= 0.7; + arg0->velocity[2] *= 0.7; } - if (arg0->unk4 == 1) { - sp38 = func_80351758(arg1); - sfxsource_setSampleRate(sp38, 0); - } else { - sp38 = func_80351758(arg1); - sfxsource_setSampleRate(sp38, (s32) ((LENGTH_VEC3F(arg0->unkC) / 400.0) * 15000.0)); + + if (arg0->state == TUMBLAR_STATE_1_CONGRATULATING) { + sfxsource_index = func_80351758_getSfxsourceIndex(arg1); + sfxsource_setSampleRate(sfxsource_index, 0); } - player_getPosition(sp48); - func_8035179C(arg1, sp54); - if (!mapSpecificFlags_get(0) && (arg0->unk4 == 0) && (func_80258640(sp54, sp48) < 250.0f)){ - if(gcdialog_showText(0xADA, 0, NULL, NULL, NULL, NULL)) { + else { + sfxsource_index = func_80351758_getSfxsourceIndex(arg1); + sfxsource_setSampleRate(sfxsource_index, (s32)((LENGTH_VEC3F(arg0->velocity) / 400.0) * 15000.0)); + } + + player_getPosition(plyr_pos); + func_8035179C_copyPosition(arg1, position); + + if (!mapSpecificFlags_get(MMM_SPECIFIC_FLAG_0_UNKNOWN) && arg0->state == TUMBLAR_STATE_0_IDLE && ml_vec3f_horizontal_distance_zero_likely(position, plyr_pos) < 250.0f) { + if (gcdialog_showText(ASSET_ADA_TEXT_UNKNOWN, 0, NULL, NULL, NULL, NULL)) { mapSpecificFlags_set(0, TRUE); } } - if ((arg0->unk4 == 1) && mapSpecificFlags_get(1)) { - arg0->unk4 = 2U; - arg0->unk8 = 0.0f; - mapSpecificFlags_set(1, 0); - FUNC_8030E8B4(SFX_11B_TUMBLAR_DISAPPEARING_1, 1.0f, 30000, sp54, 500, 2500); + if (arg0->state == TUMBLAR_STATE_1_CONGRATULATING && mapSpecificFlags_get(MMM_SPECIFIC_FLAG_TUMBLAR_BROKEN)) { + arg0->state = TUMBLAR_STATE_2_BREAKING; + arg0->timer = 0.0f; + mapSpecificFlags_set(MMM_SPECIFIC_FLAG_TUMBLAR_BROKEN, FALSE); + FUNC_8030E8B4(SFX_11B_TUMBLAR_DISAPPEARING_1, 1.0f, 30000, position, 500, 2500); } } diff --git a/src/MMM/code_5000.c b/src/MMM/code_5000.c index 6a789f89..7a055263 100644 --- a/src/MMM/code_5000.c +++ b/src/MMM/code_5000.c @@ -74,7 +74,7 @@ void func_8038B630(Struct5Fs *arg0, Struct68s *arg1){ f32 sp20; sp20 = alCents2Ratio(func_80389BBC()*100); - phi_s0 = func_80351758(arg1); + phi_s0 = func_80351758_getSfxsourceIndex(arg1); func_8030E394(phi_s0); sfxsource_playSfxAtVolume(phi_s0, sp20); sfxsource_setSfxId(phi_s0, 0x3f3); @@ -118,7 +118,7 @@ void func_8038B790(Struct5Fs *arg0, Struct68s *arg1, f32 arg2) { if (arg0->unk14 <= 0.0f) { func_80351954(arg1); } else if (arg0->unk14 <= 1.0f) { - sfxsource_setSampleRate(func_80351758(arg1), (s32)(arg0->unk14 * 32767.0f)); + sfxsource_setSampleRate(func_80351758_getSfxsourceIndex(arg1), (s32)(arg0->unk14 * 32767.0f)); } } diff --git a/src/MMM/code_DC0.c b/src/MMM/code_DC0.c index f930839e..3be7ee55 100644 --- a/src/MMM/code_DC0.c +++ b/src/MMM/code_DC0.c @@ -2,93 +2,104 @@ #include "functions.h" #include "variables.h" -void func_80387280(Actor *this); +/* public functions */ +void chFlowerpot_update(Actor *this); /* .data */ +enum chFlowerpot_state_e { + FLOWER_POT_STATE_1_IDLE = 1, + FLOWER_POT_STATE_2_FLOWERED +}; + ActorAnimationInfo D_8038BA50[] = { - {0x00, 0.0f}, + {0x00, 0.0f}, {ASSET_A9_ANIM_FLOWER_POT, 2.0f}, {ASSET_A9_ANIM_FLOWER_POT, 2.0f} }; ActorInfo D_8038BA68 = { - MARKER_34_CEMETARY_POT, ACTOR_25_CEMETARY_POT, ASSET_3AE_MODEL_GRAVE_FLOWER_POT, - 0x1, D_8038BA50, - func_80387280, actor_update_func_80326224, actor_draw, + MARKER_34_CEMETARY_POT, ACTOR_25_CEMETARY_POT, ASSET_3AE_MODEL_GRAVE_FLOWER_POT, + 0x1, D_8038BA50, + chFlowerpot_update, actor_update_func_80326224, actor_draw, 0, 0, 0.0f, 0 }; /* .code */ -//chflowerpots_getRemaining -s32 func_803871B0(void) { +s32 chFlowerpot_getRemaining(void) { return levelSpecificFlags_getN(0x39, 3); } -//chflowerpots_setRemaining -void func_803871D4(s32 arg0) { +void chFlowerpot_setRemaining(s32 arg0) { levelSpecificFlags_setN(0x39, arg0, 3); } -void MMM_func_803871FC(Actor *this){ - switch(this->state){ - case 1: +void MMM_func_803871FC(Actor *this) { + switch (this->state) { + case FLOWER_POT_STATE_1_IDLE: func_8033A45C(3, FALSE); break; - case 2: + + case FLOWER_POT_STATE_2_FLOWERED: func_8033A45C(3, TRUE); break; } + func_803255FC(this); } -void mmm_resetFlowerPots() { - func_803871D4(5); +void chFlowerpot_reset() { + chFlowerpot_setRemaining(5); } -//chflowerpots_update -void func_80387280(Actor *this){ +void chFlowerpot_update(Actor *this) { this->marker->propPtr->unk8_3 = TRUE; - if(!this->initialized){ + + if (!this->initialized) { this->initialized = TRUE; this->unk130 = MMM_func_803871FC; } - switch(this->state){ - case 1: + switch (this->state) { + case FLOWER_POT_STATE_1_IDLE: animctrl_setPlaybackType(this->animctrl, ANIMCTRL_STOPPED); break; - case 2: - if(actor_animationIsAt(this, 0.2f)){ - FUNC_8030E8B4(SFX_12F_FUUUCK_YOUUU, 1.0f, 30000, this->position, 300, 2000); + case FLOWER_POT_STATE_2_FLOWERED: + if (actor_animationIsAt(this, 0.2f)) { + FUNC_8030E8B4(SFX_12F_THAAANK_YOOOUUU, 1.0f, 30000, this->position, 300, 2000); } break; } } -bool MMM_func_80387340(ActorMarker *marker){ +bool chFlowerpot_eggCollision(ActorMarker *marker) { Actor *actor = marker_getActor(marker); - f32 sp20[3]; - s32 sp1C; - - if(actor->state == 2) - return FALSE; + f32 position[3]; + s32 remaining; - subaddie_set_state(actor, 2); + if (actor->state == FLOWER_POT_STATE_2_FLOWERED) { + return FALSE; + } + + subaddie_set_state(actor, FLOWER_POT_STATE_2_FLOWERED); animctrl_setPlaybackType(actor->animctrl, ANIMCTRL_ONCE); - sp1C = func_803871B0(); - if(sp1C != 0){ - sp1C--; - if(sp1C == 0){ - ml_vec3f_copy(sp20, actor->position); - sp20[1] += 80.0f; + remaining = chFlowerpot_getRemaining(); + + if (remaining != 0) { + remaining--; + + if (remaining == 0) { + ml_vec3f_copy(position, actor->position); + position[1] += 80.0f; + comusic_playTrack(COMUSIC_2D_PUZZLE_SOLVED_FANFARE); - jiggy_spawn(JIGGY_63_MMM_FLOWER_POTS, sp20); + jiggy_spawn(JIGGY_63_MMM_FLOWER_POTS, position); } - else{ + else { comusic_playTrack(COMUSIC_2B_DING_B); } } - func_803871D4(sp1C); + + chFlowerpot_setRemaining(remaining); return TRUE; } diff --git a/src/RBB/code_CA0.c b/src/RBB/code_CA0.c index f985dc58..682cb44a 100644 --- a/src/RBB/code_CA0.c +++ b/src/RBB/code_CA0.c @@ -201,7 +201,7 @@ void func_803878B0(Actor *this){ if(!this->volatile_initialized){ this->volatile_initialized = TRUE; this->marker->actorFreeFunc = func_80387890; - marker_setCollisionScripts(this->marker, 0, func_80387850, 0); + marker_setCollisionScripts(this->marker, NULL, func_80387850, NULL); func_8032AA58(this, 1.1f); func_8038756C(this, 1); } diff --git a/src/SM/code_5B0.c b/src/SM/code_5B0.c index ee05c9b6..8267d405 100644 --- a/src/SM/code_5B0.c +++ b/src/SM/code_5B0.c @@ -132,7 +132,7 @@ void SM_func_80386EF4(Actor *this) { Actor *other; if ((this->volatile_initialized) <= 0) { this->marker->propPtr->unk8_3 = 1; - marker_setCollisionScripts(this->marker, 0, 0, func_80386EB4); + marker_setCollisionScripts(this->marker, NULL, NULL, func_80386EB4); this->unk38_31 = 0; this->unk138_31 = 1; this->volatile_initialized = TRUE; diff --git a/src/core1/code_10A00.c b/src/core1/code_10A00.c index 8cbed3d2..3f50ec47 100644 --- a/src/core1/code_10A00.c +++ b/src/core1/code_10A00.c @@ -149,7 +149,7 @@ void func_8024E6E0(s32 controller_index, s32 *dst[4]){ dst[3] = D_80281138[controller_index].unk24[3]; } -void func_8024E71C(s32 controller_index, f32 dst[2]){ +void controller_getJoystick(s32 controller_index, f32 dst[2]){ if(func_802E4A08()){ dst[0] = D_80281250[controller_index].joystick[0]; dst[1] = D_80281250[controller_index].joystick[1]; diff --git a/src/core1/code_18350.c b/src/core1/code_18350.c index 06eba603..3f586876 100644 --- a/src/core1/code_18350.c +++ b/src/core1/code_18350.c @@ -345,14 +345,12 @@ void ml_vec3f_roll_rotate_copy(f32 dst[3], f32 src[3], f32 roll) dst[0] = val; } -void ml_vec3f_set_length(f32 arg0[3], f32 arg1) -{ - f32 length = LENGTH_VEC3F(arg0); +void ml_vec3f_set_length(f32 vec[3], f32 length) { + f32 vec_length = LENGTH_VEC3F(vec); - if (length != 0) - { - f32 inv_length = arg1 / length; - TUPLE_SCALE_COPY(arg0, arg0, inv_length) + if (vec_length != 0) { + f32 inv_length = length / vec_length; + TUPLE_SCALE_COPY(vec, vec, inv_length) } } @@ -598,16 +596,12 @@ void ml_defrag(void) //ml_timer_update //decrement a counter and returns True if timer reaches 0 -bool ml_timer_update(f32 *timer, f32 delta) -{ - if (*timer > 0) - { +bool ml_timer_update(f32 *timer, f32 delta) { + if (*timer > 0) { *timer -= delta; - if (*timer <= 0) - { + if (*timer <= 0) { *timer = 0; - return TRUE; } } @@ -946,14 +940,13 @@ int func_802585E0(s32 vec[3], s32 minX, s32 minY, s32 minZ, s32 maxX, s32 maxY, && vec[2] > minZ && vec[2] < maxZ; } -//ml_vec3f_horizontal_distance_zero_likely -f32 func_80258640(f32 vec1[3], f32 vec2[3]) -{ +f32 ml_vec3f_horizontal_distance_zero_likely(f32 vec1[3], f32 vec2[3]) { f32 dX = vec1[0] - vec2[0]; f32 dZ = vec1[2] - vec2[2]; - if (dX != 0 || dZ != 0) + if (dX != 0 || dZ != 0) { return gu_sqrtf(_SQ2(dX, dZ)); + } return 0; } diff --git a/src/core1/code_2FA0.c b/src/core1/code_2FA0.c index 0ed7bc46..17d87b9e 100644 --- a/src/core1/code_2FA0.c +++ b/src/core1/code_2FA0.c @@ -14,7 +14,7 @@ void func_802409C0(f32 arg0[3], f32 arg1){ f32 dt; dt = time_getDelta()*arg1; - func_8024E71C(0, sp28); + controller_getJoystick(0, sp28); sp30[0] = sp28[0] * dt; sp30[1] = 0.0f; @@ -46,7 +46,7 @@ void func_80240AC8(f32 arg0[3], f32 arg1){ f32 dt; dt = time_getDelta()*arg1; - func_8024E71C(0, sp28); + controller_getJoystick(0, sp28); if(0.0f != sp28[0] || 0.0f != sp28[1]){ D_80275860++; diff --git a/src/core1/code_72B0.c b/src/core1/code_72B0.c index 00dc82fa..3c026f4b 100644 --- a/src/core1/code_72B0.c +++ b/src/core1/code_72B0.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -int func_802458E0(f32 arg0[3], Actor *arg1, s32 arg2); +int collisionTri_isHitFromAbove_actor(f32 arg0[3], Actor *arg1, s32 arg2); extern bool func_80320DB0(f32[3], f32, f32[3], u32); extern bool func_80323240(struct56s *, f32, f32[3]); extern f32 ml_dotProduct_vec3f(f32[3], f32[3]); @@ -308,31 +308,32 @@ BKCollisionTri *func_802457C4(f32 arg0[3], f32 arg1[3], f32 arg2, f32 arg3, f32 return var_v1; } -void collisionTri_copy(BKCollisionTri *dst, BKCollisionTri *src){ - dst->unk0[0] = src->unk0[0]; - dst->unk0[1] = src->unk0[1]; - dst->unk0[2] = src->unk0[2]; +void collisionTri_copy(BKCollisionTri *dst, BKCollisionTri *src) { + TUPLE_COPY(dst->unk0, src->unk0) dst->flags = src->flags; dst->unk6 = src->unk6; } -int func_802458A8(f32 arg0[3], ActorMarker *arg1, s32 arg2){ - return func_802458E0(arg0, marker_getActor(arg1), arg2); +int collisionTri_isHitFromAbove_marker(f32 position[3], ActorMarker *marker, s32 verticalOffset) { + return collisionTri_isHitFromAbove_actor(position, marker_getActor(marker), verticalOffset); } -int func_802458E0(f32 arg0[3], Actor *arg1, s32 arg2){ +int collisionTri_isHitFromAbove_actor(f32 position[3], Actor *actor, s32 verticalOffset) { f32 sp34[3]; - f32 sp28[3]; - f32 sp1C[3]; + f32 tmp_position[3]; + f32 adjusted_actor_position[3]; - ml_vec3f_copy(sp28, arg0); - ml_vec3f_copy(sp1C, arg1->position); - sp1C[1] += (f32)arg2; - if(sp1C[1] < sp28[1]) - return FALSE; + ml_vec3f_copy(tmp_position, position); + ml_vec3f_copy(adjusted_actor_position, actor->position); + adjusted_actor_position[1] += (f32) verticalOffset; - if(func_80320B98(sp28, sp1C, sp34, 0x25e0000)){ + if (adjusted_actor_position[1] < tmp_position[1]) { return FALSE; } + + if (func_80320B98(tmp_position, adjusted_actor_position, sp34, 0x25e0000)) { + return FALSE; + } + return TRUE; } diff --git a/src/core2/ba/marker.c b/src/core2/ba/marker.c index 61bca831..05b650ca 100644 --- a/src/core2/ba/marker.c +++ b/src/core2/ba/marker.c @@ -388,7 +388,7 @@ void __baMarker_resolveCollision(Prop *other_prop){ return; player_getPosition(spAC); spAC[1] += 40.0f; - if(func_802458E0(spAC, actor, 0x87) == 0) + if(collisionTri_isHitFromAbove_actor(spAC, actor, 0x87) == 0) return; volatileFlag_set(VOLATILE_FLAG_1E, 1); if(fileProgressFlag_get(((actor->unkF4_8 - 1) ^ 1) + 0x49)){ diff --git a/src/core2/ch/climbBase.c b/src/core2/ch/climbBase.c index 841f9900..434828db 100644 --- a/src/core2/ch/climbBase.c +++ b/src/core2/ch/climbBase.c @@ -5,7 +5,7 @@ void func_802D77D4(Actor *this); extern void player_setClimbParams(f32[3], f32[3], f32, u32); -extern f32 func_80258640(f32[3], f32[3]); +extern f32 ml_vec3f_horizontal_distance_zero_likely(f32[3], f32[3]); typedef struct { f32 unk0[3]; @@ -40,8 +40,8 @@ s32 func_802D76E0(Actor *this, f32 *arg1) { return FALSE; } if (sp28 && temp_v0) { - sp30 = func_80258640(this->position, sp40); - if (func_80258640(this->position, sp34) < sp30) { + sp30 = ml_vec3f_horizontal_distance_zero_likely(this->position, sp40); + if (ml_vec3f_horizontal_distance_zero_likely(this->position, sp34) < sp30) { sp28 = 0; } } diff --git a/src/core2/ch/gameSelect.c b/src/core2/ch/gameSelect.c index 9f10f34d..85558805 100644 --- a/src/core2/ch/gameSelect.c +++ b/src/core2/ch/gameSelect.c @@ -26,7 +26,7 @@ extern void warp_smExitBanjosHouse(s32, s32); extern void func_80335110(s32); extern void func_8024E60C(s32, s32[3]); -extern void func_8024E71C(s32, f32*); +extern void controller_getJoystick(s32, f32*); extern char *gcpausemenu_TimeToA(int); extern struct5Bs *func_803097A0(void); @@ -334,7 +334,7 @@ void func_802C4C14(Actor *this){ else{//L802C4D24 func_8024E60C(0, sp74); func_8024E55C(0, sp5C); - func_8024E71C(0, &sp54); + controller_getJoystick(0, &sp54); switch(this->state){ case 2: case 5: diff --git a/src/core2/code_13FC0.c b/src/core2/code_13FC0.c index dd2d4bc7..df1df256 100644 --- a/src/core2/code_13FC0.c +++ b/src/core2/code_13FC0.c @@ -3,7 +3,7 @@ #include "variables.h" #include -extern void func_8024E71C(s32, f32*); +extern void controller_getJoystick(s32, f32*); extern f32 ml_acosf(f32); extern f32 player_getYaw(void); extern void particleEmitter_setSphericalParticleVelocityRange(ParticleEmitter *this, f32 pitch_min, f32 yaw_min, f32 radial_min, f32 pitch_max, f32 yaw_max, f32 radial_max); @@ -79,7 +79,7 @@ void func_8029B11C(void) { } void func_8029B174(void) { - func_8024E71C(0, &D_8037D1A0.unk1C); + controller_getJoystick(0, &D_8037D1A0.unk1C); if (D_8037D1A0.unk34) { D_8037D1A0.unk1C[0] = D_8037D1A0.unk1C[1] = 0.0f; } diff --git a/src/core2/code_14420.c b/src/core2/code_14420.c index 6e607c4f..dfd1b811 100644 --- a/src/core2/code_14420.c +++ b/src/core2/code_14420.c @@ -7,7 +7,7 @@ #include "core2/ba/physics.h" #include -extern void func_8024E71C(s32, f32*); +extern void controller_getJoystick(s32, f32*); extern f32 ml_acosf(f32); extern f32 player_getYaw(void); extern void particleEmitter_setSphericalParticleVelocityRange(ParticleEmitter *this, f32 pitch_min, f32 yaw_min, f32 radial_min, f32 pitch_max, f32 yaw_max, f32 radial_max); diff --git a/src/core2/code_4C020.c b/src/core2/code_4C020.c index a9f51678..495baf79 100644 --- a/src/core2/code_4C020.c +++ b/src/core2/code_4C020.c @@ -4,7 +4,7 @@ #include "SnS.h" -extern f32 func_80258640(f32 [3], f32[3]); +extern f32 ml_vec3f_horizontal_distance_zero_likely(f32 [3], f32[3]); extern void func_8025A788(enum comusic_e, f32, f32); extern void func_8031CC40(enum map_e, s32); extern void fxRipple_802F363C(f32); @@ -565,13 +565,13 @@ void func_802D4680(Actor *this){ player_getPosition(sp1C); switch(this->state){ case 0: - if(150.0f < func_80258640(this->position, sp1C)){ + if(150.0f < ml_vec3f_horizontal_distance_zero_likely(this->position, sp1C)){ subaddie_set_state(this, 1); D_803676AC = 0; } break; case 1: - if(func_80258640(this->position, sp1C) < 150.0f && func_8028F20C()){ + if(ml_vec3f_horizontal_distance_zero_likely(this->position, sp1C) < 150.0f && func_8028F20C()){ if(func_8028ECAC() == 0 || func_8028ECAC() == BSGROUP_8_TROT){ if(map_get() == MAP_8E_GL_FURNACE_FUN){ volatileFlag_set(VOLATILE_FLAG_0_IN_FURNACE_FUN_QUIZ, 0); diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index 66e164e4..38424f1f 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -626,7 +626,7 @@ s32 getGameMode(void){ int func_802E4A08(void){ return (D_8037E8E0.game_mode == GAME_MODE_6_FILE_PLAYBACK) - || (D_8037E8E0.game_mode == 5) + || (D_8037E8E0.game_mode == GAME_MODE_5_UNKNOWN) || (D_8037E8E0.game_mode == GAME_MODE_7_ATTRACT_DEMO) || (D_8037E8E0.game_mode == GAME_MODE_8_BOTTLES_BONUS) || (D_8037E8E0.game_mode == GAME_MODE_9_BANJO_AND_KAZOOIE) diff --git a/src/core2/code_91E10.c b/src/core2/code_91E10.c index 023da4f4..3f663217 100644 --- a/src/core2/code_91E10.c +++ b/src/core2/code_91E10.c @@ -488,7 +488,7 @@ void func_80319EA4(void) { return; func_8024E55C(0, sp58); - func_8024E71C(0, sp4C); + controller_getJoystick(0, sp4C); for(phi_s0 = 0; phi_s0 < 4; phi_s0++){ gczoombox_update(D_803830E0->unk24[phi_s0]); } diff --git a/src/core2/code_9A740.c b/src/core2/code_9A740.c index 204277af..fde31982 100644 --- a/src/core2/code_9A740.c +++ b/src/core2/code_9A740.c @@ -57,7 +57,7 @@ void func_803216D0(enum map_e map){ chTreasurehunt_resetProgress(); break; case MAP_1B_MMM_MAD_MONSTER_MANSION: - mmm_resetFlowerPots(); + chFlowerpot_reset(); break; } } diff --git a/src/core2/code_9E370.c b/src/core2/code_9E370.c index fe4a3546..a54c0553 100644 --- a/src/core2/code_9E370.c +++ b/src/core2/code_9E370.c @@ -1190,9 +1190,11 @@ static bool __subaddie_set_state(Actor *this, s32 state) void func_803285E8(Actor *this, f32 anim_start_position, int direction){ animctrl_setStart(this->animctrl, anim_start_position); - if(direction != -1){ + + if (direction != -1) { animctrl_setDirection(this->animctrl, direction); } + this->sound_timer = anim_start_position; } @@ -1275,8 +1277,8 @@ int actor_animationIsAt(Actor *this, f32 arg1){ } } -void func_803289EC(Actor *this , f32 arg1, int direction){ - func_803285E8(this, arg1, direction); +void func_803289EC(Actor *this , f32 anim_start_position, int direction){ + func_803285E8(this, anim_start_position, direction); animctrl_start(this->animctrl, "subaddie.c", 0x6b1); } @@ -1316,9 +1318,10 @@ int subaddie_maybe_set_state(Actor *this, s32 myAnimId, f32 chance){ return 0; } -void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 arg2, s32 direction){ - if(__subaddie_set_state(this, myAnimId) && this->animctrl) - func_803289EC(this, arg2, direction); +void subaddie_set_state_with_direction(Actor * this, s32 myAnimId, f32 anim_start_position, s32 direction){ + if (__subaddie_set_state(this, myAnimId) && this->animctrl) { + func_803289EC(this, anim_start_position, direction); + } } bool subaddie_maybe_set_state_position_direction(Actor *this, s32 myAnimId, f32 start_position, s32 direction, f32 probability) { diff --git a/src/core2/code_C31A0.c b/src/core2/code_C31A0.c index 716cf1c2..aebdbfe5 100644 --- a/src/core2/code_C31A0.c +++ b/src/core2/code_C31A0.c @@ -4,55 +4,49 @@ #define CORE2_C31A0_VEC_COUNT 0x21 -void func_8034A130(struct5Bs *this){ - f32 (*iPtr)[3]; - for(iPtr = this->unk0; iPtr < this->unk4; iPtr++){ +void func_8034A130(struct5Bs *this) { + f32(*iPtr)[3]; + + for (iPtr = this->unk0; iPtr < this->unk4; iPtr++) { (*iPtr)[0] = (*iPtr)[1] = (*iPtr)[2] = 0.0f; } } -void func_8034A174(struct5Bs *this, s32 indx,f32 dst[3]){ - dst[0] = this->unk0[indx][0]; - dst[1] = this->unk0[indx][1]; - dst[2] = this->unk0[indx][2]; +void func_8034A174(struct5Bs *this, s32 indx, f32 dst[3]) { + TUPLE_COPY(dst, this->unk0[indx]) } -void func_8034A1B4(struct5Bs *this, s32 indx, s32 dst[3]){ - dst[0] = (s32)this->unk0[indx][0]; - dst[1] = (s32)this->unk0[indx][1]; - dst[2] = (s32)this->unk0[indx][2]; +void func_8034A1B4(struct5Bs *this, s32 indx, s32 dst[3]) { + TUPLE_COPY(dst, this->unk0[indx]) } -void func_8034A214(struct5Bs *this, s32 indx1, s32 indx2, f32 dst[3]){ - dst[0] = this->unk0[indx2][0] - this->unk0[indx1][0]; - dst[1] = this->unk0[indx2][1] - this->unk0[indx1][1]; - dst[2] = this->unk0[indx2][2] - this->unk0[indx1][2]; +void func_8034A214(struct5Bs *this, s32 indx1, s32 indx2, f32 dst[3]) { + TUPLE_DIFF_COPY(dst, this->unk0[indx2], this->unk0[indx1]) ml_vec3f_normalize(dst); } -void func_8034A2A8(struct5Bs *this){ +void func_8034A2A8(struct5Bs *this) { free(this); } -struct5Bs *func_8034A2C8(void){ - struct5Bs *this = (struct5Bs *)malloc(sizeof(struct5Bs) + sizeof(f32[3])*CORE2_C31A0_VEC_COUNT); - this->unk0 = (f32(*)[3])((s32)this + sizeof(struct5Bs)); - this->unk4 = (f32(*)[3])((s32)this->unk0 + sizeof(f32[3])*CORE2_C31A0_VEC_COUNT); +struct5Bs *func_8034A2C8(void) { + struct5Bs *this = (struct5Bs *) malloc(sizeof(struct5Bs) + sizeof(f32[3]) * CORE2_C31A0_VEC_COUNT); + this->unk0 = (f32(*)[3])((s32) this + sizeof(struct5Bs)); + this->unk4 = (f32(*)[3])((s32) this->unk0 + sizeof(f32[3]) * CORE2_C31A0_VEC_COUNT); func_8034A130(this); return this; } -void func_8034A308(struct5Bs *this, s32 indx, f32 arg2[3]){ - this->unk0[indx][0] = arg2[0]; - this->unk0[indx][1] = arg2[1]; - this->unk0[indx][2] = arg2[2]; +void func_8034A308(struct5Bs *this, s32 indx, f32 arg2[3]) { + TUPLE_COPY(this->unk0[indx], arg2) } -struct5Bs *func_8034A348(struct5Bs *this){ - if(this){ - this = (struct5Bs *)defrag(this); - this->unk0 = (f32(*)[3])(((s32)this + sizeof(struct5Bs))); - this->unk4 = (f32(*)[3])((s32)this->unk0 + sizeof(f32[3])*CORE2_C31A0_VEC_COUNT); +struct5Bs *func_8034A348(struct5Bs *this) { + if (this) { + this = (struct5Bs *) defrag(this); + this->unk0 = (f32(*)[3])(((s32) this + sizeof(struct5Bs))); + this->unk4 = (f32(*)[3])((s32) this->unk0 + sizeof(f32[3]) * CORE2_C31A0_VEC_COUNT); } + return this; } diff --git a/src/core2/code_C9F00.c b/src/core2/code_C9F00.c index 823e770e..495f1872 100644 --- a/src/core2/code_C9F00.c +++ b/src/core2/code_C9F00.c @@ -41,7 +41,7 @@ Struct_Core2_C9F00_1 D_803725C0[] = { void func_80351DE0(Struct6Bs *, Struct68s *); -extern void MMM_func_8038ADF0(void *, Struct68s *); +extern void chTumblar_init(void *, Struct68s *); extern void func_80387940(void *, Struct68s *); extern void GV_func_80387960(void *, Struct68s *); extern void func_80387980(void *, Struct68s *); @@ -53,7 +53,7 @@ extern void CC_func_80387A20(void *, Struct68s *); extern void func_80351FE0(void *, Struct68s *); void func_80351E60(Struct6Bs *, Struct68s *, f32); -extern void func_8038AF90(void *, Struct68s *, f32); +extern void chTumblar_update(void *, Struct68s *, f32); extern void func_8038B790(void *, Struct68s *, f32); extern void CCW_func_80387A40(void *, Struct68s *, f32); extern void func_80352114(void *, Struct68s *, f32); @@ -61,7 +61,7 @@ extern void func_80352114(void *, Struct68s *, f32); Struct_Core2_C9F00_0 D_803725F4[] = { { NULL, NULL}, {func_80351DE0, func_80351E60}, - {MMM_func_8038ADF0, func_8038AF90}, + {chTumblar_init, chTumblar_update}, { NULL, NULL}, { NULL, func_8038B790}, {func_80387940, CCW_func_80387A40}, @@ -100,17 +100,20 @@ Actor *func_80350E90(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { temp_s0 = &D_803861B0.unk4[marker->actrArrayIdx]; temp_v0 = temp_s0->unkC; + if (temp_v0 == NULL) { - return 0; - } else { - if (temp_s0->unk8 != NULL) { - temp_s0->unk8(&temp_s0->local, temp_s0, temp_s0->unk14, temp_s0->unk20, temp_s0->unk2C, temp_v0, gfx, mtx, vtx); - } else { - modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); - modelRender_draw(gfx, mtx, temp_s0->unk14, temp_s0->unk20, temp_s0->unk2C, NULL, temp_s0->unkC); - } + return NULL; } - return 0; + + if (temp_s0->unk8 != NULL) { + temp_s0->unk8(&temp_s0->local, temp_s0, temp_s0->position, temp_s0->unk20, temp_s0->unk2C, temp_v0, gfx, mtx, vtx); + } + else { + modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); + modelRender_draw(gfx, mtx, temp_s0->position, temp_s0->unk20, temp_s0->unk2C, NULL, temp_s0->unkC); + } + + return NULL; } s32 func_80350F7C(ActorMarker *marker, s32 arg1, f32 arg2[3], s32 arg3, s32 arg4) { @@ -126,7 +129,7 @@ s32 func_80350F7C(ActorMarker *marker, s32 arg1, f32 arg2[3], s32 arg3, s32 arg4 colision_list = model_getCollisionList(temp_s0->unkC); vtx_list = model_getVtxList(temp_s0->unkC); - sp4C = func_802E805C(colision_list, vtx_list, temp_s0->unk14, temp_s0->unk20, temp_s0->unk2C, arg1, arg2, arg3, arg4); + sp4C = func_802E805C(colision_list, vtx_list, temp_s0->position, temp_s0->unk20, temp_s0->unk2C, arg1, arg2, arg3, arg4); if (sp4C != 0) { if (func_8029453C()) { D_80386180.unk20[0] = (s32) arg2[0]; @@ -150,7 +153,7 @@ s32 func_803510B4(ActorMarker *marker, s32 arg1, f32 arg2[3], f32 arg3, s32 arg4 } collision_list = model_getCollisionList(sp40->unkC); vertex_list = model_getVtxList(sp40->unkC); - return func_802E9118(collision_list, vertex_list, sp40->unk14, sp40->unk20, sp40->unk2C, arg1, arg2, arg3, arg4, arg5, flagFliter); + return func_802E9118(collision_list, vertex_list, sp40->position, sp40->unk20, sp40->unk2C, arg1, arg2, arg3, arg4, arg5, flagFliter); } s32 func_80351198(ActorMarker *marker, s32 arg1, f32 arg2, s32 arg3, s32 arg4) { @@ -165,11 +168,11 @@ s32 func_80351198(ActorMarker *marker, s32 arg1, f32 arg2, s32 arg3, s32 arg4) { } collision_list = model_getCollisionList(sp38->unkC); vtx_list = model_getVtxList(sp38->unkC); - return func_802E9DD8(collision_list, vtx_list, sp38->unk14, sp38->unk20, sp38->unk2C, arg1, arg2, arg3, arg4); + return func_802E9DD8(collision_list, vtx_list, sp38->position, sp38->unk20, sp38->unk2C, arg1, arg2, arg3, arg4); } -Struct68s * func_8035126C(f32 arg0[3], f32 arg1[3], f32 arg2, s32 arg3, enum asset_e arg4) { +Struct68s * func_8035126C(f32 position[3], f32 arg1[3], f32 arg2, s32 arg3, enum asset_e arg4) { s32 sp2C; s32 sp1C; @@ -177,22 +180,20 @@ Struct68s * func_8035126C(f32 arg0[3], f32 arg1[3], f32 arg2, s32 arg3, enum ass if (D_803861B0.unk8 == D_803861B0.unkC) { sp2C = D_803861B0.unk8 - D_803861B0.unk4; sp1C = sp2C * 2; - D_803861B0.unk4 = (Struct68s *)realloc(D_803861B0.unk4, sp1C * sizeof(Struct68s)); + D_803861B0.unk4 = (Struct68s *) realloc(D_803861B0.unk4, sp1C * sizeof(Struct68s)); D_803861B0.unk8 = D_803861B0.unk4 + sp2C; D_803861B0.unkC = D_803861B0.unk4 + sp1C; } + D_803861B0.unk8->unk0 = 0; D_803861B0.unk8->unk30 = 0; D_803861B0.unk8->unk8 = NULL; D_803861B0.unk8->unkC = NULL; D_803861B0.unk8->unk2C = arg2; D_803861B0.unk8->unk31 = arg3; - D_803861B0.unk8->unk14[0] = arg0[0]; - D_803861B0.unk8->unk14[1] = arg0[1]; - D_803861B0.unk8->unk14[2] = arg0[2]; - D_803861B0.unk8->unk20[0] = arg1[0]; - D_803861B0.unk8->unk20[1] = arg1[1]; - D_803861B0.unk8->unk20[2] = arg1[2]; + + TUPLE_COPY(D_803861B0.unk8->position, position) + TUPLE_COPY(D_803861B0.unk8->unk20, arg1) func_80351AD0(D_803861B0.unk8, arg4); return D_803861B0.unk8++; @@ -224,7 +225,7 @@ void func_803514F4(Struct68s *arg0){ } void func_80351538(Struct68s *arg0){ - arg0->unk4 = (ActorMarker *)func_8032FBE4(arg0->unk14, func_80350E90, 1, 0x47); + arg0->unk4 = (ActorMarker *)func_8032FBE4(arg0->position, func_80350E90, 1, 0x47); ((ActorMarker *)arg0->unk4)->collidable = FALSE; ((ActorMarker *)arg0->unk4)->actrArrayIdx = (arg0 - D_803861B0.unk4); ((ActorMarker *)arg0->unk4)->unk18 = &D_80386180.unk4; @@ -279,10 +280,11 @@ bool func_80351724(void * arg0){ return TRUE; } -s32 func_80351758(Struct68s *arg0){ - if(arg0->unk0 == 0){ +s32 func_80351758_getSfxsourceIndex(Struct68s *arg0) { + if (arg0->unk0 == NULL) { arg0->unk0 = sfxsource_createSfxsourceAndReturnIndex(); } + return arg0->unk0; } @@ -290,10 +292,8 @@ ActorMarker *func_80351794(Struct68s *arg0){ return arg0->unk4; } -void func_8035179C(Struct68s* arg0, f32 arg1[3]) { - arg1[0] = arg0->unk14[0]; - arg1[1] = arg0->unk14[1]; - arg1[2] = arg0->unk14[2]; +void func_8035179C_copyPosition(Struct68s* arg0, f32 position[3]) { + TUPLE_COPY(position, arg0->position) } void * func_803517B8(s32 arg0){ @@ -305,9 +305,7 @@ Struct68s * func_803517E8(s32 arg0){ } void func_80351814(Struct68s *arg0, f32 arg1[3]) { - arg1[0] = arg0->unk20[0]; - arg1[1] = arg0->unk20[1]; - arg1[2] = arg0->unk20[2]; + TUPLE_COPY(arg1, arg0->unk20) } f32 func_80351830(Struct68s *arg0) { @@ -315,14 +313,14 @@ f32 func_80351830(Struct68s *arg0) { } -s32 func_80351838(f32 arg0[3], s32 arg1, s32 arg2) { - f32 sp2C[3]; +s32 func_80351838(f32 position[3], s32 key_flag, s32 arg2) { + f32 rotation[3]; Struct68s *sp28; - sp2C[0] = sp2C[1] = sp2C[2] = 0.0f; - sp28 = func_8035126C(arg0, &sp2C, 1.0f, 4, arg1 + 0x884); + rotation[0] = rotation[1] = rotation[2] = 0.0f; + sp28 = func_8035126C(position, &rotation, 1.0f, 4, key_flag + 0x884); func_80351538(sp28); - func_8038B5D8(&sp28->local, sp28, arg1, arg2); + func_8038B5D8(&sp28->local, sp28, key_flag, arg2); return sp28 - D_803861B0.unk4; } @@ -416,7 +414,7 @@ void func_80351B28(Struct68s *arg0, f32 arg1[3]) { if(arg0->unkC != NULL){ sp34 = func_8033A12C(arg0->unkC); if(sp34 != NULL){ - if(func_802EA760(sp34, 0, arg0->unk14, arg0->unk20, arg0->unk2C, 0, &sp48, &sp38)){ + if(func_802EA760(sp34, 0, arg0->position, arg0->unk20, arg0->unk2C, 0, &sp48, &sp38)){ func_802EA760(sp34, 0, arg1, arg0->unk20, arg0->unk2C, 0, &sp3C, &sp38); if(func_80309DBC(&sp48, &sp3C, sp38, &sp54, 3, 0)){ return; @@ -424,17 +422,13 @@ void func_80351B28(Struct68s *arg0, f32 arg1[3]) { } } } - arg0->unk14[0] = arg1[0]; - arg0->unk14[1] = arg1[1]; - arg0->unk14[2] = arg1[2]; - func_8032F64C(arg0->unk14, arg0->unk4); + + TUPLE_COPY(arg0->position, arg1) + func_8032F64C(arg0->position, arg0->unk4); } - void func_80351C2C(Struct68s *arg0, f32 arg1[3]){ - arg0->unk20[0] = arg1[0]; - arg0->unk20[1] = arg1[1]; - arg0->unk20[2] = arg1[2]; + TUPLE_COPY(arg0->unk20, arg1) } void func_80351C48(void) { @@ -450,7 +444,7 @@ void func_80351C48(void) { if ((sp38[0] == D_80386180.unk20[0]) && (sp38[1] == D_80386180.unk20[1]) && (sp38[2] == D_80386180.unk20[2])) { player_getPosition(sp4C); mlMtxIdent(); - func_80252CC4(D_80386180.unk2C->unk14, D_80386180.unk2C->unk20, D_80386180.unk2C->unk2C, 0); + func_80252CC4(D_80386180.unk2C->position, D_80386180.unk2C->unk20, D_80386180.unk2C->unk2C, 0); mlMtx_apply_vec3f(D_80386180.unk14, sp4C); if (func_8029FC4C() != 0) { D_80386180.unk0 = D_80386180.unk2C; @@ -469,7 +463,7 @@ void func_80351C48(void) { } if (D_80386180.unk2C != NULL) { mlMtxIdent(); - func_80252C08(D_80386180.unk2C->unk14, D_80386180.unk2C->unk20, D_80386180.unk2C->unk2C, NULL); + func_80252C08(D_80386180.unk2C->position, D_80386180.unk2C->unk20, D_80386180.unk2C->unk2C, NULL); mlMtx_apply_vec3f(&sp4C, &D_80386180.unk14); func_8028FAB0(&sp4C); } @@ -480,7 +474,7 @@ void func_80351DE0(Struct6Bs *arg0, Struct68s *arg1) { arg0->unk0 = randf2(80.0f, 100.0f); arg0->unk4[0] = arg0->unk4[1] = arg0->unk4[2] = 0.0f; arg0->unk10[0] = arg0->unk10[1] = arg0->unk10[2] = 0.0f; - func_8035179C(arg1, arg0->unk1C); + func_8035179C_copyPosition(arg1, arg0->unk1C); func_80351814(arg1, arg0->unk28); arg0->unk34 = 0.0f; } @@ -492,12 +486,10 @@ void func_80351E60(Struct6Bs *arg0, Struct68s *arg1, f32 arg2) { arg0->unk10[1] = sinf(((arg0->unk34 * arg0->unk0) / 180.0) * BAD_PI) * 20.0f; arg0->unk4[0] = cosf(((arg0->unk34 * arg0->unk0) / 180.0) * BAD_PI) * 7.5; arg0->unk4[1] = sinf(((arg0->unk34 * arg0->unk0) / 180.0) * BAD_PI) * 3.0f; - sp24[0] = arg0->unk1C[0] + arg0->unk10[0]; - sp24[1] = arg0->unk1C[1] + arg0->unk10[1]; - sp24[2] = arg0->unk1C[2] + arg0->unk10[2]; + + TUPLE_ADD_COPY(sp24, arg0->unk1C, arg0->unk10) func_80351B28(arg1, &sp24); - sp24[0] = arg0->unk28[0] + arg0->unk4[0]; - sp24[1] = arg0->unk28[1] + arg0->unk4[1]; - sp24[2] = arg0->unk28[2] + arg0->unk4[2]; + + TUPLE_ADD_COPY(sp24, arg0->unk28, arg0->unk4) func_80351C2C(arg1, &sp24); } diff --git a/src/core2/code_CB050.c b/src/core2/code_CB050.c index 762a4b71..46b92aa2 100644 --- a/src/core2/code_CB050.c +++ b/src/core2/code_CB050.c @@ -32,7 +32,7 @@ void func_80351FE0(Struct_core2_CB050_0 *arg0, Struct68s *arg1) { arg0->unk28[0] = arg0->unk28[1] = arg0->unk28[2] = 0.0f; arg0->unk34[0] = arg0->unk34[1] = arg0->unk34[2] = 0.0f; arg0->unk40[0] = arg0->unk40[1] = arg0->unk40[2] = 0.0f; - func_8035179C(arg1, arg0->unk4C); + func_8035179C_copyPosition(arg1, arg0->unk4C); func_80351814(arg1, arg0->unk58); arg0->unk64 = 0.0f; arg0->unk6C = 0; diff --git a/src/core2/code_CC1E0.c b/src/core2/code_CC1E0.c index 0506f919..401f0b44 100644 --- a/src/core2/code_CC1E0.c +++ b/src/core2/code_CC1E0.c @@ -51,7 +51,7 @@ void fxegg_shatter(u8 projectile_indx){ s32 func_803531C8(u8 projectile_indx, s32 arg1){ ActorProp *prop; - f32 sp40[3]; + f32 egg_position[3]; ActorMarker * marker; ActorMarker * other_marker; s32 sp34; @@ -63,7 +63,7 @@ s32 func_803531C8(u8 projectile_indx, s32 arg1){ marker = func_8033E840(); sp34 = 0; - projectile_getPosition(projectile_indx, sp40); + projectile_getPosition(projectile_indx, egg_position); marker->unk38[1] = 0x1E; prop = func_80320EB0(marker, 30.0f, 1); if(prop != NULL && prop->unk8_0){ @@ -84,7 +84,7 @@ s32 func_803531C8(u8 projectile_indx, s32 arg1){ break; case MARKER_33_LEAKY: //L80353350 - if(func_802458A8(sp40, other_marker, 0x32) && chLeaky_eggCollision(other_marker)){ + if (collisionTri_isHitFromAbove_marker(egg_position, other_marker, 0x32) && chLeaky_eggCollision(other_marker)) { func_8033E984(); } break; @@ -94,7 +94,7 @@ s32 func_803531C8(u8 projectile_indx, s32 arg1){ func_803870EC(1); break; - case 0x1ae: //L8035339C //zubba? + case MARKER_1AE_ZUBBA: //L8035339C //zubba? func_8033E984(); fxegg_shatter(projectile_indx); break; @@ -109,26 +109,26 @@ s32 func_803531C8(u8 projectile_indx, s32 arg1){ func_8038685C(other_marker); break; - case 0xbb: //L803533E4 //"BIG_JINXYHEAD" + case MARKER_BB_UNKNOWN: //L803533E4 //"BIG_JINXYHEAD" other_actor = marker_getActor(other_marker); *(s32 *)&other_actor->local = 1; func_8033E984(); break; case MARKER_34_CEMETARY_POT: //L80353400 - if(func_802458A8(sp40, other_marker, 0x3C) && MMM_func_80387340(other_marker)){ + if (collisionTri_isHitFromAbove_marker(egg_position, other_marker, 0x3C) && chFlowerpot_eggCollision(other_marker)) { func_8033E984(); } break; case MARKER_AB_RUBEES_EGG_POT: //L80353434 - if(func_802458A8(sp40, other_marker, 0x1E) && (func_8038E178() < func_8038E184())){ + if (collisionTri_isHitFromAbove_marker(egg_position, other_marker, 0x1E) && (func_8038E178() < func_8038E184())) { func_8033E984(); func_8038E140(); } break; - case 0xae: //L80353480 //big_jynxy_head + case MARKER_AE_UNKNOWN: //L80353480 //big_jynxy_head if(func_8038E344(other_marker)){ func_8033E984(); func_8038E2FC(other_marker); diff --git a/src/core2/gc/pauseMenu.c b/src/core2/gc/pauseMenu.c index 849456fe..f0deb99e 100644 --- a/src/core2/gc/pauseMenu.c +++ b/src/core2/gc/pauseMenu.c @@ -33,7 +33,7 @@ void func_80310D2C(void); s32 level_get(void); void func_8024E6E0(s32, void *); void func_8024E60C(s32, void *); -void func_8024E71C(s32, void *); +void controller_getJoystick(s32, void *); s32 getGameMode(void); void func_802DC5B8(void); @@ -937,7 +937,7 @@ s32 gcPauseMenu_update(void) { } func_8024E55C(0, face_button); - func_8024E71C(0, joystick); + controller_getJoystick(0, joystick); func_8024E60C(0, sp60); func_8024E6E0(0, sp50); func_80310D2C(); diff --git a/src/lair/ch/brentilda.c b/src/lair/ch/brentilda.c index 5d145952..0d3de6b2 100644 --- a/src/lair/ch/brentilda.c +++ b/src/lair/ch/brentilda.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern f32 func_80258640(f32[3], f32[3]); +extern f32 ml_vec3f_horizontal_distance_zero_likely(f32[3], f32[3]); typedef struct { s32 unk0; @@ -124,7 +124,7 @@ void chBrentilda_update(Actor *this) { player_getPosition(sp64); temp_f0 = sp64[1] - this->position[1]; if ((temp_f0 > -100.0f) && (temp_f0 < 350.0f)) { - phi_f2 = func_80258640(sp64, this->position); + phi_f2 = ml_vec3f_horizontal_distance_zero_likely(sp64, this->position); } else { phi_f2 = 2000.0f; }