1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-03 14:34:32 +00:00

Introduce PLAY_LOG() (#1284)

* play log

* review, try to compromise on comment

* another compromise attempt

* new comment

* remove comma

* fix
This commit is contained in:
fig02 2022-06-21 13:25:09 -04:00 committed by GitHub
parent 5dda2f9ffc
commit e4884e0cb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 63 additions and 151 deletions

View file

@ -47,6 +47,7 @@
#define R_ENV_FOG_NEAR REG(14) #define R_ENV_FOG_NEAR REG(14)
#define R_ENV_TIME_SPEED_OLD REG(15) // Most likely used during development. Unused in the final game. #define R_ENV_TIME_SPEED_OLD REG(15) // Most likely used during development. Unused in the final game.
#define R_RUN_SPEED_LIMIT REG(45) #define R_RUN_SPEED_LIMIT REG(45)
#define R_ENABLE_PLAY_LOGS HREG(63)
#define R_ENABLE_ARENA_DBG SREG(0) #define R_ENABLE_ARENA_DBG SREG(0)
#define R_UPDATE_RATE SREG(30) #define R_UPDATE_RATE SREG(30)
#define R_ENABLE_AUDIO_DBG SREG(36) #define R_ENABLE_AUDIO_DBG SREG(36)

View file

@ -15,6 +15,15 @@ u64 D_801614D0[0xA00];
void Play_SpawnScene(PlayState* this, s32 sceneNum, s32 spawn); void Play_SpawnScene(PlayState* this, s32 sceneNum, 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.
#define PLAY_LOG(line) \
do { \
if (R_ENABLE_PLAY_LOGS) { \
LOG_NUM("1", 1, "../z_play.c", line); \
} \
} while (0)
void Play_ChangeViewpointBgCamIndex(PlayState* this) { void Play_ChangeViewpointBgCamIndex(PlayState* this) {
Camera_ChangeBgCamIndex(GET_ACTIVE_CAM(this), this->viewpoint - 1); Camera_ChangeBgCamIndex(GET_ACTIVE_CAM(this), this->viewpoint - 1);
} }
@ -167,6 +176,7 @@ void Play_Destroy(GameState* thisx) {
this->state.gfxCtx->callback = NULL; this->state.gfxCtx->callback = NULL;
this->state.gfxCtx->callbackParam = 0; this->state.gfxCtx->callbackParam = 0;
SREG(91) = 0; SREG(91) = 0;
R_PAUSE_MENU_MODE = 0; R_PAUSE_MENU_MODE = 0;
@ -309,6 +319,7 @@ void Play_Init(GameState* thisx) {
Play_SpawnScene( Play_SpawnScene(
this, gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].scene, this, gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].scene,
gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].spawn); gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].spawn);
osSyncPrintf("\nSCENE_NO=%d COUNTER=%d\n", ((void)0, gSaveContext.entranceIndex), gSaveContext.sceneSetupIndex); osSyncPrintf("\nSCENE_NO=%d COUNTER=%d\n", ((void)0, gSaveContext.entranceIndex), gSaveContext.sceneSetupIndex);
// When entering Gerudo Valley in the right setup, trigger the GC emulator to play the ending movie. // When entering Gerudo Valley in the right setup, trigger the GC emulator to play the ending movie.
@ -329,10 +340,12 @@ void Play_Init(GameState* thisx) {
gSaveContext.totalDays++; gSaveContext.totalDays++;
gSaveContext.bgsDayCount++; gSaveContext.bgsDayCount++;
gSaveContext.dogIsLost = true; gSaveContext.dogIsLost = true;
if (Inventory_ReplaceItem(this, ITEM_WEIRD_EGG, ITEM_CHICKEN) || if (Inventory_ReplaceItem(this, ITEM_WEIRD_EGG, ITEM_CHICKEN) ||
Inventory_ReplaceItem(this, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO)) { Inventory_ReplaceItem(this, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO)) {
Message_StartTextbox(this, 0x3066, NULL); Message_StartTextbox(this, 0x3066, NULL);
} }
gSaveContext.nextDayTime = NEXT_TIME_DAY_SET; gSaveContext.nextDayTime = NEXT_TIME_DAY_SET;
} else { } else {
gSaveContext.nextDayTime = NEXT_TIME_NIGHT_SET; gSaveContext.nextDayTime = NEXT_TIME_NIGHT_SET;
@ -444,12 +457,14 @@ void Play_Update(PlayState* this) {
HREG(81) = 0; HREG(81) = 0;
osSyncPrintf("object_exchange_rom_address %u\n", gObjectTableSize); osSyncPrintf("object_exchange_rom_address %u\n", gObjectTableSize);
osSyncPrintf("RomStart RomEnd Size\n"); osSyncPrintf("RomStart RomEnd Size\n");
for (i = 0; i < gObjectTableSize; i++) { for (i = 0; i < gObjectTableSize; i++) {
s32 size = gObjectTable[i].vromEnd - gObjectTable[i].vromStart; s32 size = gObjectTable[i].vromEnd - gObjectTable[i].vromStart;
osSyncPrintf("%08x-%08x %08x(%8.3fKB)\n", gObjectTable[i].vromStart, gObjectTable[i].vromEnd, size, osSyncPrintf("%08x-%08x %08x(%8.3fKB)\n", gObjectTable[i].vromStart, gObjectTable[i].vromEnd, size,
size / 1024.0f); size / 1024.0f);
} }
osSyncPrintf("\n"); osSyncPrintf("\n");
} }
@ -485,7 +500,7 @@ void Play_Update(PlayState* this) {
} }
} }
if (this->transitionMode) { if (this->transitionMode) { // != TRANS_MODE_OFF
switch (this->transitionMode) { switch (this->transitionMode) {
case TRANS_MODE_SETUP: case TRANS_MODE_SETUP:
if (this->transitionTrigger != TRANS_TRIGGER_END) { if (this->transitionTrigger != TRANS_TRIGGER_END) {
@ -559,6 +574,7 @@ void Play_Update(PlayState* this) {
(this->transitionCtx.transitionType == TRANS_TYPE_FADE_WHITE_CS_DELAYED) || (this->transitionCtx.transitionType == TRANS_TYPE_FADE_WHITE_CS_DELAYED) ||
(this->transitionCtx.transitionType == TRANS_TYPE_FADE_WHITE_INSTANT)) { (this->transitionCtx.transitionType == TRANS_TYPE_FADE_WHITE_INSTANT)) {
this->transitionCtx.setColor(&this->transitionCtx.instanceData, RGBA8(160, 160, 160, 255)); this->transitionCtx.setColor(&this->transitionCtx.instanceData, RGBA8(160, 160, 160, 255));
if (this->transitionCtx.setUnkColor != NULL) { if (this->transitionCtx.setUnkColor != NULL) {
this->transitionCtx.setUnkColor(&this->transitionCtx.instanceData, this->transitionCtx.setUnkColor(&this->transitionCtx.instanceData,
RGBA8(160, 160, 160, 255)); RGBA8(160, 160, 160, 255));
@ -725,7 +741,6 @@ void Play_Update(PlayState* this) {
case TRANS_MODE_SANDSTORM_INIT: case TRANS_MODE_SANDSTORM_INIT:
if (this->transitionTrigger != TRANS_TRIGGER_END) { if (this->transitionTrigger != TRANS_TRIGGER_END) {
// trigger in, leaving area
this->envCtx.sandstormState = SANDSTORM_FILL; this->envCtx.sandstormState = SANDSTORM_FILL;
this->transitionMode = TRANS_MODE_SANDSTORM; this->transitionMode = TRANS_MODE_SANDSTORM;
} else { } else {
@ -776,6 +791,7 @@ void Play_Update(PlayState* this) {
Audio_PlaySoundGeneral(NA_SE_EV_SAND_STORM - SFX_FLAG, &gSfxDefaultPos, 4, Audio_PlaySoundGeneral(NA_SE_EV_SAND_STORM - SFX_FLAG, &gSfxDefaultPos, 4,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultReverb); &gSfxDefaultReverb);
if (this->transitionTrigger == TRANS_TRIGGER_END) { if (this->transitionTrigger == TRANS_TRIGGER_END) {
if (this->envCtx.sandstormPrimA <= 0) { if (this->envCtx.sandstormPrimA <= 0) {
gTrnsnUnkState = 0; gTrnsnUnkState = 0;
@ -799,6 +815,7 @@ void Play_Update(PlayState* this) {
case TRANS_MODE_CS_BLACK_FILL: case TRANS_MODE_CS_BLACK_FILL:
if (gSaveContext.cutsceneTransitionControl != 0) { if (gSaveContext.cutsceneTransitionControl != 0) {
this->envCtx.screenFillColor[3] = gSaveContext.cutsceneTransitionControl; this->envCtx.screenFillColor[3] = gSaveContext.cutsceneTransitionControl;
if (gSaveContext.cutsceneTransitionControl <= 100) { if (gSaveContext.cutsceneTransitionControl <= 100) {
gTrnsnUnkState = 0; gTrnsnUnkState = 0;
R_UPDATE_RATE = 3; R_UPDATE_RATE = 3;
@ -810,53 +827,36 @@ void Play_Update(PlayState* this) {
} }
} }
if (1 && HREG(63)) { PLAY_LOG(3533);
LOG_NUM("1", 1, "../z_play.c", 3533);
}
if (1 && (gTrnsnUnkState != 3)) { if (1 && (gTrnsnUnkState != 3)) {
if (1 && HREG(63)) { PLAY_LOG(3542);
LOG_NUM("1", 1, "../z_play.c", 3542);
}
if ((gSaveContext.gameMode == 0) && (this->msgCtx.msgMode == MSGMODE_NONE) && if ((gSaveContext.gameMode == 0) && (this->msgCtx.msgMode == MSGMODE_NONE) &&
(this->gameOverCtx.state == GAMEOVER_INACTIVE)) { (this->gameOverCtx.state == GAMEOVER_INACTIVE)) {
KaleidoSetup_Update(this); KaleidoSetup_Update(this);
} }
if (1 && HREG(63)) { PLAY_LOG(3551);
LOG_NUM("1", 1, "../z_play.c", 3551);
}
sp80 = (this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0); sp80 = (this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0);
if (1 && HREG(63)) { PLAY_LOG(3555);
LOG_NUM("1", 1, "../z_play.c", 3555);
}
AnimationContext_Reset(&this->animationCtx); AnimationContext_Reset(&this->animationCtx);
if (1 && HREG(63)) { PLAY_LOG(3561);
LOG_NUM("1", 1, "../z_play.c", 3561);
}
Object_UpdateBank(&this->objectCtx); Object_UpdateBank(&this->objectCtx);
if (1 && HREG(63)) { PLAY_LOG(3577);
LOG_NUM("1", 1, "../z_play.c", 3577);
}
if ((sp80 == 0) && (IREG(72) == 0)) { if ((sp80 == 0) && (IREG(72) == 0)) {
if (1 && HREG(63)) { PLAY_LOG(3580);
LOG_NUM("1", 1, "../z_play.c", 3580);
}
this->gameplayFrames++; this->gameplayFrames++;
func_800AA178(1); func_800AA178(1);
if (this->actorCtx.freezeFlashTimer && (this->actorCtx.freezeFlashTimer-- < 5)) { if (this->actorCtx.freezeFlashTimer && (this->actorCtx.freezeFlashTimer-- < 5)) {
osSyncPrintf("FINISH=%d\n", this->actorCtx.freezeFlashTimer); osSyncPrintf("FINISH=%d\n", this->actorCtx.freezeFlashTimer);
if ((this->actorCtx.freezeFlashTimer > 0) && ((this->actorCtx.freezeFlashTimer % 2) != 0)) { if ((this->actorCtx.freezeFlashTimer > 0) && ((this->actorCtx.freezeFlashTimer % 2) != 0)) {
this->envCtx.fillScreen = true; this->envCtx.fillScreen = true;
this->envCtx.screenFillColor[0] = this->envCtx.screenFillColor[1] = this->envCtx.screenFillColor[0] = this->envCtx.screenFillColor[1] =
@ -866,91 +866,52 @@ void Play_Update(PlayState* this) {
this->envCtx.fillScreen = false; this->envCtx.fillScreen = false;
} }
} else { } else {
if (1 && HREG(63)) { PLAY_LOG(3606);
LOG_NUM("1", 1, "../z_play.c", 3606);
}
func_800973FC(this, &this->roomCtx); func_800973FC(this, &this->roomCtx);
if (1 && HREG(63)) { PLAY_LOG(3612);
LOG_NUM("1", 1, "../z_play.c", 3612);
}
CollisionCheck_AT(this, &this->colChkCtx); CollisionCheck_AT(this, &this->colChkCtx);
if (1 && HREG(63)) { PLAY_LOG(3618);
LOG_NUM("1", 1, "../z_play.c", 3618);
}
CollisionCheck_OC(this, &this->colChkCtx); CollisionCheck_OC(this, &this->colChkCtx);
if (1 && HREG(63)) { PLAY_LOG(3624);
LOG_NUM("1", 1, "../z_play.c", 3624);
}
CollisionCheck_Damage(this, &this->colChkCtx); CollisionCheck_Damage(this, &this->colChkCtx);
if (1 && HREG(63)) { PLAY_LOG(3631);
LOG_NUM("1", 1, "../z_play.c", 3631);
}
CollisionCheck_ClearContext(this, &this->colChkCtx); CollisionCheck_ClearContext(this, &this->colChkCtx);
if (1 && HREG(63)) { PLAY_LOG(3637);
LOG_NUM("1", 1, "../z_play.c", 3637);
}
if (!this->unk_11DE9) { if (!this->unk_11DE9) {
Actor_UpdateAll(this, &this->actorCtx); Actor_UpdateAll(this, &this->actorCtx);
} }
if (1 && HREG(63)) { PLAY_LOG(3643);
LOG_NUM("1", 1, "../z_play.c", 3643);
}
func_80064558(this, &this->csCtx); func_80064558(this, &this->csCtx);
if (1 && HREG(63)) { PLAY_LOG(3648);
LOG_NUM("1", 1, "../z_play.c", 3648);
}
func_800645A0(this, &this->csCtx); func_800645A0(this, &this->csCtx);
if (1 && HREG(63)) { PLAY_LOG(3651);
LOG_NUM("1", 1, "../z_play.c", 3651);
}
Effect_UpdateAll(this); Effect_UpdateAll(this);
if (1 && HREG(63)) { PLAY_LOG(3657);
LOG_NUM("1", 1, "../z_play.c", 3657);
}
EffectSs_UpdateAll(this); EffectSs_UpdateAll(this);
if (1 && HREG(63)) { PLAY_LOG(3662);
LOG_NUM("1", 1, "../z_play.c", 3662);
}
} }
} else { } else {
func_800AA178(0); func_800AA178(0);
} }
if (1 && HREG(63)) { PLAY_LOG(3672);
LOG_NUM("1", 1, "../z_play.c", 3672);
}
func_80095AA0(this, &this->roomCtx.curRoom, &input[1], 0); func_80095AA0(this, &this->roomCtx.curRoom, &input[1], 0);
if (1 && HREG(63)) { PLAY_LOG(3675);
LOG_NUM("1", 1, "../z_play.c", 3675);
}
func_80095AA0(this, &this->roomCtx.prevRoom, &input[1], 1); func_80095AA0(this, &this->roomCtx.prevRoom, &input[1], 1);
if (1 && HREG(63)) { PLAY_LOG(3677);
LOG_NUM("1", 1, "../z_play.c", 3677);
}
if (this->viewpoint != VIEWPOINT_NONE) { if (this->viewpoint != VIEWPOINT_NONE) {
if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) { if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) {
@ -969,85 +930,51 @@ void Play_Update(PlayState* this) {
Play_SetViewpoint(this, this->viewpoint ^ (VIEWPOINT_LOCKED ^ VIEWPOINT_PIVOT)); Play_SetViewpoint(this, this->viewpoint ^ (VIEWPOINT_LOCKED ^ VIEWPOINT_PIVOT));
} }
} }
Play_ChangeViewpointBgCamIndex(this); Play_ChangeViewpointBgCamIndex(this);
} }
if (1 && HREG(63)) { PLAY_LOG(3708);
LOG_NUM("1", 1, "../z_play.c", 3708);
}
SkyboxDraw_Update(&this->skyboxCtx); SkyboxDraw_Update(&this->skyboxCtx);
if (1 && HREG(63)) { PLAY_LOG(3716);
LOG_NUM("1", 1, "../z_play.c", 3716);
}
if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) {
if (1 && HREG(63)) { PLAY_LOG(3721);
LOG_NUM("1", 1, "../z_play.c", 3721);
}
KaleidoScopeCall_Update(this); KaleidoScopeCall_Update(this);
} else if (this->gameOverCtx.state != GAMEOVER_INACTIVE) { } else if (this->gameOverCtx.state != GAMEOVER_INACTIVE) {
if (1 && HREG(63)) { PLAY_LOG(3727);
LOG_NUM("1", 1, "../z_play.c", 3727);
}
GameOver_Update(this); GameOver_Update(this);
} else { } else {
if (1 && HREG(63)) { PLAY_LOG(3733);
LOG_NUM("1", 1, "../z_play.c", 3733);
}
Message_Update(this); Message_Update(this);
} }
if (1 && HREG(63)) { PLAY_LOG(3737);
LOG_NUM("1", 1, "../z_play.c", 3737);
}
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3742);
}
PLAY_LOG(3742);
Interface_Update(this); Interface_Update(this);
if (1 && HREG(63)) { PLAY_LOG(3765);
LOG_NUM("1", 1, "../z_play.c", 3765);
}
AnimationContext_Update(this, &this->animationCtx); AnimationContext_Update(this, &this->animationCtx);
if (1 && HREG(63)) { PLAY_LOG(3771);
LOG_NUM("1", 1, "../z_play.c", 3771);
}
SoundSource_UpdateAll(this); SoundSource_UpdateAll(this);
if (1 && HREG(63)) { PLAY_LOG(3777);
LOG_NUM("1", 1, "../z_play.c", 3777);
}
ShrinkWindow_Update(R_UPDATE_RATE); ShrinkWindow_Update(R_UPDATE_RATE);
if (1 && HREG(63)) { PLAY_LOG(3783);
LOG_NUM("1", 1, "../z_play.c", 3783);
}
TransitionFade_Update(&this->transitionFade, R_UPDATE_RATE); TransitionFade_Update(&this->transitionFade, R_UPDATE_RATE);
} else { } else {
goto skip; goto skip;
} }
} }
if (1 && HREG(63)) { PLAY_LOG(3799);
LOG_NUM("1", 1, "../z_play.c", 3799);
}
skip: skip:
if (1 && HREG(63)) { PLAY_LOG(3801);
LOG_NUM("1", 1, "../z_play.c", 3801);
}
if ((sp80 == 0) || gDbgCamEnabled) { if ((sp80 == 0) || gDbgCamEnabled) {
s32 pad3[5]; s32 pad3[5];
@ -1055,31 +982,21 @@ skip:
this->nextCamId = this->activeCamId; this->nextCamId = this->activeCamId;
if (1 && HREG(63)) { PLAY_LOG(3806);
LOG_NUM("1", 1, "../z_play.c", 3806);
}
for (i = 0; i < NUM_CAMS; i++) { for (i = 0; i < NUM_CAMS; i++) {
if ((i != this->nextCamId) && (this->cameraPtrs[i] != NULL)) { if ((i != this->nextCamId) && (this->cameraPtrs[i] != NULL)) {
if (1 && HREG(63)) { PLAY_LOG(3809);
LOG_NUM("1", 1, "../z_play.c", 3809);
}
Camera_Update(this->cameraPtrs[i]); Camera_Update(this->cameraPtrs[i]);
} }
} }
Camera_Update(this->cameraPtrs[this->nextCamId]); Camera_Update(this->cameraPtrs[this->nextCamId]);
if (1 && HREG(63)) { PLAY_LOG(3814);
LOG_NUM("1", 1, "../z_play.c", 3814);
}
}
if (1 && HREG(63)) {
LOG_NUM("1", 1, "../z_play.c", 3816);
} }
PLAY_LOG(3816);
Environment_Update(this, &this->envCtx, &this->lightCtx, &this->pauseCtx, &this->msgCtx, &this->gameOverCtx, Environment_Update(this, &this->envCtx, &this->lightCtx, &this->pauseCtx, &this->msgCtx, &this->gameOverCtx,
this->state.gfxCtx); this->state.gfxCtx);
} }
@ -1363,9 +1280,7 @@ void Play_Main(GameState* thisx) {
DebugDisplay_Init(); DebugDisplay_Init();
if (1 && HREG(63)) { PLAY_LOG(4556);
LOG_NUM("1", 1, "../z_play.c", 4556);
}
if ((HREG(80) == 10) && (HREG(94) != 10)) { if ((HREG(80) == 10) && (HREG(94) != 10)) {
HREG(81) = 1; HREG(81) = 1;
@ -1388,15 +1303,11 @@ void Play_Main(GameState* thisx) {
Play_Update(this); Play_Update(this);
} }
if (1 && HREG(63)) { PLAY_LOG(4583);
LOG_NUM("1", 1, "../z_play.c", 4583);
}
Play_Draw(this); Play_Draw(this);
if (1 && HREG(63)) { PLAY_LOG(4587);
LOG_NUM("1", 1, "../z_play.c", 4587);
}
} }
// original name: "Game_play_demo_mode_check" // original name: "Game_play_demo_mode_check"