From 4c40183da4fb930ab9e8561edebf49732ba36504 Mon Sep 17 00:00:00 2001 From: mzxrules Date: Tue, 1 Oct 2024 14:05:02 -0400 Subject: [PATCH] implement Open/Close using macros --- include/gfxalloc.h | 28 ++++++++++++++-- src/code/flg_set.c | 15 ++++----- src/code/game.c | 32 ++++++++----------- src/code/gfxalloc.c | 23 +++++++------ src/code/z_debug.c | 15 ++++----- src/code/z_demo.c | 14 +++----- src/code/z_kankyo.c | 14 +++----- src/code/z_message.c | 22 +++++-------- src/code/z_play.c | 19 +++++------ src/overlays/actors/ovl_En_Mag/z_en_mag.c | 15 +++------ .../misc/ovl_kaleido_scope/z_kaleido_debug.c | 15 +++------ .../misc/ovl_kaleido_scope/z_kaleido_scope.c | 15 ++++----- 12 files changed, 106 insertions(+), 121 deletions(-) diff --git a/include/gfxalloc.h b/include/gfxalloc.h index 158a2a9f58..692d2bf3b1 100644 --- a/include/gfxalloc.h +++ b/include/gfxalloc.h @@ -2,9 +2,33 @@ #define GFXALLOC_H #include "ultra64.h" +#include "gfx.h" -Gfx* Gfx_Open(Gfx* gfx); -Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); +Gfx* Gfx_Open(Gfx* gfxDisp); +Gfx* Gfx_Close(Gfx* gfxDisp, Gfx* gfxAllocDisp); void* Gfx_Alloc(Gfx** gfxP, u32 size); +/** + * Creates a new temporary graphics display list pointer, using the memory reserved by POLY_OPA_DISP + * POLY_OPA_DISP cannot be written to until GFX_ALLOC_CLOSE is called. + * + * @param gfxAllocDisp is the new temporary graphics display list pointer. + * @param tempGfx is an intermediate Gfx* variable that should not be touched. + * @param disp is the top level display list that is being given more memory. + */ +#define GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, disp) \ + gfxAllocDisp = Gfx_Open(tempGfx = POLY_OPA_DISP); \ + gSPDisplayList(disp++, gfxAllocDisp) + +/** + * Closes the graphics display list created by GFX_ALLOC_OPEN. + * + * @param gfxAllocDisp is the graphics display list pointer that was created with GFX_ALLOC_OPEN + * @param tempGfx is the same Gfx* variable that was passed into GFX_ALLOC_OPEN + */ +#define GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx) \ + gSPEndDisplayList(gfxAllocDisp++); \ + Gfx_Close(tempGfx, gfxAllocDisp); \ + POLY_OPA_DISP = gfxAllocDisp + #endif diff --git a/src/code/flg_set.c b/src/code/flg_set.c index d160f3008b..6dc96e6e71 100644 --- a/src/code/flg_set.c +++ b/src/code/flg_set.c @@ -68,8 +68,8 @@ void FlagSet_Update(PlayState* play) { GraphicsContext* gfxCtx = play->state.gfxCtx; Input* input = &play->state.input[0]; - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; OPEN_DISPS(gfxCtx, "../flg_set.c", 131); @@ -77,11 +77,10 @@ void FlagSet_Update(PlayState* play) { GfxPrint printer; s32 pad; - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); GfxPrint_Init(&printer); - GfxPrint_Open(&printer, tempGfxDisp); + GfxPrint_Open(&printer, gfxAllocDisp); GfxPrint_SetColor(&printer, 250, 50, 50, 255); GfxPrint_SetPos(&printer, 4, 13); GfxPrint_Printf(&printer, entries[entryIdx].name); @@ -166,12 +165,10 @@ void FlagSet_Update(PlayState* play) { timer--; } - tempGfxDisp = GfxPrint_Close(&printer); + gfxAllocDisp = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); } if (CHECK_BTN_ALL(input->press.button, BTN_L)) { diff --git a/src/code/game.c b/src/code/game.c index f6ffff5eb3..b6bb800f3a 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -164,22 +164,21 @@ void GameState_DrawInputDisplay(u16 input, Gfx** gfxP) { #endif void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; OPEN_DISPS(gfxCtx, "../game.c", 746); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); if (R_ENABLE_FB_FILTER == 1) { - GameState_SetFBFilter(&tempGfxDisp); + GameState_SetFBFilter(&gfxAllocDisp); } #if OOT_DEBUG sLastButtonPressed = gameState->input[0].press.button | gameState->input[0].cur.button; if (R_DISABLE_INPUT_DISPLAY == 0) { - GameState_DrawInputDisplay(sLastButtonPressed, &tempGfxDisp); + GameState_DrawInputDisplay(sLastButtonPressed, &gfxAllocDisp); } if (R_ENABLE_AUDIO_DBG & 1) { @@ -187,9 +186,9 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { GfxPrint printer; GfxPrint_Init(&printer); - GfxPrint_Open(&printer, tempGfxDisp); + GfxPrint_Open(&printer, gfxAllocDisp); AudioDebug_Draw(&printer); - tempGfxDisp = GfxPrint_Close(&printer); + gfxAllocDisp = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } #endif @@ -206,9 +205,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) { R_ENABLE_ARENA_DBG = 0; } - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(gfxCtx, "../game.c", 800); @@ -237,23 +234,20 @@ void GameState_SetFrameBuffer(GraphicsContext* gfxCtx) { } void func_800C49F4(GraphicsContext* gfxCtx) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; OPEN_DISPS(gfxCtx, "../game.c", 846); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); #if PLATFORM_N64 if (D_80121212 != 0) { - func_801C6EA0(&tempGfxDisp); + func_801C6EA0(&gfxAllocDisp); } #endif - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(gfxCtx, "../game.c", 865); } diff --git a/src/code/gfxalloc.c b/src/code/gfxalloc.c index e9273d8abf..48b20865a9 100644 --- a/src/code/gfxalloc.c +++ b/src/code/gfxalloc.c @@ -1,12 +1,14 @@ -#include "global.h" +#include "ultra64.h" +#include "gfxalloc.h" /** * Creates a new temporary graphics display list pointer, using the memory reserved by gfxDisp * * @param gfxDisp is the display list yielding memory. It cannot be written to until Gfx_Close is called. - * @returns a new graphics display list pointer. + * @return a new graphics display list pointer. * - * @note This is used to give WORK_DISP more memory to write instructions without increasing the WORK_DISP buffer size. + * @note This is used to take memory allocated to a larger display buffer and use it for a smaller display buffer. + * For example, space in POLY_OPA_DISP can be reserved for WORK_DISP and OVERLAY_DISP task data. */ Gfx* Gfx_Open(Gfx* gfxDisp) { // reserve space for a gSPBranchList command when Gfx_Close is called @@ -18,11 +20,13 @@ Gfx* Gfx_Open(Gfx* gfxDisp) { * * @param gfxDisp is the display list yielding memory. * @param gfx is the graphics display list pointer that was created with Gfx_Open - * @returns gfxDisp's new position + * @return gfxDisp's new position. + * + * @note gfxDisp must be updated after the call with the return value of this function to complete the operation. */ -Gfx* Gfx_Close(Gfx* gfxDisp, Gfx* gfx) { - gSPBranchList(gfxDisp, gfx); - return gfx; +Gfx* Gfx_Close(Gfx* gfxDisp, Gfx* gfxAllocDisp) { + gSPBranchList(gfxDisp, gfxAllocDisp); + return gfxAllocDisp; } /** @@ -30,17 +34,16 @@ Gfx* Gfx_Close(Gfx* gfxDisp, Gfx* gfx) { * * @param gfxP is a pointer to a graphics display list pointer * @param size is the number of bytes to reserve - * @returns start pointer to the allocated memory + * @return the start pointer to the allocated memory */ void* Gfx_Alloc(Gfx** gfxP, u32 size) { u8* ptr; Gfx* dst; size = ALIGN8(size); - ptr = (u8*)(*gfxP + 1); - dst = (Gfx*)(ptr + size); + gSPBranchList(*gfxP, dst); *gfxP = dst; diff --git a/src/code/z_debug.c b/src/code/z_debug.c index 536f4dd837..44cbc8c9af 100644 --- a/src/code/z_debug.c +++ b/src/code/z_debug.c @@ -281,17 +281,16 @@ void Regs_DrawEditor(GfxPrint* printer) { * Draws the Reg Editor and Debug Camera text on screen */ void Debug_DrawText(GraphicsContext* gfxCtx) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; GfxPrint printer; s32 pad; OPEN_DISPS(gfxCtx, "../z_debug.c", 628); GfxPrint_Init(&printer); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); - GfxPrint_Open(&printer, tempGfxDisp); + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + GfxPrint_Open(&printer, gfxAllocDisp); if ((OREG(0) == 1) || (OREG(0) == 8)) { DebugCamera_DrawScreenText(&printer); @@ -305,10 +304,8 @@ void Debug_DrawText(GraphicsContext* gfxCtx) { sDebugCamTextEntryCount = 0; - tempGfxDisp = GfxPrint_Close(&printer); - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + gfxAllocDisp = GfxPrint_Close(&printer); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(gfxCtx, "../z_debug.c", 664); diff --git a/src/code/z_demo.c b/src/code/z_demo.c index cada27694b..d925427e34 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -2217,18 +2217,14 @@ void CutsceneHandler_RunScript(PlayState* play, CutsceneContext* csCtx) { if (gSaveContext.save.cutsceneIndex >= 0xFFF0) { #if OOT_DEBUG if (BREG(0) != 0) { - Gfx* displayList; - Gfx* prevDisplayList; + Gfx* gfxAllocDisp; + Gfx* tempGfx; OPEN_DISPS(play->state.gfxCtx, "../z_demo.c", 4101); - prevDisplayList = POLY_OPA_DISP; - displayList = Gfx_Open(POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, displayList); - Cutscene_DrawDebugInfo(play, &displayList, csCtx); - gSPEndDisplayList(displayList++); - Gfx_Close(prevDisplayList, displayList); - POLY_OPA_DISP = displayList; + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + Cutscene_DrawDebugInfo(play, &gfxAllocDisp, csCtx); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(play->state.gfxCtx, "../z_demo.c", 4108); } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index cc04636e34..7372c37e52 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -981,18 +981,14 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex #if OOT_DEBUG if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1682); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); - Environment_PrintDebugInfo(play, &tempGfxDisp); - - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + Environment_PrintDebugInfo(play, &gfxAllocDisp); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690); } diff --git a/src/code/z_message.c b/src/code/z_message.c index 10343234c7..669ea1a03c 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -3973,8 +3973,8 @@ void Message_DrawDebugText(PlayState* play, Gfx** p) { #endif void Message_Draw(PlayState* play) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; #if OOT_VERSION < GC_US s32 pad; #endif @@ -3988,21 +3988,15 @@ void Message_Draw(PlayState* play) { watchVar = gSaveContext.save.info.scarecrowLongSongSet; Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx); if (BREG(0) != 0 && play->msgCtx.textId != 0) { - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); - Message_DrawDebugText(play, &tempGfxDisp); - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + Message_DrawDebugText(play, &gfxAllocDisp); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); } #endif - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); - Message_DrawMain(play, &tempGfxDisp); - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + Message_DrawMain(play, &gfxAllocDisp); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3582); } diff --git a/src/code/z_play.c b/src/code/z_play.c index 7def3f9b64..1362920cea 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -1159,11 +1159,10 @@ void Play_Draw(PlayState* this) { gSPSegment(POLY_OPA_DISP++, 0x01, this->billboardMtx); if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_COVER_ELEMENTS) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); if ((this->transitionMode == TRANS_MODE_INSTANCE_RUNNING) || (this->transitionMode == TRANS_MODE_INSTANCE_WAIT) || (this->transitionCtx.transitionType >= 56)) { @@ -1174,11 +1173,11 @@ void Play_Draw(PlayState* this) { SET_FULLSCREEN_VIEWPORT(&view); - View_ApplyTo(&view, VIEW_ALL, &tempGfxDisp); - this->transitionCtx.draw(&this->transitionCtx.instanceData, &tempGfxDisp); + View_ApplyTo(&view, VIEW_ALL, &gfxAllocDisp); + this->transitionCtx.draw(&this->transitionCtx.instanceData, &gfxAllocDisp); } - TransitionFade_Draw(&this->transitionFadeFlash, &tempGfxDisp); + TransitionFade_Draw(&this->transitionFadeFlash, &gfxAllocDisp); #if PLATFORM_N64 if (gVisMonoColor.a != 0) @@ -1187,12 +1186,10 @@ void Play_Draw(PlayState* this) { #endif { gPlayVisMono.vis.primColor.rgba = gVisMonoColor.rgba; - VisMono_Draw(&gPlayVisMono, &tempGfxDisp); + VisMono_Draw(&gPlayVisMono, &gfxAllocDisp); } - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); } if (gTransitionTileState == TRANS_TILE_READY) { diff --git a/src/overlays/actors/ovl_En_Mag/z_en_mag.c b/src/overlays/actors/ovl_En_Mag/z_en_mag.c index afd57b2fb3..7713843402 100644 --- a/src/overlays/actors/ovl_En_Mag/z_en_mag.c +++ b/src/overlays/actors/ovl_En_Mag/z_en_mag.c @@ -803,19 +803,14 @@ void EnMag_DrawInner(Actor* thisx, PlayState* play, Gfx** gfxP) { void EnMag_Draw(Actor* thisx, PlayState* play) { s32 pad; - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; OPEN_DISPS(play->state.gfxCtx, "../z_en_mag.c", 1151); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); - - EnMag_DrawInner(thisx, play, &tempGfxDisp); - - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + EnMag_DrawInner(thisx, play, &gfxAllocDisp); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); CLOSE_DISPS(play->state.gfxCtx, "../z_en_mag.c", 1161); } diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c index 02d40a4c43..728ebb7e66 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_debug.c @@ -98,8 +98,8 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { static s32 heldDBtnTimer = 0; PauseContext* pauseCtx = &play->pauseCtx; Input* input = &play->state.input[0]; - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; s16 spD8[4]; s16 slot; s16 i; @@ -123,14 +123,9 @@ void KaleidoScope_DrawDebugEditor(PlayState* play) { gDPSetCombineLERP(POLY_OPA_DISP++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(OVERLAY_DISP++, tempGfxDisp); - - KaleidoScope_DrawDebugEditorText(&tempGfxDisp); - - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, OVERLAY_DISP); + KaleidoScope_DrawDebugEditorText(&gfxAllocDisp); + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 0, 0, 255); diff --git a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c index 3afb6e8168..6c38cede75 100644 --- a/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c +++ b/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c @@ -907,24 +907,21 @@ static PreRender sPlayerPreRender; static void* sPreRenderCvg; void KaleidoScope_SetupPlayerPreRender(PlayState* play) { - Gfx* tempGfxDisp; - Gfx* lockedGfxDisp; + Gfx* gfxAllocDisp; + Gfx* tempGfx; void* fbuf; fbuf = play->state.gfxCtx->curFrameBuffer; OPEN_DISPS(play->state.gfxCtx, "../z_kaleido_scope_PAL.c", 496); - tempGfxDisp = Gfx_Open(lockedGfxDisp = POLY_OPA_DISP); - gSPDisplayList(WORK_DISP++, tempGfxDisp); + GFX_ALLOC_OPEN(gfxAllocDisp, tempGfx, WORK_DISP); PreRender_SetValues(&sPlayerPreRender, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT, fbuf, NULL); - PreRender_SaveFramebuffer(&sPlayerPreRender, &tempGfxDisp); - PreRender_DrawCoverage(&sPlayerPreRender, &tempGfxDisp); + PreRender_SaveFramebuffer(&sPlayerPreRender, &gfxAllocDisp); + PreRender_DrawCoverage(&sPlayerPreRender, &gfxAllocDisp); - gSPEndDisplayList(tempGfxDisp++); - Gfx_Close(lockedGfxDisp, tempGfxDisp); - POLY_OPA_DISP = tempGfxDisp; + GFX_ALLOC_CLOSE(gfxAllocDisp, tempGfx); R_GRAPH_TASKSET00_FLAGS |= 1;