diff --git a/docs/tools.md b/docs/tools.md index 0aba4fa475..5005f7f933 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -127,7 +127,7 @@ Gives the progress output that the website uses. Run for that warm glow. ### `tools/regconvert.py` -Convert `mips2c`'s `gGameInfo->data[n]` output (or a raw offset) into the appropriate variable in the REG pages. Can also be run on a file to mass-convert them: run with `-h` for details. +Convert `mips2c`'s `gRegEditor->data[n]` output (or a raw offset) into the appropriate variable in the REG pages. Can also be run on a file to mass-convert them: run with `-h` for details. ### `tools/rename_global_asm.py` diff --git a/include/functions.h b/include/functions.h index 2781886804..8f8aa7edac 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1226,7 +1226,6 @@ s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRo s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusHeight); s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos); void SaveContext_Init(void); -void GameInfo_Init(void); void Cutscene_Init(PlayState* play, CutsceneContext* csCtx); void Cutscene_Start(PlayState* play, CutsceneContext* csCtx); diff --git a/include/regs.h b/include/regs.h index 9057078c33..5dee53e977 100644 --- a/include/regs.h +++ b/include/regs.h @@ -4,13 +4,28 @@ #ifndef REGS_H #define REGS_H +#include "ultra64.h" + #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 #define REG_PER_PAGE 16 #define REG_PER_GROUP REG_PAGES * REG_PER_PAGE -/* We probably want a better name for gGameInfo based on OoT discussions */ -#define BASE_REG(n, r) gGameInfo->data[n * REG_PER_GROUP + r] +typedef struct RegEditor { + /* 0x00 */ u8 regPage; // 0: no page selected (reg editor is not active); 1: first page; `REG_PAGES`: last page + /* 0x01 */ u8 regGroup; // Indexed from 0 to `REG_GROUPS`-1. Each group has its own character to identify it. + /* 0x02 */ u8 regCur; // Selected reg, indexed from 0 as the page start + /* 0x03 */ u8 dPadInputPrev; + /* 0x04 */ u32 inputRepeatTimer; + /* 0x08 */ UNK_TYPE1 pad_08[0xC]; + /* 0x14 */ s16 data[REG_GROUPS * REG_PER_GROUP]; // Accessed through *REG macros +} RegEditor; // size = 0x15D4 + +void Regs_Init(void); + +extern RegEditor* gRegEditor; + +#define BASE_REG(n, r) (gRegEditor->data[n * REG_PER_GROUP + r]) #define REG(r) BASE_REG(0, r) #define SREG(r) BASE_REG(1, r) @@ -42,7 +57,8 @@ #define kREG(r) BASE_REG(27, r) #define bREG(r) BASE_REG(28, r) -/* TODO: Actually confirm these, in case of miss-match it's at least a simple list to `sed` */ +/* TODO: There are still a few OoT defines here that need confirmation */ + #define R_TIME_SPEED REG(15) #define R_RUN_SPEED_LIMIT REG(45) diff --git a/include/variables.h b/include/variables.h index 59779203d5..5e935b5608 100644 --- a/include/variables.h +++ b/include/variables.h @@ -2353,7 +2353,7 @@ extern SaveContext gSaveContext; // extern UNK_TYPE1 D_801F3F42; // extern UNK_TYPE1 D_801F3F4A; // extern UNK_TYPE1 D_801F3F5A; -extern GameInfo* gGameInfo; + // extern UNK_TYPE1 D_801F3F80; // extern UNK_TYPE1 D_801F3F83; // extern UNK_TYPE1 D_801F48C8; diff --git a/include/z64.h b/include/z64.h index 732fbce3c5..dd12de2117 100644 --- a/include/z64.h +++ b/include/z64.h @@ -115,44 +115,6 @@ typedef struct { /* 0x8 */ void* end; } PolygonType2; // size = 0xC -typedef struct { - /* 0x0 */ s16 x; - /* 0x2 */ s16 y; - /* 0x4 */ s16 z; - /* 0x6 */ s16 reserved; - /* 0x8 */ s16 s; - /* 0xA */ s16 t; - /* 0xC */ s8 r; - /* 0xD */ s8 g; - /* 0xE */ s8 b; - /* 0xF */ s8 a; -} F3DVertexColor; // size = 0x10 - -typedef struct { - /* 0x0 */ s16 x; - /* 0x2 */ s16 y; - /* 0x4 */ s16 z; - /* 0x6 */ s16 reserved; - /* 0x8 */ s16 s; - /* 0xA */ s16 t; - /* 0xC */ s8 normalX; - /* 0xD */ s8 normalY; - /* 0xE */ s8 normalZ; - /* 0xF */ s8 a; -} F3DVertexNormal; // size = 0x10 - -// Game Info aka. Static Context -// Data normally accessed through REG macros (see regs.h) -typedef struct { - /* 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 { /* 0x0 */ u32 size; /* 0x4 */ void* bufp; @@ -285,11 +247,6 @@ typedef struct { /* 0x14 */ OSMesgQueue unk14; } s80185D40; // size = 0x2C -typedef union { - F3DVertexColor color; - F3DVertexNormal normal; -} F3DVertex; // size = 0x10 - // End of RDRAM without the Expansion Pak installed #define NORMAL_RDRAM_END 0x80400000 // End of RDRAM with the Expansion Pak installed diff --git a/src/code/main.c b/src/code/main.c index b036123bea..c4a80f1eae 100644 --- a/src/code/main.c +++ b/src/code/main.c @@ -46,7 +46,7 @@ void Main(void* arg) { startHeapSize = fb - sysHeap; SystemArena_Init(sysHeap, startHeapSize); - GameInfo_Init(); + Regs_Init(); R_ENABLE_ARENA_DBG = 0; diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 46649a4ce1..058d896a45 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -1,20 +1,21 @@ -#include "global.h" +#include "regs.h" #include "system_malloc.h" +#include "macros.h" -GameInfo* gGameInfo; +RegEditor* gRegEditor; -void GameInfo_Init(void) { +void Regs_Init(void) { s32 i; - gGameInfo = SystemArena_Malloc(sizeof(GameInfo)); + gRegEditor = SystemArena_Malloc(sizeof(RegEditor)); if (1) {} - gGameInfo->unk_00 = 0; - gGameInfo->unk_01 = 0; - gGameInfo->unk_02 = 0; - gGameInfo->unk_04 = 0; - gGameInfo->unk_03 = 0; + gRegEditor->regPage = 0; + gRegEditor->regGroup = 0; + gRegEditor->regCur = 0; + gRegEditor->inputRepeatTimer = 0; + gRegEditor->dPadInputPrev = 0; - for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++) { - gGameInfo->data[i] = 0; + for (i = 0; i < ARRAY_COUNT(gRegEditor->data); i++) { + gRegEditor->data[i] = 0; } } diff --git a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c index 0a3f703fbd..2307fe2c42 100644 --- a/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c +++ b/src/overlays/actors/ovl_Obj_Nozoki/z_obj_nozoki.c @@ -4,6 +4,7 @@ * Description: Sakon's Hideout Objects (Sun's Mask, doors, etc) */ +#include "prevent_bss_reordering.h" #include "z_obj_nozoki.h" #include "objects/object_secom_obj/object_secom_obj.h" diff --git a/tools/disasm/functions.txt b/tools/disasm/functions.txt index 39a4c7c2b8..73d0178fa3 100644 --- a/tools/disasm/functions.txt +++ b/tools/disasm/functions.txt @@ -1519,7 +1519,7 @@ 0x800E9138:("Actor_TrackPlayerSetFocusHeight",), 0x800E9250:("Actor_TrackPlayer",), 0x800E9360:("SaveContext_Init",), - 0x800E93E0:("GameInfo_Init",), + 0x800E93E0:("Regs_Init",), 0x800E9470:("DebugDisplay_Init",), 0x800E9488:("DebugDisplay_AddObject",), 0x800E9564:("DebugDisplay_DrawObjects",), diff --git a/tools/disasm/variables.txt b/tools/disasm/variables.txt index 1c59f0fe13..d664a353f3 100644 --- a/tools/disasm/variables.txt +++ b/tools/disasm/variables.txt @@ -398,7 +398,7 @@ 0x801AE2BC:("D_801AE2BC","UNK_TYPE4","",0x4), 0x801AE2CC:("D_801AE2CC","UNK_TYPE4","",0x4), 0x801AE2DC:("D_801AE2DC","UNK_TYPE4","",0x4), - 0x801AE2F0:("sEffectShieldParticleVertices","F3DVertex","[4]",0x40), + 0x801AE2F0:("sEffShieldParticleVtx","Vtx","[4]",0x40), 0x801AE330:("sEffectInfoTable","EffectInfo","[5]",0x64), 0x801AE3A0:("sEffectSsInfo","EffectSsInfo","",0xc), 0x801AE3B0:("D_801AE3B0","Color_RGBA8","",0x4), @@ -3924,7 +3924,7 @@ 0x801EF670:("gSaveContext","SaveContext","",0x48e8), 0x801F3F58:("D_801F3F58","UNK_TYPE1","",0x1), 0x801F3F5A:("D_801F3F5A","UNK_TYPE1","",0x1), - 0x801F3F60:("gGameInfo","GameInfo*","",0x4), + 0x801F3F60:("gRegEditor","RegEditor*","",0x4), 0x801F3F70:("sDebugObjectListHead","UNK_TYPE1","",0x1), 0x801F3F80:("D_801F3F80","UNK_TYPE1","",0xDC0), 0x801F4D40:("seqId","u16","",0x2), @@ -7908,7 +7908,7 @@ 0x80920290:("jtbl_80920290","UNK_PTR","",0x4), 0x80920DF0:("gFireArrowTex","u8","[2048]",0x800), 0x809215F0:("gFireArrowMaskTex","u8","[2048]",0x800), - 0x80921DF0:("gFireArrowVtx","F3DVertex","[43]",0x2b0), + 0x80921DF0:("gFireArrowVtx","Vtx","[43]",0x2b0), 0x809220A0:("gIceArrowMaterialDL","Gfx","[22]",0xb0), 0x80922150:("gIceArrowModelDL","Gfx","[24]",0xc0), 0x80922210:("Arrow_Fire_InitVars","ActorInit","",0x20), diff --git a/tools/regconvert.py b/tools/regconvert.py index f4b9b0db13..892e3f885e 100755 --- a/tools/regconvert.py +++ b/tools/regconvert.py @@ -28,7 +28,7 @@ def read_file(filename): file_contents = src_file.read() src_file.close() - pattern = re.compile("gGameInfo->data\[((0[xX])?[0-9a-fA-F]+)\]") + pattern = re.compile("gRegEditor->data\[((0[xX])?[0-9a-fA-F]+)\]") match = pattern.search(file_contents) while match: @@ -56,19 +56,19 @@ def check_valid_offset(offset): return 0x14 <= offset <= 0x15D2 def main(): - parser = argparse.ArgumentParser(description="Converts a gGameInfo->data index to a REG macro.") + parser = argparse.ArgumentParser(description="Converts a gRegEditor->data index to a REG macro.") # TODO: Add a description and a better title # index_group = parser.add_argument_group(title="index", description="") index_group = parser.add_argument_group() - index_group.add_argument("index", help="index of gGameInfo->data in decimal (or hexadecimal if starts with 0x)") - index_group.add_argument("--offset", help="treat index argument as an offset to gGameInfo instead", action="store_true") + index_group.add_argument("index", help="index of gRegEditor->data in decimal (or hexadecimal if starts with 0x)") + index_group.add_argument("--offset", help="treat index argument as an offset to gRegEditor instead", action="store_true") index_group.add_argument("--hex", help="treat index argument as hexadecimal, even without the 0x", action="store_true") # TODO: Add a description and a better title # file_group = parser.add_argument_group(title="file", description="") file_group = parser.add_argument_group() - file_group.add_argument("--file", help="use the parameter as a filepath, then replace every occurrence of `gGameInfo->data[number]` in that file a REG macro", action="store_true") + file_group.add_argument("--file", help="use the parameter as a filepath, then replace every occurrence of `gRegEditor->data[number]` in that file a REG macro", action="store_true") file_group.add_argument("--stdout", help="print the processed file to stdout instead of overwriting the original", action="store_true") args = parser.parse_args() diff --git a/tools/sizes/code_functions.csv b/tools/sizes/code_functions.csv index 0f80073e72..7c36208b85 100644 --- a/tools/sizes/code_functions.csv +++ b/tools/sizes/code_functions.csv @@ -1033,7 +1033,7 @@ asm/non_matchings/code/code_800E8EA0/Actor_TrackPoint.s,Actor_TrackPoint,0x800E8 asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayerSetFocusHeight.s,Actor_TrackPlayerSetFocusHeight,0x800E9138,0x46 asm/non_matchings/code/code_800E8EA0/Actor_TrackPlayer.s,Actor_TrackPlayer,0x800E9250,0x44 asm/non_matchings/code/z_common_data/func_800E9360.s,func_800E9360,0x800E9360,0x20 -asm/non_matchings/code/z_debug/GameInfo_Init.s,GameInfo_Init,0x800E93E0,0x24 +asm/non_matchings/code/z_debug/Regs_Init.s,Regs_Init,0x800E93E0,0x24 asm/non_matchings/code/z_debug_display/DebugDisplay_Init.s,DebugDisplay_Init,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