diff --git a/include/core1/core1.h b/include/core1/core1.h index 82b04394..7f03b235 100644 --- a/include/core1/core1.h +++ b/include/core1/core1.h @@ -4,8 +4,6 @@ #include "core1/mem.h" void func_8025235C(f32[3], f32[3]); -void func_80252C08(f32[3], f32[3], f32, f32[3]); - void func_80252C08(f32 arg0[3], f32 arg1[3], f32 scale, f32 arg3[3]); #endif diff --git a/include/core2/nc/camera.h b/include/core2/nc/camera.h index e6934dd4..255f839d 100644 --- a/include/core2/nc/camera.h +++ b/include/core2/nc/camera.h @@ -8,4 +8,4 @@ enum camera_type_e{ CAMERA_TYPE_4_RANDOM = 4 }; -#endif \ No newline at end of file +#endif diff --git a/include/functions.h b/include/functions.h index 39a82013..145deaec 100644 --- a/include/functions.h +++ b/include/functions.h @@ -381,7 +381,7 @@ extern s32 func_802F9AA8(enum sfx_e); Actor * func_803055E0(enum actor_e id, s32 pos[3], s32 arg2, s32 arg3, s32 arg4); -Actor * func_803056FC(enum actor_e id, s32 pos[3], s32 yaw); +Actor * spawn_actor(enum actor_e id, s32 pos[3], s32 yaw); f32 func_80309724(f32[3]); BKModelBin *func_8030A428(s32); u8 func_8030D90C(void); diff --git a/include/gc/gctransition.h b/include/gc/gctransition.h index c5b2ad44..a891672a 100644 --- a/include/gc/gctransition.h +++ b/include/gc/gctransition.h @@ -1,12 +1,12 @@ #ifndef __GC_TRANSITION__ #define __GC_TRANSITION__ -void gctransition_8030B740(void); +void gctransition_defrag(void); void gctransition_draw(Gfx **arg0, Mtx **arg1, Vtx **arg2); void gctransition_8030BD4C(void); f32 gctransition_8030BD88(void); -int gctransition_8030BD98(void); -int gctransition_8030BDAC(void); +int gctransition_done(void); +int gctransition_active(void); int gctransition_8030BDC0(void); void gctransition_8030BE3C(void); void gctransition_8030BE60(void); diff --git a/include/prop.h b/include/prop.h index 8759f920..a42f0176 100644 --- a/include/prop.h +++ b/include/prop.h @@ -337,7 +337,7 @@ typedef struct { s16 y; s16 z; struct { - u16 bit15: 9; //selector_value //volume??? diameter + u16 radius: 9; //selector_value //volume??? diameter u16 bit6: 6; //category u16 bit0: 1; }unk6; diff --git a/include/structs.h b/include/structs.h index 14c19aab..023b0166 100644 --- a/include/structs.h +++ b/include/structs.h @@ -246,23 +246,6 @@ typedef struct struct_8_s{ f32 unk60; }struct8s; -typedef struct struct_9_s{ - u8 uid; - u8 unk1; - u8 unk2; - // u8 pad3[1]; - f32 unk4; //duration - s32 unk8; //asset_indx - s32 unkC; //animation_indx - f32 unk10; -}struct9s; - -typedef struct struct_10_s{ - u8 map_indx; - u8 unk1; - u8 unk2; -}struct10s; - typedef struct struct_11_s{ f32 unk0; f32 unk4; diff --git a/src/BGS/bss_pad.c b/src/BGS/bss_pad.c index ca03373b..471c70c7 100644 --- a/src/BGS/bss_pad.c +++ b/src/BGS/bss_pad.c @@ -1 +1 @@ -char pad_BGS_D_80391230[0x10]; \ No newline at end of file +char pad_BGS_D_80391230[0x10]; diff --git a/src/BGS/ch/flibbit.c b/src/BGS/ch/flibbit.c index 0fd3615d..183cb32f 100644 --- a/src/BGS/ch/flibbit.c +++ b/src/BGS/ch/flibbit.c @@ -266,7 +266,7 @@ void func_80386EB0(ActorMarker *this, ActorMarker *other){ Actor *chflibbit_draw(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ Actor *this; ActorLocal_Flibbit *local; - s32 temp_a0; + BoneTransformList *temp_a0; int i; f32 sp7C[3]; f32 phi_f2; diff --git a/src/BGS/ch/yellowflibbit.c b/src/BGS/ch/yellowflibbit.c index aa735f74..c4955360 100644 --- a/src/BGS/ch/yellowflibbit.c +++ b/src/BGS/ch/yellowflibbit.c @@ -297,7 +297,7 @@ Actor *func_8038DE5C(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 var_s0; f32 var_f2; f32 sp7C[3]; - s32 temp_a0_2; + BoneTransformList *temp_a0_2; this = marker_getActor(marker); local = (ActorLocal_Yellow_Flibbit *)&this->local; diff --git a/src/BGS/code_3030.c b/src/BGS/code_3030.c index 4903e82a..d5e81f23 100644 --- a/src/BGS/code_3030.c +++ b/src/BGS/code_3030.c @@ -43,7 +43,7 @@ void func_80389488(Actor *this, s32 next_state) { if (next_state == 3) { func_8030E6A4(SFX_86_TIPTUP_CHORUS_AH, local->unk8, 0x7FFF); skeletalAnim_set(this->unk148, ASSET_12F_ANIM_CHOIR_TURTLE_HURT, 0.1f, 1.75f); - skeletalAnim_setCallback_1(this->unk148, 0.9f, func_80389420, this->marker); + skeletalAnim_setCallback_1(this->unk148, 0.9f, (GenFunction_1)func_80389420, (s32)this->marker); if (local->tiptup_marker != NULL) { func_80388E94(local->tiptup_marker, local->unk0); } diff --git a/src/CC/code_13C0.c b/src/CC/code_13C0.c index 140e8941..de5b4afe 100644 --- a/src/CC/code_13C0.c +++ b/src/CC/code_13C0.c @@ -149,7 +149,7 @@ void func_80387CC0(void){ if(getGameMode() == GAME_MODE_7_ATTRACT_DEMO) return; - viewport_getRotation(sp1C); + viewport_get_rotation_vec3f(sp1C); tmp_v0 = func_8023DB4C(0x7F); if(tmp_v0 >= 0x40){ tmp_v0 = 0x7F - tmp_v0; @@ -158,7 +158,7 @@ void func_80387CC0(void){ if(360.0f <= sp1C[2]){ sp1C[2] -= 360.0f; } - viewport_setRotation(sp1C); + viewport_set_rotation_vec3f(sp1C); } diff --git a/src/CC/code_1F70.c b/src/CC/code_1F70.c index 54508c3a..10d32713 100644 --- a/src/CC/code_1F70.c +++ b/src/CC/code_1F70.c @@ -18,7 +18,7 @@ extern int func_80340020(s32, f32[3], s32, f32, s32, BKVertexList *, f32[3], f32 extern void boneTransformList_getBoneScale(s32, s32, f32[3]); extern void boneTransformList_setBoneScale(s32, s32, f32[3]); extern void func_8033A9A8(s32, s32, f32[3]); -extern void viewport_getPosition(f32[3]); +extern void viewport_get_position_vec3f(f32[3]); extern void ml_vec3f_normalize(f32[3]); extern void func_8033A45C(s32, s32); extern void modelRender_setBoneTransformList(s32); @@ -146,7 +146,7 @@ void CC_func_80388760(Gfx **gfx, Mtx **mtx, Vtx **vtx){ if(D_80389FA0.unk21 == 0) return; - viewport_getPosition(sp98); + viewport_get_position_vec3f(sp98); if(sp98[0] < -2600.0f || 11600.0f < sp98[0]) return; diff --git a/src/CCW/code_160.c b/src/CCW/code_160.c index 0c04fc84..6f43cb4b 100644 --- a/src/CCW/code_160.c +++ b/src/CCW/code_160.c @@ -162,7 +162,7 @@ void func_8038687C(Actor *this) { if (local->unk0 != NULL) { other = marker_getActor(local->unk0); - viewport_getPosition(sp78); + viewport_get_position_vec3f(sp78); sp6C[0] = this->position[0] - sp78[0]; sp6C[1] = this->position[1] - sp78[1]; sp6C[2] = this->position[2] - sp78[2]; diff --git a/src/FP/bss_end_pad.c b/src/FP/bss_end_pad.c index ea1cc140..7c0e2803 100644 --- a/src/FP/bss_end_pad.c +++ b/src/FP/bss_end_pad.c @@ -1 +1 @@ -char pad_FP_803935A8[0x20]; \ No newline at end of file +char pad_FP_803935A8[0x20]; diff --git a/src/FP/bss_pad.c b/src/FP/bss_pad.c index 22ee3257..3ca7500b 100644 --- a/src/FP/bss_pad.c +++ b/src/FP/bss_pad.c @@ -1 +1 @@ -char pad_FP_80392F10[0x10]; \ No newline at end of file +char pad_FP_80392F10[0x10]; diff --git a/src/FP/ch/boggy2.c b/src/FP/ch/boggy2.c index 9a10460d..fe3737db 100644 --- a/src/FP/ch/boggy2.c +++ b/src/FP/ch/boggy2.c @@ -3,7 +3,8 @@ #include "variables.h" extern void func_8028E668(f32[3], f32, f32, f32); - +extern Actor *func_80328230(enum actor_e id, f32 pos[3], f32 rot[3]); +extern NodeProp *cubeList_findNodePropByActorId(enum actor_e, s32[3]); extern f32 func_8038BE20(f32 arg0[3]); typedef struct { diff --git a/src/FP/ch/twinkly.c b/src/FP/ch/twinkly.c index 88639237..f598272e 100644 --- a/src/FP/ch/twinkly.c +++ b/src/FP/ch/twinkly.c @@ -3,6 +3,8 @@ #include "variables.h" extern Actor *func_802EBAE0(UNK_TYPE(s32), f32 position[3], f32 rotation[3], f32 scale, UNK_TYPE(s32), UNK_TYPE(s32), UNK_TYPE(s32), f32, UNK_TYPE(s32)); +extern Struct70s *func_8034C2C4(ActorMarker *marker, s32 arg1); + Actor *func_8038C0B0(ActorMarker *marker, UNK_TYPE(s32) arg1, f32 arg2, UNK_TYPE(s32) arg3); Actor *func_8038C1F8(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); void func_8038C9A0(Actor *this); @@ -42,7 +44,7 @@ ActorInfo D_80391FF4 = { MARKER_203_TWINKLY_RED, ACTOR_335_TWINKLY_RED, ASSET_44 0, 0, 1.0f, 0 }; -s32 FP_D_80392018[4] = {0, 0, 0, func_8038C0B0}; +Struct6Cs FP_D_80392018 = {NULL, NULL, NULL, (void*)func_8038C0B0}; struct43s D_80392028 = { {{-200.0f, 200.0f, -200.0f}, {200.0f, 400.0f, 200.0f}}, {{ 0.0f, -800.0f, 0.0f}, { 0.0f, -800.0f, 0.0f}}, diff --git a/src/FP/ch/wozza.c b/src/FP/ch/wozza.c index 45a5bbb5..e6f0bd99 100644 --- a/src/FP/ch/wozza.c +++ b/src/FP/ch/wozza.c @@ -49,9 +49,9 @@ Actor *func_8038F210(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ } void func_8038F274(void){ - UNK_TYPE(s32) v0 = func_8034C528(0x191); - if(v0){ - func_8034DE60(v0, 0.0f, -500.0f, 0.2f, 1); + Struct70s *v0 = func_8034C528(0x191); + if(v0 != NULL){ + func_8034DE60(&v0->type_6D, 0.0f, -500.0f, 0.2f, 1); } } diff --git a/src/FP/code_ABD0.c b/src/FP/code_ABD0.c index f63797be..c33e79d8 100644 --- a/src/FP/code_ABD0.c +++ b/src/FP/code_ABD0.c @@ -225,7 +225,7 @@ void func_80391744(Actor *this, Actor* other){ } void func_8039180C(Actor *this){ - ActorMarker *sp24; + Actor *sp24; if(!this->initialized){ sp24 = actorArray_findActorFromActorId(0x254); diff --git a/src/FP/racectrl.c b/src/FP/racectrl.c index 7292abe2..3234c89d 100644 --- a/src/FP/racectrl.c +++ b/src/FP/racectrl.c @@ -485,15 +485,15 @@ void FP_func_8038BA88(s32 arg0){ switch(FP_D_803935A8.unkC - FP_D_803935A8.unk8){ case 3: - func_8025AEA0(0x3a, 0x411aa); + func_8025AEA0(0x3a, 266666); break; case 2: - func_8025AEA0(0x3a, 0x493e0); + func_8025AEA0(0x3a, 300000); break; case 4: break; default: - func_8025AEA0(0x3a, 0x51615); + func_8025AEA0(0x3a, 333333); break; diff --git a/src/GV/bss_pad.c b/src/GV/bss_pad.c index e95b9c38..e4c10039 100644 --- a/src/GV/bss_pad.c +++ b/src/GV/bss_pad.c @@ -1 +1 @@ -char pad_GV_D_80391A20[0x10]; \ No newline at end of file +char pad_GV_D_80391A20[0x10]; diff --git a/src/GV/ch/mazectrl.c b/src/GV/ch/mazectrl.c index 664515de..be8d00ce 100644 --- a/src/GV/ch/mazectrl.c +++ b/src/GV/ch/mazectrl.c @@ -27,18 +27,18 @@ ActorInfo chMazeCtrl = { MARKER_1CD_GV_MAZE_CTRL, ACTOR_319_GV_MAZE_CTRL, 0x0, void func_8038F520(f32 arg0){ static f32 D_803915E4[3] = {460.0f, 1400.0f, 0.0f}; static f32 D_803915F0[3] = {0.0f, 0.0f, 0.0f}; - Struct6Ds *tmp_v0 = func_8034C528(0x19A); + Struct70s *tmp_v0 = func_8034C528(0x19A); if(tmp_v0 != NULL){ - func_8034DDF0(tmp_v0, D_803915E4, D_803915F0, arg0, 1); + func_8034DDF0(&tmp_v0->type_6D, D_803915E4, D_803915F0, arg0, 1); } } void func_8038F56C(f32 arg0){ static f32 D_803915FC[3] = {0.0f, 0.0f, 0.0f}; static f32 D_80391608[3] = {460.0f, 1400.0f, 0.0f}; - Struct6Ds *tmp_v0 = func_8034C528(0x19A); + Struct70s *tmp_v0 = func_8034C528(0x19A); if(tmp_v0 != NULL){ - func_8034DDF0(tmp_v0, D_803915FC, D_80391608, arg0, 1); + func_8034DDF0(&tmp_v0->type_6D, D_803915FC, D_80391608, arg0, 1); } } @@ -56,7 +56,7 @@ void __chMazeCtrl_8038F5E4(Actor *this){ void __chMazeCtrl_setState(Actor *this, s32 next_state){ f32 plyr_pos[3]; - Struct6Ds *tmp_v0; + Struct70s *tmp_v0; ActorLocal_GVMazeCtrl *local; f32 sp28[3]; @@ -111,7 +111,7 @@ void __chMazeCtrl_setState(Actor *this, s32 next_state){ func_8030E6D4(SFX_52_BANJO_YAH_OH); tmp_v0 = func_8034C528(400); if(tmp_v0){ - func_8034DE60(tmp_v0, 0.0f, -1700.0f, 1.0f, 1); + func_8034DE60(&tmp_v0->type_6D, 0.0f, -1700.0f, 1.0f, 1); } }//L8038F8C4 @@ -170,7 +170,7 @@ void chMazeCtrl_update(Actor *this){ player_getPosition(sp3C); if(this->state == 1){ - sp38 = func_8034C528(0x191); + sp38 = &func_8034C528(0x191)->type_6D; if(sp38 != NULL && func_8034DC80(sp38, sp3C)){ __chMazeCtrl_setState(this, 2); } @@ -200,7 +200,7 @@ void chMazeCtrl_update(Actor *this){ } if(this->state == 4){ - sp30 = func_8034C528(0x190); + sp30 = &func_8034C528(0x190)->type_6D; if(sp30 != NULL && func_8034DC78(sp30)){ __chMazeCtrl_setState(this, 0); } diff --git a/src/GV/code_9B70.c b/src/GV/code_9B70.c index c7064d2b..ea985be9 100644 --- a/src/GV/code_9B70.c +++ b/src/GV/code_9B70.c @@ -10,10 +10,10 @@ void func_8038FF68(void){ if(map_get() != MAP_12_GV_GOBIS_VALLEY) return; if(jiggyscore_isCollected(JIGGY_42_GV_WATER_PYRAMID)){ - func_8034DE60(func_8034C528(0x190), 0.0f, 270.0f, 0.0f, 1); + func_8034DE60(&func_8034C528(0x190)->type_6D, 0.0f, 270.0f, 0.0f, 1); } else{ - func_8034E71C(func_8034C5AC(0x130), -1500, 0.0f); + func_8034E71C(&func_8034C5AC(0x130)->type_73, -1500, 0.0f); } } diff --git a/src/GV/code_9C10.c b/src/GV/code_9C10.c index 5afb2d1d..14e4fbf4 100644 --- a/src/GV/code_9C10.c +++ b/src/GV/code_9C10.c @@ -17,13 +17,13 @@ void func_80390000(s32 arg0){ timed_setStaticCameraToNode(4.0f, 0x15); func_80324E38(8.0f, 0); - tmp_v0 = func_8034C5AC(0x130); + tmp_v0 = &func_8034C5AC(0x130)->type_73; if(tmp_v0){ func_8034E71C(tmp_v0, -1000, 0.0f); func_8034E71C(tmp_v0, 0, 10.0f); } - tmp_v0_2 = func_8034C528(0x190); + tmp_v0_2 = &func_8034C528(0x190)->type_6D; if(tmp_v0_2){ func_8034DE60(tmp_v0_2, 0.0f, 270.0f, 0.0f, 1); } diff --git a/src/GV/matchinggame.c b/src/GV/matchinggame.c index 9631ddc8..e32bf72a 100644 --- a/src/GV/matchinggame.c +++ b/src/GV/matchinggame.c @@ -160,7 +160,7 @@ void gv_matchingGame_update(void){ player_getPosition(player_position); sp4C = func_8033F3E8(mapModel_getModel(0), player_position, 0x190, 0x1a0); if(sp4C){ - sp48 = func_8034C528(sp4C); + sp48 = &func_8034C528(sp4C)->type_6D; if(matchingGame.state == 1){ __matchingGame_setState(2); } diff --git a/src/MM/bss_pad.c b/src/MM/bss_pad.c index 665fd437..28806312 100644 --- a/src/MM/bss_pad.c +++ b/src/MM/bss_pad.c @@ -1 +1 @@ -char pad_MM_D_80389C80[0x10]; \ No newline at end of file +char pad_MM_D_80389C80[0x10]; diff --git a/src/MMM/bss_pad.c b/src/MMM/bss_pad.c index 0132cf2b..88ce142d 100644 --- a/src/MMM/bss_pad.c +++ b/src/MMM/bss_pad.c @@ -1 +1 @@ -char pad_D_8038C4C0[0x10]; \ No newline at end of file +char pad_D_8038C4C0[0x10]; diff --git a/src/MMM/ch/napper.c b/src/MMM/ch/napper.c index 7f7f6f17..cc05e8d6 100644 --- a/src/MMM/ch/napper.c +++ b/src/MMM/ch/napper.c @@ -153,7 +153,7 @@ void chnapper_update(Actor *this){ }//L80386DF4 if(this->state != 4){ - viewport_getPosition(sp58); + viewport_get_position_vec3f(sp58); sp4C[0] = this->position_x - sp58[0]; sp4C[1] = this->position_y - sp58[1]; sp4C[2] = this->position_z - sp58[2]; diff --git a/src/MMM/code_47D0.c b/src/MMM/code_47D0.c index 72bd0b34..bee53e17 100644 --- a/src/MMM/code_47D0.c +++ b/src/MMM/code_47D0.c @@ -128,7 +128,7 @@ void func_8038AF90(Struct_MMM_47D0_0 *arg0, Struct68s *arg1, f32 arg2) { func_8028F66C(BS_INTR_D_SURF); } if (sp3C && ((sp40[0] != 0.0f) || (sp40[1] != 0.0f))) { - viewport_getRotation(sp70); + viewport_get_rotation_vec3f(sp70); sp64[0] = sp40[0]; sp64[1] = 0.0f; sp64[2] = -sp40[1]; @@ -147,7 +147,7 @@ void func_8038AF90(Struct_MMM_47D0_0 *arg0, Struct68s *arg1, f32 arg2) { func_80351B28(arg1, sp54); func_8035179C(arg1, sp54); if (arg0->unk0 != NULL) { - viewport_getPosition(sp7C); + viewport_get_position_vec3f(sp7C); sp64[0] = sp54[0] - sp7C[0]; sp64[2] = sp54[2] - sp7C[2]; sp64[1] = 0.0f; diff --git a/src/RBB/code_640.c b/src/RBB/code_640.c index 54b459ac..34ad2721 100644 --- a/src/RBB/code_640.c +++ b/src/RBB/code_640.c @@ -139,7 +139,7 @@ void func_80386A7C(Actor *this){ func_802D3D74(this); this->depth_mode = 1; - viewport_getPosition(&sp2C); + viewport_get_position_vec3f(&sp2C); sp28 = func_80386A30(&this->position); temp_v0 = func_80386A30(&sp2C); this->unk38_0 = 0; diff --git a/src/core1/code_10A00.c b/src/core1/code_10A00.c index 1df1a4e6..35dec438 100644 --- a/src/core1/code_10A00.c +++ b/src/core1/code_10A00.c @@ -178,7 +178,7 @@ void pfsManager_update(void) { || (getGameMode() == GAME_MODE_9_BANJO_AND_KAZOOIE) ) { s0 = 0x1000; - if (gctransition_8030BD98()) { + if (gctransition_done()) { D_802816E0 += time_getDelta(); } if ((D_802816E0 < 1.0) || (getGameMode() == GAME_MODE_9_BANJO_AND_KAZOOIE)) { diff --git a/src/core1/code_13990.c b/src/core1/code_13990.c index 37aa7aa8..fcf1ddc6 100644 --- a/src/core1/code_13990.c +++ b/src/core1/code_13990.c @@ -4,8 +4,7 @@ #include "ml/mtx.h" - -void func_8024632C(Mtx*, f32, f32, f32, f32); +void _guRotateF(Mtx*, f32, f32, f32, f32); f32 func_80263FF0(f32); f32 cosf(f32); @@ -21,25 +20,30 @@ f32 D_8027657C = BAD_DTOR; /*.bss*/ Mtx_t D_80282810; u8 pad_D_80282850[0x780]; -Mtx * D_80282FD0; +Mtx * s_mtx_stack; /*.code*/ -void mlMtxGet(f32 *arg0) { - s32 var_v0, j; +/** + * @brief copies the top of the matrix stack to the destination address + * + * @param dst + */ +void mlMtxGet(f32 *dst) { + s32 row, col; - for(var_v0 = 0; var_v0 < 4; var_v0++){ - for(j = 0; j < 4; j++){ - *(arg0++) = reinterpret_cast(f32, D_80282FD0->m[var_v0][j]); + for(row = 0; row < 4; row++){ + for(col = 0; col < 4; col++){ + *(dst++) = reinterpret_cast(f32, s_mtx_stack->m[row][col]); } } } -Mtx *func_80251488(void){ - return D_80282FD0; +Mtx *mlMtx_get_stack_pointer(void){ + return s_mtx_stack; } void mlMtxApply(Mtx *mPtr){ - func_80245A7C(D_80282FD0, mPtr); + _guMtxF2L(s_mtx_stack, mPtr); } void func_802514BC(Mtx* arg0) { @@ -49,19 +53,16 @@ void func_802514BC(Mtx* arg0) { f32 sum; f32 prod[4][4]; - for(row = 0; row < 4; row++, arg0 = &arg0->m[1][0]) - { - for(col = 0; col < 4; col++) - { + for(row = 0; row < 4; row++, arg0 = &arg0->m[1][0]) { + for(col = 0; col < 4; col++) { sum = 0.0; - for(i = 0; i < 4; i++) - { - sum += reinterpret_cast(f32, arg0->m[0][i]) * reinterpret_cast(f32, D_80282FD0->m[i][col]); + for(i = 0; i < 4; i++) { + sum += reinterpret_cast(f32, arg0->m[0][i]) * reinterpret_cast(f32, s_mtx_stack->m[i][col]); } prod[row][col] = sum; } } - func_80253010(D_80282FD0, prod, sizeof(Mtx)); + func_80253010(s_mtx_stack, prod, sizeof(Mtx)); } void func_802515D4(f32 arg0[3][3]) { @@ -75,7 +76,7 @@ void func_802515D4(f32 arg0[3][3]) { for(var_v1 = 0; var_v1 < 3; var_v1++){ var_f0 = 0.0f; for(var_v0 = 0; var_v0 < 3; var_v0++){ - var_f0 += arg0[i][var_v0] * reinterpret_cast(f32, D_80282FD0->m[var_v0][var_v1]); + var_f0 += arg0[i][var_v0] * reinterpret_cast(f32, s_mtx_stack->m[var_v0][var_v1]); } sp1C[i][var_v1] = var_f0; } @@ -84,7 +85,7 @@ void func_802515D4(f32 arg0[3][3]) { for( i = 0; i < 3; i++){ for(var_v1 = 0; var_v1 < 3; var_v1++){ - reinterpret_cast(f32, D_80282FD0->m[i][var_v1]) = sp1C[i][var_v1]; + reinterpret_cast(f32, s_mtx_stack->m[i][var_v1]) = sp1C[i][var_v1]; } } @@ -92,25 +93,34 @@ void func_802515D4(f32 arg0[3][3]) { void mlMtxPop(void){ - D_80282FD0--; + s_mtx_stack--; } -void func_802516E0(void) { +/** + * @brief pushes a copy of the current matrix on the top matrix stack to the top of + * the matrix stack. + * + */ +void mlMtx_push_duplicate(void) { s32 i, j; f32 *var_a3; f32 *var_a2; - var_a2 = D_80282FD0 + 1; - var_a3 = D_80282FD0; + var_a2 = s_mtx_stack + 1; + var_a3 = s_mtx_stack; for(i = 0; i < 16; i++) { var_a2[i] = var_a3[i]; } - D_80282FD0++; + s_mtx_stack++; } -void func_80251738(void){ +/** + * @brief pushes the identity matrix to the top of the matrix stack. + * + */ +void mlMtx_push_identity(void){ s32 i; - f32 *v0 = ++D_80282FD0; + f32 *v0 = ++s_mtx_stack; for(i = 0; i<3; i++){ v0[0] = 1.0f; v0[1] = 0.0f; @@ -122,67 +132,93 @@ void func_80251738(void){ v0[0] = 1.0f; } -f32 *func_80251788(f32 arg0, f32 arg1, f32 arg2){ - f32 * var_v0 = ++D_80282FD0; +/** + * @brief Pushes a translation matrix to the top of the matrix stack. + * + * @param x + * @param y + * @param z + * @return f32* + */ +f32 *mlMtx_push_translation(f32 x, f32 y, f32 z){ + f32 * var_v0 = ++s_mtx_stack; *(var_v0++) = 1.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 1.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 1.0f; *(var_v0++) = 0.0f; - *(var_v0++) = arg0; *(var_v0++) = arg1; *(var_v0++) = arg2; *(var_v0++) = 1.0f; + *(var_v0++) = x; *(var_v0++) = y; *(var_v0++) = z; *(var_v0++) = 1.0f; } -void func_802517F8(f32* arg0) { +/** + * @brief Pushes a copy of a matrix to the top of the matrix stack. + * + * @param mtx + */ +void mlMtx_push_mtx(f32* mtx) { s32 var_v0, j; - D_80282FD0++; + s_mtx_stack++; for(var_v0 = 0; var_v0 < 4; var_v0++){ for(j = 0; j < 4; j++){ - reinterpret_cast(f32, D_80282FD0->m[var_v0][j]) = *arg0++; + reinterpret_cast(f32, s_mtx_stack->m[var_v0][j]) = *mtx++; } } } -void func_80251878(f32* arg0) { +/** + * @brief Pushes a copy of the a matrix multiplied with the matrix at the top + * of the matrix stack onto the top of the matrix stack. + * + * @param l_mtx + */ +void mlMtx_push_multiplied(f32* l_mtx) { s32 i; s32 j; Mtx* var_a2; - var_a2 = D_80282FD0 + 1; - for(i = 0; i < 4; i++, arg0 += 4){ + var_a2 = s_mtx_stack + 1; + for(i = 0; i < 4; i++, l_mtx += 4){ for(j = 0; j < 4; j++){ - reinterpret_cast(f32, var_a2->m[i][j]) = arg0[0] * reinterpret_cast(f32, D_80282FD0->m[0][j]) - + arg0[1] * reinterpret_cast(f32, D_80282FD0->m[1][j]) - + arg0[2] * reinterpret_cast(f32, D_80282FD0->m[2][j]) - + arg0[3] * reinterpret_cast(f32, D_80282FD0->m[3][j]); + reinterpret_cast(f32, var_a2->m[i][j]) = l_mtx[0] * reinterpret_cast(f32, s_mtx_stack->m[0][j]) + + l_mtx[1] * reinterpret_cast(f32, s_mtx_stack->m[1][j]) + + l_mtx[2] * reinterpret_cast(f32, s_mtx_stack->m[2][j]) + + l_mtx[3] * reinterpret_cast(f32, s_mtx_stack->m[3][j]); } } - D_80282FD0 = var_a2; + s_mtx_stack = var_a2; } -void func_802519C8(Mtx * arg0, Mtx * arg1) { +/** + * @brief Pushes a copy of the a matrix multiplied with another matrix onto the + * top of the matrix stack. + * + * @param l_mtx + * @param r_mtx + */ +void mlMtx_push_multiplied_2(Mtx * l_mtx, Mtx * r_mtx) { s32 row; s32 col; - Mtx * dst = (D_80282FD0 + 1); + Mtx * dst = (s_mtx_stack + 1); - for (row = 0; row < 4; row++, arg1 = &arg1->m[1][0]) + for (row = 0; row < 4; row++, r_mtx = &r_mtx->m[1][0]) { for (col = 0; col < 4; col++) { reinterpret_cast(f32, dst->m[row][col]) = ( - reinterpret_cast(f32, arg1->m[0][0]) * reinterpret_cast(f32, arg0->m[0][col]) + - reinterpret_cast(f32, arg1->m[0][1]) * reinterpret_cast(f32, arg0->m[1][col]) + - reinterpret_cast(f32, arg1->m[0][2]) * reinterpret_cast(f32, arg0->m[2][col]) + - reinterpret_cast(f32, arg1->m[0][3]) * reinterpret_cast(f32, arg0->m[3][col]) + reinterpret_cast(f32, r_mtx->m[0][0]) * reinterpret_cast(f32, l_mtx->m[0][col]) + + reinterpret_cast(f32, r_mtx->m[0][1]) * reinterpret_cast(f32, l_mtx->m[1][col]) + + reinterpret_cast(f32, r_mtx->m[0][2]) * reinterpret_cast(f32, l_mtx->m[2][col]) + + reinterpret_cast(f32, r_mtx->m[0][3]) * reinterpret_cast(f32, l_mtx->m[3][col]) ); } } - D_80282FD0 = (dst + 0); + s_mtx_stack = (dst + 0); } //mlMtx void mlMtxIdent(void){ s32 i; - f32 *v0 = D_80282FD0 = &D_80282810; + f32 *v0 = s_mtx_stack = &D_80282810; for(i = 0; i<3; i++){ v0[0] = 1.0f; v0[1] = 0.0f; @@ -194,19 +230,19 @@ void mlMtxIdent(void){ v0[0] = 1.0f; } -void func_80251B5C(f32 arg0, f32 arg1, f32 arg2){ - f32 * var_v0 = D_80282FD0 = &D_80282810; +void func_80251B5C(f32 x, f32 y, f32 z){ + f32 * var_v0 = s_mtx_stack = &D_80282810; *(var_v0++) = 1.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 1.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 0.0f; *(var_v0++) = 1.0f; *(var_v0++) = 0.0f; - *(var_v0++) = arg0; *(var_v0++) = arg1; *(var_v0++) = arg2; *(var_v0++) = 1.0f; + *(var_v0++) = x; *(var_v0++) = y; *(var_v0++) = z; *(var_v0++) = 1.0f; } void mlMtxSet(Mtx* arg0) { s32 i, j; f32 *v0; - v0 = D_80282FD0 = &D_80282810; + v0 = s_mtx_stack = &D_80282810; for(i = 0; i < 4*4; i+=4){ for(j = 0; j < 4; j++){ *(v0++) = *(((f32*)arg0)++); @@ -214,9 +250,9 @@ void mlMtxSet(Mtx* arg0) { } } -void func_80251C20(f32 arg0, f32 arg1, f32 arg2, f32 arg3) { - func_8024632C(D_80282FD0 + 1, arg0, arg1, arg2, arg3); - func_80245DCC(D_80282FD0 + 1, D_80282FD0, D_80282FD0); +void mlMtxRotate(f32 a, f32 x, f32 y, f32 z) { + _guRotateF(s_mtx_stack + 1, a, x, y, z); + guMtxCatF(s_mtx_stack + 1, s_mtx_stack, s_mtx_stack); } void mlMtxRotPitch(f32 arg0) { @@ -229,20 +265,20 @@ void mlMtxRotPitch(f32 arg0) { arg0 *= D_80276578; sin = sinf(arg0); cos = cosf(arg0); - var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][0]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][0]); - reinterpret_cast(f32, D_80282FD0->m[1][0]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[2][0]) = var_f18*-sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[1][0]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[2][0]); + reinterpret_cast(f32, s_mtx_stack->m[1][0]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[2][0]) = var_f18*-sin + var_f10*cos; - var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][1]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][1]); - reinterpret_cast(f32, D_80282FD0->m[1][1]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[2][1]) = var_f18*-sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[1][1]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[2][1]); + reinterpret_cast(f32, s_mtx_stack->m[1][1]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[2][1]) = var_f18*-sin + var_f10*cos; - var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][2]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][2]); - reinterpret_cast(f32, D_80282FD0->m[1][2]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[2][2]) = var_f18*-sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[1][2]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[2][2]); + reinterpret_cast(f32, s_mtx_stack->m[1][2]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[2][2]) = var_f18*-sin + var_f10*cos; } } @@ -258,10 +294,10 @@ void mlMtxRotYaw(f32 arg0) { sin = sinf(arg0); cos = cosf(arg0); for(i = 0; i < 3; i++){ - var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][i]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][i]); - reinterpret_cast(f32, D_80282FD0->m[0][i]) = var_f18*cos - var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[2][i]) = var_f18*sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[0][i]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[2][i]); + reinterpret_cast(f32, s_mtx_stack->m[0][i]) = var_f18*cos - var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[2][i]) = var_f18*sin + var_f10*cos; } } } @@ -276,25 +312,25 @@ void mlMtxRotRoll(f32 arg0) { arg0 *= D_8027657C; sin = sinf(arg0); cos = cosf(arg0); - var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][0]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[1][0]); - reinterpret_cast(f32, D_80282FD0->m[0][0]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[1][0]) = var_f18*-sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[0][0]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[1][0]); + reinterpret_cast(f32, s_mtx_stack->m[0][0]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[1][0]) = var_f18*-sin + var_f10*cos; - var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][1]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[1][1]); - reinterpret_cast(f32, D_80282FD0->m[0][1]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[1][1]) = var_f18*-sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[0][1]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[1][1]); + reinterpret_cast(f32, s_mtx_stack->m[0][1]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[1][1]) = var_f18*-sin + var_f10*cos; - var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][2]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[1][2]); - reinterpret_cast(f32, D_80282FD0->m[0][2]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[1][2]) = var_f18*-sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[0][2]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[1][2]); + reinterpret_cast(f32, s_mtx_stack->m[0][2]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[1][2]) = var_f18*-sin + var_f10*cos; } } -void func_80251F8C(f32 arg0) { +void mlMtx_rotate_pitch_deg(f32 arg0) { f32 cos; f32 sin; f32 var_f10; @@ -306,15 +342,15 @@ void func_80251F8C(f32 arg0) { sin = sinf(arg0); cos = cosf(arg0); for(i = 0; i < 3; i++){ - var_f18 = reinterpret_cast(f32, D_80282FD0->m[1][i]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][i]); - reinterpret_cast(f32, D_80282FD0->m[1][i]) = var_f18*cos + var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[2][i]) = var_f18*-sin +var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[1][i]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[2][i]); + reinterpret_cast(f32, s_mtx_stack->m[1][i]) = var_f18*cos + var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[2][i]) = var_f18*-sin +var_f10*cos; } } } -void func_8025208C(f32 arg0) { +void mlMtx_rotate_yaw_deg(f32 arg0) { f32 cos; f32 sin; f32 var_f10; @@ -326,16 +362,16 @@ void func_8025208C(f32 arg0) { sin = sinf(arg0); cos = cosf(arg0); for(i = 0; i < 3; i++){ - var_f18 = reinterpret_cast(f32, D_80282FD0->m[0][i]); - var_f10 = reinterpret_cast(f32, D_80282FD0->m[2][i]); - reinterpret_cast(f32, D_80282FD0->m[0][i]) = var_f18*cos - var_f10*sin; - reinterpret_cast(f32, D_80282FD0->m[2][i]) = var_f18*sin + var_f10*cos; + var_f18 = reinterpret_cast(f32, s_mtx_stack->m[0][i]); + var_f10 = reinterpret_cast(f32, s_mtx_stack->m[2][i]); + reinterpret_cast(f32, s_mtx_stack->m[0][i]) = var_f18*cos - var_f10*sin; + reinterpret_cast(f32, s_mtx_stack->m[2][i]) = var_f18*sin + var_f10*cos; } } } -void mlMtxRotate(f32 pitch, f32 yaw, f32 roll){ +void mlMtxRotatePYR(f32 pitch, f32 yaw, f32 roll){ mlMtxRotYaw(yaw); mlMtxRotPitch(pitch); mlMtxRotRoll(roll); @@ -344,25 +380,25 @@ void mlMtxRotate(f32 pitch, f32 yaw, f32 roll){ void mlMtxScale_xyz(f32 x, f32 y, f32 z){ int i; for(i = 0; i < 3; i++){ - reinterpret_cast(f32, D_80282FD0->m[0][i]) *= x; - reinterpret_cast(f32, D_80282FD0->m[1][i]) *= y; - reinterpret_cast(f32, D_80282FD0->m[2][i]) *= z; + reinterpret_cast(f32, s_mtx_stack->m[0][i]) *= x; + reinterpret_cast(f32, s_mtx_stack->m[1][i]) *= y; + reinterpret_cast(f32, s_mtx_stack->m[2][i]) *= z; } } void mlMtxScale(f32 scale){ int i; for(i = 0; i < 3; i++){ - reinterpret_cast(f32, D_80282FD0->m[0][i]) *= scale; - reinterpret_cast(f32, D_80282FD0->m[1][i]) *= scale; - reinterpret_cast(f32, D_80282FD0->m[2][i]) *= scale; + reinterpret_cast(f32, s_mtx_stack->m[0][i]) *= scale; + reinterpret_cast(f32, s_mtx_stack->m[1][i]) *= scale; + reinterpret_cast(f32, s_mtx_stack->m[2][i]) *= scale; } } void func_80252330(f32 x, f32 y, f32 z){ - reinterpret_cast(f32, D_80282FD0->m[3][0]) = x; - reinterpret_cast(f32, D_80282FD0->m[3][1]) = y; - reinterpret_cast(f32, D_80282FD0->m[3][2]) = z; + reinterpret_cast(f32, s_mtx_stack->m[3][0]) = x; + reinterpret_cast(f32, s_mtx_stack->m[3][1]) = y; + reinterpret_cast(f32, s_mtx_stack->m[3][2]) = z; } void func_8025235C(f32 arg0[3], f32 arg1[3]) { @@ -374,10 +410,10 @@ void func_8025235C(f32 arg0[3], f32 arg1[3]) { sp0[2] = arg1[2]; for(i = 0; i < 3; i++){ - arg0[i] = sp0[0]*reinterpret_cast(f32, D_80282FD0->m[0][i]) - + sp0[1]*reinterpret_cast(f32, D_80282FD0->m[1][i]) - + sp0[2]*reinterpret_cast(f32, D_80282FD0->m[2][i]) - + reinterpret_cast(f32, D_80282FD0->m[3][i]); + arg0[i] = sp0[0]*reinterpret_cast(f32, s_mtx_stack->m[0][i]) + + sp0[1]*reinterpret_cast(f32, s_mtx_stack->m[1][i]) + + sp0[2]*reinterpret_cast(f32, s_mtx_stack->m[2][i]) + + reinterpret_cast(f32, s_mtx_stack->m[3][i]); } } @@ -385,17 +421,17 @@ void func_80252434(f32 arg0[3], f32 arg1[3]) { s32 i; for(i = 0; i < 3; i++){ - arg0[i] = arg1[0]*reinterpret_cast(f32, D_80282FD0->m[0][i]) - + arg1[1]*reinterpret_cast(f32, D_80282FD0->m[1][i]) - + arg1[2]*reinterpret_cast(f32, D_80282FD0->m[2][i]) - + reinterpret_cast(f32, D_80282FD0->m[3][i]); + arg0[i] = arg1[0]*reinterpret_cast(f32, s_mtx_stack->m[0][i]) + + arg1[1]*reinterpret_cast(f32, s_mtx_stack->m[1][i]) + + arg1[2]*reinterpret_cast(f32, s_mtx_stack->m[2][i]) + + reinterpret_cast(f32, s_mtx_stack->m[3][i]); } } -void func_802524F0(f32 dst[3], f32 x, f32 y, f32 z) { - dst[0] = x*((f32 (*)[4])D_80282FD0)[0][0] + y*((f32 (*)[4])D_80282FD0)[1][0] + z*((f32 (*)[4])D_80282FD0)[2][0] + ((f32 (*)[4])D_80282FD0)[3][0]; - dst[1] = x*((f32 (*)[4])D_80282FD0)[0][1] + y*((f32 (*)[4])D_80282FD0)[1][1] + z*((f32 (*)[4])D_80282FD0)[2][1] + ((f32 (*)[4])D_80282FD0)[3][1]; - dst[2] = x*((f32 (*)[4])D_80282FD0)[0][2] + y*((f32 (*)[4])D_80282FD0)[1][2] + z*((f32 (*)[4])D_80282FD0)[2][2] + ((f32 (*)[4])D_80282FD0)[3][2]; +void mlMtx_apply_f3(f32 dst[3], f32 x, f32 y, f32 z) { + dst[0] = x*((f32 (*)[4])s_mtx_stack)[0][0] + y*((f32 (*)[4])s_mtx_stack)[1][0] + z*((f32 (*)[4])s_mtx_stack)[2][0] + ((f32 (*)[4])s_mtx_stack)[3][0]; + dst[1] = x*((f32 (*)[4])s_mtx_stack)[0][1] + y*((f32 (*)[4])s_mtx_stack)[1][1] + z*((f32 (*)[4])s_mtx_stack)[2][1] + ((f32 (*)[4])s_mtx_stack)[3][1]; + dst[2] = x*((f32 (*)[4])s_mtx_stack)[0][2] + y*((f32 (*)[4])s_mtx_stack)[1][2] + z*((f32 (*)[4])s_mtx_stack)[2][2] + ((f32 (*)[4])s_mtx_stack)[3][2]; } void mlMtx_apply_vec3s(s16 dst[3], s16 src[3]) { @@ -403,7 +439,7 @@ void mlMtx_apply_vec3s(s16 dst[3], s16 src[3]) { f32 sp0[3]; f32 (*temp_v0)[4]; - temp_v0 = D_80282FD0; + temp_v0 = s_mtx_stack; sp0[0] = (f32) src[0]; sp0[1] = (f32) src[1]; sp0[2] = (f32) src[2]; @@ -457,9 +493,9 @@ void mlMtxTranslate(f32 x, f32 y, f32 z) { f32 phi_f10; s32 phi_v1; - phi_v0 = D_80282FD0; + phi_v0 = s_mtx_stack; for(phi_v1 = 0; phi_v1 < 0xC; phi_v1 +=4){ - phi_v0 = (u32)D_80282FD0 + phi_v1; + phi_v0 = (u32)s_mtx_stack + phi_v1; phi_f18 = phi_v0[0] * x; phi_f16 = phi_v0[4] * y; phi_v0[0xC] += phi_f18 + phi_f16 + (phi_v0[8] * z); @@ -470,7 +506,7 @@ void func_80252A38(f32 x, f32 y, f32 z) { s32 var_v1; for(var_v1 = 0; var_v1 != 3; var_v1++){ - reinterpret_cast(f32, D_80282FD0->m[3][var_v1]) += reinterpret_cast(f32, D_80282FD0->m[0][var_v1])*x + reinterpret_cast(f32, D_80282FD0->m[1][var_v1])*y + reinterpret_cast(f32, D_80282FD0->m[2][var_v1])*z; + reinterpret_cast(f32, s_mtx_stack->m[3][var_v1]) += reinterpret_cast(f32, s_mtx_stack->m[0][var_v1])*x + reinterpret_cast(f32, s_mtx_stack->m[1][var_v1])*y + reinterpret_cast(f32, s_mtx_stack->m[2][var_v1])*z; } } @@ -520,7 +556,7 @@ void func_80252C08(f32 arg0[3], f32 rotation[3], f32 scale, f32 arg3[3]){ } -void func_80252CC4(f32 arg0[3], f32 arg1[3], f32 scale, f32 arg3[3]){ +void func_80252CC4(f32 position[3], f32 rotation[3], f32 scale, f32 arg3[3]){ if(arg3 != NULL) mlMtxTranslate(arg3[0], arg3[1], arg3[2]); @@ -528,62 +564,62 @@ void func_80252CC4(f32 arg0[3], f32 arg1[3], f32 scale, f32 arg3[3]){ mlMtxScale_xyz(1.0f/scale, 1.0f/scale, 1.0f/scale); } - if(arg1 != NULL){ - mlMtxRotRoll(-arg1[2]); - mlMtxRotPitch(-arg1[0]); - mlMtxRotYaw(-arg1[1]); + if(rotation != NULL){ + mlMtxRotRoll(-rotation[2]); + mlMtxRotPitch(-rotation[0]); + mlMtxRotYaw(-rotation[1]); } - if(arg0 != NULL) - mlMtxTranslate(-arg0[0], -arg0[1], -arg0[2]); + if(position != NULL) + mlMtxTranslate(-position[0], -position[1], -position[2]); } -void func_80252D8C(f32 arg0[3], f32 arg1[3]){ - mlMtxTranslate(arg0[0], arg0[1], arg0[2]); - mlMtxRotRoll(arg1[2]); - mlMtxRotPitch(arg1[0]); - mlMtxRotYaw(arg1[1]); +void func_80252D8C(f32 position[3], f32 rotation[3]){ + mlMtxTranslate(position[0], position[1], position[2]); + mlMtxRotRoll(rotation[2]); + mlMtxRotPitch(rotation[0]); + mlMtxRotYaw(rotation[1]); } -void func_80252DDC(f32 arg0[3], f32 arg1[3]){ - mlMtxRotYaw(-arg1[1]); - mlMtxRotPitch(-arg1[0]); - mlMtxRotRoll(-arg1[2]); - mlMtxTranslate(-arg0[0], -arg0[1], -arg0[2]); +void func_80252DDC(f32 position[3], f32 rotation[3]){ + mlMtxRotYaw(-rotation[1]); + mlMtxRotPitch(-rotation[0]); + mlMtxRotRoll(-rotation[2]); + mlMtxTranslate(-position[0], -position[1], -position[2]); } -void func_80252E4C(f32 arg0[3], f32 arg1[3]){ - mlMtxTranslate(arg0[0], arg0[1], arg0[2]); - mlMtxRotRoll(arg1[2]); - mlMtxRotPitch(arg1[0]); - mlMtxRotYaw(arg1[1]); - mlMtxTranslate(-arg0[0], -arg0[1], -arg0[2]); +void func_80252E4C(f32 position[3], f32 rotation[3]){ + mlMtxTranslate(position[0], position[1], position[2]); + mlMtxRotRoll(rotation[2]); + mlMtxRotPitch(rotation[0]); + mlMtxRotYaw(rotation[1]); + mlMtxTranslate(-position[0], -position[1], -position[2]); } -void func_80252EC8(f32 arg0[3], f32 arg1[3]){ - mlMtxTranslate(arg0[0], arg0[1], arg0[2]); - mlMtxRotYaw(-arg1[1]); - mlMtxRotPitch(-arg1[0]); - mlMtxRotRoll(-arg1[2]); - mlMtxTranslate(-arg0[0], -arg0[1], -arg0[2]); +void func_80252EC8(f32 position[3], f32 rotation[3]){ + mlMtxTranslate(position[0], position[1], position[2]); + mlMtxRotYaw(-rotation[1]); + mlMtxRotPitch(-rotation[0]); + mlMtxRotRoll(-rotation[2]); + mlMtxTranslate(-position[0], -position[1], -position[2]); } -void func_80252F50(f32 arg0[3]){ - mlMtxRotYaw(arg0[1]); - mlMtxRotPitch(arg0[0]); - mlMtxRotRoll(arg0[2]); +void func_80252F50(f32 rotation[3]){ + mlMtxRotYaw(rotation[1]); + mlMtxRotPitch(rotation[0]); + mlMtxRotRoll(rotation[2]); } -void func_80252F8C(f32 arg0[3]){ - mlMtxRotRoll(arg0[2]); - mlMtxRotPitch(arg0[0]); - mlMtxRotYaw(arg0[1]); +void func_80252F8C(f32 rotation[3]){ + mlMtxRotRoll(rotation[2]); + mlMtxRotPitch(rotation[0]); + mlMtxRotYaw(rotation[1]); } -void func_80252FC8(f32 arg0[3]){ - mlMtxRotYaw(-arg0[1]); - mlMtxRotPitch(-arg0[0]); - mlMtxRotRoll(-arg0[2]); +void func_80252FC8(f32 rotation[3]){ + mlMtxRotYaw(-rotation[1]); + mlMtxRotPitch(-rotation[0]); + mlMtxRotRoll(-rotation[2]); } diff --git a/src/core1/code_18350.c b/src/core1/code_18350.c index 1b822f8d..15d2d3a7 100644 --- a/src/core1/code_18350.c +++ b/src/core1/code_18350.c @@ -30,7 +30,7 @@ f32 ml_acosValTbl[90] = { //D_80276CBC 0.0871559978, 0.0697569996, 0.0523359999, 0.0348990001, 0.0174519997 }; -f32 viewport_getYaw(void); +f32 viewport_get_yaw(void); // .h void func_80257918(f32 arg0[3], f32 arg1[3], f32 arg2[3], f32 arg3[3]); @@ -1481,7 +1481,7 @@ void func_802596AC(f32 a0[3], f32 a1[3], f32 a2[3], f32 a3[3]) s32 func_8025975C(f32 a0) { - f32 val = (s32)(viewport_getYaw() - a0); + f32 val = (s32)(viewport_get_yaw() - a0); while (val < 0) val += 360; diff --git a/src/core1/code_1BE90.c b/src/core1/code_1BE90.c index 418796bf..65331693 100644 --- a/src/core1/code_1BE90.c +++ b/src/core1/code_1BE90.c @@ -616,7 +616,7 @@ int func_8025AEEC(void){ return out; } -void func_8025AF38(void){ +void comusic_defrag(void){ CoMusic *iPtr; if(!D_80276E30) return; diff --git a/src/core1/code_2FA0.c b/src/core1/code_2FA0.c index f6fa3936..8faeeee3 100644 --- a/src/core1/code_2FA0.c +++ b/src/core1/code_2FA0.c @@ -17,7 +17,7 @@ void func_802409C0(f32 arg0[3], f32 arg1){ sp30[1] = 0.0f; sp30[2] = -(sp28[1] * sp24); - viewport_getRotation(&sp3C); + viewport_get_rotation_vec3f(&sp3C); ml_vec3f_yaw_rotate_copy(sp30, sp30, sp3C[1]); arg0[0] = arg0[0] + sp30[0]; @@ -59,7 +59,7 @@ void func_80240AC8(f32 arg0[3], f32 arg1){ sp30[1] = 0.0f; sp30[2] = -(sp28[1] * sp24); - viewport_getRotation(&sp3C); + viewport_get_rotation_vec3f(&sp3C); ml_vec3f_yaw_rotate_copy(sp30, sp30, sp3C[1]); arg0[0] = arg0[0] + sp30[0]; diff --git a/src/core1/code_3250.c b/src/core1/code_3250.c index c94acaa4..3a914880 100644 --- a/src/core1/code_3250.c +++ b/src/core1/code_3250.c @@ -1,7 +1,7 @@ #include extern f32 gu_sqrtf(f32); -static void _guMtxF2L(float mf[4][4], Mtx *m) +static void __guMtxF2L(float mf[4][4], Mtx *m) { int i, j; int e1,e2; @@ -142,7 +142,7 @@ void guScale(Mtx *m, float x, float y, float z) float mf[4][4]; guScaleF(mf, x, y, z); - _guMtxF2L(mf, m); + __guMtxF2L(mf, m); } void guRotateRPYF(f32 mf[4][4], f32 r, f32 p, f32 h) { diff --git a/src/core1/code_3A70.c b/src/core1/code_3A70.c index bbd00db8..de7c0f9e 100644 --- a/src/core1/code_3A70.c +++ b/src/core1/code_3A70.c @@ -4,7 +4,7 @@ extern f32 ml_cos_deg(f32); extern f32 ml_sin_deg(f32); -extern void func_8024C5F0(s32[3]); +extern void veiwport_get_position_vec3w(s32[3]); Gfx D_80275880[] = { gsSPClearGeometryMode(G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH | G_CLIPPING | 0x0060CD00), @@ -26,7 +26,7 @@ void func_80241490(Gfx **gfx, Vtx **vtx, s32 *arg2[3], s32 arg3[3], s32 arg4[3], s32 sp78[3][4]; s32 i; - func_8024C5F0(spB4); + veiwport_get_position_vec3w(spB4); gSPDisplayList((*gfx)++, D_80275880); if (arg6 != 0) { gSPSetGeometryMode((*gfx)++, G_ZBUFFER | G_CULL_BACK); @@ -95,7 +95,7 @@ void func_80241928(Gfx** gfx, Vtx** vtx, s32 arg2[3], s32 arg3, s32 arg4[3]) { s32 var_fp; s32 var_s0; - func_8024C5F0(spB4); + veiwport_get_position_vec3w(spB4); for(var_fp = 0; var_fp < 4; var_fp++){ gSPDisplayList((*gfx)++, D_80275880); gSPSetGeometryMode((*gfx)++, G_ZBUFFER); @@ -162,7 +162,7 @@ void func_802424D4(Gfx **gfx, Mtx **mtx, Vtx **vtx, f32 arg3[3], f32 arg4[3], f3 sp68[1] *= arg5; sp68[2] *= arg5; - viewport_getPosition(sp5C); + viewport_get_position_vec3f(sp5C); gSPDisplayList((*gfx)++, D_80275880); gSPSetGeometryMode((*gfx)++, G_ZBUFFER); gSPVertex((*gfx)++, *vtx, 8, 0); @@ -209,7 +209,7 @@ void func_80242BE8(Gfx **gfx, Vtx **arg1, f32 arg2[2][2][2][3], s32 arg3[3], s32 s32 i; s32 j; s32 k; - viewport_getPosition(sp84); + viewport_get_position_vec3f(sp84); gSPDisplayList((*gfx)++, D_80275880); if (arg5){ gSPSetGeometryMode((*gfx)++, G_CULL_BACK); diff --git a/src/core1/code_7F60.c b/src/core1/code_7F60.c index 21bbe26c..6f2381e7 100644 --- a/src/core1/code_7F60.c +++ b/src/core1/code_7F60.c @@ -2,14 +2,16 @@ #include "functions.h" #include "variables.h" +static void _guMtxIdentF(float mf[4][4]); + u8 D_80275900[] = {0xCF, 0xAD, 0xA2, 0x90, 0x93, 0x4A, 0x83, 0xF1}; f32 D_80275908 = BAD_DTOR; -s32 func_80245980(f32 arg0){ +static s32 guFToFix32(f32 arg0){ return arg0*65536.0f; } -void func_802459A0(float mf[4][4], Mtx *m) +static void __guMtxF2L(float mf[4][4], Mtx *m) { int i, j; int e1,e2; @@ -21,14 +23,14 @@ void func_802459A0(float mf[4][4], Mtx *m) for (i=0; i<4; i++) for (j=0; j<2; j++) { - e1=func_80245980(mf[i][j*2]); - e2=func_80245980(mf[i][j*2+1]); + e1=guFToFix32(mf[i][j*2]); + e2=guFToFix32(mf[i][j*2+1]); *(ai++) = ( e1 & 0xffff0000 ) | ((e2 >> 16)&0xffff); *(af++) = ((e1 << 16) & 0xffff0000) | (e2 & 0xffff); } } -void func_80245A7C(float mf[4][4], Mtx *m) //should be mf[4][4] +void _guMtxF2L(float mf[4][4], Mtx *m) //should be mf[4][4] { int i; int j; @@ -50,10 +52,10 @@ void func_80245A7C(float mf[4][4], Mtx *m) //should be mf[4][4] } } -void func_80245BE4(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { +void _guFustrumF(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg5, f32 arg6, f32 arg7) { s32 i, j; - _guMtxIdentF_80245D44(mf); + _guMtxIdentF(mf); mf[0][0] = (2 * arg5) / (arg2 - arg1); mf[1][1] = (2 * arg5) / (arg4 - arg3); mf[2][0] = (arg2 + arg1) / (arg2 - arg1); @@ -69,7 +71,7 @@ void func_80245BE4(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3, f32 arg4, f32 arg } } -void _guMtxIdentF_80245D44(float mf[4][4]) //static +static void _guMtxIdentF(float mf[4][4]) //static { int i, j; @@ -79,7 +81,7 @@ void _guMtxIdentF_80245D44(float mf[4][4]) //static else mf[i][j] = 0.0; } -void func_80245DCC(f32 lmf[4][4], f32 rmf[4][4], f32 dst[4][4]) { +void guMtxCatF(f32 lmf[4][4], f32 rmf[4][4], f32 dst[4][4]) { s32 i, j, k; f32 sp1C[4][4]; @@ -98,7 +100,7 @@ void func_80245DCC(f32 lmf[4][4], f32 rmf[4][4], f32 dst[4][4]) { } } -void func_80245F34(f32 *arg0, f32 *arg1, f32 *arg2) { +static void _guNormalize(f32 *arg0, f32 *arg1, f32 *arg2) { f32 inv_len; inv_len = 1.0f / gu_sqrtf((*arg0 * *arg0) + (*arg1 * *arg1) + (*arg2 * *arg2)); @@ -107,7 +109,7 @@ void func_80245F34(f32 *arg0, f32 *arg1, f32 *arg2) { *arg2 *= inv_len; } -void func_80245FB8(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale) +void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale) { float cot; float tmp; @@ -163,25 +165,25 @@ void func_80245FB8(float mf[4][4], u16 *perspNorm, float fovy, float aspect, flo void guPerspective(Mtx *m, u16 *perspNorm, f32 fovy, f32 aspect, f32 near, f32 far, f32 scale) { f32 sp28[4][4]; - func_80245FB8(sp28, perspNorm, fovy, aspect, near, far, scale); - func_802459A0(sp28, m); + guPerspectiveF(sp28, perspNorm, fovy, aspect, near, far, scale); + __guMtxF2L(sp28, m); } -void func_8024632C(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3, f32 arg4) { +void _guRotateF(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3, f32 arg4) { f32 sp34; f32 sp30; f32 sp2C; f32 sp28; volatile f32 sp24; - func_80245F34(&arg2, &arg3, &arg4); + _guNormalize(&arg2, &arg3, &arg4); arg1 *= D_80275908; sp34 = sinf(arg1); sp30 = cosf(arg1); sp2C = arg2 * arg3 * (1.0f - sp30); sp28 = arg3 * arg4 * (1.0f - sp30); sp24 = (arg4 * arg2 * (1.0f - sp30)); - _guMtxIdentF_80245D44(mf); + _guMtxIdentF(mf); mf[0][0] = ((1.0f - (arg2 * arg2)) * sp30) + (arg2 * arg2); mf[2][1] = (sp28 - (arg2 * sp34)); mf[1][2] = ((arg2 * sp34) + sp28); @@ -195,10 +197,10 @@ void func_8024632C(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3, f32 arg4) { mf[0][1] = (arg4 * sp34) + sp2C; } -void func_802464B0(f32 mf[4][4], f32 arg1){ +void guRotateRollF(f32 mf[4][4], f32 arg1){ f32 c, s; arg1 *= D_80275908; - _guMtxIdentF_80245D44(mf); + _guMtxIdentF(mf); c = cosf(arg1); mf[1][1] = c; mf[2][2] = c; @@ -207,10 +209,10 @@ void func_802464B0(f32 mf[4][4], f32 arg1){ mf[2][1] = -s; } -void func_80246510(f32 mf[4][4], f32 arg1){ +void guRotatePitchF(f32 mf[4][4], f32 arg1){ f32 c, s; arg1 *= D_80275908; - _guMtxIdentF_80245D44(mf); + _guMtxIdentF(mf); c = cosf(arg1); mf[0][0] = c; mf[2][2] = c; @@ -219,10 +221,10 @@ void func_80246510(f32 mf[4][4], f32 arg1){ mf[0][2] = -s; } -void func_80246570(f32 mf[4][4], f32 arg1){ +void guRotateYawF(f32 mf[4][4], f32 arg1){ f32 c, s; arg1 *= D_80275908; - _guMtxIdentF_80245D44(mf); + _guMtxIdentF(mf); c = cosf(arg1); mf[0][0] = c; mf[1][1] = c; @@ -231,16 +233,16 @@ void func_80246570(f32 mf[4][4], f32 arg1){ mf[1][0] = -s; } -void func_802465D0(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3){ - _guMtxIdentF_80245D44(mf); +void _guScaleF(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3){ + _guMtxIdentF(mf); mf[0][0] = arg1; mf[1][1] = arg2; mf[2][2] = arg3; mf[3][3] = 1.0f; } -void func_80246624(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3){ - _guMtxIdentF_80245D44(mf); +void _guTranslateF(f32 mf[4][4], f32 arg1, f32 arg2, f32 arg3){ + _guMtxIdentF(mf); mf[3][0] = arg1; mf[3][1] = arg2; mf[3][2] = arg3; diff --git a/src/core1/code_ABB0.c b/src/core1/code_ABB0.c index b25c79f7..5b53b136 100644 --- a/src/core1/code_ABB0.c +++ b/src/core1/code_ABB0.c @@ -535,7 +535,7 @@ void draw_texture_ci4(s32 x, s32 y, void *tmem, s32 w, s32 h, bool alpha_enabled } } -void func_80249CEC(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enabled) { +void draw_sprite(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enabled) { s16 temp_v0; temp_v0 = sprite->type; diff --git a/src/core1/code_EAF0.c b/src/core1/code_EAF0.c index b067227b..2d455ee6 100644 --- a/src/core1/code_EAF0.c +++ b/src/core1/code_EAF0.c @@ -5,11 +5,13 @@ extern void guPerspective(Mtx *, u16*, f32, f32, f32, f32, f32); extern f32 ml_dotProduct_vec3f(f32[3], f32[3]); +#define VIEWPORT_FOVY_DEFAULT (40.0f) + /* .data */ -f32 D_80275D20 = 40.0f; //fovy -f32 D_80275D24 = 1.35185182f; //aspect -f32 D_80275D28 = 30.0f; //near -f32 D_80275D2C = 4000.0f; //far +f32 s_viewport_fovy = VIEWPORT_FOVY_DEFAULT; //fovy +f32 s_viewport_aspect = 1.35185182f; //aspect +f32 s_viewport_near = 30.0f; //near +f32 s_viewport_far = 4000.0f; //far /* .data */ f32 D_80280EA0[3]; @@ -30,11 +32,11 @@ void func_8024F450(void); void func_8024F4AC(void); void func_8024C964(Gfx **, Mtx **, f32, f32); void func_8024CD7C(int); -void func_8024CDF8(f32, f32, f32); -void func_8024CE40(f32, f32, f32); +void viewport_set_position_f3(f32, f32, f32); +void viewport_set_rotation_f3(f32, f32, f32); void func_8024CE60(f32, f32); void func_8024CE74(s32 arg0, s32 arg1, s32 arg2, s32 arg3); -void func_8024DDB4(f32); +void viewport_set_field_of_view(f32); void func_80256E24(f32 [3], f32, f32, f32, f32, f32); @@ -55,31 +57,31 @@ void func_8024C5A8(f32 arg0[3]){ ml_vec3f_copy(arg0, D_80280EA0); } -void viewport_getPosition(f32 arg0[3]){ +void viewport_get_position_vec3f(f32 arg0[3]){ ml_vec3f_copy(arg0, viewportPosition); } -void func_8024C5F0(s32 dst[3]){ +void veiwport_get_position_vec3w(s32 dst[3]){ dst[0] = ((f32)(s32)(viewportPosition[0]*500.0))/500.0; dst[1] = ((f32)(s32)(viewportPosition[1]*500.0))/500.0; dst[2] = ((f32)(s32)(viewportPosition[2]*500.0))/500.0; } -void func_8024C6A0(s16 dst[3]){ +void veiwport_get_position_vec3s(s16 dst[3]){ dst[0] = ((f32)(s32)(viewportPosition[0]*500.0))/500.0; dst[1] = ((f32)(s32)(viewportPosition[1]*500.0))/500.0; dst[2] = ((f32)(s32)(viewportPosition[2]*500.0))/500.0; } -void viewport_getRotation(f32 arg0[3]){ +void viewport_get_rotation_vec3f(f32 arg0[3]){ ml_vec3f_copy(arg0, viewportRotation); } -f32 viewport_getYaw(void){ +f32 viewport_get_yaw(void){ return viewportRotation[1]; } -void func_8024C794(f32 *pitch, f32 *yaw, f32 *roll){ +void viewport_get_rotation_f3(f32 *pitch, f32 *yaw, f32 *roll){ *pitch = viewportRotation[0]; *yaw = viewportRotation[1]; *roll = viewportRotation[2]; @@ -97,21 +99,21 @@ void func_8024C7B8(Gfx **gfx, Mtx **mtx){ void func_8024C904(Gfx **gfx, Mtx **mtx){ gSPViewport((*gfx)++, &D_80280F10[D_80281018]); - func_8024C964(gfx, mtx, D_80275D28, D_80275D2C); + func_8024C964(gfx, mtx, s_viewport_near, s_viewport_far); } void func_8024C964(Gfx **gfx, Mtx **mtx, f32 near, f32 far){ u16 sp5e; - near = MAX(D_80275D28, near); - far = MIN(D_80275D2C, far); + near = MAX(s_viewport_near, near); + far = MIN(s_viewport_far, far); if(*(u32*)OS_PHYSICAL_TO_K1(0x1D8) + 0x53D4FFF0){ near = 750.0f; far = 1250.0f; } - guPerspective(*mtx, &sp5e, D_80275D20, D_80275D24, near, far, 0.5f); + guPerspective(*mtx, &sp5e, s_viewport_fovy, s_viewport_aspect, near, far, 0.5f); gSPPerspNormalize((*gfx)++, sp5e); gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); @@ -129,7 +131,7 @@ void func_8024C964(Gfx **gfx, Mtx **mtx, f32 near, f32 far){ } void func_8024CBD4(Gfx **gfx, Mtx **mtx){ - func_8024C964(gfx, mtx, D_80275D28, D_80275D2C); + func_8024C964(gfx, mtx, s_viewport_near, s_viewport_far); } void func_8024CC00(void){} @@ -150,12 +152,12 @@ void func_8024CC5C(void){ void func_8024CCC4(void){ func_8024CD7C(1); - func_8024CDF8(0.0f, 0.0f, 0.0f); - func_8024CE40(0.0f, 0.0f, 0.0f); + viewport_set_position_f3(0.0f, 0.0f, 0.0f); + viewport_set_rotation_f3(0.0f, 0.0f, 0.0f); func_8024CC08(40.0f); func_8024CE60(1.0f, 10000.0f); func_8024CC5C(); - func_8024DDB4(40.0f); + viewport_set_field_of_view(VIEWPORT_FOVY_DEFAULT); mlMtxIdent(); mlMtxRotYaw(-60.0f); mlMtxRotPitch(-90.0f); @@ -166,35 +168,35 @@ void func_8024CD7C(int arg0){ D_80280F90 = arg0; } -void viewport_setPosition(f32 src[3]){ +void viewport_set_position_vec3f(f32 src[3]){ ml_vec3f_copy(viewportPosition, src); } -void func_8024CDB0(s32 src[3]){ +void viewport_set_position_vec3w(s32 src[3]){ viewportPosition[0] = (f32)src[0]; viewportPosition[1] = (f32)src[1]; viewportPosition[2] = (f32)src[2]; } -void func_8024CDF8(f32 arg0, f32 arg1, f32 arg2){ - viewportPosition[0] = arg0; - viewportPosition[1] = arg1; - viewportPosition[2] = arg2; +void viewport_set_position_f3(f32 x, f32 y, f32 z){ + viewportPosition[0] = x; + viewportPosition[1] = y; + viewportPosition[2] = z; } -void viewport_setRotation(f32 src[3]){ +void viewport_set_rotation_vec3f(f32 src[3]){ ml_vec3f_copy(viewportRotation, src); } -void func_8024CE40(f32 arg0, f32 arg1, f32 arg2){ - viewportRotation[0] = arg0; - viewportRotation[1] = arg1; - viewportRotation[2] = arg2; +void viewport_set_rotation_f3(f32 pitch, f32 yaw, f32 roll){ + viewportRotation[0] = pitch; + viewportRotation[1] = yaw; + viewportRotation[2] = roll; } void func_8024CE60(f32 near, f32 far){ - D_80275D28 = near; - D_80275D2C = far; + s_viewport_near = near; + s_viewport_far = far; } void func_8024CE74(s32 arg0, s32 arg1, s32 arg2, s32 arg3){ @@ -348,14 +350,14 @@ bool func_8024D9B0(Cube *cube) { } bool func_8024DB50(f32 arg0[3], f32 arg1) { - f32 sp3C[3]; + f32 delta[3]; s32 i; - sp3C[0] = arg0[0] - viewportPosition[0]; - sp3C[1] = arg0[1] - viewportPosition[1]; - sp3C[2] = arg0[2] - viewportPosition[2]; + delta[0] = arg0[0] - viewportPosition[0]; + delta[1] = arg0[1] - viewportPosition[1]; + delta[2] = arg0[2] - viewportPosition[2]; for(i = 0; i < 4; i++){ - if(arg1 <= ml_dotProduct_vec3f(sp3C, D_80280ED0[i])){ + if(arg1 <= ml_dotProduct_vec3f(delta, D_80280ED0[i])){ return FALSE; } } @@ -392,20 +394,20 @@ Mtx *func_8024DD9C(void){ return &D_80280FD8; } -f32 func_8024DDA8(void){ - return D_80275D20; +f32 viewport_get_field_of_view(void){ + return s_viewport_fovy; } -void func_8024DDB4(f32 arg0){ - D_80275D20 = arg0; +void viewport_set_field_of_view(f32 fovy){ + s_viewport_fovy = fovy; } -f32 func_8024DDC0(void){ - return D_80275D24; +f32 viewport_get_aspect_ratio(void){ + return s_viewport_aspect; } -f32 func_8024DDCC(void){ - return D_80275D28; +f32 viewport_get_near(void){ + return s_viewport_near; } f32 func_8024DDD8(s32 arg0, f32 arg1){ @@ -413,16 +415,16 @@ f32 func_8024DDD8(s32 arg0, f32 arg1){ } f32 func_8024DE1C(f32 arg0, f32 arg1, f32 arg2[3], f32 arg3[3]) { - f32 sp24; + f32 fovy_rad; static f32 D_8028101C; static f32 D_80281020; static f32 D_80281024; - if ((D_80275D20 != D_8028101C) || (D_80275D28 != D_80281020)) { - sp24 = (D_80275D20 * M_PI) / 360.0; - D_80281024 = (500.0 + D_80275D28) / (((framebuffer_height / (f32)2) / sinf(sp24)) * cosf(sp24)); - D_8028101C = D_80275D20; - D_80281020 = D_80275D28; + if ((s_viewport_fovy != D_8028101C) || (s_viewport_near != D_80281020)) { + fovy_rad = (s_viewport_fovy * M_PI) / 360.0; + D_80281024 = (500.0 + s_viewport_near) / (((framebuffer_height / (f32)2) / sinf(fovy_rad)) * cosf(fovy_rad)); + D_8028101C = s_viewport_fovy; + D_80281020 = s_viewport_near; } arg0 = arg0 - (framebuffer_width / (f32)2); arg1 = (framebuffer_height / (f32)2) - arg1; @@ -431,7 +433,7 @@ f32 func_8024DE1C(f32 arg0, f32 arg1, f32 arg2[3], f32 arg3[3]) { arg3[2] = viewportRotation[2]; arg2[0] = arg0 * D_80281024; arg2[1] = arg1 * D_80281024; - arg2[2] = (-500.0 - D_80275D28); + arg2[2] = (-500.0 - s_viewport_near); ml_vec3f_pitch_rotate_copy(arg2, arg2, arg3[0]); ml_vec3f_yaw_rotate_copy(arg2, arg2, arg3[1]); @@ -456,13 +458,13 @@ bool func_8024E030(f32 arg0[3], f32 *arg1) f32 temp_f2_2; f32 temp_f2; f32 sp28; - sp28 = (D_80275D20 * 3.14159265358979323846) / 360.0; + sp28 = (s_viewport_fovy * M_PI) / 360.0; sp34[0] = arg0[0] - viewportPosition[0]; sp34[1] = arg0[1] - viewportPosition[1]; sp34[2] = arg0[2] - viewportPosition[2]; ml_vec3f_yaw_rotate_copy(sp34, sp34, -viewportRotation[1]); ml_vec3f_pitch_rotate_copy(sp34, sp34, -viewportRotation[0]); - if ((-D_80275D28) <= sp34[2]) { + if ((-s_viewport_near) <= sp34[2]) { return 0; } temp_f2 = gu_sqrtf((sp34[1] * sp34[1]) + (sp34[2] * sp34[2])) * sinf(sp28); @@ -480,8 +482,8 @@ bool func_8024E030(f32 arg0[3], f32 *arg1) void func_8024E258(void){ s32 i, j; - viewport_getPosition(D_80281028); - viewport_getRotation(D_80281038); + viewport_get_position_vec3f(D_80281028); + viewport_get_rotation_vec3f(D_80281038); func_8024D1EC(D_80281048, D_80281058, D_80281068, D_80281078); func_8024C5A8(D_80281088); for(i = 0; i < 4; i++){ @@ -493,8 +495,8 @@ void func_8024E258(void){ void func_8024E2FC(void){ s32 i, j; - viewport_setPosition(D_80281028); - viewport_setRotation(D_80281038); + viewport_set_position_vec3f(D_80281028); + viewport_set_rotation_vec3f(D_80281038); func_8024D2B0(D_80281048, D_80281058, D_80281068, D_80281078); ml_vec3f_copy(D_80280EA0, D_80281088); for(i = 0; i < 4; i++){ @@ -505,10 +507,10 @@ void func_8024E2FC(void){ } //moves the point(arg0) some distance (arg1) further away from the camera -void func_8024E3A8(f32 arg0[3], f32 arg1){ +void func_8024E3A8(f32 arg0[3], f32 distance){ f32 sp1C[3]; ml_vec3f_diff_copy(sp1C, viewportPosition, arg0); - ml_vec3f_set_length_copy(sp1C, sp1C, arg1); + ml_vec3f_set_length_copy(sp1C, sp1C, distance); arg0[0] += sp1C[0]; arg0[1] += sp1C[1]; arg0[2] += sp1C[2]; diff --git a/src/core1/data_1E820.c b/src/core1/data_1E820.c index ccd7b314..99bccb51 100644 --- a/src/core1/data_1E820.c +++ b/src/core1/data_1E820.c @@ -1 +1 @@ -unsigned long long D_80276E70 = 0xAB8D9F7781280783; \ No newline at end of file +unsigned long long D_80276E70 = 0xAB8D9F7781280783; diff --git a/src/core1/memory.c b/src/core1/memory.c index e88a24ce..c0c3d9a9 100644 --- a/src/core1/memory.c +++ b/src/core1/memory.c @@ -800,7 +800,7 @@ void func_80255A3C(void){ func_802E6820(1); if(!func_802559A0()) - func_802F542C(); + printbuffer_defrag(); if(!func_802559A0()){ ml_defrag(); diff --git a/src/core1/os/kdebugserver.c b/src/core1/os/kdebugserver.c index 9d062249..9686ad6e 100644 --- a/src/core1/os/kdebugserver.c +++ b/src/core1/os/kdebugserver.c @@ -1,4 +1,4 @@ #include //not included in final rom, but __osThreadSave is here for some reason -OSThread __osThreadSave; \ No newline at end of file +OSThread __osThreadSave; diff --git a/src/core2/bs/bFly.c b/src/core2/bs/bFly.c index 3d95e39d..c9bcd43c 100644 --- a/src/core2/bs/bFly.c +++ b/src/core2/bs/bFly.c @@ -36,7 +36,7 @@ int func_802A3350(void){ void func_802A339C(f32 arg0[3], f32 arg1[3], f32 arg2){ func_8024C5A8(arg0); ml_vec3f_scale(arg0, arg2); - viewport_getRotation(arg1); + viewport_get_rotation_vec3f(arg1); } void func_802A33D8(void){ diff --git a/src/core2/ch/badShad.c b/src/core2/ch/badShad.c index 6ee83745..950e3db0 100644 --- a/src/core2/ch/badShad.c +++ b/src/core2/ch/badShad.c @@ -88,7 +88,7 @@ f32 func_802D7038(Actor *this) { void func_802D7124(Actor *actor, f32 arg1) { f32 vp[3]; - viewport_getPosition(&vp); + viewport_get_position_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); } @@ -112,7 +112,7 @@ void func_802D71A0(s32 this, s32 arg1){ sp2C[0] = (s32) D_8037DE10[0]; sp2C[1] = (s32) D_8037DE10[1]; sp2C[2] = (s32) D_8037DE10[2]; - sp3C = func_803056FC(0x108, sp2C, (s32)sp38->yaw); + sp3C = spawn_actor(0x108, sp2C, (s32)sp38->yaw); if(sp3C){ marker_getActor(marker)->unk104 = sp3C->marker; sp3C->unk104 = marker; diff --git a/src/core2/ch/bottlesbonus.c b/src/core2/ch/bottlesbonus.c index ec45b440..50f9b833 100644 --- a/src/core2/ch/bottlesbonus.c +++ b/src/core2/ch/bottlesbonus.c @@ -139,8 +139,8 @@ void chBottlesBonus_func_802DD080(Gfx **gfx, Mtx **mtx) { vp_rotation[1] = 270.0f; vp_rotation[2] = 0.0f; } - viewport_setPosition(vp_position); - viewport_setRotation(vp_rotation); + viewport_set_position_vec3f(vp_position); + viewport_set_rotation_vec3f(vp_rotation); viewport_update(); func_8024C904(gfx, mtx); } @@ -505,7 +505,7 @@ void chBottlesBonus_update(Actor *this) { this->unk60 += sp50; switch(this->state){ case 1: - if ((this->unk60 > 2.0) && gctransition_8030BD98()) { + if ((this->unk60 > 2.0) && gctransition_done()) { this->unk60 = 0.0f; func_8025A6EC(COMUSIC_98_BBONUS_PIECES_SHUFFLE, -1); comusic_8025AB44(COMUSIC_95_BBONUS_A, 0, 2000); diff --git a/src/core2/ch/code_468E0.c b/src/core2/ch/code_468E0.c index 0d96f9f3..abc75f55 100644 --- a/src/core2/ch/code_468E0.c +++ b/src/core2/ch/code_468E0.c @@ -88,11 +88,11 @@ void func_802CDAC4(Actor *this){ f32 sp1C[3]; camera_setType(1); - viewport_setPosition(this->position); + viewport_set_position_vec3f(this->position); sp1C[0] = this->pitch; sp1C[1] = this->yaw; sp1C[2] = 0.0f; - viewport_setRotation(sp1C); + viewport_set_rotation_vec3f(sp1C); } void func_802CDB18(Actor *this){ diff --git a/src/core2/ch/gravestone.c b/src/core2/ch/gravestone.c index c3fef13b..69a08929 100644 --- a/src/core2/ch/gravestone.c +++ b/src/core2/ch/gravestone.c @@ -3,9 +3,9 @@ #include "variables.h" #include "core2/particle.h" - Actor *func_8035ECA0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx); void func_8035F138(Actor *this); +extern bool func_803257B4(ActorMarker *marker); extern void actor_postdrawMethod(ActorMarker *); extern f32 func_80257204(f32, f32, f32, f32); diff --git a/src/core2/ch/overlaynocontroller.c b/src/core2/ch/overlaynocontroller.c index e870582f..b9f5f279 100644 --- a/src/core2/ch/overlaynocontroller.c +++ b/src/core2/ch/overlaynocontroller.c @@ -40,8 +40,8 @@ Actor *chOverlayNoController_draw(ActorMarker *marker, Gfx **gdl, Mtx **mptr, Vt func_8024E258(); {sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 1312.5f;}; {sp4C[0] = 0.0f; sp4C[1] = 0.0f; sp4C[2] = 0.0f;}; - viewport_setPosition(sp58); - viewport_setRotation(sp4C); + viewport_set_position_vec3f(sp58); + viewport_set_rotation_vec3f(sp4C); viewport_update(); func_8024C904(gdl, mptr); {sp40[0] = 0.0f; sp40[1] = 0.0f; sp40[2] = 0.0f;}; diff --git a/src/core2/ch/overlaypressstart.c b/src/core2/ch/overlaypressstart.c index 2777d9fa..74fdb6e8 100644 --- a/src/core2/ch/overlaypressstart.c +++ b/src/core2/ch/overlaypressstart.c @@ -50,8 +50,8 @@ Actor *chOverlayPressStart_draw(ActorMarker *marker, Gfx **gdl, Mtx **mptr, Vtx func_8024E258(); {sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 1312.5f;}; {sp4C[0] = 0.0f; sp4C[1] = 0.0f; sp4C[2] = 0.0f;}; - viewport_setPosition(sp58); - viewport_setRotation(sp4C); + viewport_set_position_vec3f(sp58); + viewport_set_rotation_vec3f(sp4C); viewport_update(); func_8024C904(gdl, mptr); {sp40[0] = 0.0f; sp40[1] = 0.0f; sp40[2] = 0.0f;}; diff --git a/src/core2/ch/shrapnel.c b/src/core2/ch/shrapnel.c index ad81168d..ef741ee9 100644 --- a/src/core2/ch/shrapnel.c +++ b/src/core2/ch/shrapnel.c @@ -85,12 +85,12 @@ void chShrapnel_emitSmoke(Actor *this) { func_802EFB84(temp_v0, 2.0f, 3.0f); particleEmitter_setParticleSpawnPositionRange(temp_v0, -75.0f, 25.0f, -75.0f, 75.0f, 75.0f, 75.0f); particleEmitter_setParticleVelocityRange(temp_v0, -70.0f, 50.0f, -70.0f, 70.0f, 100.0f, 70.0f); - particleEmitter_setRGB(temp_v0, &D_803673F8); + particleEmitter_setRGB(temp_v0, D_803673F8); particleEmitter_setParticleLifeTimeRange(temp_v0, 3.0f, 4.0f); particleEmitter_emitN(temp_v0, 6); } -void chShrapnel_emitBodyParts(Actor *this, enum model_e model_id, s32 n) { +void chShrapnel_emitBodyParts(Actor *this, enum asset_e model_id, s32 n) { ParticleEmitter *temp_v0; temp_v0 = partEmitMgr_newEmitter(n); diff --git a/src/core2/ch/snowball.c b/src/core2/ch/snowball.c index b5404a14..1134ead5 100644 --- a/src/core2/ch/snowball.c +++ b/src/core2/ch/snowball.c @@ -3,8 +3,9 @@ #include "variables.h" extern void func_80329904(ActorMarker *, s32, f32 *); -extern int func_80320C94(f32 (*)[3], f32(*)[3], f32, s32, s32, u32); extern f32 func_8033229C(ActorMarker *); +extern BKCollisionTri *func_80320C94(f32[3], f32[3], f32, f32[3], s32, u32); + typedef struct{ s32 unk0; diff --git a/src/core2/ch/termite.c b/src/core2/ch/termite.c index 8d423ca3..90910ccd 100644 --- a/src/core2/ch/termite.c +++ b/src/core2/ch/termite.c @@ -52,7 +52,7 @@ void __chTermite_updateWalkSFX(Actor *this) { f32 sp24[3]; f32 sp20; - viewport_getPosition(&sp24); + viewport_get_position_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_14420.c b/src/core2/code_14420.c index d0de9d82..7746ea2e 100644 --- a/src/core2/code_14420.c +++ b/src/core2/code_14420.c @@ -203,7 +203,7 @@ f32 func_8029B41C(void){ f32 sp1C; player_getPosition(sp2C); - viewport_getPosition(sp20); + viewport_get_position_vec3f(sp20); func_80257F18(sp2C, sp20, &sp1C); return sp1C; } @@ -363,7 +363,7 @@ void func_8029B984(f32 dst[3]){ f32 sp18[3]; _player_getPosition(plyr_pos); - viewport_getPosition(sp18); + viewport_get_position_vec3f(sp18); ml_vec3f_diff_copy(dst, sp18, plyr_pos); } diff --git a/src/core2/code_33C30.c b/src/core2/code_33C30.c index be14e397..e4a74d11 100644 --- a/src/core2/code_33C30.c +++ b/src/core2/code_33C30.c @@ -33,8 +33,8 @@ void func_802BAC58(void) { f32 vp_rotation[3]; f32 sp1C[3]; - viewport_getPosition(vp_position); - viewport_getRotation(vp_rotation); + viewport_get_position_vec3f(vp_position); + viewport_get_rotation_vec3f(vp_rotation); func_802BEA4C(vp_rotation, vp_position, 150.0f, sp1C); if (D_8037D810 == NULL) { D_8037D810 = func_8032FBE4(sp1C, func_802BABC0, 1, 0x15D); diff --git a/src/core2/code_34790.c b/src/core2/code_34790.c index bc703d97..d5560b98 100644 --- a/src/core2/code_34790.c +++ b/src/core2/code_34790.c @@ -106,7 +106,7 @@ f32 func_802BB938(f32 arg0[3], f32 arg1[3]) { phi_f20 = 65.0f; } - if (gctransition_8030BDAC()) { + if (gctransition_active()) { phi_f20 = ml_min_f(phi_f20, gctransition_8030BD88() * 0.8); } return phi_f20; @@ -120,8 +120,8 @@ void func_802BBA84(void) { f32 max[3]; mapModel_getBounds(min, max); - viewport_getPosition(vp_position); - viewport_getRotation(vp_rotation); + viewport_get_position_vec3f(vp_position); + viewport_get_rotation_vec3f(vp_rotation); func_8024C5A8(sp48); D_8037D8CC = (f32) func_8033EAF8(min, max, vp_position, sp48); D_8037D8CC += 100.0f; @@ -295,11 +295,11 @@ void ncCamera_update(void){ break; } - viewport_getPosition(sp2C); - viewport_getRotation(sp20); + viewport_get_position_vec3f(sp2C); + viewport_get_rotation_vec3f(sp20); func_802BB4D8(sp2C, sp20); - viewport_setPosition(sp2C); - viewport_setRotation(sp20); + viewport_set_position_vec3f(sp2C); + viewport_set_rotation_vec3f(sp20); viewport_update(); func_802BEFB0(); func_802BBA84(); @@ -352,8 +352,8 @@ void func_802BC2CC(s32 arg0) { if (ncCameraType == CAMERA_TYPE_2_DYNAMIC) { func_802BE894(D_8037D918, D_8037D908); } - viewport_setPosition(D_8037D908); - viewport_setRotation(D_8037D918); + viewport_set_position_vec3f(D_8037D908); + viewport_set_rotation_vec3f(D_8037D918); viewport_update(); __spawnQueue_add_2((GenFunction_2)func_802BC2A0, reinterpret_cast(s32, sp24), reinterpret_cast(s32, sp20)); if (ncCameraType == CAMERA_TYPE_2_DYNAMIC) { diff --git a/src/core2/code_37E50.c b/src/core2/code_37E50.c index 5daea25c..2a2b41ba 100644 --- a/src/core2/code_37E50.c +++ b/src/core2/code_37E50.c @@ -94,7 +94,7 @@ void func_802BEFB0(void) { return; } D_8037DA80.unk10 += time_getDelta(); - viewport_getPosition(sp30); + viewport_get_position_vec3f(sp30); sp24[0] = sp30[0]; sp24[1] = sp30[1] + 10000.0f; sp24[2] = sp30[2]; diff --git a/src/core2/code_43800.c b/src/core2/code_43800.c index f83efc26..1c341227 100644 --- a/src/core2/code_43800.c +++ b/src/core2/code_43800.c @@ -63,7 +63,7 @@ void func_802CA92C(Actor *this){ f32 sp28[3]; this->marker->collidable = FALSE; player_getPosition(this->position); - viewport_getPosition(sp34); + viewport_get_position_vec3f(sp34); ml_vec3f_diff_copy(sp28, sp34, this->position); ml_vec3f_set_length_copy(sp28, sp28, 180.0f); this->position_x += sp28[0]; diff --git a/src/core2/code_45310.c b/src/core2/code_45310.c index 379ace82..6da38fbd 100644 --- a/src/core2/code_45310.c +++ b/src/core2/code_45310.c @@ -434,7 +434,7 @@ void func_802CCC5C(Actor *this) { } if (this->state == 1) { player_getPosition(sp8C); - viewport_getPosition(sp80); + viewport_get_position_vec3f(sp80); func_8024C5A8(sp74); sp5C[0] = this->position[0] - sp80[0]; sp5C[1] = this->position[1] - sp80[1]; diff --git a/src/core2/code_55390.c b/src/core2/code_55390.c index 7106828c..00ae1f2d 100644 --- a/src/core2/code_55390.c +++ b/src/core2/code_55390.c @@ -38,8 +38,8 @@ Actor *func_802DC320(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ vp_rotation[0] = 0.0f; vp_rotation[1] = 0.0f; vp_rotation[2] = 0.0f; - viewport_setPosition(vp_position); - viewport_setRotation(vp_rotation); + viewport_set_position_vec3f(vp_position); + viewport_set_rotation_vec3f(vp_rotation); viewport_update(); func_8024C904(gfx, mtx); model_position[0] = 0.0f; diff --git a/src/core2/code_55850.c b/src/core2/code_55850.c index f234651c..f4cc3204 100644 --- a/src/core2/code_55850.c +++ b/src/core2/code_55850.c @@ -37,8 +37,8 @@ Actor *func_802DC7E0(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx){ sp4C[0] = 0.0f; sp4C[1] = 0.0f; sp4C[2] = 0.0f; - viewport_setPosition(sp58); - viewport_setRotation(sp4C); + viewport_set_position_vec3f(sp58); + viewport_set_rotation_vec3f(sp4C); viewport_update(); func_8024C904(gfx, mtx); sp40[0] = 0.0f; diff --git a/src/core2/code_59780.c b/src/core2/code_59780.c index 913cf71e..7f3a94c3 100644 --- a/src/core2/code_59780.c +++ b/src/core2/code_59780.c @@ -145,6 +145,6 @@ void func_802E08F0(Actor *this) { if (actor_animationIsAt(this, 0.99f) != 0) { marker_despawn(this->marker); } - viewport_getRotation(sp24); + viewport_get_rotation_vec3f(sp24); this->yaw = sp24[1]; } diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index 8a445ee7..c8879970 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -5,8 +5,8 @@ #include "gc/gctransition.h" extern void func_8024C510(f32); -extern void func_8024CDF8(f32, f32, f32); -extern void func_8024CE40(f32, f32, f32); +extern void viewport_set_position_f3(f32, f32, f32); +extern void viewport_set_rotation_f3(f32, f32, f32); extern void func_8024CE60(f32, f32); extern void func_802F5374(void); extern void func_802FA0F8(void); @@ -64,8 +64,8 @@ struct{ } D_8037E8E0; void func_802E3800(void){ - func_8024CDF8(0.0f, 0.0f, 0.0f); - func_8024CE40(-30.0f, 30.0f, 0.0f); + viewport_set_position_f3(0.0f, 0.0f, 0.0f); + viewport_set_rotation_f3(-30.0f, 30.0f, 0.0f); func_8024C510(3000.0f); viewport_update(); } @@ -79,13 +79,13 @@ void func_802E3854(void){ func_802E6820(5); modelRender_defrag(); mapSavestate_defrag_all(); - gctransition_8030B740(); - func_802F542C(); + gctransition_defrag(); + printbuffer_defrag(); func_80350E00(); func_802FA4E0(); func_8033B5FC(); timedFuncQueue_defrag(); - func_8025AF38(); + comusic_defrag(); } } @@ -536,7 +536,7 @@ bool func_802E4424(void) { && func_8028F070() && (func_8028EC04() == 0) && !gctransition_8030BDC0() - && gctransition_8030BD98() + && gctransition_done() && (level_get() != 0) && (0.6 < D_8037E8E0.unk10) && gcpausemenu_80314B00() @@ -596,7 +596,7 @@ s32 game_defrag(void){ actorArray_defrag(); spawnQueue_defrag(); func_802F3300(); - func_802F542C(); + printbuffer_defrag(); gcdialog_defrag(); if(D_8037E8E0.game_mode == GAME_MODE_4_PAUSED) gcpausemenu_defrag(); diff --git a/src/core2/code_5FD90.c b/src/core2/code_5FD90.c index a28ea5cc..fdf89b10 100644 --- a/src/core2/code_5FD90.c +++ b/src/core2/code_5FD90.c @@ -971,29 +971,30 @@ BKCollisionTri *func_802E92AC(BKCollisionList *collisionList, BKVertexList *vert return spD0; } -s32 func_802E9DD8(BKCollisionList *collisionList, BKVertexList *vtxList, f32 arg2[3], f32 *arg3, f32 arg4, f32 arg5[3], f32 arg6, f32 arg7[3], s32 arg8) { +s32 func_802E9DD8(BKCollisionList *collisionList, BKVertexList *vtxList, f32 posA[3], f32 *rotA, f32 scaleA, f32 posB[3], f32 radB, f32 arg7[3], s32 arg8) { f32 sp34[3]; s32 sp30; s32 i; - if ((vtxList->global_norm * arg4) <= (ml_distance_vec3f(arg5, arg2) - arg6)) { + // check if (sphere around vtx's) <= ((distance between origins) - (radius of B)) + if ((vtxList->global_norm * scaleA) <= (ml_distance_vec3f(posB, posA) - radB)) { return 0; } mlMtxIdent(); - func_80252CC4(arg2, arg3, arg4, 0); - func_8025235C(sp34, arg5); - sp30 = func_802E92AC(collisionList, vtxList, &sp34, arg6 / arg4, arg7, arg8); + func_80252CC4(posA, rotA, scaleA, NULL); + func_8025235C(sp34, posB); + sp30 = func_802E92AC(collisionList, vtxList, &sp34, radB / scaleA, arg7, arg8); if (sp30 == 0) { return 0; } mlMtxIdent(); - func_80252C08(arg2, arg3, arg4, NULL); - func_8025235C(arg5, sp34); + func_80252C08(posA, rotA, scaleA, NULL); + func_8025235C(posB, sp34); mlMtxIdent(); - func_80252C08(NULL, arg3, 1.0f, NULL); + func_80252C08(NULL, rotA, 1.0f, NULL); func_8025235C(arg7, arg7); mlMtxIdent(); - func_80252C08(arg2, arg3, arg4, NULL); + func_80252C08(posA, rotA, scaleA, NULL); for(i = 0; i < 3; i++){ func_8025235C(D_8037EAA8[i], D_8037EAA8[i]); diff --git a/src/core2/code_637D0.c b/src/core2/code_637D0.c index 5d730a15..b3118452 100644 --- a/src/core2/code_637D0.c +++ b/src/core2/code_637D0.c @@ -4,7 +4,7 @@ extern void func_80252C08(f32[3], f32[3], f32, f32[3]); extern void func_80252CC4(f32[3], f32[3], f32, s32); -extern void func_802524F0(f32[3], f32, f32, f32); +extern void mlMtx_apply_f3(f32[3], f32, f32, f32); extern s32 func_802EBAE0(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, s32 arg5, f32 arg6[3], f32 arg7, f32 arg8[3]); /* .bss */ Mtx D_80380880; @@ -191,10 +191,10 @@ s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 spD0[0] *= 2; spD0[1] *= 2; spD0[2] *= 2; - func_802519C8(&D_80380880, animMtxList_get(arg5, i_ptr->unk16)); + mlMtx_push_multiplied_2(&D_80380880, animMtxList_get(arg5, i_ptr->unk16)); func_80252E4C(spF4, spD0); - func_802524F0(spB0, spE8[0], spE8[1], spE8[2]); - func_802524F0(sp98, spE8[0], spE8[1], spDC[2]); + mlMtx_apply_f3(spB0, spE8[0], spE8[1], spE8[2]); + mlMtx_apply_f3(sp98, spE8[0], spE8[1], spDC[2]); spBC[0] = spB0[0] - sp98[0]; spBC[1] = spB0[1] - sp98[1]; spBC[2] = spB0[2] - sp98[2]; @@ -208,7 +208,7 @@ s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 sp8C[1] = arg6[1] - sp98[1]; sp8C[2] = arg6[2] - sp98[2]; if (!(arg7 <= -((sp8C[0]*spBC[0]) + (sp8C[1]*spBC[1]) + (sp8C[2]*spBC[2])))) { - func_802524F0(sp80, spDC[0], spE8[1], spE8[2]); + mlMtx_apply_f3(sp80, spDC[0], spE8[1], spE8[2]); spBC[0] = spB0[0] - sp80[0]; spBC[1] = spB0[1] - sp80[1]; spBC[2] = spB0[2] - sp80[2]; @@ -219,7 +219,7 @@ s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 sp74[1] = arg6[1] - sp80[1]; sp74[2] = arg6[2] - sp80[2]; if (!(arg7 <= -((sp74[0]*spBC[0]) + (sp74[1]*spBC[1]) + (sp74[2]*spBC[2])))) { - func_802524F0(sp68, spE8[0], spDC[1], spE8[2]); + mlMtx_apply_f3(sp68, spE8[0], spDC[1], spE8[2]); spBC[0] = spB0[0] - sp68[0]; spBC[1] = spB0[1] - sp68[1]; spBC[2] = spB0[2] - sp68[2]; @@ -270,11 +270,11 @@ s32 func_802EB458(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 spAC[0] = (f32) (i_ptr->unkA[0] * 2); spAC[1] = (f32) (i_ptr->unkA[1] * 2); spAC[2] = (f32) (i_ptr->unkA[2] * 2); - func_802519C8(&D_80380880, animMtxList_get(arg5, i_ptr->unkE)); + mlMtx_push_multiplied_2(&D_80380880, animMtxList_get(arg5, i_ptr->unkE)); func_80252D8C(spB8, spAC); - func_802524F0(sp98, 0.0f, 0.0f, (f32) ((-i_ptr->unk2) / 2)); - func_802524F0(sp8C, 0.0f, 0.0f, (f32) (i_ptr->unk2 / 2)); - func_802524F0(sp68, (f32) i_ptr->unk0, 0.0f, (f32) ((-i_ptr->unk2) / 2)); + mlMtx_apply_f3(sp98, 0.0f, 0.0f, (f32) ((-i_ptr->unk2) / 2)); + mlMtx_apply_f3(sp8C, 0.0f, 0.0f, (f32) (i_ptr->unk2 / 2)); + mlMtx_apply_f3(sp68, (f32) i_ptr->unk0, 0.0f, (f32) ((-i_ptr->unk2) / 2)); sp68[0] -= sp98[0]; sp68[1] -= sp98[1]; sp68[2] -= sp98[2]; @@ -445,7 +445,7 @@ s32 func_802EBD3C(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scal i_rotation[2] *= 2; mlMtxIdent(); - func_80252EC8(i_position, i_rotation); //rotate about point + func_80252EC8(i_position, i_rotation); //derotate about point func_80252CC4(arg1, rotation, scale, arg4); func_8025235C(sp68, arg5); //apply matrix to arg5 for (i = 0; i < 3; i++) @@ -522,35 +522,35 @@ s32 func_802EC238(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scal mlMtxIdent(); func_80252CC4(arg1, rotation, scale, arg4); func_8025235C(sp54, arg5); - for (i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++) - { - if ((i_ptr->unk8 != 0) && ((arg6 == 0) || (arg6 == i_ptr->unk8))) - { + for (i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++) { + if ((i_ptr->unk8 != 0) && ((arg6 == 0) || (arg6 == i_ptr->unk8))) { sp40[0] = i_ptr->unk2[0]; sp40[1] = i_ptr->unk2[1]; sp40[2] = i_ptr->unk2[2]; scale = i_ptr->unk0; if (ml_distance_vec3f(sp40, sp54) < scale) return i_ptr->unk8; - if (!i_ptr->unk0){ - - } + if (!i_ptr->unk0){ } } } return 0U; } -s32 func_802EC394(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scale, f32 arg4[3], f32 arg5[3], s32 arg6) { +s32 func_802EC394(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, f32 arg4[3], f32 arg5[3], s32 arg6) { s32 phi_v0; - phi_v0 = func_802EBD3C(arg0, arg1, rotation, scale, arg4, arg5, arg6); + //transform type 0 + phi_v0 = func_802EBD3C(arg0, position, rotation, scale, arg4, arg5, arg6); if (phi_v0 != NULL) { return phi_v0; } - phi_v0 = func_802EC000(arg0, arg1, rotation, scale, arg4, arg5, arg6); + //transform type 1 + phi_v0 = func_802EC000(arg0, position, rotation, scale, arg4, arg5, arg6); if (phi_v0 != NULL) { return phi_v0; } - return func_802EC238(arg0, arg1, rotation, scale, arg4, arg5, arg6); + + //transform type 2 + return func_802EC238(arg0, position, rotation, scale, arg4, arg5, arg6); } diff --git a/src/core2/code_654C0.c b/src/core2/code_654C0.c index ce0e8104..f5d43b35 100644 --- a/src/core2/code_654C0.c +++ b/src/core2/code_654C0.c @@ -215,7 +215,7 @@ void func_802ECBD4(BKVertexList *dst, BKVertexList *src, f32 arg2[3], f32 rotati f32 temp_f0; s32 pad40; - viewport_getPosition(sp74); + viewport_get_position_vec3f(sp74); func_8024C5A8(sp68); mlMtxIdent(); func_80252CC4(arg2, rotation, 1.0f, NULL); diff --git a/src/core2/code_6A4B0.c b/src/core2/code_6A4B0.c index 3e5a5871..593edb1a 100644 --- a/src/core2/code_6A4B0.c +++ b/src/core2/code_6A4B0.c @@ -160,7 +160,7 @@ void func_802F1A10(Struct_Core2_6A4B0_2 *arg0, f32 angle_degrees) { cos = cosf(angle_degrees * 2 * BAD_PI); sin = sinf(angle_degrees * 2 * BAD_PI); - viewport_getPosition(spC0); + viewport_get_position_vec3f(spC0); spCC[0] = (-(framebuffer_width / 2) * 4) + 8; spCC[1] = ((framebuffer_height / 2) * 4) - 0x38; spCC[2] = -0xA; @@ -214,7 +214,7 @@ void func_802F1CAC(Struct_Core2_6A4B0_2 *arg0) { s32 *var_s2; - viewport_getPosition(sp78); + viewport_get_position_vec3f(sp78); sp84[0] = (s32) ((1000.0f - sp78[0]) - 200.0f); sp84[1] = (s32) ((0.0f - sp78[1]) + 300.0f); sp84[2] = (s32) ((2000.0f - sp78[2]) + 0.0f); diff --git a/src/core2/code_6B030.c b/src/core2/code_6B030.c index c44c45e3..34673821 100644 --- a/src/core2/code_6B030.c +++ b/src/core2/code_6B030.c @@ -67,7 +67,7 @@ void func_802F1FC0(Struct65s *self, Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 width; s32 height; - viewport_getPosition(spDC); + viewport_get_position_vec3f(spDC); spD0[0] = self->unk0[0] - spDC[0]; spD0[1] = self->unk0[1] - spDC[1]; spD0[2] = self->unk0[2] - spDC[2]; @@ -326,7 +326,7 @@ void func_802F2ED0(Struct64s *arg0, Gfx **gfx, Mtx **mtx, Vtx **vtx) { f32 sp38[3]; if (arg0 != NULL && arg0->unk4) { - viewport_getRotation(sp38); + viewport_get_rotation_vec3f(sp38); mlMtxIdent(); mlMtxRotPitch(-sp38[0]); mlMtxRotYaw(-sp38[1]); diff --git a/src/core2/code_6D270.c b/src/core2/code_6D270.c index 8476014f..7a282063 100644 --- a/src/core2/code_6D270.c +++ b/src/core2/code_6D270.c @@ -36,7 +36,7 @@ ParticleEmitter *func_802F4274(f32 arg0[3]) { ml_vec3f_copy(sp2C, arg0); func_8024559C(sp2C, &sp20, &sp28); sp2C[1] = sp28 + 14.0f; - viewport_getPosition(sp38); + viewport_get_position_vec3f(sp38); sp44[0] = sp38[0] - sp2C[0]; sp44[2] = sp38[2] - sp2C[2]; sp44[1] = 0.0f; diff --git a/src/core2/code_6DA30.c b/src/core2/code_6DA30.c index 5c30b3d6..35f72df1 100644 --- a/src/core2/code_6DA30.c +++ b/src/core2/code_6DA30.c @@ -479,7 +479,7 @@ void func_802F53D0(void){ D_80380B18 = 0; } -void func_802F542C(void){ +void printbuffer_defrag(void){ print_sFonts[0] = (FontLetter *)defrag(print_sFonts[0]); print_sFonts[1] = (FontLetter *)defrag(print_sFonts[1]); if(print_sFonts[3]){ diff --git a/src/core2/code_70F20.c b/src/core2/code_70F20.c index 96ba9485..c5344f0e 100644 --- a/src/core2/code_70F20.c +++ b/src/core2/code_70F20.c @@ -20,7 +20,7 @@ void func_802F7EB0(struct3s *this){ player_getPosition(plyrPos); func_8024C5A8(camNorm); - viewport_getRotation(camRot); + viewport_get_rotation_vec3f(camRot); sp50 = vector_pushBackNew(&this->unk20); tmpf = randf2(50.0f, 1100.0f); sp4C[0] = 0.0f; diff --git a/src/core2/code_71820.c b/src/core2/code_71820.c index 0164dbb9..22b8a7d9 100644 --- a/src/core2/code_71820.c +++ b/src/core2/code_71820.c @@ -21,7 +21,7 @@ void func_802F87B0(struct6s *this){ player_getPosition(plyrPos); func_8024C5A8(camNorm); - viewport_getRotation(camRot); + viewport_get_rotation_vec3f(camRot); ptr = vector_pushBackNew(&this->unk1C); f20 = randf2(50.0f, 1200.0f); sp4C[0] = 0.0f; diff --git a/src/core2/code_72060.c b/src/core2/code_72060.c index 0ab87595..895b4055 100644 --- a/src/core2/code_72060.c +++ b/src/core2/code_72060.c @@ -7,11 +7,11 @@ typedef struct { f32 unkC[3]; }Struct_core2_72060_0; -extern f32 viewport_getYaw(); +extern f32 viewport_get_yaw(); extern int func_8024DD34(f32, f32, f32); extern void func_80251B5C(f32, f32, f32); -extern void func_80251F8C(f32); -extern void func_8025208C(f32); +extern void mlMtx_rotate_pitch_deg(f32); +extern void mlMtx_rotate_yaw_deg(f32); extern void func_80252A38(f32, f32, f32); extern void mlMtxApply(Mtx *); extern f32 vtxList_getGlobalNorm(BKVertexList *); @@ -166,7 +166,7 @@ void func_802F919C(void) { } else { var_f20 = 70.0f; } - ml_vec3f_yaw_rotate_copy(sp4C, sp4C, viewport_getYaw() + randf2(-var_f20, var_f20)); + ml_vec3f_yaw_rotate_copy(sp4C, sp4C, viewport_get_yaw() + randf2(-var_f20, var_f20)); sp4C[0] += D_80381040[0]; sp4C[1] += D_80381040[1]; sp4C[2] += D_80381040[2]; @@ -200,8 +200,8 @@ void func_802F962C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { void *phi_s0_2; if ((D_80369280 != NULL) && (D_80369284 != 0)) { - viewport_getPosition(D_80381050); - viewport_getRotation(D_80381060); + viewport_get_position_vec3f(D_80381050); + viewport_get_rotation_vec3f(D_80381060); D_80381090 = (s32)D_80369288 + D_80369288->gfx_list_offset_C + sizeof(BKGfxList); temp_s3 = (BKVertexList *)((s32)D_80369288 + D_80369288->vtx_list_offset_10); D_8038108C = vtxList_getGlobalNorm(temp_s3); @@ -237,8 +237,8 @@ bool func_802F989C(Gfx **gfx, Mtx **mtx, f32 arg2[3]) { mlMtxApply(*mtx); func_80252434(&D_80381080, D_80381094->unkC); func_80251B5C(D_80381080[0], D_80381080[1], D_80381080[2]); - func_8025208C(D_80381060[1]); - func_80251F8C(D_80381060[0]); + mlMtx_rotate_yaw_deg(D_80381060[1]); + mlMtx_rotate_pitch_deg(D_80381060[0]); func_80252A38(-(D_80381094->unkC[0]), -(D_80381094->unkC[1]), -(D_80381094->unkC[2])); mlMtxApply(*mtx); gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/core2/code_7AF80.c b/src/core2/code_7AF80.c index c10d279e..9cf129e4 100644 --- a/src/core2/code_7AF80.c +++ b/src/core2/code_7AF80.c @@ -4,6 +4,8 @@ #include "prop.h" +#define SQ(x) ((x) * (x)) + extern f32 ml_distanceSquared_vec3f(f32[3], f32[3]); extern f32 func_802586B0(f32[3], f32[3]); extern void mapModel_getCubeBounds(s32 min[3], s32 max[3]); @@ -14,14 +16,9 @@ extern ActorProp *func_803322F0(Cube *, ActorMarker *, f32, s32, s32 *); extern BKCollisionTri *func_803319C0(Cube *cube, f32 position[3], f32 radius, f32 arg2[3], u32 flags); extern BKCollisionTri *func_80331638(Cube *cube, f32 volume_p1[3], f32 volume_p2[3], f32 radius, f32 arg2[3], s32, u32 flags); -typedef struct { - s32 unk0; - NodeProp *unk4; -} Struct_core2_7AF80_0; - typedef struct{ - s32 unk0[3]; - s32 unkC; + s32 position[3]; + s32 radius; u32 unk10_31: 28; u32 unk10_3: 3; u32 unk10_0: 1; @@ -29,7 +26,7 @@ typedef struct{ } Struct_core2_7AF80_2; typedef struct { - s32 unk0; //count + s32 count; //count s32 unk4; Struct_core2_7AF80_2 *unk8; } Struct_core2_7AF80_1; @@ -381,8 +378,8 @@ void func_80302C94(Gfx **gfx, Mtx **mtx, Vtx **vtx) { return; func_8032D3A8(); - viewport_getPosition(vp_position); - viewport_getRotation(vp_rotation); + viewport_get_position_vec3f(vp_position); + viewport_get_rotation_vec3f(vp_rotation); func_80256664(vp_rotation); cube_positionToIndices(vp_cube_indices, vp_position); vp_cube_indices[0] -= D_80381FA0.min[0];\ @@ -539,12 +536,12 @@ Cube *cube_atPosition_s32(s32 position[3]) { } Cube *cube_atPosition_f32(f32 position[3]){ - s32 sp1C[3]; + s32 pos_s32[3]; - sp1C[0] = (s32)position[0]; - sp1C[1] = (s32)position[1]; - sp1C[2] = (s32)position[2]; - return cube_atPosition_s32(sp1C); + pos_s32[0] = (s32)position[0]; + pos_s32[1] = (s32)position[1]; + pos_s32[2] = (s32)position[2]; + return cube_atPosition_s32(pos_s32); } Cube *func_8030364C(void){ @@ -937,7 +934,7 @@ s32 func_80304984(s32 arg0, u32 *arg1) { temp_v0 = cubeList_findNodePropByActorId(arg0, 0); if (temp_v0 != 0) { - *arg1 = temp_v0->unk6.bit15; + *arg1 = temp_v0->unk6.radius; return 1; } return 0; @@ -1031,7 +1028,7 @@ NodeProp *func_80304D04(s32 arg0, s16 *arg1) { } s32 nodeprop_getRadius(NodeProp *arg0) { - return arg0->unk6.bit15; + return arg0->unk6.radius; } void func_80304D4C(NodeProp *arg0, s32 dst[3]) { @@ -1239,7 +1236,7 @@ NodeProp *func_80305510(s32 arg0) { } Actor * func_803055E0(enum actor_e arg0, s32 arg1[3], s32 arg2, s32 arg3, s32 arg4){ - Actor *actor = func_803056FC(arg0, arg1, arg2); + Actor *actor = spawn_actor(arg0, arg1, arg2); NodeProp *tmp; s32 sp34[3]; f32 sp28[3]; @@ -1264,14 +1261,11 @@ Actor * func_803055E0(enum actor_e arg0, s32 arg1[3], s32 arg2, s32 arg3, s32 ar return actor; } -Actor *func_803056FC(enum actor_e arg0, s32 arg1[3], s32 arg2) -{ +Actor *spawn_actor(enum actor_e arg0, s32 arg1[3], s32 arg2) { s32 i; arg0 = (!func_80320248()) ? (ACTOR_4_BIGBUTT) : (arg0); - for (i = 0; i < sSpawnableActorSize; i++) - { - if (arg0 == sSpawnableActorList[i].infoPtr->actorId) - { + for (i = 0; i < sSpawnableActorSize; i++) { + if (arg0 == sSpawnableActorList[i].infoPtr->actorId) { return sSpawnableActorList[i].spawnFunc(arg1, arg2, ((0, sSpawnableActorList[i])).infoPtr, sSpawnableActorList[i].unk8); } } @@ -1448,18 +1442,18 @@ void func_80305F04(s32 *arg0, Struct_core2_7AF80_1 **arg1) { for(a_list = *arg1; a_list < *arg1 + *arg0; a_list++){ for(b_list = a_list + 1; b_list < *arg1 + *arg0; b_list++) { //same types and neither A or B are empty - if ((a_list->unk4 == b_list->unk4) && (a_list->unk0 != 0) && (b_list->unk0 != 0)) { + if ((a_list->unk4 == b_list->unk4) && (a_list->count != 0) && (b_list->count != 0)) { continue_loop = TRUE; - for(a_elem = a_list->unk8; (a_elem < a_list->unk8 + a_list->unk0) && continue_loop; a_elem++){ - for(b_elem = b_list->unk8; (b_elem < b_list->unk8 + b_list->unk0) && continue_loop; b_elem++) { - if ((((a_elem->unk0[0] - b_elem->unk0[0]) * (a_elem->unk0[0] - b_elem->unk0[0])) + ((a_elem->unk0[2] - b_elem->unk0[2]) * (a_elem->unk0[2] - b_elem->unk0[2]))) < ((a_elem->unkC + b_elem->unkC) * (a_elem->unkC + b_elem->unkC))) { + for(a_elem = a_list->unk8; (a_elem < a_list->unk8 + a_list->count) && continue_loop; a_elem++){ + for(b_elem = b_list->unk8; (b_elem < b_list->unk8 + b_list->count) && continue_loop; b_elem++) { + if ((((a_elem->position[0] - b_elem->position[0]) * (a_elem->position[0] - b_elem->position[0])) + ((a_elem->position[2] - b_elem->position[2]) * (a_elem->position[2] - b_elem->position[2]))) < ((a_elem->radius + b_elem->radius) * (a_elem->radius + b_elem->radius))) { //concat b_list to end of a_list - a_list->unk8 = (Struct_core2_7AF80_2 *) realloc(a_list->unk8, (a_list->unk0 + b_list->unk0)*sizeof(Struct_core2_7AF80_2)); - memcpy(a_list->unk8 + a_list->unk0, b_list->unk8, b_list->unk0 * sizeof(Struct_core2_7AF80_2)); - a_list->unk0 = (s32) (a_list->unk0 + b_list->unk0); + a_list->unk8 = (Struct_core2_7AF80_2 *) realloc(a_list->unk8, (a_list->count + b_list->count)*sizeof(Struct_core2_7AF80_2)); + memcpy(a_list->unk8 + a_list->count, b_list->unk8, b_list->count * sizeof(Struct_core2_7AF80_2)); + a_list->count = (s32) (a_list->count + b_list->count); - b_list->unk0 = 0; + b_list->count = 0; free(b_list->unk8); b_list->unk8 = NULL; @@ -1474,13 +1468,13 @@ void func_80305F04(s32 *arg0, Struct_core2_7AF80_1 **arg1) { //remove empty lists for(a_list = *arg1; a_list < *arg1 + *arg0; a_list++){ - if (a_list->unk0 == 0) { //A is empty + if (a_list->count == 0) { //A is empty continue_loop = TRUE; for(b_list = a_list + 1; (b_list < *arg1 + *arg0) && continue_loop; b_list++){ - if (b_list->unk0 != 0) { //B is not empty + if (b_list->count != 0) { //B is not empty //swap A an B memcpy(a_list, b_list, sizeof(Struct_core2_7AF80_1)); - b_list->unk0 = 0; + b_list->count = 0; b_list->unk8 = NULL; continue_loop = FALSE; @@ -1490,7 +1484,7 @@ void func_80305F04(s32 *arg0, Struct_core2_7AF80_1 **arg1) { } //find first empty list (end) - for(a_list = *arg1; (a_list < *arg1 + *arg0) && (a_list->unk0 != 0); a_list++) { } + for(a_list = *arg1; (a_list < *arg1 + *arg0) && (a_list->count != 0); a_list++) { } *arg0 = (a_list - *arg1); //count *arg1 = (Struct_core2_7AF80_1 *)realloc((void *) *arg1, *arg0 * sizeof(Struct_core2_7AF80_1)); //ptr @@ -1566,27 +1560,27 @@ Struct_core2_7AF80_1 *func_803064C0(s32 arg0) { bool func_80306534(Struct_core2_7AF80_1 *arg0, s32 arg1, s32 arg2[3], s32 arg3) { Struct_core2_7AF80_2 *iPtr; - for(iPtr = arg0->unk8; iPtr < &arg0->unk8[arg0->unk0]; iPtr++){ - if(((arg2[0] - iPtr->unk0[0])*(arg2[0] - iPtr->unk0[0]) + (arg2[2] - iPtr->unk0[2])*(arg2[2] - iPtr->unk0[2])) < ((arg3 + iPtr->unkC) * (arg3 + iPtr->unkC))) { + for(iPtr = arg0->unk8; iPtr < &arg0->unk8[arg0->count]; iPtr++){ + if(((arg2[0] - iPtr->position[0])*(arg2[0] - iPtr->position[0]) + (arg2[2] - iPtr->position[2])*(arg2[2] - iPtr->position[2])) < ((arg3 + iPtr->radius) * (arg3 + iPtr->radius))) { return TRUE; } } return FALSE; } -void func_803065E4(s32 arg0, s32 position[3], s32 arg2, s32 arg3, s32 arg4) { +void func_803065E4(s32 arg0, s32 position[3], s32 radius, s32 arg3, s32 arg4) { Struct_core2_7AF80_2 *temp_v1; func_80306390(); while(func_803063D8(arg0) != NULL){ - if (func_80306534(D_8036A9C0, arg0, position, arg2)) { - D_8036A9C0->unk0++; - D_8036A9C0->unk8 = realloc(D_8036A9C0->unk8, D_8036A9C0->unk0 * sizeof(Struct_core2_7AF80_2)); - temp_v1 = &D_8036A9C0->unk8[D_8036A9C0->unk0 - 1]; - temp_v1->unk0[0] = position[0]; - temp_v1->unk0[1] = position[1]; - temp_v1->unk0[2] = position[2]; - temp_v1->unkC = arg2; + if (func_80306534(D_8036A9C0, arg0, position, radius)) { + D_8036A9C0->count++; + D_8036A9C0->unk8 = realloc(D_8036A9C0->unk8, D_8036A9C0->count * sizeof(Struct_core2_7AF80_2)); + temp_v1 = &D_8036A9C0->unk8[D_8036A9C0->count - 1]; + temp_v1->position[0] = position[0]; + temp_v1->position[1] = position[1]; + temp_v1->position[2] = position[2]; + temp_v1->radius = radius; temp_v1->unk10_31 = arg3; temp_v1->unk10_0 = arg4; temp_v1->unk10_3 = 0; @@ -1595,14 +1589,14 @@ void func_803065E4(s32 arg0, s32 position[3], s32 arg2, s32 arg3, s32 arg4) { } D_8036A9B8++; D_8036A9BC = realloc(D_8036A9BC, D_8036A9B8*sizeof(Struct_core2_7AF80_1)); - D_8036A9BC[D_8036A9B8-1].unk0 = 1; + D_8036A9BC[D_8036A9B8-1].count = 1; D_8036A9BC[D_8036A9B8-1].unk4 = arg0; D_8036A9BC[D_8036A9B8-1].unk8 = malloc(sizeof(Struct_core2_7AF80_2)); temp_v1 = (D_8036A9BC + D_8036A9B8-1)->unk8; - temp_v1->unk0[0] = position[0]; - temp_v1->unk0[1] = position[1]; - temp_v1->unk0[2] = position[2]; - temp_v1->unkC = arg2; + temp_v1->position[0] = position[0]; + temp_v1->position[1] = position[1]; + temp_v1->position[2] = position[2]; + temp_v1->radius = radius; temp_v1->unk10_31 = arg3; temp_v1->unk10_0 = arg4; temp_v1->unk10_3 = 0; @@ -1618,63 +1612,63 @@ s32 func_80306840(s32 arg0){ return 7; } -void func_8030688C(s32 arg0, s32 position[3], s32 arg2, s32 arg3){ +void func_8030688C(s32 arg0, s32 position[3], s32 radius, s32 arg3){ Struct_core2_7AF80_2 *temp_v1; func_803063A8(); while(func_8030644C(arg0) != NULL){ - if (func_80306534(D_8036A9CC, arg0, position, arg2)) { - D_8036A9CC->unk0++; - D_8036A9CC->unk8 = realloc(D_8036A9CC->unk8, D_8036A9CC->unk0 * sizeof(Struct_core2_7AF80_2)); - temp_v1 = &D_8036A9CC->unk8[D_8036A9CC->unk0 - 1]; - temp_v1->unk0[0] = position[0]; - temp_v1->unk0[1] = position[1]; - temp_v1->unk0[2] = position[2]; - temp_v1->unkC = arg2; + if (func_80306534(D_8036A9CC, arg0, position, radius)) { + D_8036A9CC->count++; + D_8036A9CC->unk8 = realloc(D_8036A9CC->unk8, D_8036A9CC->count * sizeof(Struct_core2_7AF80_2)); + temp_v1 = &D_8036A9CC->unk8[D_8036A9CC->count - 1]; + temp_v1->position[0] = position[0]; + temp_v1->position[1] = position[1]; + temp_v1->position[2] = position[2]; + temp_v1->radius = radius; temp_v1->unk10_3 = func_80306840(arg3); return; } } D_8036A9C4++; D_8036A9C8 = realloc(D_8036A9C8, D_8036A9C4*sizeof(Struct_core2_7AF80_1)); - D_8036A9C8[D_8036A9C4-1].unk0 = 1; + D_8036A9C8[D_8036A9C4-1].count = 1; D_8036A9C8[D_8036A9C4-1].unk4 = arg0; D_8036A9C8[D_8036A9C4-1].unk8 = malloc(sizeof(Struct_core2_7AF80_2)); temp_v1 = (D_8036A9C8 + D_8036A9C4-1)->unk8; - temp_v1->unk0[0] = position[0]; - temp_v1->unk0[1] = position[1]; - temp_v1->unk0[2] = position[2]; - temp_v1->unkC = arg2; + temp_v1->position[0] = position[0]; + temp_v1->position[1] = position[1]; + temp_v1->position[2] = position[2]; + temp_v1->radius = radius; temp_v1->unk10_3 = func_80306840(arg3); } -void func_80306AA8(s32 arg0, s32 position[3], s32 arg2){ +void func_80306AA8(s32 arg0, s32 position[3], s32 radius){ Struct_core2_7AF80_2 *temp_v1; func_803063C0(); while(func_803064C0(arg0) != NULL){ - if (func_80306534(D_8036A9D8, arg0, position, arg2)) { - D_8036A9D8->unk0++; - D_8036A9D8->unk8 = realloc(D_8036A9D8->unk8, D_8036A9D8->unk0 * sizeof(Struct_core2_7AF80_2)); - temp_v1 = &D_8036A9D8->unk8[D_8036A9D8->unk0 - 1]; - temp_v1->unk0[0] = position[0]; - temp_v1->unk0[1] = position[1]; - temp_v1->unk0[2] = position[2]; - temp_v1->unkC = arg2; + if (func_80306534(D_8036A9D8, arg0, position, radius)) { + D_8036A9D8->count++; + D_8036A9D8->unk8 = realloc(D_8036A9D8->unk8, D_8036A9D8->count * sizeof(Struct_core2_7AF80_2)); + temp_v1 = &D_8036A9D8->unk8[D_8036A9D8->count - 1]; + temp_v1->position[0] = position[0]; + temp_v1->position[1] = position[1]; + temp_v1->position[2] = position[2]; + temp_v1->radius = radius; temp_v1->unk10_3 = 0; return; } } D_8036A9D0++; D_8036A9D4 = realloc(D_8036A9D4, D_8036A9D0*sizeof(Struct_core2_7AF80_1)); - D_8036A9D4[D_8036A9D0-1].unk0 = 1; + D_8036A9D4[D_8036A9D0-1].count = 1; D_8036A9D4[D_8036A9D0-1].unk4 = arg0; D_8036A9D4[D_8036A9D0-1].unk8 = malloc(sizeof(Struct_core2_7AF80_2)); temp_v1 = (D_8036A9D4 + D_8036A9D0-1)->unk8; - temp_v1->unk0[0] = position[0]; - temp_v1->unk0[1] = position[1]; - temp_v1->unk0[2] = position[2]; - temp_v1->unkC = arg2; + temp_v1->position[0] = position[0]; + temp_v1->position[1] = position[1]; + temp_v1->position[2] = position[2]; + temp_v1->radius = radius; temp_v1->unk10_3 = 0; } @@ -1734,9 +1728,9 @@ s32 func_80306DDC(Struct_core2_7AF80_2 *arg0) { phi_v1 = D_8036A9BC; while(phi_v1 < &D_8036A9BC[D_8036A9B8]){ phi_a0 = phi_v1->unk8; - while(phi_a0 < &phi_v1->unk8[phi_v1->unk0]){ - if (((phi_a0->unk0[1] - 150) < arg0->unk0[1]) && (arg0->unk0[1] < (phi_a0->unk0[1] + 150))) { - if ((((arg0->unk0[0] - phi_a0->unk0[0]) * (arg0->unk0[0] - phi_a0->unk0[0])) + ((arg0->unk0[2] - phi_a0->unk0[2]) * (arg0->unk0[2] - phi_a0->unk0[2]))) < (phi_a0->unkC * phi_a0->unkC)) { + while(phi_a0 < &phi_v1->unk8[phi_v1->count]){ + if (((phi_a0->position[1] - 150) < arg0->position[1]) && (arg0->position[1] < (phi_a0->position[1] + 150))) { + if ((SQ(arg0->position[0] - phi_a0->position[0]) + SQ(arg0->position[2] - phi_a0->position[2])) < SQ(phi_a0->radius)) { return phi_v1 - D_8036A9BC; } } @@ -1759,20 +1753,20 @@ s32 func_80306EF4(s32 arg0[3], s32 arg1, u32 arg2) { if (D_80381FE8[var_s1->unk4] != 0) { if (arg2 & 1) { var_s0 = var_s1->unk8; - for(var_s0 = var_s1->unk8; var_s0 < var_s1->unk8 + var_s1->unk0; var_s0++){ + 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->unk0[1]) && (temp_s6 < var_s0->unk0[1]) - && (func_80259328(arg0, (void *) var_s0, var_s0->unkC)) + && (temp_s4 >= var_s0->position[1]) && (temp_s6 < var_s0->position[1]) + && (func_80259328(arg0, (void *) var_s0, var_s0->radius)) ) { return var_s1 - D_8036A9C8; } } } else{ - for(var_s0 = var_s1->unk8; var_s0 < var_s1->unk8 + var_s1->unk0; var_s0++){ + 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->unk0[1]) && (temp_s6 < var_s0->unk0[1]))) - && (func_80259328(arg0, (void *) var_s0, var_s0->unkC)) + && ((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)) ) { return var_s1 - D_8036A9C8; } @@ -1783,20 +1777,16 @@ s32 func_80306EF4(s32 arg0[3], s32 arg1, u32 arg2) { return -1; } -s32 func_80307164(Struct_core2_7AF80_2 *arg0) { +s32 func_80307164(s32 arg0[3]) { Struct_core2_7AF80_1 *phi_v1; Struct_core2_7AF80_2 *phi_a0; - phi_v1 = D_8036A9D4; - while(phi_v1 < &D_8036A9D4[D_8036A9D0]){ - phi_a0 = phi_v1->unk8; - while(phi_a0 < &phi_v1->unk8[phi_v1->unk0]){ - if ((((arg0->unk0[0] - phi_a0->unk0[0]) * (arg0->unk0[0] - phi_a0->unk0[0])) + ((arg0->unk0[2] - phi_a0->unk0[2]) * (arg0->unk0[2] - phi_a0->unk0[2]))) < (phi_a0->unkC * phi_a0->unkC)) { + for( phi_v1 = D_8036A9D4; phi_v1 < &D_8036A9D4[D_8036A9D0]; phi_v1++){ + for(phi_a0 = phi_v1->unk8; phi_a0 < &phi_v1->unk8[phi_v1->count]; phi_a0++){ + if ((SQ(arg0[0] - phi_a0->position[0]) + SQ(arg0[2] - phi_a0->position[2])) < SQ(phi_a0->radius)) { return phi_v1 - D_8036A9D4; } - phi_a0++; } - phi_v1++; } return -1; } @@ -1811,14 +1801,14 @@ s32 func_80307258(f32 arg0[3], s32 arg1, s32 arg2) { temp_v0 = &D_8036A9BC[arg1]; var_v1 = temp_v0->unk8 + arg2; - if (((arg0[0] - var_v1->unk0[0]) * (arg0[0] - var_v1->unk0[0])) + (((arg0[2] - var_v1->unk0[2]) * (arg0[2] - var_v1->unk0[2]))) < (var_v1->unkC * var_v1->unkC)) { + if (((arg0[0] - var_v1->position[0]) * (arg0[0] - var_v1->position[0])) + (((arg0[2] - var_v1->position[2]) * (arg0[2] - var_v1->position[2]))) < (var_v1->radius * var_v1->radius)) { return arg2; } - temp_a0 = temp_v0->unk8 + temp_v0->unk0; + temp_a0 = temp_v0->unk8 + temp_v0->count; for (var_v1 = temp_v0->unk8; var_v1 < temp_a0; var_v1++) { - temp_f2 = arg0[2] - var_v1->unk0[2]; - temp_f14 = arg0[0] - var_v1->unk0[0]; - if (((temp_f2 * temp_f2) + (temp_f14 * temp_f14)) < (var_v1->unkC * var_v1->unkC)) { + temp_f2 = arg0[2] - var_v1->position[2]; + temp_f14 = arg0[0] - var_v1->position[0]; + if (((temp_f2 * temp_f2) + (temp_f14 * temp_f14)) < (var_v1->radius * var_v1->radius)) { return var_v1 - temp_v0->unk8; } } @@ -1839,14 +1829,14 @@ s32 func_803073CC(f32 arg0[3], s32 arg1, s32 arg2) { temp_v0 = &D_8036A9D4[arg1]; var_v1 = temp_v0->unk8 + arg2; - if (((arg0[0] - var_v1->unk0[0]) * (arg0[0] - var_v1->unk0[0])) + (((arg0[2] - var_v1->unk0[2]) * (arg0[2] - var_v1->unk0[2]))) < (var_v1->unkC * var_v1->unkC)) { + if (((arg0[0] - var_v1->position[0]) * (arg0[0] - var_v1->position[0])) + (((arg0[2] - var_v1->position[2]) * (arg0[2] - var_v1->position[2]))) < (var_v1->radius * var_v1->radius)) { return arg2; } - temp_a0 = temp_v0->unk8 + temp_v0->unk0; + temp_a0 = temp_v0->unk8 + temp_v0->count; for (var_v1 = temp_v0->unk8; var_v1 < temp_a0; var_v1++) { - temp_f2 = arg0[2] - var_v1->unk0[2]; - temp_f14 = arg0[0] - var_v1->unk0[0]; - if (((temp_f2 * temp_f2) + (temp_f14 * temp_f14)) < (var_v1->unkC * var_v1->unkC)) { + temp_f2 = arg0[2] - var_v1->position[2]; + temp_f14 = arg0[0] - var_v1->position[0]; + if (((temp_f2 * temp_f2) + (temp_f14 * temp_f14)) < (var_v1->radius * var_v1->radius)) { return var_v1 - temp_v0->unk8; } } @@ -1871,8 +1861,8 @@ s32 func_80307504(f32 arg0[3], s32 arg1, s32 arg2, s32 arg3, s32 arg4) { min = sp4C[1] - arg3 / 2; if (arg4 & 1) { if (var_s0->unk10_3 & arg4) { - if (!(max < var_s0->unk0[1]) && (min < var_s0->unk0[1])) { - if (func_80259328(sp4C, var_s0->unk0, var_s0->unkC)) { + if (!(max < var_s0->position[1]) && (min < var_s0->position[1])) { + if (func_80259328(sp4C, var_s0->position, var_s0->radius)) { return arg2; } } @@ -1880,24 +1870,24 @@ 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->unk0[1]) && (min < var_s0->unk0[1])))) - if( func_80259328(&sp4C, var_s0->unk0, var_s0->unkC)) + 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)) return arg2; } if (arg4 & 1) { - for(var_s0 = temp_s1->unk8; var_s0 < temp_s1->unk8 + temp_s1->unk0; var_s0++){ + 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->unk0[1]) && (min < var_s0->unk0[1])) - if(func_80259328(&sp4C, var_s0, var_s0->unkC)) + if (!(max < var_s0->position[1]) && (min < var_s0->position[1])) + if(func_80259328(&sp4C, var_s0, var_s0->radius)) return (var_s0 - temp_s1->unk8); } } else{ - for(var_s0 = temp_s1->unk8; var_s0 < temp_s1->unk8 + temp_s1->unk0; var_s0++){ + 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->unk0[1]) && (min < var_s0->unk0[1])))) - if(func_80259328(&sp4C, var_s0, var_s0->unkC)) + 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)) return var_s0 - temp_s1->unk8; } } @@ -2424,9 +2414,9 @@ void func_80308984(void) { void func_80308D2C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 phi_s4; s32 phi_s0; - s32 sp54[3]; + s32 vp_pos[3]; Cube *temp_s3; - s32 temp_lo; + s32 vp_cube_index; func_8032F464(1); phi_s4 = 0; @@ -2435,9 +2425,9 @@ void func_80308D2C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { if (!func_80308F54(D_80382150[phi_s4])) { temp_s3 = &D_80381FA0.cube_list[D_80382150[phi_s4]]; if (func_8024D8F4(temp_s3)) { - func_8024C5F0(sp54); - temp_lo = cube_atPosition_s32(sp54) - D_80381FA0.cube_list; - for(phi_s0 = 0; (phi_s0 < D_80382150[phi_s4 + 1]) && (temp_lo != D_80382150[phi_s0 + 2]); phi_s0++) { + veiwport_get_position_vec3w(vp_pos); + vp_cube_index = cube_atPosition_s32(vp_pos) - D_80381FA0.cube_list; + for(phi_s0 = 0; (phi_s0 < D_80382150[phi_s4 + 1]) && (vp_cube_index != D_80382150[phi_s0 + 2]); phi_s0++) { } if (phi_s0 < (s32) D_80382150[phi_s4 + 1]) { func_80301F10(temp_s3, gfx, mtx, vtx); diff --git a/src/core2/code_85800.c b/src/core2/code_85800.c index 753920af..f88a66fb 100644 --- a/src/core2/code_85800.c +++ b/src/core2/code_85800.c @@ -218,7 +218,7 @@ s32 func_8030CDE4(struct45s *arg0){ f32 temp_f0; f32 pad; - viewport_getPosition(&sp44); + viewport_get_position_vec3f(&sp44); func_8024C5A8(&sp38); sp2C[0] = arg0->position[0] - sp44[0]; sp2C[1] = arg0->position[1] - sp44[1]; diff --git a/src/core2/code_87E30.c b/src/core2/code_87E30.c index 62ddb73e..4d48289f 100644 --- a/src/core2/code_87E30.c +++ b/src/core2/code_87E30.c @@ -10,13 +10,14 @@ extern void gczoombox_open(gczoombox_t *); extern void gczoombox_minimize(gczoombox_t *); extern void gczoombox_close(gczoombox_t *); extern bool func_803188B4(gczoombox_t *); +extern char *dialogBin_get(enum asset_e text_id); s8 D_8036C4D0[] = {1, 0x1E, 0x14, 0xF, 0xB, 8, 6, 4, 3, 2, -1, -1}; - + /* .bss */ struct { char output[0x100]; - u8 *unk100; + u8 *dialog_bin_ptr; struct13s *string_list[2]; //string ptr char *string[2]; //current_string u8 string_count[2]; //zoombox string_count @@ -74,7 +75,7 @@ void gcdialog_init(void) { s32 i; struct14s *i_ptr; - D_80382E20.unk100 = 0; + D_80382E20.dialog_bin_ptr = 0; for( i = 0; i < 2; i++){ D_80382E20.string_list[i] = NULL; @@ -134,9 +135,9 @@ void func_8030F078(void){ D_80382E20.string_list[i] = NULL; } if(D_80382E20.unk130 != -1){ - func_8031B6D8(D_80382E20.unk130); + dialogBin_release(D_80382E20.unk130); } - D_80382E20.unk100 = NULL; + D_80382E20.dialog_bin_ptr = NULL; } void func_8030F130(void){ @@ -579,7 +580,7 @@ void func_80310574(s32 text_id){ char ch; s32 len; - txt = D_80382E20.unk100 = func_8031B66C(text_id); + txt = D_80382E20.dialog_bin_ptr = dialogBin_get(text_id); for(i = 0; i < 2; i++){ D_80382E20.string_count[i] = *(txt++); @@ -637,7 +638,7 @@ void func_803106BC(s32 text_id, s32 arg1, ActorMarker *marker, void(*callback)(A D_80382E20.unk11A[j].unk0_5 = 0; if(D_80382E20.string_list[j][i].cmd >= 0){ if(!D_80382E20.unk11A[j].unk0_7){ - D_80382E20.zoombox[j] = gczoombox_new(D_80382E20.unk124[j], D_80382E20.string_list[j][i].cmd + 0xC, 0, func_803106A4(j), func_8030F754); + D_80382E20.zoombox[j] = gczoombox_new(D_80382E20.unk124[j], D_80382E20.string_list[j][i].cmd + 0xC, 0, func_803106A4(j), (void *)func_8030F754); if( j == 1 ){ func_80347A14(0); } @@ -674,7 +675,7 @@ void func_803106BC(s32 text_id, s32 arg1, ActorMarker *marker, void(*callback)(A D_80382E20.caller = marker; D_80382E20.unk13C = callback; D_80382E20.unk140 = arg4; - D_80382E20.unk144 = arg5; + D_80382E20.unk144 = (void *)arg5; D_80382E20.unk138 = (marker != NULL )? ((marker->unk5C)? marker->unk5C : -1) : 0; gcdialog_setState(((func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) && D_80382E20.unk128_3) ? 6 : 1); //L803109EC @@ -835,7 +836,7 @@ int func_80311174(s32 text_id, s32 arg1, f32 *pos, ActorMarker *marker, void(*ca return 0; if(!func_803114B0()){ - func_80310B1C(text_id, arg1, marker, callback, arg5, arg6); + func_80310B1C(text_id, arg1, marker, (void *)callback, (void *)arg5, arg6); if(arg1 & 8){ if(!(func_802E4A08() || func_803203FC(UNKFLAGS1_1F_IN_CHARACTER_PARADE)) || !D_80382E20.unk128_3){//L80311214 if(pos != NULL){ @@ -877,8 +878,8 @@ int func_80311174(s32 text_id, s32 arg1, f32 *pos, ActorMarker *marker, void(*ca } D_80382E20.unk148[temp_v1].unk10 = marker; D_80382E20.unk148[temp_v1].unk14 = (marker != NULL )? ((marker->unk5C)? marker->unk5C : -1) : 0; - D_80382E20.unk148[temp_v1].unk18 = callback; - D_80382E20.unk148[temp_v1].unk1C = arg5; + D_80382E20.unk148[temp_v1].unk18 = (void *)callback; + D_80382E20.unk148[temp_v1].unk1C = (void *)arg5; D_80382E20.unk148[temp_v1].unk20 = arg6; D_80382E20.unk12C_15++; if(arg1 & 0x08){ diff --git a/src/core2/code_94620.c b/src/core2/code_94620.c index 9cb8747d..deac9e7a 100644 --- a/src/core2/code_94620.c +++ b/src/core2/code_94620.c @@ -8,20 +8,20 @@ s32 D_80383150; s32 pad_80383154; struct { u8 unk0; - void *unk4; - s32 unk8; + char *ptr; + s32 index; } -D_80383158; +s_dialogBin; s32 func_8031B5B0(void) { - return D_80383158.unk0; + return s_dialogBin.unk0; } s32 func_8031B5BC(void){ return 1; } void func_8031B5C4(s32 arg0) { if ((arg0 >= 0) && (arg0 < func_8031B5BC())) { - D_80383158.unk0 = (s8) arg0; + s_dialogBin.unk0 = (s8) arg0; } D_80383150 = 1; } @@ -31,40 +31,41 @@ bool func_8031B604(char *arg0) { } void func_8031B62C(void) { - D_80383158.unk0 = (u8)0; + s_dialogBin.unk0 = (u8)0; } s32 func_8031B638(void) { return D_80383150; } -void func_8031B644(void){ - D_80383158.unk4 = NULL; - D_80383158.unk8 = -1; +void dialogBin_initialize(void){ + s_dialogBin.ptr = NULL; + s_dialogBin.index = -1; } -void func_8031B65C(void){} +void dialogBin_update(void){} -void func_8031B664(void){} +void dialogBin_terminate(void){} -char *func_8031B66C(enum asset_e text_id) { +char *dialogBin_get(enum asset_e text_id) { char *sp1C; - s32 var_v0; - s32 var_a0; + char *var_v0; + s32 var_a0; //offset where text starts (normally 0x3) - D_80383158.unk4 = assetcache_get(text_id); - sp1C = (s32)D_80383158.unk4 + 1; + //get text_bin from asset cache + s_dialogBin.ptr = assetcache_get(text_id); + sp1C = s_dialogBin.ptr + 1; sp1C += func_8031B5B0()*2; var_a0 = *(sp1C++); var_a0 += *(sp1C++)<< 8; if(sp1C); - var_v0 = (s32)D_80383158.unk4 + var_a0; - D_80383158.unk8 = text_id; + var_v0 = s_dialogBin.ptr + var_a0; + s_dialogBin.index = text_id; return var_v0; } -void func_8031B6D8(s32 arg0){ - assetcache_release(D_80383158.unk4); - D_80383158.unk4 = NULL; - D_80383158.unk8 = -1; +void dialogBin_release(s32 arg0){ + assetcache_release(s_dialogBin.ptr); + s_dialogBin.ptr = NULL; + s_dialogBin.index = -1; } diff --git a/src/core2/code_98CB0.c b/src/core2/code_98CB0.c index 0c2499c8..1a8a0013 100644 --- a/src/core2/code_98CB0.c +++ b/src/core2/code_98CB0.c @@ -4,8 +4,8 @@ void func_8031FFAC(void); void fileProgressFlag_set(s32 index, s32 set); -s32 func_803200A4(u8 *array, s32 index); -s32 func_803200E4(u8 *array, s32 offset, s32 numBits); +s32 bitfield_get_bit(u8 *array, s32 index); +s32 bitfield_get_n_bits(u8 *array, s32 offset, s32 numBits); void func_8032015C(u8 *array, s32 index, s32 set); void func_803201C8(u8 *array, s32 startIndex, s32 set, s32 length); void func_8032048C(void); @@ -108,11 +108,11 @@ void func_8031FEC0(void) { } bool fileProgressFlag_get(enum file_progress_e index) { - return func_803200A4(D_803831A0.unk8, index); + return bitfield_get_bit(D_803831A0.unk8, index); } s32 fileProgressFlag_getN(s32 offset, s32 numBits) { - return func_803200E4(D_803831A0.unk8, offset, numBits); + return bitfield_get_n_bits(D_803831A0.unk8, offset, numBits); } s32 fileProgressFlag_getAndSet(s32 index, s32 set) { @@ -151,7 +151,7 @@ void func_8032008C(s32 *arg0, u8 **arg1) { } // Returns a single bit from a byte array -s32 func_803200A4(u8 *array, s32 index) { +s32 bitfield_get_bit(u8 *array, s32 index) { s32 ret; if (array[index / 8] & (1 << (index & 7))) { ret = 1; @@ -162,12 +162,12 @@ s32 func_803200A4(u8 *array, s32 index) { } // Extracts an integer of the given number of bits from a byte array at the starting bit offset -s32 func_803200E4(u8 *array, s32 offset, s32 numBits) { +s32 bitfield_get_n_bits(u8 *array, s32 offset, s32 numBits) { s32 ret = 0; s32 i; for (i = 0; i < numBits; i++) { - ret |= (func_803200A4(array, offset + i) << i); + ret |= (bitfield_get_bit(array, offset + i) << i); } return ret; } @@ -246,11 +246,11 @@ void func_803203A0(void) { } s32 func_803203FC(s32 index) { - return func_803200A4(D_803831D0.unk8, index); + return bitfield_get_bit(D_803831D0.unk8, index); } void func_80320424(s32 index, s32 numBits) { - func_803200E4(D_803831D0.unk8, index, numBits); + bitfield_get_n_bits(D_803831D0.unk8, index, numBits); } s32 func_80320454(s32 index, s32 arg1) { diff --git a/src/core2/code_9E370.c b/src/core2/code_9E370.c index 8a0d93ce..d6a3fc0a 100644 --- a/src/core2/code_9E370.c +++ b/src/core2/code_9E370.c @@ -310,7 +310,7 @@ Actor *func_80325CAC(ActorMarker *marker, Gfx **gfx, Gfx **mtx, Vtx **vtx) { this->position[1] -= D_8036E58C[1]; this->position[2] -= D_8036E58C[2]; } - viewport_getRotation(rotation); + viewport_get_rotation_vec3f(rotation); rotation[2] += this->roll; func_80338338(0xFF, 0xFF, 0xFF); if (this->unk124_11 != 0) { @@ -1054,7 +1054,7 @@ static void __actor_free(ActorMarker *arg0, Actor *arg1){ } Actor *func_8032811C(enum actor_e id, s32 (* pos)[3], s32 rot){ - return func_803056FC(id, pos, rot); + return spawn_actor(id, pos, rot); } Actor *func_8032813C(enum actor_e id, f32 pos[3], s32 rot){ @@ -1063,7 +1063,7 @@ Actor *func_8032813C(enum actor_e id, f32 pos[3], s32 rot){ for(i = 0; i< 3; i++){ sp24[i] = pos[i]; } - func_803056FC(id, &sp24, rot); + spawn_actor(id, &sp24, rot); } Actor * spawn_child_actor(enum actor_e id, Actor ** parent){ @@ -1073,7 +1073,7 @@ Actor * spawn_child_actor(enum actor_e id, Actor ** parent){ sp1C[0] = (*parent)->position_x; sp1C[1] = (*parent)->position_y; sp1C[2] = (*parent)->position_z; - child = func_803056FC(id, sp1C, (*parent)->yaw); + child = spawn_actor(id, sp1C, (*parent)->yaw); *parent = marker_getActor(sp28); return child; } @@ -1097,7 +1097,7 @@ Actor *func_803282AC(enum actor_e id, s16 (* pos)[3], s32 yaw){ for(i = 0; i< 3; i++){ sp24[i] = (*pos)[i]; } - return func_803056FC(id, &sp24, yaw); + return spawn_actor(id, &sp24, yaw); } void marker_despawn(ActorMarker *marker){ diff --git a/src/core2/code_A5BC0.c b/src/core2/code_A5BC0.c index 88f06271..8f61be9c 100644 --- a/src/core2/code_A5BC0.c +++ b/src/core2/code_A5BC0.c @@ -100,7 +100,7 @@ void func_8032CB50(Cube *cube, bool global) { if (cube->prop2Cnt >= 2) { if (global == 0) { - func_8024C5F0(ref_position); //distance from viewport + veiwport_get_position_vec3w(ref_position); //distance from viewport } else { ref_position[0] = 0; ref_position[1] = 0; @@ -649,7 +649,7 @@ bool func_8032E178(Cube *arg0, s32 *arg1, s32 arg2) { && (var_v1->unk6.bit6 == 6) && (arg2 == var_v1->unk8) ) { - *arg1 = var_v1->unk6.bit15; + *arg1 = var_v1->unk6.radius; return TRUE; } var_v1++; @@ -1314,7 +1314,7 @@ void func_80330208(Cube *cube) { actor = func_803055E0(i_prop->unk8, position, i_prop->unkC_31, i_prop->unk10_31, i_prop->unk10_19); if (actor != NULL) { actor->unk78_13 = i_prop->unk10_31; - actor->unkF4_8 = i_prop->unk6.bit15; + actor->unkF4_8 = i_prop->unk6.radius; func_8032AA58(actor, (i_prop->unkC_22 != 0) ? ((f32)i_prop->unkC_22 * 0.01) : 1.0); } } @@ -1337,17 +1337,17 @@ void func_803303B8(Cube *cube) { sp4C[0] = (s32) var_s0->x; sp4C[1] = (s32) var_s0->y; sp4C[2] = (s32) var_s0->z; - func_803065E4(var_s0->unk8, sp4C, var_s0->unk6.bit15, var_s0->unk10_31, var_s0->unk10_7); + func_803065E4(var_s0->unk8, sp4C, var_s0->unk6.radius, var_s0->unk10_31, var_s0->unk10_7); } else if (var_s0->unk6.bit6 == 9) { sp4C[0] = (s32) var_s0->x; sp4C[1] = (s32) var_s0->y; sp4C[2] = (s32) var_s0->z; - func_8030688C(var_s0->unk8, sp4C, var_s0->unk6.bit15, var_s0->unk10_0); + func_8030688C(var_s0->unk8, sp4C, var_s0->unk6.radius, var_s0->unk10_0); } else if (var_s0->unk6.bit6 == 0xA) { sp4C[0] = (s32) var_s0->x; sp4C[1] = (s32) var_s0->y; sp4C[2] = (s32) var_s0->z; - func_80306AA8(var_s0->unk8, sp4C, var_s0->unk6.bit15); + func_80306AA8(var_s0->unk8, sp4C, var_s0->unk6.radius); } var_s0++; } @@ -1606,7 +1606,7 @@ s32 func_80330F94(NodeProp *arg0, s32 arg1[3]){ arg1[0] = arg0->x; arg1[1] = arg0->y; arg1[2] = arg0->z; - return arg0->unk6.bit15; + return arg0->unk6.radius; } void func_80330FBC(UNK_TYPE(void *)arg0, s32 arg1){ @@ -1766,9 +1766,9 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s f32 *new_var2; s32 spD8; Actor *temp_v0_6; - BKModelBin *temp_v0_2; + BKModelBin *model_bin; BKVertexList *temp_a1; - BKCollisionList *temp_v0_3; + BKCollisionList *model_collision_list; f32 spBC[3]; f32 spB0[3]; u32 var_s3; @@ -1789,13 +1789,13 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s { if (((!var_s0->markerFlag) && var_s0->unk8_1) && var_s0->unk8_4) { - temp_v0_2 = func_8030A4B4(((u32) (*((u16 *) (&var_s0->modelProp)))) >> 4); - if (temp_v0_2 == 0) + model_bin = func_8030A4B4(((u32) (*((u16 *) (&var_s0->modelProp)))) >> 4); + if (model_bin == 0) { continue; } - temp_v0_3 = model_getCollisionList(temp_v0_2); - if (temp_v0_3 == 0) + model_collision_list = model_getCollisionList(model_bin); + if (model_collision_list == 0) { continue; } @@ -1806,7 +1806,10 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s spB0[1] = (f32) (var_s0->modelProp.unk0_15 * 2); new_var = spB0; spB0[2] = (f32) (var_s0->modelProp.unk0_7 * 2); - var_v0 = func_802E9118(temp_v0_3, model_getVtxList(temp_v0_2), spBC, new_var, (f32) (((f32) var_s0->modelProp.unkA) / 100.0), arg1, arg2, arg3, arg4, arg5, flags); + var_v0 = func_802E9118(model_collision_list, model_getVtxList(model_bin), + spBC, new_var, (f32) (((f32) var_s0->modelProp.unkA) / 100.0), + arg1, arg2, arg3, arg4, arg5, flags + ); if (var_v0 != 0) { spD8 = var_v0; @@ -1815,14 +1818,14 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s else if ((var_s0->markerFlag && var_s0->unk8_3) && var_s0->unk8_4) { - temp_v0_3 = func_80330DE4(var_s0->actorProp.marker); - pad9C = temp_v0_3; - if (temp_v0_3 == 0) + model_collision_list = func_80330DE4(var_s0->actorProp.marker); + pad9C = model_collision_list; + if (model_collision_list == 0) { continue; } - temp_v0_2 = model_getCollisionList(pad9C); - if (temp_v0_2 == 0) + model_bin = model_getCollisionList(pad9C); + if (model_bin == 0) { continue; } @@ -1835,7 +1838,7 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s sp8C[0] = (f32) var_s0->actorProp.marker->pitch; sp8C[1] = (f32) var_s0->actorProp.marker->yaw; sp8C[2] = (f32) var_s0->actorProp.marker->roll; - var_v0 = func_802E9118(temp_v0_2, temp_a1, sp98, new_var2, temp_v0_6->scale, arg1, arg2, arg3, arg4, arg5, flags); + var_v0 = func_802E9118(model_bin, temp_a1, sp98, new_var2, temp_v0_6->scale, arg1, arg2, arg3, arg4, arg5, flags); } if (var_v0 != 0) { @@ -1865,16 +1868,16 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s return spD8; } -BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 arg4[3], u32 arg5){ +BKCollisionTri *func_803319C0(Cube *cube, f32 position[3], f32 radius, s32 arg3, f32 arg4[3], u32 arg5){ BKCollisionTri *var_s7; BKCollisionTri *var_v0; s32 var_s3; Prop *var_s0; - BKCollisionList *temp_v0_3; + BKCollisionList *model_collision_list; BKVertexList *temp_a1; f32 spAC[3]; f32 spA0[3]; - BKModelBin *temp_v0_2; + BKModelBin *model_bin; BKModelBin *new_var; ModelProp *mProp; f32 sp88[3]; @@ -1883,25 +1886,25 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a ActorProp *aProp = &var_s0->actorProp; var_s7 = 0; - var_s0 = arg0->prop2Ptr; - for (var_s3 = arg0->prop2Cnt; var_s3 != 0; var_s3--, var_s0++) { + var_s0 = cube->prop2Ptr; + for (var_s3 = cube->prop2Cnt; var_s3 != 0; var_s3--, var_s0++) { if (((!var_s0->markerFlag) && var_s0->unk8_1) && var_s0->unk8_4) { mProp = &var_s0->modelProp; new_var = func_8030A4B4(mProp->unk0_31); if (1) { } if (1) { } if (1) { } - temp_v0_2 = new_var; - if (temp_v0_2 != 0){ - temp_v0_3 = model_getCollisionList(temp_v0_2); - if (temp_v0_3 != 0){ + model_bin = new_var; + if (model_bin != 0){ + model_collision_list = model_getCollisionList(model_bin); + if (model_collision_list != 0){ spAC[0] = (f32) mProp->unk4[0]; spAC[1] = (f32) mProp->unk4[1]; spAC[2] = (f32) mProp->unk4[2]; spA0[0] = 0.0f; spA0[1] = (f32) (mProp->unk0_15 * 2); - temp_v0_2 = temp_v0_2; + model_bin = model_bin; spA0[2] = (f32) (mProp->unk0_7 * 2); - var_v0 = func_802E9DD8(temp_v0_3, model_getVtxList(temp_v0_2), spAC, spA0, ((f32) mProp->unkA) / 100.0, arg1, arg2, arg3, arg4); + var_v0 = func_802E9DD8(model_collision_list, model_getVtxList(model_bin), spAC, spA0, ((f32) mProp->unkA) / 100.0, position, radius, arg3, arg4); if (var_v0 != 0) var_s7 = var_v0; } @@ -1910,10 +1913,9 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a aProp = &var_s0->actorProp; if ((var_s0->markerFlag && var_s0->unk8_3) && var_s0->unk8_4) { - temp_v0_2 = func_80330DE4(aProp->marker); - if (temp_v0_2 != 0) - { - new_var = model_getCollisionList(temp_v0_2); + model_bin = func_80330DE4(aProp->marker); + if (model_bin != 0) { + new_var = model_getCollisionList(model_bin); if (new_var != 0) { @@ -1925,7 +1927,7 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a sp7C[0] = aProp->marker->pitch; sp7C[1] = aProp->marker->yaw; sp7C[2] = aProp->marker->roll; - var_v0 = func_802E9DD8(new_var, temp_a1, sp88, sp7C, temp_v0_6->scale, arg1, arg2, arg3, arg4); + var_v0 = func_802E9DD8(new_var, temp_a1, sp88, sp7C, temp_v0_6->scale, position, radius, arg3, arg4); if (var_v0 != 0) { var_s7 = var_v0; @@ -1942,7 +1944,7 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a { if (temp_v0_7->unk8 != 0) { - var_v0 = temp_v0_7->unk8(aProp->marker, arg1, arg2, arg3, arg4); + var_v0 = temp_v0_7->unk8(aProp->marker, position, radius, arg3, arg4); if (var_v0 != 0) { var_s7 = var_v0; diff --git a/src/core2/code_AD5B0.c b/src/core2/code_AD5B0.c index 718e9aa7..c425e2e8 100644 --- a/src/core2/code_AD5B0.c +++ b/src/core2/code_AD5B0.c @@ -174,7 +174,7 @@ void func_80334910(void) { if (func_802E4A08() == 0) { itemPrint_free(); } - func_8031B664(); + dialogBin_terminate(); func_802986D0(); if (func_80322914() == 0) { func_8024F7C4(func_803226E8(D_803835D0.map_4)); @@ -211,7 +211,7 @@ void func_80334B20(enum map_e arg0, s32 arg1, s32 arg2) { if (func_802E4A08() == 0) { itemPrint_init(); } - func_8031B644(); + dialogBin_initialize(); spawnQueue_malloc(); func_803329AC(); func_80350BFC(); @@ -345,7 +345,7 @@ s32 func_80334ECC(void) { } AnimTextureListCache_update(); func_80350CA4(); - func_8031B65C(); + dialogBin_update(); func_80310D2C(); gcparade_update(); overlay_update(); diff --git a/src/core2/code_AEDA0.c b/src/core2/code_AEDA0.c index bff463de..2861baaa 100644 --- a/src/core2/code_AEDA0.c +++ b/src/core2/code_AEDA0.c @@ -443,7 +443,7 @@ void func_803380F8(Gfx **gfx, Mtx **mtx, f32 arg2[3]) { f32 sp2C[3]; f32 sp20[3]; - viewport_getPosition(sp2C); + viewport_get_position_vec3f(sp2C); sp20[0] = arg2[0] - sp2C[0]; sp20[1] = arg2[1] - sp2C[1]; sp20[2] = arg2[2] - sp2C[2]; @@ -457,7 +457,7 @@ void func_803381B4(Gfx **gfx, Mtx **mtx, f32 arg2[3]) { f32 sp2C[3]; f32 sp20[3]; - viewport_getPosition(sp2C); + viewport_get_position_vec3f(sp2C); sp20[0] = arg2[0] - sp2C[0]; sp20[1] = arg2[1] - sp2C[1]; sp20[2] = arg2[2] - sp2C[2]; @@ -525,4 +525,4 @@ void func_80338370(void){ void func_8033837C(s32 arg0){ D_8037033C = arg0; -} \ No newline at end of file +} diff --git a/src/core2/code_B3A80.c b/src/core2/code_B3A80.c index 28a57d19..96bced6f 100644 --- a/src/core2/code_B3A80.c +++ b/src/core2/code_B3A80.c @@ -6,7 +6,7 @@ #include "animation.h" extern f32 glspline_catmull_rom_interpolate(f32, s32, f32 *); - +extern BKSpriteDisplayData * func_80344A1C(BKSprite *arg0); f32 D_803709E0[] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, diff --git a/src/core2/code_B8860.c b/src/core2/code_B8860.c index 1c6d49e4..cf657fce 100644 --- a/src/core2/code_B8860.c +++ b/src/core2/code_B8860.c @@ -2,7 +2,7 @@ #include "functions.h" #include "variables.h" -extern void mlMtxRotate(f32, f32, f32); +extern void mlMtxRotatePYR(f32, f32, f32); extern void func_80252330(f32, f32, f32); extern void mlMtxApply(Mtx *); @@ -40,7 +40,7 @@ void func_8033F7F0(u8 arg0, Gfx **gfx, Mtx **mtx, Vtx **vtx){ if(sp54->unk28_23 != 1){ ml_vec3f_copy(sp48, sp54->unk4); sp48[1] += (sp54->unk1C*sp54->unk20[1])/100.0; - viewport_getPosition(sp3C); + viewport_get_position_vec3f(sp3C); ml_vec3f_diff_copy(sp30, sp48, sp3C); if(sp54->unk28_12){ mlMtxSet(func_8024DD90()); @@ -48,7 +48,7 @@ void func_8033F7F0(u8 arg0, Gfx **gfx, Mtx **mtx, Vtx **vtx){ else{ mlMtxIdent(); } - mlMtxRotate(sp54->unk10[0], sp54->unk10[1], sp54->unk10[2]); + mlMtxRotatePYR(sp54->unk10[0], sp54->unk10[1], sp54->unk10[2]); func_80252330(sp30[0], sp30[1], sp30[2]); mlMtxApply(*mtx); gSPMatrix((*gfx)++, OS_PHYSICAL_TO_K0((*mtx)++), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/core2/code_BD100.c b/src/core2/code_BD100.c index 8fd6267c..6d06d4a4 100644 --- a/src/core2/code_BD100.c +++ b/src/core2/code_BD100.c @@ -4,7 +4,7 @@ extern void spriteRender_drawWithSegment(Gfx**, Vtx**, BKSprite *, s32, s32); extern void func_80252330(f32, f32, f32); -extern void mlMtxRotate(f32, f32, f32); +extern void mlMtxRotatePYR(f32, f32, f32); extern void mlMtxApply(Mtx *); extern void func_80349AD0(void); extern void func_8024C5A8(f32[3]); @@ -51,7 +51,7 @@ void func_80344138(BKSpriteDisplayData *self, s32 frame, s32 mirrored, f32 posit f32 sp38; f32 sp34; - viewport_getPosition(sp6C); + viewport_get_position_vec3f(sp6C); func_8024C5A8(sp60); sp50[0] = position[0] - sp6C[0]; sp50[1] = position[1] - sp6C[1]; @@ -109,7 +109,7 @@ void func_80344424(BKSpriteDisplayData *arg0, s32 frame, bool mirrored, f32 posi f32 sp38; f32 sp34; - viewport_getPosition(sp6C); + viewport_get_position_vec3f(sp6C); func_8024C5A8(sp60); sp50[0] = position[0] - sp6C[0]; sp50[1] = position[1] - sp6C[1]; @@ -141,7 +141,7 @@ void func_80344424(BKSpriteDisplayData *arg0, s32 frame, bool mirrored, f32 posi D_80371EC0.unk0(D_80371EC0.unk4); } mlMtxSet(func_8024DD90()); - mlMtxRotate(0.0f, 0.0f, rotation); + mlMtxRotatePYR(0.0f, 0.0f, rotation); func_80252330(sp50[0], sp50[1], sp50[2]); if ((scale != NULL) || mirrored) { mlMtxScale_xyz((mirrored) ? -scale[0] : scale[0], sp38, sp34); @@ -167,7 +167,7 @@ void func_80344720(BKSpriteDisplayData *arg0, s32 frame, bool mirrored, f32 posi f32 var_f14; BKSpriteFrameDisplayData *temp_a3; - viewport_getPosition(sp5C); + viewport_get_position_vec3f(sp5C); func_8024C5A8(sp50); sp40[0] = position[0] - sp5C[0]; sp40[1] = position[1] - sp5C[1]; @@ -191,7 +191,7 @@ void func_80344720(BKSpriteDisplayData *arg0, s32 frame, bool mirrored, f32 posi } mlMtxIdent(); func_80252330(sp40[0], sp40[1], sp40[2]); - mlMtxRotate(rotation[0], rotation[1], rotation[2]); + mlMtxRotatePYR(rotation[0], rotation[1], rotation[2]); mlMtxScale_xyz((mirrored) ? -scale[0] : scale[0], scale[1], scale[2]); mlMtxApply(*mtx); gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/core2/code_BE2C0.c b/src/core2/code_BE2C0.c index 4a764413..86fcffa9 100644 --- a/src/core2/code_BE2C0.c +++ b/src/core2/code_BE2C0.c @@ -202,7 +202,7 @@ void func_80345C78(f32 arg0[4], f32 arg1[3]) { mlMtxRotYaw(arg1[1]); mlMtxRotPitch(arg1[0]); mlMtxRotRoll(arg1[2]); - func_80345A44(arg0, func_80251488()); + func_80345A44(arg0, mlMtx_get_stack_pointer()); } void func_80345CD4(f32 arg0[4], f32 arg1[4]){ @@ -210,7 +210,7 @@ void func_80345CD4(f32 arg0[4], f32 arg1[4]){ mlMtxRotRoll(arg1[2]); mlMtxRotYaw(arg1[1]); mlMtxRotPitch(arg1[0]); - func_80345A44(arg0, func_80251488()); + func_80345A44(arg0, mlMtx_get_stack_pointer()); } void func_80345D30(f32 arg0[4], f32 arg1[4], f32 arg2[4]) { diff --git a/src/core2/code_BEF20.c b/src/core2/code_BEF20.c index ad5d71b4..86af48f4 100644 --- a/src/core2/code_BEF20.c +++ b/src/core2/code_BEF20.c @@ -237,7 +237,7 @@ void func_803465E4(void){ }//L8034667C if(D_80385FE0){ - if(gctransition_8030BD98() || func_803203FC(0)){ + if(gctransition_done() || func_803203FC(0)){ if(D_80385FE4){ item_dec(ITEM_16_LIFE); func_802FACA4(ITEM_14_HEALTH); diff --git a/src/core2/code_C4320.c b/src/core2/code_C4320.c index 4a9f688c..7f8c3a77 100644 --- a/src/core2/code_C4320.c +++ b/src/core2/code_C4320.c @@ -148,7 +148,7 @@ void func_8034B580(s32 arg0) { f32 sp1C; sp1C = D_80386128; - if (gctransition_8030BD98() != 0) { + if (gctransition_done() != 0) { D_80386128 += time_getDelta(); } if ((getGameMode() != GAME_MODE_8_BOTTLES_BONUS) && (getGameMode() != GAME_MODE_A_SNS_PICTURE)) { @@ -278,7 +278,7 @@ void func_8034BB08(bool arg0) { } bool func_8034BB48(void) { - if (D_80386120 && gctransition_8030BD98()) { + if (D_80386120 && gctransition_done()) { D_80386120 = FALSE; return TRUE; } @@ -290,7 +290,7 @@ void func_8034BB90(void) { s32 sp18; sp1C = gctransition_8030BDC0(); - sp18 = gctransition_8030BD98(); + sp18 = gctransition_done(); if (!D_80386118) { func_8034B834(); func_8034B4E4(D_80386114->unk1); diff --git a/src/core2/code_C97F0.c b/src/core2/code_C97F0.c index b568052a..b806c935 100644 --- a/src/core2/code_C97F0.c +++ b/src/core2/code_C97F0.c @@ -3,7 +3,7 @@ #include "variables.h" extern bool func_8028F170(f32, f32); -extern void viewport_getPosition(f32[3]); +extern void viewport_get_position_vec3f(f32[3]); typedef struct { f32 unk0; @@ -129,8 +129,8 @@ void func_80350818(Gfx **gfx, Mtx **mtx, Vtx **vtx) { temp_s1 = D_80386170.unk4; if (( temp_s1 != NULL) && D_8038617C.unk0) { - viewport_getPosition(spDC); - viewport_getRotation(spD0); + viewport_get_position_vec3f(spDC); + viewport_get_rotation_vec3f(spD0); sp9C[0] = temp_s1->unk4[0]; sp9C[1] = temp_s1->unk4[1]; sp9C[2] = temp_s1->unk4[2]; @@ -196,7 +196,7 @@ void func_80350CA4(void) { s32 var_v0; if (D_80386170.unk4 != NULL) { - viewport_getPosition(sp54); + viewport_get_position_vec3f(sp54); sp48[0] = D_80386170.unk4->unk4[0]; sp48[1] = D_80386170.unk4->unk4[1]; sp48[2] = D_80386170.unk4->unk4[2]; diff --git a/src/core2/code_F8EAF0.c b/src/core2/code_F8EAF0.c index 768e7980..45911191 100644 --- a/src/core2/code_F8EAF0.c +++ b/src/core2/code_F8EAF0.c @@ -94,4 +94,4 @@ void func_802C02D4(f32 arg0[3]) { func_802C02B4(arg0); break; } -} \ No newline at end of file +} diff --git a/src/core2/gc/pauseMenu.c b/src/core2/gc/pauseMenu.c index 0b9de21b..3f732f71 100644 --- a/src/core2/gc/pauseMenu.c +++ b/src/core2/gc/pauseMenu.c @@ -1218,7 +1218,7 @@ void __gcpausemenu_drawSprite(Gfx** gdl, Mtx** mptr, Vtx** vptr, BKSprite* sprit func_80338338(0xFF, 0xFF, 0xFF); func_803382FC(a); func_8033837C(0); - viewport_getPosition(sp50); + viewport_get_position_vec3f(sp50); sp34 = func_8024DE1C(x, y, sp5C, sp44); mlMtxIdent(); //matrix_stack_identity @@ -1337,8 +1337,8 @@ void gcpausemenu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { sp8C[0] = 0.0f; sp8C[1] = 0.0f; sp8C[2] = 0.0f; - viewport_setPosition(sp98); - viewport_setRotation(sp8C); + viewport_set_position_vec3f(sp98); + viewport_set_rotation_vec3f(sp8C); viewport_update(); func_8024C904(gfx, mtx); sp98[0] = 0.0f; @@ -1382,8 +1382,8 @@ void gcpausemenu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { sp8C[1] = 0.0f; sp8C[2] = 0.0f; - viewport_setPosition(sp98); - viewport_setRotation(sp8C); + viewport_set_position_vec3f(sp98); + viewport_set_rotation_vec3f(sp8C); viewport_update(); func_8024C904(gfx, mtx); diff --git a/src/core2/gc/sky.c b/src/core2/gc/sky.c index e92eb58a..acf09c67 100644 --- a/src/core2/gc/sky.c +++ b/src/core2/gc/sky.c @@ -78,7 +78,7 @@ void sky_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx){ if(gcSky.model_bins[0]){ func_80254084(gfx, 0, 0, (s32)(f32) framebuffer_width, (s32)(f32)framebuffer_height,0, 0, 0); //fill screen with black func_8024C904(gfx, mtx); - viewport_getPosition(position); + viewport_get_position_vec3f(position); for(i = 0; i < 3; i++){ iAsset = gcSky.model_bins[i]; if(iAsset){ diff --git a/src/core2/gc/transition.c b/src/core2/gc/transition.c index c6c4d72e..8acc96df 100644 --- a/src/core2/gc/transition.c +++ b/src/core2/gc/transition.c @@ -9,73 +9,125 @@ void func_8025AC20(s32, s32, s32, f32, char*, s32); f32 func_80257618(void); void func_8024CE60(f32, f32); +typedef enum { + TRANSITION_ID_1_BLACK_IN = 1, + TRANSITION_ID_2_BLACK_OUT, + TRANSITION_ID_3_CIRCLE_IN, + TRANSITION_ID_4_CIRCLE_OUT, + TRANSITION_ID_5_JIGGY_IN, + TRANSITION_ID_6_JIGGY_OUT, + TRANSITION_ID_7, + TRANSITION_ID_8_WHITE_IN, + TRANSITION_ID_9_WHITE_OUT, + TRANSITION_ID_A_WITCH_HEAD_OUT, + TRANSITION_ID_B_CIRCLE_IN_FAST, + TRANSITION_ID_C_CIRCLE_OUT_FAST, + TRANSITION_ID_D, + TRANSITION_ID_E_CIRCLE_IN_SLOW, + TRANSITION_ID_F_CIRCLE_OUT_SLOW, + TRANSITION_ID_10_FALLING_PIECES_IN, + TRANSITION_ID_11_FALLING_PIECES_OUT, + TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, + TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW, + TRANSITION_ID_14_CIRCLE_IN_SUPER_SLOW, + TRANSITION_ID_15_CIRCLE_OUT_SUPER_SLOW, +} TransitionId; + +typedef enum { + TRANSITION_STATE_0_NONE, + TRANSITION_STATE_1_LOADING, + TRANSITION_STATE_2_BLACK_IN, + TRANSITION_STATE_3_BLACK_OUT, + TRANSITION_STATE_4_FADE_IN, + TRANSITION_STATE_5_FADE_OUT, + TRANSITION_STATE_6_LOADING_WHITE, + TRANSITION_STATE_7_WHITE_IN, + TRANSITION_STATE_8_WHITE_OUT +} TransitionState; + +typedef struct { + u8 uid; + u8 state; + u8 next_state; + // u8 pad3[1]; + f32 duration; + s32 model_index; + s32 anim_index; + f32 scale; +}TransitionInfo; + +typedef struct { + u8 map_indx; + u8 in_index; + u8 out_index; +}MapTransitionInfo; /* .data */ -struct9s D_8036C150[0x16]= { - {0x1, 2, 0, 0.1f, 0, 0, 0.0f}, - {0x2, 3, 1, 0.1f, 0, 0, 0.0f}, - {0x3, 4, 0, 0.5f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x4, 5, 1, 0.5f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x5, 4, 0, 2.5f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, - {0x6, 5, 1, 0.9f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, - {0x7, 0, 0, 0.0f, 0, 0, 0.0f}, - {0x8, 7, 0, 1.1f, 0, 0, 0.0f}, - {0x9, 8, 6, 0.7f, 0, 0, 0.0f}, - {0xA, 5, 1, 3.5f, ASSET_7D4_MODEL_TRANSITION_WITCH, 0, 3.7f}, - {0xB, 4, 0, 0.3f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0xC, 5, 1, 0.3f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0xD, 2, 0, 0.6f, 0, 0, 0.0f}, - {0xE, 4, 0, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0xF, 5, 1, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x10, 4, 0, 2.5f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, - {0x11, 5, 1, 2.0f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, - {0x12, 4, 0, 1.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x13, 5, 1, 1.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x14, 5, 1, 2.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x15, 4, 0, 2.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, +TransitionInfo D_8036C150[0x16]= { + {TRANSITION_ID_1_BLACK_IN, TRANSITION_STATE_2_BLACK_IN, TRANSITION_STATE_0_NONE, 0.1f, 0, 0, 0.0f}, + {TRANSITION_ID_2_BLACK_OUT, TRANSITION_STATE_3_BLACK_OUT, TRANSITION_STATE_1_LOADING, 0.1f, 0, 0, 0.0f}, + {TRANSITION_ID_3_CIRCLE_IN, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 0.5f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_4_CIRCLE_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 0.5f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_5_JIGGY_IN, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 2.5f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, + {TRANSITION_ID_6_JIGGY_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 0.9f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, + {TRANSITION_ID_7, TRANSITION_STATE_0_NONE, TRANSITION_STATE_0_NONE, 0.0f, 0, 0, 0.0f}, + {TRANSITION_ID_8_WHITE_IN, TRANSITION_STATE_7_WHITE_IN, TRANSITION_STATE_0_NONE, 1.1f, 0, 0, 0.0f}, + {TRANSITION_ID_9_WHITE_OUT, TRANSITION_STATE_8_WHITE_OUT, TRANSITION_STATE_6_LOADING_WHITE, 0.7f, 0, 0, 0.0f}, + {TRANSITION_ID_A_WITCH_HEAD_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 3.5f, ASSET_7D4_MODEL_TRANSITION_WITCH, 0, 3.7f}, + {TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 0.3f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_C_CIRCLE_OUT_FAST, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 0.3f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_D, TRANSITION_STATE_2_BLACK_IN, TRANSITION_STATE_0_NONE, 0.6f, 0, 0, 0.0f}, + {TRANSITION_ID_E_CIRCLE_IN_SLOW, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_F_CIRCLE_OUT_SLOW, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_10_FALLING_PIECES_IN, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 2.5f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, + {TRANSITION_ID_11_FALLING_PIECES_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 2.0f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, + {TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 1.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 1.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_14_CIRCLE_IN_SUPER_SLOW, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 2.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_15_CIRCLE_OUT_SUPER_SLOW, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 2.2f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, 0 }; -struct9s D_8036C308[0xC] = { - {0xA, 5, 1, 3.5f, ASSET_7D4_MODEL_TRANSITION_WITCH, 0, 3.7f}, - {0x10, 4, 0, 2.5f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, - {0x11, 5, 1, 2.0f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, - {0x6, 5, 1, 0.9f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, - {0x5, 4, 0, 2.5f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, - {0x9, 8, 6, 0.7f, 0, 0, 0.0f}, - {0x8, 7, 0, 0.7f, 0, 0, 0.0f}, - {0xE, 4, 0, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0xF, 5, 1, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, - {0x7, 0, 0, 0.0f, 0, 0, 0.0f}, - {0x8, 7, 0, 1.1f, 0, 0, 0.0f}, - {0x9, 8, 6, 1.5f, 0, 0, 0.0f} +TransitionInfo D_8036C308[0xC] = { + {TRANSITION_ID_A_WITCH_HEAD_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 3.5f, ASSET_7D4_MODEL_TRANSITION_WITCH, 0, 3.7f}, + {TRANSITION_ID_10_FALLING_PIECES_IN, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 2.5f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, + {TRANSITION_ID_11_FALLING_PIECES_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 2.0f, ASSET_467_MODEL_TRANSITION_FALLING_JIGGIES, ASSET_1F5_ANIM_TRANSITION_FALLING_JIGGIES, 0.269645989f}, + {TRANSITION_ID_6_JIGGY_OUT, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 0.9f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, + {TRANSITION_ID_5_JIGGY_IN, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 2.5f, ASSET_7D0_MODEL_TRANSITION_JIGGY, 0, 3.5f}, + {TRANSITION_ID_9_WHITE_OUT, TRANSITION_STATE_8_WHITE_OUT, TRANSITION_STATE_6_LOADING_WHITE, 0.7f, 0, 0, 0.0f}, + {TRANSITION_ID_8_WHITE_IN, TRANSITION_STATE_7_WHITE_IN, TRANSITION_STATE_0_NONE, 0.7f, 0, 0, 0.0f}, + {TRANSITION_ID_E_CIRCLE_IN_SLOW, TRANSITION_STATE_4_FADE_IN, TRANSITION_STATE_0_NONE, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_F_CIRCLE_OUT_SLOW, TRANSITION_STATE_5_FADE_OUT, TRANSITION_STATE_1_LOADING, 1.0f, ASSET_7CF_MODEL_TRANSITION_UNKNOWN, 0, 25.0f}, + {TRANSITION_ID_7, TRANSITION_STATE_0_NONE, TRANSITION_STATE_0_NONE, 0.0f, 0, 0, 0.0f}, + {TRANSITION_ID_8_WHITE_IN, TRANSITION_STATE_7_WHITE_IN, TRANSITION_STATE_0_NONE, 1.1f, 0, 0, 0.0f}, + {TRANSITION_ID_9_WHITE_OUT, TRANSITION_STATE_8_WHITE_OUT, TRANSITION_STATE_6_LOADING_WHITE, 1.5f, 0, 0, 0.0f} }; -struct10s D_8036C3F8[0x18] = { - {MAP_20_CS_END_NOT_100, 0x12, 0x13}, - {MAP_1F_CS_START_RAREWARE, 0x15, 0x09}, - {MAP_1E_CS_START_NINTENDO, 0x08, 0x13}, - {MAP_7D_CS_SPIRAL_MOUNTAIN_1, 0x0B, 0x0C}, - {MAP_7E_CS_SPIRAL_MOUNTAIN_2, 0x0B, 0x0C}, - {MAP_85_CS_SPIRAL_MOUNTAIN_3, 0x12, 0x0C}, - {MAP_86_CS_SPIRAL_MOUNTAIN_4, 0x0B, 0x0C}, - {MAP_87_CS_SPIRAL_MOUNTAIN_5, 0x12, 0x13}, - {MAP_88_CS_SPIRAL_MOUNTAIN_6, 0x12, 0x13}, - {MAP_94_CS_INTRO_SPIRAL_7, 0x12, 0x13}, - {MAP_95_CS_END_ALL_100, 0x12, 0x13}, - {MAP_98_CS_END_SPIRAL_MOUNTAIN_1, 0x12, 0x0A}, - {MAP_99_CS_END_SPIRAL_MOUNTAIN_2, 0x12, 0x0A}, - {MAP_7B_CS_INTRO_GL_DINGPOT_1, 0x0B, 0x0C}, - {MAP_81_CS_INTRO_GL_DINGPOT_2, 0x0B, 0x0C}, - {MAP_82_CS_ENTERING_GL_MACHINE_ROOM, 0x12, 0x0A}, - {MAP_83_CS_GAME_OVER_MACHINE_ROOM, 0x12, 0x13}, - {MAP_84_CS_UNUSED_MACHINE_ROOM, 0x12, 0x0C}, - {MAP_7C_CS_INTRO_BANJOS_HOUSE_1, 0x0B, 0x0C}, - {MAP_89_CS_INTRO_BANJOS_HOUSE_2, 0x0B, 0x0A}, - {MAP_8A_CS_INTRO_BANJOS_HOUSE_3, 0x01, 0x02}, - {MAP_96_CS_END_BEACH_1, 0x12, 0x13}, - {MAP_97_CS_END_BEACH_2, 0x08, 0x14}, - {0, 0x05, 0x06} +MapTransitionInfo D_8036C3F8[0x18] = { + {MAP_20_CS_END_NOT_100, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_1F_CS_START_RAREWARE, TRANSITION_ID_15_CIRCLE_OUT_SUPER_SLOW, TRANSITION_ID_9_WHITE_OUT}, + {MAP_1E_CS_START_NINTENDO, TRANSITION_ID_8_WHITE_IN, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_7D_CS_SPIRAL_MOUNTAIN_1, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_7E_CS_SPIRAL_MOUNTAIN_2, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_85_CS_SPIRAL_MOUNTAIN_3, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_86_CS_SPIRAL_MOUNTAIN_4, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_87_CS_SPIRAL_MOUNTAIN_5, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_88_CS_SPIRAL_MOUNTAIN_6, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_94_CS_INTRO_SPIRAL_7, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_95_CS_END_ALL_100, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_98_CS_END_SPIRAL_MOUNTAIN_1, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_A_WITCH_HEAD_OUT}, + {MAP_99_CS_END_SPIRAL_MOUNTAIN_2, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_A_WITCH_HEAD_OUT}, + {MAP_7B_CS_INTRO_GL_DINGPOT_1, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_81_CS_INTRO_GL_DINGPOT_2, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_82_CS_ENTERING_GL_MACHINE_ROOM, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_A_WITCH_HEAD_OUT}, + {MAP_83_CS_GAME_OVER_MACHINE_ROOM, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_84_CS_UNUSED_MACHINE_ROOM, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_7C_CS_INTRO_BANJOS_HOUSE_1, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_C_CIRCLE_OUT_FAST}, + {MAP_89_CS_INTRO_BANJOS_HOUSE_2, TRANSITION_ID_B_CIRCLE_IN_FAST, TRANSITION_ID_A_WITCH_HEAD_OUT}, + {MAP_8A_CS_INTRO_BANJOS_HOUSE_3, TRANSITION_ID_1_BLACK_IN, TRANSITION_ID_2_BLACK_OUT}, + {MAP_96_CS_END_BEACH_1, TRANSITION_ID_12_CIRCLE_IN_EXTRA_SLOW, TRANSITION_ID_13_CIRCLE_OUT_EXTRA_SLOW}, + {MAP_97_CS_END_BEACH_2, TRANSITION_ID_8_WHITE_IN, TRANSITION_ID_14_CIRCLE_IN_SUPER_SLOW}, + {0, TRANSITION_ID_5_JIGGY_IN, TRANSITION_ID_6_JIGGY_OUT} }; f32 D_8036C440 = 63.6026115f; f32 D_8036C444 = 500.0f; @@ -84,19 +136,19 @@ f32 D_8036C444 = 500.0f; /* .bss */ struct{ s32 unk0; //times drawn? - struct9s *unk4; - u8 unk8; //state - u8 pad9[3]; //not needed - void * unkC; //asset_ptr + TransitionInfo *transistion_info; + u8 state; + //u8 pad9[3]; //not needed + void * model_ptr; //asset_ptr f32 rotation; f32 timer; AnimCtrl *animctrl; - s32 unk1C; //times update called? -} D_80382430; + s32 substate; //times update called? +} s_current_transition; /* .code */ -struct9s *_gctranstion_8030B400(s32 arg0){ - struct9s * i; +TransitionInfo *_gctranstion_8030B400(s32 arg0){ + TransitionInfo * i; for(i = D_8036C150; i->uid != 0; i++){ if(i->uid == arg0) return i; @@ -104,8 +156,8 @@ struct9s *_gctranstion_8030B400(s32 arg0){ return NULL; } -struct10s *_gctranstion_8030B44C(s32 map_indx){ - struct10s * i; +MapTransitionInfo *_gctranstion_get_map_transition_info(s32 map_indx){ + MapTransitionInfo * i; for(i = D_8036C3F8; i->map_indx != 0; i++){ if(i->map_indx == map_indx) return i; @@ -113,54 +165,57 @@ struct10s *_gctranstion_8030B44C(s32 map_indx){ return i; } -void _gctranstion_changeState(s32 state, struct9s *arg1){ - if(D_80382430.unkC != NULL){ - func_8033BD20(&D_80382430.unkC); +void _gctranstion_changeState(s32 state, TransitionInfo *desc){ + if(s_current_transition.model_ptr != NULL){ + func_8033BD20(&s_current_transition.model_ptr); } - if(D_80382430.animctrl != NULL){ - animctrl_free(D_80382430.animctrl); - D_80382430.animctrl = NULL; + if(s_current_transition.animctrl != NULL){ + animctrl_free(s_current_transition.animctrl); + s_current_transition.animctrl = NULL; } - D_80382430.unk0 = 0; - D_80382430.unk4 = arg1; - D_80382430.unk8 = state; - D_80382430.timer = 0.0f; - if(state == 1) - D_80382430.unkC = assetcache_get(0x7D2); - else if(state == 6) - D_80382430.unkC = assetcache_get(0x7D3); - else if(arg1 != NULL && arg1->unk8 != 0) - D_80382430.unkC = assetcache_get(arg1->unk8); + s_current_transition.unk0 = 0; + s_current_transition.transistion_info = desc; + s_current_transition.state = state; + s_current_transition.timer = 0.0f; + + //Loading screen model?? + if(state == TRANSITION_STATE_1_LOADING) + s_current_transition.model_ptr = assetcache_get(0x7D2); //scene transition black + else if(state == TRANSITION_STATE_6_LOADING_WHITE) + s_current_transition.model_ptr = assetcache_get(0x7D3); //scene transition white + else if(desc != NULL && desc->model_index != 0) + s_current_transition.model_ptr = assetcache_get(desc->model_index); - if(arg1 != NULL && arg1->unkC != NULL){ - D_80382430.animctrl = animctrl_new(0); - animctrl_reset(D_80382430.animctrl); - animctrl_setIndex(D_80382430.animctrl, arg1->unkC); - animctrl_setDuration(D_80382430.animctrl, arg1->unk4); - animctrl_setPlaybackType(D_80382430.animctrl, ANIMCTRL_ONCE); - if(state == 5){ - animctrl_setDirection(D_80382430.animctrl, 0); + //load transistion animation + if(desc != NULL && desc->anim_index != NULL){ + s_current_transition.animctrl = animctrl_new(0); + animctrl_reset(s_current_transition.animctrl); + animctrl_setIndex(s_current_transition.animctrl, desc->anim_index); + animctrl_setDuration(s_current_transition.animctrl, desc->duration); + animctrl_setPlaybackType(s_current_transition.animctrl, ANIMCTRL_ONCE); + if(state == TRANSITION_STATE_5_FADE_OUT){ + animctrl_setDirection(s_current_transition.animctrl, 0); func_8028F7C8(1); //player_noControl(true) func_80335110(0); //objects_update(false) } else{ osViBlack(1); - animctrl_setAnimTimer(D_80382430.animctrl, 0.25f); //set animation timer + animctrl_setAnimTimer(s_current_transition.animctrl, 0.25f); //set animation timer } - animctrl_start(D_80382430.animctrl, "gctransition.c", 0x125); + animctrl_start(s_current_transition.animctrl, "gctransition.c", 0x125); } - if(state == 4){ + if(state == TRANSITION_STATE_4_FADE_IN){ if(func_802D4608()==0){ func_8025A70C(COMUSIC_4E_IN_TRANSITION); func_8025AC20(COMUSIC_4E_IN_TRANSITION, 0, 1000, 0.4f, "gctransition.c", 0x12d); func_8025AABC(COMUSIC_4E_IN_TRANSITION); } }//L8030B67C - else if(state == 5){ - if(D_80382430.unk4->uid == 0xA){ + else if(state == TRANSITION_STATE_5_FADE_OUT){ + if(s_current_transition.transistion_info->uid == 0xA){ func_8030E704(SFX_EB_GRUNTY_LAUGH_2); } else{ @@ -171,167 +226,178 @@ void _gctranstion_changeState(s32 state, struct9s *arg1){ } } } - else if(state == 0){ + else if(state == TRANSITION_STATE_0_NONE){ func_80335128(1); func_80335110(1); if(func_8028F070()) func_8028F7C8(0); } - D_80382430.unk1C = 0; + s_current_transition.substate = 0; } -void gctransition_8030B740(void){ - if(D_80382430.unkC != NULL) - D_80382430.unkC = defrag_asset(D_80382430.unkC); +void gctransition_defrag(void){ + if(s_current_transition.model_ptr != NULL) + s_current_transition.model_ptr = defrag_asset(s_current_transition.model_ptr); } void gctransition_draw(Gfx **gdl, Mtx **mptr, Vtx **vptr){ - f32 sp74[3]; - f32 sp68[3]; - f32 sp64; + f32 vp_position[3]; + f32 vp_rotation[3]; + f32 percentage; f32 sp58[3]; - f32 tmp; + f32 scale; - D_80382430.unk0++; - if(D_80382430.unk8 == 0) + s_current_transition.unk0++; + if(s_current_transition.state == 0) return; func_8024E258(); - if(D_80382430.animctrl != NULL){ - sp74[0] = 0.0f; - sp74[1] = 0.0f; - sp74[2] = 350.0f; + if(s_current_transition.animctrl != NULL){ + vp_position[0] = 0.0f; + vp_position[1] = 0.0f; + vp_position[2] = 350.0f; }else{ - sp74[0] = 0.0f; - sp74[1] = 0.0f; - sp74[2] = 300.0f; + vp_position[0] = 0.0f; + vp_position[1] = 0.0f; + vp_position[2] = 300.0f; } - sp68[0] = 0.0f; - sp68[1] = 0.0f; - sp68[2] = 0.0f; + vp_rotation[0] = 0.0f; + vp_rotation[1] = 0.0f; + vp_rotation[2] = 0.0f; func_8024CE60(D_8036C440, D_8036C444); - viewport_setPosition(sp74); //viewport_getPosition - viewport_setRotation(sp68); //viewport_getRotation + viewport_set_position_vec3f(vp_position); //viewport_get_position_vec3f + viewport_set_rotation_vec3f(vp_rotation); //viewport_get_rotation_vec3f viewport_update(); //camera_updateNormal func_8024C904(gdl, mptr); + sp58[0] = 0.0f; sp58[1] = 0.0f; sp58[2] = 0.0f; - if(D_80382430.animctrl != NULL){ + if(s_current_transition.animctrl != NULL){ gDPSetTextureFilter((*gdl)++, G_TF_POINT); gDPSetColorDither((*gdl)++, G_CD_DISABLE); - animctrl_drawSetup(D_80382430.animctrl, sp58, 1); + animctrl_drawSetup(s_current_transition.animctrl, sp58, 1); modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); } - if(D_80382430.unk8 == 1 || D_80382430.unk8 == 6){ - modelRender_draw(gdl, mptr, sp58, sp68, 1.0f, 0, D_80382430.unkC); - if(D_80382430.animctrl != NULL){ + + //complex animation (from animation bin file) + if(s_current_transition.state == 1 || s_current_transition.state == 6){ + modelRender_draw(gdl, mptr, sp58, vp_rotation, 1.0f, 0, s_current_transition.model_ptr); + if(s_current_transition.animctrl != NULL){ gDPSetTextureFilter((*gdl)++, G_TF_BILERP); gDPSetColorDither((*gdl)++, G_CD_MAGICSQ); } + return; } - else{ - sp64 = D_80382430.timer/(D_80382430.unk4->unk4); - if(D_80382430.unk8 == 4){ - if(D_80382430.unk4->uid == 0x10){ - tmp = D_80382430.unk4->unk10; - - } - else{ - sp68[2] = D_80382430.rotation - 90.0f*sp64; - tmp = sp64*D_80382430.unk4->unk10 + 0.1; - } - modelRender_draw(gdl, mptr, sp58, sp68, tmp, 0, D_80382430.unkC); + + percentage = s_current_transition.timer/(s_current_transition.transistion_info->duration); + if(s_current_transition.state == TRANSITION_STATE_4_FADE_IN){ + //rotate and zoom in + if(s_current_transition.transistion_info->uid == 0x10){ + scale = s_current_transition.transistion_info->scale; + } - else if(D_80382430.unk8 == 5){//L8030B9EC - switch (D_80382430.unk4->uid) - { + else{ + vp_rotation[2] = s_current_transition.rotation - 90.0f*percentage; + scale = percentage*s_current_transition.transistion_info->scale + 0.1; + } + modelRender_draw(gdl, mptr, sp58, vp_rotation, scale, 0, s_current_transition.model_ptr); + } + else if(s_current_transition.state == TRANSITION_STATE_5_FADE_OUT){//L8030B9EC + switch (s_current_transition.transistion_info->uid) + { default: - sp68[2] = D_80382430.rotation - 90.0f*sp64; - tmp = (1.0f - sp64)*D_80382430.unk4->unk10 + 0.1; + //rotate and zoom out + vp_rotation[2] = s_current_transition.rotation - 90.0f*percentage; + scale = (1.0f - percentage)*s_current_transition.transistion_info->scale + 0.1; break; case 0x11: - tmp = D_80382430.unk4->unk10; + //static + scale = s_current_transition.transistion_info->scale; break; case 0xA: - sp68[2] = 0.0f; - tmp = (1.0f - func_80257618())*D_80382430.unk4->unk10 + 0.1; + //zoom out only + vp_rotation[2] = 0.0f; + scale = (1.0f - func_80257618())*s_current_transition.transistion_info->scale + 0.1; break; - } - if(!(D_80382430.unk1C < 3) || D_80382430.unk4->uid != 0x11){ - modelRender_draw(gdl, mptr, sp58, sp68, tmp, 0, D_80382430.unkC); - } - else{ - modelRender_reset(); - } - } - else if(D_80382430.unk8 == 2){//L8030BAF4 - gcbound_reset(); - gcbound_alpha((1.0f - sp64)*255.0f + 0.5); - gcbound_color(0,0,0); - gcbound_draw(gdl); + if(!(s_current_transition.substate < 3) || s_current_transition.transistion_info->uid != 0x11){ + modelRender_draw(gdl, mptr, sp58, vp_rotation, scale, 0, s_current_transition.model_ptr); } - else if(D_80382430.unk8 == 3){//L8030BB6C - gcbound_reset(); - gcbound_alpha(sp64*255.0f + 0.5); - gcbound_color(0,0,0); - gcbound_draw(gdl); - } - else if(D_80382430.unk8 == 7){//L8030BBD8 - sp64 = (sp64 <= 0.5)? 1.0 : 1.0 - (sp64-0.5)/0.5; - gcbound_reset(); - gcbound_alpha(sp64*255.0f + 0.5); - gcbound_color(0xff,0xff,0xff); - gcbound_draw(gdl); - } - else if(D_80382430.unk8 == 8){//L8030BC8C - - gcbound_reset(); - gcbound_alpha(sp64*255.0f + 0.5); - gcbound_color(0xff,0xff,0xff); - gcbound_draw(gdl); - }//L8030BD00 else{ - + modelRender_reset(); } - if(D_80382430.animctrl != NULL){ - gDPSetTextureFilter((*gdl)++, G_TF_BILERP); - } - func_8024E2FC(); - func_8024C904(gdl, mptr); + } + else if(s_current_transition.state == TRANSITION_STATE_2_BLACK_IN){//L8030BAF4 + //fade in black (i.e. get less black) + gcbound_reset(); + gcbound_alpha((1.0f - percentage)*255.0f + 0.5); + gcbound_color(0,0,0); + gcbound_draw(gdl); + } + else if(s_current_transition.state == TRANSITION_STATE_3_BLACK_OUT){//L8030BB6C + //fade out black (i.e. get more black) + gcbound_reset(); + gcbound_alpha(percentage*255.0f + 0.5); + gcbound_color(0,0,0); + gcbound_draw(gdl); + } + else if(s_current_transition.state == TRANSITION_STATE_7_WHITE_IN){//L8030BBD8 + //fade in white (i.e. get less white) + percentage = (percentage <= 0.5)? 1.0 : 1.0 - (percentage-0.5)/0.5; + gcbound_reset(); + gcbound_alpha(percentage*255.0f + 0.5); + gcbound_color(0xff,0xff,0xff); + gcbound_draw(gdl); + } + else if(s_current_transition.state == TRANSITION_STATE_8_WHITE_OUT){//L8030BC8C + //fade out white (i.e. get more white) + gcbound_reset(); + gcbound_alpha(percentage*255.0f + 0.5); + gcbound_color(0xff,0xff,0xff); + gcbound_draw(gdl); + }//L8030BD00 + else{ + + } + if(s_current_transition.animctrl != NULL){ + gDPSetTextureFilter((*gdl)++, G_TF_BILERP); + } + func_8024E2FC(); + func_8024C904(gdl, mptr); + } void gctransition_8030BD4C(void){ - struct10s *tmp_10s; - struct9s *tmp_a1; - tmp_10s = _gctranstion_8030B44C(map_get()); - tmp_a1 = _gctranstion_8030B400(tmp_10s->unk1); - _gctranstion_changeState(tmp_a1->unk1, tmp_a1); + MapTransitionInfo *tmp_10s; + TransitionInfo *tmp_a1; + tmp_10s = _gctranstion_get_map_transition_info(map_get()); + tmp_a1 = _gctranstion_8030B400(tmp_10s->in_index); + _gctranstion_changeState(tmp_a1->state, tmp_a1); } f32 gctransition_8030BD88(void){ return 300.0f; } -int gctransition_8030BD98(void){ - return D_80382430.unk8 == 0; +int gctransition_done(void){ + return s_current_transition.state == TRANSITION_STATE_0_NONE; } -int gctransition_8030BDAC(void){ - return D_80382430.unk8 != 0; +int gctransition_active(void){ + return s_current_transition.state != TRANSITION_STATE_0_NONE; } int gctransition_8030BDC0(void){ - return ( D_80382430.unk8 == 0x3) - || (( D_80382430.unk8 == 1) && (D_80382430.unk0 < 2)) - || ( D_80382430.unk8 == 5) - || ( D_80382430.unk8 == 8) - || (( D_80382430.unk8 == 6) && (D_80382430.unk0 < 2)); + return ( s_current_transition.state == TRANSITION_STATE_3_BLACK_OUT) + || (( s_current_transition.state == TRANSITION_STATE_1_LOADING) && (s_current_transition.unk0 < 2)) + || ( s_current_transition.state == TRANSITION_STATE_5_FADE_OUT) + || ( s_current_transition.state == TRANSITION_STATE_8_WHITE_OUT) + || (( s_current_transition.state == TRANSITION_STATE_6_LOADING_WHITE) && (s_current_transition.unk0 < 2)); } void gctransition_8030BE3C(void){ @@ -339,37 +405,37 @@ void gctransition_8030BE3C(void){ } void gctransition_8030BE60(void){ - struct9s *tmp_a1; - tmp_a1 = _gctranstion_8030B400(_gctranstion_8030B44C(map_get())->unk2); + TransitionInfo *tmp_a1; + tmp_a1 = _gctranstion_8030B400(_gctranstion_get_map_transition_info(map_get())->out_index); func_8030C180(); - _gctranstion_changeState(tmp_a1->unk1, tmp_a1); + _gctranstion_changeState(tmp_a1->state, tmp_a1); } void gctransition_8030BEA4(s32 arg0){ - _gctranstion_changeState(D_8036C308[arg0].unk1, &D_8036C308[arg0]); + _gctranstion_changeState(D_8036C308[arg0].state, &D_8036C308[arg0]); } void gctransition_reset(void){ - D_80382430.unk4 = NULL; - D_80382430.unk8 = 0; - D_80382430.unkC = NULL; - D_80382430.rotation = 0.0f; + s_current_transition.transistion_info = NULL; + s_current_transition.state = TRANSITION_STATE_0_NONE; + s_current_transition.model_ptr = NULL; + s_current_transition.rotation = 0.0f; _gctranstion_changeState(0,0); } void gctransition_update(void){ - f32 sp24; + f32 dt; f32 tmp; - sp24 = time_getDelta(); - if(D_80382430.unk4 == NULL) + dt = time_getDelta(); + if(s_current_transition.transistion_info == NULL) return; - if(D_80382430.animctrl != NULL){ - animctrl_update(D_80382430.animctrl); - if(D_80382430.unk8 == 4){ - switch(D_80382430.unk1C){ + if(s_current_transition.animctrl != NULL){ + animctrl_update(s_current_transition.animctrl); + if(s_current_transition.state == TRANSITION_STATE_4_FADE_IN){ + switch(s_current_transition.substate){ case 0: break; case 1: @@ -380,27 +446,27 @@ void gctransition_update(void){ func_80335128(0); break; case 3: - func_802FEF48(D_80382430.unkC); //framebuffer to model texture list + func_802FEF48(s_current_transition.model_ptr); //framebuffer to model texture list break; case 4: osViBlack(0); break; default: - D_80382430.timer += sp24; + s_current_transition.timer += dt; break; } } else{//L8030BFEC - switch(D_80382430.unk1C){ + switch(s_current_transition.substate){ default: - D_80382430.timer += sp24; + s_current_transition.timer += dt; break; case 0: case 1: break; case 2: func_80335128(0); - func_802FEF48(D_80382430.unkC); //framebuffer to model texture list + func_802FEF48(s_current_transition.model_ptr); //framebuffer to model texture list break; } @@ -408,25 +474,26 @@ void gctransition_update(void){ } } else{//L8030C034 - D_80382430.timer += sp24; + s_current_transition.timer += dt; } - if(D_80382430.unk4->unk4 < D_80382430.timer - || (D_80382430.animctrl!= NULL && animctrl_isStopped(D_80382430.animctrl)) + if(s_current_transition.transistion_info->duration < s_current_transition.timer + || (s_current_transition.animctrl!= NULL && animctrl_isStopped(s_current_transition.animctrl)) ){ - D_80382430.timer = D_80382430.unk4->unk4; - if(D_80382430.unk8 == 4 || D_80382430.unk8 == 5){ - D_80382430.rotation -= 90.0f; - if (D_80382430.rotation < -360.0f) - D_80382430.rotation += 360.0f; - if (360.0f < D_80382430.rotation) - D_80382430.rotation -= 360.0f; + s_current_transition.timer = s_current_transition.transistion_info->duration; + //update next transition rotation + if(s_current_transition.state == TRANSITION_STATE_4_FADE_IN || s_current_transition.state == TRANSITION_STATE_5_FADE_OUT){ + s_current_transition.rotation -= 90.0f; + if (s_current_transition.rotation < -360.0f) + s_current_transition.rotation += 360.0f; + if (360.0f < s_current_transition.rotation) + s_current_transition.rotation -= 360.0f; }//L8030C104 - _gctranstion_changeState(D_80382430.unk4->unk2, 0); - if(D_80382430.unk8 == 4) + _gctranstion_changeState(s_current_transition.transistion_info->next_state, 0); + if(s_current_transition.state == TRANSITION_STATE_4_FADE_IN) func_8030C180(); - if(D_80382430.animctrl != NULL) + if(s_current_transition.animctrl != NULL) func_80334ECC(); } - D_80382430.unk1C++; + s_current_transition.substate++; } diff --git a/src/core2/levelspecificflags.c b/src/core2/levelspecificflags.c index 08861c7b..c70ae807 100644 --- a/src/core2/levelspecificflags.c +++ b/src/core2/levelspecificflags.c @@ -61,11 +61,11 @@ void _levelSpecificFlags_updateCRC2(void) { } s32 levelSpecificFlags_get(s32 i){ - return func_803200A4(D_80383320.unk8, i); + return bitfield_get_bit(D_80383320.unk8, i); } s32 levelSpecificFlags_getN(s32 i, s32 n){ - return func_803200E4(D_80383320.unk8, i, n); + return bitfield_get_n_bits(D_80383320.unk8, i, n); } s32 levelSpecificFlags_getSet(s32 arg0, s32 arg1){ diff --git a/src/core2/mapModel.c b/src/core2/mapModel.c index 1e447f8e..65954c2a 100644 --- a/src/core2/mapModel.c +++ b/src/core2/mapModel.c @@ -498,7 +498,7 @@ BKCollisionTri *func_80309C74(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 flagFil } bool func_80309D58(f32 arg0[3], UNK_TYPE(s32) arg1) { - BKMeshList *temp_v0; + BKModelUnk14List *temp_v0; temp_v0 = func_8033A12C(mapModel.model_bin_opa); if (temp_v0 != NULL) { diff --git a/src/core2/modelRender.c b/src/core2/modelRender.c index e63f98f4..df2dd9b5 100644 --- a/src/core2/modelRender.c +++ b/src/core2/modelRender.c @@ -9,15 +9,15 @@ extern bool func_802ED420(BKModelUnk20List *arg0, u8 *arg1, u32 arg2); extern void func_802ED52C(BKModelUnk20List *, f32[3], f32); extern void func_80252AF0(f32[3], f32[3], f32[3], f32, f32[3]); -extern void mlMtxRotate(f32, f32, f32); -extern void viewport_getPosition(f32[3]); -extern void viewport_getRotation(f32[3]); -extern void viewport_setPosition(f32[3]); -extern void viewport_setRotation(f32[3]); +extern void mlMtxRotatePYR(f32, f32, f32); +extern void viewport_get_position_vec3f(f32[3]); +extern void viewport_get_rotation_vec3f(f32[3]); +extern void viewport_set_position_vec3f(f32[3]); +extern void viewport_set_rotation_vec3f(f32[3]); extern void viewport_update(void); extern void func_8033BD4C(BKModelBin *); extern s32 func_8024DB50(f32[3], f32); -extern void func_80251788(f32, f32, f32); +extern void mlMtx_push_translation(f32, f32, f32); extern void mlMtxScale(f32); extern void mlMtxApply(Mtx* mtx); extern AnimMtxList *animMtxList_new(); @@ -696,8 +696,8 @@ void modelRender_reset(void){ func_8033A45C(1,1); func_8033A45C(2,0); if(D_80383758.unk18){ - viewport_setPosition(D_80383758.unk1C); - viewport_setRotation(D_80383758.unk28); + viewport_set_position_vec3f(D_80383758.unk1C); + viewport_set_rotation_vec3f(D_80383758.unk28); viewport_update(); } } @@ -714,7 +714,7 @@ void func_803384A8(Gfx **gfx, Mtx **mtx, void *arg2){ if(cmd->unk8){ func_8025235C(sp30, cmd->unkC); - func_80251788(sp30[0], sp30[1], sp30[2]); + mlMtx_push_translation(sp30[0], sp30[1], sp30[2]); mlMtxRotYaw(modelRenderCameraRotation[1]); if(!cmd->unkA){ mlMtxRotPitch(modelRenderCameraRotation[0]); @@ -795,7 +795,7 @@ void func_803387F8(Gfx **gfx, Mtx **mtx, void *arg2){ GeoCmd2 *cmd = (GeoCmd2 *)arg2; if(D_8038371C){ - func_802519C8(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unk9)); + mlMtx_push_multiplied_2(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unk9)); if(D_80370990){ mlMtxApply(*mtx); gSPMatrix((*gfx)++, (*mtx)++, G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -875,7 +875,7 @@ void func_80338BFC(Gfx **gfx, Mtx **mtx, void *arg2){ if(D_80383650){ if(D_8038371C){ - func_802519C8(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unkA)); + mlMtx_push_multiplied_2(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unkA)); func_8025235C(sp20, cmd->unkC); mlMtxPop(); } @@ -970,7 +970,7 @@ void func_80338EB8(Gfx ** gfx, Mtx ** mtx, void *arg2){ sp30 = (f32)cmd->unkE*modelRenderScale; if(D_8038371C){ - func_802519C8(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unk12)); + mlMtx_push_multiplied_2(&D_80383BF8, animMtxList_get(D_8038371C, cmd->unk12)); func_8025235C(sp34, sp34); mlMtxPop(); } @@ -1034,8 +1034,8 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 rotation } D_80370990 = 0; - viewport_getPosition(modelRenderCameraPosition); - viewport_getRotation(modelRenderCameraRotation); + viewport_get_position_vec3f(modelRenderCameraPosition); + viewport_get_rotation_vec3f(modelRenderCameraRotation); if(D_80383758.unk18){ D_80383758.unk1C[0] = modelRenderCameraPosition[0]; D_80383758.unk1C[1] = modelRenderCameraPosition[1]; @@ -1075,8 +1075,8 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 rotation modelRenderCameraRotation[0] = D_80383758.unkC[0], modelRenderCameraRotation[1] = D_80383758.unkC[1], modelRenderCameraRotation[2] = D_80383758.unkC[2]; - viewport_setPosition(modelRenderCameraPosition); - viewport_setRotation(modelRenderCameraRotation); + viewport_set_position_vec3f(modelRenderCameraPosition); + viewport_set_rotation_vec3f(modelRenderCameraRotation); viewport_update(); camera_focus[0] = object_position[0] - modelRenderCameraPosition[0]; camera_focus[1] = object_position[1] - modelRenderCameraPosition[1]; @@ -1264,7 +1264,7 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 rotation } if(D_803837B0.unk0){ - mlMtxRotate(D_803837B0.unk4[0], D_803837B0.unk4[1], D_803837B0.unk4[2]); + mlMtxRotatePYR(D_803837B0.unk4[0], D_803837B0.unk4[1], D_803837B0.unk4[2]); } mlMtxGet(&D_80383BF8); @@ -1420,8 +1420,8 @@ void func_8033A28C(bool arg0){ void func_8033A298(bool arg0){ D_80383758.unk18 = arg0; if(arg0){ - viewport_getPosition(D_80383758.unk0); - viewport_getRotation(D_80383758.unkC); + viewport_get_position_vec3f(D_80383758.unk0); + viewport_get_rotation_vec3f(D_80383758.unkC); } } diff --git a/src/core2/nc/dynamicCamF.c b/src/core2/nc/dynamicCamF.c index df6c7be3..52453811 100644 --- a/src/core2/nc/dynamicCamF.c +++ b/src/core2/nc/dynamicCamF.c @@ -7,8 +7,8 @@ void ncDynamicCamF_init(void){ f32 sp24[3]; f32 sp12[3]; - viewport_getPosition(sp24); - viewport_getRotation(sp12); + viewport_get_position_vec3f(sp24); + viewport_get_rotation_vec3f(sp12); ncDynamicCamera_setPosition(sp24); ncDynamicCamera_setRotation(sp12); player_getPosition(__playerStartPosition); diff --git a/src/core2/nc/dynamicCamera.c b/src/core2/nc/dynamicCamera.c index 85c4120d..af64857f 100644 --- a/src/core2/nc/dynamicCamera.c +++ b/src/core2/nc/dynamicCamera.c @@ -212,8 +212,8 @@ void func_802BCBD4(void) { func_802C0120(); func_802C2258(); func_802C0F4C(); - viewport_getRotation(cameraRotation); - viewport_getPosition(cameraPosition); + viewport_get_rotation_vec3f(cameraRotation); + viewport_get_position_vec3f(cameraPosition); ml_vec3f_copy(D_8037D948, cameraPosition); ml_vec3f_clear(D_8037D9C8); ml_vec3f_clear(D_8037D9E0); @@ -366,8 +366,8 @@ void ncDynamicCamera_update(void){ if(dynamicCameraInFirstPerson){ ncFirstPersonCamera_getPositionAndRotation(sp24, sp18); } - viewport_setPosition(sp24); - viewport_setRotation(sp18); + viewport_set_position_vec3f(sp24); + viewport_set_rotation_vec3f(sp18); } int ncDynamicCamera_getState(void){ @@ -940,8 +940,8 @@ void func_802BE720(void){ f32 sp28[3]; f32 sp1C[3]; - viewport_getPosition(sp28); - viewport_getRotation(sp1C); + viewport_get_position_vec3f(sp28); + viewport_get_rotation_vec3f(sp1C); ncDynamicCamera_setPosition(sp28); ncDynamicCamera_setRotation(sp1C); @@ -961,8 +961,8 @@ void func_802BE794(void){ sp2C[1] += 100.0f; player_getRotation(sp20); sp20[1] = mlNormalizeAngle(sp20[1] + 180.0f); - viewport_setPosition(sp2C); - viewport_setRotation(sp20); + viewport_set_position_vec3f(sp2C); + viewport_set_rotation_vec3f(sp20); func_8024C510(300.0f); func_802BE720(); }//L802BE828 diff --git a/src/core2/nc/randomCamera.c b/src/core2/nc/randomCamera.c index 19df9e44..1cfdeaea 100644 --- a/src/core2/nc/randomCamera.c +++ b/src/core2/nc/randomCamera.c @@ -15,8 +15,8 @@ void ncRandomCamera_init(void) { s32 sp24[3]; s32 sp18[3]; - viewport_getPosition(D_8037DA50.storedPosition); - viewport_getRotation(D_8037DA50.storedRotation); + viewport_get_position_vec3f(D_8037DA50.storedPosition); + viewport_get_rotation_vec3f(D_8037DA50.storedRotation); mapModel_getBounds(sp24, sp18); D_8037DA50.minPosition[0] = (f32) sp24[0]; @@ -30,8 +30,8 @@ void ncRandomCamera_init(void) { void ncRandomCamera_end(void){ - viewport_setPosition(D_8037DA50.storedPosition); - viewport_setRotation(D_8037DA50.storedRotation); + viewport_set_position_vec3f(D_8037DA50.storedPosition); + viewport_set_rotation_vec3f(D_8037DA50.storedRotation); } void ncRandomCamera_update(void) { @@ -45,6 +45,6 @@ void ncRandomCamera_update(void) { sp18[0] = randf2(-90.0f, 90.0f);\ sp18[1] = randf2(0.0f, 360.0f);\ sp18[2] = 0.0f; - viewport_setPosition(sp24); - viewport_setRotation(sp18); + viewport_set_position_vec3f(sp24); + viewport_set_rotation_vec3f(sp18); } diff --git a/src/core2/nc/staticCamera.c b/src/core2/nc/staticCamera.c index 574e22dc..e6a09f0e 100644 --- a/src/core2/nc/staticCamera.c +++ b/src/core2/nc/staticCamera.c @@ -33,8 +33,8 @@ void ncStaticCamera_setPosition(f32 arg0[3]){ } void ncStaticCamera_update(void){ - viewport_setPosition(ncStaticCameraPosition); - viewport_setRotation(ncStaticCameraRotation); + viewport_set_position_vec3f(ncStaticCameraPosition); + viewport_set_rotation_vec3f(ncStaticCameraRotation); } void __ncStaticCamera_setToNode(s32 camera_node_index){ diff --git a/src/core2/quizquestionaskedbitfield.c b/src/core2/quizquestionaskedbitfield.c index 14afb931..12fcdc41 100644 --- a/src/core2/quizquestionaskedbitfield.c +++ b/src/core2/quizquestionaskedbitfield.c @@ -9,7 +9,7 @@ u8* quizQuestionAskedBitfield; /* .code */ bool quizQuestionAskedBitfield_get(s32 index){ - return func_803200A4(quizQuestionAskedBitfield, index); + return bitfield_get_bit(quizQuestionAskedBitfield, index); } void quizQuestionAskedBitfield_free(void){ diff --git a/src/cutscenes/bss_pad.c b/src/cutscenes/bss_pad.c index 460ab074..e704b74e 100644 --- a/src/cutscenes/bss_pad.c +++ b/src/cutscenes/bss_pad.c @@ -1 +1 @@ -char pad_cutscenes_8038E9E0[0x10]; \ No newline at end of file +char pad_cutscenes_8038E9E0[0x10]; diff --git a/src/fight/chbossjinjo.c b/src/fight/chbossjinjo.c index 717c9549..1a7474ac 100644 --- a/src/fight/chbossjinjo.c +++ b/src/fight/chbossjinjo.c @@ -4,7 +4,7 @@ #include "core2/particle.h" -extern void viewport_getPosition(f32 (*)[3]); +extern void viewport_get_position_vec3f(f32 (*)[3]); extern void subaddie_set_state_with_direction(Actor *, s32, f32, s32); extern void func_80386654(f32 arg0, f32 (*arg1)[4], f32 (*arg2)[4]); extern void func_80324CFC(f32, enum comusic_e, s32); @@ -324,7 +324,7 @@ void func_8038CED8(f32 arg0[3], enum asset_e model_id, f32 arg2, f32 arg3){ f32 sp40[3]; f32 sp34[3]; - viewport_getPosition(&sp40); + viewport_get_position_vec3f(&sp40); sp34[0] = sp40[0] - arg0[0]; sp34[1] = sp40[1] - arg0[1]; diff --git a/symbol_addrs.us.v10.txt b/symbol_addrs.us.v10.txt index 1f655e20..6144285e 100644 --- a/symbol_addrs.us.v10.txt +++ b/symbol_addrs.us.v10.txt @@ -89,7 +89,7 @@ mapSavestate_apply = 0x802E30AC; getGameMode = 0x802E49FC; vtxList_getVertices = 0x802EC450; cube_atIndices = 0x80303384; -gctransition_8030BD98 = 0x8030BD98; +gctransition_done = 0x8030BD98; gcdialog_setState = 0x8030F488; gcdialog_update = 0x8030F990; gczoombox_update = 0x80316EF4;