From bbe9f8d3845f3bb9c865330e50d8ecac60f5d7c9 Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Thu, 8 Dec 2022 17:17:59 -0600 Subject: [PATCH] labeling pfsManager functions --- include/functions.h | 4 +- src/MMM/code_3D50.c | 4 +- src/TTC/code_3E30.c | 10 +-- src/core1/code_0.c | 4 +- src/core1/code_10A00.c | 166 ++++++++++++++++++------------------- src/core1/code_11AC0.c | 2 +- src/core1/code_12F10.c | 2 +- src/core1/code_18110.c | 4 +- src/core1/code_1D00.c | 72 ++++++++-------- src/core1/code_8C50.c | 8 +- src/core2/code_62FD0.c | 17 ++-- src/core2/code_AD5B0.c | 2 +- src/core2/code_AE290.c | 2 +- src/core2/code_B3A80.c | 177 ++++++++++++++++++++-------------------- src/core2/code_B8080.c | 24 +++--- src/core2/code_C4320.c | 4 +- src/core2/code_C4F40.c | 2 +- src/core2/code_C5440.c | 4 +- src/core2/code_C5AF0.c | 2 +- src/core2/code_C5CC0.c | 2 +- src/core2/code_C5F00.c | 4 +- src/core2/code_C61C0.c | 2 +- src/core2/code_C62B0.c | 18 ++-- src/core2/code_C76D0.c | 4 +- src/core2/code_C7CC0.c | 4 +- src/core2/code_C8230.c | 2 +- src/core2/code_C8360.c | 2 +- src/core2/code_C8490.c | 2 +- src/lair/code_5ED0.c | 8 +- symbol_addrs.us.v10.txt | 4 +- 30 files changed, 281 insertions(+), 281 deletions(-) diff --git a/include/functions.h b/include/functions.h index a80dcdff..840e855f 100644 --- a/include/functions.h +++ b/include/functions.h @@ -154,7 +154,7 @@ VLA * vector_defrag(VLA *this); void actor_collisionOff(Actor *); -void *assetcache_get(s32 arg0); +void *assetcache_get(enum asset_e assetId); Actor *actor_new(s32 (*position)[3], s32 yaw, ActorInfo *actorInfo, u32 flags); Actor *func_802C8A54(s32 position[3], s32 yaw, ActorInfo* actorInfo, u32 flags); @@ -256,7 +256,7 @@ void particleEmitter_setSpawnInterval(ParticleEmitter *, f32); int func_8024DC04(f32, f32, f32); void func_8024E3A8(f32 [3], f32); -OSMesgQueue *func_8024F344(void); +OSMesgQueue *pfsManager_getFrameReplyQ(void); void ml_vec3f_clear(f32 dst[3]); void ml_vec3f_roll_rotate_copy(f32[3], f32[3], f32); diff --git a/src/MMM/code_3D50.c b/src/MMM/code_3D50.c index 6643d7c1..80d5266d 100644 --- a/src/MMM/code_3D50.c +++ b/src/MMM/code_3D50.c @@ -165,10 +165,10 @@ void func_8038A750(void){ for(v1 = &D_8038C1F0[0]; v1->unk0 != 0; v1++){ v1->unk4 += f20; if(v1->unk3 == 1){ - func_8033F120(MMM_D_8038C510.unk0, v1->unk0, MMM_func_8038A2F0, v1); + BKModel_transformMesh(MMM_D_8038C510.unk0, v1->unk0, MMM_func_8038A2F0, v1); } else if(v1->unk3 == 3){ - func_8033F120(MMM_D_8038C510.unk0, v1->unk0, func_8038A58C, v1); + BKModel_transformMesh(MMM_D_8038C510.unk0, v1->unk0, func_8038A58C, v1); } } } diff --git a/src/TTC/code_3E30.c b/src/TTC/code_3E30.c index 8f754142..1abab3f0 100644 --- a/src/TTC/code_3E30.c +++ b/src/TTC/code_3E30.c @@ -221,11 +221,11 @@ void func_8038AA2C(void) { for(var_s0 = D_8038C984; var_s0->unk0 != 0; var_s0++){ var_s0->unk4 += temp_f20; if (var_s0->unk3 == 1) { - func_8033F120(D_8038D720.unk0, var_s0->unk0, func_8038A37C, (s32)var_s0); + BKModel_transformMesh(D_8038D720.unk0, var_s0->unk0, func_8038A37C, (s32)var_s0); } else if (var_s0->unk3 == 3) { - func_8033F120(D_8038D720.unk0, var_s0->unk0, func_8038A618, (s32)var_s0); + BKModel_transformMesh(D_8038D720.unk0, var_s0->unk0, func_8038A618, (s32)var_s0); } else if (var_s0->unk3 == 5) { - func_8033F120(D_8038D720.unk0, var_s0->unk0, func_8038A7DC, (s32)var_s0); + BKModel_transformMesh(D_8038D720.unk0, var_s0->unk0, func_8038A7DC, (s32)var_s0); } } } @@ -439,7 +439,7 @@ void func_8038B094(void){ if( jiggyscore_isCollected(JIGGY_10_TTC_SANDCASTLE) && !func_803203FC(2) ){ - func_8033F120(D_8038D720.unk4, 0x3C, func_8038A23C, 0); + BKModel_transformMesh(D_8038D720.unk4, 0x3C, func_8038A23C, 0); D_8038D720.unk8 = 3; }//L8038B2CC func_8038AB44(); @@ -491,7 +491,7 @@ void func_8038B2F0(void) { } } else if (D_8038D720.unk8 == 2) { D_8038D720.unkC = (f32) (D_8038D720.unkC + sp24); - func_8033F120(D_8038D720.unk4, 0x3C, func_8038A220, 0); + BKModel_transformMesh(D_8038D720.unk4, 0x3C, func_8038A220, 0); if (D_8038D720.unkC > 4.0f) { D_8038D720.unk8 = 3; func_8030E2C4(D_8038D720.unkA); diff --git a/src/core1/code_0.c b/src/core1/code_0.c index 0275fbc7..b2c6a2a0 100644 --- a/src/core1/code_0.c +++ b/src/core1/code_0.c @@ -110,9 +110,9 @@ void func_8023DC0C(void){ func_8025AFB0(); func_8033EF58(); assetCache_init(); - func_8024F05C(); + pfsManager_init(); func_80250C84(); - func_8023FB1C(); + audioManager_init(); func_8025425C(); func_80257424(); gctransition_reset(); diff --git a/src/core1/code_10A00.c b/src/core1/code_10A00.c index 11459a19..0d8dba25 100644 --- a/src/core1/code_10A00.c +++ b/src/core1/code_10A00.c @@ -42,21 +42,21 @@ s32 D_80275D38 = 0; /* .bss */ UNK_TYPE(s32) D_802810E0[4][5]; -u8 D_80281130; +u8 pfsManagerBitPattern; Struct_core1_10A00_0 D_80281138[4]; Struct_core1_10A00_0 D_80281218; Struct_core1_10A00_1 D_80281250[4]; -OSMesg D_802812B0; -OSMesg D_802812B4; -OSContPad D_802812B8[4]; +OSMesg pfsManagerContPollingMsqBuf; +OSMesg pfsManagerContReplyMsgBuf; +OSContPad pfsManagerContPadData[4]; OSContPad D_802812D0; -OSMesgQueue D_802812D8; -OSMesgQueue D_802812F0; +OSMesgQueue pfsManagerContPollingMsqQ; +OSMesgQueue pfsManagerContReplyMsgQ; f32 D_80281308[4]; -OSContStatus D_80281318; +OSContStatus pfsManagerContStatus; u8 pad_D_80281320[0x8]; -volatile s32 D_80281328; -OSThread D_80281330; +volatile s32 pfsManagerBusy; +OSThread pfsManagerThread; u8 D_802814E0[0x200]; f32 D_802816E0; OSMesgQueue D_802816E8; @@ -152,8 +152,8 @@ void func_8024E71C(s32 controller_index, f32 dst[2]){ dst[1] = D_80281250[controller_index].joystick[1]; } else{ - dst[0] = func_8024E420(D_802812B8[controller_index].stick_x, 7, 0x3B); - dst[1] = func_8024E420(D_802812B8[controller_index].stick_y, 7, 0x3D); + dst[0] = func_8024E420(pfsManagerContPadData[controller_index].stick_x, 7, 0x3B); + dst[1] = func_8024E420(pfsManagerContPadData[controller_index].stick_y, 7, 0x3D); } } @@ -173,9 +173,9 @@ void func_8024E7C8(void){ func_802E4384(); osSetThreadPri(NULL, 0x29); - D_802812D0.stick_x = D_802812B8[0].stick_x; - D_802812D0.stick_y = D_802812B8[0].stick_y; - D_802812D0.button = D_802812B8[0].button; + D_802812D0.stick_x = pfsManagerContPadData[0].stick_x; + D_802812D0.stick_y = pfsManagerContPadData[0].stick_y; + D_802812D0.button = pfsManagerContPadData[0].button; if( getGameMode() == GAME_MODE_6_FILE_PLAYBACK || getGameMode() == GAME_MODE_7_ATTRACT_DEMO || getGameMode() == GAME_MODE_8_BOTTLES_BONUS @@ -189,7 +189,7 @@ void func_8024E7C8(void){ if(D_802816E0 < 1.0 || getGameMode() == GAME_MODE_9_BANJO_AND_KAZOOIE){ s0 = 0; } - temp_t6 = demo_readInput(&D_802812B8, &sp5C) == 0; + temp_t6 = demo_readInput(&pfsManagerContPadData, &sp5C) == 0; if(D_802812D0.button & s0 || temp_t6){ if(D_802812D0.button & s0){ func_803204E4(0x64, 1); @@ -206,15 +206,15 @@ void func_8024E7C8(void){ randf(); // var_s0_2 = &D_80281250; -// var_s1 = &D_802812B8 +// var_s1 = &pfsManagerContPadData for(i = 0; i < 4; i++){ // temp_t5 = var_s1->unk0; // temp_t1 = temp_t5 & 0x20; - if ((D_802812B8[i].button & 0x20) && (D_802812B8[i].button & 0x10)) { - D_802810E0[i][0] = (D_802812B8[i].button & 0x0004) ? D_802810E0[i][0] + 1 : 0; - D_802810E0[i][1] = (D_802812B8[i].button & 0x2000) ? D_802810E0[i][1] + 1 : 0; - D_802810E0[i][2] = (D_802812B8[i].button & 0x8000) ? D_802810E0[i][2] + 1 : 0; - D_802810E0[i][3] = (D_802812B8[i].button & 0x4000) ? D_802810E0[i][3] + 1 : 0; + if ((pfsManagerContPadData[i].button & 0x20) && (pfsManagerContPadData[i].button & 0x10)) { + D_802810E0[i][0] = (pfsManagerContPadData[i].button & 0x0004) ? D_802810E0[i][0] + 1 : 0; + D_802810E0[i][1] = (pfsManagerContPadData[i].button & 0x2000) ? D_802810E0[i][1] + 1 : 0; + D_802810E0[i][2] = (pfsManagerContPadData[i].button & 0x8000) ? D_802810E0[i][2] + 1 : 0; + D_802810E0[i][3] = (pfsManagerContPadData[i].button & 0x4000) ? D_802810E0[i][3] + 1 : 0; D_802810E0[i][4] = (D_802812D0.button & 0x4000) ? D_802810E0[i][4] + 1 : 0; for(j = 0; j < 0xE; j++){ ((s32*)&D_80281138[i])[j] = 0; @@ -239,22 +239,22 @@ void func_8024E7C8(void){ D_802810E0[i][j] = 0; } - D_80281138[i].face_button[0] = (D_802812B8[i].button & 0x8000) ? D_80281138[i].face_button[0] + 1 : 0; - D_80281138[i].face_button[1] = (D_802812B8[i].button & 0x4000) ? D_80281138[i].face_button[1] + 1 : 0; - D_80281138[i].face_button[2] = (D_802812B8[i].button & 0x0002) ? D_80281138[i].face_button[2] + 1 : 0; - D_80281138[i].face_button[3] = (D_802812B8[i].button & 0x0004) ? D_80281138[i].face_button[3] + 1 : 0; - D_80281138[i].face_button[4] = (D_802812B8[i].button & 0x0008) ? D_80281138[i].face_button[4] + 1 : 0; - D_80281138[i].face_button[5] = (D_802812B8[i].button & 0x0001) ? D_80281138[i].face_button[5] + 1 : 0; + D_80281138[i].face_button[0] = (pfsManagerContPadData[i].button & 0x8000) ? D_80281138[i].face_button[0] + 1 : 0; + D_80281138[i].face_button[1] = (pfsManagerContPadData[i].button & 0x4000) ? D_80281138[i].face_button[1] + 1 : 0; + D_80281138[i].face_button[2] = (pfsManagerContPadData[i].button & 0x0002) ? D_80281138[i].face_button[2] + 1 : 0; + D_80281138[i].face_button[3] = (pfsManagerContPadData[i].button & 0x0004) ? D_80281138[i].face_button[3] + 1 : 0; + D_80281138[i].face_button[4] = (pfsManagerContPadData[i].button & 0x0008) ? D_80281138[i].face_button[4] + 1 : 0; + D_80281138[i].face_button[5] = (pfsManagerContPadData[i].button & 0x0001) ? D_80281138[i].face_button[5] + 1 : 0; - D_80281138[i].side_button[0] = (D_802812B8[i].button & 0x2000) ? D_80281138[i].side_button[0] + 1 : 0; - D_80281138[i].side_button[1] = (D_802812B8[i].button & 0x0020) ? D_80281138[i].side_button[1] + 1 : 0; - D_80281138[i].side_button[2] = (D_802812B8[i].button & 0x0010) ? D_80281138[i].side_button[2] + 1 : 0; + D_80281138[i].side_button[0] = (pfsManagerContPadData[i].button & 0x2000) ? D_80281138[i].side_button[0] + 1 : 0; + D_80281138[i].side_button[1] = (pfsManagerContPadData[i].button & 0x0020) ? D_80281138[i].side_button[1] + 1 : 0; + D_80281138[i].side_button[2] = (pfsManagerContPadData[i].button & 0x0010) ? D_80281138[i].side_button[2] + 1 : 0; - D_80281138[i].unk24[0] = (D_802812B8[i].button & 0x0800) ? D_80281138[i].unk24[0] + 1 : 0; - D_80281138[i].unk24[1] = (D_802812B8[i].button & 0x0400) ? D_80281138[i].unk24[1] + 1 : 0; - D_80281138[i].unk24[2] = (D_802812B8[i].button & 0x0200) ? D_80281138[i].unk24[2] + 1 : 0; - D_80281138[i].unk24[3] = (D_802812B8[i].button & 0x0100) ? D_80281138[i].unk24[3] + 1 : 0; - D_80281138[i].start_button = (D_802812B8[i].button & 0x1000) ? D_80281138[i].start_button + 1 : 0; + D_80281138[i].unk24[0] = (pfsManagerContPadData[i].button & 0x0800) ? D_80281138[i].unk24[0] + 1 : 0; + D_80281138[i].unk24[1] = (pfsManagerContPadData[i].button & 0x0400) ? D_80281138[i].unk24[1] + 1 : 0; + D_80281138[i].unk24[2] = (pfsManagerContPadData[i].button & 0x0200) ? D_80281138[i].unk24[2] + 1 : 0; + D_80281138[i].unk24[3] = (pfsManagerContPadData[i].button & 0x0100) ? D_80281138[i].unk24[3] + 1 : 0; + D_80281138[i].start_button = (pfsManagerContPadData[i].button & 0x1000) ? D_80281138[i].start_button + 1 : 0; if(i == 0){ D_80281218.face_button[0] = (D_802812D0.button & 0x8000) ? D_80281218.face_button[0] + 1 : 0; @@ -282,8 +282,8 @@ void func_8024E7C8(void){ D_80281250[i].unk2 = temp_v0_3; //previous buttons D_80281250[i].unk8 = D_80281250[i].joystick[0]; D_80281250[i].unkC = D_80281250[i].joystick[1]; - D_80281250[i].joystick[0] = func_8024E420(D_802812B8[i].stick_x, 7, 0x3B); - D_80281250[i].joystick[1] = func_8024E420(D_802812B8[i].stick_y, 7, 0x3D); + D_80281250[i].joystick[0] = func_8024E420(pfsManagerContPadData[i].stick_x, 7, 0x3B); + D_80281250[i].joystick[1] = func_8024E420(pfsManagerContPadData[i].stick_y, 7, 0x3D); D_80281308[i] = ((D_80281250[i].unk4 != 0) || (D_80281250[i].unk8 != D_80281250[i].joystick[0]) @@ -297,82 +297,82 @@ void func_8024E7C8(void){ } #endif -void func_8024EF74(){ +void pfsManager_readData(){ func_8024F35C(0); - if(!D_80281318.errno) - osContGetReadData(D_802812B8); + if(!pfsManagerContStatus.errno) + osContGetReadData(pfsManagerContPadData); } -void func_8024EFB0(void *arg0){ +void pfsManager_handle(void *arg0){ do{ - osRecvMesg(&D_802812D8, 0, 1); - if(D_80281328 == TRUE){ - func_8024EF74(); + osRecvMesg(&pfsManagerContPollingMsqQ, 0, 1); + if(pfsManagerBusy == TRUE){ + pfsManager_readData(); } else{ - osSendMesg(&D_802812F0, 0, 0); + osSendMesg(&pfsManagerContReplyMsgQ, 0, 0); } }while(1); } -void func_8024F05C(void){ - osCreateMesgQueue(&D_802812D8, &D_802812B0, 1); - osCreateMesgQueue(&D_802812F0, &D_802812B4, 1); - osCreateThread(&D_80281330, 7, func_8024EFB0, NULL, D_802814E0 + 0x200, 0x28); - osSetEventMesg(OS_EVENT_SI, &D_802812D8, &D_802812B0); - osContInit(&D_802812D8, &D_80281130, &D_80281318); +void pfsManager_init(void){ + osCreateMesgQueue(&pfsManagerContPollingMsqQ, &pfsManagerContPollingMsqBuf, 1); + osCreateMesgQueue(&pfsManagerContReplyMsgQ, &pfsManagerContReplyMsgBuf, 1); + osCreateThread(&pfsManagerThread, 7, pfsManager_handle, NULL, D_802814E0 + 0x200, 0x28); + osSetEventMesg(OS_EVENT_SI, &pfsManagerContPollingMsqQ, &pfsManagerContPollingMsqBuf); + osContInit(&pfsManagerContPollingMsqQ, &pfsManagerBitPattern, &pfsManagerContStatus); osContSetCh(1); func_8024F224(); func_802476DC(); - osStartThread(&D_80281330); + osStartThread(&pfsManagerThread); } -int func_8024F12C(void){ - return D_80281318.errno ? 1 : 0; +bool pfsManager_contErr(void){ + return pfsManagerContStatus.errno ? TRUE : FALSE; } void func_8024F150(void){ - if(func_8024F12C()) + if(pfsManager_contErr()) chOverlayNoController_spawn(0,0); } void func_8024F180(void){ - if(func_8024F12C()) + if(pfsManager_contErr()) chOverlayNoController_func_802DD040(0,0); } -void func_8024F1B0(void){ - if(D_80281328 == 0){ +void pfsManager_getStartReadData(void){ + if(pfsManagerBusy == 0){ func_8024F35C(1); - osContStartReadData(&D_802812D8); + osContStartReadData(&pfsManagerContPollingMsqQ); } } void func_8024F1F0(void){ - osRecvMesg(&D_802812D8, NULL, 1); + osRecvMesg(&pfsManagerContPollingMsqQ, NULL, 1); func_8024E7C8(); } void func_8024F224(void){ - s32 iController, j; + s32 iCont, j; - for(iController = 0; iController < 4; iController++){ - D_80281250[iController].unk0 = 0; - D_80281250[iController].unk2 = 0; - D_80281250[iController].unk4 = 0; - D_80281250[iController].unk6 = 0; - D_80281250[iController].joystick[0] = 0.0f; - D_80281250[iController].joystick[1] = 0.0f; - D_80281250[iController].unk8 = 0.0f; - D_80281250[iController].unkC = 0.0f; + for(iCont = 0; iCont < 4; iCont++){ + D_80281250[iCont].unk0 = 0; + D_80281250[iCont].unk2 = 0; + D_80281250[iCont].unk4 = 0; + D_80281250[iCont].unk6 = 0; + D_80281250[iCont].joystick[0] = 0.0f; + D_80281250[iCont].joystick[1] = 0.0f; + D_80281250[iCont].unk8 = 0.0f; + D_80281250[iCont].unkC = 0.0f; for(j = 0; j < 5; j++){ - D_802810E0[iController][j] = 0; + D_802810E0[iCont][j] = 0; } for(j = 0; j < 14; j++){ - D_80281138[iController].face_button[j] = 0; + D_80281138[iCont].face_button[j] = 0; } - D_80281308[iController] = 0.0f; + D_80281308[iCont] = 0.0f; } } @@ -384,12 +384,12 @@ void func_8024F328(s32 controller_index, s32 arg1){ D_80281138[controller_index].side_button[SIDE_BUTTON(BUTTON_Z)] = arg1; } -OSMesgQueue * func_8024F344(void){ - return &D_802812F0; +OSMesgQueue * pfsManager_getFrameReplyQ(void){ + return &pfsManagerContReplyMsgQ; } -OSMesgQueue *func_8024F350(void){ - return &D_802812D8; +OSMesgQueue *pfsManager_getFrameMesgQ(void){ + return &pfsManagerContPollingMsqQ; } void func_8024F35C(bool arg0){ @@ -399,16 +399,16 @@ void func_8024F35C(bool arg0){ func_8024F450(); if(arg0 || D_802816E8.validCount == 1){ - D_80281328 = arg0; + pfsManagerBusy = arg0; } } -s32 func_8024F3B4(void){ - return D_80281328; +bool pfsManager_isBusy(void){ + return pfsManagerBusy; } int func_8024F3C4(int arg0){ - return D_802812B8[arg0].button + D_802812B8[arg0].stick_x + D_802812B8[arg0].stick_y; + return pfsManagerContPadData[arg0].button + pfsManagerContPadData[arg0].stick_x + pfsManagerContPadData[arg0].stick_y; } OSContPad *func_8024F3F4(void){ @@ -425,8 +425,8 @@ void func_8024F400(void){ void func_8024F450(void){ if(!D_80275D38) func_8024F400(); - osRecvMesg(&D_802816E8, 0, 1); - osSetEventMesg(OS_EVENT_SI, &D_802812D8, &D_802812B0); + osRecvMesg(&D_802816E8, NULL, OS_MESG_BLOCK); + osSetEventMesg(OS_EVENT_SI, &pfsManagerContPollingMsqQ, &pfsManagerContPollingMsqBuf); } void func_8024F4AC(void){ diff --git a/src/core1/code_11AC0.c b/src/core1/code_11AC0.c index a6a7c985..62e57610 100644 --- a/src/core1/code_11AC0.c +++ b/src/core1/code_11AC0.c @@ -214,7 +214,7 @@ ALBank * D_80282108; structBs D_80282110[0x20]; /* .code */ -void func_8024F4E0(void){ +void musicInstruments_init(void){ s32 size; ALBankFile * bnk_f; //sp38 s32 i; diff --git a/src/core1/code_12F10.c b/src/core1/code_12F10.c index 69069dea..ae14f63e 100644 --- a/src/core1/code_12F10.c +++ b/src/core1/code_12F10.c @@ -110,7 +110,7 @@ void func_80250C84(void){ s32 pfs_status; func_8024F35C(4); - D_802823B4 = func_8024F344(); + D_802823B4 = pfsManager_getFrameReplyQ(); pfs_status = osPfsInit(D_802823B4, &D_802823B8, 0); if(pfs_status == PFS_ERR_ID_FATAL || pfs_status == PFS_ERR_DEVICE){ pfs_status = osMotorInit(D_802823B4, &D_802823B8, 0); diff --git a/src/core1/code_18110.c b/src/core1/code_18110.c index 3eb04714..7401959c 100644 --- a/src/core1/code_18110.c +++ b/src/core1/code_18110.c @@ -12,7 +12,7 @@ s32 write_file_blocks(s32 filenum, s32 blockOffset, u8 *buffer, s32 blockCount) s32 ret; func_8024F35C(3); - ret = osEepromLongWrite(func_8024F344(), address, buffer, blockCount * EEPROM_BLOCK_SIZE); + ret = osEepromLongWrite(pfsManager_getFrameReplyQ(), address, buffer, blockCount * EEPROM_BLOCK_SIZE); func_8024F35C(0); return ret; } @@ -22,7 +22,7 @@ s32 load_file_blocks(s32 filenum, s32 blockOffset, u8 *buffer, s32 blockCount) { s32 ret; func_8024F35C(3); - ret = osEepromLongRead(func_8024F344(), address, buffer, blockCount * EEPROM_BLOCK_SIZE); + ret = osEepromLongRead(pfsManager_getFrameReplyQ(), address, buffer, blockCount * EEPROM_BLOCK_SIZE); func_8024F35C(0); return ret; } diff --git a/src/core1/code_1D00.c b/src/core1/code_1D00.c index cbab8ca4..d20c8ef6 100644 --- a/src/core1/code_1D00.c +++ b/src/core1/code_1D00.c @@ -51,13 +51,13 @@ typedef struct struct_core1_1D00_5_s{ }unkC; }OscState; -void amgrCreate(void); -void func_8023FE80(void *); +void audioManager_create(void); +void audioManager_handle(void *); // void func_802403B8(void); -void amgrHandleDoneMsg(AudioInfo *info); +void audioManager_handleDoneMsg(AudioInfo *info); void *func_802403B8(void *state); void func_802403F0(void); -void amgrStartThread(void); +void audioManager_startThread(void); s32 D_80275770 = 0; @@ -141,7 +141,7 @@ struct { OSMesg audioFrameMsgBuf[8]; OSMesgQueue audioReplyMsgQ; OSMesg audioReplyMsgBuf[8]; -} g_AudioManager; +} audioManager; u8 pad_8027C178[0xE78]; ALHeap D_8027CFF0; u8 * D_8027D000; @@ -281,25 +281,25 @@ void func_8023FA64(ALSeqpConfig *arg0) { arg0->stopOsc = stopOsc; } -void func_8023FB1C(void){ +void audioManager_init(void){ D_8027D000 = (u8 *) malloc(0x21000); bzero(D_8027D000, 0x21000); alHeapInit(&D_8027CFF0, D_8027D000, 0x21000); if(osTvType != OS_TV_NTSC) osViClock = 0x2e6025c; - amgrCreate(); - func_80335220(); - func_8024F4E0(); - amgrStartThread(); + audioManager_create(); + sfxInstruments_init(); + musicInstruments_init(); + audioManager_startThread(); } -void amgrCreate(void) { +void audioManager_create(void) { int i; f32 var_f0; osCreateMesgQueue(&D_8027D008, &D_8027D020, 0x32); - osCreateMesgQueue(&g_AudioManager.audioReplyMsgQ, g_AudioManager.audioReplyMsgBuf, 8); //audioReplyMesgQueue - osCreateMesgQueue(&g_AudioManager.audioFrameMsgQ, g_AudioManager.audioFrameMsgBuf, 8); + osCreateMesgQueue(&audioManager.audioReplyMsgQ, audioManager.audioReplyMsgBuf, 8); //audioReplyMesgQueue + osCreateMesgQueue(&audioManager.audioFrameMsgQ, audioManager.audioFrameMsgBuf, 8); var_f0 = 733.333313f; D_8027DD74 = (s32)var_f0; if ((f32) D_8027DD74 < var_f0) { @@ -326,28 +326,28 @@ void amgrCreate(void) { D_8027D5C0[i].unk10 = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, 0x200); for(i = 0; i < 2; i++){ - g_AudioManager.ACMDList[i] = malloc(20000); + audioManager.ACMDList[i] = malloc(20000); } D_8027DD80 = 2500; for(i = 0; i < 3; i++){ - g_AudioManager.audioInfo[i] = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, 0x10); - g_AudioManager.audioInfo[i]->unk8 = 0; - g_AudioManager.audioInfo[i]->unkC = g_AudioManager.audioInfo[i]; - g_AudioManager.audioInfo[i]->data = malloc(D_8027DD7C * 4); + audioManager.audioInfo[i] = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, 0x10); + audioManager.audioInfo[i]->unk8 = 0; + audioManager.audioInfo[i]->unkC = audioManager.audioInfo[i]; + audioManager.audioInfo[i]->data = malloc(D_8027DD7C * 4); } - osCreateThread(&g_AudioManager.thread, 4, &func_8023FE80, 0, &D_8027CFF0, 0x32); + osCreateThread(&audioManager.thread, 4, &audioManager_handle, 0, &D_8027CFF0, 0x32); } -void func_8023FE80(void *arg0) { +void audioManager_handle(void *arg0) { s32 phi_s1; phi_s1 = 1; while(1){ - osRecvMesg(&g_AudioManager.audioFrameMsgQ, NULL, OS_MESG_BLOCK); - if (amgr_handleFrameMsg(g_AudioManager.audioInfo[D_8027DCC8 % 3], D_80275848)){ + osRecvMesg(&audioManager.audioFrameMsgQ, NULL, OS_MESG_BLOCK); + if (audioManager_handleFrameMsg(audioManager.audioInfo[D_8027DCC8 % 3], D_80275848)){ if(phi_s1 == 0){ - osRecvMesg(&g_AudioManager.audioReplyMsgQ, &D_80275844, OS_MESG_BLOCK); - amgrHandleDoneMsg(D_80275844->unk4); + osRecvMesg(&audioManager.audioReplyMsgQ, &D_80275844, OS_MESG_BLOCK); + audioManager_handleDoneMsg(D_80275844->unk4); D_80275848 = D_80275844->unk4; }else{ phi_s1 += -1; @@ -364,7 +364,7 @@ void func_8023FFD4(s32 arg0, s32 arg1, s32 arg2){ return; } -bool amgr_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){ +bool audioManager_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){ s16 *outbuffer; Acmd *sp38; s32 sp34; @@ -399,7 +399,7 @@ bool amgr_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){ info->frameSamples = D_8027DD78; } - sp38 = n_alAudioFrame(g_AudioManager.ACMDList[D_8027DCD0], &sp34, outbuffer, info->frameSamples); + sp38 = n_alAudioFrame(audioManager.ACMDList[D_8027DCD0], &sp34, outbuffer, info->frameSamples); if(D_8027DD80 < sp34){ func_80247F24(2, 2000); @@ -411,14 +411,14 @@ bool amgr_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){ if(sp34 == 0){ return 0; }else{ - func_802535A8(g_AudioManager.ACMDList[D_8027DCD0], sp38, &g_AudioManager.audioReplyMsgQ, &info->unk8); + func_802535A8(audioManager.ACMDList[D_8027DCD0], sp38, &audioManager.audioReplyMsgQ, &info->unk8); func_80250650(); D_8027DCD0 ^= 1; return 1; } } -void amgrHandleDoneMsg(AudioInfo *info) +void audioManager_handleDoneMsg(AudioInfo *info) { static int D_8027584C = TRUE; if (osAiGetLength() >> 2 == 0 && D_8027584C == FALSE) { @@ -527,22 +527,22 @@ void func_802403F0(void) { D_8027DCC8 += 1; } -void amgrStopThread(void){ +void audioManager_stopThread(void){ if(D_80275774){ D_80275774 = 0; - osStopThread(&g_AudioManager.thread); + osStopThread(&audioManager.thread); } } -void amgrStartThread(void){ +void audioManager_startThread(void){ if(D_80275774 == 0){ D_80275774 = 1; - osStartThread(&g_AudioManager.thread); + osStartThread(&audioManager.thread); } } -OSThread * amgrGetThread(void){ - return &g_AudioManager.thread; +OSThread * audioManager_getThread(void){ + return &audioManager.thread; } ALHeap * func_802405B8(void){ @@ -557,6 +557,6 @@ OSIoMesg * func_802405D0(void){ return &D_8027D0E8; } -OSMesgQueue * amgr_getFrameMesgQueue(void){ - return &g_AudioManager.audioFrameMsgQ; +OSMesgQueue * audioManager_getFrameMesgQueue(void){ + return &audioManager.audioFrameMsgQ; } diff --git a/src/core1/code_8C50.c b/src/core1/code_8C50.c index d6e868b7..3e045533 100644 --- a/src/core1/code_8C50.c +++ b/src/core1/code_8C50.c @@ -74,7 +74,7 @@ s32 D_8027FC18; s32 D_8027FC1C; s32 D_8027FC20; s32 D_8027FC24; -u8 pad_8027FC28[2040]; //stack for thread D_80280428; +u8 D_8027FC28[2040]; //stack for thread D_80280428; OSThread D_80280428; Struct_Core1_8C50_s * D_802805D8[20]; volatile s32 D_80280628; @@ -332,7 +332,7 @@ void func_802471D8(OSMesg arg0){ } void func_802471EC(void){ - osSendMesg(amgr_getFrameMesgQueue(), NULL, OS_MESG_NOBLOCK); + osSendMesg(audioManager_getFrameMesgQueue(), NULL, OS_MESG_NOBLOCK); func_80247224(); } @@ -426,7 +426,7 @@ void func_802473B4(void *arg0){ else if((u32)msg == CORE1_8C50_EVENT_FAULT) { do{}while(1); } else if((u32)msg == CORE1_8C50_EVENT_PRENMI) { func_8024730C(); } else if((u32)msg == 12) { } - else if((u32)msg == CORE1_8C50_EVENT_CONT_TIMER) { func_8024F1B0(); } + else if((u32)msg == CORE1_8C50_EVENT_CONT_TIMER) { pfsManager_getStartReadData(); } else if((u32)msg >= 100) { if(*(u32*)msg == 0){ func_80246A64(msg); } else if(*(u32*)msg == 1){ func_80246A84(msg); } @@ -458,7 +458,7 @@ void func_80247560(void){ tmp_v0 = D_8027EF40; while((u32)tmp_v0 % 0x10){((u32)tmp_v0)++;} D_80275950.t.yield_data_ptr = tmp_v0; - osCreateThread(&D_80280428, 5, func_802473B4, NULL, &pad_8027FC28[2040], 60); + osCreateThread(&D_80280428, 5, func_802473B4, NULL, &D_8027FC28[2040], 60); osStartThread(&D_80280428); } diff --git a/src/core2/code_62FD0.c b/src/core2/code_62FD0.c index b895d631..555e4e2b 100644 --- a/src/core2/code_62FD0.c +++ b/src/core2/code_62FD0.c @@ -2,13 +2,12 @@ #include "functions.h" #include "variables.h" -//BKMeshList_getVtxCount -s32 func_802E9F60(BKMeshList *arg0){ +s32 meshList_getVtxCount(BKMeshList *meshList){ s32 i; s32 v1 = 0; - BKMesh *v0 = (BKMesh *)(arg0 + 1); + BKMesh *v0 = (BKMesh *)(meshList + 1); - for(i = 0; i < arg0->meshCount_0; ++i){ + for(i = 0; i < meshList->meshCount_0; ++i){ v1 += v0->vtxCount_2; v0 = (BKMesh *)&((s16*)(v0 +1))[v0->vtxCount_2]; @@ -16,11 +15,11 @@ s32 func_802E9F60(BKMeshList *arg0){ return v1; } -BKMesh * func_802E9F9C(BKMeshList *arg0, s32 mesh_id){ +BKMesh * meshList_getMesh(BKMeshList *meshList, s32 mesh_id){ s32 i; - BKMesh *v1 = (BKMesh *)(arg0 + 1); + BKMesh *v1 = (BKMesh *)(meshList + 1); - for(i=0; i < arg0->meshCount_0; i++){ + for(i=0; i < meshList->meshCount_0; i++){ if(v1->uid_0 == mesh_id){ return v1; } @@ -29,9 +28,9 @@ BKMesh * func_802E9F9C(BKMeshList *arg0, s32 mesh_id){ return NULL; } -bool func_802E9FEC(BKMeshList * arg0, s32 mesh_id, void *vtx_id){ +bool meshList_meshContainsVtx(BKMeshList * meshList, s32 mesh_id, void *vtx_id){ s32 i; - BKMesh *v0 = func_802E9F9C(arg0, mesh_id); + BKMesh *v0 = meshList_getMesh(meshList, mesh_id); if(v0){ for(i = 0; i < v0->vtxCount_2; i++){ diff --git a/src/core2/code_AD5B0.c b/src/core2/code_AD5B0.c index 244acc51..2c1abed9 100644 --- a/src/core2/code_AD5B0.c +++ b/src/core2/code_AD5B0.c @@ -262,7 +262,7 @@ void func_80334B20(enum map_e arg0, s32 arg1, s32 arg2) { if (func_802E4A08() == 0) { func_802F5188(); } - if (arg0 != 0x1F) { + if (arg0 != MAP_1F_CS_START_RAREWARE) { func_8024F150(); } } diff --git a/src/core2/code_AE290.c b/src/core2/code_AE290.c index 660e2009..73afd2d0 100644 --- a/src/core2/code_AE290.c +++ b/src/core2/code_AE290.c @@ -18,7 +18,7 @@ struct { ALBank * D_80383604; /* .code */ -void func_80335220(void){ +void sfxInstruments_init(void){ ALBank *bnk; s32 size; ALInstrument *inst; diff --git a/src/core2/code_B3A80.c b/src/core2/code_B3A80.c index 5a223d5b..f56b3ea9 100644 --- a/src/core2/code_B3A80.c +++ b/src/core2/code_B3A80.c @@ -12,23 +12,23 @@ f32 D_803709E0[] = { 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; -s32 D_80370A10 = 0; - u8 D_80370A14 = 0; //assetCache_size; - u8 D_80370A18 = 0; +s32 assetCacheCurrentSize = 0; + u8 assetCacheLength = 0; //assetCache_size; + u8 assetCacheCurrentIndex = 0; u8 D_80370A1C = 0; /* .bss */ s32 D_80383CB0; u8 pad_80383CB8[0x8]; -AssetROMHead *D_80383CC0; -AssetFileMeta *D_80383CC4; +AssetROMHead *assetSectionRomHeader; +AssetFileMeta *assetSectionRomMetaList; u32 D_80383CC8; s32 D_80383CCC; //asset_data_rom_offset -void** D_80383CD0; //assetCache_ptrs; +void** assetCachePtrList; //assetCache_ptrs; BKSpriteDisplayData **D_80383CD4; -u8* assetCache_depCount; //assetCache_dependencies; -s16 *D_80383CDC; //assetCache_indexs +u8* assetCacheDependencyCount; //assetCache_dependencies; +s16 *assetCacheAssetIdList; //assetCache_indexs vector(struct21s) *D_80383CE0[2]; /* .public */ @@ -225,11 +225,11 @@ void func_8033B268(void){ } void func_8033B2A4(s32 arg0) { - D_80383CD0[D_80370A14] = malloc(arg0); - D_80383CD4[D_80370A14] = NULL; - assetCache_depCount[D_80370A14] = 1; - D_80383CDC[D_80370A14] = -1; - D_80370A14 += 1; + assetCachePtrList[assetCacheLength] = malloc(arg0); + D_80383CD4[assetCacheLength] = NULL; + assetCacheDependencyCount[assetCacheLength] = 1; + assetCacheAssetIdList[assetCacheLength] = -1; + assetCacheLength += 1; } bool func_8033B338(void **sprite_ptr, BKSpriteDisplayData **arg1) @@ -262,25 +262,25 @@ bool func_8033B388(BKSprite **sprite_ptr, BKSpriteDisplayData **arg1){ s32 assetcache_release(void * arg0){ s32 i; if(arg0){ - for(i = 0; i < D_80370A14 && arg0 != D_80383CD0[i]; i++); + for(i = 0; i < assetCacheLength && arg0 != assetCachePtrList[i]; i++); - if(i == D_80370A14) + if(i == assetCacheLength) return 2; - D_80370A18 = i; - if(assetCache_depCount[i] == 1){ + assetCacheCurrentIndex = i; + if(assetCacheDependencyCount[i] == 1){ if(D_80383CD4[i]) func_803449DC(D_80383CD4[i]); free(arg0); - D_80370A14--; - assetCache_depCount[i] = assetCache_depCount[D_80370A14]; - D_80383CD0[i] = D_80383CD0[D_80370A14]; - D_80383CD4[i] = D_80383CD4[D_80370A14]; - D_80383CDC[i] = D_80383CDC[D_80370A14]; + assetCacheLength--; + assetCacheDependencyCount[i] = assetCacheDependencyCount[assetCacheLength]; + assetCachePtrList[i] = assetCachePtrList[assetCacheLength]; + D_80383CD4[i] = D_80383CD4[assetCacheLength]; + assetCacheAssetIdList[i] = assetCacheAssetIdList[assetCacheLength]; return 0; } else{ - assetCache_depCount[i]--; + assetCacheDependencyCount[i]--; return 1; } } else{ @@ -294,10 +294,10 @@ void assetcache_update_ptr(void * arg0, void* arg1){ if((arg0 == NULL) || (arg1 == NULL) || (arg0 == arg1)) return; - for(i = 0; i < D_80370A14 && arg0 != D_80383CD0[i]; i++); + for(i = 0; i < assetCacheLength && arg0 != assetCachePtrList[i]; i++); - if(i != D_80370A14 && arg1 != D_80383CD0[i]) - D_80383CD0[i] = arg1; + if(i != assetCacheLength && arg1 != assetCachePtrList[i]) + assetCachePtrList[i] = arg1; } void func_8033B5FC(void){ @@ -311,35 +311,35 @@ void func_8033B61C(void){ } s32 func_8033B64C(s32 arg0){ - return D_80383CC4[arg0].unk6; + return assetSectionRomMetaList[arg0].unk6; } -s32 func_8033B664(void){//asset get rom count - return D_80383CC0->count-1; +s32 assetSection_getCount(void){ + return assetSectionRomHeader->count-1; } -s32 func_8033B678(void ){//static last asset decompressed size - return D_80370A10; +s32 func_8033B678(void ){ + return assetCacheCurrentSize; } -s32 func_8033B684(s32 arg0){ //asset_size - return D_80383CC4[arg0+1].offset - D_80383CC4[arg0].offset; +s32 asset_getSize(s32 arg0){ + return assetSectionRomMetaList[arg0+1].offset - assetSectionRomMetaList[arg0].offset; } -s32 func_8033B6A4(enum asset_e arg0){ //asset_compressed? - return (D_80383CC4[arg0].compFlag & 1) !=0; +bool asset_isCompressed(enum asset_e arg0){ //asset_compressed? + return (assetSectionRomMetaList[arg0].compFlag & 1) !=0; } //returns raw sprite(as saved in ROM) and points arg1 to a parsed sprite(?) BKSprite *func_8033B6C4(enum asset_e sprite_id, BKSpriteDisplayData **arg1){ BKSprite *s0; s0 = assetcache_get(sprite_id); - if(D_80383CD4[D_80370A18] == NULL){ + if(D_80383CD4[assetCacheCurrentIndex] == NULL){ func_803382E4(-1); func_80338308(func_802510A0(s0), func_802510A8(s0)); - D_80383CD4[D_80370A18] = func_80344A1C(s0); + D_80383CD4[assetCacheCurrentIndex] = func_80344A1C(s0); } - *arg1 = D_80383CD4[D_80370A18]; + *arg1 = D_80383CD4[assetCacheCurrentIndex]; return s0; } @@ -347,7 +347,7 @@ void func_8033B788(void ){ D_80370A1C = 1; } -void *assetcache_get(s32 arg0) { +void *assetcache_get(enum asset_e assetId) { s32 comp_size;//sp_44 s32 i; volatile s32 sp3C; //sp3C @@ -359,24 +359,24 @@ void *assetcache_get(s32 arg0) { sp28 = (s32 )D_80370A1C; D_80370A1C = (u8)0U; - for(i = 0; i < D_80370A14 && arg0 != D_80383CDC[i]; i++); - D_80370A18 = i; + for(i = 0; i < assetCacheLength && assetId != assetCacheAssetIdList[i]; i++); + assetCacheCurrentIndex = i; if(i == 0x96) return NULL; - if(i < D_80370A14){ //asset exists in array; - assetCache_depCount[i]++; - return D_80383CD0[i]; + if(i < assetCacheLength){ //asset exists in array; + assetCacheDependencyCount[i]++; + return assetCachePtrList[i]; } - comp_size = D_80383CC4[arg0+1].offset - D_80383CC4[arg0].offset; + comp_size = assetSectionRomMetaList[assetId+1].offset - assetSectionRomMetaList[assetId].offset; if(comp_size & 1) comp_size++; sp3C = comp_size; - if(D_80383CC4[arg0].compFlag & 0x0001){//compressed - func_8033BAB0(arg0, 0, 0x10, &D_80383CB0); - D_80370A10 = rarezip_get_uncompressed_size(&D_80383CB0); - uncomp_size = D_80370A10; + if(assetSectionRomMetaList[assetId].compFlag & 0x0001){//compressed + func_8033BAB0(assetId, 0, 0x10, &D_80383CB0); + assetCacheCurrentSize = rarezip_get_uncompressed_size(&D_80383CB0); + uncomp_size = assetCacheCurrentSize; if(uncomp_size & 0xF){ uncomp_size -= uncomp_size & 0xF; uncomp_size += 0x10; @@ -398,63 +398,62 @@ void *assetcache_get(s32 arg0) { uncompressed_file = malloc(comp_size); compressed_file = uncompressed_file; } - func_802405F0(compressed_file, D_80383CC4[arg0].offset + D_80383CCC, sp3C); - if(D_80383CC4[arg0].compFlag & 0x0001){//decompress + func_802405F0(compressed_file, assetSectionRomMetaList[assetId].offset + D_80383CCC, sp3C); + if(assetSectionRomMetaList[assetId].compFlag & 0x0001){//decompress rarezip_inflate(compressed_file, uncompressed_file); - realloc(uncompressed_file, D_80370A10); - osWritebackDCache(uncompressed_file, D_80370A10); + realloc(uncompressed_file, assetCacheCurrentSize); + osWritebackDCache(uncompressed_file, assetCacheCurrentSize); if (sp33 == 2) { free(compressed_file); } } - D_80370A18 = D_80370A14; - assetCache_depCount[D_80370A14] = 1; - D_80383CD0[D_80370A14] = uncompressed_file; - D_80383CD4[D_80370A14] = 0; - D_80383CDC[D_80370A14] = arg0; - D_80370A14++; + assetCacheCurrentIndex = assetCacheLength; + assetCacheDependencyCount[assetCacheLength] = 1; + assetCachePtrList[assetCacheLength] = uncompressed_file; + D_80383CD4[assetCacheLength] = 0; + assetCacheAssetIdList[assetCacheLength] = assetId; + assetCacheLength++; return uncompressed_file; } void func_8033BAB0(enum asset_e asset_id, s32 offset, s32 size, void *dst_ptr) { - func_802405F0(dst_ptr, D_80383CC4[asset_id].offset + D_80383CCC + offset, size); + func_802405F0(dst_ptr, assetSectionRomMetaList[asset_id].offset + D_80383CCC + offset, size); } -void func_8033BB00(void *arg0, s32 arg1){ +void assetCache_resizeAsset(void *assetPtr, s32 size){ s32 tmp; s32 i; - for(i = 0; i < D_80370A14 && arg0 != D_80383CD0[i]; i++); - D_80383CD0[i] = realloc(arg0, arg1); + for(i = 0; i < assetCacheLength && assetPtr != assetCachePtrList[i]; i++); + assetCachePtrList[i] = realloc(assetPtr, size); } -//assetCache_init void assetCache_init(void){ D_80370A1C = 0; func_8033B180(); - D_80383CD0 = malloc(600); + assetCachePtrList = (void **)malloc(150*sizeof(void*)); D_80383CD4 = malloc(600); - assetCache_depCount = malloc(150); - D_80383CDC = malloc(150*sizeof(s16)); - D_80370A14 = 0; - D_80383CC0 = malloc(sizeof(AssetROMHead)); + assetCacheDependencyCount = (u8*)malloc(150*sizeof(u8)); + assetCacheAssetIdList = (s16 *)malloc(150*sizeof(s16)); + assetCacheLength = 0; + assetSectionRomHeader = (AssetROMHead *)malloc(sizeof(AssetROMHead)); D_80383CC8 = (u32) &D_5E90; - func_802405F0(D_80383CC0, D_80383CC8, sizeof(AssetROMHead)); - D_80383CC4 = malloc(D_80383CC0->count*sizeof(AssetFileMeta)); - func_802405F0(D_80383CC4, D_80383CC8 + sizeof(AssetROMHead),D_80383CC0->count*sizeof(AssetFileMeta)); - D_80383CCC = D_80383CC8 + sizeof(AssetROMHead) + D_80383CC0->count*sizeof(AssetFileMeta); + func_802405F0(assetSectionRomHeader, D_80383CC8, sizeof(AssetROMHead)); + assetSectionRomMetaList = (AssetFileMeta *)malloc(assetSectionRomHeader->count*sizeof(AssetFileMeta)); + func_802405F0(assetSectionRomMetaList, D_80383CC8 + sizeof(AssetROMHead),assetSectionRomHeader->count*sizeof(AssetFileMeta)); + D_80383CCC = D_80383CC8 + sizeof(AssetROMHead) + assetSectionRomHeader->count*sizeof(AssetFileMeta); } -s32 func_8033BC94(s32 arg0){ //asset_compressedSize - return D_80383CC4[arg0+1].offset - D_80383CC4[arg0].offset; +s32 asset_getCompressedSize(enum asset_e arg0){ + return assetSectionRomMetaList[arg0+1].offset - assetSectionRomMetaList[arg0].offset; } -s32 func_8033BCB4(s32 arg0){ //asset_getDependencyCount +s32 assetCache_getDependencyCount(enum asset_e arg0){ s32 i; - for(i = 0; i < D_80370A14 && arg0 != D_80383CDC[i]; i++); - if(i < D_80370A14){ - return assetCache_depCount[i]; + for(i = 0; i < assetCacheLength && arg0 != assetCacheAssetIdList[i]; i++); + if(i < assetCacheLength){ + return assetCacheDependencyCount[i]; } return 0; } @@ -486,23 +485,23 @@ s32 func_8033BDAC(enum asset_e id, void *dst, s32 size) { s32 sp20; //find asset in cache - for(phi_v0 = 0; phi_v0 < D_80370A14 && id != D_80383CDC[phi_v0]; phi_v0++); - D_80370A18 = phi_v0; - if (phi_v0 == 0x96) { + for(phi_v0 = 0; phi_v0 < assetCacheLength && id != assetCacheAssetIdList[phi_v0]; phi_v0++); + assetCacheCurrentIndex = phi_v0; + if (phi_v0 == 150) { //asset not in cache return 0; } - comp_ptr = D_80383CC4[id + 1].offset - D_80383CC4[id].offset; + comp_ptr = assetSectionRomMetaList[id + 1].offset - assetSectionRomMetaList[id].offset; if (comp_ptr & 1) { comp_ptr++; } sp34 = comp_ptr; - if (D_80383CC4[id].compFlag & 1) { + if (assetSectionRomMetaList[id].compFlag & 1) { func_8033BAB0(id, 0, 0x10, &D_80383CB0); - D_80370A10 = rarezip_get_uncompressed_size(&D_80383CB0); + assetCacheCurrentSize = rarezip_get_uncompressed_size(&D_80383CB0); // get aligned uncompressed size - var_s0 = D_80370A10; + var_s0 = assetCacheCurrentSize; if (var_s0 & 0xF) { var_s0 = (var_s0 - (var_s0 & 0xF)) + 0x10; } @@ -531,11 +530,11 @@ s32 func_8033BDAC(enum asset_e id, void *dst, s32 size) { return 0; } } - comp_size = D_80383CC4[id].offset + D_80383CCC; + comp_size = assetSectionRomMetaList[id].offset + D_80383CCC; func_802405F0(comp_ptr, comp_size, sp34); - if (D_80383CC4[id].compFlag & 1) { + if (assetSectionRomMetaList[id].compFlag & 1) { rarezip_inflate(comp_ptr, dst); - osWritebackDCache(dst, D_80370A10); + osWritebackDCache(dst, assetCacheCurrentSize); if (sp2B == 2) { free((void *)comp_ptr); } diff --git a/src/core2/code_B8080.c b/src/core2/code_B8080.c index e7193d3b..01d26f38 100644 --- a/src/core2/code_B8080.c +++ b/src/core2/code_B8080.c @@ -3,11 +3,11 @@ #include "variables.h" -void func_8033F2B4(BKModel *model, s32 mesh_id, s16 arg2[3], s16 arg3[3]); +void BKModel_getMeshCoordRange(BKModel *model, s32 mesh_id, s16 min[3], s16 max[3]); s32 func_8033F3E8(BKModel *model, f32 position[3], s32 min_id, s32 max_id); /* .code */ //performs operation "fn" for every vtx in every mesh of a model -void func_8033F010(BKModel *model, void (*fn)(s32, BKVtxRef *, Vtx *, s32), s32 arg3) { +void BKModel_transformMeshes(BKModel *model, void (*fn)(s32, BKVtxRef *, Vtx *, s32), s32 arg3) { s32 i; BKMesh *iMesh; BKVtxRef *iVtx; @@ -28,7 +28,7 @@ void func_8033F010(BKModel *model, void (*fn)(s32, BKVtxRef *, Vtx *, s32), s32 } //performs operation "fn" for every vtx in a model's mesh -void func_8033F120(BKModel *model, s32 mesh_id, void (*fn)(s32, BKVtxRef *, Vtx *, s32), s32 arg3) { +void BKModel_transformMesh(BKModel *model, s32 mesh_id, void (*fn)(s32, BKVtxRef *, Vtx *, s32), s32 arg3) { s32 i; BKMesh *iMesh; BKVtxRef *iVtx; @@ -52,22 +52,22 @@ void func_8033F120(BKModel *model, s32 mesh_id, void (*fn)(s32, BKVtxRef *, Vtx } //BKModel_getAveragePositionOfMesh -void func_8033F220(BKModel *model, s32 mesh_id, s16 arg2[3]) { +void BKModel_getMeshCenter(BKModel *model, s32 mesh_id, s16 arg2[3]) { s16 min[3]; s16 max[3]; - func_8033F2B4(model, mesh_id, min, max); + BKModel_getMeshCoordRange(model, mesh_id, min, max); arg2[0] = (min[0] + max[0]) / 2; arg2[1] = (min[1] + max[1]) / 2; arg2[2] = (min[2] + max[2]) / 2; } -BKMeshList *func_8033F2AC(BKModel *arg0){ +BKMeshList *BKModel_getMeshList(BKModel *arg0){ return arg0->meshList_0; } -void func_8033F2B4(BKModel *model, s32 mesh_id, s16 arg2[3], s16 arg3[3]) { +void BKModel_getMeshCoordRange(BKModel *model, s32 mesh_id, s16 min[3], s16 max[3]) { s32 pad2C; s32 pad28; BKMesh *mesh; @@ -78,7 +78,7 @@ void func_8033F2B4(BKModel *model, s32 mesh_id, s16 arg2[3], s16 arg3[3]) { s16 *phi_t4; s32 i; - mesh = func_802E9F9C(model->meshList_0, mesh_id); + mesh = meshList_getMesh(model->meshList_0, mesh_id); vtx_pool = vtxList_getVertices(model->vtxList_4); if (mesh == NULL) return; @@ -88,10 +88,10 @@ void func_8033F2B4(BKModel *model, s32 mesh_id, s16 arg2[3], s16 arg3[3]) { i_vtx = &vtx_pool[*phi_t4]; for(i = 0; i < 3; i++){ if (phi_t4 == (s16*)(mesh + 1)) { - arg2[i] = arg3[i] = i_vtx->v.ob[i]; + min[i] = max[i] = i_vtx->v.ob[i]; } else { - arg2[i] = MIN(i_vtx->v.ob[i], arg2[i]); - arg3[i] = MAX(i_vtx->v.ob[i], arg3[i]); + min[i] = MIN(i_vtx->v.ob[i], min[i]); + max[i] = MAX(i_vtx->v.ob[i], max[i]); } } } @@ -181,7 +181,7 @@ BKModel *func_8033F5F8(BKMeshList *arg0, BKVertexList *arg1) { s32 phi_s1; s32 phi_s6; - sp40 = (BKModel *)malloc((func_802E9F60(arg0) * sizeof(BKVtxRef)) + (arg0->meshCount_0 * sizeof(BKMesh)) + sizeof(BKModel)); + sp40 = (BKModel *)malloc((meshList_getVtxCount(arg0) * sizeof(BKVtxRef)) + (arg0->meshCount_0 * sizeof(BKMesh)) + sizeof(BKModel)); sp40->meshList_0 = arg0; sp40->vtxList_4 = arg1; phi_s3 = (BKMesh *)(arg0 + 1); diff --git a/src/core2/code_C4320.c b/src/core2/code_C4320.c index e0a2c10d..436b1643 100644 --- a/src/core2/code_C4320.c +++ b/src/core2/code_C4320.c @@ -162,7 +162,7 @@ void func_8034B580(s32 arg0) { if ((D_80386128 >= 2.5) && (sp1C < 2.5) && (D_80371F9C == 0)) { func_802DC9DC(0, 0); } - if ((D_80386128 >= 4.0) && (sp1C < 4.0) && (func_8024F12C() == 0)) { + if ((D_80386128 >= 4.0) && (sp1C < 4.0) && !pfsManager_contErr()) { chOverlayPressStart_spawn(0, 0); if (D_80371F9C != 0) { chOverlayPressStart_func_802DCDB0(); @@ -174,7 +174,7 @@ void func_8034B580(s32 arg0) { if ((D_80386128 >= 2.5) && (sp1C < 2.5)) { chOverlayCopyright_func_802DCB0C(0, 0); } - if ((D_80386128 >= 4.0) && (sp1C < 4.0) && (func_8024F12C() == 0)) { + if ((D_80386128 >= 4.0) && (sp1C < 4.0) && !pfsManager_contErr()) { chOverlayPressStart_spawn(0, 0); } break; diff --git a/src/core2/code_C4F40.c b/src/core2/code_C4F40.c index 6bb54bc8..80e589f6 100644 --- a/src/core2/code_C4F40.c +++ b/src/core2/code_C4F40.c @@ -83,7 +83,7 @@ void func_8034BFF8(ActorMarker *marker) { if (marker->unk48 != NULL) { marker->unk4C = vector_new(sizeof(Struct6Es), 0); - sp2C = func_8033F2AC(marker->unk48); + sp2C = BKModel_getMeshList(marker->unk48); phi_s1 = (BKMesh *)(sp2C + 1); for(phi_s2 = 0; phi_s2 < sp2C->meshCount_0; phi_s2++){ if ((phi_s1->uid_0 >= 0x65) && (phi_s1->uid_0 < 0xC8)) { diff --git a/src/core2/code_C5440.c b/src/core2/code_C5440.c index 8e9ebadb..6b0a8625 100644 --- a/src/core2/code_C5440.c +++ b/src/core2/code_C5440.c @@ -122,7 +122,7 @@ Struct70s *func_8034C630(s32 arg0){ for(iPtr = vector_getBegin(D_80386140.unk4); iPtr < endPtr; iPtr++){ if( (iPtr->unk6 == 3) - && func_802E9FEC(func_8033F2AC(iPtr->unk0), iPtr->unk4, arg0) + && meshList_meshContainsVtx(BKModel_getMeshList(iPtr->unk0), iPtr->unk4, arg0) ){ return &iPtr->unk8; } @@ -131,7 +131,7 @@ Struct70s *func_8034C630(s32 arg0){ } void func_8034C6DC(BKModel *arg0){ - BKMeshList * sp2C = func_8033F2AC(arg0); + BKMeshList * sp2C = BKModel_getMeshList(arg0); s32 i; BKMesh * s1 = (sp2C + 1); for(i = 0; i < sp2C->meshCount_0; i++){ diff --git a/src/core2/code_C5AF0.c b/src/core2/code_C5AF0.c index 8e834e8c..db0c9a3d 100644 --- a/src/core2/code_C5AF0.c +++ b/src/core2/code_C5AF0.c @@ -26,5 +26,5 @@ void func_8034CB9C(Struct6Fs *arg0, BKModel *model, s32 mesh_id) { arg0->unk0 = 0.3f; arg0->unk4 = -arg0->unk4; } - func_8033F120(model, mesh_id, func_8034CA80, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034CA80, (s32) arg0); } diff --git a/src/core2/code_C5CC0.c b/src/core2/code_C5CC0.c index 267810bd..87a2c486 100644 --- a/src/core2/code_C5CC0.c +++ b/src/core2/code_C5CC0.c @@ -45,5 +45,5 @@ void func_8034CD8C(Struct71s *arg0, BKModel *arg1, s32 arg2) { if ((arg0->unk0 == 2) && func_8025773C(&arg0->unkC, temp_f14)) { func_8034CD08(arg0, 1); } - func_8033F120(arg1, arg2, func_8034CC50, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034CC50, (s32) arg0); } diff --git a/src/core2/code_C5F00.c b/src/core2/code_C5F00.c index 321c1ada..12fcda95 100644 --- a/src/core2/code_C5F00.c +++ b/src/core2/code_C5F00.c @@ -20,7 +20,7 @@ void func_8034CF90(Struct72s *arg0, BKModel *arg1, s32 arg2) { arg0->unk0 += randf2(-0.04f, 0.04f); arg0->unk0 = (arg0->unk0 > 1.0f) ? 1.0f : arg0->unk0; arg0->unk0 = (arg0->unk0 < 0.8) ? 0.8 : arg0->unk0; - func_8033F120(arg1, arg2, func_8034CE90, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034CE90, (s32) arg0); } void func_8034D048(Struct72s *arg0, BKModel *arg1, s32 arg2) { @@ -28,5 +28,5 @@ void func_8034D048(Struct72s *arg0, BKModel *arg1, s32 arg2) { arg0->unk0 += (osGetCount() & 0x1F) / 387.5; arg0->unk0 = (arg0->unk0 > 1.0f) ? 1.0f : arg0->unk0; arg0->unk0 = (arg0->unk0 < 0.8) ? 0.8 : arg0->unk0; - func_8033F120(arg1, arg2, func_8034CE90, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034CE90, (s32) arg0); } diff --git a/src/core2/code_C61C0.c b/src/core2/code_C61C0.c index 9cea1f41..9065641f 100644 --- a/src/core2/code_C61C0.c +++ b/src/core2/code_C61C0.c @@ -28,5 +28,5 @@ void func_8034D194(Struct_core2_C61C0_0 *arg0, BKModel *model, s32 mesh_id) { arg0->unk0 -= 16384.0f; } arg0->unk4 = (s16)arg0->unk0; - func_8033F120(model, mesh_id, func_8034D150, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D150, (s32) arg0); } diff --git a/src/core2/code_C62B0.c b/src/core2/code_C62B0.c index 4f821426..e319db5d 100644 --- a/src/core2/code_C62B0.c +++ b/src/core2/code_C62B0.c @@ -4,7 +4,7 @@ void func_8034E174(Struct6Ds *arg0); -void func_8033F120(BKModel *, s32, void (*)(s32, BKVtxRef*, Vtx*, s32), s32); +void BKModel_transformMesh(BKModel *, s32, void (*)(s32, BKVtxRef*, Vtx*, s32), s32); extern f32 D_80379200; extern f64 D_80379208; @@ -145,7 +145,7 @@ void func_8034DD74(Struct6Ds *arg0, s32 arg1, BKModel *model, s32 mesh_id) { arg0->unk98 = 0.0f; arg0->unk44 = 0.0f; arg0->unk48 = 0.0f; - func_8033F2B4(model, mesh_id, arg0->unk14, arg0->unk1A); + BKModel_getMeshCoordRange(model, mesh_id, arg0->unk14, arg0->unk1A); } void func_8034DDF0(Struct6Ds *arg0, f32 arg1[3], f32 arg2[3], f32 arg3, s32 arg4){ @@ -281,7 +281,7 @@ void func_8034E26C(Struct6Ds *arg0, BKModel *model, s32 mesh_id) { arg0->unk28 = 2; } } - func_8033F120(model, mesh_id, func_8034D240, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D240, (s32) arg0); if (arg0->unk28 != 0) { arg0->unk28--; if (arg0->unk28 == 0) { @@ -300,9 +300,9 @@ void func_8034E26C(Struct6Ds *arg0, BKModel *model, s32 mesh_id) { } if (arg0->unk29 == 5) { - func_8033F120(model, mesh_id, func_8034D9C8, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D9C8, (s32) arg0); } else { - func_8033F120(model, mesh_id, func_8034D740, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D740, (s32) arg0); } if (arg0->unk28 != 0) { @@ -340,16 +340,16 @@ void func_8034E26C(Struct6Ds *arg0, BKModel *model, s32 mesh_id) { } switch (arg0->unk29) { case 1: - func_8033F120(model, mesh_id, func_8034D554, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D554, (s32) arg0); break; case 2: - func_8033F120(model, mesh_id, func_8034D634, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D634, (s32) arg0); break; case 3: - func_8033F120(model, mesh_id, func_8034D700, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034D700, (s32) arg0); break; case 4: - func_8033F120(model, mesh_id, func_8034DA7C, (s32) arg0); + BKModel_transformMesh(model, mesh_id, func_8034DA7C, (s32) arg0); break; } if (arg0->unk48 <= arg0->unk44) { diff --git a/src/core2/code_C76D0.c b/src/core2/code_C76D0.c index eda05f88..934c9ec8 100644 --- a/src/core2/code_C76D0.c +++ b/src/core2/code_C76D0.c @@ -39,7 +39,7 @@ void func_8034E71C(Struct73s *arg0, s32 arg1, f32 arg2) { if (arg2 == 0.0f) { arg0->dy = arg1; sp18 = func_8034C4F0(arg0); - func_8033F120(sp18, func_8034C50C(arg0), func_8034E660, (s32) arg0); + BKModel_transformMesh(sp18, func_8034C50C(arg0), func_8034E660, (s32) arg0); } } @@ -104,5 +104,5 @@ void func_8034E8E4(Struct73s *arg0, BKModel *arg1, s32 arg2) { sp28 = ((arg0->unk14 < arg0->unk1C) ? arg0->unkC + ((arg0->unk14 / arg0->unk1C) * (arg0->unkE - arg0->unkC)) : arg0->unkE); sp28 += sp2C; arg0->dy = (sp28 >= 0.0) ? sp28 + 0.5 : sp28 - 0.5; - func_8033F120(arg1, arg2, func_8034E660, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034E660, (s32) arg0); } diff --git a/src/core2/code_C7CC0.c b/src/core2/code_C7CC0.c index 9ae59897..0c7a1f4b 100644 --- a/src/core2/code_C7CC0.c +++ b/src/core2/code_C7CC0.c @@ -28,7 +28,7 @@ void func_8034EE2C(Struct77s *arg0, s32 arg1, BKModel *arg2, s32 arg3) { s16 sp28[3]; s16 sp20[3]; - func_8033F2B4(arg2, arg3, sp28, sp20); + BKModel_getMeshCoordRange(arg2, arg3, sp28, sp20); arg0->unk0 = 1.0f; arg0->unk4 = 0.0f; arg0->unk8 = 0.0f; @@ -57,5 +57,5 @@ void func_8034EF60(Struct77s *arg0, BKModel *arg1, s32 arg2) { sp2C[1] = ((50.0f * sinf(arg0->unk2C * 0.5 * BAD_PI)) + (cosf(arg0->unk2C * 0.22 * BAD_PI) * 100.0f)) * 0.8; arg0->unk28[0] = (sp2C[0] >= 0.0) ? (sp2C[0] + 0.5) : (sp2C[0] - 0.5); arg0->unk28[1] = (sp2C[1] >= 0.0) ? (sp2C[1] + 0.5) : (sp2C[1] - 0.5); - func_8033F120(arg1, arg2, &func_8034EC50, arg0); + BKModel_transformMesh(arg1, arg2, &func_8034EC50, arg0); } diff --git a/src/core2/code_C8230.c b/src/core2/code_C8230.c index 89740a6f..89d7e2bc 100644 --- a/src/core2/code_C8230.c +++ b/src/core2/code_C8230.c @@ -28,5 +28,5 @@ void func_8034F268(Struct75s *arg0, BKModel *arg1, s32 arg2) { } else { arg0->unk0 = 0.0f; } - func_8033F120(arg1, arg2, func_8034F1C0, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034F1C0, (s32) arg0); } diff --git a/src/core2/code_C8360.c b/src/core2/code_C8360.c index 88659e74..3a3c1a41 100644 --- a/src/core2/code_C8360.c +++ b/src/core2/code_C8360.c @@ -32,5 +32,5 @@ void func_8034F398(f32 *arg0, BKModel *arg1, s32 arg2) { } else { *arg0 = 0.0f; } - func_8033F120(arg1, arg2, func_8034F2F0, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034F2F0, (s32) arg0); } diff --git a/src/core2/code_C8490.c b/src/core2/code_C8490.c index f5b7283f..f9ed34c6 100644 --- a/src/core2/code_C8490.c +++ b/src/core2/code_C8490.c @@ -67,5 +67,5 @@ void func_8034F5B0(Struct76s *arg0, BKModel *arg1, s32 arg2){ func_8034F434(arg0, 0); } } - func_8033F120(arg1, arg2, func_8034F420, (s32) arg0); + BKModel_transformMesh(arg1, arg2, func_8034F420, (s32) arg0); } diff --git a/src/lair/code_5ED0.c b/src/lair/code_5ED0.c index 3640d47f..7fbcfa00 100644 --- a/src/lair/code_5ED0.c +++ b/src/lair/code_5ED0.c @@ -56,7 +56,7 @@ extern void func_8028FA14(enum map_e, s32); extern void quizQuestionAskedBitfield_set(u32, int); // ff_isAsked_flag_set extern int quizQuestionAskedBitfield_get(u32); // ff_isAsked_flag_get -extern void func_8033F220(BKModel *model, s32 mesh_id, s16 [3]); //! $a2 type unk +extern void BKModel_getMeshCenter(BKModel *model, s32 mesh_id, s16 [3]); //! $a2 type unk extern s32 func_803203FC(s32); // get volatile flag extern void func_80295864(s32); // set unlocked moves bitfield @@ -484,7 +484,7 @@ void lair_func_8038C6BC(void) ptr->unk10 = 0.45f; } - func_8033F220(D_8037DCB8->unk0, s1, &ptr->unkA); + BKModel_getMeshCenter(D_8037DCB8->unk0, s1, &ptr->unkA); } } @@ -506,11 +506,11 @@ void func_8038C9D0(void) { } else if ((phi_s0->unk9 != 0) && (phi_s0->unk10 < 0.95)) { phi_s0->unk10 = MIN(phi_s0->unk10 + 0.05, 0.95); } - func_8033F120(D_8037DCB8->unk0, phi_s1, func_8038C3A0, (s32) phi_s0); + BKModel_transformMesh(D_8037DCB8->unk0, phi_s1, func_8038C3A0, (s32) phi_s0); phi_s0++; } - func_8033F120(D_8037DCB8->unk0, 0x1F1, func_8038C7A0, (s32) phi_s0); + BKModel_transformMesh(D_8037DCB8->unk0, 0x1F1, func_8038C7A0, (s32) phi_s0); if ( !((D_8037DCB8->currFfMode != FFA_3_TRIGGER_QUESTION) && (D_8037DCB8->currFfMode != FFA_4_UNK)) && (0.5 < D_8037DCB8->unk14) ) { diff --git a/symbol_addrs.us.v10.txt b/symbol_addrs.us.v10.txt index f6468db9..77c8c5c5 100644 --- a/symbol_addrs.us.v10.txt +++ b/symbol_addrs.us.v10.txt @@ -737,6 +737,8 @@ mapSavestate_defrag_all = 0x802E2ED4; mapSavestate_save = 0x802E2F2C; mapSavestate_apply = 0x802E30AC; getGameMode = 0x802E49FC; +meshList_getVtxVCount = 0x802E9F60; + vtxList_getVertices = 0x802EC450; vtxList_free = 0x802EC994; vtxList_clone = 0x802EC9B4; @@ -1148,7 +1150,7 @@ D_80381E90 = 0x80381E90; jiggyscore = 0x803832C0; sHoneycombScore = 0x803832E0; sMumboTokenScore = 0x803832F0; -assetCache_depCount = 0x80383CD8; +assetCacheDependencyCount = 0x80383CD8; D_A00001D8 = 0xA00001D8; D_5E90 = 0x5E90; D_D846C0 = 0xD846C0;