diff --git a/decompressed.pal.yaml b/decompressed.pal.yaml index ff98a162..cbeec075 100644 --- a/decompressed.pal.yaml +++ b/decompressed.pal.yaml @@ -515,8 +515,8 @@ segments: - [0xF7D990, c, ba/marker] - [0xF7FD00, c, code_6B30] - [0xF7FFA0, c, ba/carriedobj] - - [0xF80230, bin, core2_untouched_text] - # - [0xF5C9C0, c, code_7060] #DONE + - [0xF80230, c, code_7060] + - [0xF81F70, bin, core2_untouched_text] # - [0xF5E700, c, code_8DA0] #DONE # - [0xF5EA40, c, code_90E0] #DONE # - [0xF5EBF0, c, code_9290] #DONE @@ -892,7 +892,7 @@ segments: # - [0x102BF60, c, code_D6600] #DONE # - [0x102C9A0, c, ch/termite] #DONE # - [0x102D670, c, ch/gravestone] #DONE - # - [0x102E340, c, code_D89E0] + # - [0x102E340, c, ch/bat] # - [0x102F700, c, ch/whipcrack] #DONE # - [0x102FD00, c, code_DA3A0] #DONE # - [0x10300C0, c, code_DA760] #DONE @@ -904,8 +904,8 @@ segments: - [0x1055E70, .data, ba/anim] - [0x1055EA0, .data, snackerctl] - [0x1055EC0, .data, ba/marker] - - [0x1055F20, bin, core2_untouched_data] - # - [0x1032060, .data, code_7060] + - [0x1055F20, .data, code_7060] + - [0x1055F60, bin, core2_untouched_data] # - [0x10320A0, .data, code_90E0] # - [0x1032150, .data, ba/model] # - [0x1032150, .data, code_B850] @@ -1114,7 +1114,7 @@ segments: # - [0x1041870, .data, code_D6600] # - [0x10418E0, .data, ch/termite] # - [0x1041950, .data, ch/gravestone] - # - [0x1041A60, .data, code_D89E0] + # - [0x1041A60, .data, ch/bat] # - [0x1041AD0, .data, ch/whipcrack] # - [0x1041B00, .data, code_DA3A0] # - [0x1041B80, .data, code_DA760] @@ -1129,8 +1129,8 @@ segments: - [0x1066870, .rodata, code_39D0] - [0x1066910, .rodata, ba/marker] - [0x1066D40, .rodata, code_6B30] - - [0x1066E30, bin, core2_untouched_rodata] - # - [0x1042E60, .rodata, code_7060] + - [0x1066E30, .rodata, code_7060] + - [0x1066F60, bin, core2_untouched_rodata] # - [0x1042F90, .rodata, code_9450] # - [0x1042FC0, .rodata, code_9900] # - [0x1042FD0, .rodata, code_9BD0] @@ -1367,8 +1367,8 @@ segments: # - [0x1048240, .rodata, code_D6600] # - [0x1048280, .rodata, ch/termite] # - [0x10482F0, .rodata, ch/gravestone] - # - [0x1048390, .rodata, code_D89E0] - # - [0x10483C0, .rodata, code_D89E0] + # - [0x1048390, .rodata, ch/bat] + # - [0x10483C0, .rodata, ch/bat] # - [0x1048430, .rodata, ch/whipcrack] # - [0x1048450, .rodata, code_DA3A0] # - [0x1048460, .rodata, code_DA760] @@ -1382,7 +1382,7 @@ segments: - [0x0106C980, .bss, code_39D0] - [0x0106C980, .bss, ba/marker] - [0x0106C980, .bss, code_6B30] - # - [0x0106C980, .bss, code_7060] + - [0x0106C980, .bss, code_7060] # - [0x0106C980, .bss, code_8DA0] # - [0x0106C980, .bss, code_90E0] # - [0x0106C980, .bss, code_9290] diff --git a/decompressed.us.v10.yaml b/decompressed.us.v10.yaml index b3f871c0..8c437d92 100644 --- a/decompressed.us.v10.yaml +++ b/decompressed.us.v10.yaml @@ -892,7 +892,7 @@ segments: - [0x102BF60, c, code_D6600] #DONE - [0x102C9A0, c, ch/termite] #DONE - [0x102D670, c, ch/gravestone] #DONE - - [0x102E340, c, code_D89E0] + - [0x102E340, c, ch/bat] - [0x102F700, c, ch/whipcrack] #DONE - [0x102FD00, c, code_DA3A0] #DONE - [0x10300C0, c, code_DA760] #DONE @@ -1113,7 +1113,7 @@ segments: - [0x1041870, .data, code_D6600] - [0x10418E0, .data, ch/termite] - [0x1041950, .data, ch/gravestone] - - [0x1041A60, .data, code_D89E0] + - [0x1041A60, .data, ch/bat] - [0x1041AD0, .data, ch/whipcrack] - [0x1041B00, .data, code_DA3A0] - [0x1041B80, .data, code_DA760] @@ -1365,8 +1365,8 @@ segments: - [0x1048240, .rodata, code_D6600] - [0x1048280, .rodata, ch/termite] - [0x10482F0, .rodata, ch/gravestone] - - [0x1048390, .rodata, code_D89E0] - - [0x10483C0, .rodata, code_D89E0] + - [0x1048390, .rodata, ch/bat] + - [0x10483C0, .rodata, ch/bat] - [0x1048430, .rodata, ch/whipcrack] - [0x1048450, .rodata, code_DA3A0] - [0x1048460, .rodata, code_DA760] diff --git a/include/functions.h b/include/functions.h index 2d3424a0..1c31b2f5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -13,6 +13,7 @@ #include "core1/core1.h" #include "core2/core2.h" +#include "math.h" // ToDo: sort out actual dependencies #include "ml.h" #include "ml/mtx.h" #include "bs_funcs.h" @@ -25,32 +26,6 @@ extern f32 fabsf(f32); #pragma intrinsic (fabsf) -#define TUPLE_ASSIGN(out, a, b, c) {\ - out[0] = a;\ - out[1] = b;\ - out[2] = c;\ -} - -#define TUPLE_COPY(dst, src) {\ - dst[0] = src[0];\ - dst[1] = src[1];\ - dst[2] = src[2];\ -} - -#define v3Copy(dst, src) {\ - dst[0] = src[0];\ - dst[1] = src[1];\ - dst[2] = src[2];\ -} - -#define TUPLE_OP(out, a, op, b) {\ - out##_x = a##_x op b##_x;\ - out##_y = a##_y op b##_y;\ - out##_z = a##_z op b##_z;\ -} - -#define LENGTH_SQ_VEC3F(v) (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) - //known it uses "+" instead of "|" for fight/code_9D40.c, func_8039049C, case 6 #define FUNC_8030E624(sfx_e, vol, sample_rate) func_8030E624(\ _SHIFTL((vol*1023), 21, 11) + _SHIFTL(sample_rate >> 5, 11, 10) + _SHIFTL(sfx_e, 0, 11)\ @@ -284,8 +259,8 @@ void baanim_playForDuration_onceSmooth(enum asset_e, f32); void baanim_setEndAndDuration(f32, f32); int func_8028AED4(f32*, f32); void func_8028E668(f32[3], f32, f32, f32); -bool func_8028F364(f32[3], f32, f32, enum actor_e actor_id, Actor**); -void func_8028FA54(f32[3]); +bool player_setCarryObjectPoseInCylinder(f32[3], f32, f32, enum actor_e actor_id, Actor**); +void player_setThrowTargetPosition(f32[3]); f32 func_802915D8(void); f32 func_80291604(void); diff --git a/include/math.h b/include/math.h index 95e8fe93..8b8ba7f4 100644 --- a/include/math.h +++ b/include/math.h @@ -3,4 +3,69 @@ #define SQ(x) ((x)*(x)) +#define TUPLE_ASSIGN(out, a, b, c) {\ + out[0] = a;\ + out[1] = b;\ + out[2] = c;\ +} + +#define TUPLE_COPY(dst, src) {\ + dst[0] = src[0];\ + dst[1] = src[1];\ + dst[2] = src[2];\ +} + +#define TUPLE_ADD(dst, vec) { \ + dst[0] += vec[0]; \ + dst[1] += vec[1]; \ + dst[2] += vec[2]; \ +} + +#define TUPLE_ADD_COPY(dst, vec1, vec2) { \ + dst[0] = vec1[0] + vec2[0]; \ + dst[1] = vec1[1] + vec2[1]; \ + dst[2] = vec1[2] + vec2[2]; \ +} + +#define TUPLE_DIFF(dst, vec) { \ + dst[0] -= vec[0]; \ + dst[1] -= vec[1]; \ + dst[2] -= vec[2]; \ +} + +#define TUPLE_DIFF_COPY(dst, vec1, vec2) { \ + dst[0] = vec1[0] - vec2[0]; \ + dst[1] = vec1[1] - vec2[1]; \ + dst[2] = vec1[2] - vec2[2]; \ +} + +#define TUPLE_MULTIPLY_COPY(dst, vec1, vec2) { \ + dst[0] = vec1[0] * vec2[0]; \ + dst[1] = vec1[1] * vec2[1]; \ + dst[2] = vec1[2] * vec2[2]; \ +} + +#define TUPLE_SCALE(vec, value) { \ + vec[0] *= value; \ + vec[1] *= value; \ + vec[2] *= value; \ +} + +#define TUPLE_SCALE_COPY(dst, vec, value) { \ + dst[0] = vec[0] * value; \ + dst[1] = vec[1] * value; \ + dst[2] = vec[2] * value; \ +} + +#define TUPLE_CROSS_PRODUCT(dst, vec1, vec2) { \ + dst[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1]; \ + dst[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2]; \ + dst[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; \ +} + +#define LENGTH_SQ_VEC3F(v) (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]) +#define LENGTH_VEC3F(v) gu_sqrtf(LENGTH_SQ_VEC3F(v)) + +#define TUPLE_DOT_PRODUCT(vec1, vec2) (vec1[0] * vec2[0] + vec1[1] * vec2[1] + vec1[2] * vec2[2]) + #endif // __BANJO_KAZOOIE_MATH_H__ diff --git a/manual_syms.pal.txt b/manual_syms.pal.txt index d19c2e88..2fa6f976 100644 --- a/manual_syms.pal.txt +++ b/manual_syms.pal.txt @@ -32,54 +32,70 @@ boot_gOverlayTable = gOverlayTable; boot_func_8023DA20 = func_8023DA20; /* Temporary*/ - /* Temporary Correct*/ -player_getActiveHitbox = 0x8028e58c; -player_getTransformation = 0x8028e5ec; -func_8028E964 = 0x8028e784; -player_getPosition = 0x8028e7c4; -func_8028E9C4 = 0x8028e7e4; -player_getPosition_s32 = 0x8028e95c; -player_getYaw = 0x8028e9c4; -func_8028ECAC = 0x8028eacc; -player_getWaterState = 0x8028eca4; -func_8028F170 = 0x8028ef90; -ability_isUnlocked = 0x8028efb0; -player_is_present = 0x8028eff4; -func_8028F1E0 = 0x8028f000; -player_isDead = 0x8028f04c; -func_8028F25C = 0x8028f07c; -func_8028F428 = 0x8028f248; -func_8028F55C = 0x8028f37c; -func_8028F918 = 0x8028f738; -func_8028F94C = 0x8028f76c; -func_8028FB88 = 0x8028f9a8; +func_8029026C = 0x8029008c; +func_80290B6C = 0x8029098c; +cameraMode_update = 0x80291178; func_8029151C = 0x8029133c; +func_802915D8 = 0x802913f8; +func_80291604 = 0x80291424; func_80291610 = 0x80291430; func_80291634 = 0x80291454; +stateTimer_get = 0x80291490; stateTimer_isActive = 0x802914b8; +stateTimer_set = 0x80291604; baModel_80291AAC = 0x802918cc; +baModel_draw = 0x80291910; +baModel_setVisible = 0x80291fe8; +baModel_8029223C = 0x8029205c; +baModel_80292260 = 0x80292080; baModel_80292284 = 0x802920a4; baModel_getPosition = 0x80292288; +baModel_802924E8 = 0x80292308; +baModel_isVisible = 0x80292368; +badrone_goto = 0x80292478; +eggShatter_draw = 0x80292900; bafalldamage_get_damage = 0x80292ffc; miscFlag_isTrue = 0x802931e0; miscFlag_isFalse = 0x802931f0; miscFlag_set = 0x80293208; miscFlag_clear = 0x8029321c; +func_80293D2C = 0x80293b4c; +func_80293F0C = 0x80293d2c; func_80294438 = 0x80294258; +func_80294480 = 0x802942a0; func_80294500 = 0x80294320; +func_8029453C = 0x8029435c; func_80294548 = 0x80294368; func_80294554 = 0x80294374; +func_80294574 = 0x80294394; func_80294610 = 0x80294430; +func_802946F0 = 0x80294510; bacarry_reset_marker = 0x80294700; bacarry_get_marker = 0x8029470c; bacarry_set_marker = 0x80294718; +bacarry_set_offsets = 0x80294744; +func_802949C8 = 0x802947e8; get_slope_timer = 0x802947f4; +get_throw_target_position = 0x8029483c; +set_talk_target_position = 0x802948b8; set_throw_target_position = 0x802948e0; set_turbo_duration = 0x80294908; - +func_80294AF4 = 0x80294914; +func_80294E54 = 0x80294c74; +func_802955A4 = 0x802953c4; +func_802955BC = 0x802953dc; ability_hasLearned = 0x80295618; +ability_setLearned = 0x80295658; +func_80295914 = 0x80295754; +func_80295A8C = 0x802958cc; +func_80295B04 = 0x80295944; +func_80295C14 = 0x80295a54; +func_80295D74 = 0x80295bb4; +func_80296C90 = 0x80296ad0; +func_80296C9C = 0x80296adc; +func_80296CA8 = 0x80296ae8; func_80296CB4 = 0x80296af4; func_80296CC0 = 0x80296b00; baphysics_set_type = 0x8029771c; @@ -87,20 +103,46 @@ baphysics_set_target_horizontal_velocity = 0x802977b0; baphysics_get_velocity = 0x802978c8; baphysics_get_vertical_velocity = 0x802978ec; +baphysics_set_goto_position = 0x80297a04; func_80297C6C = 0x80297aac; +pitch_setIdeal = 0x80297d7c; +pitch_applyIdeal = 0x80297dc4; +pitch_get = 0x80297dd8; +climbGetBottom = 0x80298060; +climbSet = 0x802980b4; +func_80298464 = 0x802982a4; +player_setPosition = 0x802982e0; _player_getPosition = 0x80298314; player_getYPosition = 0x80298338; +func_80298540 = 0x80298380; +func_80298564 = 0x802983a4; +func_80298850 = 0x80298690; +func_80298890 = 0x802986d0; +func_802988DC = 0x8029871c; +func_8029892C = 0x8029876c; +roll_setIdeal = 0x80298b20; +roll_applyIdeal = 0x80298b68; +roll_get = 0x80298b7c; yaw_setUpdateState = 0x80298fe8; yaw_setIdeal = 0x80298ff4; +yaw_set = 0x80299018; +yaw_applyIdeal = 0x8029903c; yaw_get = 0x8029905c; yaw_getIdeal = 0x80299068; func_8029957C = 0x802993bc; + +bsList_getInterruptMethod = 0x8029a534; bs_setState = 0x8029a56c; bs_getState = 0x8029a608; bs_checkInterrupt = 0x8029a65c; bsStoredState_getTransformation = 0x8029a734; +bsStoredState_setTrot = 0x8029a7c0; +func_8029B318 = 0x8029b158; func_8029B41C = 0x8029b25c; +func_8029B73C = 0x8029b57c; +bs_getIdleState = 0x8029bdb8; func_8029C0D0 = 0x8029bf10; +func_8029C834 = 0x8029c674; func_8029CDA0 = 0x8029cbe0; func_8029CF20 = 0x8029cd60; func_8029D66C = 0x8029d4ac; @@ -109,13 +151,23 @@ bsbbarge_hitboxActive = 0x8029f484; bsbbuster_hitboxActive = 0x8029fa98; func_8028F66C = 0x8028f48c; func_802A02B4 = 0x802a00f4; +bsbfly_inSet = 0x802a35b8; bsbfly_bombHitboxActive = 0x802a3dd0; +bslongleg_inSet = 0x802a50ec; func_802A6388 = 0x802a61c8; bsbpeck_hitboxActive = 0x802a6350; +bsbswim_inSet = 0x802a7348; +bscarry_inSet = 0x802aafc4; bsclaw_hitboxActive = 0x802ab0c0; +bsclimb_inSet = 0x802ab640; bscroc_hitboxActive = 0x802acd8c; +func_802AD3A0 = 0x802ad1e0; +bsjump_jumpingFromWater = 0x802b1c14; bspumpkin_inSet = 0x802b2154; +bsswim_inset = 0x802b5594; bstwirl_hitboxActive = 0x802b68b0; +func_802B6F9C = 0x802b6e0c; +bswalrus_inSledSet = 0x802b8000; func_802BAFE4 = 0x802bae54; func_802BB360 = 0x802bb1d0; func_802BB378 = 0x802bb1e8; @@ -142,6 +194,8 @@ chtrainers_pickup = 0x802ca910; mapSpecificFlags_get = 0x802caeb8; mapSpecificFlags_set = 0x802caf80; mapSpecificFlags_validateCRC1 = 0x802cb1cc; +func_802D6088 = 0x802d6268; +func_802D60C4 = 0x802d62a4; func_802D6264 = 0x802d6444; func_802D686C = 0x802d6a4c; func_802D6924 = 0x802d6b0c; @@ -160,6 +214,7 @@ func_802E3580 = 0x802E3770; dummy_func_802E35D0 = 0x802E37C0; func_802E35D8 = 0x802E37c8; game_draw = 0x802E417c; +func_802E4078 = 0x802e4268; func_802E4170 = 0x802E4360; func_802E4214 = 0x802E4404; func_802E4384 = 0x802e4574; @@ -168,6 +223,10 @@ game_defrag = 0x802e4ac8; func_802E49E0 = 0x802e4bd0; getGameMode = 0x802e4bec; func_802E4A08 = 0x802e4bf8; +func_802E4A98 = 0x802e4c88; +func_802E4AAC = 0x802e4c9c; +func_802E4AC0 = 0x802e4cb0; +func_802E4AD4 = 0x802e4cc4; func_802E4B38 = 0x802e4d28; func_802E6820 = 0x802e6a04; animMtxList_setBoned = 0x802ea388; @@ -202,8 +261,13 @@ func_802FA060 = 0x802fa240; func_802FADD4 = 0x802fafb4; cubeList_findNodePropByActorId = 0x80304b6c; nodeprop_findByActorIdAndActorPosition = 0x80304dd8; +func_80304CAC = 0x80304e4c; nodeprop_getPosition_s32 = 0x80304eec; nodeprop_getPosition = 0x80304f08; +_nodeProp_findPositionFromActorId = 0x80304f70; +func_80305248 = 0x803053e8; +func_80305344 = 0x803054e4; +func_803084F0 = 0x80308690; func_80309B48 = 0x80309ce8; func_80309D58 = 0x80309ef8; func_8030A850 = 0x8030a9f0; @@ -229,6 +293,7 @@ func_8030E394 = 0x8030e534; func_803012F8 = 0x803014d8; fxairscore_count_to_time = 0x80301f5c; gcdialog_showText = 0x803116cc; +func_803114B0 = 0x803116fc; gcpausemenu_80314AC8 = 0x80314e1c; func_8031B908 = 0x8031bce8; @@ -280,7 +345,10 @@ marker_setCollisionScripts = 0x803304f8; func_803300B8 = 0x80330508; func_803306C8 = 0x80330b18; func_80332790 = 0x80332be0; +func_8033452C = 0x8033497c; map_get = 0x80334d10; +exit_get = 0x80334d1c; +func_80334904 = 0x80334d54; func_80335134 = 0x80335584; sfxInstruments_init = 0x80335670; modelRender_setBoneTransformList = 0x8033A688; diff --git a/src/BGS/ch/flibbit.c b/src/BGS/ch/flibbit.c index 3fdd8a1b..7290ed2f 100644 --- a/src/BGS/ch/flibbit.c +++ b/src/BGS/ch/flibbit.c @@ -338,10 +338,8 @@ void chflibbit_update(Actor *this){ } player_getPosition(player_position); - spB0[0] = player_position[0] - this->position[0]; - spB0[1] = player_position[1] - this->position[1]; - spB0[2] = player_position[2] - this->position[2]; - player_distance = gu_sqrtf(spB0[0]*spB0[0] + spB0[1]*spB0[1] + spB0[2]*spB0[2]); + TUPLE_DIFF_COPY(spB0, player_position, this->position) + player_distance = LENGTH_VEC3F(spB0); if(ml_timer_update(&local->unk24, spA4)){ func_8030E878(0x3f0, randf2(0.9f, 1.1f), randi2(12000, 19000), this->position, 500.0f, 2500.0f); @@ -427,15 +425,11 @@ void chflibbit_update(Actor *this){ } if(this->state == 6){ - sp4C[0] = this->position[0] - player_position[0]; - sp4C[1] = this->position[1] - player_position[1]; - sp4C[2] = this->position[2] - player_position[2]; + TUPLE_DIFF_COPY(sp4C, this->position, player_position) sp4C[1] = 0.0f; ml_vec3f_set_length(sp4C, 400.0f * spA4); - this->position[0] = this->position[0] + sp4C[0]; - this->position[1] = this->position[1] + sp4C[1]; - this->position[2] = this->position[2] + sp4C[2]; + TUPLE_ADD_COPY(this->position, this->position, sp4C) this->position_y += local->unk14*spA4; local->unk14 -= 3000.0f*spA4; diff --git a/src/BGS/ch/mudhut.c b/src/BGS/ch/mudhut.c index 523ea4a0..e2e85ded 100644 --- a/src/BGS/ch/mudhut.c +++ b/src/BGS/ch/mudhut.c @@ -88,7 +88,7 @@ void chmudhut_update(Actor *this){ if( (150.0f < diffPos[1]) && (player_getActiveHitbox(this->marker) == HITBOX_1_BEAK_BUSTER) && (func_8028F20C()) - && (gu_sqrtf(diffPos[0]*diffPos[0] + diffPos[1]*diffPos[1] + diffPos[2]*diffPos[2]) < 350.f) + && (LENGTH_VEC3F(diffPos) < 350.f) ){ tmp = (s32)( (this->position_y - 600.f)/430.0f); diffPos[0] = this->position_x; diff --git a/src/BGS/ch/yellowflibbit.c b/src/BGS/ch/yellowflibbit.c index 2fa28b10..7a91819b 100644 --- a/src/BGS/ch/yellowflibbit.c +++ b/src/BGS/ch/yellowflibbit.c @@ -371,7 +371,7 @@ void BGS_func_8038E034(Actor *this) { spA8[0] = spB4[0] - this->position[0]; spA8[1] = spB4[1] - this->position[1]; spA8[2] = spB4[2] - this->position[2]; - spA4 = gu_sqrtf(spA8[0]*spA8[0] + spA8[1]*spA8[1] + spA8[2]*spA8[2]); + spA4 = LENGTH_VEC3F(spA8); if (ml_timer_update(&local->unk28, sp9C) != 0) { func_8030E878(0x3F0, randf2(0.9f, 1.1f), randi2(12000, 19000), this->position, 500.0f, 2500.0f); local->unk28 = randf2(1.0f, 6.0f); diff --git a/src/BGS/code_3420.c b/src/BGS/code_3420.c index 7469233e..36ce96b2 100644 --- a/src/BGS/code_3420.c +++ b/src/BGS/code_3420.c @@ -1,5 +1,6 @@ #include #include "functions.h" +#include "math.h" #include "variables.h" extern f32 func_80256AB4(f32, f32, f32, f32); @@ -132,14 +133,10 @@ void BGS_func_80389850(Actor *this, s32 arg1) { local = (ActorLocal_BGS_3420 *)&this->local; vile = marker_getActor(local->vile_marker); if (arg1 != 0) { - if (gu_sqrtf(this->position[0]*this->position[0] + this->position[1]*this->position[1] + this->position[2]*this->position[2]) < 800.0f) { - sp7C[0] = 0.0f; - sp7C[1] = 150.0f; - sp7C[2] = 300.0f; + if (LENGTH_VEC3F(this->position) < 800.0f) { + TUPLE_ASSIGN(sp7C, 0.0f, 150.0f, 300.0f) ml_vec3f_yaw_rotate_copy(sp7C, sp7C, vile->yaw); - sp94[0] = vile->position[0] + sp7C[0]; - sp94[1] = vile->position[1] + sp7C[1]; - sp94[2] = vile->position[2] + sp7C[2]; + TUPLE_ADD_COPY(sp94, vile->position, sp7C) bundle_setYaw(vile->yaw); jiggy_spawn(JIGGY_28_BGS_MR_VILE, sp94); } else { diff --git a/src/CC/code_0.c b/src/CC/code_0.c index c26d6c89..aa0c35fb 100644 --- a/src/CC/code_0.c +++ b/src/CC/code_0.c @@ -68,7 +68,7 @@ void func_803864D4(Actor *this){ if(!CC_func_80388CA0()){ local->unk4 = 2.0f; } - else if(60.0f < gu_sqrtf(sp30[0]*sp30[0] + sp30[1]*sp30[1] + sp30[2]*sp30[2])){ + else if(60.0f < LENGTH_VEC3F(sp30)){ local->unk4 = 0.05f; } else{ diff --git a/src/CC/code_13C0.c b/src/CC/code_13C0.c index 2898b471..752ea224 100644 --- a/src/CC/code_13C0.c +++ b/src/CC/code_13C0.c @@ -136,7 +136,7 @@ void CC_func_80387A40(Struct_CC_13C0_1* arg0, Struct68s* arg1, f32 arg2) { sp50[2] -= sp38[2]; sp28 = ((sp50[0]*sp44[0] + sp50[1]*sp44[1] + sp50[2]*sp44[2]) >= 0.0f) ? 1 : -1; if (sp28 == -arg0->unk8) { - if (gu_sqrtf(sp50[0]*sp50[0] + sp50[1]*sp50[1] + sp50[2] * sp50[2]) < (func_80351830(arg1) * 250.0f)) { + if (LENGTH_VEC3F(sp50) < (func_80351830(arg1) * 250.0f)) { func_8038803C(arg0->unk0); } } diff --git a/src/CCW/code_14B0.c b/src/CCW/code_14B0.c index 547cc2d1..a5e03fee 100644 --- a/src/CCW/code_14B0.c +++ b/src/CCW/code_14B0.c @@ -101,7 +101,7 @@ void CCW_func_80387A40(Actor *this) { local->unk18[0] += sp5C[0] * sp68; local->unk18[1] += sp5C[1] * sp68; local->unk18[2] += sp5C[2] * sp68; - if (local->unk8 < gu_sqrtf(local->unk18[0]*local->unk18[0] + local->unk18[1]*local->unk18[1] + local->unk18[2]*local->unk18[2])) { + if (local->unk8 < LENGTH_VEC3F(local->unk18)) { ml_vec3f_set_length(local->unk18, local->unk8); } func_80258A4C(this->position, this->yaw - 90.0f, local->unkC, &sp58, &sp54, &sp50); @@ -117,7 +117,7 @@ void CCW_func_80387A40(Actor *this) { sfxsource_set_fade_distances(local->sfxsourceIdx, 500.0f, 1500.0f); sfxsource_set_position(local->sfxsourceIdx, this->position); func_8030E2C4(local->sfxsourceIdx); - sfxsource_setSampleRate(local->sfxsourceIdx, 2000.0f + 8000.0f*(gu_sqrtf(local->unk18[0]*local->unk18[0] + local->unk18[1]*local->unk18[1] + local->unk18[2]*local->unk18[2])/ local->unk8)); + sfxsource_setSampleRate(local->sfxsourceIdx, 2000.0f + 8000.0f*(LENGTH_VEC3F(local->unk18)/ local->unk8)); if (!mapSpecificFlags_get(local->unk4->unk2)) { player_getPosition(sp44); if (sp44[2] > -600.0f) { diff --git a/src/CCW/code_3310.c b/src/CCW/code_3310.c index 7a2b7391..f6526654 100644 --- a/src/CCW/code_3310.c +++ b/src/CCW/code_3310.c @@ -270,9 +270,9 @@ void CCW_func_80389BFC(Actor *this) { func_8028F784(0); } if ((local->unk0->map_id != MAP_43_CCW_SPRING) && ((this->position[0] + 500.0f) < sp4C[0])) { - func_8028F364(this->position, 1110.0f, 200.0f, ACTOR_2A2_CATERPILLAR, &this); + player_setCarryObjectPoseInCylinder(this->position, 1110.0f, 200.0f, ACTOR_2A2_CATERPILLAR, &this); if ((local->unk0->unkE != 0) && (carriedObj_getActorId() == ACTOR_2A2_CATERPILLAR) && (ml_distance_vec3f(this->position, sp4C) < 1010.0f) && (player_throwCarriedObject() != 0)) { - func_8028FA54(D_8038FDE0); + player_setThrowTargetPosition(D_8038FDE0); if ((local->unk0->map_id == MAP_44_CCW_SUMMER) && (local->unk4 == 0)) { gcdialog_showText(0xCD8, 4, NULL, NULL, NULL, NULL); } diff --git a/src/CCW/code_5540.c b/src/CCW/code_5540.c index e3cbbc12..ef3c75f1 100644 --- a/src/CCW/code_5540.c +++ b/src/CCW/code_5540.c @@ -142,9 +142,9 @@ void chnabnut_update(Actor *this) { this->yaw += sp24 * 10.0f; } if (this->has_met_before && !func_803114B0()) { - func_8028F364(this->position, 500.0f, 200.0f, ACTOR_2A9_ACORN, &this); + player_setCarryObjectPoseInCylinder(this->position, 500.0f, 200.0f, ACTOR_2A9_ACORN, &this); if ((carriedObj_getActorId() == ACTOR_2A9_ACORN) && (ml_distance_vec3f(this->position, sp30) < 300.0f) && player_throwCarriedObject()) { - func_8028FA54(D_8038F350); + player_setThrowTargetPosition(D_8038F350); local->returned_acorn_count++; if (local->returned_acorn_count == 6) { chnabnut_setState(this, NABNUT_STATE_2_WAIT); diff --git a/src/FP/ch/scarfsled.c b/src/FP/ch/scarfsled.c index bf41a8be..be59f536 100644 --- a/src/FP/ch/scarfsled.c +++ b/src/FP/ch/scarfsled.c @@ -105,7 +105,7 @@ void __chScarfSled_func_80386630(Actor *this){ sp64[0] = this->pitch; sp64[1] = this->yaw; sp64[2] = this->roll; - func_8028FAEC(sp64); + player_setIdealRotation(sp64); }//L80386724 if(1.0 == this->unk48){ diff --git a/src/GV/ch/histup.c b/src/GV/ch/histup.c index 724a0caf..7b2ad064 100644 --- a/src/GV/ch/histup.c +++ b/src/GV/ch/histup.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern void func_8028F738(f32[3], f32[3], f32, s32); +extern void player_setClimbParams(f32[3], f32[3], f32, s32); extern int func_8030E3FC(u8); @@ -62,7 +62,7 @@ Actor *func_8038DA18(ActorMarker *this_marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp38[1] = this->position_y; } if(func_8038D920(this, sp38[1])){ - func_8028F738(sp2C, sp38, (f32)this->unkF4_8, 2); + player_setClimbParams(sp2C, sp38, (f32)this->unkF4_8, 2); } return this; diff --git a/src/MM/ch/hut.c b/src/MM/ch/hut.c index 186ba75e..3992dda0 100644 --- a/src/MM/ch/hut.c +++ b/src/MM/ch/hut.c @@ -73,7 +73,7 @@ void chhut_update(Actor *this) { if (150.0f < diff_pos[1] && player_getActiveHitbox(this->marker) == HITBOX_1_BEAK_BUSTER && func_8028F20C() - && gu_sqrtf(diff_pos[0]*diff_pos[0] + diff_pos[1]*diff_pos[1] + diff_pos[2]*diff_pos[2]) < 350.0f + && LENGTH_VEC3F(diff_pos) < 350.0f ){ diff_pos[0] = this->position_x; diff_pos[1] = this->position_y; diff --git a/src/MMM/ch/motzhand.c b/src/MMM/ch/motzhand.c index a79e8e13..667195a3 100644 --- a/src/MMM/ch/motzhand.c +++ b/src/MMM/ch/motzhand.c @@ -161,7 +161,7 @@ void chmotzhand_update(Actor *this){ sp3C[0] = sp30[0] - this->position_x; sp3C[1] = sp30[1] - this->position_y; sp3C[2] = sp30[2] - this->position_z; - if(gu_sqrtf(sp3C[0]*sp3C[0] + sp3C[1]*sp3C[1] + sp3C[2]*sp3C[2]) < 5.0f){ + if(LENGTH_VEC3F(sp3C) < 5.0f){ if(*local->pattern_ptr == 0xff){ chMotzhand_setState(this, 1); } diff --git a/src/MMM/ch/napper.c b/src/MMM/ch/napper.c index 159e8841..fddf3edc 100644 --- a/src/MMM/ch/napper.c +++ b/src/MMM/ch/napper.c @@ -186,9 +186,8 @@ void chnapper_update(Actor *this){ sp30[0] = player_position[0] - this->position_x; sp30[1] = player_position[1] - this->position_y; sp30[2] = player_position[2] - this->position_z; - if( 0.0f < sp30[2] - && gu_sqrtf(sp30[0]*sp30[0] + sp30[1]*sp30[1] + sp30[2]*sp30[2]) < 600.0f - ){ + + if (0.0f < sp30[2] && LENGTH_VEC3F(sp30) < 600.0f) { __chnapper_setState(this, 5); } else{//L8038703C diff --git a/src/MMM/code_47D0.c b/src/MMM/code_47D0.c index 49a027cd..19a66baf 100644 --- a/src/MMM/code_47D0.c +++ b/src/MMM/code_47D0.c @@ -140,7 +140,7 @@ void func_8038AF90(Struct_MMM_47D0_0 *arg0, Struct68s *arg1, f32 arg2) { arg0->unkC[0] *= 0.7; arg0->unkC[2] *= 0.7; } - if (gu_sqrtf(arg0->unkC[0]*arg0->unkC[0] + arg0->unkC[1]*arg0->unkC[1] + arg0->unkC[2]*arg0->unkC[2]) > 400.0f) { + if (LENGTH_VEC3F(arg0->unkC) > 400.0f) { ml_vec3f_set_length(arg0->unkC, 400.0f); } sp54[0] += arg0->unkC[0] * arg2; @@ -173,7 +173,7 @@ void func_8038AF90(Struct_MMM_47D0_0 *arg0, Struct68s *arg1, f32 arg2) { sfxsource_setSampleRate(sp38, 0); } else { sp38 = func_80351758(arg1); - sfxsource_setSampleRate(sp38, (s32) ((gu_sqrtf(arg0->unkC[0]*arg0->unkC[0] + arg0->unkC[1]*arg0->unkC[1] + arg0->unkC[2]*arg0->unkC[2]) / 400.0) * 15000.0)); + sfxsource_setSampleRate(sp38, (s32) ((LENGTH_VEC3F(arg0->unkC) / 400.0) * 15000.0)); } player_getPosition(sp48); func_8035179C(arg1, sp54); diff --git a/src/RBB/ch/boombox.c b/src/RBB/ch/boombox.c index e65b3c3a..3eb592e8 100644 --- a/src/RBB/ch/boombox.c +++ b/src/RBB/ch/boombox.c @@ -165,7 +165,7 @@ int func_8038EF08(Actor *this, f32 (*position)[3], f32 arg2){ sp54[0] = (*position)[0] - this->position_x; sp54[1] = (*position)[1] - this->position_y; sp54[2] = (*position)[2] - this->position_z; - if(180.0 < gu_sqrtf(sp54[0]*sp54[0] + sp54[1]*sp54[1] + sp54[2]*sp54[2])) + if(180.0 < LENGTH_VEC3F(sp54)) ml_vec3f_set_length(&sp54, 150.0f); local->unk20[0] = sp54[0] + this->position_x; diff --git a/src/SM/ch/vegetables.c b/src/SM/ch/vegetables.c index bb4c39d3..b243ec3c 100644 --- a/src/SM/ch/vegetables.c +++ b/src/SM/ch/vegetables.c @@ -408,7 +408,7 @@ void func_80388080(Actor *this){ sp6C[0] = this->unk1C_x - this->position_x; sp6C[1] = this->unk1C_y - this->position_y; sp6C[2] = this->unk1C_z - this->position_z; - if( gu_sqrtf(sp6C[0]*sp6C[0] + sp6C[1]*sp6C[1] + sp6C[2]*sp6C[2] ) < 40.0f){ + if( LENGTH_VEC3F(sp6C) < 40.0f){ ml_vec3f_set_length(sp6C, 400.0f); } else{ diff --git a/src/TTC/ch/blubber.c b/src/TTC/ch/blubber.c index 9d7b1640..f412a7cd 100644 --- a/src/TTC/ch/blubber.c +++ b/src/TTC/ch/blubber.c @@ -126,7 +126,7 @@ void func_8038771C(Actor *this){ void func_80387774(Actor **this_ptr){ ActorLocal_Blubber *local = (ActorLocal_Blubber *)&(*this_ptr)->local; - func_8028F364(local->throw_target_position, local->throw_target_radius, 100.0f, ACTOR_2A_GOLD_BULLION, this_ptr); + player_setCarryObjectPoseInCylinder(local->throw_target_position, local->throw_target_radius, 100.0f, ACTOR_2A_GOLD_BULLION, this_ptr); if( func_80329530(*this_ptr, 200) && bacarry_get_markerId() == MARKER_37_GOLD_BULLION && player_throwCarriedObject() diff --git a/src/TTC/ch/clam.c b/src/TTC/ch/clam.c index a9b7e96b..1225fef1 100644 --- a/src/TTC/ch/clam.c +++ b/src/TTC/ch/clam.c @@ -58,9 +58,7 @@ bool chClam_updateFuncTarget(Actor *this, f32 arg1) { && (egg != 0) && func_80307258(egg->position, this->unk10_25 - 1, this->unk10_18 - 1) != -1 ) { - target_position[0] = egg->position[0]; - target_position[1] = egg->position[1]; - target_position[2] = egg->position[2]; + TUPLE_COPY(target_position, egg->position) phi_f2 = red_feather_dist; } else if( @@ -69,9 +67,7 @@ bool chClam_updateFuncTarget(Actor *this, f32 arg1) { && (red_feather != 0) && func_80307258(red_feather->position, this->unk10_25 - 1, this->unk10_18 - 1) != -1 ){ - target_position[0] = red_feather->position[0]; - target_position[1] = red_feather->position[1]; - target_position[2] = red_feather->position[2]; + TUPLE_COPY(target_position, red_feather->position) phi_f2 = egg_dist; } else if ((func_80329530(this, 1200) != 0) && (func_803292E0(this) != 0)) { diff --git a/src/core1/code_18350.c b/src/core1/code_18350.c index e76e5a5f..06eba603 100644 --- a/src/core1/code_18350.c +++ b/src/core1/code_18350.c @@ -43,8 +43,6 @@ void ml_vec3f_roll_rotate_copy(f32 arg0[3], f32 arg1[3], f32); #define _SQ2(x, y) ((x) * (x) + (y) * (y)) #define _SQ3(x, y, z) (((x) * (x)) + ((y) * (y)) + ((z) * (z))) -#define _SQ3v1(v) (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) -#define _SQ3v2(v1, v2) (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]) /* .code */ f32 func_80255D70(f32 x) @@ -101,9 +99,7 @@ void func_80255E58(f32 vec1[3], f32 vec2[3], f32 vec3[3], f32 vec4[3]) { f32 tmp[3]; - tmp[0] = vec3[0] - vec1[0]; - tmp[1] = vec3[1] - vec1[1]; - tmp[2] = vec3[2] - vec1[2]; + TUPLE_DIFF_COPY(tmp, vec3, vec1) ml_vec3f_yaw_rotate_copy(tmp, tmp, -vec2[1]); ml_vec3f_pitch_rotate_copy( tmp, tmp, -vec2[0]); @@ -118,17 +114,13 @@ f32 func_80255F14(f32 vec1[3], f32 vec2[3]) ml_vec3f_normalize_copy(tmp1, vec1); ml_vec3f_normalize_copy(tmp2, vec2); - return tmp1[0] * tmp2[0] - + tmp1[1] * tmp2[1] - + tmp1[2] * tmp2[2]; + return TUPLE_DOT_PRODUCT(tmp1, tmp2); } //ml_vec3f_cross_product -void ml_crossProduct_vec3f(f32 dst[3], f32 src1[3], f32 src2[3]) +void ml_crossProduct_vec3f(f32 dst[3], f32 vec1[3], f32 vec2[3]) { - dst[0] = src1[1] * src2[2] - src1[2] * src2[1]; - dst[1] = src1[2] * src2[0] - src1[0] * src2[2]; - dst[2] = src1[0] * src2[1] - src1[1] * src2[0]; + TUPLE_CROSS_PRODUCT(dst, vec1, vec2) } void ml_interpolate_vec3f(f32 dst[3], f32 vec1[3], f32 vec2[3], f32 scale) @@ -140,20 +132,14 @@ void ml_interpolate_vec3f(f32 dst[3], f32 vec1[3], f32 vec2[3], f32 scale) f32 ml_dotProduct_vec3f(f32 vec1[3], f32 vec2[3]) { - return vec1[0] * vec2[0] - + vec1[1] * vec2[1] - + vec1[2] * vec2[2]; + return TUPLE_DOT_PRODUCT(vec1, vec2); } f32 ml_distance_vec3f(f32 vec1[3], f32 vec2[3]) { f32 diff[3]; - - diff[0] = vec1[0] - vec2[0]; - diff[1] = vec1[1] - vec2[1]; - diff[2] = vec1[2] - vec2[2]; - - return gu_sqrtf(_SQ3(diff[0], diff[1], diff[2])); + TUPLE_DIFF_COPY(diff, vec1, vec2) + return LENGTH_VEC3F(diff); } f32 func_802560D0(f32 arg0[3], f32 arg1[3], f32 arg2[3]) { @@ -167,18 +153,16 @@ f32 func_802560D0(f32 arg0[3], f32 arg1[3], f32 arg2[3]) { f32 sp20; f32 pad58; - sp24[0] = arg1[0] - arg0[0]; - sp24[1] = arg1[1] - arg0[1]; - sp24[2] = arg1[2] - arg0[2]; - sp20 = gu_sqrtf(sp24[0]*sp24[0] + sp24[1]*sp24[1] + sp24[2]*sp24[2]); + TUPLE_DIFF_COPY(sp24, arg1, arg0) + sp20 = LENGTH_VEC3F(sp24); + if (sp20 < 0.01) { return ml_distance_vec3f(arg0, arg2); } - sp3C[0] = arg2[0] - arg0[0]; - sp3C[1] = arg2[1] - arg0[1]; - sp3C[2] = arg2[2] - arg0[2]; - sp38 = gu_sqrtf(sp3C[0]*sp3C[0] + sp3C[1]*sp3C[1] + sp3C[2]*sp3C[2]); + TUPLE_DIFF_COPY(sp3C, arg2, arg0) + sp38 = LENGTH_VEC3F(sp3C); + if (sp38 < 0.01) { return sp38; } @@ -195,11 +179,8 @@ f32 ml_distanceSquared_vec3f(f32 vec1[3], f32 vec2[3]) { f32 diff[3]; - diff[0] = vec1[0] - vec2[0]; - diff[1] = vec1[1] - vec2[1]; - diff[2] = vec1[2] - vec2[2]; - - return _SQ3(diff[0], diff[1], diff[2]); + TUPLE_DIFF_COPY(diff, vec1, vec2) + return LENGTH_SQ_VEC3F(diff); } void func_802562DC(f32 vec1[3], f32 vec2[3], f32 vec3[3]) @@ -208,23 +189,18 @@ void func_802562DC(f32 vec1[3], f32 vec2[3], f32 vec3[3]) ? vec1[1] * 100 : vec1[1] / -vec2[1]; - vec2[0] *= tmp; - vec2[1] *= tmp; - vec2[2] *= tmp; - - vec3[0] = vec1[0] + vec2[0]; - vec3[1] = vec1[1] + vec2[1]; - vec3[2] = vec1[2] + vec2[2]; + TUPLE_SCALE(vec2, tmp) + TUPLE_ADD_COPY(vec3, vec1, vec2) } -f32 ml_vec2f_length(f32 vec[3]) +f32 ml_vec3f_length_unused(f32 vec[3]) { - return gu_sqrtf(_SQ3(vec[0], vec[1], vec[2])); + return LENGTH_VEC3F(vec); } void ml_vec3f_normalize_copy(f32 arg0[3], f32 arg1[3]) { - f32 length_squared = _SQ3(arg1[0], arg1[1], arg1[2]); + f32 length_squared = LENGTH_SQ_VEC3F(arg1); f32 inverse; if (length_squared != 0) @@ -240,15 +216,12 @@ void ml_vec3f_normalize_copy(f32 arg0[3], f32 arg1[3]) void ml_vec3f_normalize(f32 vec[3]) { - f32 length_squared = _SQ3(vec[0], vec[1], vec[2]); + f32 length_squared = LENGTH_SQ_VEC3F(vec); if (length_squared != 0) { f32 inverse = 1.0 / gu_sqrtf(length_squared); - - vec[0] *= inverse; - vec[1] *= inverse; - vec[2] *= inverse; + TUPLE_SCALE(vec, inverse) } } @@ -277,7 +250,7 @@ void ml_3f_normalize(f32 *x, f32 *y, f32 *z) void ml_vec3f_set_length_copy(f32 dst[3], f32 src[3], f32 len) { - f32 mag = gu_sqrtf(_SQ3(src[0], src[1], src[2])); + f32 mag = LENGTH_VEC3F(src); if (mag != 0) ml_vec3f_scale_copy(dst, src, len / mag); @@ -374,15 +347,12 @@ void ml_vec3f_roll_rotate_copy(f32 dst[3], f32 src[3], f32 roll) void ml_vec3f_set_length(f32 arg0[3], f32 arg1) { - f32 length = gu_sqrtf(_SQ3(arg0[0], arg0[1], arg0[2])); + f32 length = LENGTH_VEC3F(arg0); if (length != 0) { f32 inv_length = arg1 / length; - - arg0[0] = arg0[0] * inv_length; - arg0[1] = arg0[1] * inv_length; - arg0[2] = arg0[2] * inv_length; + TUPLE_SCALE_COPY(arg0, arg0, inv_length) } } @@ -400,16 +370,12 @@ f32 func_80256AB4(f32 x1, f32 y1, f32 x2, f32 y2) //ml_vec3f_sin_of_angle_between_vectors f32 func_80256B54(f32 vec1[3], f32 vec2[3]) { - f32 a = gu_sqrtf(_SQ3v1(vec1)); - f32 b = gu_sqrtf(_SQ3v1(vec2)); - + f32 a = LENGTH_VEC3F(vec1); + f32 b = LENGTH_VEC3F(vec2); f32 tmp[3]; - tmp[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1]; - tmp[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2]; - tmp[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; - - return gu_sqrtf(_SQ3v1(tmp)) / (a * b); + TUPLE_CROSS_PRODUCT(tmp, vec1, vec2) + return LENGTH_VEC3F(tmp) / (a * b); } f32 func_80256C60(f32 vec[3], s32 val) @@ -462,9 +428,7 @@ void func_80256F44(f32 vec1[3], f32 vec2[3], f32 vec3[3], f32 dst[3]) ml_vec3f_pitch_rotate_copy(tmp2, tmp1, vec2[0]); ml_vec3f_yaw_rotate_copy(tmp1, tmp2, vec2[1]); - dst[0] = vec1[0] + tmp1[0]; - dst[1] = vec1[1] + tmp1[1]; - dst[2] = vec1[2] + tmp1[2]; + TUPLE_ADD_COPY(dst, vec1, tmp1) } f32 ml_acosf(f32 x) @@ -702,7 +666,7 @@ void func_80257918(f32 arg0[3], f32 arg1[3], f32 arg2[3], f32 arg3[3]){ f32 sp2C[3]; f32 scale; - scale = _SQ3v2(arg3, arg1) - _SQ3v2(arg3, arg2); + scale = TUPLE_DOT_PRODUCT(arg3, arg1) - TUPLE_DOT_PRODUCT(arg3, arg2); ml_vec3f_scale_copy(sp2C, arg3, scale); ml_vec3f_diff_copy(arg0, arg1, sp2C); } @@ -816,12 +780,10 @@ void func_80257DB0(f32 arg0[3], f32 arg1[3], f32 arg2[3]) void ml_setLength_vec3f(f32 v[3], f32 a) { - if (_SQ3(v[0], v[1], v[2]) > a * a) + if (LENGTH_SQ_VEC3F(v) > a * a) { ml_vec3f_normalize_copy(v, v); - v[0] *= a; - v[1] *= a; - v[2] *= a; + TUPLE_SCALE(v, a) } } @@ -855,10 +817,7 @@ int func_80257F18(f32 src[3], f32 target[3], f32 *yaw) *yaw = 0; - diff[0] = target[0] - src[0]; - diff[1] = target[1] - src[1]; - diff[2] = target[2] - src[2]; - + TUPLE_DIFF_COPY(diff, target, src) h = gu_sqrtf(_SQ2(diff[2], diff[0])); if (h < 0.01) // (f64) 0.01 @@ -883,10 +842,7 @@ int func_8025801C(f32 target[3], f32 *yaw) *yaw = 0; - diff[0] = target[0]; - diff[1] = target[1]; - diff[2] = target[2]; - + TUPLE_COPY(diff, target) h = gu_sqrtf(_SQ2(diff[2], diff[0])); if (h < 0.01) // (f64) 0.01 @@ -1014,7 +970,7 @@ f32 func_802586B0(f32 vec1[3], f32 vec2[3]) return 0; } -f32 func_80258708(f32 vec1[3], f32 vec2[3]) +f32 ml_vec3f_length(f32 vec1[3], f32 vec2[3]) { f32 val = vec1[0] - vec2[0]; f32 dY = vec1[1] - vec2[1]; @@ -1028,7 +984,7 @@ f32 func_80258708(f32 vec1[3], f32 vec2[3]) return 0; } -f32 func_80258780(f32 vec1[3], f32 vec2[3]) +f32 ml_vec3f_length_sq(f32 vec1[3], f32 vec2[3]) { f32 dX = vec1[0] - vec2[0]; f32 dY = vec1[1] - vec2[1]; @@ -1118,10 +1074,7 @@ void func_80258A4C(f32 vec1[3], f32 arg1, f32 vec2[3], f32 *arg3, f32 *arg4, f32 f32 t1[3]; f32 t2[3]; - t1[0] = vec2[0] - vec1[0]; - t1[1] = vec2[1] - vec1[1]; - t1[2] = vec2[2] - vec1[2]; - + TUPLE_DIFF_COPY(t1, vec2, vec1) t1[1] = 0; *arg3 = gu_sqrtf(_SQ3(t1[0], t1[1], t1[2])); @@ -1132,7 +1085,7 @@ void func_80258A4C(f32 vec1[3], f32 arg1, f32 vec2[3], f32 *arg3, f32 *arg4, f32 ml_vec3f_yaw_rotate_copy(t2, t2, arg1); - *arg4 = t1[0] * t2[0] + t1[1] * t2[1] + t1[2] * t2[2]; + *arg4 = TUPLE_DOT_PRODUCT(t1, t2); *arg5 = func_80256AB4(t2[0], t2[2], t1[0], t1[2]); if (*arg4 < 0) @@ -1148,51 +1101,37 @@ void ml_vec3f_clear(f32 dst[3]) void ml_vec3f_copy(f32 dst[3], f32 src[3]) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + TUPLE_COPY(dst, src) } void ml_vec3f_diff_copy(f32 dst[3], f32 src1[3], f32 src2[3]) { - dst[0] = src1[0] - src2[0]; - dst[1] = src1[1] - src2[1]; - dst[2] = src1[2] - src2[2]; + TUPLE_DIFF_COPY(dst, src1, src2) } void ml_vec3f_diff(f32 dst[3], f32 src[3]) { - dst[0] -= src[0]; - dst[1] -= src[1]; - dst[2] -= src[2]; + TUPLE_DIFF(dst, src) } void ml_vec3f_assign(f32 dst[3], f32 x, f32 y, f32 z) { - dst[0] = x; - dst[1] = y; - dst[2] = z; + TUPLE_ASSIGN(dst, x, y, z) } void ml_vec3f_add(f32 dst[3], f32 src1[3], f32 src2[3]) { - dst[0] = src1[0] + src2[0]; - dst[1] = src1[1] + src2[1]; - dst[2] = src1[2] + src2[2]; + TUPLE_ADD_COPY(dst, src1, src2) } void ml_vec3f_scale(f32 vec[3], f32 scale) { - vec[0] *= scale; - vec[1] *= scale; - vec[2] *= scale; + TUPLE_SCALE(vec, scale) } void ml_vec3f_scale_copy(f32 dst[3], f32 src[3], f32 scale) { - dst[0] = src[0] * scale; - dst[1] = src[1] * scale; - dst[2] = src[2] * scale; + TUPLE_SCALE_COPY(dst, src, scale) } void func_80258CDC(f32 vec1[3], f32 vec2[3]) @@ -1204,78 +1143,55 @@ void func_80258CDC(f32 vec1[3], f32 vec2[3]) void ml_vec3w_to_vec3f(f32 dst[3], s32 src[3]) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + TUPLE_COPY(dst, src) } void ml_vec3h_to_vec3f(f32 dst[3], s16 src[3]) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + TUPLE_COPY(dst, src) } void ml_vec3f_to_vec3w(s32 dst[3], f32 src[3]) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + TUPLE_COPY(dst, src) } void ml_vec3f_to_vec3h(s16 dst[3], f32 src[3]) { - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; + TUPLE_COPY(dst, src) } void ml_translate_y_local(f32 position[3], f32 rotation[3], f32 dy) { f32 vec[3]; - vec[0] = 0; - vec[1] = dy; - vec[2] = 0; - + TUPLE_ASSIGN(vec, 0, dy, 0) ml_vec3f_pitch_rotate_copy(vec, vec, rotation[0]); ml_vec3f_yaw_rotate_copy(vec, vec, rotation[1]); - position[0] += vec[0]; - position[1] += vec[1]; - position[2] += vec[2]; + TUPLE_ADD(position, vec) } void ml_translate_z_local(f32 dst[3], f32 src[3], f32 dz) { f32 vec[3]; - vec[0] = 0; - vec[1] = 0; - vec[2] = dz; - + TUPLE_ASSIGN(vec, 0, 0, dz) ml_vec3f_pitch_rotate_copy(vec, vec, src[0]); ml_vec3f_yaw_rotate_copy(vec, vec, src[1]); - dst[0] += vec[0]; - dst[1] += vec[1]; - dst[2] += vec[2]; + TUPLE_ADD(dst, vec) } void ml_translate_x_local(f32 dst[3], f32 src[3], f32 dx) { f32 vec[3]; - vec[0] = dx; - vec[1] = 0; - vec[2] = 0; - + TUPLE_ASSIGN(vec, dx, 0, 0) ml_vec3f_pitch_rotate_copy(vec, vec, src[0]); ml_vec3f_yaw_rotate_copy(vec, vec, src[1]); - dst[0] += vec[0]; - dst[1] += vec[1]; - dst[2] += vec[2]; + TUPLE_ADD(dst, vec) } void func_8025901C(f32 arg0, f32 arg1[3], f32 arg2[3], f32 arg3){ @@ -1333,46 +1249,43 @@ f32 mlDiffDegF(f32 arg0, f32 arg1) return diff; } -bool func_80259254(f32 vec[3], f32 x, f32 z, f32 val) +bool ml_vec3f_point_within_horizontal_distance(f32 vec[3], f32 x, f32 z, f32 distance) +{ + f32 diff[3]; + + diff[0] = x - vec[0]; + diff[1] = 0; + diff[2] = z - vec[2]; + + return _SQ3(diff[0], 0, diff[2]) <= distance * distance; +} + +bool ml_vec3f_within_horizontal_distance(f32 vec1[3], f32 vec2[3], f32 distance) +{ + f32 diff[3]; + + diff[0] = vec1[0] - vec2[0]; + diff[2] = vec1[2] - vec2[2]; + + return _SQ3(diff[0], 0, diff[2]) < distance * distance; +} + +bool ml_vec3w_within_horizontal_distance(s32 vec1[3], s32 vec2[3], s32 distance) +{ + s32 diff[3]; + + diff[0] = vec1[0] - vec2[0]; + diff[2] = vec1[2] - vec2[2]; + + return _SQ3(diff[0], 0, diff[2]) < distance * distance; +} + +bool ml_vec3f_within_distance(f32 vec1[3], f32 vec2[3], f32 distance) { f32 t[3]; - t[0] = x - vec[0]; - t[1] = 0; - t[2] = z - vec[2]; - - return _SQ3(t[0], 0, t[2]) <= val * val; -} - -bool func_802592C4(f32 v1[3], f32 v2[3], f32 a) -{ - f32 t[3]; - - t[0] = v1[0] - v2[0]; - t[2] = v1[2] - v2[2]; - - return _SQ3(t[0], 0, t[2]) < a * a; -} - -bool func_80259328(s32 v1[3], s32 v2[3], s32 a) -{ - s32 t[3]; - - t[0] = v1[0] - v2[0]; - t[2] = v1[2] - v2[2]; - - return _SQ3(t[0], 0, t[2]) < a * a; -} - -bool func_80259384(f32 v1[3], f32 v2[3], f32 a) -{ - f32 t[3]; - - t[0] = v2[0] - v1[0]; - t[1] = v2[1] - v1[1]; - t[2] = v2[2] - v1[2]; - - return _SQ3(t[0], t[1], t[2]) <= a * a; + TUPLE_DIFF_COPY(t, vec2, vec1) + return LENGTH_SQ_VEC3F(t) <= distance * distance; } bool func_80259400(f32 a0) @@ -1447,7 +1360,7 @@ f32 func_80259554(f32 dst[3], f32 vec1[3], f32 vec2[3], f32 vec3[3]) ml_vec3f_diff_copy(tmp1, vec2, vec1); ml_vec3f_diff_copy(tmp2, vec3, vec1); - mag = gu_sqrtf(_SQ3v1(tmp2)); + mag = LENGTH_VEC3F(tmp2); if (mag == 0.0) // f64 { @@ -1459,7 +1372,7 @@ f32 func_80259554(f32 dst[3], f32 vec1[3], f32 vec2[3], f32 vec3[3]) ml_vec3f_set_length_copy(tmp1, tmp1, ml_cos_deg(tmp3) * mag); - if (_SQ3v2(tmp1, tmp2) > 0) + if (TUPLE_DOT_PRODUCT(tmp1, tmp2) > 0) ml_vec3f_add(dst, vec1, tmp1); else ml_vec3f_diff_copy(dst, vec1, tmp1); diff --git a/src/core2/ba/marker.c b/src/core2/ba/marker.c index ff8185e2..61bca831 100644 --- a/src/core2/ba/marker.c +++ b/src/core2/ba/marker.c @@ -14,7 +14,7 @@ extern void func_802A6388(f32); extern f32 chwadingboots_802D6E4C(Actor *); extern void set_turbo_duration(f32); extern f32 chtrainers_getDuration(Actor *); -extern int func_80259254(f32 vec[3], f32 x, f32 z, f32 val); +extern int ml_vec3f_point_within_horizontal_distance(f32 vec[3], f32 x, f32 z, f32 val); extern void func_802EE354(Actor *, s32, s32, s32, f32, f32, f32, f32 arg8[3], s32, f32 arg10[2]); extern void func_8035644C(s32); extern void func_8035646C(s32 arg0); diff --git a/src/core2/ba/model.c b/src/core2/ba/model.c index 64c86696..c907e327 100644 --- a/src/core2/ba/model.c +++ b/src/core2/ba/model.c @@ -271,9 +271,7 @@ void baModel_setVisible(s32 arg0){ void baModel_802921D4(f32 arg0[3]){ if(player_getWaterState() == BSWATERGROUP_0_NONE){ D_8037C150.unk0 = 1; - D_8037C150.unk4[0] = arg0[0]; - D_8037C150.unk4[1] = arg0[1]; - D_8037C150.unk4[2] = arg0[2]; + TUPLE_COPY(D_8037C150.unk4, arg0) } } diff --git a/src/core2/ba/physics.c b/src/core2/ba/physics.c index 659be176..a575dfce 100644 --- a/src/core2/ba/physics.c +++ b/src/core2/ba/physics.c @@ -3,8 +3,6 @@ #include "variables.h" #include "core2/ba/physics.h" -#define _SQ3v1(v) (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) - extern f32 ml_sin_deg(f32); extern f32 ml_dotProduct_vec3f(f32[3], f32[3]); extern void func_80256D0C(f32, f32, f32, f32, f32, f32 *, f32 *, f32 *); @@ -118,7 +116,8 @@ void __baphysics_update_no_gravity(void){ //update velocity ml_vec3f_diff_copy(sp24, baphysics_target_velocity, s_player_velocity); ml_vec3f_scale(sp24, time_getDelta()*baphysics_acceleration); - if(_SQ3v1(sp24) < 0.02){ + + if (LENGTH_SQ_VEC3F(sp24) < 0.02) { ml_vec3f_copy(s_player_velocity, baphysics_target_velocity); } else{ diff --git a/src/core2/ch/badShad.c b/src/core2/ch/badShad.c index 3591f26a..1a79894a 100644 --- a/src/core2/ch/badShad.c +++ b/src/core2/ch/badShad.c @@ -90,7 +90,7 @@ f32 func_802D7038(Actor *this) { void func_802D7124(Actor *actor, f32 arg1) { f32 vp[3]; - viewport_getPosition_vec3f(&vp); + viewport_getPosition_vec3f(vp); if ((actor->position[0] - vp[0]) * (actor->position[0] - vp[0]) + (actor->position[2] - vp[2]) * (actor->position[2] - vp[2]) < 12250000.0f) { func_802D729C(actor, arg1); } diff --git a/src/core2/code_D89E0.c b/src/core2/ch/bat.c similarity index 66% rename from src/core2/code_D89E0.c rename to src/core2/ch/bat.c index ed269305..ec6d3137 100644 --- a/src/core2/code_D89E0.c +++ b/src/core2/ch/bat.c @@ -6,15 +6,26 @@ extern f32 mapModel_getFloorY(f32[3]); extern f32 func_80257204(f32, f32, f32, f32); -typedef struct { - f32 unk0; - f32 unk4; -} ActorLocal_Core2_D89E0; +typedef enum { + CH_BAT_STATE_ROOSTING = 1, + CH_BAT_STATE_EXIT_ROOST = 2, + CH_BAT_STATE_CHASE = 3, + CH_BAT_STATE_ROAM = 4, + CH_BAT_STATE_FLY_HOME = 5, + CH_BAT_STATE_ENTER_ROOST = 6, + CH_BAT_STATE_FALL = 7, + CH_BAT_STATE_DIE = 8 +} ChBatState; -void func_80360828(Actor *this); +typedef struct { + f32 cooldown; //cooldown timer after attacking the player + f32 roost_yaw; +} ChBatLocal; + +void chbat_update(Actor *this); /* .data */ -ActorAnimationInfo D_80373090[] = { +ActorAnimationInfo sChBatAnimations[] = { {0, 0.0f}, { ASSET_AE_ANIM_BAT_ROOST, 12.0f}, { ASSET_AD_ANIM_BAT_TAKE_FLIGHT, 0.3f}, @@ -26,53 +37,53 @@ ActorAnimationInfo D_80373090[] = { { ASSET_2AA_ANIM_BAT_DIE, 0.85f}, }; -ActorInfo D_803730D8 = { +ActorInfo gChBat = { MARKER_127_BAT, ACTOR_163_BAT, ASSET_3CA_MODEL_BAT, - 0x1, D_80373090, - func_80360828, func_80326224, actor_draw, + CH_BAT_STATE_ROOSTING, sChBatAnimations, + chbat_update, func_80326224, actor_draw, 2500, 0, 0.9f, 0 }; /* .code */ -void func_8035F970(Actor *this){ - subaddie_set_state(this, 1); +void chbat_roost(Actor *this){ + subaddie_set_state(this, CH_BAT_STATE_ROOSTING); actor_loopAnimation(this); } -void func_8035F99C(Actor *this){ +void chbat_exitRoost(Actor *this){ if(!volatileFlag_get(VOLATILE_FLAG_C1_IN_FINAL_CHARACTER_PARADE)){ - subaddie_set_state_with_direction(this, 2, 0.01f, 1); + subaddie_set_state_with_direction(this, CH_BAT_STATE_EXIT_ROOST, 0.01f, 1); actor_playAnimationOnce(this); this->actor_specific_1_f = 5.0f; FUNC_8030E8B4(SFX_419_UNKNOWN, 1.0f, 28000, this->position, 0x4e2, 0x9c4); } } -void func_8035FA0C(Actor *this){ - subaddie_set_state(this, 3); +void chbat_chase(Actor *this){ + subaddie_set_state(this, CH_BAT_STATE_CHASE); actor_loopAnimation(this); this->actor_specific_1_f = 5.0f; } -void func_8035FA48(Actor *this){ - subaddie_set_state(this, 4); +void chbat_roam(Actor *this){ + subaddie_set_state(this, CH_BAT_STATE_ROAM); actor_loopAnimation(this); } -void func_8035FA74(Actor *this){ - ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local; - this->yaw_ideal = local->unk4; - subaddie_set_state(this, 5); +void chbat_flyHome(Actor *this){ + ChBatLocal *local = (ChBatLocal *)&this->local; + this->yaw_ideal = local->roost_yaw; + subaddie_set_state(this, CH_BAT_STATE_FLY_HOME); actor_loopAnimation(this); } -void func_8035FAA8(Actor *this){ - subaddie_set_state_with_direction(this, 6, 0.99f, 0); +void chbat_enterRoost(Actor *this){ + subaddie_set_state_with_direction(this, CH_BAT_STATE_ENTER_ROOST, 0.99f, 0); actor_playAnimationOnce(this); } -void func_8035FAE0(Actor *this){ - subaddie_set_state_with_direction(this, 7, 0.01f, 1); +void chBat_fall(Actor *this){ + subaddie_set_state_with_direction(this, CH_BAT_STATE_FALL, 0.01f, 1); actor_loopAnimation(this); this->yaw += 180.0f; this->actor_specific_1_f = 20.0f; @@ -80,7 +91,7 @@ void func_8035FAE0(Actor *this){ } -int func_8035FB48(Actor * this, s32 dist){ +int chbat_isWithinHorzontalRadiusOfHome(Actor * this, s32 dist){ f32 f0 = this->position_x - this->unk1C_x; f32 f2 = this->position_z - this->unk1C_z; if(f0*f0 + f2*f2 < dist*dist) @@ -89,7 +100,7 @@ int func_8035FB48(Actor * this, s32 dist){ return 0; } -bool func_8035FBA8(Actor *arg0, s32 arg1) { +bool chbat_nearHome(Actor *arg0, s32 arg1) { if( (arg0->position[1] < ( arg0->unk1C[1] + 0.5)) && (( arg0->unk1C[1] - 0.5) < arg0->position[1]) ) { @@ -98,17 +109,17 @@ bool func_8035FBA8(Actor *arg0, s32 arg1) { return FALSE; } -void func_8035FC20(Actor *this, f32 arg1, f32 arg2){ - if(this->position[1] < arg1){ - this->position[1] += arg2; - if(arg1 < this->position[1]){ - this->position[1] = arg1; +void chBat_updateHeight(Actor *this, f32 target_height, f32 velocity){ + if(this->position[1] < target_height){ + this->position[1] += velocity; + if(target_height < this->position[1]){ + this->position[1] = target_height; } } - else if(arg1 < this->position[1]){ - this->position[1] -= arg2; - if(this->position[1] < arg1){ - this->position[1] = arg1; + else if(target_height < this->position[1]){ + this->position[1] -= velocity; + if(this->position[1] < target_height){ + this->position[1] = target_height; } } } @@ -121,13 +132,8 @@ bool func_8035FC98(Actor *this, f32 arg1){ if(this->unk38_0) return FALSE; - sp28[0] = this->position[0]; - sp28[1] = this->position[1]; - sp28[2] = this->position[2]; - - sp1C[0] = sp28[0]; - sp1C[1] = sp28[1]; - sp1C[2] = sp28[2]; + TUPLE_COPY(sp28, this->position); + TUPLE_COPY(sp1C, sp28); sp1C[1] += arg1; if (func_80309B48(sp28, sp1C, sp34, 0x5E0000) != NULL) @@ -145,7 +151,7 @@ bool func_8035FD28(Actor *this){ return TRUE; } -bool func_8035FDA4(Actor *this) { +bool chbat_nearPlayer(Actor *this) { f32 sp24[3]; player_getPosition(sp24); @@ -205,17 +211,17 @@ void func_8035FFAC(Actor *this, f32 arg1){ } } -void func_80360044(Actor *this) { - f32 var_f0; +void chbat_updateFlyingRoll(Actor *this) { + f32 d_yaw; - var_f0 = this->yaw_ideal - this->yaw; - if (var_f0 >= 180.0f) { - var_f0 -= 360.0f; + d_yaw = this->yaw_ideal - this->yaw; + if (d_yaw >= 180.0f) { + d_yaw -= 360.0f; } - if (var_f0 < -180.0f) { - var_f0 += 360.0f; + if (d_yaw < -180.0f) { + d_yaw += 360.0f; } - this->velocity[2] = -var_f0; + this->velocity[2] = -d_yaw; if (( this->roll < this->velocity[2]) && ( this->roll < 55.0f)) { this->roll += 2.0f; } @@ -224,7 +230,7 @@ void func_80360044(Actor *this) { } } -void func_80360130(Actor *this){ +void chbat_updateRollTowardsZero(Actor *this){ if(0.0f < this->roll){ this->roll -= 2.0; } @@ -236,11 +242,11 @@ void func_80360130(Actor *this){ bool func_80360198(Actor *this) { f32 var_f16; f64 temp_f0; - f64 var_f0; - f64 var_f0_2; + f64 d_yaw; + f64 d_yaw_2; func_80328FB0(this, 5.0f); - func_80360044(this); + chbat_updateFlyingRoll(this); this->actor_specific_1_f += (this->velocity[1] * 0.45) - (0.001 * this->actor_specific_1_f); if (this->actor_specific_1_f > 13.0) { this->actor_specific_1_f = 13.0f; @@ -279,24 +285,22 @@ f32 func_803603AC(Actor *this, s32 arg1, u8 arg2){ f32 dy; f32 D1, D2; f32 unused; - f32 sp20[3]; + f32 player_position[3]; switch (arg2) { case 1: - player_getPosition(sp20); + player_getPosition(player_position); break; case 2: - sp20[0] = this->unk1C[0]; - sp20[1] = this->unk1C[1]; - sp20[2] = this->unk1C[2]; + TUPLE_COPY(player_position, this->unk1C); break; } - D1 = SQ(this->position[0] - sp20[0]); - D2 = SQ(this->position[2] - sp20[2]); + D1 = SQ(this->position[0] - player_position[0]); + D2 = SQ(this->position[2] - player_position[2]); - dy = this->position[1] - sp20[1] - arg1; + dy = this->position[1] - player_position[1] - arg1; if(dy == 0.0 || D1 + D2 == 0.0) return 0.0f; @@ -322,18 +326,19 @@ int func_803604E8(Actor *this){ return 1; } -bool func_8036054C(Actor *this) { +bool chbat_updateRoam(Actor *this) { s32 phi_v0; s32 phi_s1; s32 phi_s2; if (this->lifetime_value == 0.0f) { + // fly towards home if lifetime is done this->yaw_ideal = func_80257204(this->position[0], this->position[2], this->unk1C[0], this->unk1C[2]); func_8035FFAC(this, func_803603AC(this, -110, 2)); } else{ - func_80328FB0(this, 5.0f); - func_80360044(this); + func_80328FB0(this, 5.0f); //update yaw + chbat_updateFlyingRoll(this); if (func_80329480(this) != 0) { this->lifetime_value = 0.0f; } else { @@ -346,9 +351,9 @@ bool func_8036054C(Actor *this) { phi_s1 = 0; do{ if (this->unk38_0) { - phi_v0 = func_80329140(this, (s32) this->yaw_ideal, 0xC8); + phi_v0 = func_80329140(this, (s32) this->yaw_ideal, 200); } else { - phi_v0 = func_80329078(this, (s32) this->yaw_ideal, 0xC8); + phi_v0 = func_80329078(this, (s32) this->yaw_ideal, 200); } if(phi_v0 == 0){ @@ -371,64 +376,62 @@ bool func_8036054C(Actor *this) { return TRUE; } -void func_80360790(ActorMarker *this_marker, ActorMarker *other_marker){ +void chBat_dieCollision(ActorMarker *this_marker, ActorMarker *other_marker){ Actor *this = marker_getActor(this_marker); - ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local; - func_8035FAE0(this); - local->unk0 = 0.0f; + ChBatLocal *local = (ChBatLocal *)&this->local; + chBat_fall(this); + local->cooldown = 0.0f; this->marker->collidable = FALSE; FUNC_8030E8B4(SFX_115_BUZZBOMB_DEATH, 1.3f, 26000, this->position, 1250, 2500); } -void func_803607FC(ActorMarker *this_marker, ActorMarker *other_marker){ +void chBat_attackCollision(ActorMarker *this_marker, ActorMarker *other_marker){ Actor *this = marker_getActor(this_marker); - ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local; - local->unk0 = 0.8f; + ChBatLocal *local = (ChBatLocal *)&this->local; + local->cooldown = 0.8f; } -void func_80360828(Actor *this){ - f32 sp3C = time_getDelta(); - ActorLocal_Core2_D89E0 *local = (ActorLocal_Core2_D89E0 *)&this->local; +void chbat_update(Actor *this){ + f32 dt = time_getDelta(); + ChBatLocal *local = (ChBatLocal *)&this->local; f32 sp34; if(!this->initialized){ this->initialized = TRUE; - marker_setCollisionScripts(this->marker, NULL, func_803607FC, func_80360790); + marker_setCollisionScripts(this->marker, NULL, chBat_attackCollision, chBat_dieCollision); this->unk38_0 = FALSE; this->actor_specific_1_f = 0.0f; this->velocity_x = 0.0f; - this->unk1C_x = this->position_x; - this->unk1C_y = this->position_y; - this->unk1C_z = this->position_z; - local->unk4 = this->yaw; + TUPLE_COPY(this->unk1C, this->position); // set roost position + local->roost_yaw = this->yaw; } - if(local->unk0 <= 0.0){ - local->unk0 = 0.0f; + if(local->cooldown <= 0.0){ + local->cooldown = 0.0f; }else{//L80360910 - local->unk0 -= sp3C; + local->cooldown -= dt; return; } switch(this->state){ - case 1: //L80360918 - if(func_8035FDA4(this)){ - func_8035F99C(this); + case CH_BAT_STATE_ROOSTING: //L80360918 + if(chbat_nearPlayer(this)){ + chbat_exitRoost(this); } break; - case 2: //L80360938 + case CH_BAT_STATE_EXIT_ROOST: //L80360938 if( 0.98 < animctrl_getAnimTimer(this->animctrl) || !func_8035FD28(this) ){ - func_8035FA0C(this); + chbat_chase(this); } break; - case 3: //L8036097C + case CH_BAT_STATE_CHASE: //L8036097C animctrl_setDuration(this->animctrl, 1.2 - this->velocity_y); - if(!func_8035FDA4(this)){ - func_8035FA48(this); + if(!chbat_nearPlayer(this)){ + chbat_roam(this); } else if(!func_803604E8(this)){ - func_8035FA48(this); + chbat_roam(this); this->unk38_31 = 0x3C; } else{ @@ -442,45 +445,45 @@ void func_80360828(Actor *this){ func_8030E878(SFX_2_CLAW_SWIPE, randf2(1.0f, 1.2f), 10000, this->position, 833.0f, 2500.0f); } break; - case 4: //L80360A9C - if(func_8035FDA4(this)){ - func_8035FA0C(this); - } else if(func_8035FB48(this, 0x14)){ - func_8035FA74(this); + case CH_BAT_STATE_ROAM: //L80360A9C + if(chbat_nearPlayer(this)){ + chbat_chase(this); + } else if(chbat_isWithinHorzontalRadiusOfHome(this, 20)){ + chbat_flyHome(this); } else{ - func_8036054C(this); + chbat_updateRoam(this); }//L80360AE8 if(actor_animationIsAt(this, 0.5f)){ func_8030E878(SFX_2_CLAW_SWIPE, randf2(1.0f, 1.2f), 10000, this->position, 833.0f, 2500.0f); } break; - case 5: //L80360B3C - if(func_8035FDA4(this)){ - func_8035FA0C(this); - } else if(func_8035FBA8(this, 1)){ - func_8035FAA8(this); + case CH_BAT_STATE_FLY_HOME: //L80360B3C + if(chbat_nearPlayer(this)){ + chbat_chase(this); + } else if(chbat_nearHome(this, 1)){ + chbat_enterRoost(this); } else{ func_80328FB0(this, 5.0f); - func_8035FC20(this, this->unk1C_y, 2.0f); - func_80360130(this); - }//L80360BA0 + chBat_updateHeight(this, this->unk1C_y, 2.0f); + chbat_updateRollTowardsZero(this); + } if(actor_animationIsAt(this, 0.5f)){ func_8030E878(SFX_2_CLAW_SWIPE, randf2(1.0f, 1.2f), 10000, this->position, 833.0f, 2500.0f); } break; - case 6: //L80360BF4 + case CH_BAT_STATE_ENTER_ROOST: if(animctrl_getAnimTimer(this->animctrl) < 0.01){ - func_8035F970(this); + chbat_roost(this); } break; - case 7: //L80360C28 + case CH_BAT_STATE_FALL: //L80360C28 sp34 = time_getDelta(); func_8032CA80(this, this->unk38_0 ? 0x13 : 0x4); if(func_8035FC98(this, this->velocity_x * sp34)){ this->position_y = mapModel_getFloorY(this->position); - subaddie_set_state_with_direction(this, 8, 0.01f, 1); + subaddie_set_state_with_direction(this, CH_BAT_STATE_DIE, 0.01f, 1); actor_playAnimationOnce(this); func_8030E6A4(SFX_1F_HITTING_AN_ENEMY_3, 1.2f, 32200); } @@ -489,7 +492,7 @@ void func_80360828(Actor *this){ this->velocity_x -= 1600.0f * sp34; } break; - case 8: //L80360CF0 + case CH_BAT_STATE_DIE: //L80360CF0 if(actor_animationIsAt(this, 0.3f)){ func_80326310(this); } diff --git a/src/core2/ch/climbBase.c b/src/core2/ch/climbBase.c index d4446371..6859a7b0 100644 --- a/src/core2/ch/climbBase.c +++ b/src/core2/ch/climbBase.c @@ -4,7 +4,7 @@ void func_802D77D4(Actor *this); -extern void func_8028F738(f32[3], f32[3], f32, u32); +extern void player_setClimbParams(f32[3], f32[3], f32, u32); extern f32 func_80258640(f32[3], f32[3]); typedef struct { @@ -78,7 +78,7 @@ void func_802D77D4(Actor *this) { if (((sp4C[0] * sp4C[0]) + (sp4C[2] * sp4C[2])) < (sp3C * sp3C)) { if ((this->position[1] < sp40[1]) && (sp40[1] <= local->unk0[1])) { if (volatileFlag_get(VOLATILE_FLAG_2_FF_IN_MINIGAME) == 0) { - func_8028F738(this->position, local->unk0, (f32)this->unkF4_8, local->unkC); + player_setClimbParams(this->position, local->unk0, (f32)this->unkF4_8, local->unkC); } } } diff --git a/src/core2/ch/crab.c b/src/core2/ch/crab.c index 6410b034..85be3490 100644 --- a/src/core2/ch/crab.c +++ b/src/core2/ch/crab.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern bool func_80259254(f32[3], f32, f32, f32); +extern bool ml_vec3f_point_within_horizontal_distance(f32[3], f32, f32, f32); /* .data */ ActorAnimationInfo chCrabAnimations[] ={ @@ -185,7 +185,7 @@ void __chCrab_die(ActorMarker *marker, ActorMarker *other){ this->unk138_27 = 1; marker_despawn(marker); if( map_get() == MAP_B_CC_CLANKERS_CAVERN - && func_80259254(this->position, 13778.0f, 0.0f, 3000.0f) + && ml_vec3f_point_within_horizontal_distance(this->position, 13778.0f, 0.0f, 3000.0f) ) { this->depth_mode = MODEL_RENDER_DEPTH_COMPARE; if( !jiggyscore_isCollected(JIGGY_16_CC_SNIPPETS) diff --git a/src/core2/ch/snowman.c b/src/core2/ch/snowman.c index 50e179ec..986ae9f6 100644 --- a/src/core2/ch/snowman.c +++ b/src/core2/ch/snowman.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern int func_802592C4(f32[3], f32[3], f32); +extern int ml_vec3f_within_horizontal_distance(f32[3], f32[3], f32); extern void func_802EFA20(ParticleEmitter *, f32, f32); extern void subaddie_set_state_with_direction(Actor *, s32, f32, s32); extern void func_80328FB0(Actor *, f32); @@ -198,7 +198,7 @@ int __chSnowman_CCW_playerInProtectedZone(void){ f32 player_position[3]; if(map_get() == MAP_46_CCW_WINTER){ player_getPosition(player_position); - if(func_802592C4(player_position, ccw_no_attack_zone, 900.0f)) + if(ml_vec3f_within_horizontal_distance(player_position, ccw_no_attack_zone, 900.0f)) return 1; } return 0; diff --git a/src/core2/ch/termite.c b/src/core2/ch/termite.c index 4784659b..aa1c318a 100644 --- a/src/core2/ch/termite.c +++ b/src/core2/ch/termite.c @@ -57,7 +57,7 @@ void __chTermite_updateWalkSFX(Actor *this) { f32 sp24[3]; f32 sp20; - viewport_getPosition_vec3f(&sp24); + viewport_getPosition_vec3f(sp24); sp20 = ml_map_f( (300.0f - sp24[0])*(300.0f - sp24[0]) + (this->position[1] - sp24[1])*(this->position[1] - sp24[1]) + (-858.0f - sp24[2])*(-858.0f - sp24[2]) , 7617600.0f, 8236900.0f , 8000.0f, 1000.0f diff --git a/src/core2/code_39D0.c b/src/core2/code_39D0.c index c69d34ca..8c5af87c 100644 --- a/src/core2/code_39D0.c +++ b/src/core2/code_39D0.c @@ -8,7 +8,7 @@ #include -extern int func_80259254(f32 vec[3], f32 x, f32 z, f32 val); +extern int ml_vec3f_point_within_horizontal_distance(f32 vec[3], f32 x, f32 z, f32 val); extern f32 player_getYaw(void); /* .bss */ @@ -179,7 +179,7 @@ int func_8028B094(void){ int player_isInHorizontalRadius(f32 arg0[3], f32 arg1){ f32 sp1C[3]; _player_getPosition(sp1C); - return func_80259254(sp1C, arg0[0], arg0[2], arg1); + return ml_vec3f_point_within_horizontal_distance(sp1C, arg0[0], arg0[2], arg1); } s32 func_8028B120(void){return 0;} diff --git a/src/core2/code_7060.c b/src/core2/code_7060.c index 1577f749..b63ce46f 100644 --- a/src/core2/code_7060.c +++ b/src/core2/code_7060.c @@ -22,7 +22,7 @@ extern void func_8029B73C(f32 arg0[3], f32 arg1, f32 arg2, f32 arg3, f32 arg4); bool func_8028F4B8(f32 arg0[3], f32 arg1, f32 arg2); bool func_8028F620(f32 arg0[3], f32 arg1, f32 arg2); void func_8028F85C(f32 arg0[3]); -void func_8028F8A4(f32 rotation[3]); +void player_setRotation(f32 rotation[3]); void func_8028F918(s32 arg0); @@ -46,15 +46,15 @@ f32 D_8037BFCC; f32 D_8037BFD0; /* .code */ -bool func_8028DFF0(s32 arg0, s32 arg1[3]) { +bool func_8028DFF0(s32 arg0, s32 position[3]) { if (arg0 >= 0x80) { - arg1[0] = func_802E4A98(arg0); - arg1[1] = func_802E4AAC(arg0); - arg1[2] = func_802E4AC0(arg0); + position[0] = func_802E4A98(arg0); + position[1] = func_802E4AAC(arg0); + position[2] = func_802E4AC0(arg0); return TRUE; } else{ - return _nodeProp_findPositionFromActorId(func_803084F0(arg0), arg1); + return _nodeProp_findPositionFromActorId(func_803084F0(arg0), position); } } @@ -151,7 +151,7 @@ void func_8028E0F0(s32 arg0, s32 arg1[3]) { bs_setState(badrone_goto(sp7C, 1.0f, func_8028E0B0, NULL)); return; } - func_8028F85C(&sp7C); + func_8028F85C(sp7C); func_80295A8C(); bsStoredState_setTrot(FALSE); miscFlag_clear(MISC_FLAG_16); @@ -192,7 +192,7 @@ void func_8028E4B0(void) { return; } if (sp20 == 0x63) { - func_8028F85C(&D_8037BFC0); + func_8028F85C(D_8037BFC0); yaw_set(D_8037BFCC); D_8037BFBC = (s32) D_8037BFD0; D_8037BFB8 = 1; @@ -213,12 +213,12 @@ void func_8028E4B0(void) { D_80363694--; if (D_80363694 == 0) { func_8028F85C(D_80363698); - func_8028F8A4(D_803636A4); + player_setRotation(D_803636A4); } } if (D_803636B0) { D_803636B0 = FALSE; - func_8028F85C(&D_803636B4); + func_8028F85C(D_803636B4); } } @@ -668,7 +668,7 @@ bool player_setCarryObjectPoseInHorizontalRadius(f32 position[3], f32 radius, en } //sets carry actor if player is within a cylinder around a point -bool func_8028F364(f32 position[3], f32 radius, f32 vert_range, enum actor_e actor_id, Actor **arg4) { +bool player_setCarryObjectPoseInCylinder(f32 position[3], f32 radius, f32 vert_range, enum actor_e actor_id, Actor **arg4) { if (player_isInVerticalRange(position, vert_range)) { return player_setCarryObjectPoseInHorizontalRadius(position, radius, actor_id, arg4); } @@ -774,7 +774,7 @@ void player_stateTimer_set(enum state_timer_e timer_id, f32 value){ stateTimer_set(timer_id, value); } -void func_8028F738(f32 bottom[3], f32 top[3], f32 radius, u32 arg3){ +void player_setClimbParams(f32 bottom[3], f32 top[3], f32 radius, u32 arg3){ climbSet(bottom, top, radius, arg3); } @@ -824,7 +824,7 @@ void func_8028F85C(f32 arg0[3]){ cameraMode_update(); } -void func_8028F8A4(f32 rotation[3]){ +void player_setRotation(f32 rotation[3]){ pitch_setIdeal(rotation[0]); yaw_setIdeal(rotation[1]); roll_setIdeal(rotation[2]); @@ -875,8 +875,8 @@ void func_8028FA34(enum actor_e arg0, Actor *arg1){ func_8028DEEC(arg0, arg1); } -void func_8028FA54(f32 arg0[3]){ - set_throw_target_position(arg0); +void player_setThrowTargetPosition(f32 position[3]){ + set_throw_target_position(position); } void func_8028FA74(f32 dst[3]){ @@ -897,7 +897,7 @@ void func_8028FAB0(f32 arg0[3]){ func_80298564(diff); } -void func_8028FAEC(f32 rotation[3]){ +void player_setIdealRotation(f32 rotation[3]){ pitch_setIdeal(rotation[0]); yaw_setIdeal(rotation[1]); roll_setIdeal(rotation[2]); diff --git a/src/core2/code_71820.c b/src/core2/code_71820.c index 3afcae8c..a3562a72 100644 --- a/src/core2/code_71820.c +++ b/src/core2/code_71820.c @@ -4,7 +4,6 @@ #include #define _SQ3(x, y, z) (((x) * (x)) + ((y) * (y)) + ((z) * (z))) -#define _SQ3v1(v) (v[0] * v[0] + v[1] * v[1] + v[2] * v[2]) /*.code*/ void func_802F87B0(struct6s *this){ @@ -28,8 +27,7 @@ void func_802F87B0(struct6s *this){ sp4C[1] = randf2(200.0f, 500.0f); sp4C[2] = -f20; - if(gu_sqrtf(_SQ3v1((&this->unkC))) < 5.0f) - { + if (LENGTH_VEC3F((&this->unkC)) < 5.0f) { ml_vec3f_yaw_rotate_copy(sp4C, sp4C, randf2(0.0f, 360.0f)); } else{ diff --git a/src/core2/code_7AF80.c b/src/core2/code_7AF80.c index b5fe619a..7d2ef178 100644 --- a/src/core2/code_7AF80.c +++ b/src/core2/code_7AF80.c @@ -1759,7 +1759,7 @@ s32 func_80306EF4(s32 arg0[3], s32 arg1, u32 arg2) { for(var_s0 = var_s1->unk8; var_s0 < var_s1->unk8 + var_s1->count; var_s0++){ if( (var_s0->unk10_3 & arg2) && (temp_s4 >= var_s0->position[1]) && (temp_s6 < var_s0->position[1]) - && (func_80259328(arg0, (void *) var_s0, var_s0->radius)) + && (ml_vec3w_within_horizontal_distance(arg0, (void *) var_s0, var_s0->radius)) ) { return var_s1 - D_8036A9C8; } @@ -1769,7 +1769,7 @@ s32 func_80306EF4(s32 arg0[3], s32 arg1, u32 arg2) { for(var_s0 = var_s1->unk8; var_s0 < var_s1->unk8 + var_s1->count; var_s0++){ if( (var_s0->unk10_3 & arg2) && ((var_s0->unk10_3 & 2) || ((temp_s4 >= var_s0->position[1]) && (temp_s6 < var_s0->position[1]))) - && (func_80259328(arg0, (void *) var_s0, var_s0->radius)) + && (ml_vec3w_within_horizontal_distance(arg0, (void *) var_s0, var_s0->radius)) ) { return var_s1 - D_8036A9C8; } @@ -1865,7 +1865,7 @@ s32 func_80307504(f32 arg0[3], s32 arg1, s32 arg2, s32 arg3, s32 arg4) { if (arg4 & 1) { if (var_s0->unk10_3 & arg4) { if (!(max < var_s0->position[1]) && (min < var_s0->position[1])) { - if (func_80259328(sp4C, var_s0->position, var_s0->radius)) { + if (ml_vec3w_within_horizontal_distance(sp4C, var_s0->position, var_s0->radius)) { return arg2; } } @@ -1874,7 +1874,7 @@ s32 func_80307504(f32 arg0[3], s32 arg1, s32 arg2, s32 arg3, s32 arg4) { else{ if( (var_s0->unk10_3 & arg4)) if( ((var_s0->unk10_3 & 2) || (!(max < var_s0->position[1]) && (min < var_s0->position[1])))) - if( func_80259328(&sp4C, var_s0->position, var_s0->radius)) + if (ml_vec3w_within_horizontal_distance(&sp4C, var_s0->position, var_s0->radius)) return arg2; } @@ -1882,7 +1882,7 @@ s32 func_80307504(f32 arg0[3], s32 arg1, s32 arg2, s32 arg3, s32 arg4) { for(var_s0 = temp_s1->unk8; var_s0 < temp_s1->unk8 + temp_s1->count; var_s0++){ if (var_s0->unk10_3 & arg4) if (!(max < var_s0->position[1]) && (min < var_s0->position[1])) - if(func_80259328(&sp4C, var_s0, var_s0->radius)) + if (ml_vec3w_within_horizontal_distance(&sp4C, var_s0, var_s0->radius)) return (var_s0 - temp_s1->unk8); } } @@ -1890,7 +1890,7 @@ s32 func_80307504(f32 arg0[3], s32 arg1, s32 arg2, s32 arg3, s32 arg4) { for(var_s0 = temp_s1->unk8; var_s0 < temp_s1->unk8 + temp_s1->count; var_s0++){ if ((var_s0->unk10_3 & arg4)) if(((var_s0->unk10_3 & 2) || (!(max < var_s0->position[1]) && (min < var_s0->position[1])))) - if(func_80259328(&sp4C, var_s0, var_s0->radius)) + if (ml_vec3w_within_horizontal_distance(&sp4C, var_s0, var_s0->radius)) return var_s0 - temp_s1->unk8; } } diff --git a/src/core2/code_85800.c b/src/core2/code_85800.c index efb92208..169dadd7 100644 --- a/src/core2/code_85800.c +++ b/src/core2/code_85800.c @@ -219,8 +219,8 @@ s32 func_8030CDE4(SfxSource *arg0){ f32 temp_f0; f32 pad; - viewport_getPosition_vec3f(&sp44); - viewport_getLookVector(&sp38); + viewport_getPosition_vec3f(sp44); + viewport_getLookVector(sp38); sp2C[0] = arg0->position[0] - sp44[0]; sp2C[1] = arg0->position[1] - sp44[1]; sp2C[2] = arg0->position[2] - sp44[2]; @@ -228,9 +228,9 @@ s32 func_8030CDE4(SfxSource *arg0){ if(sp2C[0]*sp2C[0] + sp2C[1]*sp2C[1] + sp2C[2]*sp2C[2] < 10.0f){ return 0x40; } - ml_vec3f_normalize(&sp2C); + ml_vec3f_normalize(sp2C); sp38[1] = 0.0f; - ml_vec3f_normalize(&sp38); + ml_vec3f_normalize(sp38); temp_f0 = func_80256AB4(sp38[0], sp38[2], sp2C[0], sp2C[2]); if(arg0->unk16){ arg0->unk18 += 0.07*((f32)(s32)(64.0f - (temp_f0 * 63.0f)) - arg0->unk18); diff --git a/src/core2/code_935F0.c b/src/core2/code_935F0.c index 69108786..016f061e 100644 --- a/src/core2/code_935F0.c +++ b/src/core2/code_935F0.c @@ -163,7 +163,7 @@ void chMinigame_update(Actor *this){ marker_setFreeMethod(this->marker, __chMinigame_free); func_8028FAB0(this->position); this->unk1C[0] = 0.0f; this->unk1C[1] = this->yaw; this->unk1C[2] = 0.0f; - func_8028FAEC(this->unk1C); + player_setIdealRotation(this->unk1C); this->has_met_before = FALSE; if(this->unk10_12 >= 7){ marker_despawn(this->marker); diff --git a/src/core2/code_9C170.c b/src/core2/code_9C170.c index 57507432..4f3ecf7f 100644 --- a/src/core2/code_9C170.c +++ b/src/core2/code_9C170.c @@ -45,7 +45,7 @@ void func_80323238(void){} // =============================================BREAK ??? -extern f32 func_80258708(f32 [3], f32[3]); +extern f32 ml_vec3f_length(f32 [3], f32[3]); extern f32 ml_distanceSquared_vec3f(f32 [3], f32 [3]); extern void func_80341180(f32, s32, s32, f32 *, f32 [3]); @@ -74,11 +74,11 @@ f32 func_803232AC(f32 *arg0, f32 arg1, f32 arg2, s32 arg3, f32 arg4) { while(var_f20 + arg4 < arg2){ var_f20 += arg4; func_80341180(var_f20, arg3, 3, arg0, sp60); - var_f22 += func_80258708(sp6C, sp60); + var_f22 += ml_vec3f_length(sp6C, sp60); ml_vec3f_copy(sp6C, sp60); } func_80341180(arg2, arg3, 3, arg0, sp60); - var_f22 += func_80258708(sp6C, sp60); + var_f22 += ml_vec3f_length(sp6C, sp60); return var_f22; } @@ -196,7 +196,7 @@ f32 func_80323A48(f32 arg0[3], s32 arg1, f32 arg2, f32 arg3, f32 arg4) { if (arg4 == 1.0) { var_f24 = arg4; func_80341180(var_f24, arg1, 3, arg0, spDC); - var_f22 = var_f26 + func_80258708(spF4, spDC); + var_f22 = var_f26 + ml_vec3f_length(spF4, spDC); } else { var_f24 += arg4; var_f24 = var_f24 - (s32)var_f24; @@ -210,17 +210,17 @@ f32 func_80323A48(f32 arg0[3], s32 arg1, f32 arg2, f32 arg3, f32 arg4) { } } else { func_80341180(var_f24, arg1, 3, arg0, spDC); - var_f22 = var_f26 + func_80258708(spF4, spDC); + var_f22 = var_f26 + ml_vec3f_length(spF4, spDC); } } else { if (arg4 == 1.0) { if (var_f24 < 0.0) { var_f24 = 0; func_80341180(var_f24, arg1, 3, arg0, &spDC); - var_f22 = var_f26 + func_80258708(&spF4, &spDC); + var_f22 = var_f26 + ml_vec3f_length(&spF4, &spDC); } else { func_80341180(var_f24, arg1, 3, arg0, &spDC); - var_f22 = var_f26 + func_80258708(&spF4, &spDC); + var_f22 = var_f26 + ml_vec3f_length(&spF4, &spDC); } } else if (var_f24 < arg4) { var_f24 -= arg4; @@ -235,7 +235,7 @@ f32 func_80323A48(f32 arg0[3], s32 arg1, f32 arg2, f32 arg3, f32 arg4) { var_f22 = var_f26 + gu_sqrtf(spD0[0]*spD0[0] + spD0[1]*spD0[1] + spD0[2]*spD0[2]); } else { func_80341180(var_f24, arg1, 3, arg0, &spDC); - var_f22 = var_f26 + func_80258708(&spF4, &spDC); + var_f22 = var_f26 + ml_vec3f_length(&spF4, &spDC); } } diff --git a/src/core2/code_9E370.c b/src/core2/code_9E370.c index d79c4bd7..a505f41c 100644 --- a/src/core2/code_9E370.c +++ b/src/core2/code_9E370.c @@ -8,8 +8,8 @@ #define DIST_SQ_VEC3F(v1, v2) ((v1[0] - v2[0])*(v1[0] - v2[0]) + (v1[1] - v2[1])*(v1[1] - v2[1]) + (v1[2] - v2[2])*(v1[2] - v2[2])) -extern f32 func_80258708(f32[3], f32[3]); -extern bool func_80259384(f32[3], f32[3], f32); +extern f32 ml_vec3f_length(f32[3], f32[3]); +extern bool ml_vec3f_within_distance(f32[3], f32[3], f32); extern void func_802D7124(Actor *, f32); extern void func_802EE6CC(f32[3], s32[4], s32[4], s32, f32, f32, s32, s32, s32); @@ -661,7 +661,7 @@ Actor *actorArray_findClosestActorFromActorId(f32 position[3], enum actor_e acto && (i_actor->modelCacheIndex != 0x108) && !i_actor->despawn_flag ) { - i_dist = func_80258708(position, i_actor->position); + i_dist = ml_vec3f_length(position, i_actor->position); if (i_dist < min_dist) { min_dist = i_dist; closest_actor = i_actor; @@ -736,7 +736,7 @@ bool func_803270B8(f32 arg0[3], f32 arg1, enum marker_collision_func_type_e arg2 if( !i_ptr->despawn_flag && i_ptr->marker->collidable && ((arg3 == NULL) || arg3(i_ptr)) - && func_80259384(i_ptr->position, arg0, arg1) + && ml_vec3f_within_distance(i_ptr->position, arg0, arg1) ) { if (i_ptr->marker->unk58 == NULL || i_ptr->marker->unk58(i_ptr->marker, arg4) ) { diff --git a/src/core2/code_C8760.c b/src/core2/code_C8760.c index 35670fdf..5ab5112c 100644 --- a/src/core2/code_C8760.c +++ b/src/core2/code_C8760.c @@ -55,7 +55,7 @@ void func_8034F774(void){ sfxsource_setSfxId(D_803720A0.sfxsourceIdx, 0x3EC); func_8030DD14(D_803720A0.sfxsourceIdx, 3); func_8030DFF0(D_803720A0.sfxsourceIdx, 1); - sfxsource_set_position(D_803720A0.sfxsourceIdx, &sp44); + sfxsource_set_position(D_803720A0.sfxsourceIdx, sp44); sfxsource_set_fade_distances(D_803720A0.sfxsourceIdx, 400.0f, 3200.0f); func_8030DE44(D_803720A0.sfxsourceIdx, 2, 0.5f); func_8030E2C4(D_803720A0.sfxsourceIdx); diff --git a/src/core2/code_CB050.c b/src/core2/code_CB050.c index 6b2563aa..762a4b71 100644 --- a/src/core2/code_CB050.c +++ b/src/core2/code_CB050.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern f32 func_80258780(f32[3], f32[3]); +extern f32 ml_vec3f_length_sq(f32[3], f32[3]); typedef struct{ f32 unk0; @@ -67,7 +67,7 @@ void func_80352114(Struct_core2_CB050_0 *arg0, s32 arg1, f32 arg2) { player_getPosition(player_position); if( (func_80294660() == 0x100) && func_8028F20C() - && (func_80258780(player_position, arg0->unk4C) < 50000.0f) + && (ml_vec3f_length_sq(player_position, arg0->unk4C) < 50000.0f) ) { sp58 = arg0->unk4C[0] - player_position[0]; sp54 = arg0->unk4C[2] - player_position[2]; diff --git a/src/core2/nc/dynamicCamera.c b/src/core2/nc/dynamicCamera.c index 5ec3e01c..833e7884 100644 --- a/src/core2/nc/dynamicCamera.c +++ b/src/core2/nc/dynamicCamera.c @@ -7,7 +7,7 @@ extern bool func_80245314(f32[3], f32[3], f32, f32, u32); extern int func_80244D94(f32[3], f32[3], f32[3], u32, f32); extern int func_8024575C(f32[3], f32[3], f32, f32[3], s32, u32); -extern f32 func_80258708(f32[3], f32[3]); +extern f32 ml_vec3f_length(f32[3], f32[3]); extern f32 func_80259198(f32, f32); extern f32 func_8028E82C(void); extern f32 player_getYaw(void); @@ -102,7 +102,7 @@ bool func_802BC640(f32 arg0[3], f32 arg1[3], f32 arg2, s32 arg3) { ml_vec3f_add(sp78, arg0, sp9C); func_80244D94(arg0, sp78, sp88, 0x9E0000, 40.0f); func_8024575C(arg0, sp78, 40.0f, sp88, 4, 0x9E0000); - if (phi_f26 < func_80258708(arg0, sp78)) { + if (phi_f26 < ml_vec3f_length(arg0, sp78)) { ncDynamicCamera_setPosition(sp78); ml_vec3f_clear(D_8037D9C8); ml_vec3f_clear(D_8037D9E0); diff --git a/src/core2/snackerctl.c b/src/core2/snackerctl.c index 4fdcaf39..5a43b190 100644 --- a/src/core2/snackerctl.c +++ b/src/core2/snackerctl.c @@ -11,7 +11,7 @@ #define SNACKER_BB_DIALOG_0 VER_SELECT(0xe26, 0xa68, 0, 0) #define SNACKER_BB_DIALOG_1 VER_SELECT(0xe33, 0xa75, 0, 0) -s32 func_80259254(f32 *, f32, f32, f32); +s32 ml_vec3f_point_within_horizontal_distance(f32 *, f32, f32, f32); void ncFirstPersonCamera_getZoomedInRotation(f32 *); extern u8 D_8037DCCA; @@ -34,7 +34,7 @@ static s32 __snackerctl_player_within_distance(f32 x, f32 z, f32 dist){ f32 player_position[3]; _player_getPosition(player_position); - return func_80259254(player_position, x, z, dist); + return ml_vec3f_point_within_horizontal_distance(player_position, x, z, dist); } static SnackerCtlState __snackerctl_update_ttc(void){ diff --git a/src/core2/spawnqueue.c b/src/core2/spawnqueue.c index d225d6bc..0f67ae26 100644 --- a/src/core2/spawnqueue.c +++ b/src/core2/spawnqueue.c @@ -149,7 +149,7 @@ extern ActorInfo D_80372EE0; extern ActorInfo chTermite; //ticker extern ActorInfo D_80372FC0; extern ActorInfo D_80372FE4; -extern ActorInfo D_803730D8; //nibbly +extern ActorInfo gChBat; //nibbly extern ActorInfo D_80373100; extern ActorInfo D_80373134; extern ActorInfo D_80373158; @@ -335,7 +335,7 @@ void spawnQueue_reset(void){ spawnableActorList_addIfMapVisited(&D_80372C18, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_3 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_7 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_12 | ACTOR_FLAG_UNKNOWN_17, MAP_1B_MMM_MAD_MONSTER_MANSION); //teehee spawnableActorList_addIfMapVisited(&D_80372FC0, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_16 | ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION); spawnableActorList_addIfMapVisited(&D_80372FE4, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_10 | ACTOR_FLAG_UNKNOWN_16 | ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION); - spawnableActorList_addIfMapVisited(&D_803730D8, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_21 |ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION); //nibbly + spawnableActorList_addIfMapVisited(&gChBat, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_21 |ACTOR_FLAG_UNKNOWN_25, MAP_1B_MMM_MAD_MONSTER_MANSION); //nibbly spawnableActorList_addIfMapVisited(&D_80367130, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_3 | ACTOR_FLAG_UNKNOWN_5 | ACTOR_FLAG_UNKNOWN_7 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_11 | ACTOR_FLAG_UNKNOWN_25, MAP_D_BGS_BUBBLEGLOOP_SWAMP); //buzzbomb spawnableActorList_addIfMapVisited(&D_80372B80, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_6 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_17 | ACTOR_FLAG_UNKNOWN_25, MAP_27_FP_FREEZEEZY_PEAK); spawnableActorList_addIfMapVisited(&chShrapnelDescription, actor_new, ACTOR_FLAG_UNKNOWN_0 | ACTOR_FLAG_UNKNOWN_8 | ACTOR_FLAG_UNKNOWN_25, MAP_7_TTC_TREASURE_TROVE_COVE); //scrapnel diff --git a/src/fight/chfinalboss.c b/src/fight/chfinalboss.c index a969cbce..b1f4b6cb 100644 --- a/src/fight/chfinalboss.c +++ b/src/fight/chfinalboss.c @@ -23,7 +23,7 @@ extern void sfxsource_setSampleRate(u8, s32); extern void func_80328FF0(Actor *arg0, f32 arg1); extern f32 func_80257204(f32, f32, f32, f32); extern void func_8028F85C(f32[3]); -extern void func_8028FAEC(f32[3]); +extern void player_setIdealRotation(f32[3]); extern f32 func_8033229C(ActorMarker *); Actor *chfinalboss_draw(ActorMarker *arg0, Gfx **arg1, Mtx **arg2, Vtx **arg3); @@ -1883,7 +1883,7 @@ void chfinalboss_phase5_update(ActorMarker *marker) { D_803928C8[0] = 0.0f; D_803928C8[1] = func_80257204(D_803917E0[0], D_803917E0[2], this->position[0], this->position[2]); D_803928C8[2] = 0.0f; - func_8028FAEC(D_803928C8); + player_setIdealRotation(D_803928C8); } if (__chFinalBossJinjonatorHits == 3) { gcdialog_showText(randi2(0, 5) + 0x1159, 0x20, NULL, NULL, NULL, NULL); diff --git a/src/lair/code_5ED0.c b/src/lair/code_5ED0.c index 84e8bd2a..3e53a221 100644 --- a/src/lair/code_5ED0.c +++ b/src/lair/code_5ED0.c @@ -1142,7 +1142,7 @@ void func_8038DFBC(void) void func_8038E070(void) { func_8028F85C(&D_8037DCB8->playerPosition); - func_8028F8A4(&D_8037DCB8->playerRotation); + player_setRotation(&D_8037DCB8->playerRotation); func_8028F918(2); } diff --git a/src/lair/code_9C40.c b/src/lair/code_9C40.c index 0d9c5b25..24959a29 100644 --- a/src/lair/code_9C40.c +++ b/src/lair/code_9C40.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern bool func_80259384(f32[3], f32[3], f32); +extern bool ml_vec3f_within_distance(f32[3], f32[3], f32); void func_803902B8(Actor *this); Actor *func_80390030(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); @@ -95,7 +95,7 @@ void func_803902B8(Actor *this) { this->initialized = TRUE; } _player_getPosition(sp5C); - sp58 = func_80259384(this->position, sp5C, 1750.0f) && !this->has_met_before; + sp58 = ml_vec3f_within_distance(this->position, sp5C, 1750.0f) && !this->has_met_before; if (sp58 && !this->unk38_0) { func_8032BB88(this, 0, 0x1F4); func_8025A6EC(COMUSIC_79_CHEATO, 0); @@ -105,7 +105,7 @@ void func_803902B8(Actor *this) { func_8039024C(this); } this->unk38_0 = sp58; - sp58 = func_80259384(this->position, sp5C, 400.0f); + sp58 = ml_vec3f_within_distance(this->position, sp5C, 400.0f); if (fileProgressFlag_get(sp54 + 0xAD)) { func_8024E55C(0, sp3C); sp58 &= (sp3C[FACE_BUTTON(BUTTON_B)] == 1) || func_8028EC04();