1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-10 02:54:24 +00:00

document code_8008E6A0 (frame advance) (#737)

* OK

* fixes

* format

* remove gotos, thanks petrie
This commit is contained in:
fig02 2021-03-28 19:35:16 -04:00 committed by GitHub
parent 7f3be6e37f
commit 187d2d1500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 71 additions and 78 deletions

View file

@ -183,7 +183,7 @@ glabel func_80070C24
/* AE7FD0 80070E30 57000025 */ bnezl $t8, .L80070EC8
/* AE7FD4 80070E34 8DAF1360 */ lw $t7, 0x1360($t5)
/* AE7FD8 80070E38 AFAA007C */ sw $t2, 0x7c($sp)
/* AE7FDC 80070E3C 0C03034A */ jal func_800C0D28
/* AE7FDC 80070E3C 0C03034A */ jal FrameAdvance_IsEnabled
/* AE7FE0 80070E40 E7AE0088 */ swc1 $f14, 0x88($sp)
/* AE7FE4 80070E44 3C0D8016 */ lui $t5, %hi(gSaveContext) # $t5, 0x8016
/* AE7FE8 80070E48 25ADE660 */ addiu $t5, %lo(gSaveContext) # addiu $t5, $t5, -0x19a0

View file

@ -1128,8 +1128,8 @@ void Interface_Update(GlobalContext* globalCtx);
Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max);
f32 Path_OrientAndGetDistSq(Actor* actor, Path* path, s16 waypoint, s16* yaw);
void Path_CopyLastPoint(Path* path, Vec3f* dest);
void func_8008E6A0(SubGlobalContext7B8*);
u32 func_8008E6AC(SubGlobalContext7B8* this, Input* input);
void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx);
s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input);
void Player_SetBootData(GlobalContext* globalCtx, Player* player);
s32 Player_InBlockingCsMode(GlobalContext* globalCtx, Player* player);
s32 Player_InCsMode(GlobalContext* globalCtx);
@ -1601,7 +1601,7 @@ void Gameplay_SetupRespawnPoint(GlobalContext* globalCtx, s32 respawnMode, s32 p
void Gameplay_TriggerVoidOut(GlobalContext* globalCtx);
void Gameplay_TriggerRespawn(GlobalContext* globalCtx);
s32 func_800C0CB8(GlobalContext* globalCtx);
s32 func_800C0D28(GlobalContext* globalCtx);
s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx);
s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw);
void PreRender_SetValuesSave(PreRenderContext* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg);
void PreRender_Init(PreRenderContext* this);

View file

