1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-27 07:07:09 +00:00

Cleanup?: Use gotos in z_play for large else blocks (#1486)

* remove else when using `goto Play_Draw_DrawOverlayElements`

* Add `goto Play_Draw_skip`, use on prerender save

* format
This commit is contained in:
Dragorn421 2023-08-13 16:35:38 +02:00 committed by GitHub
parent 63606af10d
commit b8c1440d1e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -332,7 +332,7 @@ void Play_Init(GameState* thisx) {
gSaveContext.sceneLayer == 6) {
osSyncPrintf("エンディングはじまるよー\n"); // "The ending starts"
((void (*)(void))0x81000000)();
osSyncPrintf("出戻り?\n"); // "Return?"
osSyncPrintf("出戻り?\n"); // "Return?"
}
Cutscene_HandleEntranceTriggers(this);
@ -1118,169 +1118,171 @@ void Play_Draw(PlayState* this) {
TransitionTile_Draw(&sTransitionTile, &sp88);
POLY_OPA_DISP = sp88;
goto Play_Draw_DrawOverlayElements;
} else {
PreRender_SetValues(&this->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer);
}
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) {
// Wait for the previous frame's display list to be processed,
// so that `pauseBgPreRender.fbufSave` and `pauseBgPreRender.cvgSave` are filled with the appropriate
// content and can be used by `PreRender_ApplyFilters` below.
Sched_FlushTaskQueue();
PreRender_SetValues(&this->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer);
PreRender_ApplyFilters(&this->pauseBgPreRender);
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) {
// Wait for the previous frame's display list to be processed,
// so that `pauseBgPreRender.fbufSave` and `pauseBgPreRender.cvgSave` are filled with the appropriate
// content and can be used by `PreRender_ApplyFilters` below.
Sched_FlushTaskQueue();
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_READY;
} else if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_MAX) {
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF;
}
PreRender_ApplyFilters(&this->pauseBgPreRender);
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) {
Gfx* gfxP = POLY_OPA_DISP;
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_READY;
} else if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_MAX) {
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF;
}
PreRender_RestoreFramebuffer(&this->pauseBgPreRender, &gfxP);
POLY_OPA_DISP = gfxP;
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) {
Gfx* gfxP = POLY_OPA_DISP;
goto Play_Draw_DrawOverlayElements;
} else {
s32 roomDrawFlags;
PreRender_RestoreFramebuffer(&this->pauseBgPreRender, &gfxP);
POLY_OPA_DISP = gfxP;
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) {
if (this->skyboxId && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) {
if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) {
Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx);
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend,
this->view.eye.x, this->view.eye.y, this->view.eye.z);
} else if (this->skyboxCtx.drawType == SKYBOX_DRAW_128) {
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y,
this->view.eye.z);
}
}
}
goto Play_Draw_DrawOverlayElements;
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SUN_AND_MOON)) {
if (!this->envCtx.sunMoonDisabled) {
Environment_DrawSunAndMoon(this);
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SKYBOX_FILTERS)) {
Environment_DrawSkyboxFilters(this);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTNING)) {
Environment_UpdateLightningStrike(this);
Environment_DrawLightning(this, 0);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTS)) {
sp228 = LightContext_NewLights(&this->lightCtx, gfxCtx);
Lights_BindAll(sp228, this->lightCtx.listHead, NULL);
Lights_Draw(sp228, gfxCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) {
if (VREG(94) == 0) {
if (R_HREG_MODE != HREG_MODE_PLAY) {
roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU;
} else {
roomDrawFlags = R_PLAY_DRAW_ROOM_FLAGS;
}
Scene_Draw(this);
Room_Draw(this, &this->roomCtx.curRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU));
Room_Draw(this, &this->roomCtx.prevRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU));
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) {
if ((this->skyboxCtx.drawType != SKYBOX_DRAW_128) &&
(GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) {
Vec3f quakeOffset;
Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this));
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x,
this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z);
}
}
if (this->envCtx.precipitation[PRECIP_RAIN_CUR] != 0) {
Environment_DrawRain(this, &this->view, gfxCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) {
Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, FILL_SCREEN_OPA);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_ACTORS) {
func_800315AC(this, &this->actorCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_LENS_FLARES) {
if (!this->envCtx.sunMoonDisabled) {
sp21C.x = this->view.eye.x + this->envCtx.sunPos.x;
sp21C.y = this->view.eye.y + this->envCtx.sunPos.y;
sp21C.z = this->view.eye.z + this->envCtx.sunPos.z;
Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp21C, 0);
}
Environment_DrawCustomLensFlare(this);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SCREEN_FILLS) {
if (MREG(64) != 0) {
Environment_FillScreen(gfxCtx, MREG(65), MREG(66), MREG(67), MREG(68),
FILL_SCREEN_OPA | FILL_SCREEN_XLU);
}
switch (this->envCtx.fillScreen) {
case 1:
Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0],
this->envCtx.screenFillColor[1], this->envCtx.screenFillColor[2],
this->envCtx.screenFillColor[3], FILL_SCREEN_OPA | FILL_SCREEN_XLU);
break;
default:
break;
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SANDSTORM) {
if (this->envCtx.sandstormState != SANDSTORM_OFF) {
Environment_DrawSandstorm(this, this->envCtx.sandstormState);
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_DEBUG_OBJECTS) {
DebugDisplay_DrawObjects(this);
}
if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) ||
(gTransitionTileState == TRANS_TILE_SETUP)) {
Gfx* gfxP = OVERLAY_DISP;
// Copy the frame buffer contents at this point in the display list to the zbuffer
// The zbuffer must then stay untouched until unpausing
this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer;
this->pauseBgPreRender.fbufSave = (u16*)gZBuffer;
PreRender_SaveFramebuffer(&this->pauseBgPreRender, &gfxP);
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) {
this->pauseBgPreRender.cvgSave = (u8*)gfxCtx->curFrameBuffer;
PreRender_DrawCoverage(&this->pauseBgPreRender, &gfxP);
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_PROCESS;
} else {
gTransitionTileState = TRANS_TILE_PROCESS;
}
OVERLAY_DISP = gfxP;
this->unk_121C7 = 2;
R_GRAPH_TASKSET00_FLAGS |= 1;
} else {
Play_Draw_DrawOverlayElements:
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) {
Play_DrawOverlayElements(this);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) {
if (this->skyboxId && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) {
if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) {
Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx);
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend, this->view.eye.x,
this->view.eye.y, this->view.eye.z);
} else if (this->skyboxCtx.drawType == SKYBOX_DRAW_128) {
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y,
this->view.eye.z);
}
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SUN_AND_MOON)) {
if (!this->envCtx.sunMoonDisabled) {
Environment_DrawSunAndMoon(this);
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SKYBOX_FILTERS)) {
Environment_DrawSkyboxFilters(this);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTNING)) {
Environment_UpdateLightningStrike(this);
Environment_DrawLightning(this, 0);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTS)) {
sp228 = LightContext_NewLights(&this->lightCtx, gfxCtx);
Lights_BindAll(sp228, this->lightCtx.listHead, NULL);
Lights_Draw(sp228, gfxCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) {
if (VREG(94) == 0) {
s32 roomDrawFlags;
if (R_HREG_MODE != HREG_MODE_PLAY) {
roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU;
} else {
roomDrawFlags = R_PLAY_DRAW_ROOM_FLAGS;
}
Scene_Draw(this);
Room_Draw(this, &this->roomCtx.curRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU));
Room_Draw(this, &this->roomCtx.prevRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU));
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) {
if ((this->skyboxCtx.drawType != SKYBOX_DRAW_128) &&
(GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) {
Vec3f quakeOffset;
Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this));
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x,
this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z);
}
}
if (this->envCtx.precipitation[PRECIP_RAIN_CUR] != 0) {
Environment_DrawRain(this, &this->view, gfxCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) {
Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, FILL_SCREEN_OPA);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_ACTORS) {
func_800315AC(this, &this->actorCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_LENS_FLARES) {
if (!this->envCtx.sunMoonDisabled) {
sp21C.x = this->view.eye.x + this->envCtx.sunPos.x;
sp21C.y = this->view.eye.y + this->envCtx.sunPos.y;
sp21C.z = this->view.eye.z + this->envCtx.sunPos.z;
Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp21C, 0);
}
Environment_DrawCustomLensFlare(this);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SCREEN_FILLS) {
if (MREG(64) != 0) {
Environment_FillScreen(gfxCtx, MREG(65), MREG(66), MREG(67), MREG(68),
FILL_SCREEN_OPA | FILL_SCREEN_XLU);
}
switch (this->envCtx.fillScreen) {
case 1:
Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], this->envCtx.screenFillColor[1],
this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3],
FILL_SCREEN_OPA | FILL_SCREEN_XLU);
break;
default:
break;
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SANDSTORM) {
if (this->envCtx.sandstormState != SANDSTORM_OFF) {
Environment_DrawSandstorm(this, this->envCtx.sandstormState);
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_DEBUG_OBJECTS) {
DebugDisplay_DrawObjects(this);
}
if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) || (gTransitionTileState == TRANS_TILE_SETUP)) {
Gfx* gfxP = OVERLAY_DISP;
// Copy the frame buffer contents at this point in the display list to the zbuffer
// The zbuffer must then stay untouched until unpausing
this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer;
this->pauseBgPreRender.fbufSave = (u16*)gZBuffer;
PreRender_SaveFramebuffer(&this->pauseBgPreRender, &gfxP);
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) {
this->pauseBgPreRender.cvgSave = (u8*)gfxCtx->curFrameBuffer;
PreRender_DrawCoverage(&this->pauseBgPreRender, &gfxP);
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_PROCESS;
} else {
gTransitionTileState = TRANS_TILE_PROCESS;
}
OVERLAY_DISP = gfxP;
this->unk_121C7 = 2;
R_GRAPH_TASKSET00_FLAGS |= 1;
goto Play_Draw_skip;
}
Play_Draw_DrawOverlayElements:
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) {
Play_DrawOverlayElements(this);
}
}
Play_Draw_skip:
if (this->view.unk_124 != 0) {
Camera_Update(GET_ACTIVE_CAM(this));
View_UpdateViewingMatrix(&this->view);