From 151e098e48fcd779a296cfbdcedd8f4528f96232 Mon Sep 17 00:00:00 2001 From: EllipticEllipsis <73679967+EllipticEllipsis@users.noreply.github.com> Date: Thu, 14 Oct 2021 16:25:14 +0100 Subject: [PATCH] `z_debug` OK (#330) * z_debug OK * Rename function * Remove duplicate struct * Update z64.h --- include/functions.h | 2 +- include/z64.h | 17 ++++++++++------- spec | 1 - src/code/main.c | 2 +- src/code/z_debug.c | 18 +++++++++++++++++- tools/disasm/functions.txt | 2 +- tools/sizes/code_functions.csv | 2 +- 7 files changed, 31 insertions(+), 13 deletions(-) diff --git a/include/functions.h b/include/functions.h index 8c8b76a3e6..173b44d26d 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1547,7 +1547,7 @@ s32 func_800E8FA4(Actor* actor, Vec3f* param_2, Vec3s* param_3, Vec3s* param_4); s32 func_800E9138(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, f32 param_5); s32 func_800E9250(GlobalContext* globalCtx, Actor* actor, Vec3s* param_3, Vec3s* param_4, Vec3f param_5); u8 func_800E9360(void); -void static_context_init(void); +void GameInfo_Init(void); // void func_800E9470(void); void DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, f32 scaleX, f32 scaleY, f32 scaleZ, u8 red, u8 green, u8 blue, u8 alpha, s16 type, GraphicsContext* gfxCtx); void DebugDisplay_DrawObjects(GlobalContext* globalCtx); diff --git a/include/z64.h b/include/z64.h index 6e179ebe22..e38d926a62 100644 --- a/include/z64.h +++ b/include/z64.h @@ -36,6 +36,7 @@ #include "z64scene.h" #include "z64save.h" #include "z64transition.h" +#include "regs.h" #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -242,14 +243,16 @@ typedef struct { /* 0x11D88 */ u8 unk_11D88; } Font; // size = 0x11D8C +// Game Info aka. Static Context +// Data normally accessed through REG macros (see regs.h) typedef struct { - /* 0x0000 */ u8 unk0; - /* 0x0001 */ u8 unk1; - /* 0x0002 */ u8 unk2; - /* 0x0003 */ u8 unk3; - /* 0x0004 */ u32 unk4; - /* 0x0008 */ UNK_TYPE1 pad8[0xC]; - /* 0x0014 */ s16 data[2784]; // Accessed through REG macros + /* 0x00 */ u8 unk_00; // regPage;? // 1 is first page + /* 0x01 */ u8 unk_01; // regGroup;? // "register" group (R, RS, RO, RP etc.) + /* 0x02 */ u8 unk_02; // regCur;? // selected register within page + /* 0x03 */ u8 unk_03; // dpadLast;? + /* 0x04 */ u32 unk_04; // repeat;? + /* 0x08 */ UNK_TYPE1 pad_08[0xC]; + /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // 0xAE0 entries } GameInfo; // size = 0x15D4 typedef struct { diff --git a/spec b/spec index 8ca54bfc5f..b121ad83c0 100644 --- a/spec +++ b/spec @@ -471,7 +471,6 @@ beginseg include "build/src/code/z_common_data.o" include "build/data/code/z_common_data.bss.o" include "build/src/code/z_debug.o" - include "build/data/code/z_debug.bss.o" include "build/src/code/z_debug_display.o" include "build/data/code/z_debug_display.data.o" include "build/data/code/z_debug_display.bss.o" diff --git a/src/code/main.c b/src/code/main.c index 648536aef1..a2b8599910 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -24,7 +24,7 @@ void Main(void* arg) { startHeapSize = fb - sysHeap; SystemArena_Init(sysHeap, startHeapSize); - static_context_init(); + GameInfo_Init(); R_ENABLE_ARENA_DBG = 0; diff --git a/src/code/z_debug.c b/src/code/z_debug.c index e6f03bb5fa..5848dfa71e 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -1,3 +1,19 @@ #include "global.h" -#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/static_context_init.s") +GameInfo* gGameInfo; + +void GameInfo_Init(void) { + s32 i; + + gGameInfo = (GameInfo*)SystemArena_Malloc(sizeof(GameInfo)); + if (1) {} + gGameInfo->unk_00 = 0; + gGameInfo->unk_01 = 0; + gGameInfo->unk_02 = 0; + gGameInfo->unk_04 = 0; + gGameInfo->unk_03 = 0; + + for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) { + gGameInfo->data[i] = 0; + } +} diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index e6e2507d67..8cf4a77b59 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1519,7 +1519,7 @@ 0x800E9138:("func_800E9138",), 0x800E9250:("func_800E9250",), 0x800E9360:("func_800E9360",), - 0x800E93E0:("static_context_init",), + 0x800E93E0:("GameInfo_Init",), 0x800E9470:("func_800E9470",), 0x800E9488:("DebugDisplay_AddObject",), 0x800E9564:("DebugDisplay_DrawObjects",), diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 0fdfe7519a..d8ca545066 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1033,7 +1033,7 @@ asm/non_matchings/code/code_800E8EA0/func_800E8FA4.s,func_800E8FA4,0x800E8FA4,0x asm/non_matchings/code/code_800E8EA0/func_800E9138.s,func_800E9138,0x800E9138,0x46 asm/non_matchings/code/code_800E8EA0/func_800E9250.s,func_800E9250,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 -asm/non_matchings/code/z_debug/static_context_init.s,static_context_init,0x800E93E0,0x24 +asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 asm/non_matchings/code/z_debug_display/func_800E9470.s,func_800E9470,0x800E9470,0x6 asm/non_matchings/code/z_debug_display/DebugDisplay_AddObject.s,DebugDisplay_AddObject,0x800E9488,0x37 asm/non_matchings/code/z_debug_display/DebugDisplay_DrawObjects.s,DebugDisplay_DrawObjects,0x800E9564,0x24