summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/game.c18
-rw-r--r--src/code/graph.c17
-rw-r--r--src/code/sched.c7
-rw-r--r--src/code/speed_meter.c262
-rw-r--r--src/code/sys_matrix.c2
-rw-r--r--src/code/z_bgcheck.c14
-rw-r--r--src/code/z_effect_soft_sprite.c2
-rw-r--r--src/code/z_kaleido_manager.c2
-rw-r--r--src/code/z_malloc.c6
-rw-r--r--src/code/z_map_exp.c2
-rw-r--r--src/code/z_message.c2
-rw-r--r--src/code/z_parameter.c6
-rw-r--r--src/code/z_play.c8
-rw-r--r--src/code/z_room.c2
-rw-r--r--src/code/z_scene.c4
-rw-r--r--src/code/z_sram_NES.c2
-rw-r--r--src/code/z_vr_box.c6
17 files changed, 306 insertions, 56 deletions
diff --git a/src/code/game.c b/src/code/game.c
index 4f2df63cd..237783319 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -164,11 +164,11 @@ void GameState_InitArena(GameState* gameState, size_t size) {
void* buf = GameAlloc_Malloc(alloc, size);
if (buf) {
- THA_Init(&gameState->heap, buf, size);
+ THA_Init(&gameState->tha, buf, size);
return;
}
- THA_Init(&gameState->heap, NULL, 0);
+ THA_Init(&gameState->tha, NULL, 0);
_dbg_hungup("../game.c", 1035);
}
@@ -178,9 +178,9 @@ void GameState_Realloc(GameState* gameState, size_t size) {
size_t systemMaxFree;
size_t bytesFree;
size_t bytesAllocated;
- void* heapStart = gameState->heap.start;
+ void* heapStart = gameState->tha.start;
- THA_Destroy(&gameState->heap);
+ THA_Destroy(&gameState->tha);
GameAlloc_Free(alloc, heapStart);
SystemArena_GetSizes(&systemMaxFree, &bytesFree, &bytesAllocated);
size = ((systemMaxFree - sizeof(ArenaNode)) < size) ? 0 : size;
@@ -190,9 +190,9 @@ void GameState_Realloc(GameState* gameState, size_t size) {
gameArena = GameAlloc_Malloc(alloc, size);
if (gameArena != NULL) {
- THA_Init(&gameState->heap, gameArena, size);
+ THA_Init(&gameState->tha, gameArena, size);
} else {
- THA_Init(&gameState->heap, NULL, 0);
+ THA_Init(&gameState->tha, NULL, 0);
_dbg_hungup("../game.c", 1074);
}
}
@@ -246,7 +246,7 @@ void GameState_Destroy(GameState* gameState) {
VisZbuf_Destroy(&sGameVisZbuf);
VisMono_Destroy(&sGameVisMono);
ViMode_Destroy(&sGameViMode);
- THA_Destroy(&gameState->heap);
+ THA_Destroy(&gameState->tha);
GameAlloc_Cleanup(&gameState->alloc);
}
@@ -263,11 +263,11 @@ u32 GameState_IsRunning(GameState* gameState) {
}
s32 GameState_GetArenaSize(GameState* gameState) {
- return THA_GetRemaining(&gameState->heap);
+ return THA_GetRemaining(&gameState->tha);
}
s32 func_80173B48(GameState* gameState) {
- s32 result = OS_CYCLES_TO_NSEC(gameState->framerateDivisor * sIrqMgrRetraceTime) - OS_CYCLES_TO_NSEC(gRDPTimeTotal);
+ s32 result = OS_CYCLES_TO_NSEC(gameState->framerateDivisor * gIrqMgrRetraceTime) - OS_CYCLES_TO_NSEC(gRDPTimeTotal);
return result;
}
diff --git a/src/code/graph.c b/src/code/graph.c
index bce162406..ad4ad0286 100644
--- a/src/code/graph.c
+++ b/src/code/graph.c
@@ -8,7 +8,7 @@ FaultAddrConvClient sGraphFaultAddrConvClient;
FaultClient sGraphFaultClient;
GfxMasterList* gGfxMasterDL;
CfbInfo sGraphCfbInfos[3];
-OSTime sGraphTaskStartTime;
+OSTime sGraphPrevUpdateEndTime;
#include "variables.h"
#include "macros.h"
@@ -16,6 +16,7 @@ OSTime sGraphTaskStartTime;
#include "idle.h"
#include "sys_cfb.h"
#include "system_malloc.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"
@@ -310,17 +311,17 @@ void Graph_ExecuteAndDraw(GraphicsContext* gfxCtx, GameState* gameState) {
{
OSTime time = osGetTime();
- D_801FBAE8 = sRSPGFXTotalTime;
- D_801FBAE0 = gRSPAudioTotalTime;
+ gRSPGfxTimeTotal = gRSPGfxTimeAcc;
+ gRSPAudioTimeTotal = gRSPAudioTimeAcc;
gRDPTimeTotal = gRDPTimeAcc;
- sRSPGFXTotalTime = 0;
- gRSPAudioTotalTime = 0;
+ gRSPGfxTimeAcc = 0;
+ gRSPAudioTimeAcc = 0;
gRDPTimeAcc = 0;
- if (sGraphTaskStartTime != 0) {
- lastRenderFrameDuration = time - sGraphTaskStartTime;
+ if (sGraphPrevUpdateEndTime != 0) {
+ gGraphUpdatePeriod = time - sGraphPrevUpdateEndTime;
}
- sGraphTaskStartTime = time;
+ sGraphPrevUpdateEndTime = time;
}
}
diff --git a/src/code/sched.c b/src/code/sched.c
index f8dc2a35d..289b4a696 100644
--- a/src/code/sched.c
+++ b/src/code/sched.c
@@ -16,6 +16,7 @@ u32 gAudioSPDataSize;
#include "functions.h"
#include "variables.h"
#include "stackcheck.h"
+#include "z64speed_meter.h"
#include "z64thread.h"
#define RSP_DONE_MSG 667
@@ -426,16 +427,16 @@ void Sched_HandleRSPDone(SchedContext* sched) {
time = osGetTime();
switch (sched->curRSPTask->list.t.type) {
case M_AUDTASK:
- gRSPAudioTotalTime += time - sRSPAudioStartTime;
+ gRSPAudioTimeAcc += time - sRSPAudioStartTime;
break;
case M_GFXTASK:
- sRSPGFXTotalTime += time - sRSPGFXStartTime;
+ gRSPGfxTimeAcc += time - sRSPGFXStartTime;
break;
default:
if (1) {}
- sRSPOtherTotalTime += time - sRSPOtherStartTime;
+ gRSPOtherTimeAcc += time - sRSPOtherStartTime;
break;
}
diff --git a/src/code/speed_meter.c b/src/code/speed_meter.c
index 1e6f1f886..3550d62ce 100644
--- a/src/code/speed_meter.c
+++ b/src/code/speed_meter.c
@@ -1,18 +1,266 @@
#include "global.h"
+#include "sys_cfb.h"
#include "z64speed_meter.h"
#include "z64view.h"
#include "system_malloc.h"
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177390.s")
+/**
+ * How much time the RSP ran audio tasks for over the course of `gGraphUpdatePeriod`.
+ */
+volatile OSTime gRSPAudioTimeTotal;
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/SpeedMeter_Init.s")
+/**
+ * How much time the RSP ran graphics tasks for over the course of `gGraphUpdatePeriod`.
+ * Typically the RSP runs 1 graphics task per `Graph_Update` cycle, but may run 0 (see `Graph_Update`).
+ */
+volatile OSTime gRSPGfxTimeTotal;
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/SpeedMeter_Destroy.s")
+/**
+ * How much time the RDP ran for over the course of `gGraphUpdatePeriod`.
+ */
+volatile OSTime gRDPTimeTotal;
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/SpeedMeter_DrawTimeEntries.s")
+/**
+ * How much time elapsed between the last two `Graph_Update` ending.
+ * This is expected to be at least the duration of a single frame, since it includes the time spent waiting on the
+ * graphics task to be done.
+ */
+volatile OSTime gGraphUpdatePeriod;
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177A84.s")
+// Accumulator for `gRSPAudioTimeTotal`
+volatile OSTime gRSPAudioTimeAcc;
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/func_80177AC8.s")
+// Accumulator for `gRSPGfxTimeTotal`.
+volatile OSTime gRSPGfxTimeAcc;
-#pragma GLOBAL_ASM("asm/non_matchings/code/speed_meter/SpeedMeter_DrawAllocEntries.s")
+volatile OSTime gRSPOtherTimeAcc;
+volatile OSTime gUnkTimeAcc;
+
+// Accumulator for `gRDPTimeTotal`
+volatile OSTime gRDPTimeAcc;
+
+typedef struct {
+ /* 0x0 */ volatile OSTime* time;
+ /* 0x4 */ u16 x;
+ /* 0x5 */ u16 y;
+ /* 0x6 */ u16 color;
+} SpeedMeterTimeEntry; // size = 0x8
+
+SpeedMeterTimeEntry* sSpeedMeterTimeEntryPtr;
+
+SpeedMeterTimeEntry sSpeedMeterTimeEntryArray[] = {
+ { &gRSPAudioTimeTotal, 0, 6, GPACK_RGBA5551(0, 0, 255, 1) },
+ { &gRSPGfxTimeTotal, 0, 8, GPACK_RGBA5551(255, 128, 128, 1) },
+ { &gRDPTimeTotal, 0, 10, GPACK_RGBA5551(0, 255, 0, 1) },
+ { &gGraphUpdatePeriod, 0, 12, GPACK_RGBA5551(255, 0, 255, 1) },
+};
+
+typedef struct {
+ /* 0x00 */ s32 maxVal;
+ /* 0x04 */ s32 val;
+ /* 0x08 */ u16 backColor;
+ /* 0x0A */ u16 foreColor;
+ /* 0x0C */ s32 ulx;
+ /* 0x10 */ s32 lrx;
+ /* 0x14 */ s32 uly;
+ /* 0x18 */ s32 lry;
+} SpeedMeterAllocEntry; // size = 0x1C
+
+//! FAKE: if(1) in macro
+
+#define gDrawRect(gfx, color, ulx, uly, lrx, lry) \
+ do { \
+ if (gSysCfbHiResEnabled == true) { \
+ u32 tmp = color; \
+ gDPPipeSync(gfx); \
+ gDPSetFillColor(gfx, ((tmp) << 16) | (tmp)); \
+ gDPFillRectangle(gfx, (ulx)*2, (uly)*2, (lrx)*2, (lry)*2); \
+ if (1) {} \
+ } else { \
+ u32 tmp = color; \
+ gDPPipeSync(gfx); \
+ gDPSetFillColor(gfx, ((tmp) << 16) | (tmp)); \
+ gDPFillRectangle(gfx, (ulx), (uly), (lrx), (lry)); \
+ } \
+ } while (0)
+
+void SpeedMeter_InitImpl(SpeedMeter* this, s32 x, s32 y) {
+ this->x = x;
+ this->y = y;
+}
+
+void SpeedMeter_Init(SpeedMeter* this) {
+ SpeedMeter_InitImpl(this, 32, 22);
+}
+
+void SpeedMeter_Destroy(SpeedMeter* this) {
+}
+
+void SpeedMeter_DrawTimeEntries(SpeedMeter* this, GraphicsContext* gfxCtx) {
+ s32 pad[3];
+ u32 baseX = 32;
+ s32 width;
+ s32 uly;
+ s32 lry;
+ s32 pad3;
+ View view;
+ s32 pad2[2];
+ s32 i;
+ Gfx* gfx;
+
+ uly = this->y;
+ lry = this->y + 2;
+
+ OPEN_DISPS(gfxCtx);
+
+ /*! @bug if gIrqMgrRetraceTime is 0, CLOSE_DISPS will never be reached */
+ if (gIrqMgrRetraceTime == 0) {
+ return;
+ }
+
+ sSpeedMeterTimeEntryPtr = &sSpeedMeterTimeEntryArray[0];
+ for (i = 0; i < ARRAY_COUNT(sSpeedMeterTimeEntryArray); i++) {
+ width = ((f64)*sSpeedMeterTimeEntryPtr->time / gIrqMgrRetraceTime) * 64.0;
+ sSpeedMeterTimeEntryPtr->x = baseX + width;
+ sSpeedMeterTimeEntryPtr++;
+ }
+
+ View_Init(&view, gfxCtx);
+ view.flags = VIEW_VIEWPORT | VIEW_PROJECTION_ORTHO;
+
+ SET_FULLSCREEN_VIEWPORT_DYNAMIC(&view);
+
+ gfx = OVERLAY_DISP;
+ View_ApplyTo(&view, &gfx);
+
+ gDPPipeSync(gfx++);
+ gDPSetOtherMode(gfx++,
+ G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
+ G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE,
+ G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
+
+ gDrawRect(gfx++, GPACK_RGBA5551(0, 0, 255, 1), baseX + 64 * 0, uly, baseX + 64 * 1, lry);
+ gDrawRect(gfx++, GPACK_RGBA5551(0, 255, 0, 1), baseX + 64 * 1, uly, baseX + 64 * 2, lry);
+ gDrawRect(gfx++, GPACK_RGBA5551(255, 0, 0, 1), baseX + 64 * 2, uly, baseX + 64 * 3, lry);
+ gDrawRect(gfx++, GPACK_RGBA5551(255, 0, 255, 1), baseX + 64 * 3, uly, baseX + 64 * 4, lry);
+
+ sSpeedMeterTimeEntryPtr = &sSpeedMeterTimeEntryArray[0];
+ for (i = 0; i < ARRAY_COUNT(sSpeedMeterTimeEntryArray); i++) {
+ gDrawRect(gfx++, sSpeedMeterTimeEntryPtr->color, baseX, lry + sSpeedMeterTimeEntryPtr->y,
+ sSpeedMeterTimeEntryPtr->x, lry + sSpeedMeterTimeEntryPtr->y + 1);
+ sSpeedMeterTimeEntryPtr++;
+ }
+ gDPPipeSync(gfx++);
+
+ OVERLAY_DISP = gfx;
+
+ CLOSE_DISPS(gfxCtx);
+}
+
+void SpeedMeter_InitAllocEntry(SpeedMeterAllocEntry* this, u32 maxVal, u32 val, u16 backColor, u16 foreColor, u32 ulx,
+ u32 lrx, u32 uly, u32 lry) {
+ this->maxVal = maxVal;
+ this->val = val;
+ this->backColor = backColor;
+ this->foreColor = foreColor;
+ this->ulx = ulx;
+ this->lrx = lrx;
+ this->uly = uly;
+ this->lry = lry;
+}
+
+void SpeedMeter_DrawAllocEntry(SpeedMeterAllocEntry* this, GraphicsContext* gfxCtx) {
+ s32 usedOff;
+ View view;
+ Gfx* gfx;
+
+ if (this->maxVal != 0) {
+ OPEN_DISPS(gfxCtx);
+
+ View_Init(&view, gfxCtx);
+ view.flags = VIEW_VIEWPORT | VIEW_PROJECTION_ORTHO;
+
+ SET_FULLSCREEN_VIEWPORT_DYNAMIC(&view);
+
+ gfx = OVERLAY_DISP;
+ View_ApplyTo(&view, &gfx);
+
+ gDPPipeSync(gfx++);
+ gDPSetOtherMode(gfx++,
+ G_AD_PATTERN | G_CD_MAGICSQ | G_CK_NONE | G_TC_CONV | G_TF_POINT | G_TT_NONE | G_TL_TILE |
+ G_TD_CLAMP | G_TP_NONE | G_CYC_FILL | G_PM_NPRIMITIVE,
+ G_AC_NONE | G_ZS_PIXEL | G_RM_NOOP | G_RM_NOOP2);
+
+ usedOff = ((this->lrx - this->ulx) * this->val) / this->maxVal + this->ulx;
+ gDrawRect(gfx++, this->backColor, usedOff, this->uly, this->lrx, this->lry);
+ gDrawRect(gfx++, this->foreColor, this->ulx, this->uly, usedOff, this->lry);
+
+ gDPPipeSync(gfx++);
+
+ //! FAKE:
+ if (this && this && this) {}
+
+ OVERLAY_DISP = gfx;
+ CLOSE_DISPS(gfxCtx);
+ }
+}
+
+void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, GameState* state) {
+ s32 pad[2];
+ u32 ulx = 30;
+ u32 lrx = 290;
+ SpeedMeterAllocEntry entry;
+ TwoHeadArena* tha;
+ s32 y;
+ TwoHeadGfxArena* thga;
+ u32 zeldaFreeMax;
+ u32 zeldaFree;
+ u32 zeldaAlloc;
+ s32 sysFreeMax;
+ s32 sysFree;
+ s32 sysAlloc;
+
+ y = 212;
+ if (R_ENABLE_ARENA_DBG > 2) {
+ if (ZeldaArena_IsInitialized()) {
+ ZeldaArena_GetSizes(&zeldaFreeMax, &zeldaFree, &zeldaAlloc);
+ SpeedMeter_InitAllocEntry(&entry, zeldaFree + zeldaAlloc, zeldaAlloc, GPACK_RGBA5551(0, 0, 255, 1),
+ GPACK_RGBA5551(255, 255, 255, 1), ulx, lrx, y, y + 1);
+ SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
+ y++;
+ y++;
+ }
+ }
+
+ if (R_ENABLE_ARENA_DBG > 1) {
+ SystemArena_GetSizes((u32*)&sysFreeMax, (u32*)&sysFree, (u32*)&sysAlloc);
+ SpeedMeter_InitAllocEntry(&entry, sysFree + sysAlloc - state->tha.size, sysAlloc - state->tha.size,
+ GPACK_RGBA5551(0, 0, 255, 1), GPACK_RGBA5551(255, 128, 128, 1), ulx, lrx, y, y);
+ SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
+ y++;
+ }
+
+ tha = &state->tha;
+ SpeedMeter_InitAllocEntry(&entry, tha->size, tha->size - THA_GetRemaining(tha), GPACK_RGBA5551(0, 0, 255, 1),
+ GPACK_RGBA5551(0, 255, 0, 1), ulx, lrx, y, y);
+ SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
+ y++;
+
+ thga = &gfxCtx->polyOpa;
+ SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetRemaining(thga), GPACK_RGBA5551(0, 0, 255, 1),
+ GPACK_RGBA5551(255, 0, 255, 1), ulx, lrx, y, y);
+ SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
+ y++;
+
+ thga = &gfxCtx->polyXlu;
+ SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetRemaining(thga), GPACK_RGBA5551(0, 0, 255, 1),
+ GPACK_RGBA5551(255, 255, 0, 1), ulx, lrx, y, y);
+ SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
+ y++;
+
+ thga = &gfxCtx->overlay;
+ SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetRemaining(thga), GPACK_RGBA5551(0, 0, 255, 1),
+ GPACK_RGBA5551(255, 0, 0, 1), ulx, lrx, y, y);
+ SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
+ y++;
+}
diff --git a/src/code/sys_matrix.c b/src/code/sys_matrix.c
index 6269add5f..f84dae383 100644
--- a/src/code/sys_matrix.c
+++ b/src/code/sys_matrix.c
@@ -75,7 +75,7 @@ MtxF* sCurrentMatrix; //!< original name: "Matrix_now"
* @remark original name: "new_Matrix"
*/
void Matrix_Init(GameState* gameState) {
- sMatrixStack = THA_AllocTailAlign16(&gameState->heap, MATRIX_STACK_SIZE * sizeof(MtxF));
+ sMatrixStack = THA_AllocTailAlign16(&gameState->tha, MATRIX_STACK_SIZE * sizeof(MtxF));
sCurrentMatrix = sMatrixStack;
}
diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c
index ae871c8a6..2bef40dce 100644
--- a/src/code/z_bgcheck.c
+++ b/src/code/z_bgcheck.c
@@ -140,7 +140,7 @@ void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list) {
}
void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes) {
- list->tbl = (SSNode*)THA_AllocTailAlign(&play->state.heap, numNodes * sizeof(SSNode), -2);
+ list->tbl = (SSNode*)THA_AllocTailAlign(&play->state.tha, numNodes * sizeof(SSNode), -2);
list->maxNodes = numNodes;
list->count = 0;
}
@@ -1580,7 +1580,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader
}
}
colCtx->lookupTbl = THA_AllocTailAlign(
- &play->state.heap,
+ &play->state.tha,
colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1);
if (colCtx->lookupTbl == NULL) {
Fault_AddHungupAndCrash("../z_bgcheck.c", 3955);
@@ -2456,8 +2456,8 @@ void SSNodeList_Init(SSNodeList* this) {
void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys) {
this->max = tblMax;
this->count = 0;
- this->tbl = THA_AllocTailAlign(&play->state.heap, tblMax * sizeof(SSNode), -2);
- this->polyCheckTbl = THA_AllocTailAlign16(&play->state.heap, numPolys * sizeof(u8));
+ this->tbl = THA_AllocTailAlign(&play->state.tha, tblMax * sizeof(SSNode), -2);
+ this->polyCheckTbl = THA_AllocTailAlign16(&play->state.tha, numPolys * sizeof(u8));
if (this->polyCheckTbl == NULL) {
sprintf(D_801ED950, "this->polygon_check == NULL(game_alloc() MemoryAllocationError.)\n");
@@ -2599,7 +2599,7 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) {
* Allocate dyna.polyList
*/
void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) {
- *polyList = THA_AllocTailAlign(&play->state.heap, numPolys * sizeof(CollisionPoly), -2);
+ *polyList = THA_AllocTailAlign(&play->state.tha, numPolys * sizeof(CollisionPoly), -2);
}
/**
@@ -2613,7 +2613,7 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) {
* Allocate dyna.vtxList
*/
void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) {
- *vtxList = THA_AllocTailAlign(&play->state.heap, numVtx * sizeof(Vec3s), -2);
+ *vtxList = THA_AllocTailAlign(&play->state.tha, numVtx * sizeof(Vec3s), -2);
}
/**
@@ -2628,7 +2628,7 @@ void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList) {
* Allocate dyna.waterBoxList
*/
void DynaPoly_AllocWaterBoxList(PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) {
- waterBoxList->boxes = THA_AllocTailAlign(&play->state.heap, numWaterBoxes * sizeof(WaterBox), -2);
+ waterBoxList->boxes = THA_AllocTailAlign(&play->state.tha, numWaterBoxes * sizeof(WaterBox), -2);
}
/**
diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c
index 870132a07..08aa845ab 100644
--- a/src/code/z_effect_soft_sprite.c
+++ b/src/code/z_effect_soft_sprite.c
@@ -8,7 +8,7 @@ void EffectSS_Init(PlayState* play, s32 numEntries) {
EffectSs* effectsSs;
EffectSsOverlay* overlay;
- sEffectSsInfo.data_table = (EffectSs*)THA_AllocTailAlign16(&play->state.heap, numEntries * sizeof(EffectSs));
+ sEffectSsInfo.data_table = (EffectSs*)THA_AllocTailAlign16(&play->state.tha, numEntries * sizeof(EffectSs));
sEffectSsInfo.searchIndex = 0;
sEffectSsInfo.size = numEntries;
diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c
index e09492d4e..d0bacdd22 100644
--- a/src/code/z_kaleido_manager.c
+++ b/src/code/z_kaleido_manager.c
@@ -66,7 +66,7 @@ void KaleidoManager_Init(PlayState* play) {
}
}
- sKaleidoAreaPtr = THA_AllocTailAlign16(&play->state.heap, largestSize);
+ sKaleidoAreaPtr = THA_AllocTailAlign16(&play->state.tha, largestSize);
gKaleidoMgrCurOvl = NULL;
Fault_AddAddrConvClient(&sKaleidoMgrFaultAddrConvClient, KaleidoManager_FaultAddrConv, NULL);
}
diff --git a/src/code/z_malloc.c b/src/code/z_malloc.c
index 781f4310e..ac56231cf 100644
--- a/src/code/z_malloc.c
+++ b/src/code/z_malloc.c
@@ -40,7 +40,7 @@ void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc)
__osGetSizes(&sZeldaArena, outMaxFree, outFree, outAlloc);
}
-s32 ZeldaArena_Check() {
+s32 ZeldaArena_Check(void) {
return __osCheckArena(&sZeldaArena);
}
@@ -48,10 +48,10 @@ void ZeldaArena_Init(void* start, size_t size) {
__osMallocInit(&sZeldaArena, start, size);
}
-void ZeldaArena_Cleanup() {
+void ZeldaArena_Cleanup(void) {
__osMallocCleanup(&sZeldaArena);
}
-u8 ZeldaArena_IsInitialized() {
+u8 ZeldaArena_IsInitialized(void) {
return __osMallocIsInitalized(&sZeldaArena);
}
diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c
index c087fe059..f04562e03 100644
--- a/src/code/z_map_exp.c
+++ b/src/code/z_map_exp.c
@@ -181,7 +181,7 @@ void Map_Init(PlayState* play) {
func_80105C40(play->roomCtx.curRoom.num);
interfaceCtx->unk_278 = -1;
interfaceCtx->dungeonOrBossAreaMapIndex = -1;
- interfaceCtx->mapSegment = THA_AllocTailAlign16(&play->state.heap, 0x1000);
+ interfaceCtx->mapSegment = THA_AllocTailAlign16(&play->state.tha, 0x1000);
if (func_8010A2AC(play)) {
gSaveContext.mapIndex = func_8010A238(play);
return;
diff --git a/src/code/z_message.c b/src/code/z_message.c
index a922f237b..42a0e301f 100644
--- a/src/code/z_message.c
+++ b/src/code/z_message.c
@@ -597,7 +597,7 @@ void Message_Init(PlayState* play) {
msgCtx->ocarinaAction = msgCtx->textUnskippable = 0;
msgCtx->textColorAlpha = 0xFF;
View_Init(&msgCtx->view, play->state.gfxCtx);
- msgCtx->textboxSegment = THA_AllocTailAlign16(&play->state.heap, 0x13C00);
+ msgCtx->textboxSegment = THA_AllocTailAlign16(&play->state.tha, 0x13C00);
font = &play->msgCtx.font;
Font_LoadOrderedFont(&play->msgCtx.font);
font->unk_11D88 = 0;
diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c
index 2c4106e05..4fcd31c8b 100644
--- a/src/code/z_parameter.c
+++ b/src/code/z_parameter.c
@@ -7115,16 +7115,16 @@ void Interface_Init(PlayState* play) {
interfaceCtx->healthTimer = 200;
parameterStaticSize = SEGMENT_ROM_SIZE(parameter_static);
- interfaceCtx->parameterSegment = THA_AllocTailAlign16(&play->state.heap, parameterStaticSize);
+ interfaceCtx->parameterSegment = THA_AllocTailAlign16(&play->state.tha, parameterStaticSize);
DmaMgr_SendRequest0(interfaceCtx->parameterSegment, SEGMENT_ROM_START(parameter_static), parameterStaticSize);
- interfaceCtx->doActionSegment = THA_AllocTailAlign16(&play->state.heap, 0xC90);
+ interfaceCtx->doActionSegment = THA_AllocTailAlign16(&play->state.tha, 0xC90);
DmaMgr_SendRequest0(interfaceCtx->doActionSegment, SEGMENT_ROM_START(do_action_static), 0x300);
DmaMgr_SendRequest0(interfaceCtx->doActionSegment + 0x300, SEGMENT_ROM_START(do_action_static) + 0x480, 0x180);
Interface_NewDay(play, CURRENT_DAY);
- interfaceCtx->iconItemSegment = THA_AllocTailAlign16(&play->state.heap, 0x4000);
+ interfaceCtx->iconItemSegment = THA_AllocTailAlign16(&play->state.tha, 0x4000);
if (CUR_FORM_EQUIP(EQUIP_SLOT_B) < ITEM_F0) {
Interface_LoadItemIconImpl(play, EQUIP_SLOT_B);
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 44efbfbfb..41b921125 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -1562,7 +1562,7 @@ void Play_GetFloorSurface(PlayState* this, MtxF* mtx, Vec3f* pos) {
void* Play_LoadFile(PlayState* this, RomFile* entry) {
size_t size = entry->vromEnd - entry->vromStart;
- void* allocp = THA_AllocTailAlign16(&this->state.heap, size);
+ void* allocp = THA_AllocTailAlign16(&this->state.tha, size);
DmaMgr_SendRequest0(allocp, entry->vromStart, size);
@@ -2324,9 +2324,9 @@ void Play_Init(GameState* thisx) {
D_801F6D4C->envColor.b = 0;
D_801F6D4C->envColor.a = 0;
CutsceneFlags_UnsetAll(this);
- THA_GetRemaining(&this->state.heap);
- zAllocSize = THA_GetRemaining(&this->state.heap);
- zAlloc = (uintptr_t)THA_AllocTailAlign16(&this->state.heap, zAllocSize);
+ THA_GetRemaining(&this->state.tha);
+ zAllocSize = THA_GetRemaining(&this->state.tha);
+ zAlloc = (uintptr_t)THA_AllocTailAlign16(&this->state.tha, zAllocSize);
ZeldaArena_Init(((zAlloc + 8) & ~0xF), (zAllocSize - ((zAlloc + 8) & ~0xF)) + zAlloc); //! @bug: Incorrect ALIGN16s
Actor_InitContext(this, &this->actorCtx, this->linkActorEntry);
diff --git a/src/code/z_room.c b/src/code/z_room.c
index b8de6caec..d06739d87 100644
--- a/src/code/z_room.c
+++ b/src/code/z_room.c
@@ -516,7 +516,7 @@ size_t Room_AllocateAndLoad(PlayState* play, RoomContext* roomCtx) {
}
}
- roomCtx->roomMemPages[0] = THA_AllocTailAlign16(&play->state.heap, maxRoomSize);
+ roomCtx->roomMemPages[0] = THA_AllocTailAlign16(&play->state.tha, maxRoomSize);
if (roomCtx->roomMemPages[0] == NULL) {
_dbg_hungup("../z_room.c", 1078);
}
diff --git a/src/code/z_scene.c b/src/code/z_scene.c
index 529458f83..811853f07 100644
--- a/src/code/z_scene.c
+++ b/src/code/z_scene.c
@@ -48,7 +48,7 @@ void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) {
for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { objectCtx->status[i].id = 0; }
// clang-format on
- objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocTailAlign16(&gameState->heap, spaceSize);
+ objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocTailAlign16(&gameState->tha, spaceSize);
objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize);
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP);
@@ -357,7 +357,7 @@ void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) {
size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
if (size != 0) {
- play->roomCtx.unk74 = THA_AllocTailAlign16(&play->state.heap, size);
+ play->roomCtx.unk74 = THA_AllocTailAlign16(&play->state.tha, size);
DmaMgr_SendRequest0(play->roomCtx.unk74, vromStart, size);
}
}
diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c
index 198dac4e9..8d382e5db 100644
--- a/src/code/z_sram_NES.c
+++ b/src/code/z_sram_NES.c
@@ -1866,7 +1866,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) {
void Sram_Alloc(GameState* gameState, SramContext* sramCtx) {
if (gSaveContext.flashSaveAvailable) {
- sramCtx->saveBuf = THA_AllocTailAlign16(&gameState->heap, SAVE_BUFFER_SIZE);
+ sramCtx->saveBuf = THA_AllocTailAlign16(&gameState->tha, SAVE_BUFFER_SIZE);
sramCtx->status = 0;
}
}
diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c
index dd0785d94..605dff84c 100644
--- a/src/code/z_vr_box.c
+++ b/src/code/z_vr_box.c
@@ -294,15 +294,15 @@ void Skybox_Init(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId) {
Skybox_Setup(gameState, skyboxCtx, skyboxId);
if (skyboxId != SKYBOX_NONE) {
- skyboxCtx->dListBuf = THA_AllocTailAlign16(&gameState->heap, 0x3840);
+ skyboxCtx->dListBuf = THA_AllocTailAlign16(&gameState->tha, 0x3840);
if (skyboxId == SKYBOX_CUTSCENE_MAP) {
// Allocate enough space for the vertices for a 6 sided skybox (cube)
- skyboxCtx->roomVtx = THA_AllocTailAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6);
+ skyboxCtx->roomVtx = THA_AllocTailAlign16(&gameState->tha, sizeof(Vtx) * 32 * 6);
func_80143148(skyboxCtx, 6);
} else {
// Allocate enough space for the vertices for a 5 sided skybox (bottom is missing)
- skyboxCtx->roomVtx = THA_AllocTailAlign16(&gameState->heap, sizeof(Vtx) * 32 * 5);
+ skyboxCtx->roomVtx = THA_AllocTailAlign16(&gameState->tha, sizeof(Vtx) * 32 * 5);
func_80143148(skyboxCtx, 5);
}
}