1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00

z_play retail OK (#1688)

* z_play OK

* cleanup spacing

* PR
This commit is contained in:
engineer124 2024-02-02 09:00:27 +11:00 committed by GitHub
parent 64dd475a3a
commit 1e21f69b37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 64 additions and 64 deletions

View File

@ -137,8 +137,10 @@
#define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \
do { \
(curState)->init = newInit; \
(curState)->size = sizeof(newStruct); \
GameState* state = curState; \
\
(state)->init = newInit; \
(state)->size = sizeof(newStruct); \
} while (0)
#define SET_FULLSCREEN_VIEWPORT(view) \

View File

@ -421,22 +421,14 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
if (gIsCtrlr2Valid && CHECK_BTN_ALL(gameState->input[0].press.button, BTN_Z) &&
CHECK_BTN_ALL(gameState->input[0].cur.button, BTN_L | BTN_R)) {
gSaveContext.gameMode = GAMEMODE_NORMAL;
{
GameState* state = gameState;
SET_NEXT_GAMESTATE(state, MapSelect_Init, MapSelectState);
}
SET_NEXT_GAMESTATE(gameState, MapSelect_Init, MapSelectState);
gameState->running = false;
}
if (gIsCtrlr2Valid && PreNmiBuff_IsResetting(gAppNmiBufferPtr) && !gameState->inPreNMIState) {
// "To reset mode"
PRINTF(VT_COL(YELLOW, BLACK) "PRE-NMIによりリセットモードに移行します\n" VT_RST);
{
GameState* state = gameState;
SET_NEXT_GAMESTATE(state, PreNMI_Init, PreNMIState);
}
SET_NEXT_GAMESTATE(gameState, PreNMI_Init, PreNMIState);
gameState->running = false;
}
#endif

View File

@ -18,12 +18,16 @@ void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn);
// This macro prints the number "1" with a file and line number if R_ENABLE_PLAY_LOGS is enabled.
// For example, it can be used to trace the play state execution at a high level.
#if OOT_DEBUG
#define PLAY_LOG(line) \
do { \
if (R_ENABLE_PLAY_LOGS) { \
LOG_NUM("1", 1, "../z_play.c", line); \
} \
} while (0)
#else
#define PLAY_LOG(line) (void)0
#endif
void Play_RequestViewpointBgCam(PlayState* this) {
Camera_RequestBgCam(GET_ACTIVE_CAM(this), this->viewpoint - 1);
@ -156,7 +160,7 @@ void Play_SetupTransition(PlayState* this, s32 transitionType) {
break;
default:
Fault_AddHungupAndCrash("../z_play.c", 2290);
HUNGUP_AND_CRASH("../z_play.c", 2290);
break;
}
}
@ -175,6 +179,8 @@ void Play_Destroy(GameState* thisx) {
PlayState* this = (PlayState*)thisx;
Player* player = GET_PLAYER(this);
if (1) {}
this->state.gfxCtx->callback = NULL;
this->state.gfxCtx->callbackParam = NULL;
@ -211,7 +217,10 @@ void Play_Destroy(GameState* thisx) {
KaleidoScopeCall_Destroy(this);
KaleidoManager_Destroy();
ZeldaArena_Cleanup();
#if OOT_DEBUG
Fault_RemoveClient(&D_801614B8);
#endif
}
void Play_Init(GameState* thisx) {
@ -233,7 +242,10 @@ void Play_Init(GameState* thisx) {
return;
}
#if OOT_DEBUG
SystemArena_Display();
#endif
GameState_Realloc(&this->state, 0x1D4790);
KaleidoManager_Init(this);
View_Init(&this->view, gfxCtx);
@ -403,7 +415,10 @@ void Play_Init(GameState* thisx) {
// "Zelda Heap"
PRINTF("ゼルダヒープ %08x-%08x\n", zAllocAligned, (u8*)zAllocAligned + zAllocSize - (s32)(zAllocAligned - zAlloc));
#if OOT_DEBUG
Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL);
#endif
Actor_InitContext(this, &this->actorCtx, this->playerEntry);
while (!func_800973FC(this, &this->roomCtx)) {
@ -436,7 +451,7 @@ void Play_Init(GameState* thisx) {
AnimationContext_Update(this, &this->animationCtx);
gSaveContext.respawnFlag = 0;
if (R_USE_DEBUG_CUTSCENE) {
if (OOT_DEBUG && R_USE_DEBUG_CUTSCENE) {
gDebugCutsceneScript = sDebugCutsceneScriptBuf;
PRINTF("\nkawauso_data=[%x]", gDebugCutsceneScript);
@ -447,20 +462,20 @@ void Play_Init(GameState* thisx) {
}
void Play_Update(PlayState* this) {
s32 pad1;
Input* input = this->state.input;
s32 isPaused;
Input* input;
u32 i;
s32 pad2;
input = this->state.input;
s32 pad1;
#if OOT_DEBUG
if ((SREG(1) < 0) || (DREG(0) != 0)) {
SREG(1) = 0;
ZeldaArena_Display();
}
if ((R_HREG_MODE == HREG_MODE_PRINT_OBJECT_TABLE) && (R_PRINT_OBJECT_TABLE_TRIGGER < 0)) {
u32 i;
s32 pad2;
R_PRINT_OBJECT_TABLE_TRIGGER = 0;
PRINTF("object_exchange_rom_address %u\n", gObjectTableSize);
PRINTF("RomStart RomEnd Size\n");
@ -482,6 +497,7 @@ void Play_Update(PlayState* this) {
HREG(82) = 0;
ActorOverlayTable_LogPrint();
}
#endif
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
@ -541,11 +557,15 @@ void Play_Update(PlayState* this) {
}
}
#if OOT_DEBUG
if (!R_TRANS_DBG_ENABLED) {
Play_SetupTransition(this, this->transitionType);
} else {
Play_SetupTransition(this, R_TRANS_DBG_TYPE);
}
#else
Play_SetupTransition(this, this->transitionType);
#endif
if (this->transitionMode >= TRANS_MODE_FILL_WHITE_INIT) {
// non-instance modes break out of this switch
@ -855,6 +875,8 @@ void Play_Update(PlayState* this) {
PLAY_LOG(3555);
AnimationContext_Reset(&this->animationCtx);
if (!OOT_DEBUG) {}
PLAY_LOG(3561);
Object_UpdateEntries(&this->objectCtx);
@ -989,7 +1011,6 @@ skip:
PLAY_LOG(3801);
if (!isPaused || gDebugCamEnabled) {
s32 pad3[5];
s32 i;
this->nextCamId = this->activeCamId;
@ -1058,7 +1079,7 @@ void Play_Draw(PlayState* this) {
Gfx_SetupFrame(gfxCtx, 0, 0, 0);
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_RUN_DRAW) {
if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_RUN_DRAW) {
POLY_OPA_DISP = Play_SetFog(this, POLY_OPA_DISP);
POLY_XLU_DISP = Play_SetFog(this, POLY_XLU_DISP);
@ -1081,7 +1102,7 @@ void Play_Draw(PlayState* this) {
gSPSegment(POLY_OPA_DISP++, 0x01, this->billboardMtx);
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_COVER_ELEMENTS) {
if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_COVER_ELEMENTS) {
Gfx* gfxP;
Gfx* sp1CC = POLY_OPA_DISP;
@ -1145,7 +1166,7 @@ void Play_Draw(PlayState* this) {
goto Play_Draw_DrawOverlayElements;
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) {
if (!OOT_DEBUG || (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);
@ -1158,32 +1179,32 @@ void Play_Draw(PlayState* this) {
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SUN_AND_MOON)) {
if (!OOT_DEBUG || (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)) {
if (!OOT_DEBUG || (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)) {
if (!OOT_DEBUG || (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)) {
if (!OOT_DEBUG || (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 (!OOT_DEBUG || (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) {
if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY)) {
roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU;
} else {
roomDrawFlags = R_PLAY_DRAW_ROOM_FLAGS;
@ -1194,7 +1215,7 @@ void Play_Draw(PlayState* this) {
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) {
if (!OOT_DEBUG || (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;
@ -1209,15 +1230,15 @@ void Play_Draw(PlayState* this) {
Environment_DrawRain(this, &this->view, gfxCtx);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) {
if (!OOT_DEBUG || (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) {
if (!OOT_DEBUG || (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 (!OOT_DEBUG || (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;
@ -1227,7 +1248,7 @@ void Play_Draw(PlayState* this) {
Environment_DrawCustomLensFlare(this);
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SCREEN_FILLS) {
if (!OOT_DEBUG || (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);
@ -1244,13 +1265,13 @@ void Play_Draw(PlayState* this) {
}
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SANDSTORM) {
if (!OOT_DEBUG || (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) {
if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_DEBUG_OBJECTS) {
DebugDisplay_DrawObjects(this);
}
@ -1277,7 +1298,7 @@ void Play_Draw(PlayState* this) {
}
Play_Draw_DrawOverlayElements:
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) {
if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) {
Play_DrawOverlayElements(this);
}
}
@ -1307,7 +1328,7 @@ void Play_Main(GameState* thisx) {
PLAY_LOG(4556);
if ((R_HREG_MODE == HREG_MODE_PLAY) && (R_PLAY_INIT != HREG_MODE_PLAY)) {
if (OOT_DEBUG && (R_HREG_MODE == HREG_MODE_PLAY) && (R_PLAY_INIT != HREG_MODE_PLAY)) {
R_PLAY_RUN_UPDATE = true;
R_PLAY_RUN_DRAW = true;
R_PLAY_DRAW_SKYBOX = true;
@ -1325,7 +1346,7 @@ void Play_Main(GameState* thisx) {
R_PLAY_INIT = HREG_MODE_PLAY;
}
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_RUN_UPDATE) {
if (!OOT_DEBUG || (R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_RUN_UPDATE) {
Play_Update(this);
}
@ -1346,18 +1367,13 @@ f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* pos) {
f32 temp1;
f32 temp2;
f32 temp3;
f32 floorY;
f32 nx;
f32 ny;
f32 nz;
s32 pad[5];
floorY = BgCheck_AnyRaycastDown1(&this->colCtx, &poly, pos);
f32 floorY = BgCheck_AnyRaycastDown1(&this->colCtx, &poly, pos);
if (floorY > BGCHECK_Y_MIN) {
nx = COLPOLY_GET_NORMAL(poly.normal.x);
ny = COLPOLY_GET_NORMAL(poly.normal.y);
nz = COLPOLY_GET_NORMAL(poly.normal.z);
f32 nx = COLPOLY_GET_NORMAL(poly.normal.x);
f32 ny = COLPOLY_GET_NORMAL(poly.normal.y);
f32 nz = COLPOLY_GET_NORMAL(poly.normal.z);
s32 pad[5];
temp1 = sqrtf(1.0f - SQ(nx));

View File

@ -1436,8 +1436,6 @@ void FileSelect_FadeOut(GameState* thisx) {
*/
void FileSelect_LoadGame(GameState* thisx) {
FileSelectState* this = (FileSelectState*)thisx;
u16 swordEquipValue;
s32 pad;
if (this->buttonIndex == FS_BTN_SELECT_FILE_1) {
Audio_PlaySfxGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
@ -1506,6 +1504,7 @@ void FileSelect_LoadGame(GameState* thisx) {
(gSaveContext.save.info.equips.buttonItems[0] != ITEM_SWORD_MASTER) &&
(gSaveContext.save.info.equips.buttonItems[0] != ITEM_SWORD_BIGGORON) &&
(gSaveContext.save.info.equips.buttonItems[0] != ITEM_GIANTS_KNIFE)) {
u16 swordEquipValue;
gSaveContext.save.info.equips.buttonItems[0] = ITEM_NONE;
swordEquipValue =

View File

@ -11,11 +11,7 @@
void MapSelect_LoadTitle(MapSelectState* this) {
this->state.running = false;
{
GameState* state = &this->state;
SET_NEXT_GAMESTATE(state, ConsoleLogo_Init, ConsoleLogoState);
}
SET_NEXT_GAMESTATE(&this->state, ConsoleLogo_Init, ConsoleLogoState);
}
void MapSelect_LoadGame(MapSelectState* this, s32 entranceIndex) {
@ -45,11 +41,7 @@ void MapSelect_LoadGame(MapSelectState* this, s32 entranceIndex) {
gWeatherMode = WEATHER_MODE_CLEAR;
this->state.running = false;
{
GameState* state = &this->state;
SET_NEXT_GAMESTATE(state, Play_Init, PlayState);
}
SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState);
}
// "Translation" (Actual name)

View File

@ -128,7 +128,7 @@ void ConsoleLogo_Main(GameState* thisx) {
ConsoleLogo_Calc(this);
ConsoleLogo_Draw(this);
if (gIsCtrlr2Valid) {
if (OOT_DEBUG && gIsCtrlr2Valid) {
Gfx* gfx = POLY_OPA_DISP;
s32 pad;

View File

@ -2635,7 +2635,6 @@ void KaleidoScope_Update(PlayState* play) {
s16 stepG;
s16 stepB;
s16 stepA;
s32 pad;
if ((R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_READY) &&
(((pauseCtx->state >= PAUSE_STATE_OPENING_1) && (pauseCtx->state <= PAUSE_STATE_SAVE_PROMPT)) ||