From a5acb3dd828becf759ec58b66ae08715a61a0428 Mon Sep 17 00:00:00 2001 From: Banjo Kazooie Date: Thu, 11 Aug 2022 18:39:17 -0500 Subject: [PATCH] core2/code_7A760.c done --- include/enums.h | 6 +- include/functions.h | 2 +- include/model.h | 8 +- include/prop.h | 6 +- progress/progress_core2.svg | 6 +- progress/progress_total.svg | 4 +- src/MM/ch/jujuhitbox.c | 8 +- src/core2/code_14420.c | 6 +- src/core2/code_55390.c | 8 +- src/core2/code_637D0.c | 184 +++++++++++++++++++++++++++++++++- src/core2/code_7A760.c | 110 ++++++++++++++++++--- src/core2/code_7AF80.c | 38 ++++++- src/core2/code_A5BC0.c | 33 +++++-- src/core2/code_AD110.c | 4 +- src/core2/code_C4B0.c | 191 +++++++++++++++++++++++++++++++----- subyaml/core2.us.v10.yaml | 7 +- 16 files changed, 540 insertions(+), 81 deletions(-) diff --git a/include/enums.h b/include/enums.h index 8ae21be7..ece14e3f 100644 --- a/include/enums.h +++ b/include/enums.h @@ -1614,6 +1614,8 @@ enum actor_e ACTOR_1CC_GRILL_CHOMPA = 0x1CC, + ACTOR_1DB_GAME_OVER = 0x1DB, + ACTOR_1E4_TOOTS = 0x1E4, ACTOR_1EA_POLAR_BEAR_CUB_BLUE = 0x1EA, @@ -2896,7 +2898,7 @@ enum asset_e // 549 GL Gold Feather Refill Pillow // 54a Gruntling (Red Cloak) // 54b (Big Fireball?) - // 54c Game Over Sign + ASSET_54C_MODEL_GAME_OVER = 0x54C, // 54d Banjo-Kazooie Sign // 54e Copyright Info (Title Screen) // 54f Cheato @@ -3633,6 +3635,8 @@ enum marker_e{ MARKER_168_ICE_KEY, MARKER_169_SNS_EGG, + MARKER_174_GAME_OVER = 0x174, + MARKER_182_RBB_EGG_TOLL = 0x182, MARKER_1AE_ZUBBA = 0x1AE, diff --git a/include/functions.h b/include/functions.h index ba251cef..ae488a54 100644 --- a/include/functions.h +++ b/include/functions.h @@ -210,7 +210,7 @@ void func_80300C70(enum item_e, struct8s *); struct7s *func_8030179C(s32); void func_80301DE4(enum item_e, struct7s *); -void func_803017D0(s32, struct8s *, Gfx**, Mtx**, s32); +void func_803017D0(enum item_e, struct8s *, Gfx**, Mtx**, Vtx **); void func_80301754(s32, struct8s *); diff --git a/include/model.h b/include/model.h index df953840..17f80a62 100644 --- a/include/model.h +++ b/include/model.h @@ -108,7 +108,8 @@ typedef struct { s16 unkC[3]; u8 unk12[3]; u8 unk15; - u8 pad16[2]; + s8 unk16; + u8 pad17[1]; }BKModelUnk14_0; typedef struct { @@ -117,7 +118,8 @@ typedef struct { s16 unk4[3]; u8 unkA[3]; u8 unkD; - u8 padE[2]; + s8 unkE; + u8 padF[1]; }BKModelUnk14_1; typedef struct { @@ -130,7 +132,7 @@ typedef struct { typedef struct { s16 cnt0; //number of BKModelUnk14_0 structs s16 cnt2; //number of BKModelUnk14_1 structs - s16 unk4; + s16 unk4; //number of BKModelUnk14_2 structs s16 unk6; //BKModelUnk14_0[] //BKModelUnk14_1[] diff --git a/include/prop.h b/include/prop.h index 2d4250a5..23f23c15 100644 --- a/include/prop.h +++ b/include/prop.h @@ -324,11 +324,11 @@ typedef struct { s16 x; s16 y; s16 z; - u16 unk6_15: 9; //selector_value + u16 unk6_15: 9; //selector_value //volume??? diameter u16 unk6_6: 6; //category u16 unk6_0: 1; u16 unk8; - u8 unkA; + u8 unkA; //marker_id u8 padB[1]; u32 unkC_31:9; u32 unkC_22:23; @@ -347,7 +347,7 @@ typedef struct cude_s{ s32 z:5; u32 prop1Cnt:6; u32 prop2Cnt:6; - u32 unk0_4:5; + u32 unk0_4:5; //node_prop_count NodeProp *prop1Ptr; Prop *prop2Ptr; }Cube; diff --git a/progress/progress_core2.svg b/progress/progress_core2.svg index 81c638cf..5f4e6f75 100644 --- a/progress/progress_core2.svg +++ b/progress/progress_core2.svg @@ -9,7 +9,7 @@ - + @@ -17,7 +17,7 @@ core2 - 78.6359% - 78.6359% + 78.9639% + 78.9639% \ No newline at end of file diff --git a/progress/progress_total.svg b/progress/progress_total.svg index b1d05fa6..7ad8b8dc 100644 --- a/progress/progress_total.svg +++ b/progress/progress_total.svg @@ -17,7 +17,7 @@ Banjo-Kazooie (us.v10) - 82.7246% - 82.7246% + 82.9127% + 82.9127% \ No newline at end of file diff --git a/src/MM/ch/jujuhitbox.c b/src/MM/ch/jujuhitbox.c index a090fa5c..e346d750 100644 --- a/src/MM/ch/jujuhitbox.c +++ b/src/MM/ch/jujuhitbox.c @@ -49,16 +49,16 @@ int func_80388B30(Actor *this, float arg1){ return 0; } -void func_80388BEC(s16 *arg0, ActorMarker *arg1){ +void func_80388BEC(NodeProp *arg0, ActorMarker *arg1){ f32 sp34; Actor *sp30; Actor *temp_v0; f32 sp20[3]; - sp20[0] = (f32)arg0[0]; - sp20[1] = (f32)arg0[1]; - sp20[2] = (f32)arg0[2]; + sp20[0] = (f32)arg0->x; + sp20[1] = (f32)arg0->y; + sp20[2] = (f32)arg0->z; sp30 = func_80326D68(sp20, 0x11, -1, &sp34); if( sp30 != NULL && !( sp34 > 500.0f ) diff --git a/src/core2/code_14420.c b/src/core2/code_14420.c index 9bf09709..82d02215 100644 --- a/src/core2/code_14420.c +++ b/src/core2/code_14420.c @@ -180,7 +180,7 @@ Struct_core2_13FC0 D_803648F0[14] = { // s32 exit_id; // }D_8037D1E0; s32 D_8037D1E0[2]; -extern u8 D_8037D1E8; +u8 D_8037D1E8; /* .code */ f32 func_8029B3B0(f32 arg0) { @@ -695,9 +695,6 @@ void func_8029C5E8(void){ func_8029AE1C(); } -#ifndef NONMATCHING -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_14420/func_8029C608.s") -#else void func_8029C608(void) { enum level_e level_id; enum map_e sp18; @@ -714,7 +711,6 @@ void func_8029C608(void) { D_8037D1E0[1] = phi_v0; D_8037D1E0[0] = sp18; } -#endif void func_8029C674(void) { f32 sp1C[3]; diff --git a/src/core2/code_55390.c b/src/core2/code_55390.c index 062e0dd3..a920742f 100644 --- a/src/core2/code_55390.c +++ b/src/core2/code_55390.c @@ -11,7 +11,7 @@ void func_802DC45C(Actor *this); /* .data */ f32 D_80368040[3] = {0.0f, 0.0f, 0.0f}; ActorInfo D_8036804C = { - 0x174, 0x1DB, 0x54C, + MARKER_174_GAME_OVER, ACTOR_1DB_GAME_OVER, ASSET_54C_MODEL_GAME_OVER, 0x1, NULL, func_802DC45C, func_80326224, func_802DC320, 0, 0, 0.0f, 0 @@ -74,7 +74,7 @@ void func_802DC45C(Actor *this){ void func_802DC4C4(void) { Actor *actor; if (D_8037DE40 == 0) { - actor = func_8032813C(0x1DB, D_80368040, 0); + actor = func_8032813C(ACTOR_1DB_GAME_OVER, D_80368040, 0); D_8037DE40 = actor->marker; func_8025A58C(0, 5000); func_8025AB00(); @@ -82,7 +82,7 @@ void func_802DC4C4(void) { } } -void func_802DC528(s32 arg0, s32 arg1){ +void func_802DC528(NodeProp *arg0, ActorMarker *arg1){ if(D_8037DE40 == NULL){ func_802C3BF8(func_802DC4C4); } @@ -91,7 +91,7 @@ void func_802DC528(s32 arg0, s32 arg1){ void func_802DC560(s32 arg0, s32 arg1){ if(D_8037DE40 != NULL){ comusic_8025AB44(COMUSIC_31_GAME_OVER, 0, 200); - func_8025AABC(0x31); + func_8025AABC(COMUSIC_31_GAME_OVER); func_80326310(marker_getActor(D_8037DE40)); } } diff --git a/src/core2/code_637D0.c b/src/core2/code_637D0.c index 3dba3167..e523172b 100644 --- a/src/core2/code_637D0.c +++ b/src/core2/code_637D0.c @@ -4,6 +4,7 @@ extern void func_80252C08(f32[3], f32[3], f32, f32[3]); extern void func_80252CC4(f32[3], f32[3], f32, s32); +extern void func_802524F0(f32[3], f32, f32, f32); /* .bss */ Mtx D_80380880; @@ -122,15 +123,194 @@ s32 func_802EAB34(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 } #endif +s32 func_802EAD5C(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, f32 arg5[3], f32 arg6) { + BKModelUnk14_0 *t0_ptr; + BKModelUnk14_1 *t1_ptr; + f32 sp5C[3]; + f32 temp_f20; + f32 sp4C[3]; + BKModelUnk14_2 *end_ptr; + BKModelUnk14_2 *var_s0; + f32 pad40; + f32 sp34[3]; -s32 func_802EAD5C(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, f32 arg6[3], f32 arg7); -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_637D0/func_802EAD5C.s") + mlMtxIdent(); + func_80252CC4(position, rotation, scale, arg4); + 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]; + temp_f20 = (f32)var_s0->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 0; +} + +#ifndef NONMATCHING s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, s32 arg5, f32 arg6[3], f32 arg7); #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_637D0/func_802EAED4.s") +#else +s32 func_802EAED4(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, struct58s *arg5, f32 arg6[3], f32 arg7) { + f32 spF4[3]; + f32 spE8[3]; + f32 spDC[3]; + f32 spD0[3]; + BKModelUnk14_0 *end_ptr; + BKModelUnk14_0 *var_s0; + f32 spBC[3]; + f32 spB0[3]; + f32 spA4[3]; + f32 sp98[3]; + f32 sp8C[3]; + f32 sp80[3]; + f32 sp74[3]; + 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]; + + spE8[0] = (f32) var_s0->unk0[0]; + spE8[1] = (f32) var_s0->unk0[1]; + spE8[2] = (f32) var_s0->unk0[2]; + + spDC[0] = (f32) var_s0->unk6[0]; + spDC[1] = (f32) var_s0->unk6[1]; + spDC[2] = (f32) var_s0->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] *= 2; + spD0[1] *= 2; + spD0[2] *= 2; + func_802519C8(&D_80380880, func_802EA110(arg5, var_s0->unk16)); + func_80252E4C(spF4, spD0); + func_802524F0(spB0, spE8[0], spE8[1], spE8[2]); + func_802524F0(sp98, spE8[0], spE8[1], spDC[2]); + spBC[0] = spB0[0] - sp98[0]; + spBC[1] = spB0[1] - sp98[1]; + spBC[2] = spB0[2] - sp98[2]; + ml_vec3f_normalize(spBC); + spA4[0] = arg6[0] - spB0[0]; + spA4[1] = arg6[1] - spB0[1]; + spA4[2] = arg6[2] - spB0[2]; + if ((arg7 <= ((spA4[0]*spBC[0]) + (spA4[1]*spBC[1]) + (spA4[2]*spBC[2])))) { + sp8C[0] = arg6[0] - sp98[0]; + sp8C[1] = arg6[1] - sp98[1]; + sp8C[2] = arg6[2] - sp98[2]; + if (!(arg7 <= -((sp8C[0]*spBC[0]) + (sp8C[1]*spBC[1]) + (sp8C[2]*spBC[2])))) { + func_802524F0(sp80, spDC[0], spE8[1], spE8[2]); + spBC[0] = spB0[0] - sp80[0]; + spBC[1] = spB0[1] - sp80[1]; + spBC[2] = spB0[2] - sp80[2]; + ml_vec3f_normalize(spBC); + if (!(arg7 <= ((spA4[0]*spBC[0]) + (spA4[1]*spBC[1]) + (spA4[2]*spBC[2])))) { + sp74[0] = arg6[0] - sp80[0]; + sp74[1] = arg6[1] - sp80[1]; + sp74[2] = arg6[2] - sp80[2]; + if (!(arg7 <= -((sp74[0]*spBC[0]) + (sp74[1]*spBC[1]) + (sp74[2]*spBC[2])))) { + func_802524F0(sp68, spE8[0], spDC[1], spE8[2]); + spBC[0] = spB0[0] - sp68[0]; + spBC[1] = spB0[1] - sp68[1]; + spBC[2] = spB0[2] - sp68[2]; + ml_vec3f_normalize(spBC); + if (!(arg7 <= ((spA4[0]*spBC[0]) + (spA4[1]*spBC[1]) + (spA4[2]*spBC[2])))) { + sp5C[0] = arg6[0] - sp68[0]; + sp5C[1] = arg6[1] - sp68[1]; + sp5C[2] = arg6[2] - sp68[2]; + if (!(arg7 <= -((sp5C[0]*spBC[0]) + (sp5C[1]*spBC[1]) + (sp5C[2]*spBC[2])))) { + return 1; + } + } + } + } + } + } + mlMtxPop(); + } + return 0; +} +#endif + +#ifndef NONMATCHING s32 func_802EB458(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, s32 arg5, f32 arg6[3], f32 arg7); #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_637D0/func_802EB458.s") +#else +s32 func_802EB458(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, s32 arg5, f32 arg6[3], f32 arg7) { + BKModelUnk14_0 *ptr_t0; + f32 spB8[3]; + f32 spAC[3]; + f32 sp98[3]; + f32 sp8C[3]; + f32 sp80[3]; + f32 sp74[3]; + f32 sp68[3]; + f32 temp_f0; + f32 temp_f20; + BKModelUnk14_1 *temp_s2; + BKModelUnk14_1 *var_s0; + + 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++){ + 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)); + 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)); + sp68[0] -= sp98[0]; + sp68[1] -= sp98[1]; + sp68[2] -= sp98[2]; + sp80[0] = sp98[0] - sp8C[0]; + sp80[1] = sp98[1] - sp8C[1]; + sp80[2] = sp98[2] - sp8C[2]; + ml_vec3f_normalize(sp80); + sp74[0] = arg6[0] - sp98[0]; + sp74[1] = arg6[1] - sp98[1]; + sp74[2] = arg6[2] - sp98[2]; + temp_f0 = sp80[0]*sp74[0] + sp80[1]*sp74[1] + sp80[2]*sp74[2]; + if (!(arg7 < temp_f0)) { + sp74[0] = arg6[0] - sp8C[0]; + sp74[1] = arg6[1] - sp8C[1]; + sp74[2] = arg6[2] - sp8C[2]; + if (!(arg7 < -(sp80[0]*sp74[0] + sp80[1]*sp74[1] + sp80[2]*sp74[2]))) { + sp74[0] = arg6[0] - (sp98[0] + (sp80[0]*temp_f0)); + sp74[1] = arg6[1] - (sp98[1] + (sp80[1]*temp_f0)); + sp74[2] = arg6[2] - (sp98[2] + (sp80[2]*temp_f0)); + 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; + } + } + } + mlMtxPop(); + } + return 0; +} +#endif s32 func_802EB8A0(BKModelUnk14List *arg0, f32 position[3], f32 rotation[3], f32 scale, s32 arg4, s32 arg5, f32 arg6[3], f32 arg7); #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_637D0/func_802EB8A0.s") diff --git a/src/core2/code_7A760.c b/src/core2/code_7A760.c index cb835305..741c24ce 100644 --- a/src/core2/code_7A760.c +++ b/src/core2/code_7A760.c @@ -2,6 +2,8 @@ #include "functions.h" #include "variables.h" +extern f32 func_802FB0E4(struct8s *); + /* .data */ BKSprite *D_8036A960 = NULL; Gfx D_8036A968[] ={ @@ -15,9 +17,6 @@ Gfx D_8036A968[] ={ gsSPEndDisplayList(), }; -/* .rodata */ -extern f64 D_803774A0; - /* .bss */ s32 D_80381F50; f32 D_80381F54; @@ -28,24 +27,104 @@ f32 D_80381F68[6]; struct7s D_80381F80; /* .code */ -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_803016F0.s") +void func_803016F0(void) { + s32 i; -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_80301754.s") + D_80381F58 = -272.0f; + D_80381F54 = 1.0f; + D_80381F50 = 0; + for(i = 0; i < 6; i++){ + D_80381F68[i] = -64.0f; + } +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_8030179C.s") +void func_80301754(s32 arg0, struct8s *arg1) { + if (D_8036A960 != NULL) { + func_8033BD4C(D_8036A960); + D_8036A960 = NULL; + } + func_803016F0(); +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_803017D0.s") +struct7s *func_8030179C(s32 arg0) { + func_803016F0(); + D_80381F5C = 0.68f; + return &D_80381F80; +} -bool func_80301CE0(f32, s32, s32); -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_80301CE0.s") +void func_803017D0(enum item_e item_id, struct8s *arg1, Gfx **gfx, Mtx **mtx, Vtx **vtx) { + f32 temp_f16; + f32 var_f14; + s32 spD4; + s32 spD0; + s32 var_s4; + s32 var_s6; + s32 var_s7; + s32 var_v0; + s32 var_v1; -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_80301D24.s") + if (D_8036A960 != 0) { + gSPDisplayList((*gfx)++, D_8036A968); + func_80347FC0(gfx, D_8036A960, 0, 0, 0, 0, 0, 2, 2, &spD4, &spD0); + func_8024C7B8(gfx, mtx); + for(var_s4 = 0; var_s4 < 6; var_s4++){ + var_s7 = var_s4 & 1; + if ((var_s4 != 0) && (var_s4 != 5)) { + var_s6 = (var_s7) ? var_s4 + 1 : var_s4 - 1; + } else { + var_s6 = var_s4; + } + gDPPipeSync((*gfx)++); + if ((f32) (5 - var_s4) < D_80381F60) { + gDPSetPrimColor((*gfx)++, 0, 0, 0x00, 0x00, 0x00, 0xFF); + } else { + gDPSetPrimColor((*gfx)++, 0, 0, 0x00, 0x00, 0x00, 0x78); + } + temp_f16 = func_802FB0E4(arg1); + temp_f16 = (-40.0f + temp_f16); + var_f14 = (temp_f16 + D_80381F68[var_s6]) - ((f32) D_80276588 / 2); + temp_f16 = (((var_s4 * 15.5) + 78.0) - ((f32) D_8027658C / 2)); + var_f14 = (var_s7) ? var_f14 + 5.0f : var_f14 - 5.0f; + gSPVertex((*gfx)++, *vtx, 4, 0); + for(var_v1 = 0; var_v1 < 2; var_v1++){ + for(var_v0 = 0; var_v0 < 2; var_v0++){ + (*vtx)->v.ob[0] = ((((spD4 * D_80381F5C) * (f32) var_v0) - ((spD4 * D_80381F5C) / 2)) + var_f14) * 4.0f; + (*vtx)->v.ob[1] = ((((spD0 * D_80381F5C) / 2) - ((spD0 * D_80381F5C) * ((f32)var_v1))) + temp_f16) * 4.0f; + (*vtx)->v.ob[2] = -0x14; + (*vtx)->v.tc[0] = ((spD4 - 1) * var_v0) << 6; + (*vtx)->v.tc[1] = ((spD0 - 1) * var_v1) << 6; + (*vtx)++; + } + } + gSP1Quadrangle((*gfx)++, 0, 1, 3, 2, 0); + } + gDPPipeSync((*gfx)++); + gDPSetTextureLUT((*gfx)++, G_TT_NONE); + gDPPipelineMode((*gfx)++, G_PM_NPRIMITIVE); + func_8024C904(gfx, mtx); + } +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_80301DBC.s") +bool func_80301CE0(f32 arg0, s32 arg1, s32 arg2){ + if(arg1 == 5) + return TRUE; + + return arg0 < D_80381F68[arg1 + 1]; +} + +s32 func_80301D24(s32 time) { + s32 minutes; + s32 var_v0; + + var_v0 = (time != 0) ? 1 : 0; + minutes = (((s32) (6*time) / 60) / 60) + var_v0; + return MIN(6, minutes); +} + +s32 func_80301DBC(s32 minutes) { + return (s32) (minutes * 60 * 60) / 6; +} -#ifndef NONMATCHING //probably just need .rodata defined -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7A760/func_80301DE4.s") -#else void func_80301DE4(enum item_e arg0, struct7s *arg1) { s32 temp_s0; s32 var_s0; @@ -69,9 +148,8 @@ void func_80301DE4(enum item_e arg0, struct7s *arg1) { if (temp_s0 != 0) { for(var_s0 = 5; var_s0 >= 0; var_s0--){ if (func_80301CE0(-15.0f, var_s0, 6)) { - D_80381F68[var_s0] *= D_803774A0; + D_80381F68[var_s0] *= 0.6; } } } } -#endif diff --git a/src/core2/code_7AF80.c b/src/core2/code_7AF80.c index 52bc4dd2..93271b64 100644 --- a/src/core2/code_7AF80.c +++ b/src/core2/code_7AF80.c @@ -91,7 +91,7 @@ struct { } D_80381FA0; u8 D_80381FE8[0x50]; -s32 D_80382038[0x20]; +Cube *D_80382038[0x20]; s32 D_803820B8[0x20]; //ActorProp *, (maybe Prop *) s32 pad_80382138; s32 D_8038213C; @@ -1493,9 +1493,44 @@ bool func_80307390(s32 arg0, s32 arg1) { #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7AF80/func_803077FC.s") +Cube *func_80307948(s32 arg0[3]); #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7AF80/func_80307948.s") + #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7AF80/func_80307CA0.s") +// void func_80307CA0(ActorMarker *marker) { +// s32 sp58[3]; +// s32 sp40[3]; +// Cube **var_s2; +// Cube *var_a0; +// NodeProp *temp_v0_2; +// s32 temp_v0_3; +// u32 var_s0; +// u8 temp_s4; +// s32 i; + +// temp_s4 = D_8036A9E4[marker->unk14_20]; +// if ((temp_s4 != 0xFF) && (func_802CAF70(D_8036A9E0, temp_s4) == 1)) { +// func_8032E010(marker->propPtr, sp58); +// var_s2 = func_80307948(sp58); +// var_a0 = *var_s2; +// for(i = 0; var_s2[i] != NULL; i++) { +// for(var_s0 = 0; var_s0 < var_s2[i]->unk0_4; var_s0++){ +// temp_v0_2 = func_8032E02C(var_a0, var_s0); +// if (func_80330F74(temp_v0_2) == temp_s4) { +// temp_v0_3 = func_80330F94(temp_v0_2, sp40); +// if( ((sp40[0] - temp_v0_3) < sp58[0]) && (sp58[0] < (sp40[0] + temp_v0_3)) +// && ((sp40[1] - temp_v0_3) < sp58[1]) && (sp58[1] < (sp40[1] + temp_v0_3)) +// && ((sp40[2] - temp_v0_3) < sp58[2]) && (sp58[2] < (sp40[2] + temp_v0_3)) +// ) { +// func_80334448(temp_v0_2, marker); +// } +// } +// } +// } +// } +// } + u32 func_80307E1C(void) { Cube *phi_v0; @@ -1540,6 +1575,7 @@ void func_80308230(s32 arg0) { #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7AF80/func_803083B0.s") + #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_7AF80/func_803084F0.s") void func_80308658(Struct_core2_7AF80_1 *arg0, s32 arg1) { diff --git a/src/core2/code_A5BC0.c b/src/core2/code_A5BC0.c index 39c29967..8b8745eb 100644 --- a/src/core2/code_A5BC0.c +++ b/src/core2/code_A5BC0.c @@ -458,9 +458,19 @@ ActorMarker *func_8032DCAC(void){ #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_8032DFF4.s") -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_8032E010.s") +void func_8032E010(ActorProp *prop, s32 dst[3]){ + dst[0] = prop->x; + dst[1] = prop->y; + dst[2] = prop->z; +} + +NodeProp *func_8032E02C(Cube *cube, s32 prop_index) { + if ((prop_index < 0) || (prop_index >= cube->prop1Cnt)) { + return NULL; + } + return &cube->prop1Ptr[prop_index]; +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_8032E02C.s") #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_8032E070.s") @@ -1137,13 +1147,24 @@ BKSprite *func_80330F50(ActorMarker * marker){ return sp1C; } -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_80330F74.s") +s32 func_80330F74(NodeProp *arg0){ + return arg0->unkA; //marker_id +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_80330F7C.s") +s32 func_80330F7C(NodeProp *arg0){ + return arg0->unk6_6; +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_80330F8C.s") +s32 func_80330F8C(NodeProp *arg0){ + return arg0->unk8; +} -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_80330F94.s") +s32 func_80330F94(NodeProp *arg0, s32 arg1[3]){ + arg1[0] = arg0->x; + arg1[1] = arg0->y; + arg1[2] = arg0->z; + return arg0->unk6_15; +} #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_A5BC0/func_80330FBC.s") diff --git a/src/core2/code_AD110.c b/src/core2/code_AD110.c index 8f442034..dbf9789a 100644 --- a/src/core2/code_AD110.c +++ b/src/core2/code_AD110.c @@ -551,10 +551,10 @@ void func_80334430(s32 arg0, s32 arg1){} void func_8033443C(s32 arg0, s32 arg1){} -void func_80334448(s32 arg0, s32 arg1) { +void func_80334448(NodeProp *arg0, ActorMarker *arg1) { s32 sp24; - switch(func_80330F7C()) { + switch(func_80330F7C(arg0)) { case 3: //L80334480 sp24 = func_8023DB5C(); if ((func_80330FC4(arg0) + 1) != sp24) { diff --git a/src/core2/code_C4B0.c b/src/core2/code_C4B0.c index d99a792f..2f8b60f2 100644 --- a/src/core2/code_C4B0.c +++ b/src/core2/code_C4B0.c @@ -2,13 +2,17 @@ #include "functions.h" #include "variables.h" -extern int func_80258424(f32 vec[3], f32 minX, f32 minY, f32 minZ, f32 maxX, f32 maxY, f32 maxZ); -extern f32 func_8031C5D4(struct0*); -extern void func_8031C5AC(struct0 *, f32 *); -extern f32 func_8031C5E4(struct0*); -extern void func_8031C5FC(struct0 *, f32); -extern f32 func_80255D70(f32 arg0); -extern s32 func_8029463C(void); +extern int func_80258424(f32 vec[3], f32 minX, f32 minY, f32 minZ, f32 maxX, f32 maxY, f32 maxZ); +extern f32 func_8031C5D4(struct0*); +extern void func_8031C5AC(struct0 *, f32 *); +extern f32 func_8031C5E4(struct0*); +extern void func_8031C5FC(struct0 *, f32); +extern void func_80244FC0(f32 arg0[3], f32 arg1[3], f32 arg2, f32 arg3, s32 arg4, u32 arg5); +extern s32 func_80244E54(f32[3], f32[3], f32 [3], u32, f32, f32); +extern Struct66s *func_802457C4(f32[3], f32[3], f32, f32, f32[3], s32, u32); +extern f32 func_80255D70(f32 arg0); +extern s32 func_8029463C(void); +extern Struct66s *func_80320C94(f32[3], f32[3], f32, f32[3], s32, u32); void func_80294378(s32 arg0); void func_80294384(s32 arg0); @@ -17,12 +21,24 @@ void func_80294390(void); typedef struct { f32 unk0[3]; f32 unkC[3]; - u8 pad18[0x78]; + Struct66s *unk18; + f32 unk1C[3]; + f32 unk28[3]; + f32 unk34[3]; + s32 unk40; + f32 unk44[3]; + u8 pad50[0x18]; + f32 unk68[3]; + u8 pad74[0x18]; + s32 unk8C; }Struct_core2_C4B0_0; /* .rodata */ extern f64 D_80374760; extern f64 D_80374768; +extern f64 D_80374770; +extern f64 D_80374778; +extern f64 D_80374780; /* .bss */ f32 D_8037C1F0[2]; @@ -84,13 +100,13 @@ void func_8029350C(f32 *arg0) { func_8031C5AC(D_8037C200, sp3C); temp_v0 = D_8037C279; D_8037C279 = FALSE; - if (!(sp3C[1] < D_80374760)) { + if (!(sp3C[1] < 0.432)) { if (arg0[1] <= sp38) { arg0[1] = sp38; D_8037C279 = TRUE; } else if ((temp_v0 != 0) && (D_8037C238[1] < 0.0f)) { - if (sp3C[1] < D_80374768) { + if (sp3C[1] < 0.9) { if (arg0[1] < (sp38 + 30.0f)) { arg0[1] = sp38; D_8037C279 = TRUE; @@ -103,8 +119,142 @@ void func_8029350C(f32 *arg0) { } } +#ifndef NONMATCHING #pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C4B0/func_80293668.s") +#else +void func_80293668(void) { + f32 sp3AC[3]; + f32 sp3A0[3]; + f32 temp_f0; + f32 sp390[3]; + f32 sp38C; + f32 sp380[3]; + f32 sp374[3]; + s32 i; + f32 sp364[3]; + Struct_core2_C4B0_0 *var_s1; + Struct_core2_C4B0_0 sp90[5]; + u32 temp_s7; + s32 temp_v0; + temp_v0 = func_8028D694(); + func_80244FC0(D_8037C228, sp390, D_8037C1F8[1], D_8037C1F8[0], 1, temp_v0 | 0x1E0000); + temp_s7 = temp_v0 | 0x1E0000; + for(i = 0; i < 5; i++){ + var_s1 = (i != 0) ? &sp90[i - 1] : NULL; + + if (i != 0) { + ml_vec3f_copy(sp90[i].unk0, var_s1->unk0); + ml_vec3f_copy(sp90[i].unkC, var_s1->unkC); + } else { + ml_vec3f_copy(sp90[i].unk0, D_8037C218); + ml_vec3f_copy(sp90[i].unkC, D_8037C228); + } + ml_vec3f_copy(sp364, sp90[i].unk0); + ml_vec3f_diff_copy(sp380, sp90[i].unk0, sp90[i].unkC); + temp_f0 = ((D_8037C1F8[1] * 2) - 4.0f); + if ((sp380[0]*sp380[0] + sp380[1]*sp380[1] + sp380[2]*sp380[2]) > (temp_f0 * temp_f0)) { + sp38C = sp90[i].unk0[1]; + sp90[i].unk40 = func_80244E54(sp90[i].unkC, sp90[i].unk0, sp90[i].unk44, temp_s7, D_8037C1F8[1] - 1.0f, D_8037C1F8[0]); + if (sp90[i].unk40 != 0) { + ml_vec3f_normalize(sp380); + if ((sp380[0]*sp90[i].unk44[0] + sp380[1]*sp90[i].unk44[1] + sp380[2]*sp90[i].unk44[2]) > 0.0f) { + sp90[i].unk40 = 0; + ml_vec3f_copy(sp90[i].unk0, sp364); + } + } + if (sp90[i].unk40 != 0) { + if ((sp90[i].unk44[1] >= 0.0) && (sp90[i].unk44[1] < D_80374770)) { + sp90[i].unk0[1] = sp38C; + } + } + } else { + sp90[i].unk40 = 0; + } + func_8029350C(sp90[i].unk0); + sp90[i].unk8C = D_8037C279; + sp90[i].unk34[0] = sp90[i].unkC[0]; + sp90[i].unk34[1] = sp90[i].unkC[1]; + sp90[i].unk34[2] = sp90[i].unkC[2]; + sp90[i].unk34[1] +=D_8037C1F8[0]; + + sp90[i].unk28[0] = sp90[i].unk0[0]; + sp90[i].unk28[1] = sp90[i].unk0[1]; + sp90[i].unk28[2] = sp90[i].unk0[2]; + sp90[i].unk28[1] +=D_8037C1F8[0]; + + sp90[i].unk18 = func_80320C94(sp90[i].unk34, sp90[i].unk28, D_8037C1F8[1], sp90[i].unk1C, 3, temp_s7); + if (sp90[i].unk18 != NULL) { + D_8037C27D++; + D_8037C204 = sp90[i].unk18; + ml_vec3f_copy(D_8037C258, sp90[i].unk1C); + if (i == 2) { + if ((sp90[i].unk18 == sp90[0].unk18) && (var_s1->unk18 != sp90[0].unk18)) { + ml_vec3f_add(sp380, sp90[i].unk1C, var_s1->unk1C); + ml_vec3f_normalize(sp380); + ml_vec3f_copy(sp90[i].unk1C, sp380); + } + } + if (i == 2) { + if (sp90[i].unk18 == sp90[0].unk18) { + if ((var_s1->unk18 == sp90[i].unk18) && func_802946FC(sp90[i].unk68, sp90[i].unk18)) { + func_802578A4(sp380, sp90[i].unk0, sp90[i].unk68); + ml_vec3f_diff_copy(sp3A0, sp90[i].unk0, sp380); + ml_vec3f_set_length_copy(sp3A0, sp3A0, D_8037C1F8[1] + 1.0f); + sp380[0] += sp3A0[0]; + sp380[1] += sp3A0[1]; + sp380[2] += sp3A0[2]; + if (!(sp90[i].unk18->unk8 & 0x00010000)) { + sp90[i].unk18 = func_802457C4(sp380, sp90[i].unk0, D_8037C1F8[0], D_8037C1F8[1], sp90[i].unk1C, 3, temp_s7); + } else { + ml_vec3f_copy(sp90[i].unk0, sp380); + } + } + } + } + if ((sp90[i].unk8C == 0) && (sp90[i].unk18 != NULL) && (D_8037C238[1] < 0.0f)) { + if( (mlAbsF(sp90[i].unk1C[1]) < D_80374778) && func_802946FC(sp90[i].unk68, sp90[i].unk18)) { + func_802578A4(sp380, sp90[i].unk0, sp90[i].unk68); + ml_vec3f_scale_copy(sp3A0, sp90[i].unk1C, D_8037C1F8[1] + 1.0f); + ml_vec3f_add(sp374, sp380, sp3A0); + sp90[i].unk18 = func_802457C4(sp374, sp380, D_8037C1F8[0], D_8037C1F8[1], sp90[i].unk1C, 3, temp_s7); + sp90[i].unk0[0] = sp380[0]; + sp90[i].unk0[2] = sp380[2]; + } + } + if ((D_80374780 < sp90[i].unk1C[1]) && func_802946FC(sp90[i].unk68, sp90[i].unk18)) { + func_8025778C(sp3AC, sp90[i].unk0, sp90[i].unk68); + sp380[0] = sp90[i].unk0[0] - sp3AC[0]; + sp380[1] = 0.0f; + sp380[2] = sp90[i].unk0[2] - sp3AC[2]; + ml_vec3f_set_length_copy(sp380, sp380, D_8037C1F8[1] + 1.0f); + sp380[0] = sp380[0] + sp3AC[0]; + sp380[1] = sp380[1] + sp3AC[1]; + sp380[2] = sp380[2] + sp3AC[2]; + sp90[i].unk0[0] = sp380[0]; + sp90[i].unk0[2] = sp380[2]; + } else if (func_80258368(sp90[i].unk1C)) { + func_802450DC(sp90[i].unkC, sp90[i].unk0, sp90[i].unk34, sp90[i].unk28, sp90[i].unk1C); + } + + } + else{ + break; + } + } + + if ((i == 5) && (D_8037C279 == 0) && (D_8037C204 != 0) && (D_8037C218[1] < D_8037C228[1])) { + D_8037C27C = 1; + } + + if (i == 5) { + ml_vec3f_copy(D_8037C218, sp390); + } + else{ + ml_vec3f_copy(D_8037C218, sp90[i].unk0); + } +} +#endif void func_80293D2C(f32 *arg0, f32 * arg1){ *arg0 = D_8037C1F8[0]; @@ -120,21 +270,13 @@ void func_80293D48(f32 arg0, f32 arg1){ void func_80293D74(void){ func_80293D48(80.0f, 35.0f);} -#ifndef NONMATCHING -#pragma GLOBAL_ASM("asm/nonmatchings/core2/code_C4B0/func_80293DA4.s") -#else void func_80293DA4(void){ - D_8037C278 = 0; - D_8037C279 = 0; - D_8037C27B = 0; - D_8037C27C = 0; - D_8037C27E = 0; - D_8037C280 = 0; + D_8037C278 = D_8037C279 = D_8037C27B = D_8037C27E = D_8037C27C = D_8037C280 = 0; D_8037C200 = func_8031B9D8(); - ml_vec3f_clear(&D_8037C268); - ml_vec3f_clear(&D_8037C218); - ml_vec3f_clear(&D_8037C228); - ml_vec3f_clear(&D_8037C258); + ml_vec3f_clear(D_8037C268); + ml_vec3f_clear(D_8037C218); + ml_vec3f_clear(D_8037C228); + ml_vec3f_clear(D_8037C258); D_8037C204 = 0; D_8037C27F = 0; func_80293D74(); @@ -145,7 +287,6 @@ void func_80293DA4(void){ D_8037C274 = 0; func_80294378(1); } -#endif void func_80293E88(void){ func_8031BA9C(D_8037C200); @@ -198,7 +339,7 @@ void func_80293F0C(void){ player_setYVelocity(1.0f); } func_80293668(); - player_setPosition(&D_8037C218); + player_setPosition(D_8037C218); break; case 5: diff --git a/subyaml/core2.us.v10.yaml b/subyaml/core2.us.v10.yaml index c10e5c0f..c663b5f8 100644 --- a/subyaml/core2.us.v10.yaml +++ b/subyaml/core2.us.v10.yaml @@ -283,7 +283,7 @@ segments: - [0x78E50, c, code_78E50] - [0x79830, c, fxcommon3score] #DONE - [0x79C80, c, code_79C80] - - [0x7A760, c, code_7A760] + - [0x7A760, c, code_7A760] #DONE - [0x7AF80, c, code_7AF80] - [0x82000, c, code_82000] - [0x83340, c, code_83340] @@ -596,7 +596,8 @@ segments: - [0xED770, .rodata, code_B850] - [0xED790, .rodata, code_BD20] - [0xED7B0, .rodata, code_C0E0] - - [0xED7D0, bin, data_ED7D0] + - [0xED7D0, .rodata, code_C4B0] + - [0xED7E0, bin, data_ED7E0] #.rodata, code_C4B0] - [0xED7F0, bin, data_ED7F0] #.rodata, code_C4B0] - [0xED810, .rodata, code_D9B0] - [0xED820, .rodata, code_E680] @@ -749,7 +750,7 @@ segments: - [0xF04A0, .rodata, code_78100] - [0xF04D0, .rodata, fxcommon3score] - [0xF04F0, .rodata, code_79C80] - - [0xF0500, bin, data_F0500] + - [0xF0500, .rodata, code_7A760] - [0xF0520, .rodata, code_7AF80] - [0xF0540, bin, data_F0540] - [0xF14C0, .rodata, gc/transition]