From c54c1f2274fe762997ea13cf2b4a758f27db35e3 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 7 Sep 2024 11:29:25 +0200 Subject: [PATCH 1/2] Move audio/general.c debug bss with the rest of bss (#2152) * Move audio/general.c debug bss to own file and include with the rest of bss * just inline the bss instead of include --- src/audio/debug.inc.c | 6 ------ src/audio/general.c | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/audio/debug.inc.c b/src/audio/debug.inc.c index 5af3030f39..29fbd50a3c 100644 --- a/src/audio/debug.inc.c +++ b/src/audio/debug.inc.c @@ -1,9 +1,3 @@ -u32 sDebugPadHold; -u32 sDebugPadBtnLast; -u32 sDebugPadPress; -s32 sAudioUpdateTaskStart; -s32 sAudioUpdateTaskEnd; - f32 D_80131C8C = 0.0f; f32 sAudioUpdateDuration = 0.0f; f32 sAudioUpdateDurationMax = 0.0f; diff --git a/src/audio/general.c b/src/audio/general.c index af5ca719a6..528b16a197 100644 --- a/src/audio/general.c +++ b/src/audio/general.c @@ -1297,6 +1297,11 @@ OcarinaNote sScarecrowsLongSongSecondNote; #if OOT_DEBUG u8 sIsMalonSinging; f32 sMalonSingingDist; +u32 sDebugPadHold; +u32 sDebugPadBtnLast; +u32 sDebugPadPress; +s32 sAudioUpdateTaskStart; +s32 sAudioUpdateTaskEnd; #endif void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest); From 62b30e2ebe285d78012c053a157068a4c55ab22b Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Sat, 7 Sep 2024 12:30:55 +0200 Subject: [PATCH 2/2] Move `Graph_Alloc` and open/close Disps to `gfx.h` (#1976) * move graph_alloc and open/close Disps to gfx.h * zcolchk bss reeeeeee * fix matching gc-eu-mq (bss) * remove __gfxCtx extern * revert makefile -Werror=implicit-function-declaration * bss --- include/functions.h | 7 +-- include/gfx.h | 48 +++++++++++++++++++++ include/macros.h | 38 ---------------- src/code/sys_math3d.c | 2 +- src/code/z_collision_check.c | 1 - src/overlays/actors/ovl_Fishing/z_fishing.c | 2 +- 6 files changed, 51 insertions(+), 47 deletions(-) diff --git a/include/functions.h b/include/functions.h index 65a95050b6..3030455cb5 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1160,12 +1160,7 @@ void Graph_Destroy(GraphicsContext* gfxCtx); void Graph_TaskSet00(GraphicsContext* gfxCtx); void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState); void Graph_ThreadEntry(void*); -void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size); -void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size); -#if OOT_DEBUG -void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line); -void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line); -#endif + Gfx* Gfx_Open(Gfx* gfx); Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); void* Gfx_Alloc(Gfx** gfxP, u32 size); diff --git a/include/gfx.h b/include/gfx.h index c68e6a3618..5414cd5ade 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -161,4 +161,52 @@ typedef struct UCodeDisas { /* 0xD4 */ u32 geometryMode; } UCodeDisas; // size = 0xD8 +void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size); +void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size); + +#define WORK_DISP __gfxCtx->work.p +#define POLY_OPA_DISP __gfxCtx->polyOpa.p +#define POLY_XLU_DISP __gfxCtx->polyXlu.p +#define OVERLAY_DISP __gfxCtx->overlay.p + +#if OOT_DEBUG + +void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line); +void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line); + +// __gfxCtx shouldn't be used directly. +// Use the DISP macros defined above when writing to display buffers. +#define OPEN_DISPS(gfxCtx, file, line) \ + { \ + GraphicsContext* __gfxCtx; \ + Gfx* dispRefs[4]; \ + __gfxCtx = gfxCtx; \ + (void)__gfxCtx; \ + Graph_OpenDisps(dispRefs, gfxCtx, file, line) + +#define CLOSE_DISPS(gfxCtx, file, line) \ + do { \ + Graph_CloseDisps(dispRefs, gfxCtx, file, line); \ + } while (0); \ + } \ + (void)0 + +#define GRAPH_ALLOC(gfxCtx, size) Graph_Alloc(gfxCtx, size) + +#else + +#define OPEN_DISPS(gfxCtx, file, line) \ + { \ + GraphicsContext* __gfxCtx = gfxCtx; \ + s32 __dispPad + +#define CLOSE_DISPS(gfxCtx, file, line) \ + do {} while (0); \ + } \ + (void)0 + +#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) + +#endif + #endif diff --git a/include/macros.h b/include/macros.h index dab193146d..e39e64b76c 100644 --- a/include/macros.h +++ b/include/macros.h @@ -160,35 +160,8 @@ } \ (void)0 -struct GraphicsContext; - -extern struct GraphicsContext* __gfxCtx; - -#define WORK_DISP __gfxCtx->work.p -#define POLY_OPA_DISP __gfxCtx->polyOpa.p -#define POLY_XLU_DISP __gfxCtx->polyXlu.p -#define OVERLAY_DISP __gfxCtx->overlay.p - #if OOT_DEBUG -// __gfxCtx shouldn't be used directly. -// Use the DISP macros defined above when writing to display buffers. -#define OPEN_DISPS(gfxCtx, file, line) \ - { \ - GraphicsContext* __gfxCtx; \ - Gfx* dispRefs[4]; \ - __gfxCtx = gfxCtx; \ - (void)__gfxCtx; \ - Graph_OpenDisps(dispRefs, gfxCtx, file, line) - -#define CLOSE_DISPS(gfxCtx, file, line) \ - do { \ - Graph_CloseDisps(dispRefs, gfxCtx, file, line); \ - } while (0); \ - } \ - (void)0 - -#define GRAPH_ALLOC(gfxCtx, size) Graph_Alloc(gfxCtx, size) #define DMA_REQUEST_SYNC(ram, vrom, size, file, line) DmaMgr_RequestSyncDebug(ram, vrom, size, file, line) #define DMA_REQUEST_ASYNC(req, ram, vrom, size, unk5, queue, msg, file, line) DmaMgr_RequestAsyncDebug(req, ram, vrom, size, unk5, queue, msg, file, line) #define GAME_STATE_ALLOC(gameState, size, file, line) GameState_Alloc(gameState, size, file, line) @@ -207,17 +180,6 @@ extern struct GraphicsContext* __gfxCtx; #else -#define OPEN_DISPS(gfxCtx, file, line) \ - { \ - GraphicsContext* __gfxCtx = gfxCtx; \ - s32 __dispPad - -#define CLOSE_DISPS(gfxCtx, file, line) \ - do {} while (0); \ - } \ - (void)0 - -#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) #define DMA_REQUEST_SYNC(ram, vrom, size, file, line) DmaMgr_RequestSync(ram, vrom, size) #define DMA_REQUEST_ASYNC(req, ram, vrom, size, unk5, queue, msg, file, line) DmaMgr_RequestAsync(req, ram, vrom, size, unk5, queue, msg) #define GAME_STATE_ALLOC(gameState, size, file, line) THA_AllocTailAlign16(&(gameState)->tha, size) diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 38fb383124..570da1ab01 100644 --- a/src/code/sys_math3d.c +++ b/src/code/sys_math3d.c @@ -5,7 +5,7 @@ #include "macros.h" #include "sys_math3d.h" -#pragma increment_block_number "gc-eu:103 gc-eu-mq:103 gc-jp:103 gc-jp-ce:103 gc-jp-mq:103 gc-us:103 gc-us-mq:103" +#pragma increment_block_number "gc-eu:106 gc-eu-mq:106 gc-jp:106 gc-jp-ce:106 gc-jp-mq:106 gc-us:106 gc-us-mq:106" s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB, Vec3f* lineAClosestToB, Vec3f* lineBClosestToA); diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index f584641b66..2c0b19d3ef 100644 --- a/src/code/z_collision_check.c +++ b/src/code/z_collision_check.c @@ -2317,7 +2317,6 @@ void CollisionCheck_ATQuadVsACCyl(PlayState* play, CollisionCheckContext* colChk #if OOT_DEBUG static s8 sBssDummy3; static s8 sBssDummy4; -static s8 sBssDummy5; #endif void CollisionCheck_ATTrisVsACTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* atCol, diff --git a/src/overlays/actors/ovl_Fishing/z_fishing.c b/src/overlays/actors/ovl_Fishing/z_fishing.c index 48ea1fc010..9ca7dfebb6 100644 --- a/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -14,7 +14,7 @@ #include "cic6105.h" #endif -#pragma increment_block_number "gc-eu:147 gc-eu-mq:147 gc-jp:149 gc-jp-ce:149 gc-jp-mq:149 gc-us:149 gc-us-mq:149" +#pragma increment_block_number "gc-eu:149 gc-eu-mq:149 gc-jp:151 gc-jp-ce:151 gc-jp-mq:151 gc-us:151 gc-us-mq:151" #define FLAGS ACTOR_FLAG_4