diff options
| author | cadmic <cadmic24@gmail.com> | 2024-01-09 04:59:03 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-09 07:59:03 -0500 |
| commit | cd917b0cb8c20e457d43805ee27d2597daed63e3 (patch) | |
| tree | 6506a87bb08252072ca10e6993f64f2b475fca09 /src/code/z_actor.c | |
| parent | e146d7bc2642633f8b09357c115014a3dfca59da (diff) | |
Create debug macros for common functions (#1597)
* Create debug macros for common functions
* Revert NDEBUG change
* MALLOCR -> MALLOC_R
* DEBUG -> OOT_DEBUG
* Use the same name for debug and non-debug matrix functions
* Fix file/line argument order
* Revert g[s]DPNoOp[Tag]
* Use SystemArena_MallocDebug directly in GameAlloc_MallocDebug
* MTXF_TO_MTX -> MATRIX_TO_MTX
Diffstat (limited to 'src/code/z_actor.c')
| -rw-r--r-- | src/code/z_actor.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index ccd3e20cd..f2cd50edc 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -54,7 +54,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dlist, temp2 = (1.0f - (temp1 * (1.0f / 350))) * actor->shape.shadowScale; Matrix_Scale(actor->scale.x * temp2, 1.0f, actor->scale.z * temp2, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 1588), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 1588), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); @@ -94,7 +94,7 @@ void ActorShadow_DrawFoot(PlayState* play, Light* light, MtxF* arg2, s32 arg3, f Matrix_RotateY(sp58, MTXMODE_APPLY); Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 1687), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 1687), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 1693); @@ -377,7 +377,7 @@ void func_8002C124(TargetContext* targetCtx, PlayState* play) { Matrix_RotateZ(M_PI / 2, MTXMODE_APPLY); Matrix_Push(); Matrix_Translate(entry->unk_0C, entry->unk_0C, 0.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 2116), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 2116), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); Matrix_Pop(); @@ -404,8 +404,7 @@ void func_8002C124(TargetContext* targetCtx, PlayState* play) { Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, naviColor->inner.r, naviColor->inner.g, naviColor->inner.b, 255); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 2153), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 2153), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); } @@ -679,7 +678,7 @@ void TitleCard_InitPlaceName(PlayState* play, TitleCardContext* titleCtx, void* u32 size = loadedScene->titleFile.vromEnd - loadedScene->titleFile.vromStart; if ((size != 0) && (size <= 0x3000)) { - DmaMgr_RequestSyncDebug(texture, loadedScene->titleFile.vromStart, size, "../z_actor.c", 2765); + DMA_REQUEST_SYNC(texture, loadedScene->titleFile.vromStart, size, "../z_actor.c", 2765); } titleCtx->texture = texture; @@ -1363,11 +1362,11 @@ Gfx* func_8002E830(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContext* LookAt* lookAt; f32 correctedEyeX; - lookAt = Graph_Alloc(gfxCtx, sizeof(LookAt)); + lookAt = GRAPH_ALLOC(gfxCtx, sizeof(LookAt)); correctedEyeX = (eye->x == object->x) && (eye->z == object->z) ? eye->x + 0.001f : eye->x; - *hilite = Graph_Alloc(gfxCtx, sizeof(Hilite)); + *hilite = GRAPH_ALLOC(gfxCtx, sizeof(Hilite)); if (R_HREG_MODE == HREG_MODE_PRINT_HILITE_INFO) { osSyncPrintf("z_actor.c 3529 eye=[%f(%f) %f %f] object=[%f %f %f] light_direction=[%f %f %f]\n", correctedEyeX, @@ -1426,7 +1425,7 @@ void func_8002EBCC(Actor* actor, PlayState* play, s32 flag) { hilite = func_8002EABC(&actor->world.pos, &play->view.eye, &lightDir, play->state.gfxCtx); if (flag != 0) { - displayList = Graph_Alloc(play->state.gfxCtx, 2 * sizeof(Gfx)); + displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 4384); @@ -1452,7 +1451,7 @@ void func_8002ED80(Actor* actor, PlayState* play, s32 flag) { hilite = func_8002EB44(&actor->world.pos, &play->view.eye, &lightDir, play->state.gfxCtx); if (flag != 0) { - displayList = Graph_Alloc(play->state.gfxCtx, 2 * sizeof(Gfx)); + displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 4429); @@ -2034,14 +2033,14 @@ void Actor_DrawFaroresWindPointer(PlayState* play) { gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); Matrix_RotateZ(BINANG_TO_RAD_ALT2((play->gameplayFrames * 1500) & 0xFFFF), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 5458), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 5458), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); Matrix_Pop(); Matrix_RotateZ(BINANG_TO_RAD_ALT2(~((play->gameplayFrames * 1200) & 0xFFFF)), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 5463), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 5463), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } @@ -2689,7 +2688,7 @@ void func_80031C3C(ActorContext* actorCtx, PlayState* play) { } if (actorCtx->absoluteSpace != NULL) { - ZeldaArena_FreeDebug(actorCtx->absoluteSpace, "../z_actor.c", 6731); + ZELDA_ARENA_FREE(actorCtx->absoluteSpace, "../z_actor.c", 6731); actorCtx->absoluteSpace = NULL; } @@ -2775,7 +2774,7 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { if (HREG(20) != 0) { osSyncPrintf("オーバーレイ解放します\n"); // "Overlay deallocated" } - ZeldaArena_FreeDebug(actorOverlay->loadedRamAddr, "../z_actor.c", 6834); + ZELDA_ARENA_FREE(actorOverlay->loadedRamAddr, "../z_actor.c", 6834); actorOverlay->loadedRamAddr = NULL; } } @@ -2833,8 +2832,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos if (actorCtx->absoluteSpace == NULL) { // "AMF: absolute magic field" - actorCtx->absoluteSpace = - ZeldaArena_MallocRDebug(ACTOROVL_ABSOLUTE_SPACE_SIZE, "AMF:絶対魔法領域", 0); + actorCtx->absoluteSpace = ZELDA_ARENA_MALLOC_R(ACTOROVL_ABSOLUTE_SPACE_SIZE, "AMF:絶対魔法領域", 0); if (HREG(20) != 0) { // "Absolute magic field reservation - %d bytes reserved" osSyncPrintf("絶対魔法領域確保 %d バイト確保\n", ACTOROVL_ABSOLUTE_SPACE_SIZE); @@ -2843,9 +2841,9 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos overlayEntry->loadedRamAddr = actorCtx->absoluteSpace; } else if (overlayEntry->allocType & ACTOROVL_ALLOC_PERSISTENT) { - overlayEntry->loadedRamAddr = ZeldaArena_MallocRDebug(overlaySize, name, 0); + overlayEntry->loadedRamAddr = ZELDA_ARENA_MALLOC_R(overlaySize, name, 0); } else { - overlayEntry->loadedRamAddr = ZeldaArena_MallocDebug(overlaySize, name, 0); + overlayEntry->loadedRamAddr = ZELDA_ARENA_MALLOC(overlaySize, name, 0); } if (overlayEntry->loadedRamAddr == NULL) { @@ -2886,7 +2884,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos return NULL; } - actor = ZeldaArena_MallocDebug(actorInit->instanceSize, name, 1); + actor = ZELDA_ARENA_MALLOC(actorInit->instanceSize, name, 1); if (actor == NULL) { // "Actor class cannot be reserved! %s <size=%d bytes>" @@ -3027,7 +3025,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { newHead = Actor_RemoveFromCategory(play, actorCtx, actor); - ZeldaArena_FreeDebug(actor, "../z_actor.c", 7242); + ZELDA_ARENA_FREE(actor, "../z_actor.c", 7242); if (overlayEntry->vramStart == NULL) { if (HREG(20) != 0) { @@ -3205,15 +3203,15 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) { u32 objectSlotsSize; matricesSize = (count + 1) * sizeof(*bodyBreak->matrices); - bodyBreak->matrices = ZeldaArena_MallocDebug(matricesSize, "../z_actor.c", 7540); + bodyBreak->matrices = ZELDA_ARENA_MALLOC(matricesSize, "../z_actor.c", 7540); if (bodyBreak->matrices != NULL) { dListsSize = (count + 1) * sizeof(*bodyBreak->dLists); - bodyBreak->dLists = ZeldaArena_MallocDebug(dListsSize, "../z_actor.c", 7543); + bodyBreak->dLists = ZELDA_ARENA_MALLOC(dListsSize, "../z_actor.c", 7543); if (bodyBreak->dLists != NULL) { objectSlotsSize = (count + 1) * sizeof(*bodyBreak->objectSlots); - bodyBreak->objectSlots = ZeldaArena_MallocDebug(objectSlotsSize, "../z_actor.c", 7546); + bodyBreak->objectSlots = ZELDA_ARENA_MALLOC(objectSlotsSize, "../z_actor.c", 7546); if (bodyBreak->objectSlots != NULL) { Lib_MemSet((u8*)bodyBreak->matrices, matricesSize, 0); @@ -3226,15 +3224,15 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) { } if (bodyBreak->matrices != NULL) { - ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7558); + ZELDA_ARENA_FREE(bodyBreak->matrices, "../z_actor.c", 7558); } if (bodyBreak->dLists != NULL) { - ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7561); + ZELDA_ARENA_FREE(bodyBreak->dLists, "../z_actor.c", 7561); } if (bodyBreak->objectSlots != NULL) { - ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7564); + ZELDA_ARENA_FREE(bodyBreak->objectSlots, "../z_actor.c", 7564); } } @@ -3301,9 +3299,9 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s1 bodyBreak->val = BODYBREAK_STATUS_FINISHED; - ZeldaArena_FreeDebug(bodyBreak->matrices, "../z_actor.c", 7678); - ZeldaArena_FreeDebug(bodyBreak->dLists, "../z_actor.c", 7679); - ZeldaArena_FreeDebug(bodyBreak->objectSlots, "../z_actor.c", 7680); + ZELDA_ARENA_FREE(bodyBreak->matrices, "../z_actor.c", 7678); + ZELDA_ARENA_FREE(bodyBreak->dLists, "../z_actor.c", 7679); + ZELDA_ARENA_FREE(bodyBreak->objectSlots, "../z_actor.c", 7680); return true; } @@ -3640,7 +3638,7 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 8149), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 8149), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8155); @@ -3728,8 +3726,7 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 8299), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 8299), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); if (i % 2) { @@ -3744,7 +3741,7 @@ void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { Matrix_Put(&baseMtxF); Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 8314), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_actor.c", 8314), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8319); @@ -4065,7 +4062,7 @@ void Npc_TrackPoint(Actor* actor, NpcInteractInfo* interactInfo, s16 presetIndex Gfx* func_80034B28(GraphicsContext* gfxCtx) { Gfx* displayList; - displayList = Graph_Alloc(gfxCtx, sizeof(Gfx)); + displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); gSPEndDisplayList(displayList); return displayList; @@ -4075,7 +4072,7 @@ Gfx* func_80034B54(GraphicsContext* gfxCtx) { Gfx* displayListHead; Gfx* displayList; - displayList = displayListHead = Graph_Alloc(gfxCtx, 2 * sizeof(Gfx)); + displayList = displayListHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); gDPSetRenderMode(displayListHead++, G_RM_FOG_SHADE_A, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | |
