More header cleanup (#1604)

* low hanging fruits on variables.h

* z_actor functions

* Move RomFile to z64object.h

* Revert "z_actor functions"

This reverts commit aa99967d16.

* yeet

* z64actor_dlftbls.h

* Move object segment declarations to object_table.c

* Move Camera functions

* z64nmi_buff.h

* fix merge

* su_mtx.h, sys_cmpdma.h and sys_initial_check.h

* sys_ucode.h

* sys_flashrom.h

* Remove unnecessary includes

* z64kanfont.h

* flg_set.h

* z64DLF.h

* z64lifemeter.h

* z64path.h

* format

* ObjectOverlay

* bss

* Yeet ObjectOverlay

* review

* review

* format

* bss

* z64font.h
This commit is contained in:
Anghelo Carvajal
2024-04-25 21:16:47 -04:00
committed by GitHub
parent 654fc4fd74
commit 666cb6ad4a
70 changed files with 434 additions and 310 deletions
+1
View File
@@ -18,6 +18,7 @@
#include "slowly.h"
#include "stack.h"
#include "stackcheck.h"
#include "sys_ucode.h"
/**
* Assigns the "save" values in PreRender
-1
View File
@@ -12,7 +12,6 @@
#include "tha.h"
#include "alignment.h"
#include "functions.h"
void* THA_GetHead(TwoHeadArena* tha) {
return tha->head;
-1
View File
@@ -11,7 +11,6 @@
#include "thga.h"
#include "alignment.h"
#include "functions.h"
void THGA_Init(TwoHeadGfxArena* thga, void* start, size_t size) {
THA_Init(&thga->tha, start, size);
+17 -14
View File
@@ -1,7 +1,8 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "libc/string.h"
static CutsceneCamera* sCurCsCamera;
CutsceneCamera* sCurCsCamera;
typedef s16 (*CsCamInterpolateCallback)(Vec3f*, f32*, s16*, CsCmdCamPoint*, CsCmdCamMisc*, CutsceneCameraInterp*);
@@ -789,16 +790,16 @@ s16 CutsceneCamera_Interp_MultiPointCubic(Vec3f* camPos, f32* camFov, s16* camRo
return 0;
}
static f32 sKnots[38];
f32 sCsCamKnots[38];
// Only used by unused CutsceneCamera_Interp_Unused
void func_80162FF8(s16 arg0) {
f32 val = 0.0f;
s32 i;
sKnots[0] = 0.0f;
sKnots[1] = 0.0f;
sKnots[2] = 0.0f;
sCsCamKnots[0] = 0.0f;
sCsCamKnots[1] = 0.0f;
sCsCamKnots[2] = 0.0f;
for (i = 3; i < arg0; i++) {
if (i == 3) {
@@ -809,13 +810,13 @@ void func_80162FF8(s16 arg0) {
val += 0.3f;
}
sKnots[i] = val;
sCsCamKnots[i] = val;
}
val += 0.9f;
sKnots[i++] = val;
sKnots[i++] = val;
sKnots[i++] = val;
sCsCamKnots[i++] = val;
sCsCamKnots[i++] = val;
sCsCamKnots[i++] = val;
}
#define FUNC_801631DC_ORDER 3
@@ -837,15 +838,17 @@ void func_801631DC(f32 progress, s32 arg2, f32* coeff) {
for (i = 1; i < FUNC_801631DC_ORDER; i++) {
for (j = arg2 - i, k = (FUNC_801631DC_ORDER - 1) - i; j <= arg2; j++, k++) {
if (sKnots[j + i] != sKnots[j]) {
coeffTemp[i][k] = ((progress - sKnots[j]) / (sKnots[j + i] - sKnots[j])) * coeffTemp[i - 1][k];
if (sCsCamKnots[j + i] != sCsCamKnots[j]) {
coeffTemp[i][k] =
((progress - sCsCamKnots[j]) / (sCsCamKnots[j + i] - sCsCamKnots[j])) * coeffTemp[i - 1][k];
} else {
coeffTemp[i][k] = 0.0f;
}
if (sKnots[j + i + 1] != sKnots[j + 1]) {
if (sCsCamKnots[j + i + 1] != sCsCamKnots[j + 1]) {
coeffTemp[i][k] +=
((sKnots[j + i + 1] - progress) / (sKnots[j + i + 1] - sKnots[j + 1])) * coeffTemp[i - 1][k + 1];
((sCsCamKnots[j + i + 1] - progress) / (sCsCamKnots[j + i + 1] - sCsCamKnots[j + 1])) *
coeffTemp[i - 1][k + 1];
}
}
}
@@ -869,7 +872,7 @@ s16 CutsceneCamera_Interp_Unused(Vec3f* camPos, f32* camFov, s16* camRoll, CsCmd
}
index = interpState->waypoint + 2;
func_801631DC(F32_LERPIMP(sKnots[index], sKnots[index + 1],
func_801631DC(F32_LERPIMP(sCsCamKnots[index], sCsCamKnots[index + 1],
(f32)interpState->curFrame / miscCmd[interpState->waypoint].unused0),
index, coeff);
+3
View File
@@ -10,8 +10,11 @@
* Hold Start and press B: clear all weekEventReg and eventInf flags
*/
#include "flg_set.h"
#include "global.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
typedef struct FlagSetEntry {
/* 0x0 */ u8* value;
/* 0x4 */ const char* name;
+3 -2
View File
@@ -1,6 +1,5 @@
#include "z64.h"
#include "regs.h"
#include "functions.h"
#include "fault.h"
// Variables are put before most headers as a hacky way to bypass bss reordering
@@ -10,13 +9,15 @@ GfxMasterList* gGfxMasterDL;
CfbInfo sGraphCfbInfos[3];
OSTime sGraphPrevUpdateEndTime;
#include "variables.h"
#include "macros.h"
#include "buffers.h"
#include "idle.h"
#include "sys_cfb.h"
#include "sys_ucode.h"
#include "libc64/malloc.h"
#include "z64DLF.h"
#include "z64speed_meter.h"
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
#include "overlays/gamestates/ovl_file_choose/z_file_select.h"
#include "overlays/gamestates/ovl_opening/z_opening.h"
+2
View File
@@ -32,7 +32,9 @@ PadMgr gPadMgr;
#include "main.h"
#include "buffers.h"
#include "global.h"
#include "sys_initial_check.h"
#include "system_heap.h"
#include "z64nmi_buff.h"
#include "z64thread.h"
s32 gScreenWidth = SCREEN_WIDTH;
+15 -4
View File
@@ -10,10 +10,21 @@ s16 gPlayerFormObjectIds[PLAYER_FORM_MAX] = {
ObjectId gObjectTableSize = OBJECT_ID_MAX;
// Segment declarations (also used in the table below)
#define DEFINE_OBJECT(name, _enumValue) DECLARE_ROM_SEGMENT(name)
#define DEFINE_OBJECT_UNSET(_enumValue)
#define DEFINE_OBJECT_EMPTY(_name, _enumValue)
#include "tables/object_table.h"
#undef DEFINE_OBJECT
#undef DEFINE_OBJECT_UNSET
#undef DEFINE_OBJECT_EMPTY
// Object Table definition
#define DEFINE_OBJECT(name, _enumValue) { SEGMENT_ROM_START(name), SEGMENT_ROM_END(name) },
#define DEFINE_OBJECT_UNSET(_enumValue) { 0, 0 },
#define DEFINE_OBJECT_SIZE_ZERO(name, _enumValue) { SEGMENT_ROM_START(name), SEGMENT_ROM_START(name) },
#define DEFINE_OBJECT(name, _enumValue) ROM_FILE(name),
#define DEFINE_OBJECT_UNSET(_enumValue) ROM_FILE_UNSET,
#define DEFINE_OBJECT_EMPTY(name, _enumValue) ROM_FILE_EMPTY(name),
RomFile gObjectTable[] = {
#include "tables/object_table.h"
@@ -21,4 +32,4 @@ RomFile gObjectTable[] = {
#undef DEFINE_OBJECT
#undef DEFINE_OBJECT_UNSET
#undef DEFINE_OBJECT_SIZE_ZERO
#undef DEFINE_OBJECT_EMPTY
+2 -1
View File
@@ -49,7 +49,8 @@
* @remark Name inferred from shared Animal Forest functions, meaning of "su" is unclear.
*/
#include "global.h"
#include "su_mtx.h"
#include "z64math.h"
/**
* Constructs a matrix \$f ST \$f, i.e. a scaling \$f S \$f followed by a translation \$f T \$f.
-2
View File
@@ -1,7 +1,6 @@
#include "z64.h"
#include "buffers.h"
#include "regs.h"
#include "functions.h"
#include "macros.h"
// Variables are put before most headers as a hacky way to bypass bss reordering
@@ -34,7 +33,6 @@ s16 gCfbUpperAdjust;
u8 gSysCfbHiResEnabled;
#include "variables.h"
#include "sys_cfb.h"
#include "libc/stdbool.h"
#include "buffers.h"
+3 -3
View File
@@ -1,7 +1,7 @@
#include "global.h"
#include "libc64/malloc.h"
#include "yaz0.h"
#include "sys_cmpdma.h"
#include "libc64/malloc.h"
#include "color.h"
#include "yaz0.h"
#include "z64dma.h"
+7 -1
View File
@@ -6,8 +6,14 @@
* These checks are some of the first functions run in Main, before even setting up the system heap, and any image files
* are DMA'd directly to fixed RAM addresses.
*/
#include "sys_initial_check.h"
#include "global.h"
#include "color.h"
#include "fault.h"
#include "segment_symbols.h"
#include "misc/locerrmsg/locerrmsg.h"
#include "misc/memerrmsg/memerrmsg.h"
@@ -28,7 +34,7 @@
void Check_WriteRGBA16Pixel(u16* buffer, u32 x, u32 y, u32 value) {
if (value & RGBA16_PIXEL_OPAQUE) {
(&buffer[x])[y * SCREEN_WIDTH] = value;
buffer[x + y * SCREEN_WIDTH] = value;
}
}
+2 -1
View File
@@ -2,7 +2,8 @@
* File: sys_ucode.c
* Description: Functions for obtaining locations and sizes of microcode
*/
#include "global.h"
#include "sys_ucode.h"
u64* initialgspUcodeText = gspF3DZEX2_NoN_PosLight_fifoTextStart;
u64* initialgspUcodeData = gspF3DZEX2_NoN_PosLight_fifoDataStart;
+2
View File
@@ -1,4 +1,6 @@
#include "z_title_setup.h"
#include "sys_flashrom.h"
#include "overlays/gamestates/ovl_title/z_title.h"
void Setup_InitRegs(void) {
+2
View File
@@ -1,4 +1,6 @@
#include "z64DLF.h"
#include "global.h"
#include "libc64/malloc.h"
#include "loadfragment.h"
+1
View File
@@ -2,6 +2,7 @@
* File: z_actor.c
* Description:
*/
#include "fault.h"
#include "sys_cfb.h"
#include "loadfragment.h"
+7 -4
View File
@@ -1,9 +1,12 @@
#include "global.h"
#include "z64actor_dlftbls.h"
#include "fault.h"
// Init Vars declarations (also used in the table below)
#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName) extern ActorInit name##_InitVars;
#define DEFINE_ACTOR_INTERNAL(name, _enumValue, _allocType, _debugName) extern ActorInit name##_InitVars;
// Segment and InitVars declarations (also used in the table below)
#define DEFINE_ACTOR(name, _enumValue, _allocType, _debugName) \
extern struct ActorInit name##_InitVars; \
DECLARE_OVERLAY_SEGMENT(name)
#define DEFINE_ACTOR_INTERNAL(name, _enumValue, _allocType, _debugName) extern struct ActorInit name##_InitVars;
#define DEFINE_ACTOR_UNSET(_enumValue)
#include "tables/actor_table.h"
+2
View File
@@ -1,3 +1,5 @@
#include "prevent_bss_reordering.h"
#include "z64bgcheck.h"
#include "global.h"
+1
View File
@@ -43,6 +43,7 @@
*
*/
#include "prevent_bss_reordering.h"
#include "global.h"
#include "libc/string.h"
#include "z64malloc.h"
+1 -1
View File
@@ -1,7 +1,7 @@
#include "z64eff_footmark.h"
#include "z64.h"
#include "macros.h"
#include "functions.h"
#include "assets/code/eff_footmark/eff_footmark.c"
+1
View File
@@ -1,4 +1,5 @@
#include "z64game_over.h"
#include "z64rumble.h"
#include "z64shrink_window.h"
#include "z64.h"
+5 -3
View File
@@ -1,7 +1,9 @@
#include "z64jpeg.h"
#include "libc/stdbool.h"
#include "variables.h"
#include "functions.h"
#include "main.h"
#include "sys_ucode.h"
#include "macros.h"
#define MARKER_ESCAPE 0x00
#define MARKER_SOI 0xD8
@@ -107,7 +109,7 @@ void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y) {
* unaligned values in JPEG header files.
*/
u16 Jpeg_GetUnalignedU16(u8* ptr) {
if (((u32)ptr & 1) == 0) {
if (((uintptr_t)ptr & 1) == 0) {
// Read the value normally if it's aligned to a 16-bit address.
return *(u16*)ptr;
} else {
+1
View File
@@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "z64pause_menu.h"
#include "z64.h"
+6 -1
View File
@@ -1,4 +1,9 @@
#include "global.h"
#include "z64font.h"
#include "segment_symbols.h"
#include "z64message.h"
#include "z64.h"
// stubbed in NTSC-U
void Font_LoadChar(PlayState* play, u16 codePointIndex, s32 offset) {
+6
View File
@@ -1,5 +1,11 @@
#include "prevent_bss_reordering.h"
#include "z64lifemeter.h"
#include "global.h"
#include "su_mtx.h"
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
#include "interface/parameter_static/parameter_static.h"
s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } };
+1
View File
@@ -3,6 +3,7 @@
#include "message_data_static.h"
#include "padmgr.h"
#include "sys_cmpdma.h"
#include "segment_symbols.h"
#include "z64actor.h"
#include "z64horse.h"
+3 -3
View File
@@ -4,8 +4,8 @@
#define NMI 1
typedef struct {
/* 0x00 */ u32 resetting;
/* 0x04 */ u32 resetCount;
/* 0x00 */ s32 resetting;
/* 0x04 */ s32 resetCount;
/* 0x08 */ OSTime duration;
/* 0x10 */ OSTime resetTime;
} NmiBuff; // size >= 0x18
@@ -32,6 +32,6 @@ void Nmi_SetPrenmiStart(void) {
gNMIBuffer->resetTime = osGetTime();
}
u32 Nmi_GetPrenmiHasStarted(void) {
s32 Nmi_GetPrenmiHasStarted(void) {
return gNMIBuffer->resetting;
}
+2
View File
@@ -1,6 +1,8 @@
#include "global.h"
#include "PR/gs2dex.h"
#include "sys_cfb.h"
#include "sys_ucode.h"
#include "z64lifemeter.h"
#include "z64malloc.h"
#include "z64snap.h"
#include "z64view.h"
+3
View File
@@ -1,5 +1,8 @@
#include "z64path.h"
#include "global.h"
#include "z64lib.h"
Path* Path_GetByIndex(PlayState* play, s16 index, s16 indexNone) {
Path* path;
-2
View File
@@ -1,6 +1,5 @@
#include "z64.h"
#include "regs.h"
#include "functions.h"
#include "z64malloc.h"
#include "z64vis.h"
#include "z64visfbuf.h"
@@ -18,7 +17,6 @@ BombersNotebook sBombersNotebook;
u8 sBombersNotebookOpen;
u8 sMotionBlurStatus;
#include "variables.h"
#include "macros.h"
#include "buffers.h"
#include "idle.h"
+1
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "sys_cfb.h"
#include "sys_cmpdma.h"
#include "z64bombers_notebook.h"
#include "z64malloc.h"
+1
View File
@@ -1,6 +1,7 @@
#include "global.h"
#include "PR/gs2dex.h"
#include "debug.h"
#include "sys_ucode.h"
void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3) {
}
+16 -16
View File
@@ -233,9 +233,9 @@ void Scene_CommandEntranceList(PlayState* play, SceneCmd* cmd) {
void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) {
// @note These quest hint files are identical to OoT's.
// They are not relevant in this game and the system to process these scripts has been removed.
static RomFile naviQuestHintFiles[2] = {
{ SEGMENT_ROM_START(elf_message_field), SEGMENT_ROM_END(elf_message_field) },
{ SEGMENT_ROM_START(elf_message_ydan), SEGMENT_ROM_END(elf_message_ydan) },
static RomFile sNaviQuestHintFiles[2] = {
ROM_FILE(elf_message_field),
ROM_FILE(elf_message_ydan),
};
if (cmd->specialFiles.subKeepId != 0) {
@@ -245,7 +245,7 @@ void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) {
}
if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) {
play->naviQuestHints = Play_LoadFile(play, &naviQuestHintFiles[cmd->specialFiles.naviQuestHintFileId - 1]);
play->naviQuestHints = Play_LoadFile(play, &sNaviQuestHintFiles[cmd->specialFiles.naviQuestHintFileId - 1]);
}
}
@@ -356,19 +356,19 @@ void Scene_CommandEnvLightSettings(PlayState* play, SceneCmd* cmd) {
* These later are stored in segment 0x06, and used in maps.
*/
void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) {
static RomFile sceneTextureFiles[9] = {
{ 0, 0 }, // Default
{ SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) },
{ SEGMENT_ROM_START(scene_texture_02), SEGMENT_ROM_END(scene_texture_02) },
{ SEGMENT_ROM_START(scene_texture_03), SEGMENT_ROM_END(scene_texture_03) },
{ SEGMENT_ROM_START(scene_texture_04), SEGMENT_ROM_END(scene_texture_04) },
{ SEGMENT_ROM_START(scene_texture_05), SEGMENT_ROM_END(scene_texture_05) },
{ SEGMENT_ROM_START(scene_texture_06), SEGMENT_ROM_END(scene_texture_06) },
{ SEGMENT_ROM_START(scene_texture_07), SEGMENT_ROM_END(scene_texture_07) },
{ SEGMENT_ROM_START(scene_texture_08), SEGMENT_ROM_END(scene_texture_08) },
static RomFile sSceneTextureFiles[9] = {
ROM_FILE_UNSET, // Default
ROM_FILE(scene_texture_01),
ROM_FILE(scene_texture_02),
ROM_FILE(scene_texture_03),
ROM_FILE(scene_texture_04),
ROM_FILE(scene_texture_05),
ROM_FILE(scene_texture_06),
ROM_FILE(scene_texture_07),
ROM_FILE(scene_texture_08),
};
uintptr_t vromStart = sceneTextureFiles[fileIndex].vromStart;
size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
uintptr_t vromStart = sSceneTextureFiles[fileIndex].vromStart;
size_t size = sSceneTextureFiles[fileIndex].vromEnd - vromStart;
if (size != 0) {
play->roomCtx.unk74 = THA_AllocTailAlign16(&play->state.tha, size);
+3
View File
@@ -1,4 +1,7 @@
#include "z64save.h"
#include "global.h"
#include "sys_flashrom.h"
#include "z64horse.h"
#include "overlays/gamestates/ovl_file_choose/z_file_select.h"
+1
View File
@@ -13,6 +13,7 @@
#include "global.h"
#include "z64visfbuf.h"
#include "sys_cfb.h"
#include "sys_ucode.h"
#define SCALE_MIN 0.032f
#define SCALE_MAX 1.0f //!< also unchanged scale