From cdabbfdbde960dbed9590b7d27ac229b2c1c4857 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Thu, 4 Aug 2022 01:34:04 -0400 Subject: [PATCH] Even more OKs --- include/functions.h | 2 +- include/variables.h | 1 - include/z64map.h | 24 +++--- include/z64scene.h | 8 -- src/code/z_map_data.c | 4 +- src/code/z_map_disp.c | 149 ++++++++++++++++++++++++++++++++++--- tools/disasm/variables.txt | 3 +- 7 files changed, 156 insertions(+), 35 deletions(-) diff --git a/include/functions.h b/include/functions.h index 7160a95fe..a9705281d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1682,7 +1682,7 @@ s16 func_80105318(void); // void func_80105328(void); // void func_8010534C(void); void func_8010549C(PlayState* play, void* segmentAddress); -void func_8010565C(PlayState* play, u8 num, void* segmentAddress); +void func_8010565C(PlayState* play, s32 num, void* segmentAddress); void func_80105818(PlayState* play, u32 uParm2, TransitionActorEntry* puParm3); void func_80105A40(void); void func_80105B34(PlayState* play); diff --git a/include/variables.h b/include/variables.h index 7c1733512..7ccb36154 100644 --- a/include/variables.h +++ b/include/variables.h @@ -3164,7 +3164,6 @@ extern s16 D_801F4E7A; // extern LightsBuffer sLightsBuffer; // extern UNK_TYPE1 D_801F5130; // extern UNK_TYPE1 D_801F5270; -// extern UNK_TYPE1 D_801F528E; // extern UNK_TYPE1 D_801F53B0; // extern UNK_TYPE1 D_801F56B0; // extern UNK_TYPE1 D_801F5730; diff --git a/include/z64map.h b/include/z64map.h index 13c861965..a17317548 100644 --- a/include/z64map.h +++ b/include/z64map.h @@ -23,6 +23,14 @@ typedef struct { /* 0x04 */ s16 unk4; } MinimapList2; // size = 0x8 +typedef struct { + /* 0x00 */ UNK_TYPE2 unk0; + /* 0x02 */ UNK_TYPE2 unk2; + /* 0x04 */ UNK_TYPE2 unk4; + /* 0x06 */ UNK_TYPE2 unk6; + /* 0x08 */ UNK_TYPE2 unk8; +} MinimapChest; // size = 0xA + /* z_map_data */ typedef struct { @@ -63,13 +71,6 @@ typedef struct { /* 0x08 */ s32 unk8; // G_IM_SIZ } T_801BEAE0; -typedef struct { - /* 0x00 */ s16 unk0; - /* 0x00 */ s16 unk2; - /* 0x00 */ s16 unk4; - /* 0x00 */ s16 unk6; -} T_801BEBB8_unk48; - typedef struct { /* 0x00 */ MinimapList2* unk0; //unk0 -> sub1 -> s16[5] /* 0x04 */ s32 unk4; @@ -84,7 +85,8 @@ typedef struct { /* 0x1E */ s16 unk1E; //same as 0E /* 0x20 */ s32 unk20; /* 0x24 */ s32 unk24; - /* 0x28 */ char unk28[8]; + /* 0x28 */ void* unk28; + /* 0x2C */ void* unk2C; /* 0x30 */ s16 unk30; //scene minBounds.x /* 0x32 */ s16 unk32; //scene minBounds.z /* 0x34 */ s16 unk34; //scene boundsWidth.x @@ -97,8 +99,11 @@ typedef struct { /* 0x44 */ s16 unk44; /* 0x48 */ s16* unk48; /* 0x4C */ s16 unk4C; - /* 0x4E */ char unk4E[0x0A]; + /* 0x4E */ char unk4E[0x02]; + /* 0x50 */ s32 unk50; //num chests + /* 0x54 */ MinimapChest* unk54; /* 0x58 */ s16 unk58; + /* 0x5A */ s16 unk5A; } T_801BEBB8; typedef struct { @@ -138,6 +143,7 @@ typedef struct { /* z_map_data */ s32 func_80109CBC(s32); s32 func_80109A98(s32); +s32 func_80109AD8(s32); s32 func_801096D4(s32 arg0); void func_8010983C(s32 arg0, s32 *arg1); void func_801097C8(s32 arg0, s32* arg1, s32* arg2); diff --git a/include/z64scene.h b/include/z64scene.h index 14a238917..d750647f0 100644 --- a/include/z64scene.h +++ b/include/z64scene.h @@ -469,14 +469,6 @@ typedef struct { /* 0x04 */ Vec3s* points; // Segment Address to the array of points } Path; // size = 0x8 -typedef struct { - /* 0x00 */ UNK_TYPE2 unk0; - /* 0x02 */ UNK_TYPE2 unk2; - /* 0x04 */ UNK_TYPE2 unk4; - /* 0x06 */ UNK_TYPE2 unk6; - /* 0x08 */ UNK_TYPE2 unk8; -} MinimapChest; // size = 0xA - // TODO: consider merging with bgCamInfo? typedef struct { /* 0x0 */ s16 setting; // camera setting described by CameraSettingType enum diff --git a/src/code/z_map_data.c b/src/code/z_map_data.c index d0240a76f..ee570aa21 100644 --- a/src/code/z_map_data.c +++ b/src/code/z_map_data.c @@ -12,6 +12,8 @@ extern Color_RGBA8 D_801BED40[]; extern s32 D_801BF3B4[]; extern s32 D_801BEFC8[]; +s32 func_80109A98(s32); + void func_801094A0(s32 arg0, Color_RGBA8* color) { *color = D_801BED40[arg0]; } @@ -184,8 +186,6 @@ s16 func_80109A20(s32 arg0) { return D_801BF170[arg0].unk8; } -s32 func_80109A98(s32); /* extern */ - s32 func_80109A40(s32 arg0) { s32 temp_s2; s32 var_s0; diff --git a/src/code/z_map_disp.c b/src/code/z_map_disp.c index a84891354..38e5e69a7 100644 --- a/src/code/z_map_disp.c +++ b/src/code/z_map_disp.c @@ -1,6 +1,7 @@ #include "global.h" #include "z64map.h" +void func_801068B4(PlayState* play); void func_80103090(MinimapEntry*, s32*, s32*); void func_80105FE0(PlayState* play, s32 x, s32 z, s32 rot); void func_80106644(PlayState* play, s32 x, s32 z, s32 rot); @@ -30,6 +31,7 @@ extern T_801BEBB8 D_801BEBB8; extern s16 D_801BEC10; extern MinimapList D_801BEC14; //D_801F5130 extern s32 D_801BEC1C; //current scene's no. of rooms +extern s32 D_801BEC20; //MinimapChest count extern u8 D_801BEC24; extern Color_RGBA8 D_801BEC2C[]; // cat colors extern T_801BEC5C D_801BEC5C[5]; @@ -39,7 +41,9 @@ extern u16 D_801BECA4[0x10]; //palette 1 extern u16 D_801BECC4[0x10]; //palette 2 extern T_801BED24 D_801BED24[2]; + extern MinimapEntry D_801F5130[0x50]; +extern MinimapChest D_801F5270[32]; extern T_801F53B0 D_801F53B0[]; extern T_801F56B0 D_801F56B0; extern TexturePtr D_801F57B4[32]; //unconfirmed length @@ -50,22 +54,63 @@ extern Gfx D_0401ED00[]; void func_80102E40(s32 arg0, s32 arg1) { if (func_80109A98(arg1) != 0) { - func_80178E3C(_map_i_staticSegmentRomStart, arg1, arg0, func_80109A98(arg1)); + func_80178E3C(SEGMENT_ROM_START(map_i_static), arg1, arg0, func_80109A98(arg1)); } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80102E90.s") +void func_80102E90(PlayState* play, s16* arg1) { + *arg1 = -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80102EA4.s") +void func_80102EA4(UNK_TYPE4 arg0, UNK_TYPE4 arg1) { -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80102EB4.s") +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80102ED0.s") +void func_80102EB4(u32 param_1) { + D_801BEBB8.unk20 |= param_1; +} -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80102EF0.s") +void func_80102ED0(u32 param_1) { + D_801BEBB8.unk20 &= ~param_1; +} -f32 func_80102F9C(f32); -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80102F9C.s") +s32 func_80102EF0(PlayState* play) { + MinimapEntry* entry; + s8 temp_v1; + + if (Map_IsInBossArea(play) == 1) { + return 1; + } + temp_v1 = play->roomCtx.currRoom.num; + if (temp_v1 == -1) { + return 0; + } + entry = &D_801BEBB8.unk0->entry[temp_v1]; + if (entry->unk0 == 0xFFFF) { + return 0; + } + if (func_80109AD8(entry->unk0) == 0x3A) { + return 0; + } + return 1; +} + +f32 func_80102F9C(f32 arg0) { + s32 i; + + if ((D_801BEBB8.unk48[D_801BEBB8.unk40-1] - 80.0f) < arg0) { + return D_801BEBB8.unk48[D_801BEBB8.unk40-1]; + } + for (i = D_801BEBB8.unk40 - 2; i >= 0; i--) { + if (((D_801BEBB8.unk48[i] - 80.0f) < arg0) && (arg0 < (D_801BEBB8.unk48[i + 1] + 80.0f))) { + return D_801BEBB8.unk48[i]; + } + } + if (arg0 < (D_801BEBB8.unk48[0] + 80.0f)) { + return D_801BEBB8.unk48[0]; + } + return 0.0f; +} void func_80103090(MinimapEntry* arg0, s32* out1, s32* out2){ func_80109754(arg0->unk0, out1, out2); @@ -413,9 +458,75 @@ void func_80104AE8(PlayState *play) { } } -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80104C80.s") +#ifdef NON_MATCHING +//https://decomp.me/scratch/kvGBZ +void func_80104C80(PlayState* play) { + s32 objBankIndex; -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80104CF4.s") + objBankIndex = Object_GetIndex(&play->objectCtx, GAMEPLAY_DANGEON_KEEP); + if (objBankIndex < 0) { + D_801BEBB8.unk20 |= 1; + return; + } + do { + + } while (!Object_IsLoaded(&play->objectCtx, objBankIndex)); +} +#else +void func_80104C80(PlayState* play); +#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80104C80.s") +#endif + +void func_80104CF4(PlayState* play) { + s32 i; + + D_801BEBB8.unk0 = NULL; + D_801BEBB8.unk4 = -1; + D_801BEBB8.unk8 = 0xD2; + D_801BEBB8.unkA = 0x8C; + D_801BEBB8.unkC = 0xD2; + D_801BEBB8.unkE = 0x8C; + D_801BEBB8.unk10 = NULL; + D_801BEBB8.unk14 = -1; + D_801BEBB8.unk18 = NULL; + D_801BEBB8.unk1C = 0; + D_801BEBB8.unk1E = 0; + D_801BEBB8.unk20 = 0; + D_801BEBB8.unk24 = 0; + + if (Map_IsInBossArea(play) == 0) { + D_801BEC1C = play->numRooms; + } + D_801BEBB8.unk28 = THA_AllocEndAlign16(&play->state.heap, 0x4000); + D_801BEBB8.unk2C = THA_AllocEndAlign16(&play->state.heap, 0x4000); + func_80104C80(play); + if (Map_IsInBossArea(play) == 0) { + D_801BEBB8.unk34 = 0x64; + D_801BEBB8.unk30 = 0; + D_801BEBB8.unk36 = 0x64; + D_801BEBB8.unk32 = 0; + D_801BEBB8.unk38 = (s16) (s32) ((f32) D_801BEBB8.unk30 + ((f32) D_801BEBB8.unk34 * 0.5f)); + D_801BEBB8.unk3A = (s16) (s32) ((f32) D_801BEBB8.unk32 + ((f32) D_801BEBB8.unk36 * 0.5f)); + } + D_801BEBB8.unk3C = THA_AllocEndAlign16(&play->state.heap, D_801BEC1C * sizeof(s16)); + + for (i = 0; i < D_801BEC1C; i++) { + func_80102E90(play, &D_801BEBB8.unk3C[i]); + } + D_801BEBB8.unk48 = THA_AllocEndAlign16(&play->state.heap, 32 * sizeof(s16)); + + for (i = 0; i < 32; i++) + { + D_801BEBB8.unk48[i] = -0x7FFF; + } + func_801068B4(play); + D_801BEBB8.unk58 = 0; + D_801BEBB8.unk5A = 0; + if (Map_IsInBossArea(play) != 0) { + func_8010549C(play, NULL); + func_8010565C(play, 0, NULL); + } +} void func_80104F34(PlayState* play) { s32 i1; @@ -583,7 +694,21 @@ void func_8010549C(PlayState* globalCtx, void* segmentAddress) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_8010549C.s") #endif -#pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_8010565C.s") +void func_8010565C(PlayState* play, s32 num, void* segmentAddress) { + MinimapChest* var_v1; + s32 var_a3; + + if (Map_IsInBossArea(play) == 0) { + var_v1 = Lib_SegmentedToVirtual(segmentAddress); + for (var_a3 = 0; var_a3 < num; var_v1++, var_a3++) { + D_801F5270[var_a3] = *var_v1; + } + D_801BEC20 = num; + } + D_801BEBB8.unk54 = D_801F5270; + D_801BEBB8.unk50 = D_801BEC20; +} + #pragma GLOBAL_ASM("asm/non_matchings/code/z_map_disp/func_80105818.s") @@ -681,7 +806,7 @@ void func_8010683C(void) { D_801BEBB8.unk20 &= ~1; } -void func_801068B4(s32 arg0) { +void func_801068B4(PlayState* play) { func_8010683C(); } diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 0c2490f40..0fcb25ef8 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -3994,8 +3994,7 @@ 0x801F4F70:("sLightsBuffer","LightsBuffer","",0x188), 0x801F5100:("sZeldaArena","Arena","",0x24), 0x801F5130:("D_801F5130","UNK_TYPE1","",0x1), - 0x801F5270:("D_801F5270","UNK_TYPE1","",0x1), - 0x801F528E:("D_801F528E","UNK_TYPE1","",0x1), + 0x801F5270:("D_801F5270","UNK_TYPE1","",0x140), 0x801F53B0:("D_801F53B0","UNK_TYPE1","",0x1), 0x801F56B0:("D_801F56B0","UNK_TYPE1","",0x1), 0x801F5730:("D_801F5730","UNK_TYPE1","",0x1),