diff --git a/decompressed.us.v10.yaml b/decompressed.us.v10.yaml index 5ccb9ce9..360df1ea 100644 --- a/decompressed.us.v10.yaml +++ b/decompressed.us.v10.yaml @@ -721,7 +721,7 @@ segments: - [0xFBAE20, c, code_654C0] #DONE - [0xFBBDF0, c, code_66490] #DONE - [0xFBBFF0, c, vla] #DONE - - [0xFBC410, c, sla] #DONE + - [0xFBC410, c, fla] #DONE - [0xFBC6F0, c, code_66D90] #DONE - [0xFBC910, c, code_66FB0] #DONE - [0xFBCDF0, c, gc/bound] #DONE @@ -834,7 +834,7 @@ segments: - [0x10164E0, c, code_C0B80] #DONE - [0x1016650, c, code_C0CF0] #DONE - [0x10167C0, c, code_C0E60] #DONE - - [0x1018580, c, code_C2C20] #DONE + - [0x1018580, c, animtexturecache] #DONE - [0x1018890, c, code_C2F30] #DONE - [0x1018B00, c, code_C31A0] #DONE - [0x1018D60, c, rand] #DONE @@ -1606,7 +1606,7 @@ segments: - [0x1048560, .bss, code_BDCC0] - [0x1048560, .bss, code_BEF20] - [0x1048560, .bss, code_C0E60] - - [0x1048560, .bss, code_C2C20] + - [0x1048560, .bss, animtexturecache] - [0x1048560, .bss, code_C2F30] - [0x1048560, .bss, rand] - [0x1048560, .bss, code_C4320] diff --git a/include/model.h b/include/model.h index 7b72428f..f2bc6758 100644 --- a/include/model.h +++ b/include/model.h @@ -36,9 +36,9 @@ typedef struct { s16 minCoord[3]; s16 maxCoord[3]; s16 centerCoord[3]; - s16 unk12; + s16 local_norm; //(distance to furthest vtx relative to model center) s16 count; - s16 unk16; + s16 global_norm; //(distance to furthest vtx relative to model origin) Vtx vtx_18[]; } BKVertexList; @@ -167,10 +167,15 @@ typedef struct{ //BKModelUnk28_0[] }BKModelUnk28List; + + typedef struct{ - u8 pad0[1]; - //BKModelUnk20_0[] -}BKModelUnk2C; + s16 frame_size; + s16 frame_cnt; + f32 frame_rate; +}AnimTexture; + + typedef struct { BKMeshList *meshList_0; @@ -190,10 +195,10 @@ typedef struct{ s32 unk20; s32 effects_list_setup_24; s32 unk28; - s32 unk2C; + s32 animated_texture_list_offset; //AnimTexture[4] }BKModelBin; -BKVertexList *func_8033A148(BKModelBin *arg0); +BKVertexList *model_getVtxList(BKModelBin *arg0); Vtx *vtxList_getVertices(BKVertexList *vtxList); void func_80333D48(BKVertexList *arg0, f32 position[3], f32 rotation[3], f32 scale, f32 arg4[3], BKVertexList *arg5); #endif diff --git a/include/structs.h b/include/structs.h index 4c0c97ac..09397920 100644 --- a/include/structs.h +++ b/include/structs.h @@ -48,13 +48,13 @@ typedef struct variable_length_array{ #define vector(T) struct variable_length_array //^defined to keep element type with vla -typedef struct static_length_array{ +typedef struct freelist_s{ s16 elem_size; s16 elem_cnt; u8 unk4[]; -}SLA; +}FLA; -#define array(T) struct static_length_array +#define FREE_LIST(T) struct freelist_s //^defined to keep element type with sla typedef struct bk_sprite_s{ @@ -108,7 +108,7 @@ typedef struct model_cache_s{ BKModelBin * modelPtr; BKSprite * unk4; BKSpriteDisplayData *unk8; - u32 unkC; + u32 animated_texture_cache_id; u32 unk10; } ModelCache; @@ -283,7 +283,7 @@ typedef struct struct_11_s{ u8 unk14; u8 unk15; u8 pad16[0x2]; - array(struct12s) *unk18; + FREE_LIST(struct12s) *unk18; s32 unk1C[0xE]; } CoMusic; diff --git a/src/CC/code_1F70.c b/src/CC/code_1F70.c index 6d6daf2a..14bee610 100644 --- a/src/CC/code_1F70.c +++ b/src/CC/code_1F70.c @@ -252,9 +252,9 @@ void func_80388CB4(void){ func_8030DA44(D_80389FA0.unk4); func_80340690(D_80389FA0.unk18); func_8034A2A8(D_80389FA0.unk34); - if(func_8033A148(D_80389FA0.unk24) != D_80389FA0.unk40) + if(model_getVtxList(D_80389FA0.unk24) != D_80389FA0.unk40) vtxList_free(D_80389FA0.unk40); - if(func_8033A148(D_80389FA0.unk24) != D_80389FA0.unk44) + if(model_getVtxList(D_80389FA0.unk24) != D_80389FA0.unk44) vtxList_free(D_80389FA0.unk44); assetcache_release((void *)D_80389FA0.unk24); D_80389FA0.unk34 = NULL; @@ -272,10 +272,10 @@ void func_80388D54(void){ D_80389FA0.unk18 = func_803406B0(); D_80389FA0.unk21 = 0; D_80389FA0.unk24 = assetcache_get(ASSET_88E_MODEL_CLANKER_CHAIN); - D_80389FA0.unk1C = func_8033A084(D_80389FA0.unk24); + D_80389FA0.unk1C = model_getCollisionList(D_80389FA0.unk24); D_80389FA0.unk34 = func_8034A2C8(); D_80389FA0.unk3C = 1.0f; - D_80389FA0.unk40 = func_8033A148(D_80389FA0.unk24); + D_80389FA0.unk40 = model_getVtxList(D_80389FA0.unk24); D_80389FA0.unk44 = vtxList_clone(D_80389FA0.unk40); D_80389FA0.unk48 = 0; D_80389FA0.unk49 = 0; diff --git a/src/RBB/ch/whistleswitch.c b/src/RBB/ch/whistleswitch.c index cc89ef8c..04244c29 100644 --- a/src/RBB/ch/whistleswitch.c +++ b/src/RBB/ch/whistleswitch.c @@ -69,7 +69,7 @@ void func_8038AC18(Actor *this, s32 new_state){ local->unk8 = 0.0f; if(new_state == 2){ func_8030E6D4(SFX_90_SWITCH_PRESS); - local->unkC = vtxList_clone(func_8033A148(func_80330B1C(this->marker))); + local->unkC = vtxList_clone(model_getVtxList(func_80330B1C(this->marker))); mapSpecificFlags_set(local->unk4->unk10, TRUE); this->position_y -= 30.0f; @@ -117,7 +117,7 @@ Actor *func_8038AD9C(ActorMarker *marker, Gfx **gdl, Mtx **mptr, s32 arg3){ sp1C = (local->unk0 == 2) ? &D_80390938 : &D_8039092C; vtxList_tint(local->unkC, sp1C, (local->unk4->unk4[1] - actor->position_y)/30.0, - func_8033A148(temp_v0) + model_getVtxList(temp_v0) ); modelRender_setVertexList(local->unkC); } diff --git a/src/core1/code_1BE90.c b/src/core1/code_1BE90.c index b8338904..98a0b648 100644 --- a/src/core1/code_1BE90.c +++ b/src/core1/code_1BE90.c @@ -13,11 +13,11 @@ void func_8024FD28(u8, s32); void func_8024FC1C(u8, s32); void func_8025AC20(enum comusic_e, s32, s32, f32, char*, s32); void func_8025AC7C(enum comusic_e, s32, s32, f32, s32, char*, s32); -void func_80259B14(void); +void comusicPlayer_free(void); void func_8025A55C(s32, s32, s32); void func_8025A7DC(enum comusic_e); void func_8025ABB8(enum comusic_e, s32, s32, s32); -void *func_802EDAA4(SLA **, s32*); +void *freelist_next(FLA **, s32*); /* .bss */ CoMusic *D_80276E30 = NULL; //active track ptr @@ -47,11 +47,11 @@ void func_80259914(CoMusic *this, s32 arg1, s32 arg2){ s32 i; struct12s *tmp; - array_clear(this->unk18); + freelist_clear(this->unk18); for(i = 0; i < 0xE; i++){ this->unk1C[i] = 0; } - tmp = (struct12s *)func_802EDAA4(&this->unk18, &sp2C); + tmp = (struct12s *)freelist_next(&this->unk18, &sp2C); tmp->unk0 = arg1; tmp->unk1 = arg2; } @@ -68,12 +68,12 @@ void func_802599B4(CoMusic *this){ func_8024FC1C(this - D_80276E30, -1); } -void func_80259A24(void){ +void comusicPlayer_init(void){ CoMusic * iPtr; s32 i; if(D_80276E30 != NULL) - func_80259B14(); + comusicPlayer_free(); D_80276E30 = (CoMusic *) malloc(6*sizeof(CoMusic)); for(iPtr = D_80276E30; iPtr < D_80276E30 + 6; iPtr++){ @@ -85,7 +85,7 @@ void func_80259A24(void){ iPtr->unk14 = 0; iPtr->unk15 = 0; iPtr->unk0 = 0.0f; - iPtr->unk18 = array_new(sizeof(struct12s),4); + iPtr->unk18 = freelist_new(sizeof(struct12s),4); for(i = 0; i < 0xE; i++){ iPtr->unk1C[i] = 0; } @@ -93,13 +93,13 @@ void func_80259A24(void){ } //comusic_freeAll -void func_80259B14(void){ +void comusicPlayer_free(void){ CoMusic *iPtr; func_8024FB8C(); func_8024F83C(); for(iPtr = D_80276E30; iPtr < D_80276E30 + 6; iPtr++){ - array_free(iPtr->unk18); + freelist_free(iPtr->unk18); } free(D_80276E30); D_80276E30 = NULL; @@ -116,17 +116,17 @@ s32 func_80259B8C(void){ return cnt; } -void func_80259BD0(void) { +void comusicPlayer_update(void) { s32 temp_lo; CoMusic *var_s0; - f32 sp3C; + f32 dt; - sp3C = time_getDelta(); + dt = time_getDelta(); for(var_s0 = D_80276E30; var_s0 < &D_80276E30[6]; var_s0++){ if (var_s0->unk10 >= 0) { temp_lo = var_s0 - D_80276E30; - var_s0->unk4 = ml_min_f(var_s0->unk4 + sp3C, 600.0f); + var_s0->unk4 = ml_min_f(var_s0->unk4 + dt, 600.0f); if ((var_s0->unk4 > 1.0f) && func_80250074(temp_lo)) { func_8025A7DC(var_s0->unk10); } @@ -180,14 +180,14 @@ void func_80259BD0(void) { void func_80259EA8(CoMusic *this, s32 *arg1, s32 *arg2){ int i; - int cnt = array_size(this->unk18); + int cnt = freelist_size(this->unk18); s32 tmp_s1 = 0x7FFF; s32 tmp_s2 = 0x40000000; struct12s *tmp_ptr; for(i = 1; i < cnt; i++){ - if(func_802EDC18(this->unk18, i)){ - tmp_ptr = (struct12s*)array_at(this->unk18, i); + if(freelist_elementIsAlive(this->unk18, i)){ + tmp_ptr = (struct12s*)freelist_at(this->unk18, i); if(tmp_ptr->unk0 < tmp_s1 || (tmp_s1 == tmp_ptr->unk0 && tmp_ptr->unk1 < tmp_s2)){ tmp_s1 = tmp_ptr->unk0; tmp_s2 = tmp_ptr->unk1; @@ -206,12 +206,12 @@ void func_80259F7C(CoMusic *self, s32 *arg1, s32 *arg2, s32 *arg3) { var_s2 = *arg1; sp34 = *arg2; - if ((*arg3 != 0) && !func_802EDC18(self->unk18, *arg3)) { + if ((*arg3 != 0) && !freelist_elementIsAlive(self->unk18, *arg3)) { *arg3 = 0; } if (var_s2 < 0) { - temp_v0 = (struct12s *)array_at(self->unk18, 1); + temp_v0 = (struct12s *)freelist_at(self->unk18, 1); if (temp_v0->unk0 < func_80250034(self->unk10)) { var_s2 = func_80250034(self->unk10); } @@ -219,9 +219,9 @@ void func_80259F7C(CoMusic *self, s32 *arg1, s32 *arg2, s32 *arg3) { var_s2 = temp_v0->unk0; } if (*arg3 != 0) { - temp_v0 = (struct12s *)array_at(self->unk18, *arg3); + temp_v0 = (struct12s *)freelist_at(self->unk18, *arg3); *arg2 = temp_v0->unk1; - func_802EDCDC(self->unk18, *arg3); + freelist_freeElement(self->unk18, *arg3); *arg3 = 0; func_80259EA8(self, arg1, &sp34); return; @@ -229,15 +229,15 @@ void func_80259F7C(CoMusic *self, s32 *arg1, s32 *arg2, s32 *arg3) { } if (*arg3 == 0) { - temp_v0 = (struct12s *)array_at(self->unk18, 1); + temp_v0 = (struct12s *)freelist_at(self->unk18, 1); if ((temp_v0->unk0 < var_s2) || ((var_s2 == temp_v0->unk0) && (sp34 >= temp_v0->unk1))) { func_80259914(self, var_s2, sp34); } else { - func_802EDAA4(&self->unk18, arg3); + freelist_next(&self->unk18, arg3); } } if (*arg3 != 0) { - temp_v0 = (struct12s *)array_at(self->unk18, *arg3); + temp_v0 = (struct12s *)freelist_at(self->unk18, *arg3); temp_v0->unk0 = var_s2; temp_v0->unk1 = sp34; } @@ -622,7 +622,7 @@ void func_8025AF38(void){ if(!D_80276E30) return; for(iPtr = &D_80276E30[0]; iPtr < &D_80276E30[6]; iPtr++){ - iPtr->unk18 = array_defrag(iPtr->unk18); + iPtr->unk18 = freelist_defrag(iPtr->unk18); } D_80276E30 = (CoMusic *)defrag(D_80276E30); } diff --git a/src/core2/animtexturecache.c b/src/core2/animtexturecache.c new file mode 100644 index 00000000..11f0ea6c --- /dev/null +++ b/src/core2/animtexturecache.c @@ -0,0 +1,82 @@ +#include +#include "functions.h" +#include "variables.h" + +typedef struct { + AnimTexture anim_texture_info[4]; + f32 current_frame[4]; +}AnimTextureList; //this struct only used when textures are active in RAM + +/* .bss */ +FREE_LIST(AnimTextureList) *AnimTextureListCache; + +/* .code */ +bool AnimTextureListCache_tryGetTextureOffset(s32 list_index, s32 texture_index, s32 *current_frame) { + AnimTextureList * temp_v0; + + temp_v0 = (AnimTextureList *)freelist_at(AnimTextureListCache, list_index); + if (temp_v0->anim_texture_info[texture_index].frame_size != 0) { + *current_frame = (s32)temp_v0->current_frame[texture_index] * temp_v0->anim_texture_info[texture_index].frame_size; + return TRUE; + } + return FALSE; +} + +s32 AnimTextureListCache_newList(void){ + AnimTextureList *phi_v0; + s32 index; + s32 i; + + phi_v0 = (AnimTextureList *)freelist_next(&AnimTextureListCache, &index); + for(i = 0; i < 4; i++){ + phi_v0->anim_texture_info[i].frame_size = 0; + phi_v0->current_frame[i] = 0.0f; + } + return index; +} + +void AnimTextureListCache_free(void){ + freelist_free(AnimTextureListCache); +} + +void AnimTextureListCache_init(void){ + AnimTextureListCache = (FREE_LIST(AnimTextureList) *)freelist_new(sizeof(AnimTextureList), 2); +} + +void AnimTextureListCache_freeList(s32 arg0){ + freelist_freeElement(AnimTextureListCache, arg0); +} + +void AnimTextureListCache_at(s32 arg0, AnimTexture arg1[4]){ + AnimTextureList * sp1C; + s32 i; + + + sp1C = (AnimTextureList *) freelist_at(AnimTextureListCache, arg0); + memcpy(sp1C, arg1, 0x20); + for(i = 0; i < 4; i++){ + sp1C->current_frame[i] = 0.0f; + } +} + +void AnimTextureListCache_update(void) { + f32 dt; + s32 j; + AnimTextureList *j_ptr; + s32 i; + + dt = time_getDelta(); + for(j = 1; j anim_texture_info[i].frame_size != 0) { + j_ptr->current_frame[i] += (j_ptr->anim_texture_info[i].frame_rate * dt); + if ((s32) j_ptr->current_frame[i] >= j_ptr->anim_texture_info[i].frame_cnt) { + j_ptr->current_frame[i] -= j_ptr->anim_texture_info[i].frame_cnt; + } + } + } + } + } +} diff --git a/src/core2/ch/bottlesbonus.c b/src/core2/ch/bottlesbonus.c index 7847bcd5..cb4b7d8b 100644 --- a/src/core2/ch/bottlesbonus.c +++ b/src/core2/ch/bottlesbonus.c @@ -462,7 +462,7 @@ void chBottlesBonus_update(Actor *this) { D_8037DEA8 = assetcache_get(0x471); } if (D_8037DEAC == NULL) { - D_8037DEAC = func_8033F5F8(func_8033A0B0(chBottleBonusBookselfModelBin), func_8033A148(chBottleBonusBookselfModelBin)); + D_8037DEAC = func_8033F5F8(func_8033A0B0(chBottleBonusBookselfModelBin), model_getVtxList(chBottleBonusBookselfModelBin)); func_8034CF74(local, 0, D_8037DEAC, 0xF0); } func_8028746C(this->animctrl, chBottlesBonus_func_802DD8AC); diff --git a/src/core2/code_12F30.c b/src/core2/code_12F30.c index 0cf38047..65877856 100644 --- a/src/core2/code_12F30.c +++ b/src/core2/code_12F30.c @@ -140,7 +140,7 @@ void func_80299EC0(f32 arg0[3]) { if (sp6C == NULL) return; if (sp6C->unk6 &2) return; - vtx_buffer = vtxList_getVertices(func_8033A148(spC8)); + vtx_buffer = vtxList_getVertices(model_getVtxList(spC8)); for(i = 0; i<3; i++){ temp_v1 = vtx_buffer + sp6C->unk0[i]; sp48[i][0] = (f32) temp_v1->v.ob[0]; diff --git a/src/core2/code_42CB0.c b/src/core2/code_42CB0.c index 1025d285..14707abb 100644 --- a/src/core2/code_42CB0.c +++ b/src/core2/code_42CB0.c @@ -26,7 +26,7 @@ ActorInfo D_80366CA4 = { MARKER_55_HONEYCOMB, ACTOR_50_HONEYCOMB, ASSET_363_MODE /* .bss */ enum honeycomb_e D_8037DDC0; -array(s32) * D_8037DDC4; +FREE_LIST(ActorMarker *) * D_8037DDC4; s32 D_8037DDC8; u32 D_8037DDCC; s32 D_8037DDD0; @@ -54,14 +54,14 @@ enum honeycomb_e func_802C9C40(Actor *this){ return func_80306DBC(tmp_a0) - 0x63; } -void func_802C9CF4(Actor *this){ +void __chHoneycomb_free(Actor *this){ ActorLocal_EmptyHoneycomb *local = (ActorLocal_EmptyHoneycomb *)&this->local; D_8037DDC8--; - func_802EDCDC(D_8037DDC4, local->uid); + freelist_freeElement(D_8037DDC4, local->uid); D_8037DDCC &= ~(1 << local->uid); if(D_8037DDC8 == 0){ - array_free(D_8037DDC4); + freelist_free(D_8037DDC4); D_8037DDC4 = NULL; } } @@ -76,9 +76,9 @@ void func_802C9D80(void){ ActorMarker *s5; s5 = NULL; s2 = 0xFFFFFFFF; - for(i = 1; i < array_size(D_8037DDC4); i++){ + for(i = 1; i < freelist_size(D_8037DDC4); i++){ if(D_8037DDCC & (1 << i)){ - i_marker_ptr = (ActorMarker **)array_at(D_8037DDC4, i); + i_marker_ptr = (ActorMarker **)freelist_at(D_8037DDC4, i); i_marker = *i_marker_ptr; i_actor = marker_getActor(i_marker); i_local = (ActorLocal_EmptyHoneycomb *)&i_actor->local; @@ -118,15 +118,15 @@ void chHoneycomb_update(Actor *this){ if( this->marker->unk14_20 == MARKER_55_HONEYCOMB && !this->unk44_2 ){ - marker_setFreeMethod(this->marker, func_802C9CF4); + marker_setFreeMethod(this->marker, __chHoneycomb_free); D_8037DDC8++; if(D_8037DDC4 == NULL){ - D_8037DDC4 = (array(s32) *) array_new(sizeof(s32), 10); + D_8037DDC4 = (FREE_LIST(s32) *) freelist_new(sizeof(s32), 10); } else if(D_8037DDC8 >= 11){ func_802C9D80(); } - tmp_v0 = (ActorMarker **)func_802EDAA4(&D_8037DDC4, this->local); + tmp_v0 = (ActorMarker **)freelist_next(&D_8037DDC4, &local->uid); *tmp_v0 = this->marker; D_8037DDCC |= 1 << local->uid; local->unk4 = D_8037DDD0; diff --git a/src/core2/code_5C240.c b/src/core2/code_5C240.c index 56e4ccf7..d07e2479 100644 --- a/src/core2/code_5C240.c +++ b/src/core2/code_5C240.c @@ -3,7 +3,7 @@ #include "variables.h" extern void func_8023DFF0(s32); -extern void func_80259BD0(void); +extern void comusicPlayer_update(void); extern void func_802F1A10(void *, f32); extern void func_8033DC10(void); extern void func_8033DC18(void); @@ -105,7 +105,7 @@ void func_802E3580(void) { assetcache_release(D_8037E8C0.unkC); func_802F1884(D_8037E8C0.unk10); func_802E5F68(); - func_80259B14(); + comusicPlayer_free(); func_80253420(); func_8024BF94(2); } @@ -160,7 +160,7 @@ void func_802E35D8(void ) { return; } } - func_80259BD0(); + comusicPlayer_update(); if (D_8037E8C0.unk14 == 0) { gcbound_alpha(D_8037E8C0.unk8); } diff --git a/src/core2/code_5C870.c b/src/core2/code_5C870.c index bb0ee16d..32bbb7ce 100644 --- a/src/core2/code_5C870.c +++ b/src/core2/code_5C870.c @@ -19,7 +19,7 @@ extern void func_8034BB90(void); extern void func_8030C27C(void); extern void func_80321C34(void); extern void func_8030ED0C(void); -extern void func_80259BD0(void); +extern void comusicPlayer_update(void); enum transition_e { TRANSITION_0_NONE @@ -109,7 +109,7 @@ void func_802E38E8(enum map_e map, s32 exit, s32 reset_on_load){ void func_802E398C(s32 arg0) { func_80334910(); func_8030ED0C(); - func_80259BD0(); + comusicPlayer_update(); if (arg0 != 0) { func_802E3854(); } @@ -370,7 +370,7 @@ void func_802E4170(void){ func_80321854(); func_8031FBF8(); func_802880C0(); - func_80259B14(); + comusicPlayer_free(); func_8030D8DC(); } @@ -384,7 +384,7 @@ void func_802E4214(enum map_e map_id){ savedata_init(); sns_save_and_update_global_data(); func_8030D86C(); - func_80259A24(); + comusicPlayer_init(); func_80322764(); timedFuncQueue_init(); func_802F9CD8(); @@ -517,7 +517,7 @@ bool func_802E4424(void) { sp1C = func_80334ECC(); func_80321C34(); func_8030ED0C(); - func_80259BD0(); + comusicPlayer_update(); switch (D_8037E8E0.game_mode) { case GAME_MODE_8_BOTTLES_BONUS: case GAME_MODE_A_SNS_PICTURE: diff --git a/src/core2/code_5FD90.c b/src/core2/code_5FD90.c index 9721920a..a28ea5cc 100644 --- a/src/core2/code_5FD90.c +++ b/src/core2/code_5FD90.c @@ -7,7 +7,7 @@ extern void func_80252C08(f32[3],f32[3], f32, f32[3]); extern void func_80252CC4(f32[3],s32, f32, s32); extern f32 func_802560D0(f32[3], f32[3], f32[3]); -extern f32 func_802EC920(BKVertexList *); +extern f32 vtxList_getGlobalNorm(BKVertexList *); extern void points_to_boundingBoxWithMargin(f32 arg0[3], f32 arg1[3], f32 margin, f32 min[3], f32 max[3]); #define ABS_F(s) (((s) >= 0.0f) ? (s) : -(s)) @@ -283,7 +283,7 @@ BKCollisionTri *func_802E76B0(BKCollisionList *collisionList, BKVertexList *vert BKCollisionTri *sp8C; sp8C = NULL; - temp_f20 = (f32) vertexList->unk16; + temp_f20 = (f32) vertexList->global_norm; func_802E75D0(arg2, arg3, sp158, sp14C, sp140); for(i = 0; i < 3; i++){ if ((sp14C[i] <= -temp_f20) || (temp_f20 <= sp158[i])) { @@ -409,7 +409,7 @@ int func_802E805C(BKCollisionList *collision_list, BKVertexList *vtxList, f32 ar int sp34; int i; - if(!func_802E74A0(arg2, vtxList->unk16*arg4, arg5, arg6)){ + if(!func_802E74A0(arg2, vtxList->global_norm*arg4, arg5, arg6)){ return 0; } else{ @@ -463,7 +463,7 @@ s32 func_802E81CC(BKCollisionList *collisionList, BKVertexList *vertexList, f32 points_to_boundingBoxWithMargin(p1, p2, margin, min, max); - temp_f0 = func_802EC920(vertexList); + temp_f0 = vtxList_getGlobalNorm(vertexList); for(i = 0; i < 3; i++){ if ((max[i] <= -temp_f0) || (temp_f0 <= min[i])) { return 0; @@ -740,7 +740,7 @@ s32 func_802E9118(BKCollisionList * collision_list, BKVertexList *vtx_list, f32 s32 sp3C; s32 i; - if (((f32)vtx_list->unk16 * arg4) <= (ml_distance_vec3f(arg6, arg2) - arg7)) { + if (((f32)vtx_list->global_norm * arg4) <= (ml_distance_vec3f(arg6, arg2) - arg7)) { return 0; } mlMtxIdent(); @@ -809,7 +809,7 @@ BKCollisionTri *func_802E92AC(BKCollisionList *collisionList, BKVertexList *vert } //check if any vertices are within range; - temp_f0_2 = func_802EC920(vertexList); + temp_f0_2 = vtxList_getGlobalNorm(vertexList); for(i = 0; i < 3; i++){ if((max[i] <= -temp_f0_2)|| temp_f0_2 <= min[i]) return NULL; @@ -976,7 +976,7 @@ s32 func_802E9DD8(BKCollisionList *collisionList, BKVertexList *vtxList, f32 arg s32 sp30; s32 i; - if ((vtxList->unk16 * arg4) <= (ml_distance_vec3f(arg5, arg2) - arg6)) { + if ((vtxList->global_norm * arg4) <= (ml_distance_vec3f(arg5, arg2) - arg6)) { return 0; } mlMtxIdent(); diff --git a/src/core2/code_637D0.c b/src/core2/code_637D0.c index 35ae7db6..085ad027 100644 --- a/src/core2/code_637D0.c +++ b/src/core2/code_637D0.c @@ -10,7 +10,7 @@ extern s32 func_802EBAE0(BKModelUnk14List *arg0, f32 position[3], f32 rotation[ Mtx D_80380880; /* .code */ -bool func_802EA760(BKModelUnk14List *arg0, s32 arg1, f32 arg2[3], f32 arg3[3], f32 arg4, f32 arg5[3], f32 arg6[3], f32 *arg7) { +bool func_802EA760(BKModelUnk14List *arg0, s32 arg1, f32 arg2[3], f32 rotation[3], f32 scale, f32 arg5[3], f32 arg6[3], f32 *arg7) { s32 start; BKModelUnk14_2 *temp_v0; @@ -25,9 +25,9 @@ bool func_802EA760(BKModelUnk14List *arg0, s32 arg1, f32 arg2[3], f32 arg3[3], f arg6[2] = (f32) temp_v0->unk2[2]; *arg7 = (f32) temp_v0->unk0; mlMtxIdent(); - func_80252C08(arg2, arg3, arg4, arg5); + func_80252C08(arg2, rotation, scale, arg5); func_8025235C(arg6, arg6); - *arg7 /= arg4; + *arg7 /= scale; return TRUE; } @@ -126,7 +126,7 @@ s32 func_802EAD5C(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 f32 temp_f20; f32 sp4C[3]; BKModelUnk14_2 *end_ptr; - BKModelUnk14_2 *var_s0; + BKModelUnk14_2 *i_ptr; f32 pad40; f32 sp34[3]; @@ -135,19 +135,19 @@ s32 func_802EAD5C(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 func_8025235C(sp5C, arg5); t0_ptr = (BKModelUnk14_0 *)(arg0 + 1); t1_ptr = (BKModelUnk14_1 *)(t0_ptr + arg0->cnt0); - var_s0 = (BKModelUnk14_2 *)(t1_ptr + arg0->cnt2); - end_ptr = var_s0 + arg0->unk4; - for(var_s0 = var_s0; var_s0 < end_ptr; var_s0++) { - sp4C[0] = (f32) var_s0->unk2[0]; - sp4C[1] = (f32) var_s0->unk2[1]; - sp4C[2] = (f32) var_s0->unk2[2]; + i_ptr = (BKModelUnk14_2 *)(t1_ptr + arg0->cnt2); + end_ptr = i_ptr + arg0->unk4; + for(i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++) { + sp4C[0] = (f32) i_ptr->unk2[0]; + sp4C[1] = (f32) i_ptr->unk2[1]; + sp4C[2] = (f32) i_ptr->unk2[2]; - temp_f20 = (f32)var_s0->unk0; + temp_f20 = (f32)i_ptr->unk0; sp34[0] = sp4C[0] - sp5C[0]; sp34[1] = sp4C[1] - sp5C[1]; sp34[2] = sp4C[2] - sp5C[2]; if (!( gu_sqrtf(sp34[0]*sp34[0] + sp34[1]*sp34[1] + sp34[2]*sp34[2]) >= ((arg6 / scale) + temp_f20))) { - return var_s0->unk8; + return i_ptr->unk8; } } return 0; @@ -159,7 +159,7 @@ s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 f32 spDC[3]; f32 spD0[3]; BKModelUnk14_0 *end_ptr; - BKModelUnk14_0 *var_s0; + BKModelUnk14_0 *i_ptr; f32 spBC[3]; f32 spB0[3]; f32 spA4[3]; @@ -170,28 +170,28 @@ s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 f32 sp68[3]; f32 sp5C[3]; - var_s0 = (BKModelUnk14_0 *)(arg0 + 1); - end_ptr = var_s0 + arg0->cnt0; - for(var_s0 = var_s0; var_s0 < end_ptr; var_s0++){ - spF4[0] = (f32) var_s0->unkC[0]; - spF4[1] = (f32) var_s0->unkC[1]; - spF4[2] = (f32) var_s0->unkC[2]; + i_ptr = (BKModelUnk14_0 *)(arg0 + 1); + end_ptr = i_ptr + arg0->cnt0; + for(i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++){ + spF4[0] = (f32) i_ptr->unkC[0]; + spF4[1] = (f32) i_ptr->unkC[1]; + spF4[2] = (f32) i_ptr->unkC[2]; - spE8[0] = (f32) var_s0->unk0[0]; - spE8[1] = (f32) var_s0->unk0[1]; - spE8[2] = (f32) var_s0->unk0[2]; + spE8[0] = (f32) i_ptr->unk0[0]; + spE8[1] = (f32) i_ptr->unk0[1]; + spE8[2] = (f32) i_ptr->unk0[2]; - spDC[0] = (f32) var_s0->unk6[0]; - spDC[1] = (f32) var_s0->unk6[1]; - spDC[2] = (f32) var_s0->unk6[2]; + spDC[0] = (f32) i_ptr->unk6[0]; + spDC[1] = (f32) i_ptr->unk6[1]; + spDC[2] = (f32) i_ptr->unk6[2]; - spD0[0] = (f32)var_s0->unk12[0]; - spD0[1] = (f32)var_s0->unk12[1]; - spD0[2] = (f32)var_s0->unk12[2]; + spD0[0] = (f32)i_ptr->unk12[0]; + spD0[1] = (f32)i_ptr->unk12[1]; + spD0[2] = (f32)i_ptr->unk12[2]; spD0[0] *= 2; spD0[1] *= 2; spD0[2] *= 2; - func_802519C8(&D_80380880, func_802EA110(arg5, var_s0->unk16)); + func_802519C8(&D_80380880, func_802EA110(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]); @@ -247,8 +247,8 @@ s32 func_802EB458(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 BKModelUnk14_0 *ptr_t0; f32 spB8[3]; f32 spAC[3]; - BKModelUnk14_1 *temp_s2; - BKModelUnk14_1 *var_s0; + BKModelUnk14_1 *end_ptr; + BKModelUnk14_1 *i_ptr; f32 sp98[3]; f32 sp8C[3]; @@ -260,21 +260,21 @@ s32 func_802EB458(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 f32 temp_f6; ptr_t0 = (BKModelUnk14_0 *) (arg0 + 1); - var_s0 = (BKModelUnk14_1 *) (ptr_t0 + arg0->cnt0); - temp_s2 = var_s0 + arg0->cnt2; - for (var_s0 = var_s0; var_s0 < temp_s2; var_s0++) + i_ptr = (BKModelUnk14_1 *) (ptr_t0 + arg0->cnt0); + end_ptr = i_ptr + arg0->cnt2; + for (i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++) { - spB8[0] = (f32) var_s0->unk4[0]; - spB8[1] = (f32) var_s0->unk4[1]; - spB8[2] = (f32) var_s0->unk4[2]; - spAC[0] = (f32) (var_s0->unkA[0] * 2); - spAC[1] = (f32) (var_s0->unkA[1] * 2); - spAC[2] = (f32) (var_s0->unkA[2] * 2); - func_802519C8(&D_80380880, func_802EA110(arg5, var_s0->unkE)); + spB8[0] = (f32) i_ptr->unk4[0]; + spB8[1] = (f32) i_ptr->unk4[1]; + spB8[2] = (f32) i_ptr->unk4[2]; + 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, func_802EA110(arg5, i_ptr->unkE)); func_80252D8C(spB8, spAC); - func_802524F0(sp98, 0.0f, 0.0f, (f32) ((-var_s0->unk2) / 2)); - func_802524F0(sp8C, 0.0f, 0.0f, (f32) (var_s0->unk2 / 2)); - func_802524F0(sp68, (f32) var_s0->unk0, 0.0f, (f32) ((-var_s0->unk2) / 2)); + 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)); sp68[0] -= sp98[0]; sp68[1] -= sp98[1]; sp68[2] -= sp98[2]; @@ -303,7 +303,7 @@ s32 func_802EB458(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 temp_f20 = gu_sqrtf(((sp74[0] * sp74[0]) + (sp74[1] * sp74[1])) + (sp74[2] * sp74[2])); if (!((temp_f20 - arg7) > gu_sqrtf(((sp68[0] * sp68[0]) + (sp68[1] * sp68[1])) + (sp68[2] * sp68[2])))) { - return var_s0->unkD; + return i_ptr->unkD; } } } @@ -319,8 +319,8 @@ s32 func_802EB8A0(BKModelUnk14List *arg0, f32 *position, f32 *rotation, f32 scal f32 sp74[3]; f32 sp68[3]; f32 sp5C[3]; - BKModelUnk14_2 *temp_s4; - BKModelUnk14_2 *var_s0; + BKModelUnk14_2 *end_ptr; + BKModelUnk14_2 *i_ptr; f32 temp_f0; f32 sp44[3]; @@ -329,17 +329,17 @@ s32 func_802EB8A0(BKModelUnk14List *arg0, f32 *position, f32 *rotation, f32 scal func_8025235C(&sp74, arg6); t0_ptr = (BKModelUnk14_0 *)(arg0 + 1); t1_ptr = (BKModelUnk14_1 *)(t0_ptr + arg0->cnt0); - var_s0 = (BKModelUnk14_2 *)(t1_ptr + arg0->cnt2); - temp_s4 = var_s0 + arg0->unk4; + i_ptr = (BKModelUnk14_2 *)(t1_ptr + arg0->cnt2); + end_ptr = i_ptr + arg0->unk4; arg7 /= scale; - for(var_s0 = var_s0; var_s0 < temp_s4; var_s0++){ - sp68[0] = (f32) var_s0->unk2[0]; - sp68[1] = (f32) var_s0->unk2[1]; - sp68[2] = (f32) var_s0->unk2[2]; - sp5C[0] = sp68[0] + (f32) var_s0->unk0; + for(i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++){ + sp68[0] = (f32) i_ptr->unk2[0]; + sp68[1] = (f32) i_ptr->unk2[1]; + sp68[2] = (f32) i_ptr->unk2[2]; + sp5C[0] = sp68[0] + (f32) i_ptr->unk0; sp5C[1] = sp68[1]; sp5C[2] = sp68[2]; - func_80251BCC(func_802EA110(arg5, var_s0->unk9)); + func_80251BCC(func_802EA110(arg5, i_ptr->unk9)); func_8025235C(sp68, sp68); func_8025235C(sp5C, sp5C); sp44[0] = sp5C[0] - sp68[0]; @@ -347,14 +347,14 @@ s32 func_802EB8A0(BKModelUnk14List *arg0, f32 *position, f32 *rotation, f32 scal sp44[2] = sp5C[2] - sp68[2]; temp_f0 = gu_sqrtf(sp44[0]*sp44[0] + sp44[1]*sp44[1] + sp44[2]*sp44[2]); if ((arg7 + temp_f0 >= ml_distance_vec3f(sp68, sp74))) { - return (s32) var_s0->unk8; + return (s32) i_ptr->unk8; } } return 0; } -bool func_802EBA98(BKModelUnk14List *arg0, f32 arg1[3], s32 arg2, f32 arg3, s32 arg4, f32 arg5[3], f32 arg6, f32 arg7[3]){ - return func_802EBAE0(arg0, arg1, arg2, arg3, arg4, NULL, arg5, arg6, arg7); +bool func_802EBA98(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scale, s32 arg4, f32 arg5[3], f32 arg6, f32 arg7[3]){ + return func_802EBAE0(arg0, arg1, rotation, scale, arg4, NULL, arg5, arg6, arg7); } 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]) @@ -407,46 +407,51 @@ s32 func_802EBAE0(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 return phi_v0; } -s32 func_802EBD3C(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, s32 arg4, s32 arg5, s32 arg6) +s32 func_802EBD3C(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scale, f32 arg4[3], f32 arg5[3], s32 arg6) { s32 i; - f32 spA0[3]; - f32 sp94[3]; - f32 sp88[3]; - f32 sp7C[3]; - BKModelUnk14_0 *phi_s0; - BKModelUnk14_0 *temp_s4; + f32 i_position[3]; + f32 i_min[3]; + f32 i_max[3]; + f32 i_rotation[3]; + BKModelUnk14_0 *i_ptr; + BKModelUnk14_0 *end_ptr; f32 sp68[3]; - BKModelUnk14_0 *temp_s0; - temp_s0 = (BKModelUnk14_0 *) (arg0 + 1); - temp_s4 = temp_s0 + arg0->cnt0; - for (phi_s0 = temp_s0; phi_s0 < temp_s4; phi_s0++) + BKModelUnk14_0 *start_ptr; + + start_ptr = (BKModelUnk14_0 *) (arg0 + 1); + end_ptr = start_ptr + arg0->cnt0; + for (i_ptr = start_ptr; i_ptr < end_ptr; i_ptr++) { - if ((phi_s0->unk15 != 0) && ((arg6 == 0) || (arg6 == phi_s0->unk15))) + if ((i_ptr->unk15 != 0) && ((arg6 == 0) || (arg6 == i_ptr->unk15))) { - spA0[0] = (f32) phi_s0->unkC[0]; - spA0[1] = (f32) phi_s0->unkC[1]; - spA0[2] = (f32) phi_s0->unkC[2]; - sp94[0] = (f32) phi_s0->unk0[0]; - sp94[1] = (f32) phi_s0->unk0[1]; - sp94[2] = (f32) phi_s0->unk0[2]; - sp88[0] = (f32) phi_s0->unk6[0]; - sp88[1] = (f32) phi_s0->unk6[1]; - sp88[2] = (f32) phi_s0->unk6[2]; - sp7C[0] = (f32) phi_s0->unk12[0]; - sp7C[1] = (f32) phi_s0->unk12[1]; - sp7C[2] = (f32) phi_s0->unk12[2]; - sp7C[0] *= 2; - sp7C[1] *= 2; - sp7C[2] *= 2; + i_position[0] = (f32) i_ptr->unkC[0]; + i_position[1] = (f32) i_ptr->unkC[1]; + i_position[2] = (f32) i_ptr->unkC[2]; + + i_min[0] = (f32) i_ptr->unk0[0]; + i_min[1] = (f32) i_ptr->unk0[1]; + i_min[2] = (f32) i_ptr->unk0[2]; + + i_max[0] = (f32) i_ptr->unk6[0]; + i_max[1] = (f32) i_ptr->unk6[1]; + i_max[2] = (f32) i_ptr->unk6[2]; + + i_rotation[0] = (f32) i_ptr->unk12[0]; + i_rotation[1] = (f32) i_ptr->unk12[1]; + i_rotation[2] = (f32) i_ptr->unk12[2]; + i_rotation[0] *= 2; + i_rotation[1] *= 2; + i_rotation[2] *= 2; + mlMtxIdent(); - func_80252EC8(spA0, sp7C); - func_80252CC4(arg1, arg2, arg3, arg4); - func_8025235C(sp68, arg5); + func_80252EC8(i_position, i_rotation); //rotate about point + func_80252CC4(arg1, rotation, scale, arg4); + func_8025235C(sp68, arg5); //apply matrix to arg5 for (i = 0; i < 3; i++) { if (1); - if ((sp68[i] <= sp94[i]) || (sp88[i] <= sp68[i])) + if ((sp68[i] <= i_min[i]) || (i_max[i] <= sp68[i])) { break; } @@ -454,7 +459,7 @@ s32 func_802EBD3C(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, s3 if (i == 3) { - return phi_s0->unk15; + return i_ptr->unk15; } } } @@ -462,37 +467,37 @@ s32 func_802EBD3C(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, s3 return 0; } -s32 func_802EC000(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, s32 arg4, f32 arg5[3], s32 arg6){ - BKModelUnk14_1 *phi_s0; +s32 func_802EC000(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scale, s32 arg4, f32 arg5[3], s32 arg6){ + BKModelUnk14_1 *i_ptr; f32 sp90[3]; f32 sp84[3]; BKModelUnk14_0 *t0_ptr; - BKModelUnk14_1 *temp_s2; + BKModelUnk14_1 *end_ptr; f32 temp_f20; f32 temp_f22; f32 sp68[3]; f32 temp_f0; t0_ptr = (BKModelUnk14_0 *)(arg0 + 1); - phi_s0 = (BKModelUnk14_1 *)(t0_ptr + arg0->cnt0); - temp_s2 = &phi_s0[arg0->cnt2]; - for(phi_s0 = phi_s0; phi_s0 < temp_s2; phi_s0++){ - if ((phi_s0->unkD != 0) && ((arg6 == 0) || (arg6 == phi_s0->unkD))) { - sp90[0] = (f32) phi_s0->unk4[0]; - sp90[1] = (f32) phi_s0->unk4[1]; - sp90[2] = (f32) phi_s0->unk4[2]; - sp84[0] = (f32) (phi_s0->unkA[0] * 2); - sp84[1] = (f32) (phi_s0->unkA[1] * 2); - sp84[2] = (f32) (phi_s0->unkA[2] * 2); - temp_f20 = (f32) phi_s0->unk0; - temp_f22 = (f32) phi_s0->unk2; + i_ptr = (BKModelUnk14_1 *)(t0_ptr + arg0->cnt0); + end_ptr = &i_ptr[arg0->cnt2]; + for(i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++){ + if ((i_ptr->unkD != 0) && ((arg6 == 0) || (arg6 == i_ptr->unkD))) { + sp90[0] = (f32) i_ptr->unk4[0]; + sp90[1] = (f32) i_ptr->unk4[1]; + sp90[2] = (f32) i_ptr->unk4[2]; + sp84[0] = (f32) (i_ptr->unkA[0] * 2); + sp84[1] = (f32) (i_ptr->unkA[1] * 2); + sp84[2] = (f32) (i_ptr->unkA[2] * 2); + temp_f20 = (f32) i_ptr->unk0; + temp_f22 = (f32) i_ptr->unk2; mlMtxIdent(); func_80252DDC(&sp90, &sp84); - func_80252CC4(arg1, arg2, arg3, arg4); + func_80252CC4(arg1, rotation, scale, arg4); func_8025235C(&sp68, arg5); temp_f0 = (f32) (temp_f22 / 2.0); if (!(temp_f0 <= sp68[2]) && !(sp68[2] <= -temp_f0) && !((temp_f20 * temp_f20) <= (sp68[0] * sp68[0] + sp68[1]*sp68[1]))) { - return phi_s0->unkD; + return i_ptr->unkD; } if(1); if(1); @@ -501,33 +506,33 @@ s32 func_802EC000(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, s3 return 0; } -s32 func_802EC238(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s32 arg5, s32 arg6){ +s32 func_802EC238(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scale, f32 arg4[3], s32 arg5, s32 arg6){ BKModelUnk14_0 *t0_ptr; BKModelUnk14_1 *t1_ptr; f32 sp54[3]; - BKModelUnk14_2 *var_s0; - BKModelUnk14_2 *temp_s4; + BKModelUnk14_2 *i_ptr; + BKModelUnk14_2 *end_ptr; f32 sp40[3]; t0_ptr = (BKModelUnk14_0 *)(arg0 + 1); t1_ptr = (BKModelUnk14_1 *)(t0_ptr + arg0->cnt0); - var_s0 = (BKModelUnk14_2 *)(t1_ptr + arg0->cnt2); - temp_s4 = var_s0 + arg0->unk4; + i_ptr = (BKModelUnk14_2 *)(t1_ptr + arg0->cnt2); + end_ptr = i_ptr + arg0->unk4; mlMtxIdent(); - func_80252CC4(arg1, arg2, arg3, arg4); + func_80252CC4(arg1, rotation, scale, arg4); func_8025235C(sp54, arg5); - for (var_s0 = var_s0; var_s0 < temp_s4; var_s0++) + for (i_ptr = i_ptr; i_ptr < end_ptr; i_ptr++) { - if ((var_s0->unk8 != 0) && ((arg6 == 0) || (arg6 == var_s0->unk8))) + if ((i_ptr->unk8 != 0) && ((arg6 == 0) || (arg6 == i_ptr->unk8))) { - sp40[0] = var_s0->unk2[0]; - sp40[1] = var_s0->unk2[1]; - sp40[2] = var_s0->unk2[2]; - arg3 = var_s0->unk0; - if (ml_distance_vec3f(sp40, sp54) < arg3) - return var_s0->unk8; - if (!var_s0->unk0){ + 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){ } } @@ -535,17 +540,17 @@ s32 func_802EC238(BKModelUnk14List *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, f3 return 0U; } -s32 func_802EC394(BKModelUnk14List *arg0, s32 arg1, s32 arg2, f32 arg3, s32 arg4, s32 arg5, s32 arg6) { +s32 func_802EC394(BKModelUnk14List *arg0, f32 arg1[3], f32 rotation[3], f32 scale, f32 arg4[3], f32 arg5[3], s32 arg6) { s32 phi_v0; - phi_v0 = func_802EBD3C(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + phi_v0 = func_802EBD3C(arg0, arg1, rotation, scale, arg4, arg5, arg6); if (phi_v0 != NULL) { return phi_v0; } - phi_v0 = func_802EC000(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + phi_v0 = func_802EC000(arg0, arg1, rotation, scale, arg4, arg5, arg6); if (phi_v0 != NULL) { return phi_v0; } - return func_802EC238(arg0, arg1, arg2, arg3, arg4, arg5, arg6); + return func_802EC238(arg0, arg1, rotation, scale, arg4, arg5, arg6); } diff --git a/src/core2/code_654C0.c b/src/core2/code_654C0.c index a57ae508..e1fb20c7 100644 --- a/src/core2/code_654C0.c +++ b/src/core2/code_654C0.c @@ -44,7 +44,7 @@ void vtxList_getBoundsMlMtxTransformed(BKVertexList *self, f32 min[3], f32 max[3 Vtx *end_vtx; Vtx *i_vtx; s32 i; - f32 sp44[3]; + f32 i_coord[3]; start_vtx = (Vtx *)(self + 1); end_vtx = start_vtx + self->count; @@ -57,17 +57,17 @@ void vtxList_getBoundsMlMtxTransformed(BKVertexList *self, f32 min[3], f32 max[3 max[2] = min[2]; for( i_vtx = start_vtx + 1; i_vtx < end_vtx; i_vtx++){ - sp44[0] = (f32) i_vtx->v.ob[0]; - sp44[1] = (f32) i_vtx->v.ob[1]; - sp44[2] = (f32) i_vtx->v.ob[2]; - func_8025235C(sp44, sp44); + i_coord[0] = (f32) i_vtx->v.ob[0]; + i_coord[1] = (f32) i_vtx->v.ob[1]; + i_coord[2] = (f32) i_vtx->v.ob[2]; + func_8025235C(i_coord, i_coord); for(i = 0; i < 3; i++){ - if( sp44[i] < min[i]){ - min[i] = sp44[i]; + if( i_coord[i] < min[i]){ + min[i] = i_coord[i]; } - if( max[i] < sp44[i]){ - max[i] = sp44[i]; + if( max[i] < i_coord[i]){ + max[i] = i_coord[i]; } } } @@ -78,51 +78,51 @@ void func_802EC680(BKVertexList *self, s32 arg1, f32 arg2[3], f32 arg3[3]) { Vtx *end_vtx; Vtx *i_vtx; s32 i; - f32 sp44[3]; + f32 i_coord[3]; start_vtx = (Vtx*)(self + 1); end_vtx = start_vtx + self->count; for(i_vtx = start_vtx; i_vtx < end_vtx; i_vtx++){ - sp44[0] = (f32) i_vtx->v.ob[0]; - sp44[1] = (f32) i_vtx->v.ob[1]; - sp44[2] = (f32) i_vtx->v.ob[2]; - func_8025235C(sp44, sp44); - if ((i_vtx == start_vtx) || (sp44[1] < arg2[1])) { - arg2[1] = sp44[1]; + i_coord[0] = (f32) i_vtx->v.ob[0]; + i_coord[1] = (f32) i_vtx->v.ob[1]; + i_coord[2] = (f32) i_vtx->v.ob[2]; + func_8025235C(i_coord, i_coord); + if ((i_vtx == start_vtx) || (i_coord[1] < arg2[1])) { + arg2[1] = i_coord[1]; } } arg3[1] = arg2[1]+ (f32) arg1; for(i_vtx = start_vtx; i_vtx < end_vtx; i_vtx++){ - sp44[0] = (f32) i_vtx->v.ob[0]; - sp44[1] = (f32) i_vtx->v.ob[1]; - sp44[2] = (f32) i_vtx->v.ob[2]; - func_8025235C(sp44, sp44); - if (sp44[1] < arg3[1]) { + i_coord[0] = (f32) i_vtx->v.ob[0]; + i_coord[1] = (f32) i_vtx->v.ob[1]; + i_coord[2] = (f32) i_vtx->v.ob[2]; + func_8025235C(i_coord, i_coord); + if (i_coord[1] < arg3[1]) { - arg2[0] = sp44[0]; - arg2[2] = sp44[2]; + arg2[0] = i_coord[0]; + arg2[2] = i_coord[2]; - arg3[0] = sp44[0]; - arg3[2] = sp44[2]; + arg3[0] = i_coord[0]; + arg3[2] = i_coord[2]; break; } } for(i_vtx = i_vtx + 1; i_vtx < end_vtx; i_vtx++) { - sp44[0] = (f32) i_vtx->v.ob[0]; - sp44[1] = (f32) i_vtx->v.ob[1]; - sp44[2] = (f32) i_vtx->v.ob[2]; - func_8025235C(sp44, sp44); - if (sp44[1] < arg3[1]) { + i_coord[0] = (f32) i_vtx->v.ob[0]; + i_coord[1] = (f32) i_vtx->v.ob[1]; + i_coord[2] = (f32) i_vtx->v.ob[2]; + func_8025235C(i_coord, i_coord); + if (i_coord[1] < arg3[1]) { for(i = 0; i < 3; i+=2){ - if (sp44[i] < arg2[i]) { - arg2[i] = sp44[i]; + if (i_coord[i] < arg2[i]) { + arg2[i] = i_coord[i]; } - if (arg3[i] < sp44[i]) { - arg3[i] = sp44[i]; + if (arg3[i] < i_coord[i]) { + arg3[i] = i_coord[i]; } } } @@ -138,19 +138,19 @@ s32 vtxList_getVtxCount(BKVertexList *this){ return this->count; } -f32 func_802EC920(BKVertexList *this){ - return (f32)this->unk16; +f32 vtxList_getGlobalNorm(BKVertexList *this){ + return (f32)this->global_norm; } -void func_802EC930(BKVertexList *this, f32 center[3], f32 *arg2){ +void vtxList_getCenterAndNorm(BKVertexList *this, f32 center[3], f32 *norm){ center[0] = (f32)this->centerCoord[0]; center[1] = (f32)this->centerCoord[1]; center[2] = (f32)this->centerCoord[2]; - *arg2 = this->unk12; + *norm = this->local_norm; } -f32 func_802EC984(BKVertexList *this){ - return (f32)this->unk12; +f32 vtxList_getLocalNorm(BKVertexList *this){ + return (f32)this->local_norm; } void vtxList_free(BKVertexList *vtxList){ @@ -203,7 +203,7 @@ void vtxList_tint(BKVertexList *dst, s32 target_color[3], f32 amount, BKVertexLi osWritebackDCache(start_ptr, ((s32)(end_ptr - start_ptr)) * sizeof(Vtx)); } -void func_802ECBD4(BKVertexList *dst, BKVertexList *src, f32 arg2[3], f32 arg3[3], f32 arg4[4]) { +void func_802ECBD4(BKVertexList *dst, BKVertexList *src, f32 arg2[3], f32 rotation[3], f32 arg4[4]) { f32 sp74[3]; f32 sp68[3]; Vtx *dst_vtx; @@ -218,11 +218,11 @@ void func_802ECBD4(BKVertexList *dst, BKVertexList *src, f32 arg2[3], f32 arg3[3 viewport_getPosition(sp74); func_8024C5A8(sp68); mlMtxIdent(); - func_80252CC4(arg2, arg3, 1.0f, NULL); + func_80252CC4(arg2, rotation, 1.0f, NULL); func_8025235C(sp74, sp74); mlMtxIdent(); - func_80252CC4(NULL, arg3, 1.0f, NULL); + func_80252CC4(NULL, rotation, 1.0f, NULL); func_8025235C(sp68, sp68); start_vtx = (Vtx *)(dst + 1); diff --git a/src/core2/code_72060.c b/src/core2/code_72060.c index 91af09ad..617fd087 100644 --- a/src/core2/code_72060.c +++ b/src/core2/code_72060.c @@ -14,7 +14,7 @@ extern void func_80251F8C(f32); extern void func_8025208C(f32); extern void func_80252A38(f32, f32, f32); extern void mlMtxApply(Mtx *); -extern f32 func_802EC920(BKVertexList *); +extern f32 vtxList_getGlobalNorm(BKVertexList *); extern bool func_8024DB50(f32[3], f32); struct4Cs *D_80369280 = NULL; @@ -204,7 +204,7 @@ void func_802F962C(Gfx **gfx, Mtx **mtx, Vtx **vtx) { viewport_getRotation(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 = func_802EC920(temp_s3); + D_8038108C = vtxList_getGlobalNorm(temp_s3); func_80349AD0(); gSPSegment((*gfx)++, 1, osVirtualToPhysical(temp_s3 + 1)); gSPSegment((*gfx)++, 0x02, osVirtualToPhysical((s32)D_80369288 + D_80369288->texture_list_offset_8 + sizeof(BKTextureList) + sizeof(BKTextureHeader))); diff --git a/src/core2/code_999A0.c b/src/core2/code_999A0.c index a1888ab4..210a016e 100644 --- a/src/core2/code_999A0.c +++ b/src/core2/code_999A0.c @@ -103,7 +103,7 @@ void func_80320B84(void){ D_80383230.unk84 = NULL; } -BKCollisionTri *func_80320B98(f32 arg0[3], f32 arg1[3], f32 arg2[3], u32 arg3) { +BKCollisionTri *func_80320B98(f32 arg0[3], f32 arg1[3], f32 arg2[3], u32 flags) { Struct_core2_999A0_0 *var_s0; BKCollisionTri * temp_v0_2; BKCollisionTri * var_s7; @@ -112,7 +112,7 @@ BKCollisionTri *func_80320B98(f32 arg0[3], f32 arg1[3], f32 arg2[3], u32 arg3) { D_80383230.unk84 = NULL; for(var_s0 = &D_80383230.unk0[0]; var_s0 < D_80383230.unk80; var_s0++){ if (var_s0->unk0 != NULL) { - temp_v0_2 = var_s0->unk0(arg0, arg1, arg2, arg3); + temp_v0_2 = var_s0->unk0(arg0, arg1, arg2, flags); if (temp_v0_2 != NULL) { if (var_s0->unkC != NULL) { D_80383230.unk84 = var_s0->unkC(); diff --git a/src/core2/code_9E370.c b/src/core2/code_9E370.c index b34bb5c9..cd7e08c5 100644 --- a/src/core2/code_9E370.c +++ b/src/core2/code_9E370.c @@ -133,7 +133,7 @@ void func_803253A0(Actor *this){ sp34[0] = this->pitch; sp34[1] = this->yaw; sp34[2] = this->roll; - func_80333D48(sp40, this->position, sp34, this->scale, 0, func_8033A148(sp48)); + func_80333D48(sp40, this->position, sp34, this->scale, 0, model_getVtxList(sp48)); }//L80325560 modelRender_setVertexList(sp40); this->unkF4_29 = NOT(this->unkF4_29); @@ -148,7 +148,7 @@ void func_803253A0(Actor *this){ } func_8033056C(this); - func_8033A494(func_80330C48(this)); + modelRender_setAnimatedTexturesCacheId(actor_getAnimatedTexturesCacheId(this)); } void func_803255FC(Actor *this) { @@ -203,8 +203,8 @@ bool func_803257B4(ActorMarker *marker) { if ((actor->unk174 == 0.0f) || (actor->unk178 == 0.0f)) { model_bin = (BKModelBin *) assetcache_get(marker->modelId); vtx_list = (BKVertexList *)((s32)model_bin + model_bin->vtx_list_offset_10); - actor->unk174 = (f32) vtx_list->unk12 * actor->scale; - actor->unk178 = (f32) vtx_list->unk16 * actor->scale; + actor->unk174 = (f32) vtx_list->local_norm * actor->scale; + actor->unk178 = (f32) vtx_list->global_norm * actor->scale; assetcache_release(model_bin); } func_8033A4A0(marker->modelId, actor->unk174, actor->unk178); @@ -2001,11 +2001,11 @@ void func_8032AB84(Actor *arg0) { if (arg0->unk14C[var_s0] == NULL) { switch (var_s0) { /* irregular */ case 0: - arg0->unk14C[0] = vtxList_clone(func_8033A148(func_80330DE4(marker))); + arg0->unk14C[0] = vtxList_clone(model_getVtxList(func_80330DE4(marker))); break; case 1: - arg0->unk14C[1] = (arg0->unk17C_31) ? func_8033A148(func_80330DE4(marker)) - : vtxList_clone(func_8033A148(func_80330DE4(marker))); + arg0->unk14C[1] = (arg0->unk17C_31) ? model_getVtxList(func_80330DE4(marker)) + : vtxList_clone(model_getVtxList(func_80330DE4(marker))); break; } } diff --git a/src/core2/code_A5BC0.c b/src/core2/code_A5BC0.c index 28124623..52a7d759 100644 --- a/src/core2/code_A5BC0.c +++ b/src/core2/code_A5BC0.c @@ -6,7 +6,7 @@ extern int func_802E74A0(f32[3], f32, s32, s32); extern s32 func_802E9118(BKCollisionList * collision_list, BKVertexList *vtx_list, f32 arg2[3], s32 arg3, f32 arg4, f32 arg5[3], f32 arg6[3], f32 arg7, f32 arg8[3], s32 arg9, s32 argA); -extern f32 func_802EC920(BKVertexList *); +extern f32 vtxList_getGlobalNorm(BKVertexList *); extern void spawnQueue_func_802C39D4(void); extern bool func_80340020(s32, f32[3], f32[3], f32, s32, BKVertexList *, f32[3], f32[3]); extern void func_80340200(s32, f32[3], f32[3], f32, s32, s32, BKVertexList *, s32); @@ -1380,7 +1380,7 @@ void func_803305AC(void){ modelCache[i].modelPtr = NULL; modelCache[i].unk4 = 0; modelCache[i].unk8 = 0; - modelCache[i].unkC = 0; + modelCache[i].animated_texture_cache_id = 0; } D_80383444 = 0; } @@ -1443,10 +1443,10 @@ void func_803308A0(void) { } var_s0 = &modelCache[i]; - var_a1 = var_s0->unkC; + var_a1 = var_s0->animated_texture_cache_id; if (var_a1) { - func_80349CD8(var_a1); - modelCache[i].unkC = 0; + AnimTextureListCache_freeList(var_a1); + modelCache[i].animated_texture_cache_id = 0; } } @@ -1500,9 +1500,9 @@ BKModelBin *func_80330B1C(ActorMarker *this){ if((modelInfo = &modelCache[thisActor->modelCacheIndex])->modelPtr == NULL){ model = assetcache_get(this->modelId); modelInfo->modelPtr = model; - if(func_8033A110(model)){ - modelInfo->unkC = func_80349C3C(); - func_80349D00(modelInfo->unkC, func_8033A110(modelInfo->modelPtr)); + if(model_getAnimTextureList(model)){ + modelInfo->animated_texture_cache_id = AnimTextureListCache_newList(); + AnimTextureListCache_at(modelInfo->animated_texture_cache_id, model_getAnimTextureList(modelInfo->modelPtr)); } func_8032ACA8(thisActor); } @@ -1514,9 +1514,9 @@ BKModelBin *func_80330B1C(ActorMarker *this){ return modelInfo->modelPtr; } -s32 func_80330C48(Actor *actor){ +s32 actor_getAnimatedTexturesCacheId(Actor *actor){ ModelCache *model_cache_ptr = &modelCache[actor->modelCacheIndex]; - return model_cache_ptr->unkC; + return model_cache_ptr->animated_texture_cache_id; } BKVertexList *func_80330C74(Actor *actor){ @@ -1528,7 +1528,7 @@ BKVertexList *func_80330C74(Actor *actor){ if(actor->unkF4_30 && actor->unk14C[actor->unkF4_29]){ return actor->unk14C[actor->unkF4_29]; }else{ - return func_8033A148(model_cache_ptr->modelPtr); + return model_getVtxList(model_cache_ptr->modelPtr); } } @@ -1540,7 +1540,7 @@ BKVertexList *func_80330CFC(Actor *this, s32 arg1){ } if(this->unkF4_30 && this->unk14C[this->unkF4_29 ^ arg1] != NULL) return this->unk14C[this->unkF4_29 ^ arg1]; - return func_8033A148(model_cache_ptr->modelPtr); + return model_getVtxList(model_cache_ptr->modelPtr); } BKVertexList * func_80330DA4(Actor *this){ @@ -1696,7 +1696,7 @@ s32 func_803311D4(Cube *arg0, f32 *arg1, f32 *arg2, f32 *arg3, u32 arg4) { if (!var_s1->markerFlag && var_s1->unk8_1 && var_s1->unk8_4) { //ModelProp var_s0 = func_8030A4B4(((u32)var_s1->modelProp.unk0 >> 0x4)); if ((var_s0 != NULL) || (func_8028F280() && ((var_s0 = func_8030A428(((u32)var_s1->modelProp.unk0 >> 0x4))) != NULL))) { - temp_s2 = func_8033A084(var_s0); + temp_s2 = model_getCollisionList(var_s0); if (temp_s2 != 0) { spAC[0] = (f32) var_s1->modelProp.unk4[0]; spAC[1] = (f32) var_s1->modelProp.unk4[1]; @@ -1704,7 +1704,7 @@ s32 func_803311D4(Cube *arg0, f32 *arg1, f32 *arg2, f32 *arg3, u32 arg4) { spA0[0] = 0.0f; spA0[1] = (f32) (var_s1->modelProp.unk0_15 * 2); spA0[2] = (f32) (var_s1->modelProp.unk0_7 * 2); - var_v0 = func_802E805C(temp_s2, func_8033A148(var_s0), spAC, spA0, (f32)var_s1->modelProp.unkA / 100.0, arg1, arg2, arg3, arg4); + var_v0 = func_802E805C(temp_s2, model_getVtxList(var_s0), spAC, spA0, (f32)var_s1->modelProp.unkA / 100.0, arg1, arg2, arg3, arg4); if (var_v0 != 0) { var_s6 = var_v0; } @@ -1718,7 +1718,7 @@ s32 func_803311D4(Cube *arg0, f32 *arg1, f32 *arg2, f32 *arg3, u32 arg4) { } if(var_a0 != NULL || (func_8028F280() && (var_a0 = func_80330B1C(var_s1->actorProp.marker), TRUE))){ - temp_s0 = func_8033A084(var_a0); + temp_s0 = model_getCollisionList(var_a0); if (temp_s0 != 0) { temp_s2_2 = marker_getActor(var_s1->actorProp.marker); temp_a1 = func_80330C74(temp_s2_2); @@ -1794,7 +1794,7 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s { continue; } - temp_v0_3 = func_8033A084(temp_v0_2); + temp_v0_3 = model_getCollisionList(temp_v0_2); if (temp_v0_3 == 0) { continue; @@ -1806,7 +1806,7 @@ 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, func_8033A148(temp_v0_2), spBC, new_var, (f32) (((f32) var_s0->modelProp.unkA) / 100.0), arg1, arg2, arg3, arg4, arg5, flags); + 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); if (var_v0 != 0) { spD8 = var_v0; @@ -1821,7 +1821,7 @@ s32 func_80331638(Cube *cube, f32 arg1[3], f32 arg2[3], f32 arg3, f32 arg4[3], s { continue; } - temp_v0_2 = func_8033A084(pad9C); + temp_v0_2 = model_getCollisionList(pad9C); if (temp_v0_2 == 0) { continue; @@ -1892,7 +1892,7 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a if (1) { } if (1) { } if (1) { } temp_v0_2 = new_var; if (temp_v0_2 != 0){ - temp_v0_3 = func_8033A084(temp_v0_2); + temp_v0_3 = model_getCollisionList(temp_v0_2); if (temp_v0_3 != 0){ spAC[0] = (f32) mProp->unk4[0]; spAC[1] = (f32) mProp->unk4[1]; @@ -1901,7 +1901,7 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a spA0[1] = (f32) (mProp->unk0_15 * 2); temp_v0_2 = temp_v0_2; spA0[2] = (f32) (mProp->unk0_7 * 2); - var_v0 = func_802E9DD8(temp_v0_3, func_8033A148(temp_v0_2), spAC, spA0, ((f32) mProp->unkA) / 100.0, arg1, arg2, arg3, arg4); + var_v0 = func_802E9DD8(temp_v0_3, model_getVtxList(temp_v0_2), spAC, spA0, ((f32) mProp->unkA) / 100.0, arg1, arg2, arg3, arg4); if (var_v0 != 0) var_s7 = var_v0; } @@ -1913,7 +1913,7 @@ BKCollisionTri *func_803319C0(Cube *arg0, f32 arg1[3], f32 arg2, s32 arg3, f32 a temp_v0_2 = func_80330DE4(aProp->marker); if (temp_v0_2 != 0) { - new_var = func_8033A084(temp_v0_2); + new_var = model_getCollisionList(temp_v0_2); if (new_var != 0) { @@ -1993,7 +1993,7 @@ f32 func_80331E64(ActorMarker *marker) { f32 func_80331F1C(Prop *arg0){ - return func_802EC920(func_8033A148(func_8030A428(arg0->modelProp.unk0_31))); + return vtxList_getGlobalNorm(model_getVtxList(func_8030A428(arg0->modelProp.unk0_31))); } f32 func_80331F54(ActorMarker *marker) { @@ -2005,7 +2005,7 @@ f32 func_80331F54(ActorMarker *marker) { if (model == NULL) { return 1.0f; } - func_802EC930(func_8033A148(model), model_center, &sp34); + vtxList_getCenterAndNorm(model_getVtxList(model), model_center, &sp34); if (marker->unk3E_0) { model_center[0] = model_center[0] * marker_getActor(marker)->scale;\ model_center[1] = model_center[1] * marker_getActor(marker)->scale;\ diff --git a/src/core2/code_AC520.c b/src/core2/code_AC520.c index ab77304a..36413ebd 100644 --- a/src/core2/code_AC520.c +++ b/src/core2/code_AC520.c @@ -4,7 +4,7 @@ extern void func_80252CC4(f32[3], f32[3], f32, f32[3]); -extern f32 func_802EC920(BKVertexList *arg0); +extern f32 vtxList_getGlobalNorm(BKVertexList *arg0); extern void func_803334B0(f32 position[3], f32 rotation[3], f32 scale, f32[3], f32); void func_80333918(void); @@ -232,7 +232,7 @@ void func_80333D48(BKVertexList *arg0, f32 position[3], f32 rotation[3], f32 sca Struct_core2_AC520_0 *struct_ptr; f32 temp_f0; - func_803334B0(position, rotation, scale, arg4, func_802EC920(arg0)); + func_803334B0(position, rotation, scale, arg4, vtxList_getGlobalNorm(arg0)); if (D_80383570.unk44 == (&D_80383570.unk4[0])) { vtxList_recolor(arg0, &D_8036F970); return; diff --git a/src/core2/code_AD5B0.c b/src/core2/code_AD5B0.c index 24ef9fa2..bbe7f627 100644 --- a/src/core2/code_AD5B0.c +++ b/src/core2/code_AD5B0.c @@ -180,7 +180,7 @@ void func_80334910(void) { func_8024F7C4(func_803226E8(D_803835D0.map_4)); } func_80244B3C(); - func_80349C8C(); + AnimTextureListCache_free(); func_80322FDC(); func_8033BD6C(); func_80255198();//heap_flush_free_queue @@ -203,7 +203,7 @@ void func_80334B20(enum map_e arg0, s32 arg1, s32 arg2) { func_8024F764(func_803226E8(D_803835D0.map_4)); } func_80320B84(); - func_80349CB0(); + AnimTextureListCache_init(); func_8034C97C(); func_8030A078(); func_8031B718(); @@ -343,7 +343,7 @@ s32 func_80334ECC(void) { if (mapSpecificFlags_validateCRC1() == 0) { func_8028FCBC(); } - func_80349D60(); + AnimTextureListCache_update(); func_80350CA4(); func_8031B65C(); func_80310D2C(); diff --git a/src/core2/code_B8080.c b/src/core2/code_B8080.c index 56343d7d..fd8a5258 100644 --- a/src/core2/code_B8080.c +++ b/src/core2/code_B8080.c @@ -189,7 +189,7 @@ void func_8033F738(ActorMarker *arg0) { sp1C = func_80330B1C(arg0); sp18 = func_8033A0B0(sp1C); - arg0->unk48 = func_8033F5F8(sp18, func_8033A148(sp1C)); + arg0->unk48 = func_8033F5F8(sp18, model_getVtxList(sp1C)); } diff --git a/src/core2/code_C2C20.c b/src/core2/code_C2C20.c deleted file mode 100644 index c7431098..00000000 --- a/src/core2/code_C2C20.c +++ /dev/null @@ -1,88 +0,0 @@ -#include -#include "functions.h" -#include "variables.h" - -typedef struct{ - s16 unk0; - s16 unk2; - f32 unk4; -}Struct_core2_C2C20_1; - -typedef struct { - Struct_core2_C2C20_1 unk0[4]; - f32 unk20[4]; -}Struct_core2_C2C20_0; - -/* .bss */ -array(Struct_core2_C2C20_0) *D_803860C0; - -/* .code */ -bool func_80349BB0(s32 arg0, s32 arg1, s32 *arg2) { - Struct_core2_C2C20_0 * temp_v0; - - temp_v0 = (Struct_core2_C2C20_0 *)array_at(D_803860C0, arg0); - if (temp_v0->unk0[arg1].unk0 != 0) { - *arg2 = (s32)temp_v0->unk20[arg1] * temp_v0->unk0[arg1].unk0; - return TRUE; - } - return FALSE; -} - -s32 func_80349C3C(void){ - Struct_core2_C2C20_0 *phi_v0; - s32 sp20; - s32 i; - - phi_v0 = (Struct_core2_C2C20_0 *)func_802EDAA4(&D_803860C0, &sp20); - for(i = 0; i < 4; i++){ - phi_v0->unk0[i].unk0 = 0; - phi_v0->unk20[i] = 0.0f; - } - return sp20; -} - -void func_80349C8C(void){ - array_free(D_803860C0); -} - -void func_80349CB0(void){ - D_803860C0 = (array(Struct_core2_C2C20_0) *)array_new(sizeof(Struct_core2_C2C20_0), 2); -} - -void func_80349CD8(s32 arg0){ - func_802EDCDC(D_803860C0, arg0); -} - -void func_80349D00(s32 arg0, BKModelUnk2C *arg1){ - Struct_core2_C2C20_0 * sp1C; - s32 i; - - - sp1C = (Struct_core2_C2C20_0 *) array_at(D_803860C0, arg0); - memcpy(sp1C, arg1, 0x20); - for(i = 0; i < 4; i++){ - sp1C->unk20[i] = 0.0f; - } -} - -void func_80349D60(void) { - f32 temp_f20; - s32 phi_s1; - Struct_core2_C2C20_0 *phi_a0; - s32 i; - - temp_f20 = time_getDelta(); - for(phi_s1 = 1; phi_s1 unk0[i].unk0 != 0) { - phi_a0->unk20[i] += (phi_a0->unk0[i].unk4 * temp_f20); - if ((s32) phi_a0->unk20[i] >= phi_a0->unk0[i].unk2) { - phi_a0->unk20[i] -= phi_a0->unk0[i].unk2; - } - } - } - } - } -} diff --git a/src/core2/code_C9F00.c b/src/core2/code_C9F00.c index 79f1493d..66ed54dd 100644 --- a/src/core2/code_C9F00.c +++ b/src/core2/code_C9F00.c @@ -116,17 +116,17 @@ Actor *func_80350E90(ActorMarker *marker, Gfx **gfx, Mtx **mtx, Vtx **vtx) { s32 func_80350F7C(ActorMarker *marker, s32 arg1, f32 arg2[3], s32 arg3, s32 arg4) { s32 sp4C; Struct68s *temp_s0; - BKVertexList *sp44; - BKCollisionList *sp40; + BKVertexList *vtx_list; + BKCollisionList *colision_list; temp_s0 = &D_803861B0.unk4[marker->actrArrayIdx]; if ((temp_s0->unkC == NULL) || (temp_s0->unk30 & 1)) { return 0; } - sp40 = func_8033A084(temp_s0->unkC); - sp44 = func_8033A148(temp_s0->unkC); - sp4C = func_802E805C(sp40, sp44, temp_s0->unk14, temp_s0->unk20, temp_s0->unk2C, arg1, arg2, arg3, arg4); + colision_list = model_getCollisionList(temp_s0->unkC); + vtx_list = model_getVtxList(temp_s0->unkC); + sp4C = func_802E805C(colision_list, vtx_list, temp_s0->unk14, temp_s0->unk20, temp_s0->unk2C, arg1, arg2, arg3, arg4); if (sp4C != 0) { if (func_8029453C()) { D_80386180.unk20[0] = (s32) arg2[0]; @@ -148,24 +148,24 @@ s32 func_803510B4(ActorMarker *marker, s32 arg1, f32 arg2[3], f32 arg3, s32 arg4 if ((sp40->unkC == NULL) || (sp40->unk30 & 1)) { return 0; } - collision_list = func_8033A084(sp40->unkC); - vertex_list = func_8033A148(sp40->unkC); + collision_list = model_getCollisionList(sp40->unkC); + vertex_list = model_getVtxList(sp40->unkC); return func_802E9118(collision_list, vertex_list, sp40->unk14, sp40->unk20, sp40->unk2C, arg1, arg2, arg3, arg4, arg5, flagFliter); } s32 func_80351198(ActorMarker *marker, s32 arg1, f32 arg2, s32 arg3, s32 arg4) { s32 pad3C; Struct68s *sp38; - BKVertexList *sp34; - BKCollisionList *sp30; + BKVertexList *vtx_list; + BKCollisionList *collision_list; sp38 = &D_803861B0.unk4[marker->actrArrayIdx]; if ((sp38->unkC == NULL) || (sp38->unk30 & 1)) { return 0; } - sp30 = func_8033A084(sp38->unkC); - sp34 = func_8033A148(sp38->unkC); - return func_802E9DD8(sp30, sp34, sp38->unk14, sp38->unk20, sp38->unk2C, arg1, arg2, arg3, arg4); + collision_list = model_getCollisionList(sp38->unkC); + vtx_list = model_getVtxList(sp38->unkC); + return func_802E9DD8(collision_list, vtx_list, sp38->unk14, sp38->unk20, sp38->unk2C, arg1, arg2, arg3, arg4); } diff --git a/src/core2/fla.c b/src/core2/fla.c new file mode 100644 index 00000000..2cc137ea --- /dev/null +++ b/src/core2/fla.c @@ -0,0 +1,110 @@ +#include +#include "functions.h" +#include "variables.h" + +/* Freelist + This is a data container that contains arbitrary element types. + Every element in the array starts with an i16, that represents + either: + - it's own array index in the array if not free, OR + - the next free element's array index if this element is free. + + The 0th element in the array is never used, and contains the first + index in the freelist. +*/ + +/* .code */ +void freelist_clear(FLA *this){ + int i; + s32 ptr = (s32)(this + 1); + for(i = 1; i < this->elem_cnt; i++){ + *(s16 *)ptr = i; + ptr += this->elem_size; + } + *(s16 *)ptr = 0; +} + +void *freelist_at(FLA *this, s32 indx){ + return (void *)((s32)(this + 1) + indx*this->elem_size); +} + +s32 freelist_size(FLA *this){ + return this->elem_cnt; +} + +void *freelist_freeListPtr(FLA *this){ + return (void*)(this + 1); +} + +//returns next free element in the freelist +void *freelist_next(FLA **this_ptr, s32 *arg1) { + s32 new_cnt; + FLA *this; + s16 *first_ptr; + s16 *next_ptr; + s32 prev_cnt; + s32 i; + + this = *this_ptr; + first_ptr = (s16*)(this + 1); + if (*first_ptr == 0) { + prev_cnt = this->elem_cnt; + new_cnt = prev_cnt + 10; + this = realloc(this, (this->elem_size * new_cnt) + sizeof(FLA)); + first_ptr = (s16*)(this + 1); + this->elem_cnt = new_cnt; + *this_ptr = this; + for(i = new_cnt - 1, next_ptr = (s16*)((s32)(this + 1) + i * this->elem_size); i >= prev_cnt; i--){ + *next_ptr = *first_ptr; + *first_ptr = i; + next_ptr = (s16*)((s32)next_ptr - this->elem_size); + } + } + i = *first_ptr; + next_ptr = (s16*)((s32)first_ptr + (i * this->elem_size)); + *arg1 = i; + *first_ptr = *next_ptr; + return (void *) next_ptr; +} + +bool freelist_elementIsAlive(FLA *this, s32 index) +{ + u8 *tmp_v0 = (this + 1); + s16 *i_ptr; + u8 *new_var; + + new_var = (this + 1); + for (i_ptr = (s16 *) (this + 1); *i_ptr; i_ptr = (s16 *) (((*i_ptr) * this->elem_size) + (new_var = tmp_v0))) + { + if ((*i_ptr) == index) + { + return FALSE; + } + } + + return TRUE; +} +void freelist_free(FLA *this){ + free(this); +} + +FLA *freelist_new(s32 size, s32 cnt){ + FLA *this; + cnt++; + this = (FLA *) malloc(size*cnt + sizeof(FLA)); + this->elem_size = size; + this->elem_cnt = cnt; + freelist_clear(this); + return this; +} + +//removes first free element +void freelist_freeElement(FLA *this, s32 indx){ + void* *ptr_n = (void *)((s32)(this + 1) + indx*this->elem_size); + *(s16 *)ptr_n = *(s16 *)(this +1); + *(s16 *)(this +1) = indx; +} + +FLA *freelist_defrag(FLA *this){ + return (FLA *)defrag(this); +} diff --git a/src/core2/fx/common3score.c b/src/core2/fx/common3score.c index bb8820f5..a78fe81d 100644 --- a/src/core2/fx/common3score.c +++ b/src/core2/fx/common3score.c @@ -3,7 +3,7 @@ #include "variables.h" extern f32 func_8024DE1C(f32, f32, f32[3], f32[3]); -extern f32 func_802EC920(BKVertexList *); +extern f32 vtxList_getGlobalNorm(BKVertexList *); extern void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer); extern s16 D_803A5D00[2][0xF660]; @@ -207,7 +207,7 @@ void fxcommon3score_draw(enum item_e item_id, void *arg1, Gfx **gfx, Mtx **mtx, } sp68[0] += a1->unk4C; if(a1->unk6C == 0.0f){ - a1->unk6C = 1.1*(func_802EC920(func_8033A148(a1->model)) * a1->unk3C); + a1->unk6C = 1.1*(vtxList_getGlobalNorm(model_getVtxList(a1->model)) * a1->unk3C); } func_80253208(gfx, a1->unk30 - a1->unk6C, sp40 - a1->unk6C, 2*a1->unk6C, 2*a1->unk6C, D_803A5D00[func_8024BDA0()]); if(a1->anim_ctrl != NULL){ diff --git a/src/core2/gc/sky.c b/src/core2/gc/sky.c index 8a3e1199..e92eb58a 100644 --- a/src/core2/gc/sky.c +++ b/src/core2/gc/sky.c @@ -118,7 +118,7 @@ void sky_reset(void){ if(gcSky.sky_info->sky_list[i].model_id){ gcSky.model_bins[i] = assetcache_get(gcSky.sky_info->sky_list[i].model_id); if(func_8033A0B0(gcSky.model_bins[i])){ - gcSky.model[i] = func_8033F5F8(func_8033A0B0(gcSky.model_bins[i]), func_8033A148( gcSky.model_bins[i])); + gcSky.model[i] = func_8033F5F8(func_8033A0B0(gcSky.model_bins[i]), model_getVtxList( gcSky.model_bins[i])); func_8034C6DC(gcSky.model[i]); } } diff --git a/src/core2/mapModel.c b/src/core2/mapModel.c index ac09ce3c..e749f78c 100644 --- a/src/core2/mapModel.c +++ b/src/core2/mapModel.c @@ -10,7 +10,7 @@ extern s32 func_802EC394(BKModelUnk14List *arg0, s32 arg1, s32 arg2, f32 arg3, s extern void vtxList_getBounds_s32(BKVertexList *, s32[3], s32[3]); extern void func_802F7BC0(Gfx **, Mtx **, Vtx **); extern void func_8033A45C(s32, s32); - +extern struct5Bs *func_8034A348(struct5Bs *this); BKCollisionTri *func_80309B48(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 arg3) ; @@ -339,7 +339,7 @@ void mapModel_opa_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { modelRender_setDepthMode(MODEL_RENDER_DEPTH_FULL); temp_a0 = mapModel.unk0; if (temp_a0 != 0) { - func_8033A494(temp_a0); + modelRender_setAnimatedTexturesCacheId(temp_a0); } modelRender_setEnvColor(mapModel.env_red, mapModel.env_green, mapModel.env_blue, 0xFF); modelRender_draw(gfx, mtx, NULL, NULL, mapModel.description->scale, NULL, mapModel.model_bin_opa); @@ -359,7 +359,7 @@ void mapModel_xlu_draw(Gfx **gfx, Mtx **mtx, Vtx **vtx) { modelRender_setDepthMode(MODEL_RENDER_DEPTH_COMPARE); temp_a0 = mapModel.unk4; if (temp_a0 != 0) { - func_8033A494(temp_a0); + modelRender_setAnimatedTexturesCacheId(temp_a0); } modelRender_setEnvColor(mapModel.env_red, mapModel.env_green, mapModel.env_blue, 0xFF); modelRender_draw(gfx, mtx, NULL, NULL, mapModel.description->scale, NULL, mapModel.model_bin_xlu); @@ -399,7 +399,7 @@ struct5Bs *func_803097A0(void){ void mapModel_getCubeBounds(s32 min[3], s32 max[3]) { - vtxList_getBounds_s32(func_8033A148(mapModel.model_bin_opa), min, max); + vtxList_getBounds_s32(model_getVtxList(mapModel.model_bin_opa), min, max); func_8033ECD8(min, max, 1000); min[0] = min[0] + mapModel.description->unk6[0]; min[1] = min[1] + mapModel.description->unk6[1]; @@ -412,7 +412,7 @@ void mapModel_getCubeBounds(s32 min[3], s32 max[3]) { void mapModel_getOpaBounds(s32 min[3], s32 max[3]) { s32 i; - vtxList_getBounds_s32(func_8033A148(mapModel.model_bin_opa), min, max); + vtxList_getBounds_s32(model_getVtxList(mapModel.model_bin_opa), min, max); for(i = 0; i < 3; i++){ min[i] *= mapModel.scale; max[i] *= mapModel.scale; @@ -424,14 +424,14 @@ void mapModel_getBounds(s32 min[3], s32 max[3]) { s32 xlu_min[3]; s32 xlu_max[3]; - vtxList_getBounds_s32(func_8033A148(mapModel.model_bin_opa), min, max); + vtxList_getBounds_s32(model_getVtxList(mapModel.model_bin_opa), min, max); for(i = 0; i < 3; i++){ min[i] *= mapModel.scale; max[i] *= mapModel.scale; } if (mapModel.model_bin_xlu != NULL) { - vtxList_getBounds_s32(func_8033A148(mapModel.model_bin_xlu), xlu_min, xlu_max); + vtxList_getBounds_s32(model_getVtxList(mapModel.model_bin_xlu), xlu_min, xlu_max); for(j = 0; j < 3; j++){ if(xlu_min[j] < min[j]){ min[j] = xlu_min[j]; @@ -457,9 +457,9 @@ BKCollisionTri *func_80309B48(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 flagFil if ((flagFilter & 0x80001F00) == 0x80001F00) { sp2C = NULL; } else { - sp2C = func_802E76B0(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), arg0, arg1, arg2, flagFilter); + sp2C = func_802E76B0(mapModel.collision_opa, model_getVtxList(mapModel.model_bin_opa), arg0, arg1, arg2, flagFilter); } - temp_v0 = func_802E76B0(mapModel.collision_xlu, func_8033A148(mapModel.model_bin_xlu), arg0, arg1, arg2, flagFilter); + temp_v0 = func_802E76B0(mapModel.collision_xlu, model_getVtxList(mapModel.model_bin_xlu), arg0, arg1, arg2, flagFilter); if (temp_v0 != NULL) { mapModel.unk20 = (s32) mapModel.model_bin_xlu; return temp_v0; @@ -470,7 +470,7 @@ BKCollisionTri *func_80309B48(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 flagFil return sp2C; } else{ - sp2C = func_802E76B0(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), arg0, arg1, arg2, flagFilter); + sp2C = func_802E76B0(mapModel.collision_opa, model_getVtxList(mapModel.model_bin_opa), arg0, arg1, arg2, flagFilter); if (sp2C != NULL) { mapModel.unk20 = (s32) mapModel.model_bin_opa; } @@ -482,7 +482,7 @@ BKCollisionTri *func_80309C74(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 flagFil BKCollisionTri *sp2C; BKCollisionTri *phi_v0; - sp2C = func_802E76B0(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), arg0, arg1, arg2, flagFilter); + sp2C = func_802E76B0(mapModel.collision_opa, model_getVtxList(mapModel.model_bin_opa), arg0, arg1, arg2, flagFilter); if (sp2C != NULL) { *arg4 = mapModel.model_bin_opa; } @@ -490,19 +490,19 @@ BKCollisionTri *func_80309C74(f32 arg0[3], f32 arg1[3], f32 arg2[3], s32 flagFil return sp2C; } - phi_v0 = func_802E76B0(mapModel.collision_xlu, func_8033A148(mapModel.model_bin_xlu), arg0, arg1, arg2, flagFilter); + phi_v0 = func_802E76B0(mapModel.collision_xlu, model_getVtxList(mapModel.model_bin_xlu), arg0, arg1, arg2, flagFilter); if (phi_v0 != 0) { *arg4 = mapModel.model_bin_xlu; } return (phi_v0 != NULL) ? phi_v0 : sp2C; } -UNK_TYPE(s32) func_80309D58(UNK_TYPE(s32) arg0, UNK_TYPE(s32) arg1) { +bool func_80309D58(f32 arg0[3], UNK_TYPE(s32) arg1) { BKMeshList *temp_v0; temp_v0 = func_8033A12C(mapModel.model_bin_opa); if (temp_v0 != NULL) { - return func_802EC394(temp_v0, 0, 0, 1.0f, 0, arg0, arg1); + return func_802EC394(temp_v0, NULL, NULL, 1.0f, NULL, arg0, arg1); } return 0; } @@ -512,14 +512,14 @@ UNK_TYPE(s32) func_80309DBC(f32 currentPosition[3], f32 next_position[3], f32 ar s32 temp_v0_2; mapModel.unk20 = 0; - sp34 = func_802E8E88(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), currentPosition, next_position, arg2, arg3, arg4, arg5); + sp34 = func_802E8E88(mapModel.collision_opa, model_getVtxList(mapModel.model_bin_opa), currentPosition, next_position, arg2, arg3, arg4, arg5); if (sp34 != 0) { mapModel.unk20 = (s32) mapModel.model_bin_opa; } if (mapModel.collision_xlu == 0) { return sp34; } - temp_v0_2 = func_802E8E88(mapModel.collision_xlu, func_8033A148(mapModel.model_bin_xlu), currentPosition, next_position, arg2, arg3, arg4, arg5); + temp_v0_2 = func_802E8E88(mapModel.collision_xlu, model_getVtxList(mapModel.model_bin_xlu), currentPosition, next_position, arg2, arg3, arg4, arg5); if (temp_v0_2 != 0) { mapModel.unk20 = (s32) mapModel.model_bin_xlu; return temp_v0_2; @@ -531,11 +531,11 @@ UNK_TYPE(s32) func_80309EB0(f32 arg0[3], f32 arg1, f32 arg2[3], s32 arg3) { s32 sp24; s32 temp_v0_2; - sp24 = func_802E92AC(mapModel.collision_opa, func_8033A148(mapModel.model_bin_opa), arg0, arg1, arg2, arg3); + sp24 = func_802E92AC(mapModel.collision_opa, model_getVtxList(mapModel.model_bin_opa), arg0, arg1, arg2, arg3); if (mapModel.collision_xlu == 0) { return sp24; } - temp_v0_2 = func_802E92AC(mapModel.collision_xlu, func_8033A148(mapModel.model_bin_xlu), arg0, arg1, arg2, arg3); + temp_v0_2 = func_802E92AC(mapModel.collision_xlu, model_getVtxList(mapModel.model_bin_xlu), arg0, arg1, arg2, arg3); return (temp_v0_2 != 0) ? temp_v0_2 : sp24; } @@ -585,18 +585,18 @@ void func_8030A078(void) { mapModel.description = description; mapModel.scale = (f32) description->scale; mapModel.model_bin_opa = (BKModelBin *)assetcache_get(mapModel.description->opa_model_id); - mapModel.collision_opa = func_8033A084(mapModel.model_bin_opa); + mapModel.collision_opa = model_getCollisionList(mapModel.model_bin_opa); mapModel.unk20 = 0; if (mapModel.description->xlu_model_id != 0) { mapModel.model_bin_xlu = (BKModelBin *)assetcache_get(mapModel.description->xlu_model_id); - mapModel.collision_xlu = func_8033A084(mapModel.model_bin_xlu); + mapModel.collision_xlu = model_getCollisionList(mapModel.model_bin_xlu); } else { mapModel.model_bin_xlu = NULL; mapModel.collision_xlu = NULL; } sp24 = func_8033A0B0(mapModel.model_bin_opa); if (sp24 != NULL) { - mapModel.model_opa = func_8033F5F8(sp24, func_8033A148(mapModel.model_bin_opa)); + mapModel.model_opa = func_8033F5F8(sp24, model_getVtxList(mapModel.model_bin_opa)); } else { mapModel.model_opa = NULL; } @@ -612,7 +612,7 @@ void func_8030A078(void) { } if (sp24 != NULL) { - mapModel.model_xlu = func_8033F5F8(sp24, func_8033A148(mapModel.model_bin_xlu)); + mapModel.model_xlu = func_8033F5F8(sp24, model_getVtxList(mapModel.model_bin_xlu)); } else { mapModel.model_xlu = 0; } @@ -622,15 +622,15 @@ void func_8030A078(void) { mapModel.unk24 = func_8034A2C8(); func_80320B44(func_80309B48, func_80309DBC, func_80309EB0, func_80309794); - if (( mapModel.model_bin_opa != NULL) && (func_8033A110( mapModel.model_bin_opa) != NULL)) { - mapModel.unk0 = func_80349C3C(); - func_80349D00(mapModel.unk0, func_8033A110(mapModel.model_bin_opa)); + if (( mapModel.model_bin_opa != NULL) && (model_getAnimTextureList( mapModel.model_bin_opa) != NULL)) { + mapModel.unk0 = AnimTextureListCache_newList(); + AnimTextureListCache_at(mapModel.unk0, model_getAnimTextureList(mapModel.model_bin_opa)); } else { mapModel.unk0 = NULL; } - if ((mapModel.model_bin_xlu != NULL) && (func_8033A110(mapModel.model_bin_xlu) != 0)) { - mapModel.unk4 = func_80349C3C(); - func_80349D00(mapModel.unk4, func_8033A110(mapModel.model_bin_xlu)); + if ((mapModel.model_bin_xlu != NULL) && (model_getAnimTextureList(mapModel.model_bin_xlu) != 0)) { + mapModel.unk4 = AnimTextureListCache_newList(); + AnimTextureListCache_at(mapModel.unk4, model_getAnimTextureList(mapModel.model_bin_xlu)); } else{ mapModel.unk4 = NULL; diff --git a/src/core2/modelRender.c b/src/core2/modelRender.c index beabb569..24c70c9d 100644 --- a/src/core2/modelRender.c +++ b/src/core2/modelRender.c @@ -611,7 +611,7 @@ enum model_render_color_mode_e modelRenderColorMode; BKGfxList * modelRenderDisplayList; struct58s * D_8038371C; static BKTextureList * modelRenderTextureList; -s32 D_80383724; +s32 modelRenderAnimatedTexturesCacheId; static BKVertexList * modelRendervertexList; BKModelUnk20List * D_8038372C; struct58s * D_80383730; @@ -684,7 +684,7 @@ void modelRender_reset(void){ modelRenderDisplayList = NULL; D_8038371C = NULL; modelRenderTextureList = NULL; - D_80383724 = 0; + modelRenderAnimatedTexturesCacheId = 0; modelRendervertexList = NULL; D_8038372C = 0; modelRenderCallback.pre_method = NULL; @@ -1084,8 +1084,8 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 rotation if(model_bin){ verts = modelRendervertexList ? modelRendervertexList : (BKVertexList *)((s32)model_bin + model_bin->vtx_list_offset_10); - spD0 = verts->unk16; - spD4 = verts->unk12; + spD0 = verts->global_norm; + spD4 = verts->local_norm; } else{ spD0 = D_803837C8.unk8; @@ -1143,12 +1143,13 @@ BKModelBin *modelRender_draw(Gfx **gfx, Mtx **mtx, f32 position[3], f32 rotation gSPSegment((*gfx)++, 0x01, osVirtualToPhysical(&modelRendervertexList->vtx_18)); gSPSegment((*gfx)++, 0x02, osVirtualToPhysical(&modelRenderTextureList->tex_8[modelRenderTextureList->cnt_4])); - if(D_80383724){ + //segments 11 to 15 contain animated textures + if(modelRenderAnimatedTexturesCacheId){ int i_segment; s32 texture_offset; for(i_segment = 0; i_segment < 4; i_segment++){ - if(func_80349BB0(D_80383724, i_segment, &texture_offset)) + if(AnimTextureListCache_tryGetTextureOffset(modelRenderAnimatedTexturesCacheId, i_segment, &texture_offset)) gSPSegment((*gfx)++, 15 - i_segment, osVirtualToPhysical((u8*)&modelRenderTextureList->tex_8[modelRenderTextureList->cnt_4] + texture_offset)); } } @@ -1308,11 +1309,11 @@ s32 func_8033A070(BKModelBin *arg0){ return arg0->geo_typ_A; } -BKGfxList *func_8033A078(BKModelBin *arg0){ +BKGfxList *model_getDisplayList(BKModelBin *arg0){ return (BKGfxList *)((s32)arg0 + arg0->gfx_list_offset_C); } -BKCollisionList *func_8033A084(BKModelBin *arg0){ +BKCollisionList *model_getCollisionList(BKModelBin *arg0){ if(arg0 == NULL) return NULL; @@ -1344,14 +1345,14 @@ s32 func_8033A0F0(s32 arg0){ return D_80383658[arg0]; } -BKTextureList *model_getTextureList(BKModelBin *arg0){ - return (BKTextureList *)((s32)arg0 + arg0->texture_list_offset_8); +BKTextureList *model_getTextureList(BKModelBin *model_bin){ + return (BKTextureList *)((s32)model_bin + model_bin->texture_list_offset_8); } -void *func_8033A110(BKModelBin *arg0){ - if(arg0->unk2C == 0) +AnimTexture *model_getAnimTextureList(BKModelBin *model_bin){ + if(model_bin->animated_texture_list_offset == 0) return NULL; - return (void*)((s32)arg0 + arg0->unk2C); + return (void*)((s32)model_bin + model_bin->animated_texture_list_offset); } BKModelUnk14List *func_8033A12C(BKModelBin *this){ @@ -1360,7 +1361,7 @@ BKModelUnk14List *func_8033A12C(BKModelBin *this){ return (BKModelUnk14List *)((s32)this + this->unk14); } -BKVertexList *func_8033A148(BKModelBin *arg0){ +BKVertexList *model_getVtxList(BKModelBin *arg0){ return (BKVertexList *)((s32)arg0 + arg0->vtx_list_offset_10); } @@ -1503,8 +1504,8 @@ void modelRender_setTextureList(BKTextureList *textureList){ modelRenderTextureList = textureList; } -void func_8033A494(s32 arg0){ - D_80383724 = arg0; +void modelRender_setAnimatedTexturesCacheId(s32 arg0){ + modelRenderAnimatedTexturesCacheId = arg0; } void func_8033A4A0(enum asset_e modelId, f32 arg1, f32 arg2){ diff --git a/src/core2/nc/dynamicCamera.c b/src/core2/nc/dynamicCamera.c index 5b982cc8..85c4120d 100644 --- a/src/core2/nc/dynamicCamera.c +++ b/src/core2/nc/dynamicCamera.c @@ -114,30 +114,30 @@ bool func_802BC640(f32 arg0[3], f32 arg1[3], f32 arg2, s32 arg3) { s32 func_802BC84C(s32 arg0){ f32 sp74[3]; - f32 sp68[3]; - f32 sp5C[3]; - f32 sp50[3]; + f32 target_direction[3]; + f32 d_target[3]; + f32 player_position[3]; f32 sp44[3]; - f32 sp38[3]; + f32 camera_position[3]; f32 sp2C[3]; f32 sp20[3]; - f32 sp1C; + f32 target_distance; if(player_getTransformation() == TRANSFORM_3_PUMPKIN){ - player_getPosition(sp50); - sp50[1] += 76.0f; + player_getPosition(player_position); + player_position[1] += 76.0f; } else{ - func_8028EC64(sp50); + func_8028EC64(player_position); } - ncDynamicCamera_getPosition(sp38); - ml_vec3f_diff_copy(sp5C, sp50, sp38); - ml_vec3f_normalize_copy(sp68, sp5C); - ml_vec3f_copy(sp44, sp50); - sp1C = gu_sqrtf(sp5C[0]*sp5C[0] + sp5C[1]*sp5C[1] + sp5C[2]*sp5C[2]); - if (1500.0f < sp1C) { - ml_vec3f_scale_copy(sp5C, sp68, 1500.0f); - ml_vec3f_add(sp44, sp38, sp5C); + ncDynamicCamera_getPosition(camera_position); + ml_vec3f_diff_copy(d_target, player_position, camera_position); + ml_vec3f_normalize_copy(target_direction, d_target); + ml_vec3f_copy(sp44, player_position); + target_distance = gu_sqrtf(d_target[0]*d_target[0] + d_target[1]*d_target[1] + d_target[2]*d_target[2]); + if (1500.0f < target_distance) { + ml_vec3f_scale_copy(d_target, target_direction, 1500.0f); + ml_vec3f_add(sp44, camera_position, d_target); } switch(D_8037D9F6) { case 0: //802BC94C @@ -145,12 +145,12 @@ s32 func_802BC84C(s32 arg0){ break; case 1: //802BC95C - ml_vec3f_scale_copy(sp2C, sp68, 100.0f); + ml_vec3f_scale_copy(sp2C, target_direction, 100.0f); ml_vec3f_yaw_rotate_copy(sp2C, sp2C, -90.0f); break; case 2: //802BC984 - ml_vec3f_scale_copy(sp2C, sp68, 100.0f); + ml_vec3f_scale_copy(sp2C, target_direction, 100.0f); ml_vec3f_yaw_rotate_copy(sp2C, sp2C, 90.0f); break; @@ -165,11 +165,11 @@ s32 func_802BC84C(s32 arg0){ break; }//L802BC9D0 ml_vec3f_add(sp20, sp2C, sp44); - if (func_80320B98(sp38, sp20, sp74, 0x9E0000)) { + if (func_80320B98(camera_position, sp20, sp74, 0x9E0000)) { D_8037D9F6++; if (D_8037D9F6 >= 5) { D_8037D9F6 = 0; - return func_802BC640(sp50, sp68, sp1C, arg0); + return func_802BC640(player_position, target_direction, target_distance, arg0); } }else{ D_8037D9F6 = 0; diff --git a/src/core2/sla.c b/src/core2/sla.c deleted file mode 100644 index d3cf76f7..00000000 --- a/src/core2/sla.c +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include "functions.h" -#include "variables.h" - -// Static Length Array - -/* .code */ -void array_clear(SLA *this){ - int i; - s32 ptr = (s32)(this + 1); - for(i = 1; i < this->elem_cnt; i++){ - *(s16 *)ptr = i; - ptr += this->elem_size; - } - *(s16 *)ptr = 0; -} - -void *array_at(SLA *this, s32 indx){ - return (void *)((s32)(this + 1) + indx*this->elem_size); -} - -s32 array_size(SLA *this){ - return this->elem_cnt; -} - -void *array_begin(SLA *this){ - return (void*)(this + 1); -} - -void *func_802EDAA4(SLA **this, s32 *arg1) { - s32 new_cnt; - SLA *var_s0; - s16 *first_ptr; - s16 *i_ptr; - s32 prev_cnt; - s32 i; - - var_s0 = *this; - first_ptr = (s16*)var_s0->unk4; - if (*first_ptr == 0) { - prev_cnt = var_s0->elem_cnt; - new_cnt = prev_cnt + 10; - var_s0 = realloc(var_s0, (var_s0->elem_size * new_cnt) + sizeof(SLA)); - first_ptr = (s16*)var_s0->unk4; - var_s0->elem_cnt = new_cnt; - *this = var_s0; - for(i = new_cnt - 1, i_ptr = (s16*)&var_s0->unk4[i * var_s0->elem_size]; i >= prev_cnt; i--){ - *i_ptr = *first_ptr; - *first_ptr = i; - i_ptr = (s16*)((s32)i_ptr - var_s0->elem_size); - } - } - i = *first_ptr; - i_ptr = (s16*)((s32)first_ptr + (i * var_s0->elem_size)); - *arg1 = i; - *first_ptr = *i_ptr; - return (void *) i_ptr; -} - -int func_802EDC18(SLA *this, s32 arg1) -{ - u8 *tmp_v0 = this->unk4; - s16 *i_ptr; - u8 *new_var; - new_var = this->unk4; - for (i_ptr = (s16 *) new_var; *i_ptr; i_ptr = (s16 *) (((*i_ptr) * this->elem_size) + (new_var = tmp_v0))) - { - if ((*i_ptr) == arg1) - { - return 0; - } - } - - return 1; -} -void array_free(SLA *this){ - free(this); -} - -SLA *array_new(s32 size, s32 cnt){ - SLA *this; - cnt++; - this = (SLA *) malloc(size*cnt + sizeof(SLA)); - this->elem_size = size; - this->elem_cnt = cnt; - array_clear(this); - return this; -} - -void func_802EDCDC(SLA *this, s32 indx){ - void* *ptr_n = (void *)((s32)(this + 1) + indx*this->elem_size); - *(s16 *)ptr_n = *(s16 *)(this +1); - *(s16 *)(this +1) = indx; -} - -SLA *array_defrag(SLA *this){ - return (SLA *)defrag(this); -} diff --git a/symbol_addrs.us.v10.txt b/symbol_addrs.us.v10.txt index 3e9a21a4..1f655e20 100644 --- a/symbol_addrs.us.v10.txt +++ b/symbol_addrs.us.v10.txt @@ -102,6 +102,7 @@ levelSpecificFlags_validateCRC1 = 0x8032204C; marker_despawn = 0x803282F4; actor_copy = 0x80329C40; actors_appendToSavestate = 0x80329CBC; +model_getVtxList = 0x8033A148; strIToA = 0x8033D884; strlen = 0x8033DA80; time_getDelta = 0x8033DD9C;