diff --git a/include/functions.h b/include/functions.h index 07b0e5b83d..e4a9e70c9a 100644 --- a/include/functions.h +++ b/include/functions.h @@ -174,9 +174,6 @@ void func_800BDAA0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overr void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animInfo, s32 animIndex); void Actor_Noop(Actor* actor, PlayState* play); -void Gfx_DrawDListOpa(PlayState* play, Gfx* dList); -void Gfx_DrawDListXlu(PlayState* play, Gfx* dList); - Actor* Actor_FindNearby(PlayState* play, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance); s32 func_800BE184(PlayState* play, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5); u8 Actor_ApplyDamage(Actor* actor); @@ -224,27 +221,6 @@ s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* tors void GetItem_Draw(PlayState* play, s16 drawId); -u16 QuestHint_GetTatlTextId(PlayState* play); - -f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); -f32 OLib_Vec3fDistOutDiff(Vec3f* a, Vec3f* b, Vec3f* dest); -f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); -f32 OLib_ClampMinDist(f32 val, f32 min); -f32 OLib_ClampMaxDist(f32 val, f32 max); -Vec3f OLib_Vec3fDistNormalize(Vec3f* a, Vec3f* b); -Vec3f OLib_VecSphToVec3f(VecSph* sph); -Vec3f OLib_VecGeoToVec3f(VecGeo* geo); -VecSph OLib_Vec3fToVecSph(Vec3f* vec); -VecGeo OLib_Vec3fToVecGeo(Vec3f* vec); -VecSph OLib_Vec3fDiffToVecSph(Vec3f* a, Vec3f* b); -VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b); -Vec3f OLib_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo); -Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b); -Vec3f OLib_Vec3fDiffDegF(Vec3f* a, Vec3f* b); -Vec3s OLib_Vec3fDiffBinAng(Vec3f* a, Vec3f* b); -void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); -void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); - void Room_Noop(PlayState* play, Room* room, Input* input, s32 arg3); void Room_Init(PlayState* play, RoomContext* roomCtx); size_t Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx); @@ -253,32 +229,6 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx); void Room_Draw(PlayState* play, Room* room, u32 flags); void func_8012EBF8(PlayState* play, RoomContext* roomCtx); -s32 Inventory_GetBtnBItem(PlayState* play); -void Inventory_ChangeEquipment(s16 value); -u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment); -void Inventory_ChangeUpgrade(s16 upgrade, u32 value); -s32 Inventory_IsMapVisible(s16 sceneId); -void Inventory_SetWorldMapCloudVisibility(s16 tingleIndex); -void Inventory_SaveDekuPlaygroundHighScore(s16 timerId); -void Inventory_IncrementSkullTokenCount(s16 sceneIndex); -s16 Inventory_GetSkullTokenCount(s16 sceneIndex); -void Inventory_SaveLotteryCodeGuess(PlayState* play); - -void Graph_FaultClient(void); -void Graph_InitTHGA(TwoHeadGfxArena* arena, Gfx* buffer, s32 size); -void Graph_SetNextGfxPool(GraphicsContext* gfxCtx); -GameStateOverlay* Graph_GetNextGameState(GameState* gameState); -uintptr_t Graph_FaultAddrConv(uintptr_t address, void* param); -void Graph_Init(GraphicsContext* gfxCtx); -void Graph_Destroy(GraphicsContext* gfxCtx); -void Graph_TaskSet00(GraphicsContext* gfxCtx, GameState* gameState); -void Graph_UpdateGame(GameState* gameState); -void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState); -void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState); -void Graph_ThreadEntry(void* arg); -Gfx* Gfx_Open(Gfx* gfx); -Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); -void* Gfx_Alloc(Gfx** gfxP, size_t size); void func_80183070(void); @@ -311,6 +261,4 @@ void Audio_ResetForAudioHeapStep2(void); void Audio_ResetForAudioHeapStep1(s32 specId); void Audio_PreNMI(void); -void Regs_InitData(PlayState* play); - #endif diff --git a/include/gfx.h b/include/gfx.h index a26c759adf..8b0a375cce 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -8,6 +8,7 @@ #include "unk.h" struct GameState; +struct PlayState; #define TMEM_SIZE 0x1000 @@ -88,7 +89,7 @@ typedef enum SetupDL { /* 0x49 */ SETUPDL_MAX } SetupDL; -typedef struct { +typedef struct GfxMasterList { /* 0x000 */ Gfx taskStart[9]; /* 0x048 */ Gfx clearZBuffer[8]; // original name: clear_zb_dl /* 0x088 */ Gfx clearFrameBuffer[5]; // original name: clear_fb_dl @@ -155,6 +156,9 @@ typedef struct GraphicsContext { /* 0x2EC */ GfxMasterList* masterList; } GraphicsContext; // size = 0x2F0 +// graph.c +void Graph_ThreadEntry(void* arg); + Gfx* Gfx_SetFog(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFogWithSync(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); Gfx* Gfx_SetFog2(Gfx* gfx, s32 r, s32 g, s32 b, s32 a, s32 n, s32 f); @@ -236,6 +240,12 @@ void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g void func_8012D374(GraphicsContext* gfxCtx, u8 r, u8 g, u8 b); void func_8012D40C(f32* param_1, f32* param_2, s16* param_3); +void Gfx_DrawDListOpa(struct PlayState* play, Gfx* dList); +void Gfx_DrawDListXlu(struct PlayState* play, Gfx* dList); + +// graph.c +extern struct GfxMasterList* gGfxMasterDL; + extern Gfx gSetupDLs[SETUPDL_MAX][6]; extern Gfx gEmptyDL[]; diff --git a/include/gfxalloc.h b/include/gfxalloc.h new file mode 100644 index 0000000000..9bfd9425d8 --- /dev/null +++ b/include/gfxalloc.h @@ -0,0 +1,10 @@ +#ifndef GFXALLOC_H +#define GFXALLOC_H + +#include "ultra64.h" + +Gfx* Gfx_Open(Gfx* gfx); +Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); +void* Gfx_Alloc(Gfx** gfxP, size_t size); + +#endif diff --git a/include/regs.h b/include/regs.h index a8a584fcce..1f5bc418d3 100644 --- a/include/regs.h +++ b/include/regs.h @@ -7,6 +7,7 @@ #include "ultra64.h" #include "unk.h" +struct PlayState; #define REG_GROUPS 29 // number of REG groups, i.e. REG, SREG, OREG, etc. #define REG_PAGES 6 @@ -182,4 +183,6 @@ extern RegEditor* gRegEditor; // Name inferred from OoT. Set to true to manually set play->csCtx.script #define R_USE_DEBUG_CUTSCENE dREG(95) +void Regs_InitData(struct PlayState* play); + #endif diff --git a/include/variables.h b/include/variables.h index 13f36e4ffa..47a635348d 100644 --- a/include/variables.h +++ b/include/variables.h @@ -8,22 +8,6 @@ // data -extern u32 gBitFlags[32]; -extern u16 gEquipMasks[]; -extern u16 gEquipNegMasks[]; -extern u32 gUpgradeMasks[8]; -extern u32 gUpgradeNegMasks[]; -extern u8 gEquipShifts[]; -extern u8 gUpgradeShifts[8]; -extern u16 gUpgradeCapacities[][4]; -extern u32 gGsFlagsMask[]; -extern u32 gGsFlagsShift[]; -extern TexturePtr gItemIcons[]; -extern u8 gItemSlots[]; -extern s16 gItemPrices[]; -extern u16 gSceneIdsPerRegion[11][27]; -extern u8 gPlayerFormItemRestrictions[PLAYER_FORM_MAX][114]; - extern s16 gLowPassFilterData[]; extern s16 gHighPassFilterData[]; extern s16 gBandStopFilterData[]; @@ -61,8 +45,6 @@ extern u8 gSampleBankTable[]; // bss -extern GfxMasterList* gGfxMasterDL; - extern u64* gAudioSPDataPtr; extern u32 gAudioSPDataSize; diff --git a/include/z64actor.h b/include/z64actor.h index f043c5080d..27732fc13c 100644 --- a/include/z64actor.h +++ b/include/z64actor.h @@ -25,11 +25,6 @@ typedef void (*ActorFunc)(struct Actor* this, struct PlayState* play); typedef u16 (*NpcGetTextIdFunc)(struct PlayState*, struct Actor*); typedef s16 (*NpcUpdateTalkStateFunc)(struct PlayState*, struct Actor*); -typedef struct PosRot { - /* 0x00 */ Vec3f pos; - /* 0x0C */ Vec3s rot; -} PosRot; // size = 0x14 - typedef struct { /* 0x0 */ s16 unk_0; // frame? /* 0x2 */ Vec3s unk_2; // scale diff --git a/include/z64cutscene.h b/include/z64cutscene.h index 82d2308902..a308048cd2 100644 --- a/include/z64cutscene.h +++ b/include/z64cutscene.h @@ -4,6 +4,13 @@ #include "ultra64.h" #include "unk.h" +#include "color.h" + +#include "z64math.h" + +struct Actor; +struct Camera; +struct PlayState; typedef union { struct { @@ -789,7 +796,7 @@ typedef struct CutsceneCamera { /* 0x70 */ CsCmdCamPoint* atCmd; /* 0x74 */ CsCmdCamPoint* eyeCmd; /* 0x78 */ CsCmdCamMisc* miscCmd; - /* 0x7C */ Camera* camera; + /* 0x7C */ struct Camera* camera; } CutsceneCamera; // size = 0x80 typedef enum { @@ -811,24 +818,24 @@ void Cutscene_UpdateScripted(struct PlayState* play, CutsceneContext* csCtx); void Cutscene_HandleEntranceTriggers(struct PlayState* play); void func_800EDDB0(struct PlayState* play); void Cutscene_StartScripted(struct PlayState* play, u8 scriptIndex); -void Cutscene_ActorTranslate(Actor* actor, struct PlayState* play, s32 cueChannel); -void Cutscene_ActorTranslateAndYaw(Actor* actor, struct PlayState* play, s32 cueChannel); -void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, struct PlayState* play, s32 cueChannel); -void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslate(struct Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslateAndYaw(struct Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslateAndYawSmooth(struct Actor* actor, struct PlayState* play, s32 cueChannel); +void Cutscene_ActorTranslateXZAndYawSmooth(struct Actor* actor, struct PlayState* play, s32 cueChannel); s32 Cutscene_GetSceneLayer(struct PlayState* play); s32 Cutscene_GetCueChannel(struct PlayState* play, u16 cueType); s32 Cutscene_IsCueInChannel(struct PlayState* play, u16 cueType); u8 Cutscene_IsPlaying(struct PlayState* play); void CutsceneManager_Init(struct PlayState* play, CutsceneEntry* cutsceneList, s16 numEntries); -void CutsceneManager_StoreCamera(Camera* camera); +void CutsceneManager_StoreCamera(struct Camera* camera); void CutsceneManager_ClearWaiting(void); s16 CutsceneManager_Update(void); void CutsceneManager_Queue(s16 csId); s16 CutsceneManager_IsNext(s16 csId); -s16 CutsceneManager_StartWithPlayerCs(s16 csId, Actor* actor); -s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, Actor* actor); -s16 CutsceneManager_Start(s16 csId, Actor* actor); +s16 CutsceneManager_StartWithPlayerCs(s16 csId, struct Actor* actor); +s16 CutsceneManager_StartWithPlayerCsAndSetFlag(s16 csId, struct Actor* actor); +s16 CutsceneManager_Start(s16 csId, struct Actor* actor); s16 CutsceneManager_Stop(s16 csId); s16 CutsceneManager_GetCurrentCsId(void); CutsceneEntry* CutsceneManager_GetCutsceneEntry(s16 csId); @@ -838,10 +845,10 @@ s16 CutsceneManager_GetCutsceneScriptIndex(s16 csId); s16 CutsceneManager_GetCutsceneCustomValue(s16 csId); s16 CutsceneManager_GetCurrentSubCamId(s16 csId); s16 CutsceneManager_FindEntranceCsId(void); -s32 func_800F22C4(s16 csId, Actor* actor); +s32 func_800F22C4(s16 csId, struct Actor* actor); void CutsceneManager_SetReturnCamera(s16 camId); -s32 CutsceneCamera_Init(Camera* camera, CutsceneCamera* csCamera); +s32 CutsceneCamera_Init(struct Camera* camera, CutsceneCamera* csCamera); s32 CutsceneCamera_UpdateSplines(u8* script, CutsceneCamera* csCamera); void CutsceneCamera_SetState(s16 state); void CutsceneCamera_Reset(void); diff --git a/include/z64elf_message.h b/include/z64elf_message.h new file mode 100644 index 0000000000..a64db86347 --- /dev/null +++ b/include/z64elf_message.h @@ -0,0 +1,10 @@ +#ifndef Z64ELF_MESSAGE_H +#define Z64ELF_MESSAGE_H + +#include "PR/ultratypes.h" + +struct PlayState; + +u16 QuestHint_GetTatlTextId(struct PlayState* play); + +#endif diff --git a/include/z64inventory.h b/include/z64inventory.h new file mode 100644 index 0000000000..7bb6094325 --- /dev/null +++ b/include/z64inventory.h @@ -0,0 +1,35 @@ +#ifndef Z64INVENTORY_H +#define Z64INVENTORY_H + +#include "PR/ultratypes.h" + +struct PlayState; + +s32 Inventory_GetBtnBItem(struct PlayState* play); +void Inventory_ChangeEquipment(s16 value); +u8 Inventory_DeleteEquipment(struct PlayState* play, s16 equipment); +void Inventory_ChangeUpgrade(s16 upgrade, u32 value); +s32 Inventory_IsMapVisible(s16 sceneId); +void Inventory_SetWorldMapCloudVisibility(s16 tingleIndex); +void Inventory_SaveDekuPlaygroundHighScore(s16 timerId); +void Inventory_IncrementSkullTokenCount(s16 sceneIndex); +s16 Inventory_GetSkullTokenCount(s16 sceneIndex); +void Inventory_SaveLotteryCodeGuess(struct PlayState* play); + +extern u32 gBitFlags[32]; +extern u16 gEquipMasks[]; +extern u16 gEquipNegMasks[]; +extern u32 gUpgradeMasks[8]; +extern u32 gUpgradeNegMasks[]; +extern u8 gEquipShifts[]; +extern u8 gUpgradeShifts[8]; +extern u16 gUpgradeCapacities[][4]; +extern u32 gGsFlagsMask[]; +extern u32 gGsFlagsShift[]; +extern TexturePtr gItemIcons[]; +extern u8 gItemSlots[]; +extern s16 gItemPrices[]; +extern u16 gSceneIdsPerRegion[11][27]; +extern u8 gPlayerFormItemRestrictions[][114]; + +#endif diff --git a/include/z64math.h b/include/z64math.h index f552b513d8..d0c50f3f1e 100644 --- a/include/z64math.h +++ b/include/z64math.h @@ -62,6 +62,11 @@ typedef struct { /* 0xC */ f32 radius; } Spheref; // size = 0x10 +typedef struct PosRot { + /* 0x00 */ Vec3f pos; + /* 0x0C */ Vec3s rot; +} PosRot; // size = 0x14 + /* The plane paramaters are of form `ax + by + cz + d = 0` where `(a,b,c)` is the plane's normal vector and d is the originDist @@ -114,19 +119,6 @@ typedef VecSphGeo VecSph; // Pitch is 0 along the xz-plane (horizon) typedef VecSphGeo VecGeo; -// To be used with OLib_Vec3fAdd() -typedef enum { - /* 0 */ OLIB_ADD_COPY, // Copy `b` to dest - /* 1 */ OLIB_ADD_OFFSET, // Add `a` and `b` to dest, and also add the yaw of `a` to the dest - /* 2 */ OLIB_ADD // Add `a` and `b` to dest -} OlibVec3fAdd; - -typedef enum { - /* 0 */ OLIB_DIFF_COPY, // Copy `b` to dest - /* 1 */ OLIB_DIFF_OFFSET, // Sub `a` and `b` to dest, and also subs the yaw of `a` to the dest - /* 2 */ OLIB_DIFF // Sub `a` and `b` to dest -} OlibVec3fDiff; - typedef float MtxF_t[4][4]; typedef union { MtxF_t mf; diff --git a/include/z64olib.h b/include/z64olib.h new file mode 100644 index 0000000000..ce38e0a379 --- /dev/null +++ b/include/z64olib.h @@ -0,0 +1,40 @@ +#ifndef Z64OLIB_H +#define Z64OLIB_H + +#include "ultra64.h" + +#include "z64math.h" + +// To be used with OLib_Vec3fAdd() +typedef enum { + /* 0 */ OLIB_ADD_COPY, // Copy `b` to dest + /* 1 */ OLIB_ADD_OFFSET, // Add `a` and `b` to dest, and also add the yaw of `a` to the dest + /* 2 */ OLIB_ADD // Add `a` and `b` to dest +} OlibVec3fAdd; + +typedef enum { + /* 0 */ OLIB_DIFF_COPY, // Copy `b` to dest + /* 1 */ OLIB_DIFF_OFFSET, // Sub `a` and `b` to dest, and also subs the yaw of `a` to the dest + /* 2 */ OLIB_DIFF // Sub `a` and `b` to dest +} OlibVec3fDiff; + +f32 OLib_Vec3fDist(Vec3f* a, Vec3f* b); +f32 OLib_Vec3fDistOutDiff(Vec3f* a, Vec3f* b, Vec3f* dest); +f32 OLib_Vec3fDistXZ(Vec3f* a, Vec3f* b); +f32 OLib_ClampMinDist(f32 val, f32 min); +f32 OLib_ClampMaxDist(f32 val, f32 max); +Vec3f OLib_Vec3fDistNormalize(Vec3f* a, Vec3f* b); +Vec3f OLib_VecSphToVec3f(VecSph* sph); +Vec3f OLib_VecGeoToVec3f(VecGeo* geo); +VecSph OLib_Vec3fToVecSph(Vec3f* vec); +VecGeo OLib_Vec3fToVecGeo(Vec3f* vec); +VecSph OLib_Vec3fDiffToVecSph(Vec3f* a, Vec3f* b); +VecGeo OLib_Vec3fDiffToVecGeo(Vec3f* a, Vec3f* b); +Vec3f OLib_AddVecGeoToVec3f(Vec3f* a, VecGeo* geo); +Vec3f OLib_Vec3fDiffRad(Vec3f* a, Vec3f* b); +Vec3f OLib_Vec3fDiffDegF(Vec3f* a, Vec3f* b); +Vec3s OLib_Vec3fDiffBinAng(Vec3f* a, Vec3f* b); +void OLib_Vec3fDiff(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); +void OLib_Vec3fAdd(PosRot* a, Vec3f* b, Vec3f* dest, s16 mode); + +#endif diff --git a/include/z64save.h b/include/z64save.h index 45bc64fd9f..5d0f5bff57 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -3,8 +3,11 @@ #include "ultra64.h" #include "PR/os.h" + +#include "z64inventory.h" #include "z64item.h" #include "z64math.h" + #include "unk.h" struct GameState; diff --git a/include/z64snap.h b/include/z64snap.h index 8bec78c3dd..c645e8cb72 100644 --- a/include/z64snap.h +++ b/include/z64snap.h @@ -4,6 +4,8 @@ #include "PR/ultratypes.h" #include "z64actor.h" +struct PlayState; + typedef s32 (*PictoValidationFunc)(struct PlayState*, Actor*); typedef struct { @@ -42,11 +44,11 @@ typedef enum { #define PICTO_VALID_TOPLEFT_X ((SCREEN_WIDTH - PICTO_VALID_WIDTH) / 2) #define PICTO_VALID_TOPLEFT_Y ((SCREEN_HEIGHT - PICTO_VALID_HEIGHT) / 2) -s32 Snap_RecordPictographedActors(PlayState* play); +s32 Snap_RecordPictographedActors(struct PlayState* play); void Snap_SetFlag(s32 flag); void Snap_UnsetFlag(s32 flag); u32 Snap_CheckFlag(s32 flag); s16 Snap_AbsS(s16 val); -s32 Snap_ValidatePictograph(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleRange); +s32 Snap_ValidatePictograph(struct PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax, s16 angleRange); #endif diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 52a914a075..0a46b9ccc5 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -15,6 +15,7 @@ #include "color.h" #include "macros.h" #include "gfx.h" +#include "gfxalloc.h" #include "slowly.h" #include "stack.h" #include "stackcheck.h" diff --git a/src/code/cutscene_camera.c b/src/code/cutscene_camera.c index 20406e60a7..b560e9c954 100644 --- a/src/code/cutscene_camera.c +++ b/src/code/cutscene_camera.c @@ -1,6 +1,9 @@ #include "global.h" + #include "string.h" +#include "z64olib.h" + CutsceneCamera* sCurCsCamera; typedef s16 (*CsCamInterpolateCallback)(Vec3f*, f32*, s16*, CsCmdCamPoint*, CsCmdCamMisc*, CutsceneCameraInterp*); diff --git a/src/code/flg_set.c b/src/code/flg_set.c index b964bba80a..2498603290 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -11,6 +11,8 @@ */ #include "flg_set.h" + +#include "gfxalloc.h" #include "global.h" #include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h" diff --git a/src/code/game.c b/src/code/game.c index 90b9b106bb..69131cc705 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -1,14 +1,21 @@ +#include "z64game.h" + #include "global.h" #include "audiomgr.h" +#include "debug.h" +#include "gfx.h" +#include "gfxalloc.h" #include "idle.h" +#include "regs.h" #include "sys_cfb.h" #include "libc64/malloc.h" + #include "z64debug_text.h" +#include "z64pause_menu.h" #include "z64rumble.h" #include "z64speed_meter.h" #include "z64vimode.h" #include "z64vis.h" -#include "debug.h" s32 gFramerateDivisor = 1; f32 gFramerateDivisorF = 1.0f; diff --git a/src/code/gfxalloc.c b/src/code/gfxalloc.c index 07070e9643..2af4926bac 100644 --- a/src/code/gfxalloc.c +++ b/src/code/gfxalloc.c @@ -1,4 +1,6 @@ -#include "global.h" +#include "gfxalloc.h" + +#include "alignment.h" Gfx* Gfx_Open(Gfx* gfx) { return &gfx[1]; diff --git a/src/code/graph.c b/src/code/graph.c index 2be2d9de8f..7fa6e505fe 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -1,14 +1,17 @@ -#include "z64.h" -#include "regs.h" -#include "fault.h" +#include "ultra64.h" + +#include "scheduler.h" // Variables are put before most headers as a hacky way to bypass bss reordering -FaultAddrConvClient sGraphFaultAddrConvClient; -FaultClient sGraphFaultClient; -GfxMasterList* gGfxMasterDL; +struct FaultAddrConvClient sGraphFaultAddrConvClient; +struct FaultClient sGraphFaultClient; +struct GfxMasterList* gGfxMasterDL; CfbInfo sGraphCfbInfos[3]; OSTime sGraphPrevUpdateEndTime; +#include "regs.h" +#include "fault.h" + #include "macros.h" #include "buffers.h" #include "idle.h" diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 4e9bcdc05e..d770a0d73c 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -1,6 +1,6 @@ #include "prevent_bss_reordering2.h" // bumps the bss index by 65 // clang-format off -// Partial structs taken from "prevent_bss_reordering.h", bumps the bss index by 56 +// Partial structs taken from "prevent_bss_reordering.h", bumps the bss index by 59 struct Dummy200 { int x; }; struct Dummy201 { int x; }; struct Dummy202 { int x; }; @@ -29,12 +29,15 @@ struct Dummy224 { int x; }; struct Dummy225 { int x; }; struct Dummy226 { int x; }; struct Dummy227 { int x; }; +struct Dummy228 { int x; }; +typedef int Dummy229; + // clang-format on -// Headers are currently valued at 63 mod 256 (./tools/calc_bss.sh ) +// Headers are currently valued at 60 mod 256 (./tools/calc_bss.sh ) #include "z64math.h" -#include "libc/stdbool.h" +#include "stdbool.h" #include "PR/gu.h" // The bss index at this point should be 184 diff --git a/src/code/z_camera.c b/src/code/z_camera.c index af79344902..58f57cd935 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -43,12 +43,17 @@ * */ +#include "z64camera.h" + #include "global.h" #include "string.h" + #include "z64malloc.h" +#include "z64olib.h" #include "z64quake.h" #include "z64shrink_window.h" #include "z64view.h" + #include "overlays/actors/ovl_En_Horse/z_en_horse.h" void func_800DDFE0(Camera* camera); diff --git a/src/code/z_debug_mode.c b/src/code/z_debug_mode.c index 9e9c2abba3..ae4c877ce4 100644 --- a/src/code/z_debug_mode.c +++ b/src/code/z_debug_mode.c @@ -1,5 +1,10 @@ #include "z64debug_text.h" -#include "global.h" + +#include "color.h" +#include "gfx.h" +#include "gfxalloc.h" +#include "gfxprint.h" +#include "macros.h" typedef struct { /* 0x0 */ u8 colorIndex; diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c index a7e97c3bde..029b07fa15 100644 --- a/src/code/z_elf_message.c +++ b/src/code/z_elf_message.c @@ -7,7 +7,12 @@ * which hint to give based on a script. * That system has been replaced with a single function that hardcodes the checks. */ + +#include "z64elf_message.h" + #include "global.h" +#include "z64save.h" +#include "z64scene.h" /** * Gets the relevant text ID for Tatl hints in first cycle. diff --git a/src/code/z_eventmgr.c b/src/code/z_eventmgr.c index 6c629cf5ef..ed112e8c60 100644 --- a/src/code/z_eventmgr.c +++ b/src/code/z_eventmgr.c @@ -4,10 +4,14 @@ * Manages all cutscenes except for manual */ -#include "global.h" -#include "z64shrink_window.h" +#include "z64cutscene.h" + #include "string.h" +#include "global.h" +#include "z64olib.h" +#include "z64shrink_window.h" + CutsceneEntry sGlobalCutsceneList[] = { // CS_ID_GLOBAL_78 { -100, -1, CS_CAM_ID_NONE, CS_SCRIPT_ID_NONE, CS_ID_NONE, CS_END_SFX_NONE_ALT, 255, CS_HUD_VISIBILITY_ALL_ALT, 255, diff --git a/src/code/z_inventory.c b/src/code/z_inventory.c index 69fcdcc0d6..d0b50a5be7 100644 --- a/src/code/z_inventory.c +++ b/src/code/z_inventory.c @@ -1,4 +1,14 @@ +#include "z64inventory.h" + #include "global.h" +#include "regs.h" + +#include "z64item.h" +#include "z64interface.h" +#include "z64player.h" +#include "z64save.h" +#include "z64scene.h" + #include "interface/parameter_static/parameter_static.h" #include "archives/icon_item_static/icon_item_static_yar.h" #include "archives/icon_item_24_static/icon_item_24_static_yar.h" diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index b576056681..3a0d126707 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -61,6 +61,7 @@ Gfx* sSkyboxStarsDList; #include "z64environment.h" +#include "gfxalloc.h" #include "global.h" #include "string.h" #include "sys_cfb.h" diff --git a/src/code/z_message.c b/src/code/z_message.c index 7fed4ade48..48bf479208 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -2,10 +2,12 @@ #include "z64message.h" #include "global.h" +#include "gfxalloc.h" #include "message_data_static.h" #include "padmgr.h" #include "sys_cmpdma.h" #include "segment_symbols.h" + #include "z64actor.h" #include "z64horse.h" #include "z64shrink_window.h" diff --git a/src/code/z_olib.c b/src/code/z_olib.c index 86fa656f9a..32ea40dd61 100644 --- a/src/code/z_olib.c +++ b/src/code/z_olib.c @@ -1,4 +1,7 @@ -#include "global.h" +#include "z64olib.h" + +#include "macros.h" +#include "z64camera.h" /** * Calculates the distances between `a` and `b` diff --git a/src/code/z_play.c b/src/code/z_play.c index af7b40426c..188336c00b 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -16,6 +16,7 @@ u8 sMotionBlurStatus; #include "z64play.h" #include "buffers.h" +#include "gfxalloc.h" #include "idle.h" #include "regs.h" #include "sys_cfb.h" diff --git a/src/code/z_quake.c b/src/code/z_quake.c index 37b51df700..aad0bde12d 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -3,6 +3,7 @@ #include "string.h" #include "global.h" +#include "z64olib.h" #include "z64view.h" typedef struct { diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 31bc019422..5636e96568 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1,6 +1,12 @@ +#include "gfx.h" + #include "global.h" +#include "gfxalloc.h" +#include "regs.h" #include "sys_cfb.h" +#include "z64pause_menu.h" + Gfx gSetupDLs[SETUPDL_MAX][6] = { { /* SETUPDL_0 */ diff --git a/src/code/z_snap.c b/src/code/z_snap.c index cd5a037045..6bd2a05f26 100644 --- a/src/code/z_snap.c +++ b/src/code/z_snap.c @@ -1,5 +1,8 @@ -#include "global.h" #include "z64snap.h" + +#include "global.h" +#include "z64olib.h" + #include "overlays/actors/ovl_En_Kakasi/z_en_kakasi.h" #define PICTO_SEEN_IN_SCENE 1 diff --git a/src/code/z_visfbuf.c b/src/code/z_visfbuf.c index 86a8c0d31a..f875a3a67d 100644 --- a/src/code/z_visfbuf.c +++ b/src/code/z_visfbuf.c @@ -10,8 +10,10 @@ * VisFbuf_Draw() for how to do this. */ -#include "global.h" #include "z64visfbuf.h" + +#include "gfxalloc.h" +#include "global.h" #include "sys_cfb.h" #include "sys_ucode.h" diff --git a/src/code/z_vismono.c b/src/code/z_vismono.c index c898882b12..ba15bccd07 100644 --- a/src/code/z_vismono.c +++ b/src/code/z_vismono.c @@ -7,7 +7,10 @@ * color palette that converts each color into the desaturated equivalent. More precise details can be found in inline * comments. */ + #include "z64vis.h" + +#include "gfxalloc.h" #include "global.h" #include "libc64/malloc.h" diff --git a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c index 8aca463114..530f63014f 100644 --- a/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c +++ b/src/overlays/actors/ovl_Dm_Char01/z_dm_char01.c @@ -4,7 +4,6 @@ * Description: Woodfall scene objects (temple, water, walls, etc) */ -#include "prevent_bss_reordering.h" #include "z_dm_char01.h" #include "objects/object_mtoride/object_mtoride.h" #include "overlays/actors/ovl_Obj_Etcetera/z_obj_etcetera.h" diff --git a/src/overlays/actors/ovl_En_Egol/z_en_egol.c b/src/overlays/actors/ovl_En_Egol/z_en_egol.c index 91ecfafb4c..fd5a76e8d9 100644 --- a/src/overlays/actors/ovl_En_Egol/z_en_egol.c +++ b/src/overlays/actors/ovl_En_Egol/z_en_egol.c @@ -5,6 +5,9 @@ */ #include "z_en_egol.h" + +#include "z64olib.h" + #include "objects/object_eg/object_eg.h" #include "objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_En_Arrow/z_en_arrow.h" diff --git a/src/overlays/actors/ovl_En_Elf/z_en_elf.c b/src/overlays/actors/ovl_En_Elf/z_en_elf.c index 7cdb19209f..fd09d65fc2 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -6,6 +6,8 @@ #include "z_en_elf.h" +#include "z64elf_message.h" + #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20 | ACTOR_FLAG_2000000) #define THIS ((EnElf*)thisx) diff --git a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c index 5de6ee04f9..da43bb0a79 100644 --- a/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c +++ b/src/overlays/actors/ovl_En_Jso2/z_en_jso2.c @@ -5,6 +5,9 @@ */ #include "z_en_jso2.h" + +#include "z64olib.h" + #include "assets/objects/gameplay_keep/gameplay_keep.h" #include "overlays/actors/ovl_En_Clear_Tag/z_en_clear_tag.h" #include "overlays/actors/ovl_En_Col_Man/z_en_col_man.h" diff --git a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c index 4a35d757bc..87ae08456c 100644 --- a/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c +++ b/src/overlays/actors/ovl_En_Kakasi/z_en_kakasi.c @@ -6,6 +6,9 @@ #include "prevent_bss_reordering.h" #include "z_en_kakasi.h" + +#include "z64olib.h" + #include "objects/object_ka/object_ka.h" #define FLAGS (ACTOR_FLAG_TARGETABLE | ACTOR_FLAG_FRIENDLY | ACTOR_FLAG_10 | ACTOR_FLAG_2000000) diff --git a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c index 617ddecc54..cfb33d7740 100644 --- a/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c +++ b/src/overlays/actors/ovl_En_Kusa/z_en_kusa.c @@ -4,7 +4,6 @@ * Description: Grass / Bush */ -#include "prevent_bss_reordering.h" #include "z_en_kusa.h" #include "objects/object_kusa/object_kusa.h" #include "objects/gameplay_keep/gameplay_keep.h" diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index 9b2874521a..450d07f1c6 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -5,6 +5,9 @@ */ #include "z_en_mag.h" + +#include "gfxalloc.h" + #include "objects/object_mag/object_mag.h" #define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20) diff --git a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c index 1a3449b2dd..75a4bbbdeb 100644 --- a/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_debug.c @@ -5,6 +5,9 @@ */ #include "z_kaleido_scope.h" + +#include "gfxalloc.h" + #include "interface/parameter_static/parameter_static.h" s16 sCurSection = 0; diff --git a/tools/check_reordering.py b/tools/check_reordering.py index 03df306381..f91b2d601d 100755 --- a/tools/check_reordering.py +++ b/tools/check_reordering.py @@ -18,7 +18,7 @@ def mapPathToSource(origName: Path) -> Path: # Try to map built path to the source path parts = origName.parts if parts[0] == "build": - parts = parts[1:] + parts = parts[2:] path = Path(*parts) # Assume every file in the asm folder has .s extension, while everything else has .c extension