Yet another header cleanup (#1508)

* lights.c

* z64skin_matrix.h

* Move out some stuff from macros.h

* gamealloc.h

* move most transition functions to z64transition.h

* z64lib.h

* `include` cleanup on transition files

* z_overlay cleanup

* z64malloc.h

* format

* forgot to remove those

* forgot this

* fix borken includes
This commit is contained in:
Anghelo Carvajal
2023-11-22 23:55:05 -03:00
committed by GitHub
parent 5ef277df2d
commit 506e215547
47 changed files with 389 additions and 253 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
#include "global.h"
#include "gamealloc.h"
#include "system_malloc.h"
void GameAlloc_Log(GameAlloc* this) {
GameAllocEntry* iter;
GameAllocEntry* iter = this->base.next;
iter = this->base.next;
while (iter != &this->base) {
iter = iter->next;
}
+10 -3
View File
@@ -1,8 +1,15 @@
#include "global.h"
#include "sys_cfb.h"
#include "prevent_bss_reordering.h"
#include "z64speed_meter.h"
#include "z64view.h"
#include "gfx.h"
#include "regs.h"
#include "sys_cfb.h"
#include "system_malloc.h"
#include "z64game.h"
#include "z64malloc.h"
#include "z64view.h"
#include "variables.h"
/**
* How much time the RSP ran audio tasks for over the course of `gGraphUpdatePeriod`.
+2
View File
@@ -4,11 +4,13 @@
*/
#include "z64actor.h"
#include "prevent_bss_reordering.h"
#include "fault.h"
#include "sys_cfb.h"
#include "loadfragment.h"
#include "z64horse.h"
#include "z64malloc.h"
#include "z64quake.h"
#include "z64rumble.h"
+1
View File
@@ -45,6 +45,7 @@
#include "global.h"
#include "libc/string.h"
#include "z64malloc.h"
#include "z64quake.h"
#include "z64shrink_window.h"
#include "z64view.h"
+3 -1
View File
@@ -1,7 +1,9 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "z64collision_check.h"
#include "global.h"
#include "z64malloc.h"
typedef s32 (*ColChkResetFunc)(struct PlayState*, Collider*);
typedef void (*ColChkBloodFunc)(struct PlayState*, Collider*, Vec3f*);
typedef void (*ColChkApplyFunc)(struct PlayState*, CollisionCheckContext*, Collider*);
+1
View File
@@ -1,5 +1,6 @@
#include "global.h"
#include "loadfragment.h"
#include "z64malloc.h"
EffectSsInfo sEffectSsInfo = { NULL, 0, 0 };
+3
View File
@@ -9,6 +9,9 @@
* @note The only coded effect has a visual effect to blend the tiles to a single point, which looks like the screen
* gets sucked into.
*/
#include "z64transition.h"
#include "global.h"
#include "system_malloc.h"
+19 -7
View File
@@ -1,7 +1,10 @@
#include "global.h"
#include "sys_cfb.h"
#include "z64transition.h"
typedef enum {
#include "sys_cfb.h"
#include "z64math.h"
#include "variables.h"
typedef enum TransitionCircleDirection {
/* 0 */ TRANS_CIRCLE_DIR_IN,
/* 1 */ TRANS_CIRCLE_DIR_OUT
} TransitionCircleDirection;
@@ -18,10 +21,18 @@ Gfx sTransCircleSetupDL[] = {
gsSPEndDisplayList(),
};
//! @bug: TransitionCircle_Update should take an additional argument `s32 updateRate`
void TransitionCircle_Start(void* thisx);
void* TransitionCircle_Init(void* thisx);
void TransitionCircle_Destroy(void* thisx);
void TransitionCircle_Update(void* thisx, s32 updateRate);
void TransitionCircle_SetColor(void* thisx, u32 color);
void TransitionCircle_SetType(void* thisx, s32 type);
void TransitionCircle_Draw(void* thisx, Gfx** gfxp);
s32 TransitionCircle_IsDone(void* thisx);
TransitionInit TransitionCircle_InitVars = {
TransitionCircle_Init, TransitionCircle_Destroy, (void*)TransitionCircle_Update, TransitionCircle_Draw,
TransitionCircle_Start, TransitionCircle_SetType, TransitionCircle_SetColor, NULL,
TransitionCircle_Init, TransitionCircle_Destroy, TransitionCircle_Update, TransitionCircle_Draw,
TransitionCircle_Start, TransitionCircle_SetType, TransitionCircle_SetColor, NULL,
TransitionCircle_IsDone,
};
@@ -56,8 +67,9 @@ void* TransitionCircle_Init(void* thisx) {
void TransitionCircle_Destroy(void* thisx) {
}
void TransitionCircle_Update(void* thisx) {
void TransitionCircle_Update(void* thisx, s32 updateRate) {
TransitionCircle* this = (TransitionCircle*)thisx;
s32 unused = updateRate ? 0 : 0;
this->isDone = Math_StepToF(&this->referenceRadius, this->targetRadius, this->stepValue);
}
+4 -1
View File
@@ -1,4 +1,7 @@
#include "global.h"
#include "z64transition.h"
#include "segment_symbols.h"
#include "z64lib.h"
// InitVars and Linker symbol declarations (used in the table below)
#define DEFINE_TRANSITION(_enumValue, structName, _instanceName, name) \
+9 -3
View File
@@ -1,13 +1,19 @@
#include "global.h"
#include "z64transition.h"
#include "libc/stdbool.h"
#include "gfx.h"
#include "regs.h"
#include "z64math.h"
#include "z64save.h"
#define THIS ((TransitionFade*)thisx)
typedef enum {
typedef enum TransitionFadeDirection {
/* 0 */ TRANS_FADE_DIR_IN,
/* 1 */ TRANS_FADE_DIR_OUT
} TransitionFadeDirection;
typedef enum {
typedef enum TransitionFadeType {
/* 0 */ TRANS_FADE_TYPE_NONE,
/* 1 */ TRANS_FADE_TYPE_ONE_WAY,
/* 2 */ TRANS_FADE_TYPE_FLASH
+8 -2
View File
@@ -25,9 +25,15 @@
* - higher detail draws both.
*/
#include "global.h"
#include "z64curve.h"
#include "libc/stdbool.h"
#include "z64actor.h"
#include "z64animation.h"
#include "z64curve.h"
#include "z64malloc.h"
#include "z64.h"
void SkelCurve_Clear(SkelCurve* skelCurve) {
skelCurve->limbCount = 0;
skelCurve->skeleton = NULL;
@@ -76,7 +82,7 @@ void SkelCurve_SetAnim(SkelCurve* skelCurve, CurveAnimationHeader* animation, f3
skelCurve->animation = animation;
}
typedef enum {
typedef enum SkelCurveVecType {
/* 0 */ SKELCURVE_VEC_TYPE_SCALE,
/* 1 */ SKELCURVE_VEC_TYPE_ROTATION,
/* 2 */ SKELCURVE_VEC_TYPE_POSIITON,
+10 -2
View File
@@ -1,4 +1,12 @@
#include "global.h"
#include "z64lib.h"
#include "main.h"
#include "ichain.h"
#include "sfx.h"
#include "z64actor.h"
#include "z64game.h"
#include "functions.h"
#include "macros.h"
void* Lib_MemCpy(void* dest, void* src, size_t size) {
bcopy(src, dest, size);
@@ -11,7 +19,7 @@ void* Lib_MemSet(void* buffer, s32 value, size_t size) {
s32 i;
if (value == 0) {
bzero(buffer, (u32)size);
bzero(buffer, size);
return buffer;
}
+19 -9
View File
@@ -1,10 +1,15 @@
#include "global.h"
#include "z64light.h"
#include "sys_cfb.h"
#include "z64skin_matrix.h"
#include "z64.h"
#include "functions.h"
#include "objects/gameplay_keep/gameplay_keep.h"
LightsBuffer sLightsBuffer;
void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, s32 type) {
void Lights_PointSetInfo(LightInfo* info, s16 x, s16 y, s16 z, u8 r, u8 g, u8 b, s16 radius, LightType type) {
info->type = type;
info->params.point.x = x;
info->params.point.y = y;
@@ -79,7 +84,7 @@ void Lights_Draw(Lights* lights, GraphicsContext* gfxCtx) {
}
Light* Lights_FindSlot(Lights* lights) {
if (lights->numLights >= 7) {
if (lights->numLights >= ARRAY_COUNT(lights->l.l)) {
return NULL;
}
return &lights->l.l[lights->numLights++];
@@ -182,6 +187,9 @@ void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused) {
}
}
typedef void (*LightsBindFunc)(Lights* lights, LightParams* params, Vec3f* vec);
typedef void (*LightsPosBindFunc)(Lights* lights, LightParams* params, struct PlayState* play);
/**
* For every light in a provided list, try to find a free slot in the provided Lights group and bind
* a light to it. Then apply color and positional/directional info for each light
@@ -240,13 +248,15 @@ LightNode* Lights_FindBufSlot(void) {
}
void Lights_FreeNode(LightNode* light) {
if (light != NULL) {
sLightsBuffer.numOccupied--;
light->info = NULL;
sLightsBuffer.searchIndex =
(light - sLightsBuffer.lights) /
(s32)sizeof(LightNode); //! @bug Due to pointer arithmetic, the division is unnecessary
if (light == NULL) {
return;
}
sLightsBuffer.numOccupied--;
light->info = NULL;
//! @bug Due to pointer arithmetic, the division is unnecessary
sLightsBuffer.searchIndex = (light - sLightsBuffer.lights) / (s32)sizeof(LightNode);
}
void LightContext_Init(PlayState* play, LightContext* lightCtx) {
+2 -1
View File
@@ -1,4 +1,5 @@
#include "global.h"
#include "z64malloc.h"
#include "os_malloc.h"
Arena sZeldaArena;
+31 -31
View File
@@ -2,18 +2,13 @@
* @file z_overlay.c
*
* Functions for handling transition overlays in memory
*
* Status codes returned from TransitionOverlay_Load and TransitionOverlay_Free:
*
* -1 : failed allocation or null reference
* 0 : successfully loaded/freed overlay
* 1 : successfully added/removed instance
* 2 : overlay is loaded but has no instances (?) TODO: Figure out why this exists
* 3 : internal overlay, so always loaded
*/
#include "global.h"
#include "z64transition.h"
#include "loadfragment.h"
#include "z64lib.h"
#include "z64malloc.h"
void* TransitionOverlay_VramToRam(TransitionOverlay* overlayEntry, void* vramAddr) {
void* loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr);
@@ -32,46 +27,51 @@ void TransitionOverlay_VramToRamArray(TransitionOverlay* overlayEntry, void** vr
}
}
s32 TransitionOverlay_Load(TransitionOverlay* overlayEntry) {
TransitionOverlayStatus TransitionOverlay_Load(TransitionOverlay* overlayEntry) {
s32 count;
void* loadedRamAddr;
if (overlayEntry->vromStart == 0) {
return 3;
return TRANSITION_OVERLAY_STATUS_INTERNAL;
}
if (Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr) == NULL) {
loadedRamAddr = ZeldaArena_Malloc((uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart);
if (loadedRamAddr == NULL) {
return -1;
return TRANSITION_OVERLAY_STATUS_FAILED;
}
Overlay_Load(overlayEntry->vromStart, overlayEntry->vromEnd, overlayEntry->vramStart, overlayEntry->vramEnd,
loadedRamAddr);
overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(loadedRamAddr);
overlayEntry->loadInfo.count = 1;
return 0;
} else {
count = overlayEntry->loadInfo.count;
if (count != 0) {
count++;
overlayEntry->loadInfo.count = count;
if (count == 0) {
return 2;
} else {
return 1;
}
}
return 2;
return TRANSITION_OVERLAY_STATUS_LOAD_FREE;
}
count = overlayEntry->loadInfo.count;
if (count != 0) {
count++;
overlayEntry->loadInfo.count = count;
if (count == 0) {
return TRANSITION_OVERLAY_STATUS_LOADED_NO_INSTANCES;
} else {
return TRANSITION_OVERLAY_STATUS_ADD_REMOVAL;
}
}
return TRANSITION_OVERLAY_STATUS_LOADED_NO_INSTANCES;
}
s32 TransitionOverlay_Free(TransitionOverlay* overlayEntry) {
TransitionOverlayStatus TransitionOverlay_Free(TransitionOverlay* overlayEntry) {
s32 count;
void* loadedRamAddr;
if (overlayEntry->vromStart == 0) {
return 3;
return TRANSITION_OVERLAY_STATUS_INTERNAL;
}
loadedRamAddr = Lib_PhysicalToVirtual(overlayEntry->loadInfo.addr);
if (loadedRamAddr != NULL) {
count = overlayEntry->loadInfo.count;
@@ -81,13 +81,13 @@ s32 TransitionOverlay_Free(TransitionOverlay* overlayEntry) {
if (count == 0) {
ZeldaArena_Free(loadedRamAddr);
overlayEntry->loadInfo.addr = Lib_VirtualToPhysical(NULL);
return 0;
return TRANSITION_OVERLAY_STATUS_LOAD_FREE;
}
return 1;
return TRANSITION_OVERLAY_STATUS_ADD_REMOVAL;
}
return 2;
return TRANSITION_OVERLAY_STATUS_LOADED_NO_INSTANCES;
}
return -1;
return TRANSITION_OVERLAY_STATUS_FAILED;
}
void TransitionOverlay_ClearLoadInfo(TransitionOverlay* overlayEntry) {
+2
View File
@@ -1,9 +1,11 @@
#include "global.h"
#include "PR/gs2dex.h"
#include "sys_cfb.h"
#include "z64malloc.h"
#include "z64snap.h"
#include "z64view.h"
#include "z64voice.h"
#include "archives/icon_item_static/icon_item_static_yar.h"
#include "interface/parameter_static/parameter_static.h"
#include "interface/do_action_static/do_action_static.h"
+1
View File
@@ -2,6 +2,7 @@
#include "z64.h"
#include "regs.h"
#include "functions.h"
#include "z64malloc.h"
#include "z64vismono.h"
#include "z64visfbuf.h"
+2
View File
@@ -1,6 +1,8 @@
#include "global.h"
#include "sys_cfb.h"
#include "z64bombers_notebook.h"
#include "z64malloc.h"
#include "interface/schedule_static/schedule_static.h"
#include "archives/schedule_dma_static/schedule_dma_static_yar.h"
+1
View File
@@ -1,4 +1,5 @@
#include "global.h"
#include "z64malloc.h"
#define ANIM_INTERP 1
+3 -1
View File
@@ -1,6 +1,8 @@
#include "global.h"
#include "z64skin.h"
#include "global.h"
#include "z64malloc.h"
void Skin_Setup(Skin* skin) {
skin->skeletonHeader = NULL;
skin->limbCount = 0;
+5 -1
View File
@@ -1,4 +1,8 @@
#include "global.h"
#include "z64skin_matrix.h"
#include "gfx.h"
#include "macros.h"
#include "z64math.h"
MtxF sMtxFClear = { {
{ 1.0f, 0.0f, 0.0f, 0.0f },