diff --git a/include/macros.h b/include/macros.h index ad963153f3..c93a489ed9 100644 --- a/include/macros.h +++ b/include/macros.h @@ -69,6 +69,11 @@ #define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask)) +#define ALIGN8(val) (((val) + 7) & ~7) +#define ALIGN16(val) (((val) + 0xF) & ~0xF) +#define ALIGN64(val) (((val) + 0x3F) & ~0x3F) +#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) + extern GraphicsContext* __gfxCtx; #define WORK_DISP __gfxCtx->work.p @@ -106,7 +111,7 @@ extern GraphicsContext* __gfxCtx; #define VTX_T(x, y, z, s, t, cr, cg, cb, a) \ { { x, y, z }, 0, { s, t }, { cr, cg, cb, a }, } -#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - (size)))) +#define GRAPH_ALLOC(gfxCtx, size) ((void*)((gfxCtx)->polyOpa.d = (Gfx*)((u8*)(gfxCtx)->polyOpa.d - ALIGN16(size)))) // Custom gbi macro #define gDPSetTileCustom(pkt, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ @@ -123,10 +128,6 @@ extern GraphicsContext* __gfxCtx; } \ (void)0 -#define ALIGN8(val) (((val) + 7) & ~7) -#define ALIGN16(val) (((val) + 0xF) & ~0xF) -#define ALIGN64(val) (((val) + 0x3F) & ~0x3F) -#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define SQ(x) ((x) * (x)) #define ABS(x) ((x) >= 0 ? (x) : -(x)) diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 05a8165947..ced233c54c 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1721,16 +1721,14 @@ void func_800B8050(Actor* actor, PlayState* play, s32 flag) { Hilite* hilite = func_800BCBF4(&actor->world.pos, play); if (flag != 0) { - Gfx* displayListHead; - Gfx* displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); - - displayListHead = displayList; + Gfx* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; OPEN_DISPS(play->state.gfxCtx); - gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); - gSPEndDisplayList(displayListHead); - gSPSegment(POLY_OPA_DISP++, 0x07, displayList); + gDPSetHilite1Tile(gfx++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(gfx++); + gSPSegment(POLY_OPA_DISP++, 0x07, gfxHead); CLOSE_DISPS(play->state.gfxCtx); } @@ -1740,16 +1738,14 @@ void func_800B8118(Actor* actor, PlayState* play, s32 flag) { Hilite* hilite = func_800BCC68(&actor->world.pos, play); if (flag != 0) { - Gfx* displayListHead; - Gfx* displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); - - displayListHead = displayList; + Gfx* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; OPEN_DISPS(play->state.gfxCtx); - gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); - gSPEndDisplayList(displayListHead); - gSPSegment(POLY_XLU_DISP++, 0x07, displayList); + gDPSetHilite1Tile(gfx++, 1, hilite, 0x10, 0x10); + gSPEndDisplayList(gfx++); + gSPSegment(POLY_XLU_DISP++, 0x07, gfxHead); CLOSE_DISPS(play->state.gfxCtx); } @@ -4190,19 +4186,16 @@ Gfx D_801AEFA0[] = { }; Gfx* func_800BD9A0(GraphicsContext* gfxCtx) { - Gfx* displayListHead; - Gfx* displayList; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - displayListHead = displayList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + gDPSetRenderMode( + gfx++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | G_RM_FOG_SHADE_A, + AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | + GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); + gSPEndDisplayList(gfx++); - gDPSetRenderMode(displayListHead++, - AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | - G_RM_FOG_SHADE_A, - AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | - GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); - gSPEndDisplayList(displayListHead++); - - return displayList; + return gfxHead; } // unused diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index e7c9dd0be3..f98b8636eb 100644 --- a/src/code/z_debug_display.c +++ b/src/code/z_debug_display.c @@ -148,9 +148,9 @@ Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path) { s32 segment; // of path ending at the current point, 1-indexed if (path != NULL) { - // count - 1 segments, 1 gSPVertex and 3 gSP2Triangles for each, plus a gSPEndDisplayList - gfx = GRAPH_ALLOC(gfxCtx, ALIGN16(((path->count - 1) * 4 + 1) * sizeof(Gfx))); - curVtx = GRAPH_ALLOC(gfxCtx, ALIGN16(path->count * 6 * sizeof(Vtx))); + // (count - 1) segments, 1 gSPVertex and 3 gSP2Triangles for each, plus a gSPEndDisplayList + gfx = GRAPH_ALLOC(gfxCtx, ((path->count - 1) * 4 + 1) * sizeof(Gfx)); + curVtx = GRAPH_ALLOC(gfxCtx, path->count * 6 * sizeof(Vtx)); gfxHead = gfx; curBaseVtx = curVtx; @@ -202,7 +202,7 @@ Gfx* DebugDisplay_PathDisplayList(GraphicsContext* gfxCtx, Path* path) { gSPEndDisplayList(gfx++); } else { // No path, trivial displaylist - gfxHead = gfx = GRAPH_ALLOC(gfxCtx, ALIGN16(sizeof(Gfx))); + gfx = gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); gSPEndDisplayList(gfx++); } return gfxHead; diff --git a/src/code/z_eff_blure.c b/src/code/z_eff_blure.c index 6ab70f1efa..5f02219698 100644 --- a/src/code/z_eff_blure.c +++ b/src/code/z_eff_blure.c @@ -408,7 +408,7 @@ void EffectBlure_DrawElemNoInterpolation(EffectBlure* this, EffectBlureElement* Math_Vec3s_ToVec3f(&sp6C, &this->elements[0].p2); - vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[4])); + vtx = GRAPH_ALLOC(gfxCtx, 4 * sizeof(Vtx)); if (vtx == NULL) { } else { vtx[0].v = baseVtx; @@ -559,7 +559,7 @@ void EffectBlure_DrawElemHermiteInterpolation(EffectBlure* this, EffectBlureElem Math_Vec3f_Scale(&sp174, 0.5f); Math_Vec3f_Scale(&sp168, 0.5f); - vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[16])); + vtx = GRAPH_ALLOC(gfxCtx, 16 * sizeof(Vtx)); if (vtx == NULL) { } else { Math_Vec3f_Diff(&sp1CC, &sp138, &sp158); @@ -849,7 +849,7 @@ void EffectBlure_DrawSimple(EffectBlure* this2, GraphicsContext* gfxCtx) { if (this->numElements >= 2) { vtxCount = this->numElements * 4; - vtx = GRAPH_ALLOC(gfxCtx, ALIGN16(vtxCount * sizeof(Vtx))); + vtx = GRAPH_ALLOC(gfxCtx, vtxCount * sizeof(Vtx)); if (vtx == NULL) { return; } @@ -941,7 +941,7 @@ void EffectBlure_Draw(void* thisx, GraphicsContext* gfxCtx) { func_8012C560(gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - vtx = GRAPH_ALLOC(gfxCtx, sizeof(Vtx[32])); + vtx = GRAPH_ALLOC(gfxCtx, 32 * sizeof(Vtx)); if (vtx == NULL) { } else { j = 0; diff --git a/src/code/z_eff_spark.c b/src/code/z_eff_spark.c index fd92516dfc..fdd25a6b40 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -120,7 +120,7 @@ s32 EffectSpark_Update(void* thisx) { } void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { - Vtx* vertices; + Vtx* vtx; EffectSpark* this = (EffectSpark*)thisx; PlayState* play = Effect_GetPlayState(); s32 i; @@ -162,8 +162,8 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { gSPSetGeometryMode(POLY_XLU_DISP++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH); gDPPipeSync(POLY_XLU_DISP++); - vertices = GRAPH_ALLOC(gfxCtx, ALIGN16(this->numElements * sizeof(Vtx[4]))); - if (vertices == NULL) { + vtx = GRAPH_ALLOC(gfxCtx, this->numElements * (4 * sizeof(Vtx))); + if (vtx == NULL) { goto end; } @@ -202,49 +202,49 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { SkinMatrix_MtxFMtxFMult(&spEC, &play->billboardMtxF, &sp6C); SkinMatrix_MtxFMtxFMult(&sp6C, &spAC, &sp12C); - vertices[j].v.ob[0] = -32; - vertices[j].v.ob[1] = -32; - vertices[j].v.ob[2] = 0; - vertices[j].v.cn[0] = sp1D3; - vertices[j].v.cn[1] = sp1D2; - vertices[j].v.cn[2] = sp1D1; - vertices[j].v.cn[3] = sp1D0; - vertices[j].v.tc[0] = 0; - vertices[j].v.tc[1] = 1024; - vertices[j].v.flag = 0; + vtx[j].v.ob[0] = -32; + vtx[j].v.ob[1] = -32; + vtx[j].v.ob[2] = 0; + vtx[j].v.cn[0] = sp1D3; + vtx[j].v.cn[1] = sp1D2; + vtx[j].v.cn[2] = sp1D1; + vtx[j].v.cn[3] = sp1D0; + vtx[j].v.tc[0] = 0; + vtx[j].v.tc[1] = 1024; + vtx[j].v.flag = 0; - vertices[j + 1].v.ob[0] = 32; - vertices[j + 1].v.ob[1] = 32; - vertices[j + 1].v.ob[2] = 0; - vertices[j + 1].v.cn[0] = sp1CF; - vertices[j + 1].v.cn[1] = sp1CE; - vertices[j + 1].v.cn[2] = sp1CD; - vertices[j + 1].v.cn[3] = sp1CC; - vertices[j + 1].v.tc[0] = 1024; - vertices[j + 1].v.tc[1] = 0; - vertices[j + 1].v.flag = 0; + vtx[j + 1].v.ob[0] = 32; + vtx[j + 1].v.ob[1] = 32; + vtx[j + 1].v.ob[2] = 0; + vtx[j + 1].v.cn[0] = sp1CF; + vtx[j + 1].v.cn[1] = sp1CE; + vtx[j + 1].v.cn[2] = sp1CD; + vtx[j + 1].v.cn[3] = sp1CC; + vtx[j + 1].v.tc[0] = 1024; + vtx[j + 1].v.tc[1] = 0; + vtx[j + 1].v.flag = 0; - vertices[j + 2].v.ob[0] = -32; - vertices[j + 2].v.ob[1] = 32; - vertices[j + 2].v.ob[2] = 0; - vertices[j + 2].v.cn[0] = sp1CB; - vertices[j + 2].v.cn[1] = sp1CA; - vertices[j + 2].v.cn[2] = sp1C9; - vertices[j + 2].v.cn[3] = sp1C8; - vertices[j + 2].v.tc[0] = 0; - vertices[j + 2].v.tc[1] = 0; - vertices[j + 2].v.flag = 0; + vtx[j + 2].v.ob[0] = -32; + vtx[j + 2].v.ob[1] = 32; + vtx[j + 2].v.ob[2] = 0; + vtx[j + 2].v.cn[0] = sp1CB; + vtx[j + 2].v.cn[1] = sp1CA; + vtx[j + 2].v.cn[2] = sp1C9; + vtx[j + 2].v.cn[3] = sp1C8; + vtx[j + 2].v.tc[0] = 0; + vtx[j + 2].v.tc[1] = 0; + vtx[j + 2].v.flag = 0; - vertices[j + 3].v.ob[0] = 32; - vertices[j + 3].v.ob[1] = -32; - vertices[j + 3].v.ob[2] = 0; - vertices[j + 3].v.cn[0] = sp1C7; - vertices[j + 3].v.cn[1] = sp1C6; - vertices[j + 3].v.cn[2] = sp1C5; - vertices[j + 3].v.cn[3] = sp1C4; - vertices[j + 3].v.tc[0] = 1024; - vertices[j + 3].v.tc[1] = 1024; - vertices[j + 3].v.flag = 0; + vtx[j + 3].v.ob[0] = 32; + vtx[j + 3].v.ob[1] = -32; + vtx[j + 3].v.ob[2] = 0; + vtx[j + 3].v.cn[0] = sp1C7; + vtx[j + 3].v.cn[1] = sp1C6; + vtx[j + 3].v.cn[2] = sp1C5; + vtx[j + 3].v.cn[3] = sp1C4; + vtx[j + 3].v.tc[0] = 1024; + vtx[j + 3].v.tc[1] = 1024; + vtx[j + 3].v.flag = 0; j += 4; @@ -254,7 +254,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { } gSPMatrix(POLY_XLU_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPVertex(POLY_XLU_DISP++, &vertices[4 * i], 4, 0); + gSPVertex(POLY_XLU_DISP++, &vtx[4 * i], 4, 0); gSP2Triangles(POLY_XLU_DISP++, 2, 0, 3, 0, 2, 3, 1, 0); } diff --git a/src/code/z_eff_tire_mark.c b/src/code/z_eff_tire_mark.c index 532e8e2fb0..75b0ecd030 100644 --- a/src/code/z_eff_tire_mark.c +++ b/src/code/z_eff_tire_mark.c @@ -226,7 +226,7 @@ void EffectTireMark_Draw(void* thisx, GraphicsContext* gfxCtx) { OPEN_DISPS(gfxCtx); if (this->numElements >= 2) { - vtx = GRAPH_ALLOC(gfxCtx, ALIGN16(this->numElements * sizeof(Vtx[2]))); + vtx = GRAPH_ALLOC(gfxCtx, this->numElements * (2 * sizeof(Vtx))); if (vtx != NULL) { gSPMatrix(POLY_OPA_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 21753040f7..f773e6ff23 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -2322,7 +2322,7 @@ void func_80128388(struct_801F58B0 arg0[], struct_80128388_arg1 arg1[], s32 arg2 void Player_DrawGreatFairysMask(PlayState* play, Player* player) { s32 pad; - Mtx* sp90 = GRAPH_ALLOC(play->state.gfxCtx, 6 * sizeof(Mtx)); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, 6 * sizeof(Mtx)); Vec3f sp84; Vec3f sp78; Vec3f* iter = D_801C0C0C; @@ -2332,7 +2332,7 @@ void Player_DrawGreatFairysMask(PlayState* play, Player* player) { OPEN_DISPS(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x0B, sp90); + gSPSegment(POLY_OPA_DISP++, 0x0B, mtx); Matrix_MultVec3f(&D_801C0C00, &D_801C0C54[1].unk_08); Math_Vec3f_Lerp(&player->bodyPartsPos[7], &player->bodyPartsPos[0], 0.2f, &D_801C0C54[2].unk_08); @@ -2346,7 +2346,7 @@ void Player_DrawGreatFairysMask(PlayState* play, Player* player) { Matrix_Push(); Matrix_Translate(iter->x, iter->y, iter->z, MTXMODE_APPLY); - func_80128388(D_801F58B0[i], D_801C0C54, 3, &sp90); + func_80128388(D_801F58B0[i], D_801C0C54, 3, &mtx); Matrix_Pop(); iter++; iter2++; diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c index 057424e3c6..39f09f1d49 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1108,13 +1108,13 @@ void func_8012CA38(GraphicsContext* gfxCtx) { } Gfx* Gfx_BranchTexScroll(Gfx** gfxp, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); + Gfx* gfx = Graph_DlistAlloc(gfxp, 3 * sizeof(Gfx)); - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); - gSPEndDisplayList(displayList + 2); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); + gSPEndDisplayList(&gfx[2]); - return displayList; + return gfx; } void func_8012CB04(Gfx** gfxp, u32 x, u32 y) { @@ -1126,101 +1126,71 @@ Gfx* func_8012CB28(GraphicsContext* gfxCtx, u32 x, u32 y) { } Gfx* Gfx_TexScroll(GraphicsContext* gfxCtx, u32 x, u32 y, s32 width, s32 height) { - Gfx* displayList; - - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 4; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 3 * sizeof(Gfx)); x %= 2048; y %= 2048; - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); - gSPEndDisplayList(displayList + 2); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], 0, x, y, (x + ((width - 1) << 2)), (y + ((height - 1) << 2))); + gSPEndDisplayList(&gfx[2]); - return displayList; + return gfx; } Gfx* Gfx_TwoTexScroll(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2) { - Gfx* displayList; - - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 6; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 5 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; x2 %= 2048; y2 %= 2048; - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); - gDPTileSync(displayList + 2); - gDPSetTileSize(displayList + 3, tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); - gSPEndDisplayList(displayList + 4); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); + gDPTileSync(&gfx[2]); + gDPSetTileSize(&gfx[3], tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); + gSPEndDisplayList(&gfx[4]); - return displayList; + return gfx; } Gfx* Gfx_TwoTexScrollEnvColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, u32 x2, u32 y2, s32 width2, s32 height2, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList; - - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 6; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 6 * sizeof(Gfx)); x1 %= 2048; y1 %= 2048; x2 %= 2048; y2 %= 2048; - gDPTileSync(displayList); - gDPSetTileSize(displayList + 1, tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); - gDPTileSync(displayList + 2); - gDPSetTileSize(displayList + 3, tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); - gDPSetEnvColor(displayList + 4, r, g, b, a); - gSPEndDisplayList(displayList + 5); + gDPTileSync(&gfx[0]); + gDPSetTileSize(&gfx[1], tile1, x1, y1, (x1 + ((width1 - 1) << 2)), (y1 + ((height1 - 1) << 2))); + gDPTileSync(&gfx[2]); + gDPSetTileSize(&gfx[3], tile2, x2, y2, (x2 + ((width2 - 1) << 2)), (y2 + ((height2 - 1) << 2))); + gDPSetEnvColor(&gfx[4], r, g, b, a); + gSPEndDisplayList(&gfx[5]); - return displayList; + return gfx; } Gfx* Gfx_EnvColor(GraphicsContext* gfxCtx, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList; + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 2; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + gDPSetEnvColor(&gfx[0], r, g, b, a); + gSPEndDisplayList(&gfx[1]); - gDPSetEnvColor(displayList, r, g, b, a); - gSPEndDisplayList(displayList + 1); - - return displayList; + return gfx; } Gfx* Gfx_PrimColor(GraphicsContext* gfxCtx, s32 lodfrac, s32 r, s32 g, s32 b, s32 a) { - Gfx* displayList; + Gfx* gfx = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); - { - Gfx* _g = (Gfx*)gfxCtx->polyOpa.d - 2; - displayList = _g; - gfxCtx->polyOpa.d = _g; - } + gDPSetPrimColor(&gfx[0], 0, lodfrac, r, g, b, a); + gSPEndDisplayList(&gfx[1]); - gDPSetPrimColor(displayList, 0, lodfrac, r, g, b, a); - gSPEndDisplayList(displayList + 1); - - return displayList; + return gfx; } void func_8012CF0C(GraphicsContext* gfxCtx, s32 clearFb, s32 clearZb, u8 r, u8 g, u8 b) { diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c index 4de83bcaad..67f503e589 100644 --- a/src/code/z_scene_proc.c +++ b/src/code/z_scene_proc.c @@ -113,23 +113,23 @@ void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params) { * Generates a displaylist that sets the prim and env color, and stores it in the provided segment ID. */ void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) { - Gfx* colorDList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 3 * sizeof(Gfx)); OPEN_DISPS(play->state.gfxCtx); // clang-format off - if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, colorDList); } - if (sMatAnimFlags & 2) { gSPSegment(POLY_XLU_DISP++, segment, colorDList); } + if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, gfx); } + if (sMatAnimFlags & 2) { gSPSegment(POLY_XLU_DISP++, segment, gfx); } // clang-format on - gDPSetPrimColor(colorDList++, 0, primColorResult->lodFrac, primColorResult->r, primColorResult->g, - primColorResult->b, (u8)(primColorResult->a * sMatAnimAlphaRatio)); + gDPSetPrimColor(gfx++, 0, primColorResult->lodFrac, primColorResult->r, primColorResult->g, primColorResult->b, + (u8)(primColorResult->a * sMatAnimAlphaRatio)); if (envColor != NULL) { - gDPSetEnvColor(colorDList++, envColor->r, envColor->g, envColor->b, envColor->a); + gDPSetEnvColor(gfx++, envColor->r, envColor->g, envColor->b, envColor->a); } - gSPEndDisplayList(colorDList++); + gSPEndDisplayList(gfx++); CLOSE_DISPS(play->state.gfxCtx); } @@ -709,8 +709,8 @@ void Scene_DrawConfigGreatBayTemple(PlayState* play) { }; s32 lodFrac; s32 i; - Gfx* dListHead; - Gfx* dList; + Gfx* gfx; + Gfx* gfxHead; if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) && Flags_GetSwitch(play, 0x36)) { @@ -719,16 +719,16 @@ void Scene_DrawConfigGreatBayTemple(PlayState* play) { BgCheck_UnsetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW); } - dList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 18); + gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 18 * sizeof(Gfx)); AnimatedMat_Draw(play, play->sceneMaterialAnims); OPEN_DISPS(play->state.gfxCtx); - for (dListHead = dList, i = 0; i < 9; i++, dListHead += 2) { + for (gfx = gfxHead, i = 0; i < 9; i++, gfx += 2) { lodFrac = 0; - bcopy(greatBayTempleColorSetDL, dListHead, sizeof(greatBayTempleColorSetDL)); + bcopy(greatBayTempleColorSetDL, gfx, sizeof(greatBayTempleColorSetDL)); switch (i) { case 0: @@ -779,11 +779,11 @@ void Scene_DrawConfigGreatBayTemple(PlayState* play) { break; } - gDPSetPrimColor(dListHead, 0, lodFrac, 255, 255, 255, 255); + gDPSetPrimColor(gfx, 0, lodFrac, 255, 255, 255, 255); } - gSPSegment(POLY_OPA_DISP++, 0x06, dList); - gSPSegment(POLY_XLU_DISP++, 0x06, dList); + gSPSegment(POLY_OPA_DISP++, 0x06, gfxHead); + gSPSegment(POLY_XLU_DISP++, 0x06, gfxHead); CLOSE_DISPS(play->state.gfxCtx); } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 088f1469f1..e14956905b 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -200,7 +200,7 @@ void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { return; @@ -418,7 +418,7 @@ void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { return; @@ -560,7 +560,7 @@ void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* joi OPEN_DISPS(play->state.gfxCtx); - mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + mtx = GRAPH_ALLOC(play->state.gfxCtx, dListCount * sizeof(Mtx)); gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); @@ -822,7 +822,7 @@ Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 return NULL; } - mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount)); + mtx = GRAPH_ALLOC(play->state.gfxCtx, dListCount * sizeof(Mtx)); gSPSegment(gfx++, 0x0D, mtx); diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c index efc6774a7e..2924fe3535 100644 --- a/src/code/z_sub_s.c +++ b/src/code/z_sub_s.c @@ -112,7 +112,7 @@ Gfx* SubS_DrawTransformFlex(PlayState* play, void** skeleton, Vec3s* jointTable, Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx))); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { return NULL; diff --git a/src/overlays/actors/ovl_Boss_02/z_boss_02.c b/src/overlays/actors/ovl_Boss_02/z_boss_02.c index 9815ae5a55..ceb9ffae58 100644 --- a/src/overlays/actors/ovl_Boss_02/z_boss_02.c +++ b/src/overlays/actors/ovl_Boss_02/z_boss_02.c @@ -1336,8 +1336,8 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { Boss02* this = THIS; s32 i; s32 idx; - Mtx* mtx; - Mtx* mtxIter; + Mtx* mtxHead = GRAPH_ALLOC(play->state.gfxCtx, 23 * sizeof(Mtx)); + Mtx* mtx = mtxHead; s32 phi_v0; f32 phi_f12; f32 spAC; @@ -1347,8 +1347,6 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { f32 sp9C; f32 sp98; - mtxIter = mtx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 23); - OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); @@ -1359,7 +1357,7 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(gTwinmoldBlueSkinTex)); } - gSPSegment(POLY_OPA_DISP++, 0x0D, mtx); + gSPSegment(POLY_OPA_DISP++, 0x0D, mtxHead); if (!sIsInGiantMode) { sp98 = -500.0f; @@ -1396,7 +1394,7 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { spA4 = 0.0f; spA0 = 0.0f; - for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtxIter++) { + for (i = 0; i < ARRAY_COUNT(D_809DFA9C); i++, mtx++) { if (this->unk_0195 != 0) { phi_v0 = (D_809DF5E4[i + 1] + this->unk_014E) % ARRAY_COUNT(this->unk_01BC); } else { @@ -1415,9 +1413,9 @@ void Boss02_Twinmold_Draw(Actor* thisx, PlayState* play2) { Matrix_Scale(this->actor.scale.x, this->actor.scale.y, this->actor.scale.z, MTXMODE_APPLY); Matrix_RotateYF(M_PI / 2, MTXMODE_APPLY); Matrix_RotateXFApply(-(M_PI / 2)); - Matrix_ToMtx(mtxIter); + Matrix_ToMtx(mtx); - gSPMatrix(POLY_OPA_DISP++, mtxIter, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gSPMatrix(POLY_OPA_DISP++, mtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if ((this->unk_0156 & 1) && (i >= this->unk_0158) && (this->unk_015A >= i)) { POLY_OPA_DISP = Gfx_SetFog(POLY_OPA_DISP, 255, 0, 0, 255, 0x384, 0x44B); diff --git a/src/overlays/actors/ovl_Boss_03/z_boss_03.c b/src/overlays/actors/ovl_Boss_03/z_boss_03.c index a4c58e71dd..980db6ebec 100644 --- a/src/overlays/actors/ovl_Boss_03/z_boss_03.c +++ b/src/overlays/actors/ovl_Boss_03/z_boss_03.c @@ -2593,7 +2593,7 @@ void Boss03_SeaweedDraw(Actor* thisx, PlayState* play) { Boss03* this = THIS; s16 i; // Why 10 Mtxs? This seems to only use the first 6 elements - Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 10); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, 10 * sizeof(Mtx)); OPEN_DISPS(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c index 853d91cb98..60f9e898bb 100644 --- a/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c +++ b/src/overlays/actors/ovl_Demo_Syoten/z_demo_syoten.c @@ -480,16 +480,16 @@ s32 func_80C170F8(PlayState* play, UNK_TYPE arg1, s32 arg2, UNK_TYPE arg3, UNK_T void func_80C173B4(Actor* thisx, PlayState* play) { s32 pad; DemoSyoten* this = THIS; - Mtx* matrix; + Mtx* mtx; AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(&object_syoten_Matanimheader_001298)); - matrix = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_144.unk_18->unk_1)); + mtx = GRAPH_ALLOC(play->state.gfxCtx, this->unk_144.unk_18->unk_1 * sizeof(Mtx)); - if (matrix != NULL) { + if (mtx != NULL) { func_8012C2DC(play->state.gfxCtx); Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); - func_8018450C(play, &this->unk_144, matrix, (void*)func_80C170F8, 0, &this->actor); + func_8018450C(play, &this->unk_144, mtx, (void*)func_80C170F8, 0, &this->actor); } } diff --git a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c index 95aef1835c..43cc626037 100644 --- a/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c +++ b/src/overlays/actors/ovl_Dm_Char00/z_dm_char00.c @@ -912,7 +912,7 @@ void DmChar00_Draw(Actor* thisx, PlayState* play2) { DmChar00* this = THIS; s32 phi_a0; s32 pad; - Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Gfx)); if ((play->csCtx.state == 0) && ((play->sceneId != SCENE_OPENINGDAN) || (gSaveContext.sceneLayer != 0) || (play->roomCtx.curRoom.num != 0) || diff --git a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c index 12165ed899..5c835152df 100644 --- a/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c +++ b/src/overlays/actors/ovl_Dm_Char04/z_dm_char04.c @@ -129,7 +129,7 @@ s32 DmChar04_OverrideLimbDraw(PlayState* play2, s32 limbIndex, Gfx** dList, Vec3 } void DmChar04_Draw(Actor* thisx, PlayState* play) { - Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Gfx)); s32 alpha; s32 pad; DmChar04* this = THIS; diff --git a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c index 00abe6e05a..dc6d8bcef9 100644 --- a/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c +++ b/src/overlays/actors/ovl_Dm_Sa/z_dm_sa.c @@ -83,26 +83,24 @@ void DmSa_TransformLimbDraw(PlayState* play, s32 limbIndex, Actor* thisx) { } Gfx* func_80A2EB58(GraphicsContext* gfxCtx, u32 alpha) { - Gfx* dList; - Gfx* dListHead; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); //! @bug this does not allocate enough for 3 Gfx commands; + Gfx* gfx = gfxHead; - dList = dListHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); //! @bug this does not allocate enough for 3 Gfx commands - gDPSetRenderMode(dListHead++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); - gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); - gSPEndDisplayList(dListHead++); + gDPSetRenderMode(gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_XLU_SURF2); + gDPSetEnvColor(gfx++, 0, 0, 0, alpha); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } Gfx* func_80A2EBB0(GraphicsContext* gfxCtx, u32 alpha) { - Gfx* dList; - Gfx* dListHead; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - dList = dListHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); - gDPSetEnvColor(dListHead++, 0, 0, 0, alpha); - gSPEndDisplayList(dListHead++); + gDPSetEnvColor(gfx++, 0, 0, 0, alpha); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } void DmSa_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c index cad0ec0955..9174fafc00 100644 --- a/src/overlays/actors/ovl_Eff_Change/z_eff_change.c +++ b/src/overlays/actors/ovl_Eff_Change/z_eff_change.c @@ -130,7 +130,7 @@ void EffChange_Draw(Actor* thisx, PlayState* play) { EffChange* this = THIS; AnimatedMat_DrawStepXlu(play, Lib_SegmentedToVirtual(&gameplay_keep_Matanimheader_028FEC), this->step); - mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + mtx = GRAPH_ALLOC(play->state.gfxCtx, this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx)); if (mtx != NULL) { func_8012C2DC(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c index fd5ce0bf6f..0b5ffff54d 100644 --- a/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c +++ b/src/overlays/actors/ovl_En_Bombf/z_en_bombf.c @@ -451,15 +451,15 @@ void EnBombf_Update(Actor* thisx, PlayState* play) { } Gfx* func_808AF86C(GraphicsContext* gfxCtx, PlayState* play) { - Gfx* head = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 6); - Gfx* gfx = head; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 5 * sizeof(Gfx)); + Gfx* gfx = gfxHead; Matrix_ReplaceRotation(&play->billboardMtxF); gSPMatrix(gfx++, Matrix_NewMtx(gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPEndDisplayList(gfx++); - return head; + return gfxHead; } void EnBombf_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Box/z_en_box.c b/src/overlays/actors/ovl_En_Box/z_en_box.c index 2ae1e76c33..f4527957fe 100644 --- a/src/overlays/actors/ovl_En_Box/z_en_box.c +++ b/src/overlays/actors/ovl_En_Box/z_en_box.c @@ -658,32 +658,34 @@ void EnBox_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, } Gfx* EnBox_SetRenderMode1(GraphicsContext* gfxCtx) { - Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - gSPEndDisplayList(dl); - return dl; + gSPEndDisplayList(gfx++); + + return gfxHead; } Gfx* EnBox_SetRenderMode2(GraphicsContext* gfxCtx) { - Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); - Gfx* cur = dl; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; gDPSetRenderMode( - cur++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | G_RM_FOG_SHADE_A, + gfx++, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | G_RM_FOG_SHADE_A, AA_EN | Z_CMP | Z_UPD | IM_RD | CLR_ON_CVG | CVG_DST_WRAP | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA)); - gSPEndDisplayList(cur++); - return dl; + gSPEndDisplayList(gfx++); + return gfxHead; } Gfx* EnBox_SetRenderMode3(GraphicsContext* gfxCtx) { - Gfx* dl = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); - Gfx* cur = dl; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; - gDPSetRenderMode(cur++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); - gSPEndDisplayList(cur++); - return dl; + gDPSetRenderMode(gfx++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2); + gSPEndDisplayList(gfx++); + return gfxHead; } void EnBox_Draw(Actor* thisx, PlayState* play) { 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 6d21e23e56..aa062b46d0 100644 --- a/src/overlays/actors/ovl_En_Elf/z_en_elf.c +++ b/src/overlays/actors/ovl_En_Elf/z_en_elf.c @@ -1579,7 +1579,7 @@ void EnElf_Draw(Actor* thisx, PlayState* play) { (!Cutscene_CheckActorAction(play, 201) || (play->csCtx.actorActions[Cutscene_GetActorActionIndex(play, 201)]->action != 6)) && (!(player->stateFlags1 & PLAYER_STATE1_100000) || (kREG(90) < this->actor.projectedPos.z))) { - Gfx* dListHead = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4); + Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Gfx)); f32 alphaScale; s32 envAlpha; @@ -1592,19 +1592,19 @@ void EnElf_Draw(Actor* thisx, PlayState* play) { alphaScale = (this->disappearTimer < 0) ? (this->disappearTimer * 0.0011666666f) + 1.0f : 1.0f; - gSPSegment(POLY_XLU_DISP++, 0x08, dListHead); + gSPSegment(POLY_XLU_DISP++, 0x08, gfx); - gDPPipeSync(dListHead++); - gDPSetPrimColor(dListHead++, 0, 0x01, (u8)(s8)this->innerColor.r, (u8)(s8)this->innerColor.g, + gDPPipeSync(gfx++); + gDPSetPrimColor(gfx++, 0, 0x01, (u8)(s8)this->innerColor.r, (u8)(s8)this->innerColor.g, (u8)(s8)this->innerColor.b, (u8)(s8)(this->innerColor.a * alphaScale)); if (this->fairyFlags & 4) { - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_CLD_SURF2); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_CLD_SURF2); } else { - gDPSetRenderMode(dListHead++, G_RM_PASS, G_RM_ZB_CLD_SURF2); + gDPSetRenderMode(gfx++, G_RM_PASS, G_RM_ZB_CLD_SURF2); } - gSPEndDisplayList(dListHead); + gSPEndDisplayList(gfx); gDPSetEnvColor(POLY_XLU_DISP++, (u8)(s8)this->outerColor.r, (u8)(s8)this->outerColor.g, (u8)(s8)this->outerColor.b, (u8)(s8)(envAlpha * alphaScale)); diff --git a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c index e2eaefe264..33cf9a64df 100644 --- a/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c +++ b/src/overlays/actors/ovl_En_Fall2/z_en_fall2.c @@ -158,7 +158,7 @@ void EnFall2_Draw(Actor* thisx, PlayState* play) { func_8012C2DC(play->state.gfxCtx); AnimatedMat_DrawXlu(play, Lib_SegmentedToVirtual(object_fall2_Matanimheader_008840)); - mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + mtx = GRAPH_ALLOC(play->state.gfxCtx, this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx)); if (mtx != NULL) { func_8012C2DC(play->state.gfxCtx); diff --git a/src/overlays/actors/ovl_En_Rr/z_en_rr.c b/src/overlays/actors/ovl_En_Rr/z_en_rr.c index 15dd1d1c4f..6c7ac273c0 100644 --- a/src/overlays/actors/ovl_En_Rr/z_en_rr.c +++ b/src/overlays/actors/ovl_En_Rr/z_en_rr.c @@ -874,20 +874,18 @@ void EnRr_Update(Actor* thisx, PlayState* play) { void EnRr_Draw(Actor* thisx, PlayState* play2) { PlayState* play = play2; EnRr* this = THIS; - Mtx* matrix; + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, 4 * sizeof(Mtx)); Vec3f* vecPtr; s32 i; EnRrStruct* ptr; Vec3f spA4; f32 temp_f20; - matrix = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Mtx) * 4); - OPEN_DISPS(play->state.gfxCtx); func_8012C28C(play->state.gfxCtx); - gSPSegment(POLY_OPA_DISP++, 0x0C, matrix); + gSPSegment(POLY_OPA_DISP++, 0x0C, mtx); gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TwoTexScroll(play->state.gfxCtx, 0, (this->unk_1E8 * 0) & 0x7F, (this->unk_1E8 * 0) & 0x3F, 0x20, 0x10, 1, (this->unk_1E8 * 0) & 0x3F, (this->unk_1E8 * -6) & 0x7F, 0x20, 0x10)); @@ -914,7 +912,7 @@ void EnRr_Draw(Actor* thisx, PlayState* play2) { Matrix_RotateZYX(ptr->unk_1A.x, ptr->unk_1A.y, ptr->unk_1A.z, MTXMODE_APPLY); Matrix_Push(); Matrix_Scale(temp_f20, 1.0f, temp_f20, MTXMODE_APPLY); - Matrix_ToMtx(matrix); + Matrix_ToMtx(mtx); if ((i & 1) != 0) { Matrix_RotateYS(0x2000, MTXMODE_APPLY); @@ -925,7 +923,7 @@ void EnRr_Draw(Actor* thisx, PlayState* play2) { Matrix_MultVecX(1842.1053f, vecPtr++); Matrix_MultVecX(-1842.1053f, vecPtr++); Matrix_Pop(); - matrix++; + mtx++; if (i == 3) { Matrix_MultZero(&spA4); } diff --git a/src/overlays/actors/ovl_En_Sda/z_en_sda.c b/src/overlays/actors/ovl_En_Sda/z_en_sda.c index bd453c84c2..5a487d4dd7 100644 --- a/src/overlays/actors/ovl_En_Sda/z_en_sda.c +++ b/src/overlays/actors/ovl_En_Sda/z_en_sda.c @@ -93,7 +93,7 @@ void EnSda_Update(Actor* thisx, PlayState* play) { void EnSda_Draw(Actor* thisx, PlayState* play) { EnSda* this = THIS; Player* player; - u8* shadowTexture = GRAPH_ALLOC(play->state.gfxCtx, 64 * 64); + u8* shadowTex = GRAPH_ALLOC(play->state.gfxCtx, 64 * 64); if (this->actor.params == ENSDA_1) { player = (Player*)this->actor.parent; @@ -102,10 +102,10 @@ void EnSda_Draw(Actor* thisx, PlayState* play) { } player->actor.shape.shadowAlpha = 0; - func_8094702C(this, shadowTexture, player, play); + func_8094702C(this, shadowTex, player, play); if (KREG(0) < 5) { - func_80947668(shadowTexture, player, play); + func_80947668(shadowTex, player, play); } } diff --git a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c index 2a3fb4e32d..f2deae2037 100644 --- a/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c +++ b/src/overlays/actors/ovl_En_Sob1/z_en_sob1.c @@ -1611,13 +1611,12 @@ void EnSob1_BombShopkeeper_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dL } Gfx* EnSob1_EndDList(GraphicsContext* gfxCtx) { - Gfx* dList; - Gfx* dListHead; + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - dList = dListHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); - gSPEndDisplayList(dListHead++); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } void EnSob1_ZoraShopkeeper_Draw(Actor* thisx, PlayState* play) { diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 95fdce4e15..7f0a3e9715 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -250,7 +250,7 @@ s32 EnTest_OverrideKeyframeDraw(PlayState* play, SkeletonInfo* skeletonInfo, s32 void EnTest_Draw(Actor* thisx, PlayState* play) { EnTest* this = THIS; - Mtx* sp28; + Mtx* mtx; s32 sp2C = this->unk_208 - 1; if (sp2C >= 29) { @@ -263,11 +263,11 @@ void EnTest_Draw(Actor* thisx, PlayState* play) { AnimatedMat_DrawStep(play, Lib_SegmentedToVirtual(gameplay_keep_Matanimheader_06B6A0), sp2C); } - sp28 = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx))); + mtx = GRAPH_ALLOC(play->state.gfxCtx, this->skeletonInfo.unk_18->unk_1 * sizeof(Mtx)); - if (sp28 != NULL) { + if (mtx != NULL) { func_8012C2DC(play->state.gfxCtx); - func_8018450C(play, &this->skeletonInfo, sp28, EnTest_OverrideKeyframeDraw, NULL, thisx); + func_8018450C(play, &this->skeletonInfo, mtx, EnTest_OverrideKeyframeDraw, NULL, thisx); func_80863048(play, this->unk_20C); } } diff --git a/src/overlays/actors/ovl_En_Test6/z_en_test6.c b/src/overlays/actors/ovl_En_Test6/z_en_test6.c index 3f91751800..0e171a21dd 100644 --- a/src/overlays/actors/ovl_En_Test6/z_en_test6.c +++ b/src/overlays/actors/ovl_En_Test6/z_en_test6.c @@ -240,8 +240,8 @@ void func_80A90D34(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { void func_80A90FC0(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { s32 pad; - Gfx* gfx = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 2); - Gfx* gfx2 = gfx; + Gfx* gfxHead = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx)); + Gfx* gfx = gfxHead; Hilite* sp70; Vec3f sp64; @@ -253,14 +253,14 @@ void func_80A90FC0(EnTest6* this, PlayState* play, EnTest6Struct* ptr) { OPEN_DISPS(play->state.gfxCtx); - if (gfx != NULL) { + if (gfxHead != NULL) { func_8012C28C(play->state.gfxCtx); gDPSetTileSize(gfx++, 1, sp70->h.x1 & 0xFFFF, sp70->h.y1 & 0xFFFF, (sp70->h.x1 + 60) & 0xFFFF, (sp70->h.y1 + 60) & 0xFFFF); - gSPEndDisplayList(gfx); + gSPEndDisplayList(gfx++); - gSPSegment(POLY_OPA_DISP++, 0x07, gfx2); + gSPSegment(POLY_OPA_DISP++, 0x07, gfxHead); Matrix_Translate(sp64.x, sp64.y, sp64.z, MTXMODE_NEW); Matrix_Scale(ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, ptr->unk_04 * 0.018f, MTXMODE_APPLY); diff --git a/src/overlays/actors/ovl_En_Test7/z_en_test7.c b/src/overlays/actors/ovl_En_Test7/z_en_test7.c index 7dbbaec930..ea671d4ad0 100644 --- a/src/overlays/actors/ovl_En_Test7/z_en_test7.c +++ b/src/overlays/actors/ovl_En_Test7/z_en_test7.c @@ -957,7 +957,7 @@ void EnTest7_Draw(Actor* thisx, PlayState* play) { s32 sp40; if (this->unk_144 & 1) { - Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * this->unk_18CC.unk_18->unk_1)); + Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, this->unk_18CC.unk_18->unk_1 * sizeof(Mtx)); if (mtx != NULL) { func_8018450C(play, &this->unk_18CC, mtx, func_80AF31D0, NULL, &this->actor); diff --git a/src/overlays/actors/ovl_En_Zot/z_en_zot.c b/src/overlays/actors/ovl_En_Zot/z_en_zot.c index f8a9c0bd21..02f726fc53 100644 --- a/src/overlays/actors/ovl_En_Zot/z_en_zot.c +++ b/src/overlays/actors/ovl_En_Zot/z_en_zot.c @@ -1345,11 +1345,12 @@ void EnZot_Update(Actor* thisx, PlayState* play) { } Gfx* func_80B99580(GraphicsContext* gfxCtx) { - Gfx* dList = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - gSPEndDisplayList(dList); + gSPEndDisplayList(gfx++); - return dList; + return gfxHead; } s32 EnZot_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { diff --git a/src/overlays/actors/ovl_En_Zow/z_en_zow.c b/src/overlays/actors/ovl_En_Zow/z_en_zow.c index 2d4bf16059..e1db787df1 100644 --- a/src/overlays/actors/ovl_En_Zow/z_en_zow.c +++ b/src/overlays/actors/ovl_En_Zow/z_en_zow.c @@ -589,11 +589,12 @@ void EnZow_Update(Actor* thisx, PlayState* play) { } Gfx* func_80BDDA7C(GraphicsContext* gfxCtx) { - Gfx* gfx = GRAPH_ALLOC(gfxCtx, sizeof(Gfx) * 2); + Gfx* gfxHead = GRAPH_ALLOC(gfxCtx, sizeof(Gfx)); + Gfx* gfx = gfxHead; - gSPEndDisplayList(gfx); + gSPEndDisplayList(gfx++); - return gfx; + return gfxHead; } Vec3f D_80BDDD4C = { 400.0f, 0.0f, 0.0f };