@ -190,9 +190,9 @@ typedef struct {
} SoundContext; // size = 0x4
typedef struct {
/* 0x00 */ u32 toggle;
/* 0x04 */ s32 counter;
} SubGlobalContext7B8; // size = 0x8
/* 0x00 */ s32 enabled;
/* 0x04 */ s32 timer;
} FrameAdvanceContext; // size = 0x8
typedef struct {
/* 0x00 */ Vec3f pos;
@ -869,7 +869,7 @@ typedef struct GlobalContext {
/* 0x007A2 */ s16 nextCamera;
/* 0x007A4 */ SoundContext soundCtx;
/* 0x007A8 */ LightContext lightCtx;
/* 0x007B8 */ SubGlobalContext7B8 sub_7B8;
/* 0x007B8 */ FrameAdvanceContext frameAdvCtx;
/* 0x007C0 */ CollisionContext colCtx;
/* 0x01C24 */ ActorContext actorCtx;
/* 0x01D64 */ CutsceneContext csCtx; // "demo_play"

2
spec
View file

@ -331,7 +331,7 @@ beginseg
include "build/src/code/z_map_data.o"
include "build/src/code/z_parameter.o"
include "build/src/code/z_path.o"
include "build/src/code/code_8008E6A0.o"
include "build/src/code/z_frame_advance.o"
include "build/src/code/z_player_lib.o"
include "build/src/code/z_prenmi.o"
include "build/src/code/z_quake.o"

View file

@ -1,36 +0,0 @@
#include "global.h"
void func_8008E6A0(SubGlobalContext7B8* this) {
this->counter = 0;
this->toggle = false;
}
u32 func_8008E6AC(SubGlobalContext7B8* this, Input* input) {
if (CHECK_BTN_ALL(input->cur.button, BTN_R) && CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
this->toggle = !this->toggle;
}
if (!this->toggle) {
goto ret_true;
}
if (CHECK_BTN_ALL(input->cur.button, BTN_Z)) {
if (CHECK_BTN_ALL(input->press.button, BTN_R)) {
goto ret_true;
}
if (CHECK_BTN_ALL(input->cur.button, BTN_R)) {
this->counter++;
if (this->counter >= 9) {
goto ret_true;
}
}
}
goto ret_false;
ret_true:
this->counter = 0;
return true;
ret_false:
return false;
}

View file

@ -1189,7 +1189,7 @@ static ColChkResetFunc sATResetFuncs[] = {
s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) {
s32 index;
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
if (!(collider->shape <= COLSHAPE_QUAD)) {
@ -1223,7 +1223,7 @@ s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* co
if (!(collider->shape <= COLSHAPE_QUAD)) {
__assert("pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3037);
}
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
sATResetFuncs[collider->shape](globalCtx, collider);
@ -1263,7 +1263,7 @@ static ColChkResetFunc sACResetFuncs[] = {
s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) {
s32 index;
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
if (!(collider->shape <= COLSHAPE_QUAD)) {
@ -1296,7 +1296,7 @@ s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co
if (!(collider->shape <= COLSHAPE_QUAD)) {
__assert("pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3153);
}
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
sACResetFuncs[collider->shape](globalCtx, collider);
@ -1336,7 +1336,7 @@ static ColChkResetFunc sOCResetFuncs[] = {
s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) {
s32 index;
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
if (!(collider->shape <= COLSHAPE_QUAD)) {
@ -1366,7 +1366,7 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colChk
*/
s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider,
s32 index) {
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
if (!(collider->shape <= COLSHAPE_QUAD)) {
@ -1403,7 +1403,7 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co
s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, OcLine* collider) {
s32 index;
if (func_800C0D28(globalCtx) == 1) {
if (FrameAdvance_IsEnabled(globalCtx) == true) {
return -1;
}
Collider_ResetLineOC(globalCtx, collider);

View file

@ -104,7 +104,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg
*pIndex = TOTAL_EFFECT_COUNT;
if (func_800C0D28(globalCtx) != 1) {
if (FrameAdvance_IsEnabled(globalCtx) != true) {
slotFound = false;
switch (type) {
case EFFECT_SPARK:

View file

@ -158,7 +158,7 @@ s32 EffectSs_FindSlot(s32 priority, s32* pIndex) {
void EffectSs_Insert(GlobalContext* globalCtx, EffectSs* effectSs) {
s32 index;
if (func_800C0D28(globalCtx) != 1) {
if (FrameAdvance_IsEnabled(globalCtx) != true) {
if (EffectSs_FindSlot(effectSs->priority, &index) == 0) {
sEffectSsInfo.searchStartIndex = index + 1;
sEffectSsInfo.table[index] = *effectSs;

View file

@ -0,0 +1,29 @@
#include "global.h"
void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx) {
frameAdvCtx->timer = 0;
frameAdvCtx->enabled = false;
}
/**
* Frame advance allows you to advance through the game one frame at a time on command.
* To enable, hold R and press Dpad Down on the provided controller.
* To advance a frame, hold Z and press R.
* Holding Z and R will advance a frame every half second.
*
* This function returns true when frame advance is not active (game will run normally)
*/
s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) {
if (CHECK_BTN_ALL(input->cur.button, BTN_R) && CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
frameAdvCtx->enabled = !frameAdvCtx->enabled;
}
if (!frameAdvCtx->enabled || (CHECK_BTN_ALL(input->cur.button, BTN_Z) &&
(CHECK_BTN_ALL(input->press.button, BTN_R) ||
(CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) {
frameAdvCtx->timer = 0;
return true;
}
return false;
}

View file

@ -328,7 +328,7 @@ void Gameplay_Init(GameState* thisx) {
PreRender_SetValues(&globalCtx->preRenderCtx, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
gTrnsnUnkState = 0;
globalCtx->transitionMode = 0;
func_8008E6A0(&globalCtx->sub_7B8);
FrameAdvance_Init(&globalCtx->frameAdvCtx);
Rand_Seed((u32)osGetTime());
Matrix_Init(&globalCtx->state);
globalCtx->state.main = Gameplay_Main;
@ -442,7 +442,7 @@ void Gameplay_Update(GlobalContext* globalCtx) {
gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment);
if (func_8008E6AC(&globalCtx->sub_7B8, &input[1]) != 0) {
if (FrameAdvance_Update(&globalCtx->frameAdvCtx, &input[1])) {
if ((globalCtx->transitionMode == 0) && (globalCtx->sceneLoadFlag != 0)) {
globalCtx->transitionMode = 1;
}
@ -1773,8 +1773,8 @@ s32 func_800C0CB8(GlobalContext* globalCtx) {
(YREG(15) != 0x40) && (globalCtx->sceneNum != SCENE_HAIRAL_NIWA);
}
s32 func_800C0D28(GlobalContext* globalCtx) {
return (globalCtx->sub_7B8.toggle != 0);
s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx) {
return !!globalCtx->frameAdvCtx.enabled;
}
s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw) {

View file

@ -2327,7 +2327,7 @@ void func_8009FE58(GlobalContext* globalCtx) {
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);
if (func_800C0D28(globalCtx) != 1) {
if (FrameAdvance_IsEnabled(globalCtx) != true) {
D_8012A39C += 1820;
D_8012A3A0 += 1820;

View file

@ -59,7 +59,7 @@ void DemoGt_SpawnDust(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec
void func_8097D7D8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velOffset, f32 scale, s32 arg4, s32 arg5, s16 life) {
s32 pad;
if (func_800C0D28(globalCtx) == 0) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
s32 frames = globalCtx->gameplayFrames;
if (ABS(frames % arg4) == arg5) {
@ -281,7 +281,7 @@ void func_8097E454(GlobalContext* globalCtx, Vec3f* spawnerPos, Vec3f* velocity,
f32 dustScale = 300.0f * scale;
Vec3f pos;
if ((func_800C0D28(globalCtx) == 0) && (arg7 > 0) && (arg6 > 0)) {
if ((!FrameAdvance_IsEnabled(globalCtx)) && (arg7 > 0) && (arg6 > 0)) {
frames = (ABS((s32)globalCtx->gameplayFrames) % arg7);
phi_s0 = 0x10000 * frames / arg6;
increment = 0x10000 / arg6;
@ -1298,7 +1298,7 @@ void DemoGt_Draw4(DemoGt* this, GlobalContext* globalCtx) {
Matrix_Translate(sp48.x, sp48.y, sp48.z, MTXMODE_APPLY);
Matrix_ToMtx(sp60, "../z_demo_gt_part4_1.c", 232);
if (func_800C0D28(globalCtx2) == 0) {
if (!FrameAdvance_IsEnabled(globalCtx2)) {
func_80980F8C(this, globalCtx2);
}
@ -1417,7 +1417,7 @@ void DemoGt_Draw5(DemoGt* this, GlobalContext* globalCtx) {
Matrix_Translate(sp48.x, sp48.y, sp48.z, MTXMODE_APPLY);
Matrix_ToMtx(sp60, "../z_demo_gt_part4_2.c", 227);
if (func_800C0D28(globalCtx) == 0) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80981458(this, globalCtx);
}

View file

@ -73,7 +73,7 @@ void EnOkarinaEffect_TriggerStorm(EnOkarinaEffect* this, GlobalContext* globalCt
void EnOkarinaEffect_ManageStorm(EnOkarinaEffect* this, GlobalContext* globalCtx) {
Flags_UnsetEnv(globalCtx, 5); // clear storms env flag
if (((globalCtx->pauseCtx.state == 0) && (globalCtx->unk_10A20 == 0) && (globalCtx->msgCtx.unk_E300 == 0) &&
(func_800C0D28(globalCtx) == 0) && ((globalCtx->transitionMode == 0) || (gSaveContext.gameMode != 0))) ||
(!FrameAdvance_IsEnabled(globalCtx)) && ((globalCtx->transitionMode == 0) || (gSaveContext.gameMode != 0))) ||
(this->timer >= 250)) {
if (globalCtx->envCtx.unk_1E != 0 || globalCtx->envCtx.unk_1F != 1) {
this->timer--;

View file

@ -455,7 +455,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_Translate(362.0f, -133.0f, 0.0f, MTXMODE_APPLY);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 0);
func_80B4F230(this, sp2C.x, 1);
func_80B4EF64(this, sp2C.z, 2);
@ -465,7 +465,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp74[0], "../z_en_zl2.c", 1056);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 3);
func_80B4F230(this, sp2C.x, 4);
}
@ -474,7 +474,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp74[1], "../z_en_zl2.c", 1100);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 6);
func_80B4F230(this, sp2C.x, 7);
}
@ -486,7 +486,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_Translate(467.0f, 265.0f, 389.0f, MTXMODE_APPLY);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 9);
func_80B4F230(this, sp2C.x, 10);
func_80B4EF64(this, sp2C.z, 11);
@ -496,7 +496,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp74[3], "../z_en_zl2.c", 1145);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 12);
func_80B4F230(this, sp2C.x, 13);
func_80B4EF64(this, sp2C.z, 14);
@ -509,7 +509,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_Translate(467.0f, 265.0f, -389.0f, MTXMODE_APPLY);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 15);
func_80B4F230(this, sp2C.x, 16);
func_80B4EF64(this, sp2C.z, 17);
@ -519,7 +519,7 @@ s32 func_80B4F45C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp74[5], "../z_en_zl2.c", 1189);
Matrix_Get(&sp34);
func_800D20CC(&sp34, &sp2C, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B4EE38(this, sp2C.y, 18);
func_80B4F230(this, sp2C.x, 19);
func_80B4EF64(this, sp2C.z, 20);

View file

@ -621,7 +621,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_Translate(362.0f, -133.0f, 0.0f, MTXMODE_APPLY);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B53980(this, sp30.y, 0);
func_80B54360(this, sp30.x, 1);
func_80B53B64(this, sp30.z, 2);
@ -631,7 +631,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp78[0], "../z_en_zl3.c", 1490);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B53980(this, sp30.y, 3);
}
Matrix_RotateRPY(unk_28C[3] + kREG(34), unk_28C[4] + kREG(35), unk_28C[5] + kREG(36), MTXMODE_APPLY);
@ -639,7 +639,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp78[1], "../z_en_zl3.c", 1534);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B54360(this, sp30.x, 7);
}
Matrix_RotateRPY(unk_28C[6] + kREG(37), unk_28C[7] + kREG(38), unk_28C[8] + kREG(39), MTXMODE_APPLY);
@ -650,7 +650,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_Translate(467.0f, 265.0f, 389.0f, MTXMODE_APPLY);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B53980(this, sp30.y, 9);
func_80B54360(this, sp30.x, 10);
func_80B53B64(this, sp30.z, 11);
@ -660,7 +660,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp78[3], "../z_en_zl3.c", 1579);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B53980(this, sp30.y, 12);
func_80B54360(this, sp30.x, 13);
func_80B53B64(this, sp30.z, 14);
@ -673,7 +673,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_Translate(467.0f, 265.0f, -389.0f, MTXMODE_APPLY);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B53980(this, sp30.y, 15);
func_80B54360(this, sp30.x, 16);
func_80B53B64(this, sp30.z, 17);
@ -683,7 +683,7 @@ s32 func_80B5458C(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p
Matrix_ToMtx(&sp78[5], "../z_en_zl3.c", 1623);
Matrix_Get(&sp38);
func_800D20CC(&sp38, &sp30, 0);
if (!func_800C0D28(globalCtx)) {
if (!FrameAdvance_IsEnabled(globalCtx)) {
func_80B53980(this, sp30.y, 18);
func_80B54360(this, sp30.x, 19);
func_80B53B64(this, sp30.z, 20);