diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2022-11-06 02:24:34 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-06 09:24:34 +0100 |
| commit | 99260acaf119b6b2b57dd10eb357fa1271bfc536 (patch) | |
| tree | 54a84799114585a484af6224c84b06fe582c9202 /soh/src/code | |
| parent | 710a768d76ca6a04ed8596b9db9d665a79400ad9 (diff) | |
Use PlayState instead of GlobalContext (#1927)
* Use PlayState instead of GlobalContext
- GlobalContext -> PlayState
- globalCtx -> play
- GlobalCtx -> PlayState
- globalContext -> playState
* Find and replace Gameplay_ with Play_
* Correct some misnamed argument cases
Diffstat (limited to 'soh/src/code')
60 files changed, 5408 insertions, 5408 deletions
diff --git a/soh/src/code/code_80043480.c b/soh/src/code/code_80043480.c index eda615d35..3ba733e26 100644 --- a/soh/src/code/code_80043480.c +++ b/soh/src/code/code_80043480.c @@ -76,7 +76,7 @@ s32 func_800435B4(DynaPolyActor* dynaActor) { } } -s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4) { +s32 func_800435D8(PlayState* play, DynaPolyActor* dynaActor, s16 arg2, s16 arg3, s16 arg4) { Vec3f posA; Vec3f posB; Vec3f posResult; @@ -98,7 +98,7 @@ s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, posB.y = posA.y; posB.z = sign * a3 * cos + posA.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId, + if (BgCheck_EntityLineTest3(&play->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId, &dynaActor->actor, 0.0f)) { return false; } @@ -106,7 +106,7 @@ s32 func_800435D8(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 arg2, posA.z = (dynaActor->actor.world.pos.z * 2) - posA.z; posB.x = sign * a3 * sin + posA.x; posB.z = sign * a3 * cos + posA.z; - if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId, + if (BgCheck_EntityLineTest3(&play->colCtx, &posA, &posB, &posResult, &poly, true, false, false, true, &bgId, &dynaActor->actor, 0.0f)) { return false; } diff --git a/soh/src/code/code_8006C3A0.c b/soh/src/code/code_8006C3A0.c index 341a44595..d3397086e 100644 --- a/soh/src/code/code_8006C3A0.c +++ b/soh/src/code/code_8006C3A0.c @@ -1,33 +1,33 @@ #include "global.h" -void Flags_UnsetAllEnv(GlobalContext* globalCtx) { +void Flags_UnsetAllEnv(PlayState* play) { u8 i; for (i = 0; i < 20; i++) { - globalCtx->envFlags[i] = 0; + play->envFlags[i] = 0; } } -void Flags_SetEnv(GlobalContext* globalCtx, s16 flag) { +void Flags_SetEnv(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = 1 << bit; - globalCtx->envFlags[index] |= mask; + play->envFlags[index] |= mask; } -void Flags_UnsetEnv(GlobalContext* globalCtx, s16 flag) { +void Flags_UnsetEnv(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = (1 << bit) ^ 0xFFFF; - globalCtx->envFlags[index] &= mask; + play->envFlags[index] &= mask; } -s32 Flags_GetEnv(GlobalContext* globalCtx, s16 flag) { +s32 Flags_GetEnv(PlayState* play, s16 flag) { s16 index = flag / 16; s16 bit = flag % 16; s16 mask = 1 << bit; - return globalCtx->envFlags[index] & mask; + return play->envFlags[index] & mask; } diff --git a/soh/src/code/code_80097A00.c b/soh/src/code/code_80097A00.c index 727c199ac..00fdb0a4d 100644 --- a/soh/src/code/code_80097A00.c +++ b/soh/src/code/code_80097A00.c @@ -188,8 +188,8 @@ void Inventory_ChangeEquipment(s16 equipment, u16 value) { gSaveContext.equips.equipment |= value << gEquipShifts[equipment]; } -u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { - Player* player = GET_PLAYER(globalCtx); +u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) { + Player* player = GET_PLAYER(play); s32 pad; u16 sp26 = gSaveContext.equips.equipment & gEquipMasks[equipment]; @@ -211,8 +211,8 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { gSaveContext.infTable[29] = 1; } - Player_SetEquipmentData(globalCtx, player); - globalCtx->pauseCtx.cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; + Player_SetEquipmentData(play, player); + play->pauseCtx.cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; } return sp26; diff --git a/soh/src/code/db_camera.c b/soh/src/code/db_camera.c index d663b4191..0f6d110b8 100644 --- a/soh/src/code/db_camera.c +++ b/soh/src/code/db_camera.c @@ -1,7 +1,7 @@ #include "ultra64.h" #include "global.h" -static GlobalContext* sGlobalCtx; +static PlayState* sPlayState; // TODO: cleanup these arrays and UB access char* D_8012CEE0[] = { GFXP_KATAKANA "キ-フレ-ム" GFXP_HIRAGANA "ガ" }; @@ -349,7 +349,7 @@ s32 func_800B4370(DbCamera* dbCamera, s16 idx, Camera* cam) { void func_800B44E0(DbCamera* dbCamera, Camera* cam) { s32 i; - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CRIGHT)) { sDbCamAnim.keyframe = 0; sDbCamAnim.unk_0A = 1; sDbCamAnim.curFrame = 0.0f; @@ -523,7 +523,7 @@ void DbCamera_Init(DbCamera* dbCamera, Camera* cameraPtr) { dbCamera->sub.unk_104A.x = dbCamera->sub.unk_104A.z; dbCamera->fov = 0.0f; dbCamera->rollDegrees = 0.0f; - sGlobalCtx = cameraPtr->globalCtx; + sPlayState = cameraPtr->play; dbCamera->sub.mode = 0; dbCamera->sub.nFrames = -1; dbCamera->sub.nPoints = 1; @@ -598,7 +598,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { sp80 = &dbCamera->eye; sp7C = &dbCamera->at; - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_Z)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_Z)) { dbCamera->unk_00++; dbCamera->unk_00 %= 3; dbCamera->unk_38 = 1; @@ -688,7 +688,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } dbCamera->unk_3C = D_80161140; - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_B | BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_B | BTN_L)) { sp104.r += temp_f2; if (sp104.r > 30000.0f) { @@ -702,7 +702,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } dbCamera->unk_40 = 7; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_B)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_B)) { spFC = sp104; spFC.r = temp_f2; if (!D_80161144) { @@ -719,7 +719,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 0xB; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_A | BTN_L)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_A | BTN_L)) { sp104.r -= temp_f2; if (sp104.r < 10.0f) { sp104.r = 10.0f; @@ -730,7 +730,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 8; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_A)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_A)) { spFC = sp104; spFC.r = -temp_f2; if (!D_80161144) { @@ -752,7 +752,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_40 = -1; } - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DDOWN | BTN_L)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DDOWN | BTN_L)) { spFC = sp104; spFC.r = temp_f2; spFC.pitch = 0; @@ -770,7 +770,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 1; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DUP | BTN_L)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DUP | BTN_L)) { spFC = sp104; spFC.r = -temp_f2; spFC.pitch = 0; @@ -787,7 +787,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 2; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DUP)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DUP)) { spFC = sp104; spFC.r = temp_f2; spFC.pitch = 0x3FFF; @@ -803,7 +803,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 3; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DDOWN)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DDOWN)) { spFC = sp104; spFC.r = temp_f2; spFC.pitch = -0x3FFF; @@ -819,8 +819,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 4; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, (BTN_DRIGHT | BTN_L)) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DRIGHT)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, (BTN_DRIGHT | BTN_L)) || + CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DRIGHT)) { spFC = sp104; spFC.r = temp_f2; spFC.pitch = 0; @@ -837,8 +837,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 5; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, (BTN_DLEFT | BTN_L)) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DLEFT)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, (BTN_DLEFT | BTN_L)) || + CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DLEFT)) { spFC = sp104; spFC.r = temp_f2; spFC.pitch = 0; @@ -855,7 +855,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 6; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_B | BTN_L)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_B | BTN_L)) { sp104.r = sp104.r + temp_f2; if (sp104.r > 30000.0f) { sp104.r = 30000.0f; @@ -866,7 +866,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 7; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_B)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_B)) { spFC = sp104; spFC.r = temp_f2; if (!D_80161144) { @@ -883,7 +883,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 0xB; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_A | BTN_L)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_A | BTN_L)) { sp104.r -= temp_f2; if (sp104.r < 10.0f) { @@ -895,7 +895,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_44 = 0; } dbCamera->unk_40 = 8; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_A)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_A)) { spFC = sp104; spFC.r = -temp_f2; if (!D_80161144) { @@ -917,7 +917,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->unk_40 = -1; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_R)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_R)) { if (dbCamera->unk_00 == 0) { dbCamera->sub.unk_104A = cam->inputDir; *sp7C = cam->at; @@ -931,12 +931,12 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { func_800B41DC(dbCamera, dbCamera->sub.unkIdx, cam); } else { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_R) && - CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_R) && + CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.nPoints = dbCamera->sub.unkIdx + 1; func_800B4088(dbCamera, cam); - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_R)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_R)) { if (dbCamera->sub.unkIdx == 0x80) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { @@ -952,8 +952,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } } } else { - temp_f0_5 = sGlobalCtx->state.input[2].rel.stick_y; - temp_f2_2 = sGlobalCtx->state.input[2].rel.stick_x; + temp_f0_5 = sPlayState->state.input[2].rel.stick_y; + temp_f2_2 = sPlayState->state.input[2].rel.stick_x; pitch = DEGF_TO_BINANG((SQ(temp_f0_5) / 600.0f) * 0.8f); yaw = DEGF_TO_BINANG((SQ(temp_f2_2) / 600.0f) * 0.8f); if (!D_80161144) { @@ -973,7 +973,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { OLib_Vec3fDiffToVecSphGeo(&spF4, sp80, sp7C); DbCamera_CalcUpFromPitchYawRoll(&dbCamera->unk_1C, spF4.pitch, spF4.yaw, DEGF_TO_BINANG(dbCamera->rollDegrees)); if (dbCamera->unk_00 == 1) { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_CRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_CRIGHT)) { cam->inputDir = dbCamera->sub.unk_104A; new_var2 = OLib_Vec3fDist(&cam->at, &cam->eye); cam->at = *sp7C; @@ -987,12 +987,12 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { if (dbCamera->unk_00 == 1) { OREG(0) = 8; func_8006376C(0xC, 5, 0, D_8012CEF4); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_CRIGHT) && - !CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_CRIGHT) && + !CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { func_800B44E0(dbCamera, cam); } else { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CRIGHT) && - CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CRIGHT) && + CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** start here *** */\n@@@\n"); DbCamera_PrintPoints("Lookat", dbCamera->sub.nPoints, dbCamera->sub.lookAt); @@ -1001,13 +1001,13 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { osSyncPrintf("@@@static short nFrames = %d;\n@@@\n", dbCamera->sub.nFrames); osSyncPrintf("@@@static short Mode = %d;\n@@@\n", dbCamera->sub.mode); osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** finish! *** */\n@@@\n"); - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CLEFT)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.unk_08 = (dbCamera->sub.unk_08 + 1) % 3; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CUP) && - CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CUP) && + CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.unkIdx > 0) { dbCamera->sub.unkIdx--; @@ -1015,7 +1015,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.unkIdx = dbCamera->sub.nPoints - 1; } } else { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CUP)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CUP)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.unkIdx > 0) { @@ -1036,8 +1036,8 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L) && - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CDOWN)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L) && + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CDOWN)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) { dbCamera->sub.unkIdx++; @@ -1045,7 +1045,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.unkIdx = 0; } } else { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CDOWN)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CDOWN)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) { @@ -1115,7 +1115,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { break; case 1: dbCamera->unk_3C = true; - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DUP)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DUP)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.unk_0A == 0) { @@ -1124,7 +1124,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.unk_0A--; } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.unk_0A == 5) { @@ -1133,12 +1133,12 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.unk_0A++; } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); switch (dbCamera->sub.unk_0A) { case 1: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame -= 5; } else { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame--; @@ -1170,7 +1170,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.unk_0C = false; break; case 2: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll -= 5; dbCamera->roll = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll; } else { @@ -1182,7 +1182,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DLEFT)) { if ((D_8012D10C++ % 5) == 0) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -1190,7 +1190,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { switch (dbCamera->sub.unk_0A) { case 0: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle -= 1.0f; dbCamera->fov = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle; } else { @@ -1199,7 +1199,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } break; case 5: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.nFrames -= 10; } else { dbCamera->sub.nFrames--; @@ -1221,13 +1221,13 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); switch (dbCamera->sub.unk_0A) { case 1: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame += 5; } else { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame++; @@ -1258,7 +1258,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.unk_0C = true; break; case 2: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll += 5; dbCamera->roll = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].cameraRoll; } else { @@ -1269,7 +1269,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { break; } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_DRIGHT)) { if ((D_8012D10C++ % 5) == 0) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -1277,7 +1277,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { switch (dbCamera->sub.unk_0A) { case 0: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle += 1.0f; dbCamera->fov = dbCamera->sub.lookAt[dbCamera->sub.unkIdx].viewAngle; } else { @@ -1286,7 +1286,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } break; case 5: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { dbCamera->sub.nFrames += 10; } else { dbCamera->sub.nFrames++; @@ -1388,11 +1388,11 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } DebugDisplay_AddObject(dbCamera->at.x, dbCamera->at.y + 1.0f, dbCamera->at.z, 0, 0, 0, 0.02f, 2.0f, 0.02f, - 0xFF, 0xFF, 0x7F, 0x40, 0, cam->globalCtx->view.gfxCtx); + 0xFF, 0xFF, 0x7F, 0x40, 0, cam->play->view.gfxCtx); DebugDisplay_AddObject(dbCamera->at.x, dbCamera->at.y + 1.0f, dbCamera->at.z, 0, 0, 0, 2.0f, 0.02f, 0.02f, - 0x7F, 0xFF, 0xFF, 0x40, 0, cam->globalCtx->view.gfxCtx); + 0x7F, 0xFF, 0xFF, 0x40, 0, cam->play->view.gfxCtx); DebugDisplay_AddObject(dbCamera->at.x, dbCamera->at.y + 1.0f, dbCamera->at.z, 0, 0, 0, 0.02f, 0.02f, 2.0f, - 0xFF, 0x7F, 0xFF, 0x40, 0, cam->globalCtx->view.gfxCtx); + 0xFF, 0x7F, 0xFF, 0x40, 0, cam->play->view.gfxCtx); if (dbCamera->sub.unk_08 == 2) { for (i = 0; i < (dbCamera->sub.nPoints - 1); i++) { if (dbCamera->sub.mode != 1) { @@ -1406,14 +1406,14 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { spAA = dbCamera->sub.lookAt[i].cameraRoll * 0xB6; if (i == dbCamera->sub.unkIdx) { DebugDisplay_AddObject(spAC.x, spAC.y, spAC.z, spFC.pitch * -1, spFC.yaw, spAA, .5f, .5f, .5f, - 0x7F, 0xFF, 0x7F, 0x80, 5, cam->globalCtx->view.gfxCtx); + 0x7F, 0xFF, 0x7F, 0x80, 5, cam->play->view.gfxCtx); DebugDisplay_AddObject(spB8.x, spB8.y, spB8.z, spFC.pitch * -1, spFC.yaw, spAA, 1.5f, 2.0f, - 1.0f, 0x7F, 0xFF, 0x7F, 0x80, 4, cam->globalCtx->view.gfxCtx); + 1.0f, 0x7F, 0xFF, 0x7F, 0x80, 4, cam->play->view.gfxCtx); } else { DebugDisplay_AddObject(spAC.x, spAC.y, spAC.z, spFC.pitch * -1, spFC.yaw, spAA, .5f, .5f, .5f, - 0xFF, 0x7F, 0x7F, 0x80, 5, cam->globalCtx->view.gfxCtx); + 0xFF, 0x7F, 0x7F, 0x80, 5, cam->play->view.gfxCtx); DebugDisplay_AddObject(spB8.x, spB8.y, spB8.z, spFC.pitch * -1, spFC.yaw, spAA, 1.5f, 2.0f, - 1.0f, 0xFF, 0x7F, 0x7F, 0x80, 4, cam->globalCtx->view.gfxCtx); + 1.0f, 0xFF, 0x7F, 0x7F, 0x80, 4, cam->play->view.gfxCtx); } } } @@ -1423,7 +1423,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { dbCamera->roll = 0; dbCamera->fov = 60.0f; dbCamera->rollDegrees = dbCamera->roll * 1.40625f; - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CLEFT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->unk_78 = (dbCamera->unk_78 + 1) % 3; dbCamera->unk_38 = -1; @@ -1471,18 +1471,18 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { OLib_Vec3fDiffToVecSphGeo(&spA0, &cam->eye, &cam->at); DebugDisplay_AddObject(dbCamera->at.x, dbCamera->at.y + 1.0f, dbCamera->at.z, 0, 0, 0, 0.02f, 2.0f, 0.02f, 0xFF, - 0xFF, 0x7F, 0x2D, 0, cam->globalCtx->view.gfxCtx); + 0xFF, 0x7F, 0x2D, 0, cam->play->view.gfxCtx); DebugDisplay_AddObject(dbCamera->at.x, dbCamera->at.y + 1.0f, dbCamera->at.z, 0, 0, 0, 2.0f, 0.02f, 0.02f, 0x7F, - 0xFF, 0xFF, 0x2D, 0, cam->globalCtx->view.gfxCtx); + 0xFF, 0xFF, 0x2D, 0, cam->play->view.gfxCtx); DebugDisplay_AddObject(dbCamera->at.x, dbCamera->at.y + 1.0f, dbCamera->at.z, 0, 0, 0, 0.02f, 0.02f, 2.0f, 0xFF, - 0x7F, 0xFF, 0x2D, 0, cam->globalCtx->view.gfxCtx); + 0x7F, 0xFF, 0x2D, 0, cam->play->view.gfxCtx); DebugDisplay_AddObject(cam->eye.x, cam->eye.y, cam->eye.z, spA0.pitch * -1, spA0.yaw, 0, .5f, .5f, .5f, 0xFF, - 0x7F, 0x7F, 0x80, 5, cam->globalCtx->view.gfxCtx); + 0x7F, 0x7F, 0x80, 5, cam->play->view.gfxCtx); DebugDisplay_AddObject(cam->at.x, cam->at.y, cam->at.z, spA0.pitch * -1, spA0.yaw, 0, 1.5f, 2.0f, 1.0f, 0xFF, - 0x7F, 0x7F, 0x80, 4, cam->globalCtx->view.gfxCtx); + 0x7F, 0x7F, 0x80, 4, cam->play->view.gfxCtx); OLib_Vec3fDiffToVecSphGeo(&spA0, &cam->eyeNext, &cam->at); DebugDisplay_AddObject(cam->eyeNext.x, cam->eyeNext.y, cam->eyeNext.z, spA0.pitch * -1, spA0.yaw, 0, .5f, .5f, - .5f, 0xFF, 0xC0, 0x7F, 0x50, 5, cam->globalCtx->view.gfxCtx); + .5f, 0xFF, 0xC0, 0x7F, 0x50, 5, cam->play->view.gfxCtx); } } @@ -1850,8 +1850,8 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { case DEMO_CTRL_MENU(ACTION_LOAD, MENU_INFO): case DEMO_CTRL_MENU(ACTION_CLEAR, MENU_INFO): { if ((1 << sCurFileIdx) & sMempakFiles) { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DLEFT) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DLEFT) || + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlToggleSwitch ^= 1; @@ -1864,7 +1864,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { func_8006376C(0x11, 8, dbCamera->sub.demoCtrlToggleSwitch ? 4 : 7, D_8012CF94); func_8006376C(0x15, 8, dbCamera->sub.demoCtrlToggleSwitch ? 7 : 4, D_8012CF98); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_A)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_A)) { if (dbCamera->sub.demoCtrlToggleSwitch == 0) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -1886,7 +1886,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { func_8006376C(0xD, 9, dbCamera->sub.demoCtrlToggleSwitch ? 1 : 6, "PRESS B BUTTON"); } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlMenu = 0; return 1; @@ -1921,8 +1921,8 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { func_8006376C(0x17, 7, 5, D_8012CFA4); func_8006376C(0xD, 9, (dbCamera->sub.demoCtrlToggleSwitch != 0) ? 1 : 6, "PRESS B BUTTON"); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_A) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_A) || + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (dbCamera->sub.demoCtrlMenu == DEMO_CTRL_MENU(ACTION_LOAD, MENU_SUCCESS)) { dbCamera->sub.demoCtrlActionIdx = ACTION_E; @@ -1943,8 +1943,8 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { func_8006376C(0x17, 7, 5, D_8012CFA4); func_8006376C(0xD, 9, (dbCamera->sub.demoCtrlToggleSwitch != 0) ? 1 : 6, "PRESS B BUTTON"); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_A) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_A) || + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlMenu -= 9; } @@ -1978,7 +1978,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sp74[i * 2 + 0] = '-'; sp74[i * 2 + 1] = '\0'; - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (sCurFileIdx >= 4) { @@ -1995,7 +1995,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { dbCamera->sub.demoCtrlActionIdx = ACTION_SAVE; } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (sCurFileIdx <= 0) { @@ -2038,24 +2038,24 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { func_8006376C(0xD, 0x1A, 5, D_8012CF60[0]); func_8006376C(0x14, 0x1A, 5, D_8012CF70); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DUP)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DUP)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx + 1) % 4u; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_A)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_A)) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlToggleSwitch = 0; dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(dbCamera->sub.demoCtrlActionIdx, MENU_INFO); } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlActionIdx = ACTION_E; @@ -2065,9 +2065,9 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } else { func_8006376C(0xC, 0x1A, 4, D_8012CF60[0]); func_8006376C(0x13, 0x1A, 4, D_8012CF80); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DUP) || - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_B) || + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DUP) || + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -2081,13 +2081,13 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { break; default: { - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DUP)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DUP)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO); dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u; sCurFileIdx = 0; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO); dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx + 1) % 4u; @@ -2100,7 +2100,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { func_8006376C(4, 7, 5, D_8012CF4C); func_8006376C(D_8016110C * 2 + 6, 7, 7, ">"); - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CUP)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CUP)) { if (D_8016110C > 0) { D_8016110C--; } @@ -2108,7 +2108,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sDbCamAnim.curFrame = 0.0f; sDbCamAnim.keyframe = 0; sDbCamAnim.unk_04 = 0; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CDOWN)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CDOWN)) { if (D_8016110C < 14) { D_8016110C++; } @@ -2116,7 +2116,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sDbCamAnim.curFrame = 0.0f; sDbCamAnim.keyframe = 0; sDbCamAnim.unk_04 = 0; - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CLEFT)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CLEFT)) { sDbCamAnim.unk_0A = 0; Interface_ChangeAlpha(2); ShrinkWindow_SetVal(0); @@ -2135,7 +2135,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { return 2; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[1].press.button, BTN_CRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[1].press.button, BTN_CRIGHT)) { D_8015FCC8 = 0; gSaveContext.cutsceneIndex = 0xFFFD; gSaveContext.cutsceneTrigger = 1; @@ -2148,7 +2148,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { Audio_PlaySoundGeneral(NA_SE_SY_HP_RECOVER, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_L)) { if (sp74[sCurFileIdx] == '?') { sLastFileIdx = -1; D_801612EA = '*'; @@ -2156,7 +2156,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sLastFileIdx = sCurFileIdx; D_801612EA = sDbCameraCuts[idx1].letter; } - } else if (!CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + } else if (!CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L)) { if (sLastFileIdx != -1) { switch (sp74[sCurFileIdx]) { case '?': @@ -2198,7 +2198,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sLastFileIdx = -1; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_A)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_A)) { if (sp74[sCurFileIdx] == '?') { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); sp74[sCurFileIdx] = DbCamera_InitCut(idx1, &dbCamera->sub); @@ -2208,7 +2208,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_B)) { if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); sp74[sCurFileIdx] = '?'; @@ -2216,7 +2216,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_R)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_R)) { if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -2239,7 +2239,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); if (sCurFileIdx == 0x1E) { sCurFileIdx = 0; @@ -2247,21 +2247,21 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sCurFileIdx++; } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); sCurFileIdx = (sCurFileIdx == 0) ? 0x1E : sCurFileIdx - 1; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L) && - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CRIGHT)) { + if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L) && + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CRIGHT)) { for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) { osSyncPrintf("###%2d:(%c) (%d %d) %d %d %d\n", i, sDbCameraCuts[i].letter, sDbCameraCuts[i].position, sDbCameraCuts[i].lookAt, sDbCameraCuts[i].nFrames, sDbCameraCuts[i].nPoints, sDbCameraCuts[i].mode); } DbCamera_PrintAllCuts(cam); - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L) && - CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CLEFT)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].cur.button, BTN_L) && + CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) { if (sDbCameraCuts[i].nPoints != 0) { @@ -2269,7 +2269,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { DbCamera_PrintCutBytes(&sDbCameraCuts[i]); } } - } else if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_CRIGHT)) { + } else if (CHECK_BTN_ALL(sPlayState->state.input[2].press.button, BTN_CRIGHT)) { sDbCamAnim.curFrame = 0.0f; sDbCamAnim.keyframe = 0; sDbCamAnim.unk_04 = 0.0f; diff --git a/soh/src/code/flg_set.c b/soh/src/code/flg_set.c index 54bbd21e8..c6e809c63 100644 --- a/soh/src/code/flg_set.c +++ b/soh/src/code/flg_set.c @@ -1,6 +1,6 @@ #include "global.h" -void FlagSet_Update(GlobalContext* globalCtx) { +void FlagSet_Update(PlayState* play) { static s32 entryIdx = 0; static u32 curBit = 0; static s32 timer = 0; @@ -35,8 +35,8 @@ void FlagSet_Update(GlobalContext* globalCtx) { { &gSaveContext.eventInf[2], "event_inf[2]" }, { &gSaveContext.eventInf[3], "event_inf[3]" }, }; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - Input* input = &globalCtx->state.input[0]; + GraphicsContext* gfxCtx = play->state.gfxCtx; + Input* input = &play->state.input[0]; Gfx* gfx; Gfx* polyOpa; @@ -145,7 +145,7 @@ void FlagSet_Update(GlobalContext* globalCtx) { } if (CHECK_BTN_ALL(input->press.button, BTN_L)) { - globalCtx->pauseCtx.debugState = 0; + play->pauseCtx.debugState = 0; } CLOSE_DISPS(gfxCtx); diff --git a/soh/src/code/game.c b/soh/src/code/game.c index 712bc6f2a..8482c7678 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -389,10 +389,10 @@ void GameState_Update(GameState* gameState) { // Moon Jump On L if (CVar_GetS32("gMoonJumpOnL", 0) != 0) { - if (gGlobalCtx) { - Player* player = GET_PLAYER(gGlobalCtx); + if (gPlayState) { + Player* player = GET_PLAYER(gPlayState); - if (CHECK_BTN_ANY(gGlobalCtx->state.input[0].cur.button, BTN_L)) { + if (CHECK_BTN_ANY(gPlayState->state.input[0].cur.button, BTN_L)) { player->actor.velocity.y = 6.34375f; } } @@ -400,18 +400,18 @@ void GameState_Update(GameState* gameState) { // Permanent infinite sword glitch (ISG) if (CVar_GetS32("gEzISG", 0) != 0) { - if (gGlobalCtx) { - Player* player = GET_PLAYER(gGlobalCtx); + if (gPlayState) { + Player* player = GET_PLAYER(gPlayState); player->swordState = 1; } } // Unrestricted Items if (CVar_GetS32("gNoRestrictItems", 0) != 0) { - if (gGlobalCtx) { - u8 sunsBackup = gGlobalCtx->interfaceCtx.restrictions.sunsSong; - memset(&gGlobalCtx->interfaceCtx.restrictions, 0, sizeof(gGlobalCtx->interfaceCtx.restrictions)); - gGlobalCtx->interfaceCtx.restrictions.sunsSong = sunsBackup; + if (gPlayState) { + u8 sunsBackup = gPlayState->interfaceCtx.restrictions.sunsSong; + memset(&gPlayState->interfaceCtx.restrictions, 0, sizeof(gPlayState->interfaceCtx.restrictions)); + gPlayState->interfaceCtx.restrictions.sunsSong = sunsBackup; } } diff --git a/soh/src/code/graph.c b/soh/src/code/graph.c index 2a0e5c733..c6354ae93 100644 --- a/soh/src/code/graph.c +++ b/soh/src/code/graph.c @@ -124,7 +124,7 @@ GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { if (gameStateInitFunc == Title_Init) { return &gGameStateOverlayTable[2]; } - if (gameStateInitFunc == Gameplay_Init) { + if (gameStateInitFunc == Play_Init) { return &gGameStateOverlayTable[3]; } if (gameStateInitFunc == Opening_Init) { @@ -469,8 +469,8 @@ static void RunFrame() // Setup the normal skybox once before entering any game states to avoid the 0xabababab crash. // The crash is due to certain skyboxes not loading all the data they need from Skybox_Setup. if (!hasSetupSkybox) { - GlobalContext* globalCtx = (GlobalContext*)runFrameContext.gameState; - Skybox_Setup(globalCtx, &globalCtx->skyboxCtx, SKYBOX_NORMAL_SKY); + PlayState* play = (PlayState*)runFrameContext.gameState; + Skybox_Setup(play, &play->skyboxCtx, SKYBOX_NORMAL_SKY); hasSetupSkybox = true; } diff --git a/soh/src/code/padmgr.c b/soh/src/code/padmgr.c index e7f8bcf14..ed18dcbac 100644 --- a/soh/src/code/padmgr.c +++ b/soh/src/code/padmgr.c @@ -294,7 +294,7 @@ void PadMgr_ProcessInputs(PadMgr* padMgr) { if (HealthMeter_IsCritical()) { controllerCallback.ledColor = 0; - } else if (gGlobalCtx) { + } else if (gPlayState) { switch (CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1) { case PLAYER_TUNIC_KOKIRI: controllerCallback.ledColor = 1; diff --git a/soh/src/code/sys_math3d.c b/soh/src/code/sys_math3d.c index 39ffea881..66ec88316 100644 --- a/soh/src/code/sys_math3d.c +++ b/soh/src/code/sys_math3d.c @@ -2147,8 +2147,8 @@ s32 Math3D_YZInSphere(Sphere16* sphere, f32 y, f32 z) { return false; } -void Math3D_DrawSphere(GlobalContext* globalCtx, Sphere16* sph) { +void Math3D_DrawSphere(PlayState* play, Sphere16* sph) { } -void Math3D_DrawCylinder(GlobalContext* globalCtx, Cylinder16* cyl) { +void Math3D_DrawCylinder(PlayState* play, Cylinder16* cyl) { } diff --git a/soh/src/code/z_actor.c b/soh/src/code/z_actor.c index d3dbf9216..3d8ef6753 100644 --- a/soh/src/code/z_actor.c +++ b/soh/src/code/z_actor.c @@ -84,7 +84,7 @@ void ActorShape_Init(ActorShape* shape, f32 yOffset, ActorShadowFunc shadowDraw, shape->shadowAlpha = 255; } -void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gfx* dlist, Color_RGBA8* color) { +void ActorShadow_Draw(Actor* actor, Lights* lights, PlayState* play, Gfx* dlist, Color_RGBA8* color) { f32 temp1; f32 temp2; MtxF sp60; @@ -93,7 +93,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf temp1 = actor->world.pos.y - actor->floorHeight; if (temp1 >= -50.0f && temp1 < 500.0f) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -120,35 +120,35 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf temp2 = (1.0f - (temp1 * (1.0f / 350))) * actor->shape.shadowScale; Matrix_Scale(actor->scale.x * temp2, 1.0f, actor->scale.z * temp2, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } } -void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, NULL); +void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play) { + ActorShadow_Draw(actor, lights, play, gCircleShadowDL, NULL); } -void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, PlayState* play) { static Color_RGBA8 white = { 255, 255, 255, 255 }; - ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, &white); + ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &white); } -void ActorShadow_DrawHorse(Actor* actor, Lights* lights, GlobalContext* globalCtx) { - ActorShadow_Draw(actor, lights, globalCtx, gHorseShadowDL, NULL); +void ActorShadow_DrawHorse(Actor* actor, Lights* lights, PlayState* play) { + ActorShadow_Draw(actor, lights, play, gHorseShadowDL, NULL); } -void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3, f32 arg4, f32 arg5, f32 arg6) { +void ActorShadow_DrawFoot(PlayState* play, Light* light, MtxF* arg2, s32 arg3, f32 arg4, f32 arg5, f32 arg6) { s32 pad1; f32 sp58; s32 pad2[2]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u32)(((arg3 * 0.00005f) > 1.0f ? 1.0f : (arg3 * 0.00005f)) * arg4) & 0xFF); @@ -160,14 +160,14 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3 Matrix_RotateY(sp58, MTXMODE_APPLY); Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx) { +void ActorShadow_DrawFeet(Actor* actor, Lights* lights, PlayState* play) { f32 distToFloor = actor->world.pos.y - actor->floorHeight; if (distToFloor > 20.0f) { @@ -178,7 +178,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx actor->shape.shadowScale *= 0.3f; alphaRatio = (distToFloor - 20.0f) * 0.02f; actor->shape.shadowAlpha = (f32)actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f); - ActorShadow_DrawCircle(actor, lights, globalCtx); + ActorShadow_DrawCircle(actor, lights, play); actor->shape.shadowScale = shadowScale; actor->shape.shadowAlpha = shadowAlpha; } @@ -200,7 +200,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx Vec3f* feetPosPtr = actor->shape.feetPos; f32* floorHeightPtr = floorHeight; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -208,7 +208,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx for (i = 0; i < 2; i++) { feetPosPtr->y += 50.0f; - *floorHeightPtr = func_800BFCB8(globalCtx, &floorMtx, feetPosPtr); + *floorHeightPtr = func_800BFCB8(play, &floorMtx, feetPosPtr); feetPosPtr->y -= 50.0f; actor->shape.feetFloorFlags <<= 1; distToFloor = feetPosPtr->y - *floorHeightPtr; @@ -231,7 +231,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx (lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS(lightPtr->l.dir[1]); if (lightNum > 0) { lightNumMax += lightNum; - ActorShadow_DrawFoot(globalCtx, lightPtr, &floorMtx, lightNum, shadowAlpha, shadowScaleX, + ActorShadow_DrawFoot(play, lightPtr, &floorMtx, lightNum, shadowAlpha, shadowScaleX, shadowScaleZ); } } @@ -244,7 +244,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx ((lightPtr->l.col[0] + lightPtr->l.col[1] + lightPtr->l.col[2]) * ABS(lightPtr->l.dir[1])) - (lightNumMax * 8); if (lightNum > 0) { - ActorShadow_DrawFoot(globalCtx, lightPtr, &floorMtx, lightNum, shadowAlpha, shadowScaleX, + ActorShadow_DrawFoot(play, lightPtr, &floorMtx, lightNum, shadowAlpha, shadowScaleX, shadowScaleZ); } } @@ -267,7 +267,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -280,8 +280,8 @@ void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* lef } } -void func_8002BE04(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3); +void func_8002BE04(PlayState* play, Vec3f* arg1, Vec3f* arg2, f32* arg3) { + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg1, arg2, arg3); *arg3 = (*arg3 < 1.0f) ? 1.0f : (1.0f / *arg3); } @@ -312,12 +312,12 @@ void func_8002BE64(TargetContext* targetCtx, s32 index, f32 arg2, f32 arg3, f32 targetCtx->arr_50[index].unk_0C = targetCtx->unk_44; } -void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, GlobalContext* globalCtx) { +void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, PlayState* play) { TargetContextEntry* entry; NaviColor* naviColor; s32 i; - Math_Vec3f_Copy(&targetCtx->targetCenterPos, &globalCtx->view.eye); + Math_Vec3f_Copy(&targetCtx->targetCenterPos, &play->view.eye); targetCtx->unk_44 = 500.0f; targetCtx->unk_48 = 0x100; @@ -333,7 +333,7 @@ void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, GlobalContext* g } } -void func_8002BF60(TargetContext* targetCtx, Actor* actor, s32 actorCategory, GlobalContext* globalCtx) { +void func_8002BF60(TargetContext* targetCtx, Actor* actor, s32 actorCategory, PlayState* play) { NaviColor* naviColor = &sNaviColorList[actorCategory]; Color_RGB8 customInnerNaviColor; Color_RGB8 customOuterNaviColor; @@ -393,7 +393,7 @@ void func_8002BF60(TargetContext* targetCtx, Actor* actor, s32 actorCategory, Gl targetCtx->naviOuter.a = naviColor->outer.a; } -void func_8002C0C0(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) { +void func_8002C0C0(TargetContext* targetCtx, Actor* actor, PlayState* play) { targetCtx->arrowPointedActor = NULL; targetCtx->targetedActor = NULL; targetCtx->unk_40 = 0.0f; @@ -401,14 +401,14 @@ void func_8002C0C0(TargetContext* targetCtx, Actor* actor, GlobalContext* global targetCtx->bgmEnemy = NULL; targetCtx->unk_4B = 0; targetCtx->unk_4C = 0; - func_8002BF60(targetCtx, actor, actor->category, globalCtx); - func_8002BE98(targetCtx, actor->category, globalCtx); + func_8002BF60(targetCtx, actor, actor->category, play); + func_8002BE98(targetCtx, actor->category, play); } -void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { +void func_8002C124(TargetContext* targetCtx, PlayState* play) { Actor* actor = targetCtx->targetedActor; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (targetCtx->unk_48 != 0) { TargetContextEntry* entry; @@ -425,7 +425,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { s32 i; FrameInterpolation_RecordOpenChild(actor, 0); - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); spCE = 0xFF; var1 = 1.0f; @@ -447,7 +447,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { spCE = targetCtx->unk_48; } - func_8002BE04(globalCtx, &targetCtx->targetCenterPos, &spBC, &spB4); + func_8002BE04(play, &targetCtx->targetCenterPos, &spBC, &spB4); spBC.x = (160 * (spBC.x * spB4)) * var1; spBC.x = CLAMP(spBC.x, -320.0f, 320.0f); @@ -488,7 +488,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { Matrix_RotateZ(M_PI / 2, MTXMODE_APPLY); Matrix_Push(); Matrix_Translate(entry->unk_0C, entry->unk_0C, 0.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); Matrix_Pop(); @@ -513,20 +513,20 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { Matrix_Translate(actor->focus.pos.x, actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y) + 17.0f, actor->focus.pos.z, MTXMODE_NEW); - Matrix_RotateY((f32)((u16)(globalCtx->gameplayFrames * 3000)) * (M_PI / 0x8000), MTXMODE_APPLY); + Matrix_RotateY((f32)((u16)(play->gameplayFrames * 3000)) * (M_PI / 0x8000), MTXMODE_APPLY); Matrix_Scale((iREG(27) + 35) / 1000.0f, (iREG(28) + 60) / 1000.0f, (iREG(29) + 50) / 1000.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, naviColor->inner.r, naviColor->inner.g, naviColor->inner.b, 255); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); FrameInterpolation_RecordCloseChild(); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, GlobalContext* globalCtx) { +void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, PlayState* play) { s32 pad; Actor* unkActor; s32 actorCategory; @@ -545,7 +545,7 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl if ((player->unk_664 != NULL) && (player->unk_84B[player->unk_846] == 2)) { targetCtx->unk_94 = NULL; } else { - func_80032AF0(globalCtx, &globalCtx->actorCtx, &unkActor, player); + func_80032AF0(play, &play->actorCtx, &unkActor, player); targetCtx->unk_94 = unkActor; } @@ -581,11 +581,11 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl targetCtx->naviRefPos.y += temp3 * temp1; targetCtx->naviRefPos.z += temp4 * temp1; } else { - func_8002BF60(targetCtx, unkActor, actorCategory, globalCtx); + func_8002BF60(targetCtx, unkActor, actorCategory, play); } if ((actorArg != NULL) && (targetCtx->unk_4B == 0)) { - func_8002BE04(globalCtx, &actorArg->focus.pos, &sp50, &sp4C); + func_8002BE04(play, &actorArg->focus.pos, &sp50, &sp4C); if (((sp50.z <= 0.0f) || (1.0f <= fabsf(sp50.x * sp4C))) || (1.0f <= fabsf(sp50.y * sp4C))) { actorArg = NULL; } @@ -593,7 +593,7 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl if (actorArg != NULL) { if (actorArg != targetCtx->targetedActor) { - func_8002BE98(targetCtx, actorArg->category, globalCtx); + func_8002BE98(targetCtx, actorArg->category, play); targetCtx->targetedActor = actorArg; if (actorArg->id == ACTOR_EN_BOOM) { @@ -628,156 +628,156 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl /** * Tests if current scene switch flag is set. */ -s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) { +s32 Flags_GetSwitch(PlayState* play, s32 flag) { if (flag < 0x20) { - return globalCtx->actorCtx.flags.swch & (1 << flag); + return play->actorCtx.flags.swch & (1 << flag); } else { - return globalCtx->actorCtx.flags.tempSwch & (1 << (flag - 0x20)); + return play->actorCtx.flags.tempSwch & (1 << (flag - 0x20)); } } /** * Sets current scene switch flag. */ -void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag) { +void Flags_SetSwitch(PlayState* play, s32 flag) { if (flag < 0x20) { - globalCtx->actorCtx.flags.swch |= (1 << flag); + play->actorCtx.flags.swch |= (1 << flag); } else { - globalCtx->actorCtx.flags.tempSwch |= (1 << (flag - 0x20)); + play->actorCtx.flags.tempSwch |= (1 << (flag - 0x20)); } } /** * Unsets current scene switch flag. */ -void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) { +void Flags_UnsetSwitch(PlayState* play, s32 flag) { if (flag < 0x20) { - globalCtx->actorCtx.flags.swch &= ~(1 << flag); + play->actorCtx.flags.swch &= ~(1 << flag); } else { - globalCtx->actorCtx.flags.tempSwch &= ~(1 << (flag - 0x20)); + play->actorCtx.flags.tempSwch &= ~(1 << (flag - 0x20)); } } /** * Tests if unknown flag is set. */ -s32 Flags_GetUnknown(GlobalContext* globalCtx, s32 flag) { +s32 Flags_GetUnknown(PlayState* play, s32 flag) { if (flag < 0x20) { - return globalCtx->actorCtx.flags.unk0 & (1 << flag); + return play->actorCtx.flags.unk0 & (1 << flag); } else { - return globalCtx->actorCtx.flags.unk1 & (1 << (flag - 0x20)); + return play->actorCtx.flags.unk1 & (1 << (flag - 0x20)); } } /** * Sets unknown flag. */ -void Flags_SetUnknown(GlobalContext* globalCtx, s32 flag) { +void Flags_SetUnknown(PlayState* play, s32 flag) { if (flag < 0x20) { - globalCtx->actorCtx.flags.unk0 |= (1 << flag); + play->actorCtx.flags.unk0 |= (1 << flag); } else { - globalCtx->actorCtx.flags.unk1 |= (1 << (flag - 0x20)); + play->actorCtx.flags.unk1 |= (1 << (flag - 0x20)); } } /** * Unsets unknown flag. */ -void Flags_UnsetUnknown(GlobalContext* globalCtx, s32 flag) { +void Flags_UnsetUnknown(PlayState* play, s32 flag) { if (flag < 0x20) { - globalCtx->actorCtx.flags.unk0 &= ~(1 << flag); + play->actorCtx.flags.unk0 &= ~(1 << flag); } else { - globalCtx->actorCtx.flags.unk1 &= ~(1 << (flag - 0x20)); + play->actorCtx.flags.unk1 &= ~(1 << (flag - 0x20)); } } /** * Tests if current scene chest flag is set. */ -s32 Flags_GetTreasure(GlobalContext* globalCtx, s32 flag) { - return globalCtx->actorCtx.flags.chest & (1 << flag); +s32 Flags_GetTreasure(PlayState* play, s32 flag) { + return play->actorCtx.flags.chest & (1 << flag); } /** * Sets current scene chest flag. */ -void Flags_SetTreasure(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.chest |= (1 << flag); +void Flags_SetTreasure(PlayState* play, s32 flag) { + play->actorCtx.flags.chest |= (1 << flag); } /** * Tests if current scene clear flag is set. */ -s32 Flags_GetClear(GlobalContext* globalCtx, s32 flag) { - return globalCtx->actorCtx.flags.clear & (1 << flag); +s32 Flags_GetClear(PlayState* play, s32 flag) { + return play->actorCtx.flags.clear & (1 << flag); } /** * Sets current scene clear flag. */ -void Flags_SetClear(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.clear |= (1 << flag); +void Flags_SetClear(PlayState* play, s32 flag) { + play->actorCtx.flags.clear |= (1 << flag); } /** * Unsets current scene clear flag. */ -void Flags_UnsetClear(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.clear &= ~(1 << flag); +void Flags_UnsetClear(PlayState* play, s32 flag) { + play->actorCtx.flags.clear &= ~(1 << flag); } /** * Tests if current scene temp clear flag is set. */ -s32 Flags_GetTempClear(GlobalContext* globalCtx, s32 flag) { - return globalCtx->actorCtx.flags.tempClear & (1 << flag); +s32 Flags_GetTempClear(PlayState* play, s32 flag) { + return play->actorCtx.flags.tempClear & (1 << flag); } /** * Sets current scene temp clear flag. */ -void Flags_SetTempClear(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.tempClear |= (1 << flag); +void Flags_SetTempClear(PlayState* play, s32 flag) { + play->actorCtx.flags.tempClear |= (1 << flag); } /** * Unsets current scene temp clear flag. */ -void Flags_UnsetTempClear(GlobalContext* globalCtx, s32 flag) { - globalCtx->actorCtx.flags.tempClear &= ~(1 << flag); +void Flags_UnsetTempClear(PlayState* play, s32 flag) { + play->actorCtx.flags.tempClear &= ~(1 << flag); } /** * Tests if current scene collectible flag is set. */ -s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) { +s32 Flags_GetCollectible(PlayState* play, s32 flag) { if (flag < 0x20) { - return globalCtx->actorCtx.flags.collect & (1 << flag); + return play->actorCtx.flags.collect & (1 << flag); } else { - return globalCtx->actorCtx.flags.tempCollect & (1 << (flag - 0x20)); + return play->actorCtx.flags.tempCollect & (1 << (flag - 0x20)); } } /** * Sets current scene collectible flag. */ -void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) { +void Flags_SetCollectible(PlayState* play, s32 flag) { if (flag != 0) { if (flag < 0x20) { - globalCtx->actorCtx.flags.collect |= (1 << flag); + play->actorCtx.flags.collect |= (1 << flag); } else { - globalCtx->actorCtx.flags.tempCollect |= (1 << (flag - 0x20)); + play->actorCtx.flags.tempCollect |= (1 << (flag - 0x20)); } } } -void func_8002CDE4(GlobalContext* globalCtx, TitleCardContext* titleCtx) { +void func_8002CDE4(PlayState* play, TitleCardContext* titleCtx) { titleCtx->durationTimer = titleCtx->delayTimer = titleCtx->intensityR = titleCtx->alpha = 0; titleCtx->durationTimer = titleCtx->delayTimer = titleCtx->intensityG = titleCtx->alpha = 0; titleCtx->durationTimer = titleCtx->delayTimer = titleCtx->intensityB = titleCtx->alpha = 0; } -void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s16 x, s16 y, u8 width, +void TitleCard_InitBossName(PlayState* play, TitleCardContext* titleCtx, void* texture, s16 x, s16 y, u8 width, u8 height, s16 hasTranslation) { if (ResourceMgr_OTRSigCheck(texture)) @@ -794,11 +794,11 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx titleCtx->delayTimer = 0; } -void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, +void TitleCard_InitPlaceName(PlayState* play, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, s32 width, s32 height, s32 delay) { - SceneTableEntry* loadedScene = globalCtx->loadedScene; + SceneTableEntry* loadedScene = play->loadedScene; // size_t size = loadedScene->titleFile.vromEnd - loadedScene->titleFile.vromStart; - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_YDAN: texture = gDekuTreeTitleCardENGTex; break; @@ -1016,7 +1016,7 @@ void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCt titleCtx->delayTimer = delay; } -void TitleCard_Update(GlobalContext* globalCtx, TitleCardContext* titleCtx) { +void TitleCard_Update(PlayState* play, TitleCardContext* titleCtx) { const Color_RGB8 TitleCard_Colors_ori = {255,255,255}; Color_RGB8 TitleCard_Colors = {255,255,255}; if (titleCtx->isBossCard && CVar_GetS32("gHudColors", 1) == 2) {//Bosses cards. @@ -1042,7 +1042,7 @@ void TitleCard_Update(GlobalContext* globalCtx, TitleCardContext* titleCtx) { } } -void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { +void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { s32 width; s32 height; s32 unused; @@ -1083,7 +1083,7 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { titleY = (TitleCard_PosY * 4) - (height * 2); doubleWidth = width * 2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); height = (width * height > 0x1000) ? 0x1000 / width : height; titleSecondY = titleY + (height * 4); @@ -1131,12 +1131,12 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { titleSecondY + (height * 4), G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -s32 func_8002D53C(GlobalContext* globalCtx, TitleCardContext* titleCtx) { - if ((globalCtx->actorCtx.titleCtx.delayTimer != 0) || (globalCtx->actorCtx.titleCtx.alpha != 0)) { +s32 func_8002D53C(PlayState* play, TitleCardContext* titleCtx) { + if ((play->actorCtx.titleCtx.delayTimer != 0) || (play->actorCtx.titleCtx.alpha != 0)) { titleCtx->durationTimer = 0; titleCtx->delayTimer = 0; return false; @@ -1179,11 +1179,11 @@ void Actor_SetScale(Actor* actor, f32 scale) { actor->scale.x = scale; } -void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) { - gSegments[6] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[actor->objBankIndex].segment); +void Actor_SetObjectDependency(PlayState* play, Actor* actor) { + gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[actor->objBankIndex].segment); } -void Actor_Init(Actor* actor, GlobalContext* globalCtx) { +void Actor_Init(Actor* actor, PlayState* play) { Actor_SetWorldToHome(actor); Actor_SetShapeRotToWorld(actor); Actor_SetFocus(actor, 0.0f); @@ -1199,7 +1199,7 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { if (CVar_GetS32("gDisableDrawDistance", 0) != 0 && actor->id != ACTOR_EN_TORCH2 && actor->id != ACTOR_EN_BLKOBJ // Extra check for Dark Link and his room && actor->id != ACTOR_EN_HORSE // Check for Epona, else if we call her she will spawn at the other side of the map + we can hear her during the title screen sequence && actor->id != ACTOR_EN_HORSE_GANON && actor->id != ACTOR_EN_HORSE_ZELDA // check for Zelda's and Ganondorf's horses that will always be scene during cinematic whith camera paning - && (globalCtx->sceneNum != SCENE_DDAN && actor->id != ACTOR_EN_ZF)) { // Check for DC and Lizalfos for the case where the miniboss music would still play under certains conditions and changing room + && (play->sceneNum != SCENE_DDAN && actor->id != ACTOR_EN_ZF)) { // Check for DC and Lizalfos for the case where the miniboss music would still play under certains conditions and changing room actor->uncullZoneForward = 32767.0f; actor->uncullZoneScale = 32767.0f; actor->uncullZoneDownward = 32767.0f; @@ -1207,20 +1207,20 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { CollisionCheck_InitInfo(&actor->colChkInfo); actor->floorBgId = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); - //if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) + //if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { - //Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + //Actor_SetObjectDependency(play, actor); + actor->init(actor, play); actor->init = NULL; } } -void Actor_Destroy(Actor* actor, GlobalContext* globalCtx) { +void Actor_Destroy(Actor* actor, PlayState* play) { ActorOverlay* overlayEntry; char* name; if (actor->destroy != NULL) { - actor->destroy(actor, globalCtx); + actor->destroy(actor, play); actor->destroy = NULL; } else { overlayEntry = actor->overlayEntry; @@ -1369,26 +1369,26 @@ s32 func_8002DD78(Player* player) { return func_8002DD6C(player) && player->unk_834; } -s32 func_8002DDA8(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002DDA8(PlayState* play) { + Player* player = GET_PLAYER(play); return (player->stateFlags1 & 0x800) || func_8002DD78(player); } -s32 func_8002DDE4(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002DDE4(PlayState* play) { + Player* player = GET_PLAYER(play); return player->stateFlags2 & 0x8; } -s32 func_8002DDF4(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002DDF4(PlayState* play) { + Player* player = GET_PLAYER(play); return player->stateFlags2 & 0x1000; } -void func_8002DE04(GlobalContext* globalCtx, Actor* actorA, Actor* actorB) { - ArmsHook* hookshot = (ArmsHook*)Actor_Find(&globalCtx->actorCtx, ACTOR_ARMS_HOOK, ACTORCAT_ITEMACTION); +void func_8002DE04(PlayState* play, Actor* actorA, Actor* actorB) { + ArmsHook* hookshot = (ArmsHook*)Actor_Find(&play->actorCtx, ACTOR_ARMS_HOOK, ACTORCAT_ITEMACTION); hookshot->grabbed = actorB; hookshot->grabbedDistDiff.x = 0.0f; @@ -1398,13 +1398,13 @@ void func_8002DE04(GlobalContext* globalCtx, Actor* actorA, Actor* actorB) { actorA->flags &= ~ACTOR_FLAG_13; } -void func_8002DE74(GlobalContext* globalCtx, Player* player) { - if ((globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && func_800C0CB8(globalCtx)) { - Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, MAIN_CAM), CAM_SET_HORSE); +void func_8002DE74(PlayState* play, Player* player) { + if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_4) && func_800C0CB8(play)) { + Camera_ChangeSetting(Play_GetCamera(play, MAIN_CAM), CAM_SET_HORSE); } } -void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse) { +void Actor_MountHorse(PlayState* play, Player* player, Actor* horse) { player->rideActor = horse; player->stateFlags1 |= 0x800000; horse->child = &player->actor; @@ -1414,12 +1414,12 @@ s32 func_8002DEEC(Player* player) { return (player->stateFlags1 & 0x20000080) || (player->csMode != 0); } -void func_8002DF18(GlobalContext* globalCtx, Player* player) { - func_8006DC68(globalCtx, player); +void func_8002DF18(PlayState* play, Player* player) { + func_8006DC68(play, player); } -s32 func_8002DF38(GlobalContext* globalCtx, Actor* actor, u8 csMode) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002DF38(PlayState* play, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(play); player->csMode = csMode; player->unk_448 = actor; @@ -1428,10 +1428,10 @@ s32 func_8002DF38(GlobalContext* globalCtx, Actor* actor, u8 csMode) { return true; } -s32 func_8002DF54(GlobalContext* globalCtx, Actor* actor, u8 csMode) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002DF54(PlayState* play, Actor* actor, u8 csMode) { + Player* player = GET_PLAYER(play); - func_8002DF38(globalCtx, actor, csMode); + func_8002DF38(play, actor, csMode); player->unk_46A = 1; return true; @@ -1451,8 +1451,8 @@ void func_8002DFA4(DynaPolyActor* dynaActor, f32 arg1, s16 arg2) { * Chcek if the player is facing the specified actor. * The maximum angle difference that qualifies as "facing" is specified by `maxAngle`. */ -s32 Player_IsFacingActor(Actor* actor, s16 maxAngle, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 Player_IsFacingActor(Actor* actor, s16 maxAngle, PlayState* play) { + Player* player = GET_PLAYER(play); s16 yawDiff = (s16)(actor->yawTowardsPlayer + 0x8000) - player->actor.shape.rot.y; if (ABS(yawDiff) < maxAngle) { @@ -1559,14 +1559,14 @@ s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) { return true; } -s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3) { +s32 func_8002E2AC(PlayState* play, Actor* actor, Vec3f* arg2, s32 arg3) { f32 floorHeightDiff; s32 floorBgId; arg2->y += 50.0f; actor->floorHeight = - BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId, actor, arg2); + BgCheck_EntityRaycastFloor5(play, &play->colCtx, &actor->floorPoly, &floorBgId, actor, arg2); actor->bgCheckFlags &= ~0x0086; if (actor->floorHeight <= BGCHECK_Y_MIN) { @@ -1602,11 +1602,11 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3) } actor->bgCheckFlags |= 0x1; - func_80043334(&globalCtx->colCtx, actor, actor->floorBgId); + func_80043334(&play->colCtx, actor, actor->floorBgId); } } else { // actor is above ground if ((actor->bgCheckFlags & 0x1) && (floorHeightDiff >= -11.0f)) { - func_80043334(&globalCtx->colCtx, actor, actor->floorBgId); + func_80043334(&play->colCtx, actor, actor->floorBgId); } return func_8002E234(actor, floorHeightDiff, arg3); @@ -1615,7 +1615,7 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3) return true; } -void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, +void Actor_UpdateBgCheckInfo(PlayState* play, Actor* actor, f32 wallCheckHeight, f32 wallCheckRadius, f32 ceilingCheckHeight, s32 flags) { f32 sp74; s32 pad; @@ -1630,15 +1630,15 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe sp74 = actor->world.pos.y - actor->prevPos.y; if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) { - func_800433A4(&globalCtx->colCtx, actor->floorBgId, actor); + func_800433A4(&play->colCtx, actor->floorBgId, actor); } if (flags & 1) { if ((!(flags & 0x80) && - BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius, + BgCheck_EntitySphVsWall3(&play->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius, &actor->wallPoly, &bgId, actor, wallCheckHeight)) || ((flags & 0x80) && - BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius, + BgCheck_EntitySphVsWall4(&play->colCtx, &sp64, &actor->world.pos, &actor->prevPos, wallCheckRadius, &actor->wallPoly, &bgId, actor, wallCheckHeight))) { wallPoly = actor->wallPoly; Math_Vec3f_Copy(&actor->world.pos, &sp64); @@ -1655,7 +1655,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe if (flags & 2) { sp64.y = actor->prevPos.y + 10.0f; - if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp58, &sp64, (ceilingCheckHeight + sp74) - 10.0f, + if (BgCheck_EntityCheckCeiling(&play->colCtx, &sp58, &sp64, (ceilingCheckHeight + sp74) - 10.0f, &sCurCeilingPoly, &sCurCeilingBgId, actor)) { actor->bgCheckFlags |= 0x10; actor->world.pos.y = (sp58 + sp74) - 10.0f; @@ -1666,9 +1666,9 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe if (flags & 4) { sp64.y = actor->prevPos.y; - func_8002E2AC(globalCtx, actor, &sp64, flags); + func_8002E2AC(play, actor, &sp64, flags); waterBoxYSurface = actor->world.pos.y; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, + if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &waterBoxYSurface, &waterBox)) { actor->yDistToWater = waterBoxYSurface - actor->world.pos.y; if (actor->yDistToWater < 0.0f) { @@ -1680,9 +1680,9 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe ripplePos.x = actor->world.pos.x; ripplePos.y = waterBoxYSurface; ripplePos.z = actor->world.pos.z; - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 0); - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 4); - EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 8); + EffectSsGRipple_Spawn(play, &ripplePos, 100, 500, 0); + EffectSsGRipple_Spawn(play, &ripplePos, 100, 500, 4); + EffectSsGRipple_Spawn(play, &ripplePos, 100, 500, 8); } } actor->bgCheckFlags |= 0x20; @@ -1746,60 +1746,60 @@ Hilite* func_8002EB44(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsContex return hilite; } -void func_8002EBCC(Actor* actor, GlobalContext* globalCtx, s32 flag) { +void func_8002EBCC(Actor* actor, PlayState* play, s32 flag) { Hilite* hilite; Vec3f lightDir; Gfx* displayListHead; Gfx* displayList; - lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; - lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; - lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + lightDir.x = play->envCtx.dirLight1.params.dir.x; + lightDir.y = play->envCtx.dirLight1.params.dir.y; + lightDir.z = play->envCtx.dirLight1.params.dir.z; if (HREG(80) == 6) { - osSyncPrintf("z_actor.c 3637 game_play->view.eye=[%f(%f) %f %f]\n", globalCtx->view.eye.x, - globalCtx->view.eye.y, globalCtx->view.eye.z); + osSyncPrintf("z_actor.c 3637 game_play->view.eye=[%f(%f) %f %f]\n", play->view.eye.x, + play->view.eye.y, play->view.eye.z); } - hilite = func_8002EABC(&actor->world.pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + hilite = func_8002EABC(&actor->world.pos, &play->view.eye, &lightDir, play->state.gfxCtx); if (flag != 0) { - displayList = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + displayList = Graph_Alloc(play->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); gSPEndDisplayList(displayListHead); gSPSegment(POLY_OPA_DISP++, 0x07, displayList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_8002ED80(Actor* actor, GlobalContext* globalCtx, s32 flag) { +void func_8002ED80(Actor* actor, PlayState* play, s32 flag) { Hilite* hilite; Vec3f lightDir; Gfx* displayListHead; Gfx* displayList; - lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; - lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; - lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + lightDir.x = play->envCtx.dirLight1.params.dir.x; + lightDir.y = play->envCtx.dirLight1.params.dir.y; + lightDir.z = play->envCtx.dirLight1.params.dir.z; - hilite = func_8002EB44(&actor->world.pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + hilite = func_8002EB44(&actor->world.pos, &play->view.eye, &lightDir, play->state.gfxCtx); if (flag != 0) { - displayList = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx)); + displayList = Graph_Alloc(play->state.gfxCtx, 2 * sizeof(Gfx)); displayListHead = displayList; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); gSPEndDisplayList(displayListHead); gSPSegment(POLY_XLU_DISP++, 0x07, displayList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -1887,7 +1887,7 @@ s32 func_8002F0C8(Actor* actor, Player* player, s32 flag) { return false; } -u32 Actor_ProcessTalkRequest(Actor* actor, GlobalContext* globalCtx) { +u32 Actor_ProcessTalkRequest(Actor* actor, PlayState* play) { if (actor->flags & ACTOR_FLAG_8) { actor->flags &= ~ACTOR_FLAG_8; return true; @@ -1896,11 +1896,11 @@ u32 Actor_ProcessTalkRequest(Actor* actor, GlobalContext* globalCtx) { return false; } -s32 func_8002F1C4(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, u32 exchangeItemId) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002F1C4(Actor* actor, PlayState* play, f32 arg2, f32 arg3, u32 exchangeItemId) { + Player* player = GET_PLAYER(play); // This is convoluted but it seems like it must be a single if statement to match - if ((player->actor.flags & ACTOR_FLAG_8) || ((exchangeItemId != EXCH_ITEM_NONE) && Player_InCsMode(globalCtx)) || + if ((player->actor.flags & ACTOR_FLAG_8) || ((exchangeItemId != EXCH_ITEM_NONE) && Player_InCsMode(play)) || (!actor->isTargeted && ((arg3 < fabsf(actor->yDistToPlayer)) || (player->targetActorDistance < actor->xzDistToPlayer) || (arg2 < actor->xzDistToPlayer)))) { @@ -1914,44 +1914,44 @@ s32 func_8002F1C4(Actor* actor, GlobalContext* globalCtx, f32 arg2, f32 arg3, u3 return true; } -s32 func_8002F298(Actor* actor, GlobalContext* globalCtx, f32 arg2, u32 exchangeItemId) { - return func_8002F1C4(actor, globalCtx, arg2, arg2, exchangeItemId); +s32 func_8002F298(Actor* actor, PlayState* play, f32 arg2, u32 exchangeItemId) { + return func_8002F1C4(actor, play, arg2, arg2, exchangeItemId); } -s32 func_8002F2CC(Actor* actor, GlobalContext* globalCtx, f32 arg2) { - return func_8002F298(actor, globalCtx, arg2, EXCH_ITEM_NONE); +s32 func_8002F2CC(Actor* actor, PlayState* play, f32 arg2) { + return func_8002F298(actor, play, arg2, EXCH_ITEM_NONE); } -s32 func_8002F2F4(Actor* actor, GlobalContext* globalCtx) { +s32 func_8002F2F4(Actor* actor, PlayState* play) { f32 var1 = 50.0f + actor->colChkInfo.cylRadius; - return func_8002F2CC(actor, globalCtx, var1); + return func_8002F2CC(actor, play, var1); } -u32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) { - if (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_CLOSING) { +u32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) { + if (Message_GetState(&play->msgCtx) == TEXT_STATE_CLOSING) { return true; } else { return false; } } -s8 func_8002F368(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s8 func_8002F368(PlayState* play) { + Player* player = GET_PLAYER(play); return player->exchangeItemId; } -void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) { +void Actor_GetScreenPos(PlayState* play, Actor* actor, s16* x, s16* y) { Vec3f projectedPos; f32 w; - func_8002BE04(globalCtx, &actor->focus.pos, &projectedPos, &w); + func_8002BE04(play, &actor->focus.pos, &projectedPos, &w); *x = projectedPos.x * w * (SCREEN_WIDTH / 2) + (SCREEN_WIDTH / 2); *y = projectedPos.y * w * -(SCREEN_HEIGHT / 2) + (SCREEN_HEIGHT / 2); } -u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { +u32 Actor_HasParent(Actor* actor, PlayState* play) { if (actor->parent != NULL) { return true; } else { @@ -1964,12 +1964,12 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { * where Link holds an item over his head. This function does not require an actor for giving * the player an item, instead setting the player as their own interactRangeActor and getItemDirection. * - * \param globalCtx the Global Context + * \param play the Global Context * \param getItemEntry the GetItemEntry for the item you want the player to receive. * \return true if the player can receive an item, false if not. */ -s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntry) { - Player* player = GET_PLAYER(globalCtx); +s32 GiveItemEntryWithoutActor(PlayState* play, GetItemEntry getItemEntry) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { if (((player->heldActor != NULL) && ((getItemEntry.getItemId > GI_NONE) && (getItemEntry.getItemId < GI_MAX)) || @@ -1996,7 +1996,7 @@ s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntr * * \param actor the actor link is receiving an item from. Will usually be a chest but can also * be an npc. - * \param globalCtx the Global Context + * \param play the Global Context * \param getItemEntry the GetItemEntry for the item you want the player to receive. * \param xzRange the distance on the x and z axes that the player can be from the target * actor to receive the item. @@ -2004,8 +2004,8 @@ s32 GiveItemEntryWithoutActor(GlobalContext* globalCtx, GetItemEntry getItemEntr * to receive the item. * \return true if the player can receive an item, false if not. */ -s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) { - Player* player = GET_PLAYER(globalCtx); +s32 GiveItemEntryFromActor(Actor* actor, PlayState* play, GetItemEntry getItemEntry, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { if ((((player->heldActor != NULL) || (actor == player->targetActor)) && @@ -2036,17 +2036,17 @@ s32 GiveItemEntryFromActor(Actor* actor, GlobalContext* globalCtx, GetItemEntry * that supplies a fixed xzRange of 50.0f and a fixed yRange of 10.0f. * * \param actor the target actor that link is receiving an item from. - * \param globalCtx the Global Context + * \param play the Global Context * \param getItemEntry the GetItemEntry for the item you want the player to receive. */ -void GiveItemEntryFromActorWithFixedRange(Actor* actor, GlobalContext* globalCtx, GetItemEntry getItemEntry) { - GiveItemEntryFromActor(actor, globalCtx, getItemEntry, 50.0f, 10.0f); +void GiveItemEntryFromActorWithFixedRange(Actor* actor, PlayState* play, GetItemEntry getItemEntry) { + GiveItemEntryFromActor(actor, play, getItemEntry, 50.0f, 10.0f); } // TODO: Rename to GiveItemIdFromActor or similar // If you're doing something for randomizer, you're probably looking for GiveItemEntryFromActor -s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002F434(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) { if ((((player->heldActor != NULL) || (actor == player->targetActor)) && @@ -2071,15 +2071,15 @@ s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzR // TODO: Rename to GiveItemIdFromActorWithFixedRange or similar // If you're doing something for randomizer, you're probably looking for GiveItemEntryFromActorWithFixedRange -void func_8002F554(Actor* actor, GlobalContext* globalCtx, s32 getItemId) { - func_8002F434(actor, globalCtx, getItemId, 50.0f, 10.0f); +void func_8002F554(Actor* actor, PlayState* play, s32 getItemId) { + func_8002F434(actor, play, getItemId, 50.0f, 10.0f); } -void func_8002F580(Actor* actor, GlobalContext* globalCtx) { - func_8002F554(actor, globalCtx, GI_NONE); +void func_8002F580(Actor* actor, PlayState* play) { + func_8002F554(actor, play, GI_NONE); } -u32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { +u32 Actor_HasNoParent(Actor* actor, PlayState* play) { if (actor->parent == NULL) { return true; } else { @@ -2087,7 +2087,7 @@ u32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) { } } -void func_8002F5C4(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { +void func_8002F5C4(Actor* actorA, Actor* actorB, PlayState* play) { Actor* parent = actorA->parent; if (parent->id == ACTOR_PLAYER) { @@ -2102,15 +2102,15 @@ void func_8002F5C4(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) { actorA->parent = NULL; } -void func_8002F5F0(Actor* actor, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8002F5F0(Actor* actor, PlayState* play) { + Player* player = GET_PLAYER(play); if (actor->xyzDistToPlayerSq < player->unk_6A4) { player->unk_6A4 = actor->xyzDistToPlayerSq; } } -s32 Actor_IsMounted(GlobalContext* globalCtx, Actor* horse) { +s32 Actor_IsMounted(PlayState* play, Actor* horse) { if (horse->child != NULL) { return true; } else { @@ -2118,8 +2118,8 @@ s32 Actor_IsMounted(GlobalContext* globalCtx, Actor* horse) { } } -u32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) { - Player* player = GET_PLAYER(globalCtx); +u32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide) { + Player* player = GET_PLAYER(play); if (!(player->stateFlags1 & 0x003C7880)) { player->rideActor = horse; @@ -2130,7 +2130,7 @@ u32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) { return false; } -s32 Actor_NotMounted(GlobalContext* globalCtx, Actor* horse) { +s32 Actor_NotMounted(PlayState* play, Actor* horse) { if (horse->child == NULL) { return true; } else { @@ -2138,8 +2138,8 @@ s32 Actor_NotMounted(GlobalContext* globalCtx, Actor* horse) { } } -void func_8002F698(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) { - Player* player = GET_PLAYER(globalCtx); +void func_8002F698(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) { + Player* player = GET_PLAYER(play); player->unk_8A0 = arg6; player->unk_8A1 = arg5; @@ -2148,20 +2148,20 @@ void func_8002F698(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f player->unk_8A8 = arg4; } -void func_8002F6D4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { - func_8002F698(globalCtx, actor, arg2, arg3, arg4, 2, arg5); +void func_8002F6D4(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { + func_8002F698(play, actor, arg2, arg3, arg4, 2, arg5); } -void func_8002F71C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { - func_8002F6D4(globalCtx, actor, arg2, arg3, arg4, 0); +void func_8002F71C(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_8002F6D4(play, actor, arg2, arg3, arg4, 0); } -void func_8002F758(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { - func_8002F698(globalCtx, actor, arg2, arg3, arg4, 1, arg5); +void func_8002F758(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) { + func_8002F698(play, actor, arg2, arg3, arg4, 1, arg5); } -void func_8002F7A0(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { - func_8002F758(globalCtx, actor, arg2, arg3, arg4, 0); +void func_8002F7A0(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) { + func_8002F758(play, actor, arg2, arg3, arg4, 0); } void func_8002F7DC(Actor* actor, u16 sfxId) { @@ -2172,7 +2172,7 @@ void Audio_PlayActorSound2(Actor* actor, u16 sfxId) { func_80078914(&actor->projectedPos, sfxId); } -void func_8002F850(GlobalContext* globalCtx, Actor* actor) { +void func_8002F850(PlayState* play, Actor* actor) { s32 sfxId; if (actor->bgCheckFlags & 0x20) { @@ -2182,7 +2182,7 @@ void func_8002F850(GlobalContext* globalCtx, Actor* actor) { sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; } } else { - sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, actor->floorPoly, actor->floorBgId); + sfxId = SurfaceType_GetSfx(&play->colCtx, actor->floorPoly, actor->floorBgId); } func_80078914(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); @@ -2225,10 +2225,10 @@ void func_8002F994(Actor* actor, s32 arg1) { } // Tests if something hit Jabu Jabu surface, displaying hit splash and playing sfx if true -s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) { - if (func_80041D4C(&globalCtx->colCtx, poly, bgId) == 8) { - globalCtx->roomCtx.unk_74[0] = 1; - CollisionCheck_BlueBlood(globalCtx, NULL, pos); +s32 func_8002F9EC(PlayState* play, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) { + if (func_80041D4C(&play->colCtx, poly, bgId) == 8) { + play->roomCtx.unk_74[0] = 1; + CollisionCheck_BlueBlood(play, NULL, pos); Audio_PlayActorSound2(actor, NA_SE_IT_WALL_HIT_BUYO); return true; } @@ -2242,7 +2242,7 @@ LightNode* D_8015BC10; s32 D_8015BC14; f32 D_8015BC18; -void func_8002FA60(GlobalContext* globalCtx) { +void func_8002FA60(PlayState* play) { Vec3f lightPos; if (gSaveContext.fw.set) { @@ -2269,16 +2269,16 @@ void func_8002FA60(GlobalContext* globalCtx) { Lights_PointNoGlowSetInfo(&D_8015BC00, lightPos.x, lightPos.y, lightPos.z, 0xFF, 0xFF, 0xFF, -1); - D_8015BC10 = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &D_8015BC00); + D_8015BC10 = LightContext_InsertLight(play, &play->lightCtx, &D_8015BC00); D_8015BC14 = 0; D_8015BC18 = 0.0f; } -void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { +void Actor_DrawFaroresWindPointer(PlayState* play) { s32 lightRadius = -1; s32 params; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); params = gSaveContext.respawn[RESPAWN_MODE_TOP].data; @@ -2333,7 +2333,7 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { effectPos.y = curPos->y + 80.0f + (6.0f * Rand_ZeroOne()); effectPos.z = curPos->z + Rand_CenteredFloat(6.0f); - EffectSsKiraKira_SpawnDispersed(globalCtx, &effectPos, &effectVel, &effectAccel, &effectPrimCol, + EffectSsKiraKira_SpawnDispersed(play, &effectPos, &effectVel, &effectAccel, &effectPrimCol, &effectEnvCol, 1000, 16); if (D_8015BC18 == 0.0f) { @@ -2352,9 +2352,9 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { f32 diff; if (nextRatio > 0.0f) { - eye.x = globalCtx->view.eye.x; - eye.y = globalCtx->view.eye.y - yOffset; - eye.z = globalCtx->view.eye.z; + eye.x = play->view.eye.x; + eye.y = play->view.eye.y - yOffset; + eye.z = play->view.eye.z; diff = Math_Vec3f_DistXYZAndStoreDiff(&eye, curPos, &dist); diff = (diff * (nextRatio / curRatio)) / diff; curPos->x = eye.x + (dist.x * diff); @@ -2378,10 +2378,10 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { lightRadius = 500.0f * ratio; - if ((globalCtx->csCtx.state == CS_STATE_IDLE) && + if ((play->csCtx.state == CS_STATE_IDLE) && (((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex) == ((void)0, gSaveContext.entranceIndex)) && - (((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].roomIndex) == globalCtx->roomCtx.curRoom.num)) { + (((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].roomIndex) == play->roomCtx.curRoom.num)) { f32 scale = 0.025f * ratio; POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 0x19); @@ -2390,22 +2390,22 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y) + yOffset, ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z), MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_Push(); gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 128, 128, 255, 255, 200, alpha); gDPSetEnvColor(POLY_XLU_DISP++, 100, 200, 0, 255); - Matrix_RotateZ(((globalCtx->gameplayFrames * 1500) & 0xFFFF) * M_PI / 32768.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Matrix_RotateZ(((play->gameplayFrames * 1500) & 0xFFFF) * M_PI / 32768.0f, MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); Matrix_Pop(); - Matrix_RotateZ(~((globalCtx->gameplayFrames * 1200) & 0xFFFF) * M_PI / 32768.0f, MTXMODE_APPLY); + Matrix_RotateZ(~((play->gameplayFrames * 1200) & 0xFFFF) * M_PI / 32768.0f, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } @@ -2415,33 +2415,33 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z), 255, 255, 255, lightRadius); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80030488(GlobalContext* globalCtx) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, D_8015BC10); +void func_80030488(PlayState* play) { + LightContext_RemoveLight(play, &play->lightCtx, D_8015BC10); } -void Actor_DisableLens(GlobalContext* globalCtx) { - if (globalCtx->actorCtx.lensActive) { - globalCtx->actorCtx.lensActive = false; - func_800876C8(globalCtx); +void Actor_DisableLens(PlayState* play) { + if (play->actorCtx.lensActive) { + play->actorCtx.lensActive = false; + func_800876C8(play); } } // Actor_InitContext -void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry) { +void func_800304DC(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry) { ActorOverlay* overlayEntry; SavedSceneFlags* savedSceneFlags; s32 i; - savedSceneFlags = &gSaveContext.sceneFlags[globalCtx->sceneNum]; + savedSceneFlags = &gSaveContext.sceneFlags[play->sceneNum]; memset(actorCtx, 0, sizeof(*actorCtx)); ActorOverlayTable_Init(); - Matrix_MtxFCopy(&globalCtx->billboardMtxF, &gMtxFClear); - Matrix_MtxFCopy(&globalCtx->viewProjectionMtxF, &gMtxFClear); + Matrix_MtxFCopy(&play->billboardMtxF, &gMtxFClear); + Matrix_MtxFCopy(&play->viewProjectionMtxF, &gMtxFClear); overlayEntry = &gActorOverlayTable[0]; for (i = 0; i < ARRAY_COUNT(gActorOverlayTable); i++) { @@ -2455,13 +2455,13 @@ void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorCtx->flags.clear = savedSceneFlags->clear; actorCtx->flags.collect = savedSceneFlags->collect; - func_8002CDE4(globalCtx, &actorCtx->titleCtx); + func_8002CDE4(play, &actorCtx->titleCtx); actorCtx->absoluteSpace = NULL; - Actor_SpawnEntry(actorCtx, actorEntry, globalCtx); - func_8002C0C0(&actorCtx->targetCtx, actorCtx->actorLists[ACTORCAT_PLAYER].head, globalCtx); - func_8002FA60(globalCtx); + Actor_SpawnEntry(actorCtx, actorEntry, play); + func_8002C0C0(&actorCtx->targetCtx, actorCtx->actorLists[ACTORCAT_PLAYER].head, play); + func_8002FA60(play); } u32 D_80116068[ACTORCAT_MAX] = { @@ -2469,7 +2469,7 @@ u32 D_80116068[ACTORCAT_MAX] = { 0x10000080, 0x00000000, 0x300000C0, 0x100004C0, 0x00000000, 0x100000C0, }; -void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { +void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { Actor* refActor; Actor* actor; Player* player; @@ -2480,7 +2480,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { ActorEntry* actorEntry; s32 i; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); if (0) { // This ASSERT is optimized out but it exists due to its presence in rodata @@ -2490,12 +2490,12 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { sp74 = NULL; unkFlag = 0; - if (globalCtx->numSetupActors != 0) { - actorEntry = &globalCtx->setupActorList[0]; - for (i = 0; i < globalCtx->numSetupActors; i++) { - Actor_SpawnEntry(&globalCtx->actorCtx, actorEntry++, globalCtx); + if (play->numSetupActors != 0) { + actorEntry = &play->setupActorList[0]; + for (i = 0; i < play->numSetupActors; i++) { + Actor_SpawnEntry(&play->actorCtx, actorEntry++, play); } - globalCtx->numSetupActors = 0; + play->numSetupActors = 0; } if (actorCtx->unk_02 != 0) { @@ -2503,9 +2503,9 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (KREG(0) == -100) { - refActor = &GET_PLAYER(globalCtx)->actor; + refActor = &GET_PLAYER(play)->actor; KREG(0) = 0; - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_CLEAR_TAG, refActor->world.pos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_CLEAR_TAG, refActor->world.pos.x, refActor->world.pos.y + 100.0f, refActor->world.pos.z, 0, 0, 0, 1); } @@ -2531,14 +2531,14 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor->sfx = 0; if (actor->init != NULL) { - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) + if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { - Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + Actor_SetObjectDependency(play, actor); + actor->init(actor, play); actor->init = NULL; } actor = actor->next; - } else if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + } else if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { Actor_Kill(actor); actor = actor->next; } else if ((unkFlag && !(actor->flags & unkFlag)) || @@ -2548,9 +2548,9 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor = actor->next; } else if (actor->update == NULL) { if (!actor->isDrawn) { - actor = Actor_Delete(&globalCtx->actorCtx, actor, globalCtx); + actor = Actor_Delete(&play->actorCtx, actor, play); } else { - Actor_Destroy(actor, globalCtx); + Actor_Destroy(actor, play); actor = actor->next; } } else { @@ -2573,12 +2573,12 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor->targetPriority = 0; } - Actor_SetObjectDependency(globalCtx, actor); + Actor_SetObjectDependency(play, actor); if (actor->colorFilterTimer != 0) { actor->colorFilterTimer--; } - actor->update(actor, globalCtx); - func_8003F8EC(globalCtx, &globalCtx->colCtx.dyna, actor); + actor->update(actor, play); + func_8003F8EC(play, &play->colCtx.dyna, actor); } CollisionCheck_ResetDamage(&actor->colChkInfo); @@ -2588,7 +2588,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (i == ACTORCAT_BG) { - DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); + DynaPoly_Setup(play, &play->colCtx.dyna); } } @@ -2607,9 +2607,9 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - func_8002C7BC(&actorCtx->targetCtx, player, actor, globalCtx); - TitleCard_Update(globalCtx, &actorCtx->titleCtx); - DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna); + func_8002C7BC(&actorCtx->targetCtx, player, actor, play); + TitleCard_Update(play, &actorCtx->titleCtx); + DynaPoly_UpdateBgActorTransforms(play, &play->colCtx.dyna); } void Actor_FaultPrint(Actor* actor, char* command) { @@ -2634,36 +2634,36 @@ void Actor_FaultPrint(Actor* actor, char* command) { FaultDrawer_Printf("ACTOR NAME %08x:%s", actor, name); } -void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { +void Actor_Draw(PlayState* play, Actor* actor) { FaultClient faultClient; Lights* lights; Fault_AddClient(&faultClient, Actor_FaultPrint, actor, "Actor_draw"); FrameInterpolation_RecordOpenChild(actor, 0); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); + lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); - Lights_BindAll(lights, globalCtx->lightCtx.listHead, (actor->flags & ACTOR_FLAG_22) ? NULL : &actor->world.pos); - Lights_Draw(lights, globalCtx->state.gfxCtx); + Lights_BindAll(lights, play->lightCtx.listHead, (actor->flags & ACTOR_FLAG_22) ? NULL : &actor->world.pos); + Lights_Draw(lights, play->state.gfxCtx); FrameInterpolation_RecordActorPosRotMatrix(); if (actor->flags & ACTOR_FLAG_12) { Matrix_SetTranslateRotateYXZ( - actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x, - actor->world.pos.y + (f32)((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y), - actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot); + actor->world.pos.x + play->mainCamera.skyboxOffset.x, + actor->world.pos.y + (f32)((actor->shape.yOffset * actor->scale.y) + play->mainCamera.skyboxOffset.y), + actor->world.pos.z + play->mainCamera.skyboxOffset.z, &actor->shape.rot); } else { Matrix_SetTranslateRotateYXZ(actor->world.pos.x, actor->world.pos.y + (actor->shape.yOffset * actor->scale.y), actor->world.pos.z, &actor->shape.rot); } Matrix_Scale(actor->scale.x, actor->scale.y, actor->scale.z, MTXMODE_APPLY); - Actor_SetObjectDependency(globalCtx, actor); + Actor_SetObjectDependency(play, actor); - gSPSegment(POLY_OPA_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x06, globalCtx->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x06, play->objectCtx.status[actor->objBankIndex].segment); if (actor->colorFilterTimer != 0) { Color_RGBA8 color = { 0, 0, 0, 255 }; @@ -2677,27 +2677,27 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) { } if (actor->colorFilterParams & 0x2000) { - func_80026860(globalCtx, &color, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_80026860(play, &color, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); } else { - func_80026400(globalCtx, &color, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); + func_80026400(play, &color, actor->colorFilterTimer, actor->colorFilterParams & 0xFF); } } - actor->draw(actor, globalCtx); + actor->draw(actor, play); if (actor->colorFilterTimer != 0) { if (actor->colorFilterParams & 0x2000) { - func_80026A6C(globalCtx); + func_80026A6C(play); } else { - func_80026608(globalCtx); + func_80026608(play); } } if (actor->shape.shadowDraw != NULL) { - actor->shape.shadowDraw(actor, lights, globalCtx); + actor->shape.shadowDraw(actor, lights, play); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); FrameInterpolation_RecordCloseChild(); Fault_RemoveClient(&faultClient); @@ -2745,12 +2745,12 @@ void Actor_DrawLensOverlay(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Actor** invisibleActors) { +void Actor_DrawLensActors(PlayState* play, s32 numInvisibleActors, Actor** invisibleActors) { Actor** invisibleActor; GraphicsContext* gfxCtx; s32 i; - gfxCtx = globalCtx->state.gfxCtx; + gfxCtx = play->state.gfxCtx; OPEN_DISPS(gfxCtx); @@ -2758,7 +2758,7 @@ void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Acto gDPPipeSync(POLY_XLU_DISP++); - if (globalCtx->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) { + if (play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) { // Update both the color frame buffer and the z-buffer gDPSetOtherMode(POLY_XLU_DISP++, G_AD_DISABLE | G_CD_MAGICSQ | G_CK_NONE | G_TC_FILT | G_TF_BILERP | G_TT_NONE | G_TL_TILE | @@ -2801,13 +2801,13 @@ void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Acto for (i = 0; i < numInvisibleActors; i++) { // "Magic lens invisible Actor display" gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示", i); - Actor_Draw(globalCtx, *(invisibleActor++)); + Actor_Draw(play, *(invisibleActor++)); } // "Magic lens invisible Actor display END" gDPNoOpString(POLY_OPA_DISP++, "魔法のメガネ 見えないActor表示 END", numInvisibleActors); - if (globalCtx->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { + if (play->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { // Draw the lens overlay to the color frame buffer gDPNoOpString(POLY_OPA_DISP++, "青い眼鏡(外側)", 0); // "Blue spectacles (exterior)" @@ -2831,17 +2831,17 @@ void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Acto CLOSE_DISPS(gfxCtx); } -s32 func_800314B0(GlobalContext* globalCtx, Actor* actor) { - return func_800314D4(globalCtx, actor, &actor->projectedPos, actor->projectedW); +s32 func_800314B0(PlayState* play, Actor* actor) { + return func_800314D4(play, actor, &actor->projectedPos, actor->projectedW); } -s32 func_800314D4(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3) { +s32 func_800314D4(PlayState* play, Actor* actor, Vec3f* arg2, f32 arg3) { f32 var; if (CVar_GetS32("gDisableDrawDistance", 0) != 0 && actor->id != ACTOR_EN_TORCH2 && actor->id != ACTOR_EN_BLKOBJ // Extra check for Dark Link and his room && actor->id != ACTOR_EN_HORSE // Check for Epona, else if we call her she will spawn at the other side of the map + we can hear her during the title screen sequence && actor->id != ACTOR_EN_HORSE_GANON && actor->id != ACTOR_EN_HORSE_ZELDA // check for Zelda's and Ganondorf's horses that will always be scene during cinematic whith camera paning - && (globalCtx->sceneNum != SCENE_DDAN && actor->id != ACTOR_EN_ZF)) { // Check for DC and Lizalfos for the case where the miniboss music would still play under certains conditions and changing room + && (play->sceneNum != SCENE_DDAN && actor->id != ACTOR_EN_ZF)) { // Check for DC and Lizalfos for the case where the miniboss music would still play under certains conditions and changing room return true; } @@ -2858,7 +2858,7 @@ s32 func_800314D4(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, f32 arg3) return false; } -void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { +void func_800315AC(PlayState* play, ActorContext* actorCtx) { s32 invisibleActorCounter; Actor* invisibleActors[INVISIBLE_ACTOR_MAX]; ActorListEntry* actorListEntry; @@ -2867,7 +2867,7 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { invisibleActorCounter = 0; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); actorListEntry = &actorCtx->actorLists[0]; @@ -2884,7 +2884,7 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { HREG(66) = i; if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(68) == 0)) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos, &actor->projectedW); } @@ -2895,7 +2895,7 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { } if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(70) == 0)) { - if (func_800314B0(globalCtx, actor)) { + if (func_800314B0(play, actor)) { actor->flags |= ACTOR_FLAG_6; } else { actor->flags &= ~ACTOR_FLAG_6; @@ -2907,14 +2907,14 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(71) == 0)) { if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & (ACTOR_FLAG_5 | ACTOR_FLAG_6))) { if ((actor->flags & ACTOR_FLAG_7) && - ((globalCtx->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || - globalCtx->actorCtx.lensActive || (actor->room != globalCtx->roomCtx.curRoom.num))) { + ((play->roomCtx.curRoom.lensMode == LENS_MODE_HIDE_ACTORS) || + play->actorCtx.lensActive || (actor->room != play->roomCtx.curRoom.num))) { ASSERT(invisibleActorCounter < INVISIBLE_ACTOR_MAX); invisibleActors[invisibleActorCounter] = actor; invisibleActorCounter++; } else { if ((HREG(64) != 1) || ((HREG(65) != -1) && (HREG(65) != HREG(66))) || (HREG(72) == 0)) { - Actor_Draw(globalCtx, actor); + Actor_Draw(play, actor); actor->isDrawn = true; } } @@ -2926,47 +2926,47 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { } if ((HREG(64) != 1) || (HREG(73) != 0)) { - Effect_DrawAll(globalCtx->state.gfxCtx); + Effect_DrawAll(play->state.gfxCtx); } if ((HREG(64) != 1) || (HREG(74) != 0)) { - EffectSs_DrawAll(globalCtx); + EffectSs_DrawAll(play); } if ((HREG(64) != 1) || (HREG(72) != 0)) { - if (globalCtx->actorCtx.lensActive) { - Actor_DrawLensActors(globalCtx, invisibleActorCounter, invisibleActors); - if ((globalCtx->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(globalCtx)) { - Actor_DisableLens(globalCtx); + if (play->actorCtx.lensActive) { + Actor_DrawLensActors(play, invisibleActorCounter, invisibleActors); + if ((play->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(play)) { + Actor_DisableLens(play); } } } - Actor_DrawFaroresWindPointer(globalCtx); + Actor_DrawFaroresWindPointer(play); if (IREG(32) == 0) { - Lights_DrawGlow(globalCtx); + Lights_DrawGlow(play); } if ((HREG(64) != 1) || (HREG(75) != 0)) { - TitleCard_Draw(globalCtx, &actorCtx->titleCtx); + TitleCard_Draw(play, &actorCtx->titleCtx); } if ((HREG(64) != 1) || (HREG(76) != 0)) { - CollisionCheck_DrawCollision(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_DrawCollision(play, &play->colChkCtx); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80031A28(GlobalContext* globalCtx, ActorContext* actorCtx) { +void func_80031A28(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { actor = actorCtx->actorLists[i].head; while (actor != NULL) { - if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { + if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { Actor_Kill(actor); } actor = actor->next; @@ -2976,7 +2976,7 @@ void func_80031A28(GlobalContext* globalCtx, ActorContext* actorCtx) { u8 sEnemyActorCategories[] = { ACTORCAT_ENEMY, ACTORCAT_BOSS }; -void Actor_FreezeAllEnemies(GlobalContext* globalCtx, ActorContext* actorCtx, s32 duration) { +void Actor_FreezeAllEnemies(PlayState* play, ActorContext* actorCtx, s32 duration) { Actor* actor; s32 i; @@ -2989,20 +2989,20 @@ void Actor_FreezeAllEnemies(GlobalContext* globalCtx, ActorContext* actorCtx, s3 } } -void func_80031B14(GlobalContext* globalCtx, ActorContext* actorCtx) { +void func_80031B14(PlayState* play, ActorContext* actorCtx) { Actor* actor; s32 i; for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { actor = actorCtx->actorLists[i].head; while (actor != NULL) { - if ((actor->room >= 0) && (actor->room != globalCtx->roomCtx.curRoom.num) && - (actor->room != globalCtx->roomCtx.prevRoom.num)) { + if ((actor->room >= 0) && (actor->room != play->roomCtx.curRoom.num) && + (actor->room != play->roomCtx.prevRoom.num)) { if (!actor->isDrawn) { - actor = Actor_Delete(actorCtx, actor, globalCtx); + actor = Actor_Delete(actorCtx, actor, play); } else { Actor_Kill(actor); - Actor_Destroy(actor, globalCtx); + Actor_Destroy(actor, play); actor = actor->next; } } else { @@ -3011,21 +3011,21 @@ void func_80031B14(GlobalContext* globalCtx, ActorContext* actorCtx) { } } - CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_ClearContext(play, &play->colChkCtx); actorCtx->flags.tempClear = 0; actorCtx->flags.tempSwch &= 0xFFFFFF; - globalCtx->msgCtx.unk_E3F4 = 0; + play->msgCtx.unk_E3F4 = 0; } // Actor_CleanupContext -void func_80031C3C(ActorContext* actorCtx, GlobalContext* globalCtx) { +void func_80031C3C(ActorContext* actorCtx, PlayState* play) { Actor* actor; s32 i; for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) { actor = actorCtx->actorLists[i].head; while (actor != NULL) { - Actor_Delete(actorCtx, actor, globalCtx); + Actor_Delete(actorCtx, actor, play); actor = actorCtx->actorLists[i].head; } } @@ -3039,8 +3039,8 @@ void func_80031C3C(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - Gameplay_SaveSceneFlags(globalCtx); - func_80030488(globalCtx); + Play_SaveSceneFlags(play); + func_80030488(play); ActorOverlayTable_Cleanup(); } @@ -3069,7 +3069,7 @@ void Actor_AddToCategory(ActorContext* actorCtx, Actor* actorToAdd, u8 actorCate * Removes a given actor instance from its actor list. * Also sets the temp clear flag of the current room if the actor removed was the last enemy loaded. */ -Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove) { +Actor* Actor_RemoveFromCategory(PlayState* play, ActorContext* actorCtx, Actor* actorToRemove) { Actor* newHead; actorCtx->total--; @@ -3090,9 +3090,9 @@ Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx actorToRemove->next = NULL; actorToRemove->prev = NULL; - if ((actorToRemove->room == globalCtx->roomCtx.curRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && + if ((actorToRemove->room == play->roomCtx.curRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) && (actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) { - Flags_SetTempClear(globalCtx, globalCtx->roomCtx.curRoom.num); + Flags_SetTempClear(play, play->roomCtx.curRoom.num); } return newHead; @@ -3140,7 +3140,7 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { int gMapLoading = 0; -Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, +Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s16 params) { s32 pad; Actor* actor; @@ -3224,13 +3224,13 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId : NULL); } - objBankIndex = Object_GetIndex(&globalCtx->objectCtx, actorInit->objectId); + objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId); if (objBankIndex < 0 && !gMapLoading) objBankIndex = 0; if ((objBankIndex < 0) || - ((actorInit->category == ACTORCAT_ENEMY) && Flags_GetClear(globalCtx, globalCtx->roomCtx.curRoom.num))) { + ((actorInit->category == ACTORCAT_ENEMY) && Flags_GetClear(play, play->roomCtx.curRoom.num))) { // "No data bank!! <data bank=%d> (profilep->bank=%d)" osSyncPrintf(VT_COL(RED, WHITE) "データバンク無し!!<データバンク=%d>(profilep->bank=%d)\n" VT_RST, objBankIndex, actorInit->objectId); @@ -3273,7 +3273,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId actor->destroy = actorInit->destroy; actor->update = actorInit->update; actor->draw = actorInit->draw; - actor->room = globalCtx->roomCtx.curRoom.num; + actor->room = play->roomCtx.curRoom.num; actor->home.pos.x = posX; actor->home.pos.y = posY; actor->home.pos.z = posZ; @@ -3285,15 +3285,15 @@ Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId Actor_AddToCategory(actorCtx, actor, actorInit->category); temp = gSegments[6]; - Actor_Init(actor, globalCtx); + Actor_Init(actor, play); gSegments[6] = temp; return actor; } -Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* globalCtx, s16 actorId, f32 posX, +Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s16 params) { - Actor* spawnedActor = Actor_Spawn(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params); + Actor* spawnedActor = Actor_Spawn(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params); if (spawnedActor == NULL) { return NULL; @@ -3309,50 +3309,50 @@ Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, GlobalContext* return spawnedActor; } -void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx) { +void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) { TransitionActorEntry* transitionActor; u8 numActors; s32 i; - transitionActor = globalCtx->transiActorCtx.list; - numActors = globalCtx->transiActorCtx.numActors; + transitionActor = play->transiActorCtx.list; + numActors = play->transiActorCtx.numActors; for (i = 0; i < numActors; i++) { if (transitionActor->id >= 0) { if (((transitionActor->sides[0].room >= 0) && - ((transitionActor->sides[0].room == globalCtx->roomCtx.curRoom.num) || - (transitionActor->sides[0].room == globalCtx->roomCtx.prevRoom.num))) || + ((transitionActor->sides[0].room == play->roomCtx.curRoom.num) || + (transitionActor->sides[0].room == play->roomCtx.prevRoom.num))) || ((transitionActor->sides[1].room >= 0) && - ((transitionActor->sides[1].room == globalCtx->roomCtx.curRoom.num) || - (transitionActor->sides[1].room == globalCtx->roomCtx.prevRoom.num)))) { - Actor_Spawn(actorCtx, globalCtx, (s16)(transitionActor->id & 0x1FFF), transitionActor->pos.x, + ((transitionActor->sides[1].room == play->roomCtx.curRoom.num) || + (transitionActor->sides[1].room == play->roomCtx.prevRoom.num)))) { + Actor_Spawn(actorCtx, play, (s16)(transitionActor->id & 0x1FFF), transitionActor->pos.x, transitionActor->pos.y, transitionActor->pos.z, 0, transitionActor->rotY, 0, (i << 0xA) + transitionActor->params); transitionActor->id = -transitionActor->id; - numActors = globalCtx->transiActorCtx.numActors; + numActors = play->transiActorCtx.numActors; } } transitionActor++; } } -Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx) { +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play) { gMapLoading = 1; - Actor* ret = Actor_Spawn(actorCtx, globalCtx, actorEntry->id, actorEntry->pos.x, actorEntry->pos.y, actorEntry->pos.z, + Actor* ret = Actor_Spawn(actorCtx, play, actorEntry->id, actorEntry->pos.x, actorEntry->pos.y, actorEntry->pos.z, actorEntry->rot.x, actorEntry->rot.y, actorEntry->rot.z, actorEntry->params); gMapLoading = 0; return ret; } -Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx) { +Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) { char* name; Player* player; Actor* newHead; ActorOverlay* overlayEntry; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); overlayEntry = actor->overlayEntry; name = overlayEntry->name != NULL ? overlayEntry->name : ""; @@ -3363,7 +3363,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC if ((player != NULL) && (actor == player->unk_664)) { func_8008EDF0(player); - Camera_ChangeMode(Gameplay_GetCamera(globalCtx, Gameplay_GetActiveCamId(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), 0); } if (actor == actorCtx->targetCtx.arrowPointedActor) { @@ -3379,9 +3379,9 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC } Audio_StopSfxByPos(&actor->projectedPos); - Actor_Destroy(actor, globalCtx); + Actor_Destroy(actor, play); - newHead = Actor_RemoveFromCategory(globalCtx, actorCtx, actor); + newHead = Actor_RemoveFromCategory(play, actorCtx, actor); ZELDA_ARENA_FREE_DEBUG(actor); @@ -3399,11 +3399,11 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC return newHead; } -s32 func_80032880(GlobalContext* globalCtx, Actor* actor) { +s32 func_80032880(PlayState* play, Actor* actor) { s16 sp1E; s16 sp1C; - Actor_GetScreenPos(globalCtx, actor, &sp1E, &sp1C); + Actor_GetScreenPos(play, actor, &sp1E, &sp1C); return (sp1E > -20) && (sp1E < 340) && (sp1C > -160) && (sp1C < 400); } @@ -3415,7 +3415,7 @@ f32 sbgmEnemyDistSq; s32 D_8015BBF8; s16 D_8015BBFC; -void func_800328D4(GlobalContext* globalCtx, ActorContext* actorCtx, Player* player, u32 actorCategory) { +void func_800328D4(PlayState* play, ActorContext* actorCtx, Player* player, u32 actorCategory) { f32 var; Actor* actor; Actor* sp84; @@ -3439,10 +3439,10 @@ void func_800328D4(GlobalContext* globalCtx, ActorContext* actorCtx, Player* pla if (actor != sp84) { var = func_8002EFC0(actor, player, D_8015BBFC); - if ((var < D_8015BBF0) && func_8002F090(actor, var) && func_80032880(globalCtx, actor) && - (!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos, &actor->focus.pos, &sp70, + if ((var < D_8015BBF0) && func_8002F090(actor, var) && func_80032880(play, actor) && + (!BgCheck_CameraLineTest1(&play->colCtx, &player->actor.focus.pos, &actor->focus.pos, &sp70, &sp80, 1, 1, 1, 1, &sp7C) || - SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C))) { + SurfaceType_IsIgnoredByProjectiles(&play->colCtx, sp80, sp7C))) { if (actor->targetPriority != 0) { if (actor->targetPriority < D_8015BBF8) { D_8015BBEC = actor; @@ -3465,7 +3465,7 @@ u8 D_801160A0[] = { ACTORCAT_CHEST, ACTORCAT_SWITCH, ACTORCAT_PROP, ACTORCAT_MISC, ACTORCAT_DOOR, ACTORCAT_SWITCH, }; -Actor* func_80032AF0(GlobalContext* globalCtx, ActorContext* actorCtx, Actor** actorPtr, Player* player) { +Actor* func_80032AF0(PlayState* play, ActorContext* actorCtx, Actor** actorPtr, Player* player) { s32 i; u8* entry; @@ -3473,20 +3473,20 @@ Actor* func_80032AF0(GlobalContext* globalCtx, ActorContext* actorCtx, Actor** a D_8015BBF0 = sbgmEnemyDistSq = FLT_MAX; D_8015BBF8 = 0x7FFFFFFF; - if (!Player_InCsMode(globalCtx)) { + if (!Player_InCsMode(play)) { entry = &D_801160A0[0]; actorCtx->targetCtx.bgmEnemy = NULL; D_8015BBFC = player->actor.shape.rot.y; for (i = 0; i < 3; i++) { - func_800328D4(globalCtx, actorCtx, player, *entry); + func_800328D4(play, actorCtx, player, *entry); entry++; } if (D_8015BBE8 == NULL) { for (; i < ARRAY_COUNT(D_801160A0); i++) { - func_800328D4(globalCtx, actorCtx, player, *entry); + func_800328D4(play, actorCtx, player, *entry); entry++; } } @@ -3521,9 +3521,9 @@ Actor* Actor_Find(ActorContext* actorCtx, s32 actorId, s32 actorCategory) { * Play the death sound effect and flash the screen white for 4 frames. * While the screen flashes, the game freezes. */ -void Enemy_StartFinishingBlow(GlobalContext* globalCtx, Actor* actor) { - globalCtx->actorCtx.freezeFlashTimer = 5; - SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); +void Enemy_StartFinishingBlow(PlayState* play, Actor* actor) { + play->actorCtx.freezeFlashTimer = 5; + SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 20, NA_SE_EN_LAST_DAMAGE); } s16 func_80032CB4(s16* arg0, s16 arg1, s16 arg2, s16 arg3) { @@ -3555,7 +3555,7 @@ s16 func_80032D60(s16* arg0, s16 arg1, s16 arg2, s16 arg3) { return arg0[0]; } -void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, GlobalContext* globalCtx) { +void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, PlayState* play) { u32 matricesSize; u32 dListsSize; u32 objectIdsSize; @@ -3596,9 +3596,9 @@ void BodyBreak_Alloc(BodyBreak* bodyBreak, s32 count, GlobalContext* globalCtx) void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s32 maxLimbIndex, u32 count, Gfx** dList, s16 objectId) { - GlobalContext* globalCtx = Effect_GetGlobalCtx(); + PlayState* play = Effect_GetPlayState(); - if ((globalCtx->actorCtx.freezeFlashTimer == 0) && (bodyBreak->val > 0)) { + if ((play->actorCtx.freezeFlashTimer == 0) && (bodyBreak->val > 0)) { if ((limbIndex >= minLimbIndex) && (limbIndex <= maxLimbIndex) && (*dList != NULL)) { bodyBreak->dLists[bodyBreak->val] = *dList; Matrix_Get(&bodyBreak->matrices[bodyBreak->val]); @@ -3619,7 +3619,7 @@ void BodyBreak_SetInfo(BodyBreak* bodyBreak, s32 limbIndex, s32 minLimbIndex, s3 bodyBreak->prevLimbIndex = limbIndex; } -s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, GlobalContext* globalCtx, s16 type) { +s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, PlayState* play, s16 type) { EnPart* spawnedEnPart; MtxF* mtx; s16 objBankIndex; @@ -3643,7 +3643,7 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, GlobalContext* glob mtx = &bodyBreak->matrices[bodyBreak->count]; - spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, mtx->xw, + spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, mtx->xw, mtx->yw, mtx->zw, 0, 0, objBankIndex, type); if (spawnedEnPart != NULL) { @@ -3664,7 +3664,7 @@ s32 BodyBreak_SpawnParts(Actor* actor, BodyBreak* bodyBreak, GlobalContext* glob return true; } -void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 amountMinusOne, +void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 radius, s32 amountMinusOne, f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting) { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; @@ -3683,12 +3683,12 @@ void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* pos accel.z = (Rand_ZeroOne() - 0.5f) * randAccelWeight; if (scale == 0) { - func_8002857C(globalCtx, &pos, &velocity, &accel); + func_8002857C(play, &pos, &velocity, &accel); } else { if (useLighting) { - func_800286CC(globalCtx, &pos, &velocity, &accel, scale, scaleStep); + func_800286CC(play, &pos, &velocity, &accel, scale, scaleStep); } else { - func_8002865C(globalCtx, &pos, &velocity, &accel, scale, scaleStep); + func_8002865C(play, &pos, &velocity, &accel, scale, scaleStep); } } @@ -3696,7 +3696,7 @@ void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* pos } } -void func_80033480(GlobalContext* globalCtx, Vec3f* posBase, f32 randRangeDiameter, s32 amountMinusOne, s16 scaleBase, +void func_80033480(PlayState* play, Vec3f* posBase, f32 randRangeDiameter, s32 amountMinusOne, s16 scaleBase, s16 scaleStep, u8 arg6) { Vec3f pos; Vec3f velocity = { 0.0f, 0.0f, 0.0f }; @@ -3714,14 +3714,14 @@ void func_80033480(GlobalContext* globalCtx, Vec3f* posBase, f32 randRangeDiamet var2 = arg6; if (var2 != 0) { - func_800286CC(globalCtx, &pos, &velocity, &accel, scale, scaleStep); + func_800286CC(play, &pos, &velocity, &accel, scale, scaleStep); } else { - func_8002865C(globalCtx, &pos, &velocity, &accel, scale, scaleStep); + func_8002865C(play, &pos, &velocity, &accel, scale, scaleStep); } } } -Actor* Actor_GetCollidedExplosive(GlobalContext* globalCtx, Collider* collider) { +Actor* Actor_GetCollidedExplosive(PlayState* play, Collider* collider) { if ((collider->acFlags & AC_HIT) && (collider->ac->category == ACTORCAT_EXPLOSIVE)) { collider->acFlags &= ~AC_HIT; return collider->ac; @@ -3730,8 +3730,8 @@ Actor* Actor_GetCollidedExplosive(GlobalContext* globalCtx, Collider* collider) return NULL; } -Actor* func_80033684(GlobalContext* globalCtx, Actor* explosiveActor) { - Actor* actor = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; +Actor* func_80033684(PlayState* play, Actor* explosiveActor) { + Actor* actor = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVE].head; while (actor != NULL) { if ((actor == explosiveActor) || (actor->params != 1)) { @@ -3752,8 +3752,8 @@ Actor* func_80033684(GlobalContext* globalCtx, Actor* explosiveActor) { * Dynamically changes the category of a given actor instance. * This is done by moving it to the corresponding category list and setting its category variable accordingly. */ -void Actor_ChangeCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory) { - Actor_RemoveFromCategory(globalCtx, actorCtx, actor); +void Actor_ChangeCategory(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 actorCategory) { + Actor_RemoveFromCategory(play, actorCtx, actor); Actor_AddToCategory(actorCtx, actor, actorCategory); } @@ -3764,7 +3764,7 @@ void Actor_ChangeCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Acto * * Returns the actor if there will be collision, NULL otherwise. */ -Actor* Actor_GetProjectileActor(GlobalContext* globalCtx, Actor* refActor, f32 radius) { +Actor* Actor_GetProjectileActor(PlayState* play, Actor* refActor, f32 radius) { Actor* actor; Vec3f spA8; f32 deltaX; @@ -3773,7 +3773,7 @@ Actor* Actor_GetProjectileActor(GlobalContext* globalCtx, Actor* refActor, f32 r Vec3f sp90; Vec3f sp84; - actor = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; + actor = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].head; while (actor != NULL) { if (((actor->id != ACTOR_ARMS_HOOK) && (actor->id != ACTOR_EN_ARROW)) || (actor == refActor)) { actor = actor->next; @@ -3811,10 +3811,10 @@ Actor* Actor_GetProjectileActor(GlobalContext* globalCtx, Actor* refActor, f32 r /** * Sets the actor's text id with a dynamic prefix based on the current scene. */ -void Actor_SetTextWithPrefix(GlobalContext* globalCtx, Actor* actor, s16 baseTextId) { +void Actor_SetTextWithPrefix(PlayState* play, Actor* actor, s16 baseTextId) { s16 prefix; - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_YDAN_BOSS: case SCENE_MORIBOSSROOM: @@ -3894,7 +3894,7 @@ void Actor_SetTextWithPrefix(GlobalContext* globalCtx, Actor* actor, s16 baseTex * * Returns true if the actor will be standing on ground. */ -s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 distance, s16 angle) { +s16 Actor_TestFloorInDirection(Actor* actor, PlayState* play, f32 distance, s16 angle) { s16 ret; s16 prevBgCheckFlags; f32 dx; @@ -3909,7 +3909,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista actor->world.pos.x += dx; actor->world.pos.z += dz; - Actor_UpdateBgCheckInfo(globalCtx, actor, 0.0f, 0.0f, 0.0f, 4); + Actor_UpdateBgCheckInfo(play, actor, 0.0f, 0.0f, 0.0f, 4); Math_Vec3f_Copy(&actor->world.pos, &prevActorPos); @@ -3922,8 +3922,8 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista /** * Returns true if the player is targeting the provided actor */ -s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor) { - Player* player = GET_PLAYER(globalCtx); +s32 Actor_IsTargeted(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); if ((player->stateFlags1 & 0x10) && actor->isTargeted) { return true; @@ -3935,8 +3935,8 @@ s32 Actor_IsTargeted(GlobalContext* globalCtx, Actor* actor) { /** * Returns true if the player is targeting an actor other than the provided actor */ -s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor) { - Player* player = GET_PLAYER(globalCtx); +s32 Actor_OtherIsTargeted(PlayState* play, Actor* actor) { + Player* player = GET_PLAYER(play); if ((player->stateFlags1 & 0x10) && !actor->isTargeted) { return true; @@ -3961,13 +3961,13 @@ f32 func_80033AEC(Vec3f* arg0, Vec3f* arg1, f32 arg2, f32 arg3, f32 arg4, f32 ar return ret; } -void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) { +void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) { MtxF sp60; f32 var; Vec3f sp50; CollisionPoly* sp4C; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -3977,7 +3977,7 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) sp50.y = arg0->y + 1.0f; sp50.z = arg0->z; - var = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp4C, &sp50); + var = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp4C, &sp50); if (sp4C != NULL) { func_80038A28(sp4C, arg0->x, var, arg0->z, &sp60); @@ -3988,37 +3988,37 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) Matrix_Scale(arg1->x, 1.0f, arg1->z, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80033DB8(GlobalContext* globalCtx, s16 arg1, s16 arg2) { - s16 var = Quake_Add(&globalCtx->mainCamera, 3); +void func_80033DB8(PlayState* play, s16 arg1, s16 arg2) { + s16 var = Quake_Add(&play->mainCamera, 3); Quake_SetSpeed(var, 20000); Quake_SetQuakeValues(var, arg1, 0, 0, 0); Quake_SetCountdown(var, arg2); } -void func_80033E1C(GlobalContext* globalCtx, s16 arg1, s16 arg2, s16 arg3) { - s16 var = Quake_Add(&globalCtx->mainCamera, 3); +void func_80033E1C(PlayState* play, s16 arg1, s16 arg2, s16 arg3) { + s16 var = Quake_Add(&play->mainCamera, 3); Quake_SetSpeed(var, arg3); Quake_SetQuakeValues(var, arg1, 0, 0, 0); Quake_SetCountdown(var, arg2); } -void func_80033E88(Actor* actor, GlobalContext* globalCtx, s16 arg2, s16 arg3) { +void func_80033E88(Actor* actor, PlayState* play, s16 arg2, s16 arg3) { if (arg2 >= 5) { func_800AA000(actor->xyzDistToPlayerSq, 0xFF, 0x14, 0x96); } else { func_800AA000(actor->xyzDistToPlayerSq, 0xB4, 0x14, 0x64); } - func_80033DB8(globalCtx, arg2, arg3); + func_80033DB8(play, arg2, arg3); } f32 Rand_ZeroFloat(f32 f) { @@ -4049,7 +4049,7 @@ static DoorLockInfo sDoorLocksInfo[] = { * Draws chains and lock of a locked door, of the specified `type` (see `DoorLockType`). * `frame` can be 0 to 10, where 0 is "open" and 10 is "closed", the chains slide accordingly. */ -void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { +void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type) { DoorLockInfo* entry; s32 i; MtxF baseMtxF; @@ -4061,7 +4061,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { entry = &sDoorLocksInfo[type]; chainRotZ = entry->chainsRotZInit; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); Matrix_Get(&baseMtxF); @@ -4079,7 +4079,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { Matrix_Scale(entry->chainsScale, entry->chainsScale, entry->chainsScale, MTXMODE_APPLY); } - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); @@ -4096,15 +4096,15 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { Matrix_Put(&baseMtxF); Matrix_Scale(frame * 0.1f, frame * 0.1f, frame * 0.1f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_8003424C(GlobalContext* globalCtx, Vec3f* arg1) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, arg1); +void func_8003424C(PlayState* play, Vec3f* arg1) { + CollisionCheck_SpawnShieldParticlesMetal(play, arg1); } void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 xluFlag, s16 duration) { @@ -4116,52 +4116,52 @@ void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s1 actor->colorFilterTimer = duration; } -Hilite* func_800342EC(Vec3f* object, GlobalContext* globalCtx) { +Hilite* func_800342EC(Vec3f* object, PlayState* play) { Vec3f lightDir; - lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; - lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; - lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + lightDir.x = play->envCtx.dirLight1.params.dir.x; + lightDir.y = play->envCtx.dirLight1.params.dir.y; + lightDir.z = play->envCtx.dirLight1.params.dir.z; - return func_8002EABC(object, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + return func_8002EABC(object, &play->view.eye, &lightDir, play->state.gfxCtx); } -Hilite* func_8003435C(Vec3f* object, GlobalContext* globalCtx) { +Hilite* func_8003435C(Vec3f* object, PlayState* play) { Vec3f lightDir; - lightDir.x = globalCtx->envCtx.dirLight1.params.dir.x; - lightDir.y = globalCtx->envCtx.dirLight1.params.dir.y; - lightDir.z = globalCtx->envCtx.dirLight1.params.dir.z; + lightDir.x = play->envCtx.dirLight1.params.dir.x; + lightDir.y = play->envCtx.dirLight1.params.dir.y; + lightDir.z = play->envCtx.dirLight1.params.dir.z; - return func_8002EB44(object, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + return func_8002EB44(object, &play->view.eye, &lightDir, play->state.gfxCtx); } -s32 func_800343CC(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 interactRange, callback1_800343CC unkFunc1, +s32 func_800343CC(PlayState* play, Actor* actor, s16* arg2, f32 interactRange, callback1_800343CC unkFunc1, callback2_800343CC unkFunc2) { s16 x; s16 y; - if (Actor_ProcessTalkRequest(actor, globalCtx)) { + if (Actor_ProcessTalkRequest(actor, play)) { *arg2 = 1; return true; } if (*arg2 != 0) { - *arg2 = unkFunc2(globalCtx, actor); + *arg2 = unkFunc2(play, actor); return false; } - Actor_GetScreenPos(globalCtx, actor, &x, &y); + Actor_GetScreenPos(play, actor, &x, &y); if ((x < 0) || (x > SCREEN_WIDTH) || (y < 0) || (y > SCREEN_HEIGHT)) { return false; } - if (!func_8002F2CC(actor, globalCtx, interactRange)) { + if (!func_8002F2CC(actor, play, interactRange)) { return false; } - actor->textId = unkFunc1(globalCtx, actor); + actor->textId = unkFunc1(play, actor); return false; } @@ -4340,45 +4340,45 @@ Gfx* func_80034B54(GraphicsContext* gfxCtx) { return displayList; } -void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, +void func_80034BA0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, alpha); gDPPipeSync(POLY_OPA_DISP++); - gSPSegment(POLY_OPA_DISP++, 0x0C, func_80034B28(globalCtx->state.gfxCtx)); + gSPSegment(POLY_OPA_DISP++, 0x0C, func_80034B28(play->state.gfxCtx)); - POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + POLY_OPA_DISP = SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, overrideLimbDraw, postLimbDraw, actor, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, +void func_80034CC4(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, alpha); - gSPSegment(POLY_XLU_DISP++, 0x0C, func_80034B54(globalCtx->state.gfxCtx)); + gSPSegment(POLY_XLU_DISP++, 0x0C, func_80034B54(play->state.gfxCtx)); - POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, + POLY_XLU_DISP = SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, overrideLimbDraw, postLimbDraw, actor, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -s16 func_80034DD4(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) { - Player* player = GET_PLAYER(globalCtx); +s16 func_80034DD4(Actor* actor, PlayState* play, s16 arg2, f32 arg3) { + Player* player = GET_PLAYER(play); f32 var; - if ((globalCtx->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) { - var = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f; + if ((play->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) { + var = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f; } else { var = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos); } @@ -4409,8 +4409,8 @@ void Animation_ChangeByInfo(SkelAnime* skelAnime, AnimationInfo* animationInfo, frameCount, animationInfo->mode, animationInfo->morphFrames); } -void func_80034F54(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3) { - u32 frames = globalCtx->gameplayFrames; +void func_80034F54(PlayState* play, s16* arg1, s16* arg2, s32 arg3) { + u32 frames = play->gameplayFrames; s32 i; for (i = 0; i < arg3; i++) { @@ -4419,15 +4419,15 @@ void func_80034F54(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 arg3) { } } -void Actor_Noop(Actor* actor, GlobalContext* globalCtx) { +void Actor_Noop(Actor* actor, PlayState* play) { } -s32 func_80035124(Actor* actor, GlobalContext* globalCtx) { +s32 func_80035124(Actor* actor, PlayState* play) { s32 ret = 0; switch (actor->params) { case 0: - if (Actor_HasParent(actor, globalCtx)) { + if (Actor_HasParent(actor, play)) { actor->params = 1; } else if (!(actor->bgCheckFlags & 1)) { Actor_MoveForward(actor); @@ -4436,24 +4436,24 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) { ret = 1; } else { actor->shape.rot.x = actor->shape.rot.z = 0; - func_8002F580(actor, globalCtx); + func_8002F580(actor, play); } break; case 1: - if (Actor_HasNoParent(actor, globalCtx)) { + if (Actor_HasNoParent(actor, play)) { actor->params = 0; } break; } - Actor_UpdateBgCheckInfo(globalCtx, actor, actor->colChkInfo.cylHeight, actor->colChkInfo.cylRadius, + Actor_UpdateBgCheckInfo(play, actor, actor->colChkInfo.cylHeight, actor->colChkInfo.cylRadius, actor->colChkInfo.cylRadius, 0x1D); return ret; } -u8 func_800353E8(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +u8 func_800353E8(PlayState* play) { + Player* player = GET_PLAYER(play); return player->unk_845; } @@ -4463,8 +4463,8 @@ u8 func_800353E8(GlobalContext* globalCtx) { * an actor if there is one. If the ID provided is -1, this will look for any actor of the * specified category rather than a specific ID. */ -Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* refActor, s16 actorId, u8 actorCategory, f32 range) { - Actor* actor = globalCtx->actorCtx.actorLists[actorCategory].head; +Actor* Actor_FindNearby(PlayState* play, Actor* refActor, s16 actorId, u8 actorCategory, f32 range) { + Actor* actor = play->actorCtx.actorLists[actorCategory].head; while (actor != NULL) { if (actor == refActor || ((actorId != -1) && (actorId != actor->id))) { @@ -4481,8 +4481,8 @@ Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* refActor, s16 actorId, return NULL; } -s32 func_800354B4(GlobalContext* globalCtx, Actor* actor, f32 range, s16 arg3, s16 arg4, s16 arg5) { - Player* player = GET_PLAYER(globalCtx); +s32 func_800354B4(PlayState* play, Actor* actor, f32 range, s16 arg3, s16 arg4, s16 arg5) { + Player* player = GET_PLAYER(play); s16 var1; s16 var2; @@ -4496,7 +4496,7 @@ s32 func_800354B4(GlobalContext* globalCtx, Actor* actor, f32 range, s16 arg3, s } } -void func_8003555C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void func_8003555C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 color1; Color_RGBA8 color2; @@ -4509,7 +4509,7 @@ void func_8003555C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* color2.b = 50; //! @bug color1 and color2 alpha components not set before being passed on - EffectSsKiraKira_SpawnSmall(globalCtx, pos, velocity, accel, &color1, &color2); + EffectSsKiraKira_SpawnSmall(play, pos, velocity, accel, &color1, &color2); } Vec3f D_80116268 = { 0.0f, -1.5f, 0.0f }; @@ -4522,12 +4522,12 @@ Gfx D_80116280[] = { gsSPEndDisplayList(), }; -void func_800355B8(GlobalContext* globalCtx, Vec3f* pos) { - func_8003555C(globalCtx, pos, &D_80116268, &D_80116274); +void func_800355B8(PlayState* play, Vec3f* pos) { + func_8003555C(play, pos, &D_80116268, &D_80116274); } -u8 func_800355E4(GlobalContext* globalCtx, Collider* collider) { - Player* player = GET_PLAYER(globalCtx); +u8 func_800355E4(PlayState* play, Collider* collider) { + Player* player = GET_PLAYER(play); if ((collider->acFlags & AC_TYPE_PLAYER) && (player->swordState != 0) && (player->swordAnimation == 0x16)) { return true; @@ -4625,11 +4625,11 @@ void func_80035844(Vec3f* arg0, Vec3f* arg1, Vec3s* arg2, s32 arg3) { * Spawns En_Part (Dissipating Flames) actor as a child of the given actor. */ Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* unused, - GlobalContext* globalCtx, s16 params, s32 arg8) { + PlayState* play, s16 params, s32 arg8) { EnPart* spawnedEnPart; spawnedEnPart = - (EnPart*)Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, spawnPos->x, spawnPos->y, + (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, spawnPos->x, spawnPos->y, spawnPos->z, spawnRot->x, spawnRot->y, actor->objBankIndex, params); if (spawnedEnPart != NULL) { spawnedEnPart->actor.scale = actor->scale; @@ -4676,8 +4676,8 @@ void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) { } } -void func_80035B18(GlobalContext* globalCtx, Actor* actor, u16 textId) { - Message_ContinueTextbox(globalCtx, textId); +void func_80035B18(PlayState* play, Actor* actor, u16 textId) { + Message_ContinueTextbox(play, textId); actor->textId = textId; } @@ -4723,7 +4723,7 @@ void Flags_SetRandomizerInf(RandomizerInf flag) { gSaveContext.randomizerInf[flag >> 4] |= (1 << (flag & 0xF)); } -u32 func_80035BFC(GlobalContext* globalCtx, s16 arg1) { +u32 func_80035BFC(PlayState* play, s16 arg1) { u16 retTextId = 0; switch (arg1) { @@ -5013,7 +5013,7 @@ u32 func_80035BFC(GlobalContext* globalCtx, s16 arg1) { } break; case 16: - if (globalCtx->sceneNum == SCENE_SPOT15) { + if (play->sceneNum == SCENE_SPOT15) { retTextId = 0x7002; } else if (Flags_GetInfTable(0x6A)) { retTextId = 0x7004; @@ -5710,24 +5710,24 @@ void func_80036E50(u16 textId, s16 arg1) { } } -s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { - MessageContext* msgCtx = &globalCtx->msgCtx; +s32 func_800374E0(PlayState* play, Actor* actor, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; s32 ret = 1; switch (textId) { case 0x1035: if (msgCtx->choiceIndex == 0) { if (Flags_GetInfTable(0x2A)) { - func_80035B18(globalCtx, actor, 0x1036); + func_80035B18(play, actor, 0x1036); } else { - func_80035B18(globalCtx, actor, 0x1041); + func_80035B18(play, actor, 0x1041); } } if (msgCtx->choiceIndex == 1) { if (Flags_GetInfTable(0x2B)) { - func_80035B18(globalCtx, actor, 0x1037); + func_80035B18(play, actor, 0x1037); } else { - func_80035B18(globalCtx, actor, 0x1041); + func_80035B18(play, actor, 0x1041); } } ret = 0; @@ -5735,58 +5735,58 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { case 0x1038: if (msgCtx->choiceIndex == 0) { if (Flags_GetInfTable(0x2E)) { - func_80035B18(globalCtx, actor, 0x1039); + func_80035B18(play, actor, 0x1039); } else { - func_80035B18(globalCtx, actor, 0x1041); + func_80035B18(play, actor, 0x1041); } } if (msgCtx->choiceIndex == 1) { if (Flags_GetInfTable(0x2F)) { - func_80035B18(globalCtx, actor, 0x103A); + func_80035B18(play, actor, 0x103A); } else { - func_80035B18(globalCtx, actor, 0x1041); + func_80035B18(play, actor, 0x1041); } } if (msgCtx->choiceIndex == 2) { if (Flags_GetInfTable(0x30)) { - func_80035B18(globalCtx, actor, 0x103B); + func_80035B18(play, actor, 0x103B); } else { - func_80035B18(globalCtx, actor, 0x1041); + func_80035B18(play, actor, 0x1041); } } ret = 0; break; case 0x103E: if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x103F); + func_80035B18(play, actor, 0x103F); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x1040); + func_80035B18(play, actor, 0x1040); } ret = 0; break; case 0x1041: if (msgCtx->choiceTextId == 0x1035) { if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x1036); + func_80035B18(play, actor, 0x1036); Flags_SetInfTable(0x2A); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x1037); + func_80035B18(play, actor, 0x1037); Flags_SetInfTable(0x2B); } } if (msgCtx->choiceTextId == 0x1038) { if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x1039); + func_80035B18(play, actor, 0x1039); Flags_SetInfTable(0x2E); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x103A); + func_80035B18(play, actor, 0x103A); Flags_SetInfTable(0x2F); } if (msgCtx->choiceIndex == 2) { - func_80035B18(globalCtx, actor, 0x103B); + func_80035B18(play, actor, 0x103B); Flags_SetInfTable(0x30); } } @@ -5794,10 +5794,10 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { break; case 0x1062: if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x1063); + func_80035B18(play, actor, 0x1063); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x1064); + func_80035B18(play, actor, 0x1064); } ret = 0; break; @@ -5805,14 +5805,14 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { case 0x2031: if (msgCtx->choiceIndex == 0) { if (gSaveContext.rupees >= 10) { - func_80035B18(globalCtx, actor, 0x2034); + func_80035B18(play, actor, 0x2034); Rupees_ChangeBy(-10); } else { - func_80035B18(globalCtx, actor, 0x2032); + func_80035B18(play, actor, 0x2032); } } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x2032); + func_80035B18(play, actor, 0x2032); } Flags_SetInfTable(0x9A); ret = 0; @@ -5820,10 +5820,10 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { case 0x2036: case 0x2037: if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x201F); + func_80035B18(play, actor, 0x201F); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x205A); + func_80035B18(play, actor, 0x205A); } ret = 0; break; @@ -5832,7 +5832,7 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { break; } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x205A); + func_80035B18(play, actor, 0x205A); } ret = 0; break; @@ -5840,14 +5840,14 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { if (msgCtx->choiceIndex != 0) { break; } - func_80035B18(globalCtx, actor, 0x2035); + func_80035B18(play, actor, 0x2035); ret = 0; break; case 0x2043: if (Flags_GetEventChkInf(0x12)) { break; } - func_80035B18(globalCtx, actor, 0x2044); + func_80035B18(play, actor, 0x2044); ret = 0; break; case 0x205A: @@ -5855,52 +5855,52 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { case 0x300A: if (msgCtx->choiceIndex == 0) { if (Flags_GetEventChkInf(0x22)) { - func_80035B18(globalCtx, actor, 0x300B); + func_80035B18(play, actor, 0x300B); } else { - func_80035B18(globalCtx, actor, 0x300C); + func_80035B18(play, actor, 0x300C); } } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x300D); + func_80035B18(play, actor, 0x300D); } ret = 0; break; case 0x301B: if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x301D); + func_80035B18(play, actor, 0x301D); } if (msgCtx->choiceIndex == 1) { if (Flags_GetInfTable(0x113)) { - func_80035B18(globalCtx, actor, 0x301F); + func_80035B18(play, actor, 0x301F); } else { - func_80035B18(globalCtx, actor, 0x301E); + func_80035B18(play, actor, 0x301E); } } ret = 0; break; case 0x301E: - func_80035B18(globalCtx, actor, 0x3020); + func_80035B18(play, actor, 0x3020); ret = 0; break; case 0x400C: if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x400D); + func_80035B18(play, actor, 0x400D); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x400E); + func_80035B18(play, actor, 0x400E); } ret = 0; break; case 0x7007: - func_80035B18(globalCtx, actor, 0x703E); + func_80035B18(play, actor, 0x703E); ret = 0; break; case 0x703E: - func_80035B18(globalCtx, actor, 0x703F); + func_80035B18(play, actor, 0x703F); ret = 0; break; case 0x703F: - func_80035B18(globalCtx, actor, 0x7042); + func_80035B18(play, actor, 0x7042); ret = 0; break; } @@ -5908,31 +5908,31 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { return ret; } -u16 func_80037C30(GlobalContext* globalCtx, s16 arg1) { - return func_80035BFC(globalCtx, arg1); +u16 func_80037C30(PlayState* play, s16 arg1) { + return func_80035BFC(play, arg1); } -s32 func_80037C5C(GlobalContext* globalCtx, s16 arg1, u16 textId) { +s32 func_80037C5C(PlayState* play, s16 arg1, u16 textId) { func_80036E50(textId, arg1); return false; } -s32 func_80037C94(GlobalContext* globalCtx, Actor* actor, s32 arg2) { - return func_800374E0(globalCtx, actor, actor->textId); +s32 func_80037C94(PlayState* play, Actor* actor, s32 arg2) { + return func_800374E0(play, actor, actor->textId); } -s32 func_80037CB8(GlobalContext* globalCtx, Actor* actor, s16 arg2) { - MessageContext* msgCtx = &globalCtx->msgCtx; +s32 func_80037CB8(PlayState* play, Actor* actor, s16 arg2) { + MessageContext* msgCtx = &play->msgCtx; s32 ret = false; switch (Message_GetState(msgCtx)) { case TEXT_STATE_CLOSING: - func_80037C5C(globalCtx, arg2, actor->textId); + func_80037C5C(play, arg2, actor->textId); ret = true; break; case TEXT_STATE_CHOICE: case TEXT_STATE_EVENT: - if (Message_ShouldAdvance(globalCtx) && func_80037C94(globalCtx, actor, arg2)) { + if (Message_ShouldAdvance(play) && func_80037C94(play, actor, arg2)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); msgCtx->msgMode = MSGMODE_TEXT_CLOSING; ret = true; @@ -5943,25 +5943,25 @@ s32 func_80037CB8(GlobalContext* globalCtx, Actor* actor, s16 arg2) { return ret; } -s32 func_80037D98(GlobalContext* globalCtx, Actor* actor, s16 arg2, s32* arg3) { +s32 func_80037D98(PlayState* play, Actor* actor, s16 arg2, s32* arg3) { s16 var; s16 sp2C; s16 sp2A; s16 abs_var; - if (Actor_ProcessTalkRequest(actor, globalCtx)) { + if (Actor_ProcessTalkRequest(actor, play)) { *arg3 = 1; return true; } if (*arg3 == 1) { - if (func_80037CB8(globalCtx, actor, arg2)) { + if (func_80037CB8(play, actor, arg2)) { *arg3 = 0; } return false; } - Actor_GetScreenPos(globalCtx, actor, &sp2C, &sp2A); + Actor_GetScreenPos(play, actor, &sp2C, &sp2A); if ((sp2C < 0) || (sp2C > SCREEN_WIDTH) || (sp2A < 0) || (sp2A > SCREEN_HEIGHT)) { return false; @@ -5979,12 +5979,12 @@ s32 func_80037D98(GlobalContext* globalCtx, Actor* actor, s16 arg2, s32* arg3) { } if (actor->xyzDistToPlayerSq <= SQ(80.0f)) { - if (func_8002F2CC(actor, globalCtx, 80.0f)) { - actor->textId = func_80037C30(globalCtx, arg2); + if (func_8002F2CC(actor, play, 80.0f)) { + actor->textId = func_80037C30(play, arg2); } } else { - if (func_8002F2F4(actor, globalCtx)) { - actor->textId = func_80037C30(globalCtx, arg2); + if (func_8002F2F4(actor, play)) { + actor->textId = func_80037C30(play, arg2); } } @@ -6023,8 +6023,8 @@ s32 func_80037FC8(Actor* actor, Vec3f* arg1, Vec3s* arg2, Vec3s* arg3) { return true; } -s32 func_80038154(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* arg3, f32 arg4) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80038154(PlayState* play, Actor* actor, Vec3s* arg2, Vec3s* arg3, f32 arg4) { + Player* player = GET_PLAYER(play); s32 pad; Vec3f sp2C; s16 var; @@ -6033,7 +6033,7 @@ s32 func_80038154(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar actor->focus.pos = actor->world.pos; actor->focus.pos.y += arg4; - if (!(((globalCtx->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE))) { + if (!(((play->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE))) { var = actor->yawTowardsPlayer - actor->shape.rot.y; abs_var = ABS(var); if (abs_var >= 0x4300) { @@ -6042,8 +6042,8 @@ s32 func_80038154(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar } } - if (((globalCtx->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE)) { - sp2C = globalCtx->view.eye; + if (((play->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE)) { + sp2C = play->view.eye; } else { sp2C = player->actor.focus.pos; } @@ -6053,8 +6053,8 @@ s32 func_80038154(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar return true; } -s32 func_80038290(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* arg3, Vec3f arg4) { - Player* player = GET_PLAYER(globalCtx); +s32 func_80038290(PlayState* play, Actor* actor, Vec3s* arg2, Vec3s* arg3, Vec3f arg4) { + Player* player = GET_PLAYER(play); s32 pad; Vec3f sp24; s16 var; @@ -6062,7 +6062,7 @@ s32 func_80038290(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar actor->focus.pos = arg4; - if (!(((globalCtx->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE))) { + if (!(((play->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE))) { var = actor->yawTowardsPlayer - actor->shape.rot.y; abs_var = ABS(var); if (abs_var >= 0x4300) { @@ -6071,8 +6071,8 @@ s32 func_80038290(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar } } - if (((globalCtx->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE)) { - sp24 = globalCtx->view.eye; + if (((play->csCtx.state != CS_STATE_IDLE) || (gDbgCamEnabled)) && (gSaveContext.entranceIndex == 0x00EE)) { + sp24 = play->view.eye; } else { sp24 = player->actor.focus.pos; } @@ -6082,7 +6082,7 @@ s32 func_80038290(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar return true; } -GetItemEntry GetChestGameRandoGetItem(s8 room, s16 ogDrawId, GlobalContext* globalCtx) { +GetItemEntry GetChestGameRandoGetItem(s8 room, s16 ogDrawId, PlayState* play) { if (Randomizer_GetSettingValue(RSK_SHUFFLE_CHEST_MINIGAME)) { // RANDOTODO update this logic when we implement keysanity // because 3drando replaces the keys not the rupees @@ -6092,27 +6092,27 @@ GetItemEntry GetChestGameRandoGetItem(s8 room, s16 ogDrawId, GlobalContext* glob { switch(room) { case 1: - if(!Flags_GetCollectible(globalCtx, 0x1B)) { + if(!Flags_GetCollectible(play, 0x1B)) { return Randomizer_GetItemFromKnownCheck(RC_MARKET_TREASURE_CHEST_GAME_ITEM_1, GI_RUPEE_GREEN); } break; case 2: - if(!Flags_GetCollectible(globalCtx, 0x1C)) { + if(!Flags_GetCollectible(play, 0x1C)) { return Randomizer_GetItemFromKnownCheck(RC_MARKET_TREASURE_CHEST_GAME_ITEM_2, GI_RUPEE_GREEN); } break; case 3: - if(!Flags_GetCollectible(globalCtx, 0x1D)) { + if(!Flags_GetCollectible(play, 0x1D)) { return Randomizer_GetItemFromKnownCheck(RC_MARKET_TREASURE_CHEST_GAME_ITEM_3, GI_RUPEE_BLUE); } break; case 4: - if(!Flags_GetCollectible(globalCtx, 0x1E)) { + if(!Flags_GetCollectible(play, 0x1E)) { return Randomizer_GetItemFromKnownCheck(RC_MARKET_TREASURE_CHEST_GAME_ITEM_4, GI_RUPEE_BLUE); } break; case 5: - if(!Flags_GetCollectible(globalCtx, 0x1F)) { + if(!Flags_GetCollectible(play, 0x1F)) { return Randomizer_GetItemFromKnownCheck(RC_MARKET_TREASURE_CHEST_GAME_ITEM_5, GI_RUPEE_RED); } break; @@ -6127,8 +6127,8 @@ GetItemEntry GetChestGameRandoGetItem(s8 room, s16 ogDrawId, GlobalContext* glob return (GetItemEntry)GET_ITEM_NONE; } -s16 GetChestGameRandoGiDrawId(s8 room, s16 ogDrawId, GlobalContext* globalCtx) { - GetItemEntry randoGetItem = GetChestGameRandoGetItem(room, ogDrawId, globalCtx); +s16 GetChestGameRandoGiDrawId(s8 room, s16 ogDrawId, PlayState* play) { + GetItemEntry randoGetItem = GetChestGameRandoGetItem(room, ogDrawId, play); if (randoGetItem.itemId != ITEM_NONE) { return randoGetItem.gid; diff --git a/soh/src/code/z_bgcheck.c b/soh/src/code/z_bgcheck.c index e8721fdfb..0b0025927 100644 --- a/soh/src/code/z_bgcheck.c +++ b/soh/src/code/z_bgcheck.c @@ -95,7 +95,7 @@ void DynaSSNodeList_SetSSListHead(DynaSSNodeList* nodeList, SSList* ssList, s16* /** * Initialize DynaSSNodeList */ -void DynaSSNodeList_Initialize(GlobalContext* globalCtx, DynaSSNodeList* nodeList) { +void DynaSSNodeList_Initialize(PlayState* play, DynaSSNodeList* nodeList) { nodeList->tbl = NULL; nodeList->count = 0; } @@ -103,8 +103,8 @@ void DynaSSNodeList_Initialize(GlobalContext* globalCtx, DynaSSNodeList* nodeLis /** * Initialize DynaSSNodeList tbl */ -void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* nodeList, s32 max) { - nodeList->tbl = THA_AllocEndAlign(&globalCtx->state.tha, max * sizeof(SSNode), -2); +void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* nodeList, s32 max) { + nodeList->tbl = THA_AllocEndAlign(&play->state.tha, max * sizeof(SSNode), -2); ASSERT(nodeList->tbl != NULL); @@ -1355,7 +1355,7 @@ s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* pol * Initialize StaticLookup Table * returns size of table, in bytes */ -u32 BgCheck_InitializeStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) { +u32 BgCheck_InitializeStaticLookup(CollisionContext* colCtx, PlayState* play, StaticLookup* lookupTbl) { Vec3s* vtxList; CollisionPoly* polyList; s32 polyMax; @@ -1438,7 +1438,7 @@ u32 BgCheck_InitializeStaticLookup(CollisionContext* colCtx, GlobalContext* glob /** * Is current scene a SPOT scene */ -s32 BgCheck_IsSpotScene(GlobalContext* globalCtx) { +s32 BgCheck_IsSpotScene(PlayState* play) { static s16 spotScenes[] = { SCENE_SPOT00, SCENE_SPOT01, SCENE_SPOT02, SCENE_SPOT03, SCENE_SPOT04, SCENE_SPOT05, SCENE_SPOT06, SCENE_SPOT07, SCENE_SPOT08, SCENE_SPOT09, SCENE_SPOT10, SCENE_SPOT11, SCENE_SPOT12, SCENE_SPOT13, @@ -1447,7 +1447,7 @@ s32 BgCheck_IsSpotScene(GlobalContext* globalCtx) { s16* i; for (i = spotScenes; i < spotScenes + ARRAY_COUNT(spotScenes); i++) { - if (globalCtx->sceneNum == *i) { + if (play->sceneNum == *i) { return true; } } @@ -1501,7 +1501,7 @@ typedef struct { /** * Allocate CollisionContext */ -void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader) { +void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader) { static BgCheckSceneSubdivisionEntry sceneSubdivisionList[] = { { SCENE_HAKADAN, { 23, 7, 14 }, -1 }, { SCENE_BMORI1, { 38, 1, 38 }, -1 }, @@ -1522,7 +1522,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis osSyncPrintf("/*---------------- BGCheck バッファーメモリサイズ -------------*/\n"); if (YREG(15) == 0x10 || YREG(15) == 0x20 || YREG(15) == 0x30 || YREG(15) == 0x40) { - if (globalCtx->sceneNum == SCENE_MALON_STABLE) { + if (play->sceneNum == SCENE_MALON_STABLE) { // "/* BGCheck LonLon Size %dbyte */\n" osSyncPrintf("/* BGCheck LonLonサイズ %dbyte */\n", 0x3520); colCtx->memSize = 0x3520; @@ -1537,7 +1537,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis colCtx->subdivAmount.x = 2; colCtx->subdivAmount.y = 2; colCtx->subdivAmount.z = 2; - } else if (BgCheck_IsSpotScene(globalCtx) == true) { + } else if (BgCheck_IsSpotScene(play) == true) { colCtx->memSize = 0xF000; // "/* BGCheck Spot Size %dbyte */\n" osSyncPrintf("/* BGCheck Spot用サイズ %dbyte */\n", 0xF000); @@ -1548,7 +1548,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis colCtx->subdivAmount.y = 4; colCtx->subdivAmount.z = 16; } else { - if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) { + if (BgCheck_TryGetCustomMemsize(play->sceneNum, &customMemSize)) { colCtx->memSize = customMemSize; } else { colCtx->memSize = 0x1CC00; @@ -1561,7 +1561,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis useCustomSubdivisions = false; for (i = 0; i < ARRAY_COUNT(sceneSubdivisionList); i++) { - if (globalCtx->sceneNum == sceneSubdivisionList[i].sceneId) { + if (play->sceneNum == sceneSubdivisionList[i].sceneId) { colCtx->subdivAmount.x = sceneSubdivisionList[i].subdivAmount.x; colCtx->subdivAmount.y = sceneSubdivisionList[i].subdivAmount.y; colCtx->subdivAmount.z = sceneSubdivisionList[i].subdivAmount.z; @@ -1576,7 +1576,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis } } colCtx->lookupTbl = THA_AllocEndAlign( - &globalCtx->state.tha, + &play->state.tha, colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1); if (colCtx->lookupTbl == NULL) { LOG_HUNGUP_THREAD(); @@ -1624,15 +1624,15 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis } SSNodeList_Initialize(&colCtx->polyNodes); - SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons); + SSNodeList_Alloc(play, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons); - lookupTblMemSize = BgCheck_InitializeStaticLookup(colCtx, globalCtx, colCtx->lookupTbl); + lookupTblMemSize = BgCheck_InitializeStaticLookup(colCtx, play, colCtx->lookupTbl); osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("/*---結局 BG使用サイズ %dbyte---*/\n", memSize + lookupTblMemSize); osSyncPrintf(VT_RST); - DynaPoly_Init(globalCtx, &colCtx->dyna); - DynaPoly_Alloc(globalCtx, &colCtx->dyna); + DynaPoly_Init(play, &colCtx->dyna); + DynaPoly_Alloc(play, &colCtx->dyna); } /** @@ -1675,7 +1675,7 @@ s32 BgCheck_PosInStaticBoundingBox(CollisionContext* colCtx, Vec3f* pos) { * returns the yIntersect of the nearest poly found directly below `pos`, or BGCHECK_Y_MIN if no floor detected * returns the poly found in `outPoly`, and the bgId of the entity in `outBgId` */ -f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, +f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFlags, CollisionPoly** outPoly, s32* outBgId, Vec3f* pos, Actor* actor, u32 arg7, f32 chkDist) { f32 yIntersectDyna; @@ -1720,7 +1720,7 @@ f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx, dynaRaycast.actor = actor; dynaRaycast.unk_20 = arg7; dynaRaycast.chkDist = chkDist; - dynaRaycast.globalCtx = globalCtx; + dynaRaycast.play = play; dynaRaycast.resultPoly = outPoly; dynaRaycast.bgId = outBgId; @@ -1760,11 +1760,11 @@ f32 BgCheck_EntityRaycastFloor1(CollisionContext* colCtx, CollisionPoly** outPol * Public raycast toward floor * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected */ -f32 BgCheck_EntityRaycastFloor2(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, +f32 BgCheck_EntityRaycastFloor2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, Vec3f* pos) { s32 bgId; - return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f); + return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f); } /** @@ -1788,9 +1788,9 @@ f32 BgCheck_EntityRaycastFloor4(CollisionContext* colCtx, CollisionPoly** outPol * Public raycast toward floor * returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected */ -f32 BgCheck_EntityRaycastFloor5(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, +f32 BgCheck_EntityRaycastFloor5(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId, Actor* actor, Vec3f* pos) { - return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f); + return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f); } /** @@ -2441,14 +2441,14 @@ void SSNodeList_Initialize(SSNodeList* this) { * tblMax is the number of SSNode records to allocate * numPolys is the number of polygons defined within the CollisionHeader */ -void SSNodeList_Alloc(GlobalContext* globalCtx, SSNodeList* this, s32 tblMax, s32 numPolys) { +void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys) { this->max = tblMax; this->count = 0; - this->tbl = THA_AllocEndAlign(&globalCtx->state.tha, tblMax * sizeof(SSNode), -2); + this->tbl = THA_AllocEndAlign(&play->state.tha, tblMax * sizeof(SSNode), -2); ASSERT(this->tbl != NULL); - this->polyCheckTbl = GAMESTATE_ALLOC_MC(&globalCtx->state, numPolys); + this->polyCheckTbl = GAMESTATE_ALLOC_MC(&play->state, numPolys); ASSERT(this->polyCheckTbl != NULL); } @@ -2534,7 +2534,7 @@ void DynaLookup_ResetVtxStartIndex(u16* vtxStartIndex) { /** * Initialize BgActor */ -void BgActor_Initialize(GlobalContext* globalCtx, BgActor* bgActor) { +void BgActor_Initialize(PlayState* play, BgActor* bgActor) { bgActor->actor = NULL; bgActor->colHeader = NULL; ScaleRotPos_Initialize(&bgActor->prevTransform); @@ -2577,8 +2577,8 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) { /** * Allocate dyna.polyList */ -void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) { - *polyList = THA_AllocEndAlign(&globalCtx->state.tha, numPolys * sizeof(CollisionPoly), -2); +void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) { + *polyList = THA_AllocEndAlign(&play->state.tha, numPolys * sizeof(CollisionPoly), -2); ASSERT(*polyList != NULL); } @@ -2592,15 +2592,15 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) { /** * Allocate dyna.vtxList */ -void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) { - *vtxList = THA_AllocEndAlign(&globalCtx->state.tha, numVtx * sizeof(Vec3s), -2); +void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) { + *vtxList = THA_AllocEndAlign(&play->state.tha, numVtx * sizeof(Vec3s), -2); ASSERT(*vtxList != NULL); } /** * Update BgActor's prevTransform */ -void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor) { +void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) { bgActor->prevTransform = bgActor->curTransform; } @@ -2617,38 +2617,38 @@ s32 DynaPoly_IsBgIdBgActor(s32 bgId) { /** * Init DynaCollisionContext */ -void DynaPoly_Init(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_Init(PlayState* play, DynaCollisionContext* dyna) { dyna->bitFlag = DYNAPOLY_INVALIDATE_LOOKUP; DynaPoly_NullPolyList(&dyna->polyList); DynaPoly_NullVtxList(&dyna->vtxList); - DynaSSNodeList_Initialize(globalCtx, &dyna->polyNodes); + DynaSSNodeList_Initialize(play, &dyna->polyNodes); } /** * Set DynaCollisionContext */ -void DynaPoly_Alloc(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_Alloc(PlayState* play, DynaCollisionContext* dyna) { s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { - BgActor_Initialize(globalCtx, &dyna->bgActors[i]); + BgActor_Initialize(play, &dyna->bgActors[i]); dyna->bgActorFlags[i] = 0; } DynaPoly_NullPolyList(&dyna->polyList); - DynaPoly_AllocPolyList(globalCtx, &dyna->polyList, dyna->polyListMax); + DynaPoly_AllocPolyList(play, &dyna->polyList, dyna->polyListMax); DynaPoly_NullVtxList(&dyna->vtxList); - DynaPoly_AllocVtxList(globalCtx, &dyna->vtxList, dyna->vtxListMax); + DynaPoly_AllocVtxList(play, &dyna->vtxList, dyna->vtxListMax); - DynaSSNodeList_Initialize(globalCtx, &dyna->polyNodes); - DynaSSNodeList_Alloc(globalCtx, &dyna->polyNodes, dyna->polyNodesMax); + DynaSSNodeList_Initialize(play, &dyna->polyNodes); + DynaSSNodeList_Alloc(play, &dyna->polyNodes, dyna->polyNodesMax); } /** * Set BgActor * original name: DynaPolyInfo_setActor */ -s32 DynaPoly_SetBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor, +s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader) { s32 bgId; s32 foundSlot = false; @@ -2690,28 +2690,28 @@ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) { return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor; } -void func_8003EBF8(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_8003EBF8(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] |= 4; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_8003EC50(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_8003EC50(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] &= ~4; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_8003ECA8(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_8003ECA8(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] |= 8; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } -void func_8003ED00(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void func_8003ED00(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { if (DynaPoly_IsBgIdBgActor(bgId)) { dyna->bgActorFlags[bgId] &= ~8; dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; @@ -2721,7 +2721,7 @@ void func_8003ED00(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgI /** * original name: DynaPolyInfo_delReserve */ -void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) { +void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgId) { DynaPolyActor* actor; osSyncPrintf(VT_FGCOL(GREEN)); @@ -2746,7 +2746,7 @@ void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna return; } } - actor = DynaPoly_GetActor(&globalCtx->colCtx, bgId); + actor = DynaPoly_GetActor(&play->colCtx, bgId); if (actor != NULL) { actor->bgId = BGACTOR_NEG_ONE; @@ -2755,14 +2755,14 @@ void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna } } -void func_8003EE6C(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void func_8003EE6C(PlayState* play, DynaCollisionContext* dyna) { dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } /** * original name: DynaPolyInfo_expandSRT */ -void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, +void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex) { MtxF mtx; Actor* actor; @@ -2941,13 +2941,13 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3 } } -void func_8003F8EC(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor) { +void func_8003F8EC(PlayState* play, DynaCollisionContext* dyna, Actor* actor) { DynaPolyActor* dynaActor; s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { if ((dyna->bgActorFlags[i] & 1)) { - dynaActor = DynaPoly_GetActor(&globalCtx->colCtx, i); + dynaActor = DynaPoly_GetActor(&play->colCtx, i); if (dynaActor != NULL && &dynaActor->actor == actor) { func_800434A0((DynaPolyActor*)actor); return; @@ -2959,7 +2959,7 @@ void func_8003F8EC(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* /** * DynaPolyInfo_setup */ -void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) { DynaPolyActor* actor; s32 vtxStartIndex; s32 polyStartIndex; @@ -2979,7 +2979,7 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { osSyncPrintf(VT_RST); dyna->bgActorFlags[i] = 0; - BgActor_Initialize(globalCtx, &dyna->bgActors[i]); + BgActor_Initialize(play, &dyna->bgActors[i]); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) { @@ -2987,14 +2987,14 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("DynaPolyInfo_setup():削除 index=%d\n", i); osSyncPrintf(VT_RST); - actor = DynaPoly_GetActor(&globalCtx->colCtx, i); + actor = DynaPoly_GetActor(&play->colCtx, i); if (actor == NULL) { return; } actor->bgId = BGACTOR_NEG_ONE; dyna->bgActorFlags[i] = 0; - BgActor_Initialize(globalCtx, &dyna->bgActors[i]); + BgActor_Initialize(play, &dyna->bgActors[i]); dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP; } } @@ -3002,7 +3002,7 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { polyStartIndex = 0; for (i = 0; i < BG_ACTOR_MAX; i++) { if (dyna->bgActorFlags[i] & 1) { - DynaPoly_ExpandSRT(globalCtx, dyna, i, &vtxStartIndex, &polyStartIndex); + DynaPoly_ExpandSRT(play, dyna, i, &vtxStartIndex, &polyStartIndex); } } dyna->bitFlag &= ~DYNAPOLY_INVALIDATE_LOOKUP; @@ -3011,12 +3011,12 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) { /** * Update all BgActor's previous ScaleRotPos */ -void DynaPoly_UpdateBgActorTransforms(GlobalContext* globalCtx, DynaCollisionContext* dyna) { +void DynaPoly_UpdateBgActorTransforms(PlayState* play, DynaCollisionContext* dyna) { s32 i; for (i = 0; i < BG_ACTOR_MAX; i++) { if (dyna->bgActorFlags[i] & 1) { - DynaPoly_SetBgActorPrevTransform(globalCtx, &dyna->bgActors[i]); + DynaPoly_SetBgActorPrevTransform(play, &dyna->bgActors[i]); } } } @@ -3155,10 +3155,10 @@ f32 BgCheck_RaycastFloorDyna(DynaRaycast* dynaRaycast) { } dynaActor = DynaPoly_GetActor(dynaRaycast->colCtx, *dynaRaycast->bgId); - if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->globalCtx != NULL)) { - pauseState = dynaRaycast->globalCtx->pauseCtx.state != 0; + if ((result != BGCHECK_Y_MIN) && (dynaActor != NULL) && (dynaRaycast->play != NULL)) { + pauseState = dynaRaycast->play->pauseCtx.state != 0; if (pauseState == 0) { - pauseState = dynaRaycast->globalCtx->pauseCtx.debugState != 0; + pauseState = dynaRaycast->play->pauseCtx.debugState != 0; } if (!pauseState && (dynaRaycast->colCtx->dyna.bgActorFlags[*dynaRaycast->bgId] & 2)) { curTransform = &dynaRaycast->dyna->bgActors[*dynaRaycast->bgId].curTransform; @@ -3820,7 +3820,7 @@ void CollisionHeader_GetVirtual(void* colHeader, CollisionHeader** dest) /** * SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders */ -void func_800418D0(CollisionContext* colCtx, GlobalContext* globalCtx) { +void func_800418D0(CollisionContext* colCtx, PlayState* play) { DynaCollisionContext* dyna = &colCtx->dyna; s32 i; u16 flag; @@ -3828,7 +3828,7 @@ void func_800418D0(CollisionContext* colCtx, GlobalContext* globalCtx) { for (i = 0; i < BG_ACTOR_MAX; i++) { flag = dyna->bgActorFlags[i]; if ((flag & 1) && !(flag & 2)) { - Actor_SetObjectDependency(globalCtx, dyna->bgActors[i].actor); + Actor_SetObjectDependency(play, dyna->bgActors[i].actor); CollisionHeader_SegmentedToVirtual(dyna->bgActors[i].colHeader); } } @@ -4205,9 +4205,9 @@ f32 zdWaterBoxMaxZ = -967.0f; * returns true if point is within the xz boundaries of an active water box, else false * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ -s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { - if (globalCtx->sceneNum == SCENE_SPOT07) { + if (play->sceneNum == SCENE_SPOT07) { if (zdWaterBoxMinX < x && x < zdWaterBoxMaxX && zdWaterBoxMinY < *ySurface && *ySurface < zdWaterBoxMaxY && zdWaterBoxMinZ < z && z < zdWaterBoxMaxZ) { *outWaterBox = &zdWaterBox; @@ -4215,7 +4215,7 @@ s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 return true; } } - return WaterBox_GetSurfaceImpl(globalCtx, colCtx, x, z, ySurface, outWaterBox); + return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox); } /** @@ -4223,7 +4223,7 @@ s32 WaterBox_GetSurface1(GlobalContext* globalCtx, CollisionContext* colCtx, f32 * returns true if point is within the xz boundaries of an active water box, else false * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ -s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +s32 WaterBox_GetSurfaceImpl(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { CollisionHeader* colHeader = colCtx->colHeader; u32 room; @@ -4236,7 +4236,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = (curWaterBox->properties >> 13) & 0x3F; - if (room == (u32)globalCtx->roomCtx.curRoom.num || room == 0x3F) { + if (room == (u32)play->roomCtx.curRoom.num || room == 0x3F) { if ((curWaterBox->properties & 0x80000) == 0) { if (curWaterBox->xMin < x && x < curWaterBox->xMin + curWaterBox->xLength) { if (curWaterBox->zMin < z && z < curWaterBox->zMin + curWaterBox->zLength) { @@ -4257,7 +4257,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx, * returns the index of the waterbox found, or -1 if no waterbox is found * `outWaterBox` returns the pointer to the waterbox found, or NULL if none is found */ -s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, +s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, WaterBox** outWaterBox) { CollisionHeader* colHeader = colCtx->colHeader; s32 room; @@ -4274,7 +4274,7 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec waterBox = &colHeader->waterBoxes[i]; room = WATERBOX_ROOM(waterBox->properties); - if (!(room == globalCtx->roomCtx.curRoom.num || room == 0x3F)) { + if (!(room == play->roomCtx.curRoom.num || room == 0x3F)) { continue; } if ((waterBox->properties & 0x80000)) { @@ -4334,7 +4334,7 @@ u32 WaterBox_GetLightSettingIndex(CollisionContext* colCtx, WaterBox* waterBox) * returns true if point is within the xz boundaries of an active water box, else false * `ySurface` returns the water box's surface, while `outWaterBox` returns a pointer to the WaterBox */ -s32 func_800425B0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, +s32 func_800425B0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { CollisionHeader* colHeader = colCtx->colHeader; u32 room; @@ -4347,7 +4347,7 @@ s32 func_800425B0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes; curWaterBox++) { room = (curWaterBox->properties >> 0xD) & 0x3F; - if ((room == (u32)globalCtx->roomCtx.curRoom.num) || (room == 0x3F)) { + if ((room == (u32)play->roomCtx.curRoom.num) || (room == 0x3F)) { if ((curWaterBox->properties & 0x80000) != 0) { if (curWaterBox->xMin < x && x < (curWaterBox->xMin + curWaterBox->xLength)) { if (curWaterBox->zMin < z && z < (curWaterBox->zMin + curWaterBox->zLength)) { @@ -4403,7 +4403,7 @@ s32 func_800427B4(CollisionPoly* polyA, CollisionPoly* polyB, Vec3f* pointA, Vec /** * Draw a list of dyna polys, specified by `ssList` */ -void BgCheck_DrawDynaPolyList(GlobalContext* globalCtx, CollisionContext* colCtx, DynaCollisionContext* dyna, +void BgCheck_DrawDynaPolyList(PlayState* play, CollisionContext* colCtx, DynaCollisionContext* dyna, SSList* ssList, u8 r, u8 g, u8 b) { s16 curPolyId; CollisionPoly* poly; @@ -4437,7 +4437,7 @@ void BgCheck_DrawDynaPolyList(GlobalContext* globalCtx, CollisionContext* colCtx vC.y += AREG(26) * ny; vC.z += AREG(26) * nz; } - Collider_DrawPoly(globalCtx->state.gfxCtx, &vA, &vB, &vC, r, g, b); + Collider_DrawPoly(play->state.gfxCtx, &vA, &vB, &vC, r, g, b); if (curNode->next == SS_NULL) { break; } @@ -4450,17 +4450,17 @@ void BgCheck_DrawDynaPolyList(GlobalContext* globalCtx, CollisionContext* colCtx * Draw a BgActor's dyna polys * `bgId` is the BgActor index that should be drawn */ -void BgCheck_DrawBgActor(GlobalContext* globalCtx, CollisionContext* colCtx, s32 bgId) { +void BgCheck_DrawBgActor(PlayState* play, CollisionContext* colCtx, s32 bgId) { if (AREG(21)) { - BgCheck_DrawDynaPolyList(globalCtx, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.ceiling, 255, + BgCheck_DrawDynaPolyList(play, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.ceiling, 255, 0, 0); } if (AREG(22)) { - BgCheck_DrawDynaPolyList(globalCtx, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.wall, 0, 255, + BgCheck_DrawDynaPolyList(play, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.wall, 0, 255, 0); } if (AREG(23)) { - BgCheck_DrawDynaPolyList(globalCtx, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.floor, 0, 0, + BgCheck_DrawDynaPolyList(play, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.floor, 0, 0, 255); } } @@ -4468,7 +4468,7 @@ void BgCheck_DrawBgActor(GlobalContext* globalCtx, CollisionContext* colCtx, s32 /** * Draw all dyna polys */ -void BgCheck_DrawDynaCollision(GlobalContext* globalCtx, CollisionContext* colCtx) { +void BgCheck_DrawDynaCollision(PlayState* play, CollisionContext* colCtx) { s32 bgId; for (bgId = 0; bgId < BG_ACTOR_MAX; bgId++) { @@ -4476,14 +4476,14 @@ void BgCheck_DrawDynaCollision(GlobalContext* globalCtx, CollisionContext* colCt if (!(colCtx->dyna.bgActorFlags[bgId] & 1)) { continue; } - BgCheck_DrawBgActor(globalCtx, colCtx, bgId); + BgCheck_DrawBgActor(play, colCtx, bgId); } } /** * Draw a static poly */ -void BgCheck_DrawStaticPoly(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly* poly, u8 r, u8 g, u8 b) { +void BgCheck_DrawStaticPoly(PlayState* play, CollisionContext* colCtx, CollisionPoly* poly, u8 r, u8 g, u8 b) { Vec3f vA; Vec3f vB; Vec3f vC; @@ -4508,13 +4508,13 @@ void BgCheck_DrawStaticPoly(GlobalContext* globalCtx, CollisionContext* colCtx, vC.y += AREG(26) * ny; vC.z += AREG(26) * nz; } - Collider_DrawPoly(globalCtx->state.gfxCtx, &vA, &vB, &vC, r, g, b); + Collider_DrawPoly(play->state.gfxCtx, &vA, &vB, &vC, r, g, b); } /** * Draw a list of static polys, specified by `ssList` */ -void BgCheck_DrawStaticPolyList(GlobalContext* globalCtx, CollisionContext* colCtx, SSList* ssList, u8 r, u8 g, u8 b) { +void BgCheck_DrawStaticPolyList(PlayState* play, CollisionContext* colCtx, SSList* ssList, u8 r, u8 g, u8 b) { SSNode* curNode; CollisionPoly* polyList = colCtx->colHeader->polyList; s16 curPolyId; @@ -4523,7 +4523,7 @@ void BgCheck_DrawStaticPolyList(GlobalContext* globalCtx, CollisionContext* colC curNode = &colCtx->polyNodes.tbl[ssList->head]; while (true) { curPolyId = curNode->polyId; - BgCheck_DrawStaticPoly(globalCtx, colCtx, &polyList[curPolyId], r, g, b); + BgCheck_DrawStaticPoly(play, colCtx, &polyList[curPolyId], r, g, b); if (curNode->next == SS_NULL) { break; } @@ -4535,17 +4535,17 @@ void BgCheck_DrawStaticPolyList(GlobalContext* globalCtx, CollisionContext* colC /** * Draw scene collision */ -void BgCheck_DrawStaticCollision(GlobalContext* globalCtx, CollisionContext* colCtx) { - Player* player = GET_PLAYER(globalCtx); +void BgCheck_DrawStaticCollision(PlayState* play, CollisionContext* colCtx) { + Player* player = GET_PLAYER(play); StaticLookup* lookup = BgCheck_GetNearestStaticLookup(colCtx, colCtx->lookupTbl, &player->actor.world.pos); if (AREG(23) != 0) { - BgCheck_DrawStaticPolyList(globalCtx, colCtx, &lookup->floor, 0, 0, 255); + BgCheck_DrawStaticPolyList(play, colCtx, &lookup->floor, 0, 0, 255); } if (AREG(22) != 0) { - BgCheck_DrawStaticPolyList(globalCtx, colCtx, &lookup->wall, 0, 255, 0); + BgCheck_DrawStaticPolyList(play, colCtx, &lookup->wall, 0, 255, 0); } if (AREG(21) != 0) { - BgCheck_DrawStaticPolyList(globalCtx, colCtx, &lookup->ceiling, 255, 0, 0); + BgCheck_DrawStaticPolyList(play, colCtx, &lookup->ceiling, 255, 0, 0); } } diff --git a/soh/src/code/z_camera.c b/soh/src/code/z_camera.c index c1003c6dd..a2147d97a 100644 --- a/soh/src/code/z_camera.c +++ b/soh/src/code/z_camera.c @@ -211,7 +211,7 @@ Vec3f* Camera_Vec3fTranslateByUnitVector(Vec3f* dest, Vec3f* src, Vec3f* unitVec * Detects the collision poly between `from` and `to`, places collision info in `to` */ s32 Camera_BGCheckInfo(Camera* camera, Vec3f* from, CamColChk* to) { - CollisionContext* colCtx = &camera->globalCtx->colCtx; + CollisionContext* colCtx = &camera->play->colCtx; Vec3f toNewPos; Vec3f toPoint; Vec3f fromToNorm; @@ -274,7 +274,7 @@ s32 Camera_BGCheck(Camera* camera, Vec3f* from, Vec3f* to) { } s32 func_80043F94(Camera* camera, Vec3f* from, CamColChk* to) { - CollisionContext* colCtx = &camera->globalCtx->colCtx; + CollisionContext* colCtx = &camera->play->colCtx; Vec3f toNewPos; Vec3f toPos; Vec3f fromToNorm; @@ -359,7 +359,7 @@ s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) { s32 pad2; s32 bgId; CollisionPoly* poly; - CollisionContext* colCtx = &camera->globalCtx->colCtx; + CollisionContext* colCtx = &camera->play->colCtx; poly = NULL; if (BgCheck_CameraLineTest1(colCtx, from, to, &intersect, &poly, 1, 1, 1, 0, &bgId) && @@ -378,7 +378,7 @@ s32 Camera_CheckOOB(Camera* camera, Vec3f* from, Vec3f* to) { f32 Camera_GetFloorYNorm(Camera* camera, Vec3f* floorNorm, Vec3f* chkPos, s32* bgId) { s32 pad; CollisionPoly* floorPoly; - f32 floorY = BgCheck_EntityRaycastFloor3(&camera->globalCtx->colCtx, &floorPoly, bgId, chkPos); + f32 floorY = BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, bgId, chkPos); if (floorY == BGCHECK_Y_MIN) { // no floor @@ -414,7 +414,7 @@ f32 Camera_GetFloorY(Camera* camera, Vec3f* pos) { */ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) { CollisionPoly* floorPoly; - CollisionContext* colCtx = &camera->globalCtx->colCtx; + CollisionContext* colCtx = &camera->play->colCtx; f32 floorY; s32 i; @@ -449,14 +449,14 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) { * Returns the CameraSettingType of the camera at index `camDataIdx` */ s16 Camera_GetCamDataSetting(Camera* camera, s32 camDataIdx) { - return func_80041A4C(&camera->globalCtx->colCtx, camDataIdx, BGCHECK_SCENE); + return func_80041A4C(&camera->play->colCtx, camDataIdx, BGCHECK_SCENE); } /** * Returns the scene camera info for the current camera data index */ Vec3s* Camera_GetCamBGData(Camera* camera) { - return func_80041C10(&camera->globalCtx->colCtx, camera->camDataIdx, BGCHECK_SCENE); + return func_80041C10(&camera->play->colCtx, camera->camDataIdx, BGCHECK_SCENE); } /** @@ -469,9 +469,9 @@ s32 Camera_GetDataIdxForPoly(Camera* camera, s32* bgId, CollisionPoly* poly) { s32 ret; Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); // unused. - camDataIdx = SurfaceType_GetCamDataIndex(&camera->globalCtx->colCtx, poly, *bgId); + camDataIdx = SurfaceType_GetCamDataIndex(&camera->play->colCtx, poly, *bgId); - if (func_80041A4C(&camera->globalCtx->colCtx, camDataIdx, *bgId) == CAM_SET_NONE) { + if (func_80041A4C(&camera->play->colCtx, camDataIdx, *bgId) == CAM_SET_NONE) { ret = -1; } else { ret = camDataIdx; @@ -492,13 +492,13 @@ Vec3s* Camera_GetCamBgDataUnderPlayer(Camera* camera, u16* dataCnt) { Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor); playerPosShape.pos.y += Player_GetHeight(camera->player); - if (BgCheck_EntityRaycastFloor3(&camera->globalCtx->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == + if (BgCheck_EntityRaycastFloor3(&camera->play->colCtx, &floorPoly, &bgId, &playerPosShape.pos) == BGCHECK_Y_MIN) { // no floor return NULL; } - *dataCnt = SurfaceType_GetNumCameras(&camera->globalCtx->colCtx, floorPoly, bgId); - return SurfaceType_GetCamPosData(&camera->globalCtx->colCtx, floorPoly, bgId); + *dataCnt = SurfaceType_GetNumCameras(&camera->play->colCtx, floorPoly, bgId); + return SurfaceType_GetCamPosData(&camera->play->colCtx, floorPoly, bgId); } /** @@ -515,7 +515,7 @@ s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) { Actor_GetWorldPosShapeRot(&playerPosShape, &camera->player->actor); *waterY = playerPosShape.pos.y; - if (!WaterBox_GetSurface1(camera->globalCtx, &camera->globalCtx->colCtx, playerPosShape.pos.x, playerPosShape.pos.z, + if (!WaterBox_GetSurface1(camera->play, &camera->play->colCtx, playerPosShape.pos.x, playerPosShape.pos.z, waterY, &waterBox)) { // player's position is not in a water box. *waterY = BGCHECK_Y_MIN; @@ -528,8 +528,8 @@ s32 Camera_GetWaterBoxDataIdx(Camera* camera, f32* waterY) { return -1; } - ret = WaterBox_GetCamDataIndex(&camera->globalCtx->colCtx, waterBox); - if ((ret <= 0) || (WaterBox_GetCameraSType(&camera->globalCtx->colCtx, waterBox) <= 0)) { + ret = WaterBox_GetCamDataIndex(&camera->play->colCtx, waterBox); + if ((ret <= 0) || (WaterBox_GetCameraSType(&camera->play->colCtx, waterBox) <= 0)) { // no camera data idx, or no CameraSettingType return -2; } @@ -550,7 +550,7 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) { Actor_GetWorldPosShapeRot(&playerPosRot, &camera->player->actor); waterY = playerPosRot.pos.y; - if (!WaterBox_GetSurface1(camera->globalCtx, &camera->globalCtx->colCtx, chkPos->x, chkPos->z, &waterY, + if (!WaterBox_GetSurface1(camera->play, &camera->play->colCtx, chkPos->x, chkPos->z, &waterY, &waterBox)) { // chkPos is not within the x/z boundaries of a water box. return BGCHECK_Y_MIN; @@ -562,7 +562,7 @@ f32 Camera_GetWaterSurface(Camera* camera, Vec3f* chkPos, s32* envProp) { return BGCHECK_Y_MIN; } - *envProp = WaterBox_GetLightSettingIndex(&camera->globalCtx->colCtx, waterBox); + *envProp = WaterBox_GetLightSettingIndex(&camera->play->colCtx, waterBox); return waterY; } @@ -604,7 +604,7 @@ s16 func_80044ADC(Camera* camera, s16 yaw, s16 arg2) { rotatedPos.x = playerPos.x + (sp30 * sinYaw); rotatedPos.y = playerPos.y; rotatedPos.z = playerPos.z + (sp30 * cosYaw); - if (arg2 || (camera->globalCtx->state.frames % 2) == 0) { + if (arg2 || (camera->play->state.frames % 2) == 0) { D_8015CE58.pos.x = playerPos.x + (sp2C * sinYaw); D_8015CE58.pos.y = playerPos.y; D_8015CE58.pos.z = playerPos.z + (sp2C * cosYaw); @@ -1419,17 +1419,17 @@ s32 SetCameraManual(Camera* camera) { f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f; f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f; - if ((fabsf(newCamX) >= 15.0f || fabsf(newCamY) >= 15.0f) && camera->globalCtx->manualCamera == false) { - camera->globalCtx->manualCamera = true; + if ((fabsf(newCamX) >= 15.0f || fabsf(newCamY) >= 15.0f) && camera->play->manualCamera == false) { + camera->play->manualCamera = true; VecSph eyeAdjustment; OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, &camera->at, &camera->eye); - camera->globalCtx->camX = eyeAdjustment.yaw; - camera->globalCtx->camY = eyeAdjustment.pitch; + camera->play->camX = eyeAdjustment.yaw; + camera->play->camY = eyeAdjustment.pitch; } - if (camera->globalCtx->manualCamera) { + if (camera->play->manualCamera) { return 1; } @@ -1458,8 +1458,8 @@ s32 Camera_Free(Camera* camera) { if (RELOAD_PARAMS) { OLib_Vec3fDiffToVecSphGeo(&spA8, &camera->at, &camera->eye); - camera->globalCtx->camX = spA8.yaw; - camera->globalCtx->camY = spA8.pitch; + camera->play->camX = spA8.yaw; + camera->play->camY = spA8.pitch; CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; f32 yNormal = (1.0f + PCT(OREG(46))) - (PCT(OREG(46)) * (68.0f / playerHeight)); @@ -1488,22 +1488,22 @@ s32 Camera_Free(Camera* camera) { f32 newCamX = -D_8015BD7C->state.input[0].cur.right_stick_x * 10.0f * (CVar_GetFloat("gCameraSensitivity", 1.0f)); f32 newCamY = D_8015BD7C->state.input[0].cur.right_stick_y * 10.0f * (CVar_GetFloat("gCameraSensitivity", 1.0f)); - camera->globalCtx->camX += newCamX * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1); - camera->globalCtx->camY += newCamY * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1); + camera->play->camX += newCamX * (CVar_GetS32("gInvertXAxis", 0) ? -1 : 1); + camera->play->camY += newCamY * (CVar_GetS32("gInvertYAxis", 1) ? 1 : -1); - if (camera->globalCtx->camY > 0x32A4) { - camera->globalCtx->camY = 0x32A4; + if (camera->play->camY > 0x32A4) { + camera->play->camY = 0x32A4; } - if (camera->globalCtx->camY < -0x228C) { - camera->globalCtx->camY = -0x228C; + if (camera->play->camY < -0x228C) { + camera->play->camY = -0x228C; } camera->dist = Camera_LERPCeilF(para1->distTarget, camera->dist, 1.0f / camera->rUpdateRateInv, 0.0f); OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext); spA8.r = camera->dist; - spA8.yaw = camera->globalCtx->camX; - spA8.pitch = camera->globalCtx->camY; + spA8.yaw = camera->play->camX; + spA8.pitch = camera->play->camY; Camera_Vec3fVecSphGeoAdd(eyeNext, at, &spA8); if (camera->status == CAM_STAT_ACTIVE) { @@ -1733,7 +1733,7 @@ s32 Camera_Normal1(Camera* camera) { // crit wiggle if(!CVar_GetS32("gDisableCritWiggle",0)) { - if (gSaveContext.health <= 16 && ((camera->globalCtx->state.frames % 256) == 0)) { + if (gSaveContext.health <= 16 && ((camera->play->state.frames % 256) == 0)) { wiggleAdj = Rand_ZeroOne() * 10000.0f; camera->inputDir.y = wiggleAdj + camera->inputDir.y; } @@ -1903,7 +1903,7 @@ s32 Camera_Normal2(Camera* camera) { if (camera->status == CAM_STAT_ACTIVE) { bgChk.pos = *eyeNext; - if (!camera->globalCtx->envCtx.skyboxDisabled || norm2->interfaceFlags & 0x10) { + if (!camera->play->envCtx.skyboxDisabled || norm2->interfaceFlags & 0x10) { Camera_BGCheckInfo(camera, at, &bgChk); *eye = bgChk.pos; } else { @@ -2123,7 +2123,7 @@ s32 Camera_Parallel1(Camera* camera) { OLib_Vec3fDiffToVecSphGeo(&atToEyeDir, at, eye); OLib_Vec3fDiffToVecSphGeo(&atToEyeNextDir, at, eyeNext); - camera->globalCtx->manualCamera = false; + camera->play->manualCamera = false; switch (camera->animState) { case 0: @@ -2241,7 +2241,7 @@ s32 Camera_Parallel1(Camera* camera) { Camera_Vec3fVecSphGeoAdd(eyeNext, at, &spA8); if (camera->status == CAM_STAT_ACTIVE) { sp6C.pos = *eyeNext; - if (!camera->globalCtx->envCtx.skyboxDisabled || para1->interfaceFlags & 0x10) { + if (!camera->play->envCtx.skyboxDisabled || para1->interfaceFlags & 0x10) { Camera_BGCheckInfo(camera, at, &sp6C); *eye = sp6C.pos; } else { @@ -3051,7 +3051,7 @@ s32 Camera_Battle1(Camera* camera) { Camera_Vec3fVecSphGeoAdd(eyeNext, at, &spB4); spBC.pos = *eyeNext; if (camera->status == CAM_STAT_ACTIVE) { - if (!camera->globalCtx->envCtx.skyboxDisabled || batt1->flags & 1) { + if (!camera->play->envCtx.skyboxDisabled || batt1->flags & 1) { Camera_BGCheckInfo(camera, at, &spBC); } else if (batt1->flags & 2) { func_80043F94(camera, at, &spBC); @@ -3382,7 +3382,7 @@ s32 Camera_KeepOn1(Camera* camera) { Camera_Vec3fVecSphGeoAdd(eyeNext, at, &spD8); sp8C.pos = *eyeNext; if (camera->status == CAM_STAT_ACTIVE) { - if (!camera->globalCtx->envCtx.skyboxDisabled || keep1->interfaceFlags & 1) { + if (!camera->play->envCtx.skyboxDisabled || keep1->interfaceFlags & 1) { Camera_BGCheckInfo(camera, at, &sp8C); } else if (keep1->interfaceFlags & 2) { func_80043F94(camera, at, &sp8C); @@ -3448,9 +3448,9 @@ s32 Camera_KeepOn3(Camera* camera) { return 1; } if (camera->animState == 0 || camera->animState == 0xA || camera->animState == 0x14) { - if (camera->globalCtx->view.unk_124 == 0) { + if (camera->play->view.unk_124 == 0) { camera->unk_14C |= 0x20; - camera->globalCtx->view.unk_124 = camera->thisIdx | 0x50; + camera->play->view.unk_124 = camera->thisIdx | 0x50; return 1; } camera->unk_14C &= ~0x20; @@ -3538,7 +3538,7 @@ s32 Camera_KeepOn3(Camera* camera) { Camera_Vec3fVecSphGeoAdd(&lineChkPointB, &anim->atTarget, &atToEyeAdj); if (!(keep3->flags & 0x80)) { while (i < angleCnt) { - if (!CollisionCheck_LineOCCheck(camera->globalCtx, &camera->globalCtx->colChkCtx, &anim->atTarget, + if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &anim->atTarget, &lineChkPointB, colChkActors, 2) && !Camera_BGCheck(camera, &anim->atTarget, &lineChkPointB)) { break; @@ -3622,15 +3622,15 @@ s32 Camera_KeepOn4(Camera* camera) { KeepOn4_Unk20* unk20 = &keep4->unk_20; s32 pad; f32 playerHeight; - Player* player = GET_PLAYER(camera->globalCtx); + Player* player = GET_PLAYER(camera->play); s16 angleCnt; s32 i; if (camera->animState == 0 || camera->animState == 0xA || camera->animState == 0x14) { - if (camera->globalCtx->view.unk_124 == 0) { + if (camera->play->view.unk_124 == 0) { camera->unk_14C |= 0x20; camera->unk_14C &= ~(0x4 | 0x2); - camera->globalCtx->view.unk_124 = camera->thisIdx | 0x50; + camera->play->view.unk_124 = camera->thisIdx | 0x50; return 1; } unk20->unk_14 = *temp_s0; @@ -3643,7 +3643,7 @@ s32 Camera_KeepOn4(Camera* camera) { camera->animState = 0x14; camera->unk_14C |= 0x20; camera->unk_14C &= ~(0x4 | 0x2); - camera->globalCtx->view.unk_124 = camera->thisIdx | 0x50; + camera->play->view.unk_124 = camera->thisIdx | 0x50; return 1; } @@ -3761,7 +3761,7 @@ s32 Camera_KeepOn4(Camera* camera) { OLib_Vec3fDiffToVecSphGeo(&spA8, at, eyeNext); D_8015BD50 = playerPosRot->pos; D_8015BD50.y += playerHeight; - temp_f0_2 = BgCheck_CameraRaycastFloor2(&camera->globalCtx->colCtx, &spC0, &i, &D_8015BD50); + temp_f0_2 = BgCheck_CameraRaycastFloor2(&camera->play->colCtx, &spC0, &i, &D_8015BD50); if (temp_f0_2 > (keep4->unk_00 + D_8015BD50.y)) { D_8015BD50.y = temp_f0_2 + 10.0f; } else { @@ -3821,7 +3821,7 @@ s32 Camera_KeepOn4(Camera* camera) { if (!(keep4->unk_1C & 1)) { angleCnt = ARRAY_COUNT(D_8011D3B0); for (i = 0; i < angleCnt; i++) { - if (!CollisionCheck_LineOCCheck(camera->globalCtx, &camera->globalCtx->colChkCtx, &D_8015BD50, + if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &D_8015BD50, &D_8015BD70, spCC, sp9C) && !Camera_BGCheck(camera, &D_8015BD50, &D_8015BD70)) { break; @@ -4303,8 +4303,8 @@ s32 Camera_Subj3(Camera* camera) { Actor_GetFocus(&sp60, &camera->player->actor); playerHeight = Player_GetHeight(camera->player); - if (camera->globalCtx->view.unk_124 == 0) { - camera->globalCtx->view.unk_124 = camera->thisIdx | 0x50; + if (camera->play->view.unk_124 == 0) { + camera->play->view.unk_124 = camera->thisIdx | 0x50; return true; } @@ -4364,7 +4364,7 @@ s32 Camera_Subj3(Camera* camera) { *eye = *eyeNext; anim->animTimer--; - if (!camera->globalCtx->envCtx.skyboxDisabled) { + if (!camera->play->envCtx.skyboxDisabled) { Camera_BGCheck(camera, at, eye); } else { func_80044340(camera, at, eye); @@ -4430,8 +4430,8 @@ s32 Camera_Subj4(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - if (camera->globalCtx->view.unk_124 == 0) { - camera->globalCtx->view.unk_124 = (camera->thisIdx | 0x50); + if (camera->play->view.unk_124 == 0) { + camera->play->view.unk_124 = (camera->thisIdx | 0x50); anim->unk_24 = camera->xzSpeed; return true; } @@ -5223,11 +5223,11 @@ s32 Camera_Unique9(Camera* camera) { } else if ((anim->curKeyFrame->unk_01 & 0xF0) == 0xC0) { Camera_UpdateInterface(0xF000 | ((anim->curKeyFrame->unk_01 & 0xF) << 8)); } else if (camera->player->stateFlags1 & 0x8000000 && player->currentBoots != PLAYER_BOOTS_IRON) { - func_8002DF38(camera->globalCtx, camera->target, 8); + func_8002DF38(camera->play, camera->target, 8); osSyncPrintf("camera: demo: player demo set WAIT\n"); } else { osSyncPrintf("camera: demo: player demo set %d\n", anim->curKeyFrame->unk_01); - func_8002DF38(camera->globalCtx, camera->target, anim->curKeyFrame->unk_01); + func_8002DF38(camera->play, camera->target, anim->curKeyFrame->unk_01); } } } else { @@ -5246,9 +5246,9 @@ s32 Camera_Unique9(Camera* camera) { anim->atTarget = anim->curKeyFrame->atTargetInit; } else if (atInitFlags == 2) { if (anim->isNewKeyFrame) { - anim->atTarget.x = camera->globalCtx->view.lookAt.x + anim->curKeyFrame->atTargetInit.x; - anim->atTarget.y = camera->globalCtx->view.lookAt.y + anim->curKeyFrame->atTargetInit.y; - anim->atTarget.z = camera->globalCtx->view.lookAt.z + anim->curKeyFrame->atTargetInit.z; + anim->atTarget.x = camera->play->view.lookAt.x + anim->curKeyFrame->atTargetInit.x; + anim->atTarget.y = camera->play->view.lookAt.y + anim->curKeyFrame->atTargetInit.y; + anim->atTarget.z = camera->play->view.lookAt.z + anim->curKeyFrame->atTargetInit.z; } } else if (atInitFlags == 3) { if (anim->isNewKeyFrame) { @@ -5328,9 +5328,9 @@ s32 Camera_Unique9(Camera* camera) { anim->eyeTarget = anim->curKeyFrame->eyeTargetInit; } else if (eyeInitFlags == 0x200) { if (anim->isNewKeyFrame) { - anim->eyeTarget.x = camera->globalCtx->view.eye.x + anim->curKeyFrame->eyeTargetInit.x; - anim->eyeTarget.y = camera->globalCtx->view.eye.y + anim->curKeyFrame->eyeTargetInit.y; - anim->eyeTarget.z = camera->globalCtx->view.eye.z + anim->curKeyFrame->eyeTargetInit.z; + anim->eyeTarget.x = camera->play->view.eye.x + anim->curKeyFrame->eyeTargetInit.x; + anim->eyeTarget.y = camera->play->view.eye.y + anim->curKeyFrame->eyeTargetInit.y; + anim->eyeTarget.z = camera->play->view.eye.z + anim->curKeyFrame->eyeTargetInit.z; } } else if (eyeInitFlags == 0x300) { if (anim->isNewKeyFrame) { @@ -5417,7 +5417,7 @@ s32 Camera_Unique9(Camera* camera) { } if (anim->curKeyFrame->initFlags == 2) { - anim->fovTarget = camera->globalCtx->view.fovy; + anim->fovTarget = camera->play->view.fovy; anim->rollTarget = 0; } else if (anim->curKeyFrame->initFlags == 0) { anim->fovTarget = camera->fov; @@ -5571,12 +5571,12 @@ s32 Camera_Unique9(Camera* camera) { // Change the parent camera (or default)'s mode to normal s32 camIdx = camera->parentCamIdx <= SUBCAM_NONE ? MAIN_CAM : camera->parentCamIdx; - Camera_ChangeModeFlags(camera->globalCtx->cameraPtrs[camIdx], CAM_MODE_NORMAL, 1); + Camera_ChangeModeFlags(camera->play->cameraPtrs[camIdx], CAM_MODE_NORMAL, 1); } case 18: { // copy the current camera to the parent (or default)'s camera. s32 camIdx = camera->parentCamIdx <= SUBCAM_NONE ? MAIN_CAM : camera->parentCamIdx; - Camera* cam = camera->globalCtx->cameraPtrs[camIdx]; + Camera* cam = camera->play->cameraPtrs[camIdx]; *eye = *eyeNext; Camera_Copy(cam, camera); @@ -5698,7 +5698,7 @@ s32 Camera_Demo1(Camera* camera) { camera->animState++; // "absolute" : "relative" osSyncPrintf(VT_SGR("1") "%06u:" VT_RST " camera: spline demo: start %s \n", - camera->globalCtx->state.frames, *relativeToPlayer == 0 ? "絶対" : "相対"); + camera->play->state.frames, *relativeToPlayer == 0 ? "絶対" : "相対"); if (PREG(93)) { Camera_DebugPrintSplineArray("CENTER", 5, csAtPoints); @@ -5794,7 +5794,7 @@ s32 Camera_Demo3(Camera* camera) { sp68.x = anim->initialAt.x + (Math_SinS(angle) * 40.0f); sp68.y = anim->initialAt.y + 40.0f; sp68.z = anim->initialAt.z + (Math_CosS(angle) * 40.0f); - if (camera->globalCtx->state.frames & 1) { + if (camera->play->state.frames & 1) { angle -= 0x3FFF; anim->yawDir = 1; } else { @@ -5991,7 +5991,7 @@ s32 Camera_Demo5(Camera* camera) { Actor_GetFocus(&camera->targetPosRot, camera->target); OLib_Vec3fDiffToVecSphGeo(&playerTargetGeo, &camera->targetPosRot.pos, &camera->playerPosRot.pos); D_8011D3AC = camera->target->category; - Actor_GetScreenPos(camera->globalCtx, camera->target, &sp78.yaw, &sp78.pitch); + Actor_GetScreenPos(camera->play, camera->target, &sp78.yaw, &sp78.pitch); eyeTargetDist = OLib_Vec3fDist(&camera->targetPosRot.pos, &camera->eye); OLib_Vec3fDiffToVecSphGeo(&eyePlayerGeo, &playerhead.pos, &camera->eyeNext); sp4A = eyePlayerGeo.yaw - playerTargetGeo.yaw; @@ -6087,7 +6087,7 @@ s32 Camera_Demo5(Camera* camera) { // the target is a door. D_8011D954[0].timerInit = camera->timer - 5; sp4A = 0; - if (!func_800C0D34(camera->globalCtx, camera->target, &sp4A)) { + if (!func_800C0D34(camera->play, camera->target, &sp4A)) { osSyncPrintf(VT_COL(YELLOW, BLACK) "camera: attention demo: this door is dummy door!\n" VT_RST); if (ABS(playerTargetGeo.yaw - camera->target->shape.rot.y) >= 0x4000) { sp4A = camera->target->shape.rot.y; @@ -6140,7 +6140,7 @@ s32 Camera_Demo5(Camera* camera) { ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D9F4; ONEPOINT_CS_INFO(camera)->keyFrameCnt = ARRAY_COUNT(D_8011D9F4); if (camera->parentCamIdx != MAIN_CAM) { - if (camera->globalCtx->state.frames & 1) { + if (camera->play->state.frames & 1) { D_8011D9F4[0].rollTargetInit = -D_8011D9F4[0].rollTargetInit; D_8011D9F4[1].rollTargetInit = -D_8011D9F4[1].rollTargetInit; } @@ -6151,12 +6151,12 @@ s32 Camera_Demo5(Camera* camera) { } } - pad = sDemo5PrevSfxFrame - camera->globalCtx->state.frames; + pad = sDemo5PrevSfxFrame - camera->play->state.frames; if ((pad >= 0x33) || (pad < -0x32)) { func_80078884(camera->data1); } - sDemo5PrevSfxFrame = camera->globalCtx->state.frames; + sDemo5PrevSfxFrame = camera->play->state.frames; if (camera->player->stateFlags1 & 0x8000000 && (player->currentBoots != PLAYER_BOOTS_IRON)) { // swimming, and not iron boots @@ -6166,21 +6166,21 @@ s32 Camera_Demo5(Camera* camera) { } else { sp4A = playerhead.rot.y - playerTargetGeo.yaw; if (camera->target->category == ACTORCAT_PLAYER) { - pad = camera->globalCtx->state.frames - sDemo5PrevAction12Frame; + pad = camera->play->state.frames - sDemo5PrevAction12Frame; if (player->stateFlags1 & 0x800) { // holding object over head. - func_8002DF54(camera->globalCtx, camera->target, 8); + func_8002DF54(camera->play, camera->target, 8); } else if (ABS(pad) > 3000) { - func_8002DF54(camera->globalCtx, camera->target, 12); + func_8002DF54(camera->play, camera->target, 12); } else { - func_8002DF54(camera->globalCtx, camera->target, 69); + func_8002DF54(camera->play, camera->target, 69); } } else { - func_8002DF54(camera->globalCtx, camera->target, 1); + func_8002DF54(camera->play, camera->target, 1); } } - sDemo5PrevAction12Frame = camera->globalCtx->state.frames; + sDemo5PrevAction12Frame = camera->play->state.frames; Camera_ChangeSettingFlags(camera, CAM_SET_CS_C, (4 | 1)); Camera_Unique9(camera); return true; @@ -6201,7 +6201,7 @@ s32 Camera_Demo6(Camera* camera) { s16 stateTimers[4]; Vec3f* at = &camera->at; - mainCam = Gameplay_GetCamera(camera->globalCtx, MAIN_CAM); + mainCam = Play_GetCamera(camera->play, MAIN_CAM); camFocus = camera->target; stateTimers[1] = 0x37; stateTimers[2] = 0x46; @@ -6235,7 +6235,7 @@ s32 Camera_Demo6(Camera* camera) { camera->animState++; case 1: if (stateTimers[camera->animState] < anim->animTimer) { - func_8002DF54(camera->globalCtx, &camera->player->actor, 8); + func_8002DF54(camera->play, &camera->player->actor, 8); Actor_GetWorld(&focusPosRot, camFocus); anim->atTarget.x = focusPosRot.pos.x; anim->atTarget.y = focusPosRot.pos.y - 20.0f; @@ -6306,7 +6306,7 @@ s32 Camera_Demo9(Camera* camera) { f32* camFOV = &camera->fov; Demo9Anim* anim = &demo9->anim; - mainCam = Gameplay_GetCamera(camera->globalCtx, MAIN_CAM); + mainCam = Play_GetCamera(camera->play, MAIN_CAM); mainCamPlayerPosRot = &mainCam->playerPosRot; if (RELOAD_PARAMS) { values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; @@ -6397,7 +6397,7 @@ s32 Camera_Demo9(Camera* camera) { // finish action = 0x2000, run OnePointCs 0x3FC (Dramatic Return to Link) onePointTimer = demo9OnePoint->onePointCs.initTimer < 50 ? 5 : demo9OnePoint->onePointCs.initTimer / 5; - OnePointCutscene_Init(camera->globalCtx, 1020, onePointTimer, NULL, camera->parentCamIdx); + OnePointCutscene_Init(camera->play, 1020, onePointTimer, NULL, camera->parentCamIdx); } } else { // finish action = 0x1000, copy the current camera's values to the @@ -6616,7 +6616,7 @@ s32 Camera_Special7(Camera* camera) { yOffset = Player_GetHeight(camera->player); if (camera->animState == 0) { - if (camera->globalCtx->sceneNum == SCENE_JYASINZOU) { + if (camera->play->sceneNum == SCENE_JYASINZOU) { // Spirit Temple spec7->idx = 3; } else if (playerPosRot->pos.x < 1500.0f) { @@ -6838,7 +6838,7 @@ s32 Camera_Special9(Camera* camera) { // 0xE38 ~ 20 degrees eyeAdjustment.pitch = 0xE38; // 0xAAA ~ 15 degrees. - yaw = 0xAAA * ((camera->globalCtx->state.frames & 1) ? 1 : -1); + yaw = 0xAAA * ((camera->play->state.frames & 1) ? 1 : -1); eyeAdjustment.yaw = anim->targetYaw + yaw; eyeAdjustment.r = 200.0f * yNormal; Camera_Vec3fVecSphGeoAdd(eyeNext, at, &eyeAdjustment); @@ -6909,12 +6909,12 @@ s32 Camera_Special9(Camera* camera) { return true; } -Camera* Camera_Create(View* view, CollisionContext* colCtx, GlobalContext* globalCtx) { +Camera* Camera_Create(View* view, CollisionContext* colCtx, PlayState* play) { Camera* newCamera = ZELDA_ARENA_MALLOC_DEBUG(sizeof(*newCamera)); if (newCamera != NULL) { osSyncPrintf(VT_FGCOL(BLUE) "camera: create --- allocate %d byte" VT_RST "\n", sizeof(*newCamera) * 4); - Camera_Init(newCamera, view, colCtx, globalCtx); + Camera_Init(newCamera, view, colCtx, play); } else { osSyncPrintf(VT_COL(RED, WHITE) "camera: create: not enough memory\n" VT_RST); } @@ -6930,7 +6930,7 @@ void Camera_Destroy(Camera* camera) { } } -void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalContext* globalCtx) { +void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState* play) { Camera* camP; s32 i; s16 curUID; @@ -6950,7 +6950,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalCon sInitRegs = false; PREG(88) = -1; } - camera->globalCtx = D_8015BD7C = globalCtx; + camera->play = D_8015BD7C = play; DbCamera_Init(&D_8015BD80, camera); curUID = sNextUID; sNextUID++; @@ -6960,7 +6960,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalCon } for (j = 0; j < NUM_CAMS; j++) { - camP = camera->globalCtx->cameraPtrs[j]; + camP = camera->play->cameraPtrs[j]; if (camP != NULL && curUID == camP->uid) { break; } @@ -7009,11 +7009,11 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalCon } void func_80057FC4(Camera* camera) { - if (camera != &camera->globalCtx->mainCamera) { + if (camera != &camera->play->mainCamera) { camera->prevSetting = camera->setting = CAM_SET_FREE0; camera->unk_14C &= ~0x4; - } else if (camera->globalCtx->roomCtx.curRoom.meshHeader->base.type != 1) { - switch (camera->globalCtx->roomCtx.curRoom.behaviorType1) { + } else if (camera->play->roomCtx.curRoom.meshHeader->base.type != 1) { + switch (camera->play->roomCtx.curRoom.behaviorType1) { case ROOM_BEHAVIOR_TYPE1_1: Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); camera->prevSetting = camera->setting = CAM_SET_DUNGEON0; @@ -7025,7 +7025,7 @@ void func_80057FC4(Camera* camera) { break; default: osSyncPrintf("camera: room type: default set etc (%d)\n", - camera->globalCtx->roomCtx.curRoom.behaviorType1); + camera->play->roomCtx.curRoom.behaviorType1); Camera_ChangeDoorCam(camera, NULL, -99, 0, 0, 18, 10); camera->prevSetting = camera->setting = CAM_SET_NORMAL0; camera->unk_14C |= 4; @@ -7088,7 +7088,7 @@ void Camera_InitPlayerSettings(Camera* camera, Player* player) { camera->waterPrevCamSetting = -1; camera->unk_14C |= 4; - if (camera == &camera->globalCtx->mainCamera) { + if (camera == &camera->play->mainCamera) { sCameraInterfaceFlags = 0xB200; } else { sCameraInterfaceFlags = 0; @@ -7142,13 +7142,13 @@ void Camera_PrintSettings(Camera* camera) { char sp48[8]; s32 i; - if ((OREG(0) & 1) && (camera->globalCtx->activeCamera == camera->thisIdx) && !gDbgCamEnabled) { + if ((OREG(0) & 1) && (camera->play->activeCamera == camera->thisIdx) && !gDbgCamEnabled) { for (i = 0; i < NUM_CAMS; i++) { - if (camera->globalCtx->cameraPtrs[i] == NULL) { + if (camera->play->cameraPtrs[i] == NULL) { sp58[i] = '-'; sp48[i] = ' '; } else { - switch (camera->globalCtx->cameraPtrs[i]->status) { + switch (camera->play->cameraPtrs[i]->status) { case 0: sp58[i] = 'c'; break; @@ -7174,7 +7174,7 @@ void Camera_PrintSettings(Camera* camera) { sp58[i] = '\0'; sp48[i] = '\0'; - sp48[camera->globalCtx->activeCamera] = 'a'; + sp48[camera->play->activeCamera] = 'a'; func_8006376C(3, 0x16, 5, sp58); func_8006376C(3, 0x16, 1, sp48); func_8006376C(3, 0x17, 5, "S:"); @@ -7288,7 +7288,7 @@ s32 Camera_UpdateWater(Camera* camera) { if (!(camera->unk_14C & 0x100)) { camera->unk_14C |= 0x100; osSyncPrintf("kankyo changed water, sound on\n"); - Environment_EnableUnderwaterLights(camera->globalCtx, waterLightsIndex); + Environment_EnableUnderwaterLights(camera->play, waterLightsIndex); camera->waterDistortionTimer = 80; } @@ -7311,7 +7311,7 @@ s32 Camera_UpdateWater(Camera* camera) { if (camera->waterDistortionTimer > 0) { camera->waterDistortionTimer--; camera->distortionFlags |= DISTORTION_UNDERWATER_STRONG; - } else if (camera->globalCtx->sceneNum == SCENE_TURIBORI) { + } else if (camera->play->sceneNum == SCENE_TURIBORI) { camera->distortionFlags |= DISTORTION_UNDERWATER_FISHING; } else { camera->distortionFlags |= DISTORTION_UNDERWATER_WEAK; @@ -7320,7 +7320,7 @@ s32 Camera_UpdateWater(Camera* camera) { if (camera->unk_14C & 0x100) { camera->unk_14C &= ~0x100; osSyncPrintf("kankyo changed water off, sound off\n"); - Environment_DisableUnderwaterLights(camera->globalCtx); + Environment_DisableUnderwaterLights(camera->play); if (*quakeId != 0) { Quake_RemoveFromIdx(*quakeId); } @@ -7334,7 +7334,7 @@ s32 Camera_UpdateWater(Camera* camera) { s32 Camera_UpdateHotRoom(Camera* camera) { camera->distortionFlags &= ~DISTORTION_HOT_ROOM; - if (camera->globalCtx->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { + if (camera->play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { camera->distortionFlags |= DISTORTION_HOT_ROOM; } @@ -7344,7 +7344,7 @@ s32 Camera_UpdateHotRoom(Camera* camera) { s32 Camera_DbgChangeMode(Camera* camera) { s32 changeDir = 0; - if (!gDbgCamEnabled && camera->globalCtx->activeCamera == MAIN_CAM) { + if (!gDbgCamEnabled && camera->play->activeCamera == MAIN_CAM) { if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_CUP)) { osSyncPrintf("attention sound URGENCY\n"); func_80078884(NA_SE_SY_ATTENTION_URGENCY); @@ -7440,17 +7440,17 @@ void Camera_UpdateDistortion(Camera* camera) { depthPhase += DEGF_TO_BINANG(depthPhaseStep); screenPlanePhase += DEGF_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionOrientation(&camera->globalCtx->view, Math_CosS(depthPhase) * 0.0f, Math_SinS(depthPhase) * 0.0f, + View_SetDistortionOrientation(&camera->play->view, Math_CosS(depthPhase) * 0.0f, Math_SinS(depthPhase) * 0.0f, Math_SinS(screenPlanePhase) * 0.0f); - View_SetDistortionScale(&camera->globalCtx->view, Math_SinS(screenPlanePhase) * (xScale * scaleFactor) + 1.0f, + View_SetDistortionScale(&camera->play->view, Math_SinS(screenPlanePhase) * (xScale * scaleFactor) + 1.0f, Math_CosS(screenPlanePhase) * (yScale * scaleFactor) + 1.0f, Math_CosS(depthPhase) * (zScale * scaleFactor) + 1.0f); - View_SetDistortionSpeed(&camera->globalCtx->view, speed * speedFactor); + View_SetDistortionSpeed(&camera->play->view, speed * speedFactor); camera->unk_14C |= 0x40; } else if (camera->unk_14C & 0x40) { - View_ClearDistortion(&camera->globalCtx->view); + View_ClearDistortion(&camera->play->view); camera->unk_14C &= ~0x40; } } @@ -7471,7 +7471,7 @@ Vec3s Camera_Update(Camera* camera) { QuakeCamCalc quake; Player* player; - player = camera->globalCtx->cameraPtrs[MAIN_CAM]->player; + player = camera->play->cameraPtrs[MAIN_CAM]->player; if (R_DBG_CAM_UPDATE) { osSyncPrintf("camera: in %x\n", camera); @@ -7497,7 +7497,7 @@ Vec3s Camera_Update(Camera* camera) { spAC = curPlayerPosRot.pos; spAC.y += Player_GetHeight(camera->player); - playerGroundY = BgCheck_EntityRaycastFloor5(camera->globalCtx, &camera->globalCtx->colCtx, &playerFloorPoly, + playerGroundY = BgCheck_EntityRaycastFloor5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId, &camera->player->actor, &spAC); if (playerGroundY != BGCHECK_Y_MIN) { // player is above ground. @@ -7581,10 +7581,10 @@ Vec3s Camera_Update(Camera* camera) { D_8011D3F0--; sCameraInterfaceFlags = 0x3200; Camera_UpdateInterface(sCameraInterfaceFlags); - } else if (camera->globalCtx->transitionMode != 0) { + } else if (camera->play->transitionMode != 0) { sCameraInterfaceFlags = 0xF200; Camera_UpdateInterface(sCameraInterfaceFlags); - } else if (camera->globalCtx->csCtx.state != CS_STATE_IDLE) { + } else if (camera->play->csCtx.state != CS_STATE_IDLE) { sCameraInterfaceFlags = 0x3200; Camera_UpdateInterface(sCameraInterfaceFlags); } else { @@ -7593,7 +7593,7 @@ Vec3s Camera_Update(Camera* camera) { } if (R_DBG_CAM_UPDATE) { - osSyncPrintf("camera: shrink_and_bitem %x(%d)\n", sCameraInterfaceFlags, camera->globalCtx->transitionMode); + osSyncPrintf("camera: shrink_and_bitem %x(%d)\n", sCameraInterfaceFlags, camera->play->transitionMode); } if (R_DBG_CAM_UPDATE) { @@ -7608,16 +7608,16 @@ Vec3s Camera_Update(Camera* camera) { gDbgCamEnabled ^= 1; if (gDbgCamEnabled) { DbgCamera_Enable(&D_8015BD80, camera); - } else if (camera->globalCtx->csCtx.state != CS_STATE_IDLE) { - func_80064534(camera->globalCtx, &camera->globalCtx->csCtx); + } else if (camera->play->csCtx.state != CS_STATE_IDLE) { + func_80064534(camera->play, &camera->play->csCtx); } } // Debug cam update if (gDbgCamEnabled) { - camera->globalCtx->view.fovy = D_8015BD80.fov; + camera->play->view.fovy = D_8015BD80.fov; DbCamera_Update(&D_8015BD80, camera); - func_800AA358(&camera->globalCtx->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); + func_800AA358(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); if (R_DBG_CAM_UPDATE) { osSyncPrintf("camera: debug out\n"); } @@ -7662,13 +7662,13 @@ Vec3s Camera_Update(Camera* camera) { Camera_UpdateDistortion(camera); - if ((camera->globalCtx->sceneNum == SCENE_SPOT00) && (camera->fov < 59.0f)) { - View_SetScale(&camera->globalCtx->view, 0.79f); + if ((camera->play->sceneNum == SCENE_SPOT00) && (camera->fov < 59.0f)) { + View_SetScale(&camera->play->view, 0.79f); } else { - View_SetScale(&camera->globalCtx->view, 1.0f); + View_SetScale(&camera->play->view, 1.0f); } - camera->globalCtx->view.fovy = viewFov; - func_800AA358(&camera->globalCtx->view, &viewEye, &viewAt, &viewUp); + camera->play->view.fovy = viewFov; + func_800AA358(&camera->play->view, &viewEye, &viewAt, &viewUp); camera->camDir.x = eyeAtAngle.pitch; camera->camDir.y = eyeAtAngle.yaw; camera->camDir.z = 0; @@ -7708,18 +7708,18 @@ Vec3s Camera_Update(Camera* camera) { * When the camera's timer is 0, change the camera to its parent */ void Camera_Finish(Camera* camera) { - Camera* mainCam = camera->globalCtx->cameraPtrs[MAIN_CAM]; - Player* player = GET_PLAYER(camera->globalCtx); + Camera* mainCam = camera->play->cameraPtrs[MAIN_CAM]; + Player* player = GET_PLAYER(camera->play); if (camera->timer == 0) { - Gameplay_ChangeCameraStatus(camera->globalCtx, camera->parentCamIdx, CAM_STAT_ACTIVE); + Play_ChangeCameraStatus(camera->play, camera->parentCamIdx, CAM_STAT_ACTIVE); if ((camera->parentCamIdx == MAIN_CAM) && (camera->csId != 0)) { player->actor.freezeTimer = 0; player->stateFlags1 &= ~0x20000000; if (player->csMode != 0) { - func_8002DF54(camera->globalCtx, &player->actor, 7); + func_8002DF54(camera->play, &player->actor, 7); osSyncPrintf("camera: player demo end!!\n"); } @@ -7740,9 +7740,9 @@ void Camera_Finish(Camera* camera) { camera->childCamIdx = camera->parentCamIdx = SUBCAM_FREE; camera->timer = -1; - camera->globalCtx->envCtx.fillScreen = false; + camera->play->envCtx.fillScreen = false; - Gameplay_ClearCamera(camera->globalCtx, camera->thisIdx); + Play_ClearCamera(camera->play, camera->thisIdx); } } @@ -7756,7 +7756,7 @@ s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags) { static s32 modeChangeFlags = 0; if (QREG(89)) { - osSyncPrintf("+=+(%d)+=+ recive request -> %s\n", camera->globalCtx->state.frames, sCameraModeNames[mode]); + osSyncPrintf("+=+(%d)+=+ recive request -> %s\n", camera->play->state.frames, sCameraModeNames[mode]); } if (camera->unk_14C & 0x20 && flags == 0) { @@ -7858,7 +7858,7 @@ s32 Camera_ChangeModeFlags(Camera* camera, s16 mode, u8 flags) { func_80078884(0); break; case 2: - if (camera->globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) { + if (camera->play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) { func_80078884(NA_SE_SY_ATTENTION_URGENCY); } else { func_80078884(NA_SE_SY_ATTENTION_ON); @@ -7905,7 +7905,7 @@ s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags) { } } if (((setting == CAM_SET_MEADOW_BIRDS_EYE) || (setting == CAM_SET_MEADOW_UNUSED)) && LINK_IS_ADULT && - (camera->globalCtx->sceneNum == SCENE_SPOT05)) { + (camera->play->sceneNum == SCENE_SPOT05)) { camera->unk_14A |= 0x10; return -5; } @@ -7951,7 +7951,7 @@ s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags) { Camera_CopyDataToRegs(camera, camera->mode); } - osSyncPrintf(VT_SGR("1") "%06u:" VT_RST " camera: change camera[%d] set %s\n", camera->globalCtx->state.frames, + osSyncPrintf(VT_SGR("1") "%06u:" VT_RST " camera: change camera[%d] set %s\n", camera->play->state.frames, camera->thisIdx, sCameraSettingNames[camera->setting]); return setting; @@ -8280,9 +8280,9 @@ s32 func_8005B198() { s16 func_8005B1A4(Camera* camera) { camera->unk_14C |= 0x8; - if ((camera->thisIdx == MAIN_CAM) && (camera->globalCtx->activeCamera != MAIN_CAM)) { - GET_ACTIVE_CAM(camera->globalCtx)->unk_14C |= 0x8; - return camera->globalCtx->activeCamera; + if ((camera->thisIdx == MAIN_CAM) && (camera->play->activeCamera != MAIN_CAM)) { + GET_ACTIVE_CAM(camera->play)->unk_14C |= 0x8; + return camera->play->activeCamera; } return camera->thisIdx; diff --git a/soh/src/code/z_camera_data.inc b/soh/src/code/z_camera_data.inc index 1f457888e..f7bd99549 100644 --- a/soh/src/code/z_camera_data.inc +++ b/soh/src/code/z_camera_data.inc @@ -2398,6 +2398,6 @@ s16 D_8011DAFC[] = { CAM_SET_NORMAL0, CAM_SET_NORMAL1, CAM_SET_NORMAL2, CAM_SET_DUNGEON0, CAM_SET_DUNGEON1, CAM_SET_DUNGEON2, }; -GlobalContext* D_8015BD7C; +PlayState* D_8015BD7C; DbCamera D_8015BD80; CollisionPoly* playerFloorPoly; diff --git a/soh/src/code/z_cheap_proc.c b/soh/src/code/z_cheap_proc.c index 75b6b8f5d..73afef668 100644 --- a/soh/src/code/z_cheap_proc.c +++ b/soh/src/code/z_cheap_proc.c @@ -1,23 +1,23 @@ #include "global.h" -void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) { + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist) { + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/code/z_collision_check.c b/soh/src/code/z_collision_check.c index 91deaa26a..c27f35d6d 100644 --- a/soh/src/code/z_collision_check.c +++ b/soh/src/code/z_collision_check.c @@ -2,11 +2,11 @@ #include "vt.h" #include "overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.h" -typedef s32 (*ColChkResetFunc)(GlobalContext*, Collider*); -typedef void (*ColChkBloodFunc)(GlobalContext*, Collider*, Vec3f*); -typedef void (*ColChkApplyFunc)(GlobalContext*, CollisionCheckContext*, Collider*); -typedef void (*ColChkVsFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Collider*); -typedef s32 (*ColChkLineFunc)(GlobalContext*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); +typedef s32 (*ColChkResetFunc)(PlayState*, Collider*); +typedef void (*ColChkBloodFunc)(PlayState*, Collider*, Vec3f*); +typedef void (*ColChkApplyFunc)(PlayState*, CollisionCheckContext*, Collider*); +typedef void (*ColChkVsFunc)(PlayState*, CollisionCheckContext*, Collider*, Collider*); +typedef s32 (*ColChkLineFunc)(PlayState*, CollisionCheckContext*, Collider*, Vec3f*, Vec3f*); typedef struct { /* 0 */ u8 blood; @@ -100,7 +100,7 @@ void Collider_DrawPoly(GraphicsContext* gfxCtx, Vec3f* vA, Vec3f* vB, Vec3f* vC, CLOSE_DISPS(gfxCtx); } -s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_InitBase(PlayState* play, Collider* collider) { static Collider init = { NULL, NULL, NULL, NULL, AT_NONE, AC_NONE, OC1_NONE, OC2_NONE, COLTYPE_HIT3, COLSHAPE_INVALID, }; @@ -109,14 +109,14 @@ s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) { return 1; } -s32 Collider_DestroyBase(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_DestroyBase(PlayState* play, Collider* collider) { return 1; } /** * Uses default OC2_TYPE_1 and COLTYPE_HIT0 */ -s32 Collider_SetBaseToActor(GlobalContext* globalCtx, Collider* collider, ColliderInitToActor* src) { +s32 Collider_SetBaseToActor(PlayState* play, Collider* collider, ColliderInitToActor* src) { collider->actor = src->actor; collider->atFlags = src->atFlags; collider->acFlags = src->acFlags; @@ -129,7 +129,7 @@ s32 Collider_SetBaseToActor(GlobalContext* globalCtx, Collider* collider, Collid /** * Uses default OC2_TYPE_1 */ -s32 Collider_SetBaseType1(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInitType1* src) { +s32 Collider_SetBaseType1(PlayState* play, Collider* collider, Actor* actor, ColliderInitType1* src) { collider->actor = actor; collider->colType = src->colType; collider->atFlags = src->atFlags; @@ -140,7 +140,7 @@ s32 Collider_SetBaseType1(GlobalContext* globalCtx, Collider* collider, Actor* a return 1; } -s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInit* src) { +s32 Collider_SetBase(PlayState* play, Collider* collider, Actor* actor, ColliderInit* src) { collider->actor = actor; collider->colType = src->colType; collider->atFlags = src->atFlags; @@ -151,62 +151,62 @@ s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor, return 1; } -void Collider_ResetATBase(GlobalContext* globalCtx, Collider* collider) { +void Collider_ResetATBase(PlayState* play, Collider* collider) { collider->at = NULL; collider->atFlags &= ~(AT_HIT | AT_BOUNCED); } -void Collider_ResetACBase(GlobalContext* globalCtx, Collider* collider) { +void Collider_ResetACBase(PlayState* play, Collider* collider) { collider->ac = NULL; collider->acFlags &= ~(AC_HIT | AC_BOUNCED); } -void Collider_ResetOCBase(GlobalContext* globalCtx, Collider* collider) { +void Collider_ResetOCBase(PlayState* play, Collider* collider) { collider->oc = NULL; collider->ocFlags1 &= ~OC1_HIT; collider->ocFlags2 &= ~OC2_HIT_PLAYER; } -s32 Collider_InitTouch(GlobalContext* globalCtx, ColliderTouch* touch) { +s32 Collider_InitTouch(PlayState* play, ColliderTouch* touch) { static ColliderTouch init = { 0x00000000, 0, 0 }; *touch = init; return 1; } -s32 Collider_DestroyTouch(GlobalContext* globalCtx, ColliderTouch* touch) { +s32 Collider_DestroyTouch(PlayState* play, ColliderTouch* touch) { return 1; } -s32 Collider_SetTouch(GlobalContext* globalCtx, ColliderTouch* dest, ColliderTouch* src) { +s32 Collider_SetTouch(PlayState* play, ColliderTouch* dest, ColliderTouch* src) { dest->dmgFlags = src->dmgFlags; dest->effect = src->effect; dest->damage = src->damage; return 1; } -void Collider_ResetATInfo_Unk(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetATInfo_Unk(PlayState* play, ColliderInfo* info) { } -s32 Collider_InitBump(GlobalContext* globalCtx, ColliderBump* bump) { +s32 Collider_InitBump(PlayState* play, ColliderBump* bump) { static ColliderBump init = { 0xFFCFFFFF, 0, 0, { 0, 0, 0 } }; *bump = init; return 1; } -s32 Collider_DestroyBump(GlobalContext* globalCtx, ColliderBump* bump) { +s32 Collider_DestroyBump(PlayState* play, ColliderBump* bump) { return 1; } -s32 Collider_SetBump(GlobalContext* globalCtx, ColliderBump* bump, ColliderBumpInit* init) { +s32 Collider_SetBump(PlayState* play, ColliderBump* bump, ColliderBumpInit* init) { bump->dmgFlags = init->dmgFlags; bump->effect = init->effect; bump->defense = init->defense; return 1; } -s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info) { +s32 Collider_InitInfo(PlayState* play, ColliderInfo* info) { static ColliderInfo init = { { 0, 0, 0 }, { 0xFFCFFFFF, 0, 0, { 0, 0, 0 } }, ELEMTYPE_UNK0, TOUCH_NONE, @@ -216,36 +216,36 @@ s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info) { }; *info = init; - Collider_InitTouch(globalCtx, &info->toucher); - Collider_InitBump(globalCtx, &info->bumper); + Collider_InitTouch(play, &info->toucher); + Collider_InitBump(play, &info->bumper); return 1; } -s32 Collider_DestroyInfo(GlobalContext* globalCtx, ColliderInfo* info) { - Collider_DestroyTouch(globalCtx, &info->toucher); - Collider_DestroyBump(globalCtx, &info->bumper); +s32 Collider_DestroyInfo(PlayState* play, ColliderInfo* info) { + Collider_DestroyTouch(play, &info->toucher); + Collider_DestroyBump(play, &info->bumper); return 1; } -s32 Collider_SetInfo(GlobalContext* globalCtx, ColliderInfo* info, ColliderInfoInit* infoInit) { +s32 Collider_SetInfo(PlayState* play, ColliderInfo* info, ColliderInfoInit* infoInit) { info->elemType = infoInit->elemType; - Collider_SetTouch(globalCtx, &info->toucher, &infoInit->toucher); - Collider_SetBump(globalCtx, &info->bumper, &infoInit->bumper); + Collider_SetTouch(play, &info->toucher, &infoInit->toucher); + Collider_SetBump(play, &info->bumper, &infoInit->bumper); info->toucherFlags = infoInit->toucherFlags; info->bumperFlags = infoInit->bumperFlags; info->ocElemFlags = infoInit->ocElemFlags; return 1; } -void Collider_ResetATInfo(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetATInfo(PlayState* play, ColliderInfo* info) { info->atHit = NULL; info->atHitInfo = NULL; info->toucherFlags &= ~TOUCH_HIT; info->toucherFlags &= ~TOUCH_DREW_HITMARK; - Collider_ResetATInfo_Unk(globalCtx, info); + Collider_ResetATInfo_Unk(play, info); } -void Collider_ResetACInfo(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetACInfo(PlayState* play, ColliderInfo* info) { info->bumper.hitPos.x = info->bumper.hitPos.y = info->bumper.hitPos.z = 0; info->bumperFlags &= ~BUMP_HIT; info->bumperFlags &= ~BUMP_DRAW_HITMARK; @@ -253,11 +253,11 @@ void Collider_ResetACInfo(GlobalContext* globalCtx, ColliderInfo* info) { info->acHitInfo = NULL; } -void Collider_ResetOCInfo(GlobalContext* globalCtx, ColliderInfo* info) { +void Collider_ResetOCInfo(PlayState* play, ColliderInfo* info) { info->ocElemFlags &= ~OCELEM_HIT; } -s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dim) { +s32 Collider_InitJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim) { static ColliderJntSphElementDim init = { { { 0, 0, 0 }, 0 }, { { 0, 0, 0 }, 0 }, @@ -268,11 +268,11 @@ s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElemen return 1; } -s32 Collider_DestroyJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* element) { +s32 Collider_DestroyJntSphElementDim(PlayState* play, ColliderJntSphElementDim* element) { return 1; } -s32 Collider_SetJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dest, +s32 Collider_SetJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src) { dest->limb = src->limb; dest->modelSphere = src->modelSphere; @@ -280,44 +280,44 @@ s32 Collider_SetJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElement return 1; } -s32 Collider_InitJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element) { - Collider_InitInfo(globalCtx, &element->info); - Collider_InitJntSphElementDim(globalCtx, &element->dim); +s32 Collider_InitJntSphElement(PlayState* play, ColliderJntSphElement* element) { + Collider_InitInfo(play, &element->info); + Collider_InitJntSphElementDim(play, &element->dim); return 1; } -s32 Collider_DestroyJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element) { - Collider_DestroyInfo(globalCtx, &element->info); - Collider_DestroyJntSphElementDim(globalCtx, &element->dim); +s32 Collider_DestroyJntSphElement(PlayState* play, ColliderJntSphElement* element) { + Collider_DestroyInfo(play, &element->info); + Collider_DestroyJntSphElementDim(play, &element->dim); return 1; } -s32 Collider_SetJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* dest, ColliderJntSphElementInit* src) { - Collider_SetInfo(globalCtx, &dest->info, &src->info); - Collider_SetJntSphElementDim(globalCtx, &dest->dim, &src->dim); +s32 Collider_SetJntSphElement(PlayState* play, ColliderJntSphElement* dest, ColliderJntSphElementInit* src) { + Collider_SetInfo(play, &dest->info, &src->info); + Collider_SetJntSphElementDim(play, &dest->dim, &src->dim); return 1; } -s32 Collider_ResetJntSphElementAT(GlobalContext* globalCtx, ColliderJntSphElement* collider) { - Collider_ResetATInfo(globalCtx, &collider->info); +s32 Collider_ResetJntSphElementAT(PlayState* play, ColliderJntSphElement* collider) { + Collider_ResetATInfo(play, &collider->info); return 1; } -s32 Collider_ResetJntSphElementAC(GlobalContext* globalCtx, ColliderJntSphElement* collider) { - Collider_ResetACInfo(globalCtx, &collider->info); +s32 Collider_ResetJntSphElementAC(PlayState* play, ColliderJntSphElement* collider) { + Collider_ResetACInfo(play, &collider->info); return 1; } -s32 Collider_ResetJntSphElementOC(GlobalContext* globalCtx, ColliderJntSphElement* collider) { - Collider_ResetOCInfo(globalCtx, &collider->info); +s32 Collider_ResetJntSphElementOC(PlayState* play, ColliderJntSphElement* collider) { + Collider_ResetOCInfo(play, &collider->info); return 1; } /** * Initializes a ColliderJntSph to default values */ -s32 Collider_InitJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { - Collider_InitBase(globalCtx, &collider->base); +s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* collider) { + Collider_InitBase(play, &collider->base); collider->count = 0; collider->elements = NULL; return 1; @@ -326,12 +326,12 @@ s32 Collider_InitJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { /** * Destroys a dynamically allocated ColliderJntSph */ -s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { +s32 Collider_FreeJntSph(PlayState* play, ColliderJntSph* collider) { ColliderJntSphElement* element; - Collider_DestroyBase(globalCtx, &collider->base); + Collider_DestroyBase(play, &collider->base); for (element = collider->elements; element < collider->elements + collider->count; element++) { - Collider_DestroyJntSphElement(globalCtx, element); + Collider_DestroyJntSphElement(play, element); } collider->count = 0; @@ -345,12 +345,12 @@ s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { /** * Destroys a preallocated ColliderJntSph */ -s32 Collider_DestroyJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { +s32 Collider_DestroyJntSph(PlayState* play, ColliderJntSph* collider) { ColliderJntSphElement* element; - Collider_DestroyBase(globalCtx, &collider->base); + Collider_DestroyBase(play, &collider->base); for (element = collider->elements; element < collider->elements + collider->count; element++) { - Collider_DestroyJntSphElement(globalCtx, element); + Collider_DestroyJntSphElement(play, element); } collider->count = 0; collider->elements = NULL; @@ -361,11 +361,11 @@ s32 Collider_DestroyJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) { * Sets up the ColliderJntSph using the values in src, sets it to the actor specified in src, and dynamically allocates * the element array. Uses default OC2_TYPE_1 and COLTYPE_HIT0. Unused. */ -s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* dest, ColliderJntSphInitToActor* src) { +s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* dest, ColliderJntSphInitToActor* src) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBaseToActor(globalCtx, &dest->base, &src->base); + Collider_SetBaseToActor(play, &dest->base, &src->base); dest->count = src->count; dest->elements = ZELDA_ARENA_MALLOC_DEBUG(src->count * sizeof(ColliderJntSphElement)); @@ -379,8 +379,8 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* dest, Co for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; } @@ -389,12 +389,12 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* dest, Co * Sets up the ColliderJntSph using the values in src and dynamically allocates the element array. Uses default * OC2_TYPE_1. Only used by En_Nwc, an unused and unfinished actor. */ -s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* dest, Actor* actor, +s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInitType1* src) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBaseType1(globalCtx, &dest->base, actor, &src->base); + Collider_SetBaseType1(play, &dest->base, actor, &src->base); dest->count = src->count; dest->elements = ZELDA_ARENA_MALLOC_DEBUG(src->count * sizeof(ColliderJntSphElement)); @@ -408,8 +408,8 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* dest, for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; } @@ -418,11 +418,11 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* dest, * Sets up the ColliderJntSph using the values in src and dynamically allocates the element array. * Unused. */ -s32 Collider_SetJntSphAlloc(GlobalContext* globalCtx, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src) { +s32 Collider_SetJntSphAlloc(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBase(globalCtx, &dest->base, actor, &src->base); + Collider_SetBase(play, &dest->base, actor, &src->base); dest->count = src->count; dest->elements = ZELDA_ARENA_MALLOC_DEBUG(src->count * sizeof(ColliderJntSphElement)); @@ -435,8 +435,8 @@ s32 Collider_SetJntSphAlloc(GlobalContext* globalCtx, ColliderJntSph* dest, Acto } for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; } @@ -444,20 +444,20 @@ s32 Collider_SetJntSphAlloc(GlobalContext* globalCtx, ColliderJntSph* dest, Acto /** * Sets up the ColliderJntSph using the values in src, placing the element array in elements. */ -s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src, +s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* dest, Actor* actor, ColliderJntSphInit* src, ColliderJntSphElement* elements) { ColliderJntSphElement* destElem; ColliderJntSphElementInit* srcElem; - Collider_SetBase(globalCtx, &dest->base, actor, &src->base); + Collider_SetBase(play, &dest->base, actor, &src->base); dest->count = src->count; dest->elements = elements; ASSERT(dest->elements != NULL); for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitJntSphElement(globalCtx, destElem); - Collider_SetJntSphElement(globalCtx, destElem, srcElem); + Collider_InitJntSphElement(play, destElem); + Collider_SetJntSphElement(play, destElem, srcElem); } return 1; } @@ -465,14 +465,14 @@ s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* dest, Actor* ac /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetJntSphAT(PlayState* play, Collider* collider) { ColliderJntSphElement* element; ColliderJntSph* jntSph = (ColliderJntSph*)collider; - Collider_ResetATBase(globalCtx, &jntSph->base); + Collider_ResetATBase(play, &jntSph->base); for (element = jntSph->elements; element < jntSph->elements + jntSph->count; element++) { - Collider_ResetJntSphElementAT(globalCtx, element); + Collider_ResetJntSphElementAT(play, element); } return 1; } @@ -480,14 +480,14 @@ s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetJntSphAC(PlayState* play, Collider* collider) { ColliderJntSphElement* element; ColliderJntSph* jntSph = (ColliderJntSph*)collider; - Collider_ResetACBase(globalCtx, &jntSph->base); + Collider_ResetACBase(play, &jntSph->base); for (element = jntSph->elements; element < jntSph->elements + jntSph->count; element++) { - Collider_ResetJntSphElementAC(globalCtx, element); + Collider_ResetJntSphElementAC(play, element); } return 1; } @@ -495,30 +495,30 @@ s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetJntSphOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetJntSphOC(PlayState* play, Collider* collider) { ColliderJntSphElement* element; ColliderJntSph* jntSph = (ColliderJntSph*)collider; - Collider_ResetOCBase(globalCtx, &jntSph->base); + Collider_ResetOCBase(play, &jntSph->base); for (element = jntSph->elements; element < jntSph->elements + jntSph->count; element++) { - Collider_ResetJntSphElementOC(globalCtx, element); + Collider_ResetJntSphElementOC(play, element); } return 1; } -s32 Collider_InitCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) { +s32 Collider_InitCylinderDim(PlayState* play, Cylinder16* dim) { Cylinder16 init = { 0, 0, 0, { 0, 0, 0 } }; *dim = init; return 1; } -s32 Collider_DestroyCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) { +s32 Collider_DestroyCylinderDim(PlayState* play, Cylinder16* dim) { return 1; } -s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dest, Cylinder16* src) { +s32 Collider_SetCylinderDim(PlayState* play, Cylinder16* dest, Cylinder16* src) { *dest = *src; return 1; } @@ -526,20 +526,20 @@ s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dest, Cylinder /** * Initializes a ColliderCylinder to default values */ -s32 Collider_InitCylinder(GlobalContext* globalCtx, ColliderCylinder* collider) { - Collider_InitBase(globalCtx, &collider->base); - Collider_InitInfo(globalCtx, &collider->info); - Collider_InitCylinderDim(globalCtx, &collider->dim); +s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* collider) { + Collider_InitBase(play, &collider->base); + Collider_InitInfo(play, &collider->info); + Collider_InitCylinderDim(play, &collider->dim); return 1; } /** * Destroys a ColliderCylinder */ -s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collider) { - Collider_DestroyBase(globalCtx, &collider->base); - Collider_DestroyInfo(globalCtx, &collider->info); - Collider_DestroyCylinderDim(globalCtx, &collider->dim); +s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* collider) { + Collider_DestroyBase(play, &collider->base); + Collider_DestroyInfo(play, &collider->info); + Collider_DestroyCylinderDim(play, &collider->dim); return 1; } @@ -547,70 +547,70 @@ s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collide * Sets up the ColliderCylinder using the values in src and sets it to the actor specified in src. Uses default * OC2_TYPE_1 and COLTYPE_0. Used only by DekuJr, who sets it to himself anyways. */ -s32 Collider_SetCylinderToActor(GlobalContext* globalCtx, ColliderCylinder* collider, +s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* collider, ColliderCylinderInitToActor* src) { - Collider_SetBaseToActor(globalCtx, &collider->base, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); + Collider_SetBaseToActor(play, &collider->base, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return 1; } /** * Sets up the ColliderCylinder using the values in src. Uses default OC2_TYPE_1 */ -s32 Collider_SetCylinderType1(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, +s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInitType1* src) { - Collider_SetBaseType1(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); + Collider_SetBaseType1(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return 1; } /** * Sets up the ColliderCylinder using the values in src. */ -s32 Collider_SetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor, +s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src) { - Collider_SetBase(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); + Collider_SetBase(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return 1; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetCylinderAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetCylinderAT(PlayState* play, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - Collider_ResetATBase(globalCtx, &cylinder->base); - Collider_ResetATInfo(globalCtx, &cylinder->info); + Collider_ResetATBase(play, &cylinder->base); + Collider_ResetATInfo(play, &cylinder->info); return 1; } /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetCylinderAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetCylinderAC(PlayState* play, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - Collider_ResetACBase(globalCtx, &cylinder->base); - Collider_ResetACInfo(globalCtx, &cylinder->info); + Collider_ResetACBase(play, &cylinder->base); + Collider_ResetACInfo(play, &cylinder->info); return 1; } /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetCylinderOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetCylinderOC(PlayState* play, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - Collider_ResetOCBase(globalCtx, &cylinder->base); - Collider_ResetOCInfo(globalCtx, &cylinder->info); + Collider_ResetOCBase(play, &cylinder->base); + Collider_ResetOCInfo(play, &cylinder->info); return 1; } -s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { +s32 Collider_InitTrisElementDim(PlayState* play, TriNorm* dim) { static TriNorm init = { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { { 0.0f, 0.0f, 0.0f }, 0.0f }, @@ -620,11 +620,11 @@ s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { return 1; } -s32 Collider_DestroyTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { +s32 Collider_DestroyTrisElementDim(PlayState* play, TriNorm* dim) { return 1; } -s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dest, ColliderTrisElementDimInit* src) { +s32 Collider_SetTrisElementDim(PlayState* play, TriNorm* dest, ColliderTrisElementDimInit* src) { Vec3f* destVtx; Vec3f* srcVtx; f32 nx; @@ -645,44 +645,44 @@ s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dest, Collider return 1; } -s32 Collider_InitTrisElement(GlobalContext* globalCtx, ColliderTrisElement* collider) { - Collider_InitInfo(globalCtx, &collider->info); - Collider_InitTrisElementDim(globalCtx, &collider->dim); +s32 Collider_InitTrisElement(PlayState* play, ColliderTrisElement* collider) { + Collider_InitInfo(play, &collider->info); + Collider_InitTrisElementDim(play, &collider->dim); return 1; } -s32 Collider_DestroyTrisElement(GlobalContext* globalCtx, ColliderTrisElement* collider) { - Collider_DestroyInfo(globalCtx, &collider->info); - Collider_DestroyTrisElementDim(globalCtx, &collider->dim); +s32 Collider_DestroyTrisElement(PlayState* play, ColliderTrisElement* collider) { + Collider_DestroyInfo(play, &collider->info); + Collider_DestroyTrisElementDim(play, &collider->dim); return 1; } -s32 Collider_SetTrisElement(GlobalContext* globalCtx, ColliderTrisElement* dest, ColliderTrisElementInit* src) { - Collider_SetInfo(globalCtx, &dest->info, &src->info); - Collider_SetTrisElementDim(globalCtx, &dest->dim, &src->dim); +s32 Collider_SetTrisElement(PlayState* play, ColliderTrisElement* dest, ColliderTrisElementInit* src) { + Collider_SetInfo(play, &dest->info, &src->info); + Collider_SetTrisElementDim(play, &dest->dim, &src->dim); return 1; } -s32 Collider_ResetTrisElementAT(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_ResetATInfo(globalCtx, &element->info); +s32 Collider_ResetTrisElementAT(PlayState* play, ColliderTrisElement* element) { + Collider_ResetATInfo(play, &element->info); return 1; } -s32 Collider_ResetTrisElementAC(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_ResetACInfo(globalCtx, &element->info); +s32 Collider_ResetTrisElementAC(PlayState* play, ColliderTrisElement* element) { + Collider_ResetACInfo(play, &element->info); return 1; } -s32 Collider_ResetTrisElementOC(GlobalContext* globalCtx, ColliderTrisElement* element) { - Collider_ResetOCInfo(globalCtx, &element->info); +s32 Collider_ResetTrisElementOC(PlayState* play, ColliderTrisElement* element) { + Collider_ResetOCInfo(play, &element->info); return 1; } /** * Initializes a ColliderTris to default values */ -s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris) { - Collider_InitBase(globalCtx, &tris->base); +s32 Collider_InitTris(PlayState* play, ColliderTris* tris) { + Collider_InitBase(play, &tris->base); tris->count = 0; tris->elements = 0; return 1; @@ -692,12 +692,12 @@ s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris) { * Destroys a dynamically allocated ColliderTris * Unused */ -s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris) { +s32 Collider_FreeTris(PlayState* play, ColliderTris* tris) { ColliderTrisElement* element; - Collider_DestroyBase(globalCtx, &tris->base); + Collider_DestroyBase(play, &tris->base); for (element = tris->elements; element < tris->elements + tris->count; element++) { - Collider_DestroyTrisElement(globalCtx, element); + Collider_DestroyTrisElement(play, element); } tris->count = 0; @@ -711,12 +711,12 @@ s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris) { /** * Destroys a preallocated ColliderTris */ -s32 Collider_DestroyTris(GlobalContext* globalCtx, ColliderTris* tris) { +s32 Collider_DestroyTris(PlayState* play, ColliderTris* tris) { ColliderTrisElement* element; - Collider_DestroyBase(globalCtx, &tris->base); + Collider_DestroyBase(play, &tris->base); for (element = tris->elements; element < tris->elements + tris->count; element++) { - Collider_DestroyTrisElement(globalCtx, element); + Collider_DestroyTrisElement(play, element); } tris->count = 0; @@ -728,11 +728,11 @@ s32 Collider_DestroyTris(GlobalContext* globalCtx, ColliderTris* tris) { * Sets up the ColliderTris using the values in src and dynamically allocates the element array. Uses default OC2_TYPE_1 * Unused. */ -s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* dest, Actor* actor, ColliderTrisInitType1* src) { +s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInitType1* src) { ColliderTrisElement* destElem; ColliderTrisElementInit* srcElem; - Collider_SetBaseType1(globalCtx, &dest->base, actor, &src->base); + Collider_SetBaseType1(play, &dest->base, actor, &src->base); dest->count = src->count; dest->elements = ZELDA_ARENA_MALLOC_DEBUG(dest->count * sizeof(ColliderTrisElement)); if (dest->elements == NULL) { @@ -744,8 +744,8 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* dest, Act } for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitTrisElement(globalCtx, destElem); - Collider_SetTrisElement(globalCtx, destElem, srcElem); + Collider_InitTrisElement(play, destElem); + Collider_SetTrisElement(play, destElem, srcElem); } return 1; } @@ -754,11 +754,11 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* dest, Act * Sets up the ColliderTris using the values in src and dynamically allocates the element array. * Unused */ -s32 Collider_SetTrisAlloc(GlobalContext* globalCtx, ColliderTris* dest, Actor* actor, ColliderTrisInit* src) { +s32 Collider_SetTrisAlloc(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInit* src) { ColliderTrisElement* destElem; ColliderTrisElementInit* srcElem; - Collider_SetBase(globalCtx, &dest->base, actor, &src->base); + Collider_SetBase(play, &dest->base, actor, &src->base); dest->count = src->count; dest->elements = ZELDA_ARENA_MALLOC_DEBUG(dest->count * sizeof(ColliderTrisElement)); @@ -772,8 +772,8 @@ s32 Collider_SetTrisAlloc(GlobalContext* globalCtx, ColliderTris* dest, Actor* a for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitTrisElement(globalCtx, destElem); - Collider_SetTrisElement(globalCtx, destElem, srcElem); + Collider_InitTrisElement(play, destElem); + Collider_SetTrisElement(play, destElem, srcElem); } return 1; } @@ -781,20 +781,20 @@ s32 Collider_SetTrisAlloc(GlobalContext* globalCtx, ColliderTris* dest, Actor* a /** * Sets up the ColliderTris using the values in src, placing the element array in elements. */ -s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* dest, Actor* actor, ColliderTrisInit* src, +s32 Collider_SetTris(PlayState* play, ColliderTris* dest, Actor* actor, ColliderTrisInit* src, ColliderTrisElement* elements) { ColliderTrisElement* destElem; ColliderTrisElementInit* srcElem; - Collider_SetBase(globalCtx, &dest->base, actor, &src->base); + Collider_SetBase(play, &dest->base, actor, &src->base); dest->count = src->count; dest->elements = elements; ASSERT(dest->elements != NULL); for (destElem = dest->elements, srcElem = src->elements; destElem < dest->elements + dest->count; destElem++, srcElem++) { - Collider_InitTrisElement(globalCtx, destElem); - Collider_SetTrisElement(globalCtx, destElem, srcElem); + Collider_InitTrisElement(play, destElem); + Collider_SetTrisElement(play, destElem, srcElem); } return 1; } @@ -802,13 +802,13 @@ s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* dest, Actor* actor, /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetTrisAT(PlayState* play, Collider* collider) { ColliderTrisElement* element; ColliderTris* tris = (ColliderTris*)collider; - Collider_ResetATBase(globalCtx, &tris->base); + Collider_ResetATBase(play, &tris->base); for (element = tris->elements; element < tris->elements + tris->count; element++) { - Collider_ResetTrisElementAT(globalCtx, element); + Collider_ResetTrisElementAT(play, element); } return 1; } @@ -816,13 +816,13 @@ s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetTrisAC(PlayState* play, Collider* collider) { ColliderTrisElement* element; ColliderTris* tris = (ColliderTris*)collider; - Collider_ResetACBase(globalCtx, &tris->base); + Collider_ResetACBase(play, &tris->base); for (element = tris->elements; element < tris->elements + tris->count; element++) { - Collider_ResetTrisElementAC(globalCtx, element); + Collider_ResetTrisElementAC(play, element); } return 1; } @@ -830,18 +830,18 @@ s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider) { /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetTrisOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetTrisOC(PlayState* play, Collider* collider) { ColliderTrisElement* element; ColliderTris* tris = (ColliderTris*)collider; - Collider_ResetOCBase(globalCtx, &tris->base); + Collider_ResetOCBase(play, &tris->base); for (element = tris->elements; element < tris->elements + tris->count; element++) { - Collider_ResetTrisElementOC(globalCtx, element); + Collider_ResetTrisElementOC(play, element); } return 1; } -s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_InitQuadDim(PlayState* play, ColliderQuadDim* dim) { static ColliderQuadDim init = { { { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } }, { 0, 0, 0 }, @@ -853,11 +853,11 @@ s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { return 1; } -s32 Collider_DestroyQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_DestroyQuadDim(PlayState* play, ColliderQuadDim* dim) { return 1; } -s32 Collider_ResetQuadACDist(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_ResetQuadACDist(PlayState* play, ColliderQuadDim* dim) { dim->acDist = 1.0E38f; return 1; } @@ -871,7 +871,7 @@ void Collider_SetQuadMidpoints(ColliderQuadDim* dim) { dim->baMid.z = (dim->quad[1].z + dim->quad[0].z) * 0.5f; } -s32 Collider_SetQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dest, ColliderQuadDimInit* src) { +s32 Collider_SetQuadDim(PlayState* play, ColliderQuadDim* dest, ColliderQuadDimInit* src) { dest->quad[0] = src->quad[0]; dest->quad[1] = src->quad[1]; dest->quad[2] = src->quad[2]; @@ -883,74 +883,74 @@ s32 Collider_SetQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dest, Collide /** * Initializes a ColliderQuad to default values. */ -s32 Collider_InitQuad(GlobalContext* globalCtx, ColliderQuad* collider) { - Collider_InitBase(globalCtx, &collider->base); - Collider_InitInfo(globalCtx, &collider->info); - Collider_InitQuadDim(globalCtx, &collider->dim); +s32 Collider_InitQuad(PlayState* play, ColliderQuad* collider) { + Collider_InitBase(play, &collider->base); + Collider_InitInfo(play, &collider->info); + Collider_InitQuadDim(play, &collider->dim); return 1; } /** * Destroys a ColliderQuad. */ -s32 Collider_DestroyQuad(GlobalContext* globalCtx, ColliderQuad* collider) { - Collider_DestroyBase(globalCtx, &collider->base); - Collider_DestroyInfo(globalCtx, &collider->info); - Collider_DestroyQuadDim(globalCtx, &collider->dim); +s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* collider) { + Collider_DestroyBase(play, &collider->base); + Collider_DestroyInfo(play, &collider->info); + Collider_DestroyQuadDim(play, &collider->dim); return 1; } /** * Sets up the ColliderQuad using the values in src. Uses the default OC2_TYPE_1 */ -s32 Collider_SetQuadType1(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src) { - Collider_SetBaseType1(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetQuadDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src) { + Collider_SetBaseType1(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetQuadDim(play, &collider->dim, &src->dim); return 1; } /** * Sets up the ColliderQuad using the values in src. */ -s32 Collider_SetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) { - Collider_SetBase(globalCtx, &collider->base, actor, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetQuadDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) { + Collider_SetBase(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetQuadDim(play, &collider->dim, &src->dim); return 1; } /** * Resets the collider's AT collision flags. */ -s32 Collider_ResetQuadAT(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetQuadAT(PlayState* play, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - Collider_ResetATBase(globalCtx, &quad->base); - Collider_ResetATInfo(globalCtx, &quad->info); - Collider_ResetQuadACDist(globalCtx, &quad->dim); + Collider_ResetATBase(play, &quad->base); + Collider_ResetATInfo(play, &quad->info); + Collider_ResetQuadACDist(play, &quad->dim); return 1; } /** * Resets the collider's AC collision flags. */ -s32 Collider_ResetQuadAC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetQuadAC(PlayState* play, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - Collider_ResetACBase(globalCtx, &quad->base); - Collider_ResetACInfo(globalCtx, &quad->info); + Collider_ResetACBase(play, &quad->base); + Collider_ResetACInfo(play, &quad->info); return 1; } /** * Resets the collider's OC collision flags. */ -s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_ResetQuadOC(PlayState* play, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - Collider_ResetOCBase(globalCtx, &quad->base); - Collider_ResetOCInfo(globalCtx, &quad->info); + Collider_ResetOCBase(play, &quad->base); + Collider_ResetOCInfo(play, &quad->info); return 1; } @@ -958,7 +958,7 @@ s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider) { * For quad colliders with AT_NEAREST, resets the previous AC collider it hit if the current element is closer, * otherwise returns false. Used on player AT colliders to prevent multiple collisions from registering. */ -s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3f* hitPos) { +s32 Collider_QuadSetNearestAC(PlayState* play, ColliderQuad* quad, Vec3f* hitPos) { f32 acDist; Vec3f dcMid; @@ -970,10 +970,10 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3 if (acDist < quad->dim.acDist) { quad->dim.acDist = acDist; if (quad->info.atHit != NULL) { - Collider_ResetACBase(globalCtx, quad->info.atHit); + Collider_ResetACBase(play, quad->info.atHit); } if (quad->info.atHitInfo != NULL) { - Collider_ResetACInfo(globalCtx, quad->info.atHitInfo); + Collider_ResetACInfo(play, quad->info.atHitInfo); } return true; } @@ -984,7 +984,7 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3 * Initializes an OcLine to default values * OcLines are entirely unused. */ -s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line) { +s32 Collider_InitLine(PlayState* play, OcLine* line) { Vec3f init = { 0.0f, 0.0f, 0.0f }; Math_Vec3f_Copy(&line->line.a, &init); @@ -996,7 +996,7 @@ s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line) { * Destroys an OcLine * OcLines are entirely unused. */ -s32 Collider_DestroyLine(GlobalContext* globalCtx, OcLine* line) { +s32 Collider_DestroyLine(PlayState* play, OcLine* line) { return 1; } @@ -1004,7 +1004,7 @@ s32 Collider_DestroyLine(GlobalContext* globalCtx, OcLine* line) { * Sets up an OcLine with endpoints a and b. * OcLines are entirely unused. */ -s32 Collider_SetLinePoints(GlobalContext* GlobalContext, OcLine* ocLine, Vec3f* a, Vec3f* b) { +s32 Collider_SetLinePoints(PlayState* PlayState, OcLine* ocLine, Vec3f* a, Vec3f* b) { Math_Vec3f_Copy(&ocLine->line.a, a); Math_Vec3f_Copy(&ocLine->line.b, b); return 1; @@ -1014,9 +1014,9 @@ s32 Collider_SetLinePoints(GlobalContext* GlobalContext, OcLine* ocLine, Vec3f* * Sets up an OcLine using the values in src. * OcLines are entirely unused. */ -s32 Collider_SetLine(GlobalContext* globalCtx, OcLine* dest, OcLine* src) { +s32 Collider_SetLine(PlayState* play, OcLine* dest, OcLine* src) { dest->ocFlags = src->ocFlags; - Collider_SetLinePoints(globalCtx, dest, &src->line.a, &src->line.b); + Collider_SetLinePoints(play, dest, &src->line.a, &src->line.b); return 1; } @@ -1024,7 +1024,7 @@ s32 Collider_SetLine(GlobalContext* globalCtx, OcLine* dest, OcLine* src) { * Resets the OcLine's collision flags. * OcLines are entirely unused. */ -s32 Collider_ResetLineOC(GlobalContext* globalCtx, OcLine* line) { +s32 Collider_ResetLineOC(PlayState* play, OcLine* line) { line->ocFlags &= ~OCLINE_HIT; return 1; } @@ -1032,21 +1032,21 @@ s32 Collider_ResetLineOC(GlobalContext* globalCtx, OcLine* line) { /** * Initializes CollisionCheckContext. Clears all collider arrays, disables SAC, and sets flags for drawing colliders. */ -void CollisionCheck_InitContext(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colChkCtx) { colChkCtx->sacFlags = 0; - CollisionCheck_ClearContext(globalCtx, colChkCtx); + CollisionCheck_ClearContext(play, colChkCtx); AREG(21) = true; AREG(22) = true; AREG(23) = true; } -void CollisionCheck_DestroyContext(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colChkCtx) { } /** * Clears all collider lists in CollisionCheckContext when not in SAC mode. */ -void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colChkCtx) { Collider** col; OcLine** line; @@ -1076,14 +1076,14 @@ void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext /** * Enables SAC, an alternate collision check mode that allows direct management of collider lists. Unused. */ -void CollisionCheck_EnableSAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colChkCtx) { colChkCtx->sacFlags |= 1; } /** * Disables SAC, an alternate collision check mode that allows direct management of collider lists. Unused. */ -void CollisionCheck_DisableSAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colChkCtx) { colChkCtx->sacFlags &= ~1; } @@ -1091,7 +1091,7 @@ void CollisionCheck_DisableSAC(GlobalContext* globalCtx, CollisionCheckContext* * Draws a collider of any shape. * Math3D_DrawSphere and Math3D_DrawCylinder are noops, so JntSph and Cylinder are not drawn. */ -void Collider_Draw(GlobalContext* globalCtx, Collider* collider) { +void Collider_Draw(PlayState* play, Collider* collider) { ColliderJntSph* jntSph; ColliderCylinder* cylinder; ColliderTris* tris; @@ -1105,24 +1105,24 @@ void Collider_Draw(GlobalContext* globalCtx, Collider* collider) { case COLSHAPE_JNTSPH: jntSph = (ColliderJntSph*)collider; for (i = 0; i < jntSph->count; i++) { - Math3D_DrawSphere(globalCtx, &jntSph->elements[i].dim.worldSphere); + Math3D_DrawSphere(play, &jntSph->elements[i].dim.worldSphere); } break; case COLSHAPE_CYLINDER: cylinder = (ColliderCylinder*)collider; - Math3D_DrawCylinder(globalCtx, &cylinder->dim); + Math3D_DrawCylinder(play, &cylinder->dim); break; case COLSHAPE_TRIS: tris = (ColliderTris*)collider; for (i = 0; i < tris->count; i++) { - Collider_DrawRedPoly(globalCtx->state.gfxCtx, &tris->elements[i].dim.vtx[0], + Collider_DrawRedPoly(play->state.gfxCtx, &tris->elements[i].dim.vtx[0], &tris->elements[i].dim.vtx[1], &tris->elements[i].dim.vtx[2]); } break; case COLSHAPE_QUAD: quad = (ColliderQuad*)collider; - Collider_DrawRedPoly(globalCtx->state.gfxCtx, &quad->dim.quad[2], &quad->dim.quad[3], &quad->dim.quad[1]); - Collider_DrawRedPoly(globalCtx->state.gfxCtx, &quad->dim.quad[1], &quad->dim.quad[0], &quad->dim.quad[2]); + Collider_DrawRedPoly(play->state.gfxCtx, &quad->dim.quad[2], &quad->dim.quad[3], &quad->dim.quad[1]); + Collider_DrawRedPoly(play->state.gfxCtx, &quad->dim.quad[1], &quad->dim.quad[0], &quad->dim.quad[2]); break; } } @@ -1131,34 +1131,34 @@ void Collider_Draw(GlobalContext* globalCtx, Collider* collider) { * Draws collision if AREG(15) and other AREGs are set. AREG(21) draws AT colliders, AREG(22) draws AC colliders, * AREG(23) draws OC colliders, AREG(24) draws dynapolys, and AREG(25) draws bg polys */ -void CollisionCheck_DrawCollision(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_DrawCollision(PlayState* play, CollisionCheckContext* colChkCtx) { Collider* collider; s32 i; if (AREG(15)) { if (AREG(21)) { for (i = 0; i < colChkCtx->colATCount; i++) { - Collider_Draw(globalCtx, colChkCtx->colAT[i]); + Collider_Draw(play, colChkCtx->colAT[i]); } } if (AREG(22)) { for (i = 0; i < colChkCtx->colACCount; i++) { - Collider_Draw(globalCtx, colChkCtx->colAC[i]); + Collider_Draw(play, colChkCtx->colAC[i]); } } if (AREG(23)) { for (i = 0; i < colChkCtx->colOCCount; i++) { collider = colChkCtx->colOC[i]; if (collider->ocFlags1 & OC1_ON) { - Collider_Draw(globalCtx, collider); + Collider_Draw(play, collider); } } } if (AREG(24)) { - BgCheck_DrawDynaCollision(globalCtx, &globalCtx->colCtx); + BgCheck_DrawDynaCollision(play, &play->colCtx); } if (AREG(25)) { - BgCheck_DrawStaticCollision(globalCtx, &globalCtx->colCtx); + BgCheck_DrawStaticCollision(play, &play->colCtx); } } } @@ -1174,14 +1174,14 @@ static ColChkResetFunc sATResetFuncs[] = { * Sets collider as an AT (attack) for the current frame, which will be checked against ACs (attack colliders) * The last argument takes a Collider, so pass collider.base rather than the raw collider. */ -s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } ASSERT(collider->shape <= COLSHAPE_QUAD); - sATResetFuncs[collider->shape](globalCtx, collider); + sATResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1203,13 +1203,13 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colChk * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot */ -s32 CollisionCheck_SetAT_SAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, +s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index) { ASSERT(collider->shape <= COLSHAPE_QUAD); - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } - sATResetFuncs[collider->shape](globalCtx, collider); + sATResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1243,14 +1243,14 @@ static ColChkResetFunc sACResetFuncs[] = { * Sets collider as an AC (attack collider) for the current frame, allowing it to detect ATs (attacks) * The last argument takes a Collider, so pass collider.base rather than the raw collider. */ -s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } ASSERT(collider->shape <= COLSHAPE_QUAD); - sACResetFuncs[collider->shape](globalCtx, collider); + sACResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1272,13 +1272,13 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colChk * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot */ -s32 CollisionCheck_SetAC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, +s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index) { ASSERT(collider->shape <= COLSHAPE_QUAD); - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } - sACResetFuncs[collider->shape](globalCtx, collider); + sACResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1312,16 +1312,16 @@ static ColChkResetFunc sOCResetFuncs[] = { * Sets collider as an OC (object collider) for the current frame, allowing it to detect other OCs * The last argument takes a Collider, so pass collider.base rather than the raw collider. */ -s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } ASSERT(collider->shape <= COLSHAPE_QUAD); - sOCResetFuncs[collider->shape](globalCtx, collider); + sOCResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1343,13 +1343,13 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colChk * If CollisionCheck_SAC is enabled, the collider will be inserted into the list at the specified index, otherwise it * will be inserted into the next slot */ -s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, +s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index) { - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } ASSERT(collider->shape <= COLSHAPE_QUAD); - sOCResetFuncs[collider->shape](globalCtx, collider); + sOCResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1377,13 +1377,13 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co * Sets a line as an OC collider for this frame. * OC lines are entirely unused, and do not even have collision check functions. */ -s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, OcLine* collider) { +s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colChkCtx, OcLine* collider) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) == true) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } - Collider_ResetLineOC(globalCtx, collider); + Collider_ResetLineOC(play, collider); if (!(colChkCtx->colLineCount < COLLISION_CHECK_OC_LINE_MAX)) { // "Index exceeded and cannot add more" osSyncPrintf("CollisionCheck_setOCLine():インデックスがオーバして追加不能\n"); @@ -1428,14 +1428,14 @@ s32 CollisionCheck_NoSharedFlags(ColliderInfo* atInfo, ColliderInfo* acInfo) { * Spawns no blood drops. * Used by collider types HIT1, HIT3, HIT5, METAL, NONE, WOOD, HARD, and TREE */ -void CollisionCheck_NoBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { +void CollisionCheck_NoBlood(PlayState* play, Collider* collider, Vec3f* v) { } /** * Spawns blue blood drops. * Used by collider types HIT0 and HIT8. */ -void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { +void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v) { static EffectSparkInit D_8015D8A0; s32 effectIndex; @@ -1481,14 +1481,14 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3 D_8015D8A0.speed = 8.0f; D_8015D8A0.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015D8A0); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015D8A0); } /** * Spawns green blood drops. * Used by collider types HIT2 and HIT6. No actor has type HIT2. */ -void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { +void CollisionCheck_GreenBlood(PlayState* play, Collider* collider, Vec3f* v) { static EffectSparkInit D_8015DD68; s32 effectIndex; @@ -1534,42 +1534,42 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec D_8015DD68.speed = 8.0f; D_8015DD68.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015DD68); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015DD68); } /** * Spawns a burst of water. * Used by collider type HIT4, which no actor has. */ -void CollisionCheck_WaterBurst(GlobalContext* globalCtx, Collider* collider, Vec3f* pos) { - EffectSsSibuki_SpawnBurst(globalCtx, pos); - CollisionCheck_SpawnWaterDroplets(globalCtx, pos); +void CollisionCheck_WaterBurst(PlayState* play, Collider* collider, Vec3f* pos) { + EffectSsSibuki_SpawnBurst(play, pos); + CollisionCheck_SpawnWaterDroplets(play, pos); } /** * Spawns red blood drops. * Used by collider type HIT7, which no actor has. */ -void CollisionCheck_RedBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - CollisionCheck_SpawnRedBlood(globalCtx, v); +void CollisionCheck_RedBlood(PlayState* play, Collider* collider, Vec3f* v) { + CollisionCheck_SpawnRedBlood(play, v); } /** * Spawns red blood drops. * Unused. */ -void CollisionCheck_RedBloodUnused(GlobalContext* globalCtx, Collider* collider, Vec3f* v) { - CollisionCheck_SpawnRedBlood(globalCtx, v); +void CollisionCheck_RedBloodUnused(PlayState* play, Collider* collider, Vec3f* v) { + CollisionCheck_SpawnRedBlood(play, v); } /** * Plays sound effects and displays hitmarks for solid-type AC colliders (METAL, WOOD, HARD, and TREE) */ -void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Collider* collider, Vec3f* hitPos) { +void CollisionCheck_HitSolid(PlayState* play, ColliderInfo* info, Collider* collider, Vec3f* hitPos) { s32 flags = info->toucherFlags & TOUCH_SFX_NONE; if (flags == TOUCH_SFX_NORMAL && collider->colType != COLTYPE_METAL) { - EffectSsHitMark_SpawnFixedScale(globalCtx, EFFECT_HITMARK_WHITE, hitPos); + EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_WHITE, hitPos); if (collider->actor == NULL) { Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_BOUND, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { @@ -1577,14 +1577,14 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli &D_801333E8); } } else if (flags == TOUCH_SFX_NORMAL) { // collider->colType == COLTYPE_METAL - EffectSsHitMark_SpawnFixedScale(globalCtx, EFFECT_HITMARK_METAL, hitPos); + EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_METAL, hitPos); if (collider->actor == NULL) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, hitPos); + CollisionCheck_SpawnShieldParticlesMetal(play, hitPos); } else { - CollisionCheck_SpawnShieldParticlesMetalSound(globalCtx, hitPos, &collider->actor->projectedPos); + CollisionCheck_SpawnShieldParticlesMetalSound(play, hitPos, &collider->actor->projectedPos); } } else if (flags == TOUCH_SFX_HARD) { - EffectSsHitMark_SpawnFixedScale(globalCtx, EFFECT_HITMARK_WHITE, hitPos); + EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_WHITE, hitPos); if (collider->actor == NULL) { Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_BOUND, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { @@ -1592,7 +1592,7 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli &D_801333E8); } } else if (flags == TOUCH_SFX_WOOD) { - EffectSsHitMark_SpawnFixedScale(globalCtx, EFFECT_HITMARK_DUST, hitPos); + EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_DUST, hitPos); if (collider->actor == NULL) { Audio_PlaySoundGeneral(NA_SE_IT_REFLECTION_WOOD, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { @@ -1638,7 +1638,7 @@ static HitInfo sHitInfo[] = { /** * Handles hitmarks, blood, and sound effects for each AC collision, determined by the AC collider's colType */ -void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Collider* ac, +void CollisionCheck_HitEffects(PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, Vec3f* hitPos) { if (acInfo->bumperFlags & BUMP_NO_HITMARK) { return; @@ -1647,26 +1647,26 @@ void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderI return; } if (ac->actor != NULL) { - sBloodFuncs[sHitInfo[ac->colType].blood](globalCtx, ac, hitPos); + sBloodFuncs[sHitInfo[ac->colType].blood](play, ac, hitPos); } if (ac->actor != NULL) { if (sHitInfo[ac->colType].effect == HIT_SOLID) { - CollisionCheck_HitSolid(globalCtx, atInfo, ac, hitPos); + CollisionCheck_HitSolid(play, atInfo, ac, hitPos); } else if (sHitInfo[ac->colType].effect == HIT_WOOD) { if (at->actor == NULL) { - CollisionCheck_SpawnShieldParticles(globalCtx, hitPos); + CollisionCheck_SpawnShieldParticles(play, hitPos); Audio_PlaySoundGeneral(NA_SE_IT_REFLECTION_WOOD, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - CollisionCheck_SpawnShieldParticlesWood(globalCtx, hitPos, &at->actor->projectedPos); + CollisionCheck_SpawnShieldParticlesWood(play, hitPos, &at->actor->projectedPos); } } else if (sHitInfo[ac->colType].effect != HIT_NONE) { - EffectSsHitMark_SpawnFixedScale(globalCtx, sHitInfo[ac->colType].effect, hitPos); + EffectSsHitMark_SpawnFixedScale(play, sHitInfo[ac->colType].effect, hitPos); if (!(acInfo->bumperFlags & BUMP_NO_SWORD_SFX)) { CollisionCheck_SwordHitAudio(at, acInfo); } } } else { - EffectSsHitMark_SpawnFixedScale(globalCtx, EFFECT_HITMARK_WHITE, hitPos); + EffectSsHitMark_SpawnFixedScale(play, EFFECT_HITMARK_WHITE, hitPos); if (ac->actor == NULL) { Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_BOUND, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { @@ -1687,7 +1687,7 @@ void CollisionCheck_SetBounce(Collider* at, Collider* ac) { /** * Performs the AC collision between the AT element and AC element that collided. */ -s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, +s32 CollisionCheck_SetATvsAC(PlayState* play, Collider* at, ColliderInfo* atInfo, Vec3f* atPos, Collider* ac, ColliderInfo* acInfo, Vec3f* acPos, Vec3f* hitPos) { if (ac->acFlags & AC_HARD && at->actor != NULL && ac->actor != NULL) { CollisionCheck_SetBounce(at, ac); @@ -1717,7 +1717,7 @@ s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInf ac->colType != COLTYPE_HARD) { acInfo->bumperFlags |= BUMP_DRAW_HITMARK; } else { - CollisionCheck_HitEffects(globalCtx, at, atInfo, ac, acInfo, hitPos); + CollisionCheck_HitEffects(play, at, atInfo, ac, acInfo, hitPos); atInfo->toucherFlags |= TOUCH_DREW_HITMARK; } return 1; @@ -1726,7 +1726,7 @@ s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInf /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderJntSphElement* atItem; @@ -1768,7 +1768,7 @@ void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; @@ -1782,7 +1782,7 @@ void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderJntSphElement* atItem; @@ -1825,7 +1825,7 @@ void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } @@ -1836,7 +1836,7 @@ void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_CylVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderJntSph* ac = (ColliderJntSph*)colAC; @@ -1879,7 +1879,7 @@ void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckConte } else { Math_Vec3f_Copy(&hitPos, &atPos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { break; @@ -1892,7 +1892,7 @@ void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckConte /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_JntSphVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderJntSph* at = (ColliderJntSph*)colAT; ColliderJntSphElement* atSph; @@ -1922,7 +1922,7 @@ void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckCont acPos.x = (acTri->dim.vtx[0].x + acTri->dim.vtx[1].x + acTri->dim.vtx[2].x) * (1.0f / 3); acPos.y = (acTri->dim.vtx[0].y + acTri->dim.vtx[1].y + acTri->dim.vtx[2].y) * (1.0f / 3); acPos.z = (acTri->dim.vtx[0].z + acTri->dim.vtx[1].z + acTri->dim.vtx[2].z) * (1.0f / 3); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atSph->info, &atPos, &ac->base, &acTri->info, + CollisionCheck_SetATvsAC(play, &at->base, &atSph->info, &atPos, &ac->base, &acTri->info, &acPos, &hitPos); return; } @@ -1934,7 +1934,7 @@ void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_TrisVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderTris* at = (ColliderTris*)colAT; ColliderTrisElement* atItem; @@ -1962,7 +1962,7 @@ void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckCont atPos.x = (atItem->dim.vtx[0].x + atItem->dim.vtx[1].x + atItem->dim.vtx[2].x) * (1.0f / 3); atPos.y = (atItem->dim.vtx[0].y + atItem->dim.vtx[1].y + atItem->dim.vtx[2].y) * (1.0f / 3); atPos.z = (atItem->dim.vtx[0].z + atItem->dim.vtx[1].z + atItem->dim.vtx[2].z) * (1.0f / 3); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; @@ -1976,7 +1976,7 @@ void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_JntSphVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm D_8015E230; static TriNorm D_8015E268; @@ -2009,7 +2009,7 @@ void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckCont acPos.y = (ac->dim.quad[0].y + (ac->dim.quad[1].y + (ac->dim.quad[3].y + ac->dim.quad[2].y))) / 4.0f; acPos.z = (ac->dim.quad[0].z + (ac->dim.quad[1].z + (ac->dim.quad[3].z + ac->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } @@ -2020,7 +2020,7 @@ void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_QuadVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm D_8015E2A0; static TriNorm D_8015E2D8; @@ -2044,7 +2044,7 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont } if (Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &D_8015E2A0, &hitPos) == 1 || Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &D_8015E2D8, &hitPos) == 1) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2058,7 +2058,7 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont (at->dim.quad[0].y + (at->dim.quad[1].y + (at->dim.quad[3].y + at->dim.quad[2].y))) / 4.0f; atPos.z = (at->dim.quad[0].z + (at->dim.quad[1].z + (at->dim.quad[3].z + at->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; @@ -2072,7 +2072,7 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_CylVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderCylinder* ac = (ColliderCylinder*)colAC; @@ -2105,7 +2105,7 @@ void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* } else { Math_Vec3s_ToVec3f(&hitPos, &ac->dim.pos); } - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); } } } @@ -2113,7 +2113,7 @@ void CollisionCheck_AC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_CylVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderTris* ac = (ColliderTris*)colAC; @@ -2140,7 +2140,7 @@ void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext acPos.x = (acElem->dim.vtx[0].x + acElem->dim.vtx[1].x + acElem->dim.vtx[2].x) * (1.0f / 3); acPos.y = (acElem->dim.vtx[0].y + acElem->dim.vtx[1].y + acElem->dim.vtx[2].y) * (1.0f / 3); acPos.z = (acElem->dim.vtx[0].z + acElem->dim.vtx[1].z + acElem->dim.vtx[2].z) * (1.0f / 3); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atpos, &ac->base, &acElem->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atpos, &ac->base, &acElem->info, &acPos, &hitPos); return; } @@ -2151,7 +2151,7 @@ void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_TrisVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f D_8015E310; ColliderTris* at = (ColliderTris*)colAT; @@ -2177,7 +2177,7 @@ void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext atPos.y = (atItem->dim.vtx[0].y + atItem->dim.vtx[1].y + atItem->dim.vtx[2].y) * (1.0f / 3); atPos.z = (atItem->dim.vtx[0].z + atItem->dim.vtx[1].z + atItem->dim.vtx[2].z) * (1.0f / 3); Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &D_8015E310); return; } @@ -2188,7 +2188,7 @@ void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_CylVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm D_8015E320; static TriNorm D_8015E358; @@ -2213,7 +2213,7 @@ void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext acPos1.x = (ac->dim.quad[0].x + (ac->dim.quad[1].x + (ac->dim.quad[3].x + ac->dim.quad[2].x))) / 4.0f; acPos1.y = (ac->dim.quad[0].y + (ac->dim.quad[1].y + (ac->dim.quad[3].y + ac->dim.quad[2].y))) / 4.0f; acPos1.z = (ac->dim.quad[0].z + (ac->dim.quad[1].z + (ac->dim.quad[3].z + ac->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos1, &ac->base, &ac->info, &acPos1, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos1, &ac->base, &ac->info, &acPos1, &D_8015E390); } else if (Math3D_CylTriVsIntersect(&at->dim, &D_8015E358, &D_8015E390) == 1) { Vec3f atPos2; @@ -2223,7 +2223,7 @@ void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext acPos2.x = (ac->dim.quad[0].x + (ac->dim.quad[1].x + (ac->dim.quad[3].x + ac->dim.quad[2].x))) / 4.0f; acPos2.y = (ac->dim.quad[0].y + (ac->dim.quad[1].y + (ac->dim.quad[3].y + ac->dim.quad[2].y))) / 4.0f; acPos2.z = (ac->dim.quad[0].z + (ac->dim.quad[1].z + (ac->dim.quad[3].z + ac->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos2, &ac->base, &ac->info, &acPos2, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos2, &ac->base, &ac->info, &acPos2, &D_8015E390); } } @@ -2235,7 +2235,7 @@ static s8 sBssDummy1; /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_QuadVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm D_8015E3A0; static TriNorm D_8015E3D8; @@ -2253,7 +2253,7 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext Math3D_TriNorm(&D_8015E3A0, &at->dim.quad[2], &at->dim.quad[3], &at->dim.quad[1]); Math3D_TriNorm(&D_8015E3D8, &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]); if (Math3D_CylTriVsIntersect(&ac->dim, &D_8015E3A0, &D_8015E410) == 1) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_8015E410)) { + if (Collider_QuadSetNearestAC(play, at, &D_8015E410)) { Vec3f atPos1; Vec3f acPos1; @@ -2261,13 +2261,13 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext atPos1.y = (at->dim.quad[0].y + (at->dim.quad[1].y + (at->dim.quad[3].y + at->dim.quad[2].y))) / 4.0f; atPos1.z = (at->dim.quad[0].z + (at->dim.quad[1].z + (at->dim.quad[3].z + at->dim.quad[2].z))) / 4.0f; Math_Vec3s_ToVec3f(&acPos1, &ac->dim.pos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos1, &ac->base, &ac->info, &acPos1, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos1, &ac->base, &ac->info, &acPos1, &D_8015E410); return; } } if (Math3D_CylTriVsIntersect(&ac->dim, &D_8015E3D8, &D_8015E410) == 1) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_8015E410)) { + if (Collider_QuadSetNearestAC(play, at, &D_8015E410)) { Vec3f atPos2; Vec3f acPos2; @@ -2275,7 +2275,7 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext atPos2.y = (at->dim.quad[0].y + (at->dim.quad[1].y + (at->dim.quad[3].y + at->dim.quad[2].y))) / 4.0f; atPos2.z = (at->dim.quad[0].z + (at->dim.quad[1].z + (at->dim.quad[3].z + at->dim.quad[2].z))) / 4.0f; Math_Vec3s_ToVec3f(&acPos2, &ac->dim.pos); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos2, &ac->base, &ac->info, &acPos2, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos2, &ac->base, &ac->info, &acPos2, &D_8015E410); } } @@ -2290,7 +2290,7 @@ static s8 sBssDummy6; /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_TrisVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f D_8015E420; ColliderTris* at = (ColliderTris*)colAT; @@ -2320,7 +2320,7 @@ void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContex acPos.x = (acElem->dim.vtx[0].x + acElem->dim.vtx[1].x + acElem->dim.vtx[2].x) * (1.0f / 3); acPos.y = (acElem->dim.vtx[0].y + acElem->dim.vtx[1].y + acElem->dim.vtx[2].y) * (1.0f / 3); acPos.z = (acElem->dim.vtx[0].z + acElem->dim.vtx[1].z + acElem->dim.vtx[2].z) * (1.0f / 3); - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, &acPos, &D_8015E420); return; } @@ -2337,7 +2337,7 @@ static s8 sBssDummy10; /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_TrisVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f D_8015E430; static TriNorm D_8015E440; @@ -2370,7 +2370,7 @@ void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContex acPos.x = (ac->dim.quad[0].x + (ac->dim.quad[1].x + (ac->dim.quad[3].x + ac->dim.quad[2].x))) / 4.0f; acPos.y = (ac->dim.quad[0].y + (ac->dim.quad[1].y + (ac->dim.quad[3].y + ac->dim.quad[2].y))) / 4.0f; acPos.z = (ac->dim.quad[0].z + (ac->dim.quad[1].z + (ac->dim.quad[3].z + ac->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &D_8015E430); return; } @@ -2381,7 +2381,7 @@ void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_QuadVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f D_8015E4B0; static TriNorm D_8015E4C0; @@ -2405,7 +2405,7 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex } if (Math3D_TriVsTriIntersect(&D_8015E4C0, &acElem->dim, &D_8015E4B0) == 1 || Math3D_TriVsTriIntersect(&D_8015E4F8, &acElem->dim, &D_8015E4B0) == 1) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_8015E4B0)) { + if (Collider_QuadSetNearestAC(play, at, &D_8015E4B0)) { Vec3f atPos; Vec3f acPos; @@ -2418,7 +2418,7 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex (at->dim.quad[0].y + (at->dim.quad[1].y + (at->dim.quad[3].y + at->dim.quad[2].y))) / 4.0f; atPos.z = (at->dim.quad[0].z + (at->dim.quad[1].z + (at->dim.quad[3].z + at->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &D_8015E4B0); return; } @@ -2430,7 +2430,7 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex /** * AC overlap check. Calculates the center of each collider element and the point of contact. */ -void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT, +void CollisionCheck_AC_QuadVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm D_8015E530[2]; static Vec3f D_8015E598; @@ -2458,7 +2458,7 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { if (Math3D_TriVsTriIntersect(&D_8015E5A8[j], &D_8015E530[i], &D_8015E598) == 1) { - if (Collider_QuadSetNearestAC(globalCtx, at, &D_8015E598)) { + if (Collider_QuadSetNearestAC(play, at, &D_8015E598)) { Vec3f atPos; Vec3f acPos; @@ -2474,7 +2474,7 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex (ac->dim.quad[0].y + (ac->dim.quad[1].y + (ac->dim.quad[3].y + ac->dim.quad[2].y))) / 4.0f; acPos.z = (ac->dim.quad[0].z + (ac->dim.quad[1].z + (ac->dim.quad[3].z + ac->dim.quad[2].z))) / 4.0f; - CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_8015E598); return; } @@ -2486,7 +2486,7 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex /** * Sets a ColliderJntSph's hit effects */ -void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderJntSph* jntSph = (ColliderJntSph*)collider; ColliderJntSphElement* element; Vec3f hitPos; @@ -2495,7 +2495,7 @@ void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckConte if ((element->info.bumperFlags & BUMP_DRAW_HITMARK) && (element->info.acHitInfo != NULL) && !(element->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { Math_Vec3s_ToVec3f(&hitPos, &element->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, element->info.acHit, element->info.acHitInfo, &jntSph->base, + CollisionCheck_HitEffects(play, element->info.acHit, element->info.acHitInfo, &jntSph->base, &element->info, &hitPos); element->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; return; @@ -2506,14 +2506,14 @@ void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckConte /** * Sets a ColliderCylinder's hit effects */ -void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; Vec3f hitPos; if ((cylinder->info.bumperFlags & BUMP_DRAW_HITMARK) && (cylinder->info.acHitInfo != NULL) && !(cylinder->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { Math_Vec3s_ToVec3f(&hitPos, &cylinder->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, cylinder->info.acHit, cylinder->info.acHitInfo, &cylinder->base, + CollisionCheck_HitEffects(play, cylinder->info.acHit, cylinder->info.acHitInfo, &cylinder->base, &cylinder->info, &hitPos); cylinder->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; } @@ -2522,7 +2522,7 @@ void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* /** * Sets a ColliderTris's hit effects */ -void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderTris* tris = (ColliderTris*)collider; ColliderTrisElement* element; Vec3f hitPos; @@ -2531,7 +2531,7 @@ void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext if ((element->info.bumperFlags & BUMP_DRAW_HITMARK) && (element->info.acHitInfo != NULL) && !(element->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { Math_Vec3s_ToVec3f(&hitPos, &element->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, element->info.acHit, element->info.acHitInfo, &tris->base, + CollisionCheck_HitEffects(play, element->info.acHit, element->info.acHitInfo, &tris->base, &element->info, &hitPos); element->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; return; @@ -2542,14 +2542,14 @@ void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext /** * Sets a ColliderQuad's hit effects */ -void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_SetQuadHitFX(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; Vec3f hitPos; if ((quad->info.bumperFlags & BUMP_DRAW_HITMARK) && (quad->info.acHitInfo != NULL) && !(quad->info.acHitInfo->toucherFlags & TOUCH_DREW_HITMARK)) { Math_Vec3s_ToVec3f(&hitPos, &quad->info.bumper.hitPos); - CollisionCheck_HitEffects(globalCtx, quad->info.acHit, quad->info.acHitInfo, &quad->base, &quad->info, &hitPos); + CollisionCheck_HitEffects(play, quad->info.acHit, quad->info.acHitInfo, &quad->base, &quad->info, &hitPos); quad->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; } } @@ -2564,7 +2564,7 @@ static ColChkApplyFunc sColChkApplyFuncs[] = { /** * Handles hit effects for each AC collider that had an AC collision. Spawns hitmarks and plays sound effects. */ -void CollisionCheck_SetHitEffects(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_SetHitEffects(PlayState* play, CollisionCheckContext* colChkCtx) { Collider** col; for (col = colChkCtx->colAC; col < colChkCtx->colAC + colChkCtx->colACCount; col++) { @@ -2574,7 +2574,7 @@ void CollisionCheck_SetHitEffects(GlobalContext* globalCtx, CollisionCheckContex if (colAC->actor != NULL && colAC->actor->update == NULL) { continue; } - sColChkApplyFuncs[colAC->shape](globalCtx, colChkCtx, colAC); + sColChkApplyFuncs[colAC->shape](play, colChkCtx, colAC); } } } @@ -2593,7 +2593,7 @@ static ColChkVsFunc sACVsFuncs[4][4] = { /** * Iterates through all AC colliders, performing AC collisions with the AT collider. */ -void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* colAT) { +void CollisionCheck_AC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT) { Collider** col; for (col = colChkCtx->colAC; col < colChkCtx->colAC + colChkCtx->colACCount; col++) { @@ -2607,7 +2607,7 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colChkCt if (!(colAT->atFlags & AT_SELF) && colAT->actor != NULL && colAC->actor == colAT->actor) { continue; } - sACVsFuncs[colAT->shape][colAC->shape](globalCtx, colChkCtx, colAT, colAC); + sACVsFuncs[colAT->shape][colAC->shape](play, colChkCtx, colAT, colAC); } } } @@ -2619,7 +2619,7 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colChkCt * successful collision. To collide, an AT collider must share a type (AC_TYPE_PLAYER, AC_TYPE_ENEMY, or AC_TYPE_OTHER) * with the AC collider and the toucher and bumper elements that overlapped must share a dmgFlag. */ -void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colChkCtx) { Collider** col; if (colChkCtx->colATCount == 0 || colChkCtx->colACCount == 0) { @@ -2632,10 +2632,10 @@ void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colChkCt if (colAT->actor != NULL && colAT->actor->update == NULL) { continue; } - CollisionCheck_AC(globalCtx, colChkCtx, colAT); + CollisionCheck_AC(play, colChkCtx, colAT); } } - CollisionCheck_SetHitEffects(globalCtx, colChkCtx); + CollisionCheck_SetHitEffects(play, colChkCtx); } /** @@ -2749,7 +2749,7 @@ void CollisionCheck_SetOCvsOC(Collider* left, ColliderInfo* leftInfo, Vec3f* lef /** * OC overlap check for two JntSphs */ -void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* l, +void CollisionCheck_OC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderJntSphElement* leftElem; @@ -2783,7 +2783,7 @@ void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * OC overlap check for a JntSph and Cylinder */ -void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* l, +void CollisionCheck_OC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderJntSphElement* leftElem; @@ -2813,15 +2813,15 @@ void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte /** * OC overlap check for a Cylinder and JntSph */ -void CollisionCheck_OC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* l, +void CollisionCheck_OC_CylVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { - CollisionCheck_OC_JntSphVsCyl(globalCtx, colChkCtx, r, l); + CollisionCheck_OC_JntSphVsCyl(play, colChkCtx, r, l); } /** * OC overlap check for two Cylinders */ -void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { +void CollisionCheck_OC_CylVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { ColliderCylinder* left = (ColliderCylinder*)l; ColliderCylinder* right = (ColliderCylinder*)r; f32 deadSpace; @@ -2883,7 +2883,7 @@ static ColChkVsFunc sOCVsFuncs[4][4] = { * can collide, and each collider must have the OC flag corresponding to the other's OC type. Additionally, OC2_UNK1 * cannot collide with OC2_UNK2, nor can two colliders that share an actor. */ -void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colChkCtx) { Collider** left; Collider** right; ColChkVsFunc vsFunc; @@ -2903,7 +2903,7 @@ void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colChkCt osSyncPrintf("CollisionCheck_OC():未対応 %d, %d\n", (*left)->shape, (*right)->shape); continue; } - vsFunc(globalCtx, colChkCtx, *left, *right); + vsFunc(play, colChkCtx, *left, *right); } } } @@ -2975,7 +2975,7 @@ void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, C /** * Apply AC damage effect */ -void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, +void CollisionCheck_ApplyDamage(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, ColliderInfo* info) { DamageTable* tbl; f32 damage; @@ -3015,13 +3015,13 @@ void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext* /** * Apply ColliderJntSph AC damage effect */ -void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_ApplyDamageJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderJntSph* jntSph = (ColliderJntSph*)collider; s32 i; if (jntSph->count > 0 && jntSph->elements != NULL) { for (i = 0; i < jntSph->count; i++) { - CollisionCheck_ApplyDamage(globalCtx, colChkCtx, &jntSph->base, &jntSph->elements[i].info); + CollisionCheck_ApplyDamage(play, colChkCtx, &jntSph->base, &jntSph->elements[i].info); } } } @@ -3029,29 +3029,29 @@ void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckCo /** * Apply ColliderCylinder AC damage effect */ -void CollisionCheck_ApplyDamageCyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_ApplyDamageCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderCylinder* cylinder = (ColliderCylinder*)collider; - CollisionCheck_ApplyDamage(globalCtx, colChkCtx, &cylinder->base, &cylinder->info); + CollisionCheck_ApplyDamage(play, colChkCtx, &cylinder->base, &cylinder->info); } /** * Apply ColliderTris AC damage effect */ -void CollisionCheck_ApplyDamageTris(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_ApplyDamageTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderTris* tris = (ColliderTris*)collider; s32 i; for (i = 0; i < tris->count; i++) { - CollisionCheck_ApplyDamage(globalCtx, colChkCtx, collider, &tris->elements[i].info); + CollisionCheck_ApplyDamage(play, colChkCtx, collider, &tris->elements[i].info); } } /** * Apply ColliderQuad AC damage effect */ -void CollisionCheck_ApplyDamageQuad(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider) { +void CollisionCheck_ApplyDamageQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider) { ColliderQuad* quad = (ColliderQuad*)collider; - CollisionCheck_ApplyDamage(globalCtx, colChkCtx, &quad->base, &quad->info); + CollisionCheck_ApplyDamage(play, colChkCtx, &quad->base, &quad->info); } static ColChkApplyFunc sApplyDamageFuncs[4] = { @@ -3065,7 +3065,7 @@ static ColChkApplyFunc sApplyDamageFuncs[4] = { * For all AC colliders, sets any damage effects from collisions with AT colliders to their corresponding actor's * CollisionCheckInfo. */ -void CollisionCheck_Damage(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx) { +void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colChkCtx) { s32 i; for (i = 0; i < colChkCtx->colACCount; i++) { @@ -3077,14 +3077,14 @@ void CollisionCheck_Damage(GlobalContext* globalCtx, CollisionCheckContext* colC if (collider->acFlags & AC_NO_DAMAGE) { continue; } - sApplyDamageFuncs[collider->shape](globalCtx, colChkCtx, collider); + sApplyDamageFuncs[collider->shape](play, colChkCtx, collider); } } /** * Checks if the line ab intersects any of the ColliderJntSph's elements */ -s32 CollisionCheck_LineOC_JntSph(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, +s32 CollisionCheck_LineOC_JntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b) { static Linef D_8015E610; ColliderJntSph* jntSph = (ColliderJntSph*)collider; @@ -3108,7 +3108,7 @@ s32 CollisionCheck_LineOC_JntSph(GlobalContext* globalCtx, CollisionCheckContext /** * Checks if the line segment ab intersects the ColliderCylinder */ -s32 CollisionCheck_LineOC_Cyl(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, +s32 CollisionCheck_LineOC_Cyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, Vec3f* b) { static Vec3f D_8015E628; static Vec3f D_8015E638; @@ -3134,7 +3134,7 @@ static ColChkLineFunc sOCLineCheckFuncs[4] = { * Checks if the line segment ab intersects any OC colliders, excluding those attached to actors * on the exclusion list. Returns true if there are any intersections and false otherwise. */ -s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, +s32 CollisionCheck_LineOC(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions) { ColChkLineFunc lineCheck; Collider** col; @@ -3161,7 +3161,7 @@ s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colCh // "type %d not supported" osSyncPrintf("CollisionCheck_generalLineOcCheck():未対応 %dタイプ\n", (*col)->shape); } else { - result = lineCheck(globalCtx, colChkCtx, (*col), a, b); + result = lineCheck(play, colChkCtx, (*col), a, b); if (result) { break; } @@ -3174,17 +3174,17 @@ s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colCh * Checks if the line segment ab intersects any OC colliders. Returns true if there are any intersections and false * otherwise. Unused. */ -s32 CollisionCheck_LineOCCheckAll(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b) { - return CollisionCheck_LineOC(globalCtx, colChkCtx, a, b, NULL, 0); +s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b) { + return CollisionCheck_LineOC(play, colChkCtx, a, b, NULL, 0); } /** * Checks if the line segment ab intersects any OC colliders, excluding those attached to actors on the exclusion list. * Returns true if there are any intersections and false otherwise. */ -s32 CollisionCheck_LineOCCheck(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, +s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, s32 numExclusions) { - return CollisionCheck_LineOC(globalCtx, colChkCtx, a, b, exclusions, numExclusions); + return CollisionCheck_LineOC(play, colChkCtx, a, b, exclusions, numExclusions); } /** @@ -3239,10 +3239,10 @@ void Collider_SetTrisVertices(ColliderTris* collider, s32 index, Vec3f* a, Vec3f /** * Sets the specified ColliderTrisElement's dim using the values in src */ -void Collider_SetTrisDim(GlobalContext* globalCtx, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* src) { +void Collider_SetTrisDim(PlayState* play, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* src) { ColliderTrisElement* element = &collider->elements[index]; - Collider_SetTrisElementDim(globalCtx, &element->dim, src); + Collider_SetTrisElementDim(play, &element->dim, src); } // Due to an unknown reason, bss ordering changed between the 2 static Vec3f variables in the function below. @@ -3281,7 +3281,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) { * Spawns red blood droplets. * No actor has a collision type that spawns red blood. */ -void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v) { static EffectSparkInit D_8015CF10; s32 effectIndex; @@ -3327,14 +3327,14 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { D_8015CF10.speed = 8.0f; D_8015CF10.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015CF10); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015CF10); } /** * Spawns water droplets. * No actor has a collision type that spawns water droplets. */ -void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v) { static EffectSparkInit D_8015D3D8; s32 effectIndex; @@ -3380,13 +3380,13 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { D_8015D3D8.speed = 8.0f; D_8015D3D8.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015D3D8); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_8015D3D8); } /** * Spawns streaks of light from hits against solid objects */ -void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { +void CollisionCheck_SpawnShieldParticles(PlayState* play, Vec3f* v) { static EffectShieldParticleInit initMetal = { 16, { 0, 0, 0 }, @@ -3412,36 +3412,36 @@ void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { initMetal.lightPoint.y = initMetal.position.y; initMetal.lightPoint.z = initMetal.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &initMetal); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &initMetal); } /** * Spawns streaks of light and makes a metallic sound */ -void CollisionCheck_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* v) { - CollisionCheck_SpawnShieldParticles(globalCtx, v); +void CollisionCheck_SpawnShieldParticlesMetal(PlayState* play, Vec3f* v) { + CollisionCheck_SpawnShieldParticles(play, v); Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_REFLECT_SW, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } /** * Spawns streaks of light and makes a metallic sound at the specified position */ -void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec3f* v, Vec3f* pos) { - CollisionCheck_SpawnShieldParticles(globalCtx, v); +void CollisionCheck_SpawnShieldParticlesMetalSound(PlayState* play, Vec3f* v, Vec3f* pos) { + CollisionCheck_SpawnShieldParticles(play, v); Audio_PlaySoundGeneral(NA_SE_IT_SHIELD_REFLECT_SW, pos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } /** * Spawns streaks of light and makes a metallic sound */ -void CollisionCheck_SpawnShieldParticlesMetal2(GlobalContext* globalCtx, Vec3f* v) { - CollisionCheck_SpawnShieldParticlesMetal(globalCtx, v); +void CollisionCheck_SpawnShieldParticlesMetal2(PlayState* play, Vec3f* v) { + CollisionCheck_SpawnShieldParticlesMetal(play, v); } /** * Spawns streaks of light and makes a wooden sound */ -void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, Vec3f* actorPos) { +void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* actorPos) { static EffectShieldParticleInit initWood = { 16, { 0, 0, 0 }, @@ -3467,7 +3467,7 @@ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, initWood.lightPoint.y = initWood.position.y; initWood.lightPoint.z = initWood.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &initWood); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &initWood); Audio_PlaySoundGeneral(NA_SE_IT_REFLECTION_WOOD, actorPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } diff --git a/soh/src/code/z_construct.c b/soh/src/code/z_construct.c index 08497fe1c..6c5f6e21d 100644 --- a/soh/src/code/z_construct.c +++ b/soh/src/code/z_construct.c @@ -1,19 +1,19 @@ #include "global.h" #include <textures/do_action_static/do_action_static.h> -void func_80110990(GlobalContext* globalCtx) { - Map_Destroy(globalCtx); +void func_80110990(PlayState* play) { + Map_Destroy(play); } -void func_801109B0(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_801109B0(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; u32 parameterSize; u8 temp; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gSaveContext.unk_13E8 = gSaveContext.unk_13EA = 0; - View_Init(&interfaceCtx->view, globalCtx->state.gfxCtx); + View_Init(&interfaceCtx->view, play->state.gfxCtx); interfaceCtx->unk_1FA = interfaceCtx->unk_261 = interfaceCtx->unk_1FC = 0; interfaceCtx->unk_1EC = interfaceCtx->unk_1EE = interfaceCtx->unk_1F0 = 0; @@ -33,7 +33,7 @@ void func_801109B0(GlobalContext* globalCtx) { // "Permanent PARAMETER Segment = %x" osSyncPrintf("常駐PARAMETERセグメント=%x\n", parameterSize); - interfaceCtx->parameterSegment = GAMESTATE_ALLOC_MC(&globalCtx->state, parameterSize); + interfaceCtx->parameterSegment = GAMESTATE_ALLOC_MC(&play->state, parameterSize); osSyncPrintf("parameter->parameterSegment=%x\n", interfaceCtx->parameterSegment); @@ -41,7 +41,7 @@ void func_801109B0(GlobalContext* globalCtx) { DmaMgr_SendRequest1(interfaceCtx->parameterSegment, (uintptr_t)_parameter_staticSegmentRomStart, parameterSize, __FILE__, 162); - interfaceCtx->doActionSegment = GAMESTATE_ALLOC_MC(&globalCtx->state, 0x480); + interfaceCtx->doActionSegment = GAMESTATE_ALLOC_MC(&play->state, 0x480); osSyncPrintf("DOアクション テクスチャ初期=%x\n", 0x480); // "DO Action Texture Initialization" osSyncPrintf("parameter->do_actionSegment=%x\n", interfaceCtx->doActionSegment); @@ -55,7 +55,7 @@ void func_801109B0(GlobalContext* globalCtx) { memcpy(interfaceCtx->doActionSegment + attackDoActionTexSize, ResourceMgr_LoadTexByName(gReturnDoActionENGTex), ResourceMgr_LoadTexSizeByName(gReturnDoActionENGTex)); interfaceCtx->iconItemSegment = GAMESTATE_ALLOC_MC( - &globalCtx->state, 0x1000 * ARRAY_COUNT(gSaveContext.equips.buttonItems)); + &play->state, 0x1000 * ARRAY_COUNT(gSaveContext.equips.buttonItems)); // "Icon Item Texture Initialization = %x" osSyncPrintf("アイコンアイテム テクスチャ初期=%x\n", 0x4000); @@ -118,8 +118,8 @@ void func_801109B0(GlobalContext* globalCtx) { osSyncPrintf("PARAMETER領域=%x\n", parameterSize + 0x5300); // "Parameter Area = %x" - HealthMeter_Init(globalCtx); - Map_Init(globalCtx); + HealthMeter_Init(play); + Map_Init(play); interfaceCtx->unk_23C = interfaceCtx->unk_242 = 0; @@ -136,29 +136,29 @@ void func_801109B0(GlobalContext* globalCtx) { R_A_BTN_COLOR(2) = 50; } -void Message_Init(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_Init(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; s32 pad; Message_SetTables(); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; + play->msgCtx.ocarinaMode = OCARINA_MODE_00; msgCtx->msgMode = MSGMODE_NONE; msgCtx->msgLength = 0; msgCtx->textId = msgCtx->textboxEndType = msgCtx->choiceIndex = msgCtx->ocarinaAction = msgCtx->textUnskippable = 0; msgCtx->textColorAlpha = 255; - View_Init(&msgCtx->view, globalCtx->state.gfxCtx); + View_Init(&msgCtx->view, play->state.gfxCtx); - msgCtx->textboxSegment = GAMESTATE_ALLOC_MC(&globalCtx->state, 0x2200); + msgCtx->textboxSegment = GAMESTATE_ALLOC_MC(&play->state, 0x2200); osSyncPrintf("message->fukidashiSegment=%x\n", msgCtx->textboxSegment); osSyncPrintf("吹き出しgame_alloc=%x\n", 0x2200); // "Textbox game_alloc=%x" ASSERT(msgCtx->textboxSegment != NULL); - Font_LoadOrderedFont(&globalCtx->msgCtx.font); + Font_LoadOrderedFont(&play->msgCtx.font); YREG(31) = 0; } @@ -572,6 +572,6 @@ void func_80111070(void) { VREG(92) = -63; } -void func_80112098(GlobalContext* globalCtx) { +void func_80112098(PlayState* play) { func_80111070(); } diff --git a/soh/src/code/z_debug_display.c b/soh/src/code/z_debug_display.c index 14a75aa41..48cca9149 100644 --- a/soh/src/code/z_debug_display.c +++ b/soh/src/code/z_debug_display.c @@ -6,10 +6,10 @@ typedef struct { /* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw function when called } DebugDispObjectInfo; // size = 0x8 -typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, GlobalContext*); +typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*); -void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx); -void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, GlobalContext* globalCtx); +void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play); +void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, PlayState* play); static DebugDispObject_DrawFunc sDebugObjectDrawFuncTable[] = { DebugDisplay_DrawSpriteI8, @@ -55,43 +55,43 @@ DebugDispObject* DebugDisplay_AddObject(f32 posX, f32 posY, f32 posZ, s16 rotX, return sDebugObjectListHead; } -void DebugDisplay_DrawObjects(GlobalContext* globalCtx) { +void DebugDisplay_DrawObjects(PlayState* play) { DebugDispObject* dispObj = sDebugObjectListHead; DebugDispObjectInfo* objInfo; while (dispObj != NULL) { objInfo = &sDebugObjectInfoTable[dispObj->type]; - sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, globalCtx); + sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, play); dispObj = dispObj->next; } } -void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_80094678(globalCtx->state.gfxCtx); + func_80094678(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); Matrix_Translate(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, MTXMODE_NEW); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); Matrix_RotateZYX(dispObj->rot.x, dispObj->rot.y, dispObj->rot.z, MTXMODE_APPLY); gDPLoadTextureBlock(POLY_XLU_DISP++, texture, G_IM_FMT_I, G_IM_SIZ_8b, 16, 16, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gDebugSpriteDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); - func_8009435C(globalCtx->state.gfxCtx); + func_8009435C(play->state.gfxCtx); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a); @@ -100,9 +100,9 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, GlobalConte Matrix_SetTranslateRotateYXZ(dispObj->pos.x, dispObj->pos.y, dispObj->pos.z, &dispObj->rot); Matrix_Scale(dispObj->scale.x, dispObj->scale.y, dispObj->scale.z, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/code/z_demo.c b/soh/src/code/z_demo.c index a447f549c..8f5a5fd31 100644 --- a/soh/src/code/z_demo.c +++ b/soh/src/code/z_demo.c @@ -34,14 +34,14 @@ u16 D_8011E1C0 = 0; u16 D_8011E1C4 = 0; -typedef void (*CutsceneStateHandler)(GlobalContext*, CutsceneContext*); +typedef void (*CutsceneStateHandler)(PlayState*, CutsceneContext*); -void func_80064720(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_80064760(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_800647C0(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_80068C3C(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_80068D84(GlobalContext* globalCtx, CutsceneContext* csCtx); -void func_80068DC0(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_80064720(PlayState* play, CutsceneContext* csCtx); +void func_80064760(PlayState* play, CutsceneContext* csCtx); +void func_800647C0(PlayState* play, CutsceneContext* csCtx); +void func_80068C3C(PlayState* play, CutsceneContext* csCtx); +void func_80068D84(PlayState* play, CutsceneContext* csCtx); +void func_80068DC0(PlayState* play, CutsceneContext* csCtx); CutsceneStateHandler sCsStateHandlers1[] = { func_80064720, func_80064760, func_80064720, func_80068D84, func_80064720, @@ -105,9 +105,9 @@ u16 D_8015FCCC; // only written to, never read char D_8015FCD0[20]; // unreferenced u8 D_8015FCE4; // only written to, never read -void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx); +void func_80068ECC(PlayState* play, CutsceneContext* csCtx); -void Cutscene_DrawDebugInfo(GlobalContext* globalCtx, Gfx** dlist, CutsceneContext* csCtx) { +void Cutscene_DrawDebugInfo(PlayState* play, Gfx** dlist, CutsceneContext* csCtx) { GfxPrint printer; s32 pad[2]; @@ -127,30 +127,30 @@ void Cutscene_DrawDebugInfo(GlobalContext* globalCtx, Gfx** dlist, CutsceneConte GfxPrint_Destroy(&printer); } -void func_8006450C(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_8006450C(PlayState* play, CutsceneContext* csCtx) { csCtx->state = CS_STATE_IDLE; csCtx->unk_0C = 0.0f; } -void func_80064520(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80064520(PlayState* play, CutsceneContext* csCtx) { csCtx->state = CS_STATE_SKIPPABLE_INIT; csCtx->linkAction = NULL; } -void func_80064534(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80064534(PlayState* play, CutsceneContext* csCtx) { if (csCtx->state != CS_STATE_UNSKIPPABLE_EXEC) { csCtx->state = CS_STATE_UNSKIPPABLE_INIT; } } -void func_80064558(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80064558(PlayState* play, CutsceneContext* csCtx) { if (gSaveContext.cutsceneIndex < 0xFFF0) { - sCsStateHandlers1[csCtx->state](globalCtx, csCtx); + sCsStateHandlers1[csCtx->state](play, csCtx); } } -void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) { - Input* input = &globalCtx->state.input[0]; +void func_800645A0(PlayState* play, CutsceneContext* csCtx) { + Input* input = &play->state.input[0]; if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT) && (csCtx->state == CS_STATE_IDLE) && (gSaveContext.sceneSetupIndex >= 4)) { @@ -166,7 +166,7 @@ void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) { gSaveContext.cutsceneTrigger = 1; } - if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->sceneLoadFlag == 0x14)) { + if ((gSaveContext.cutsceneTrigger != 0) && (play->sceneLoadFlag == 0x14)) { gSaveContext.cutsceneTrigger = 0; } @@ -177,42 +177,42 @@ void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) { } if (gSaveContext.cutsceneIndex >= 0xFFF0) { - func_80068ECC(globalCtx, csCtx); - sCsStateHandlers2[csCtx->state](globalCtx, csCtx); + func_80068ECC(play, csCtx); + sCsStateHandlers2[csCtx->state](play, csCtx); } } -void func_80064720(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80064720(PlayState* play, CutsceneContext* csCtx) { } -u32 func_8006472C(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) { +u32 func_8006472C(PlayState* play, CutsceneContext* csCtx, f32 target) { return Math_StepToF(&csCtx->unk_0C, target, 0.1f); } -void func_80064760(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80064760(PlayState* play, CutsceneContext* csCtx) { Interface_ChangeAlpha(1); ShrinkWindow_SetVal(0x20); - if (func_8006472C(globalCtx, csCtx, 1.0f)) { + if (func_8006472C(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(1); csCtx->state++; } } -void func_800647C0(GlobalContext* globalCtx, CutsceneContext* csCtx) { - func_80068C3C(globalCtx, csCtx); +void func_800647C0(PlayState* play, CutsceneContext* csCtx) { + func_80068C3C(play, csCtx); Interface_ChangeAlpha(1); ShrinkWindow_SetVal(0x20); - if (func_8006472C(globalCtx, csCtx, 1.0f)) { + if (func_8006472C(play, csCtx, 1.0f)) { Audio_SetCutsceneFlag(1); csCtx->state++; } } // Command 3: Misc. Actions -void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { - Player* player = GET_PLAYER(globalCtx); +void func_80064824(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { + Player* player = GET_PLAYER(play); f32 temp; u8 sp3F = 0; @@ -231,60 +231,60 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* if (sp3F != 0) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_4, 0x3F); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 1); - globalCtx->envCtx.unk_EE[0] = 20; + play->envCtx.unk_EE[0] = 20; } break; case 2: if (sp3F != 0) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0); - Environment_AddLightningBolts(globalCtx, 3); + Environment_AddLightningBolts(play, 3); gLightningStrike.state = LIGHTNING_STRIKE_START; } break; case 3: if (sp3F != 0) { - Flags_SetEnv(globalCtx, 0); + Flags_SetEnv(play, 0); if (gSaveContext.entranceIndex == 0x0053 || (gSaveContext.n64ddFlag && gSaveContext.entranceIndex == 0x05F4)) { - Flags_SetEnv(globalCtx, 2); + Flags_SetEnv(play, 2); } } break; case 6: - if (globalCtx->envCtx.adjFogFar < 12800) { - globalCtx->envCtx.adjFogFar += 35; + if (play->envCtx.adjFogFar < 12800) { + play->envCtx.adjFogFar += 35; } break; case 7: if (sp3F != 0) { - globalCtx->envCtx.unk_19 = 1; - globalCtx->envCtx.unk_17 = 1; - globalCtx->envCtx.unk_18 = 0; - globalCtx->envCtx.unk_1A = 0x3C; - globalCtx->envCtx.unk_21 = 1; - globalCtx->envCtx.unk_1F = 0; - globalCtx->envCtx.unk_20 = 1; - globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24 = 0x3C; + play->envCtx.unk_19 = 1; + play->envCtx.unk_17 = 1; + play->envCtx.unk_18 = 0; + play->envCtx.unk_1A = 0x3C; + play->envCtx.unk_21 = 1; + play->envCtx.unk_1F = 0; + play->envCtx.unk_20 = 1; + play->envCtx.unk_22 = play->envCtx.unk_24 = 0x3C; } break; case 8: - if (globalCtx->roomCtx.unk_74[0] < 0x80) { - globalCtx->roomCtx.unk_74[0] += 4; + if (play->roomCtx.unk_74[0] < 0x80) { + play->roomCtx.unk_74[0] += 4; } break; case 9: - globalCtx->envCtx.unk_EE[3] = 16; + play->envCtx.unk_EE[3] = 16; break; case 10: - Flags_SetEnv(globalCtx, 1); + Flags_SetEnv(play, 1); break; case 11: - if (globalCtx->roomCtx.unk_74[0] < 0x672) { - globalCtx->roomCtx.unk_74[0] += 0x14; + if (play->roomCtx.unk_74[0] < 0x672) { + play->roomCtx.unk_74[0] += 0x14; } if (csCtx->frames == 0x30F) { func_80078884(NA_SE_EV_DEKU_DEATH); } else if (csCtx->frames == 0x2CD) { - globalCtx->roomCtx.unk_74[0] = 0; + play->roomCtx.unk_74[0] = 0; } break; case 12: @@ -295,27 +295,27 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } break; case 13: - if (globalCtx->roomCtx.unk_74[1] == 0) { + if (play->roomCtx.unk_74[1] == 0) { func_80078884(NA_SE_EV_TRIFORCE_FLASH); } - if (globalCtx->roomCtx.unk_74[1] < 0xFF) { - globalCtx->roomCtx.unk_74[1] += 5; + if (play->roomCtx.unk_74[1] < 0xFF) { + play->roomCtx.unk_74[1] += 5; } break; case 14: if (sp3F != 0) { - func_800BC490(globalCtx, 1); + func_800BC490(play, 1); } break; case 15: if (sp3F != 0) { - TitleCard_InitPlaceName(globalCtx, &globalCtx->actorCtx.titleCtx, player->giObjectSegment, 160, 120, + TitleCard_InitPlaceName(play, &play->actorCtx.titleCtx, player->giObjectSegment, 160, 120, 144, 24, 20); } break; case 16: if (sp3F != 0) { - sQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6); + sQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6); Quake_SetSpeed(sQuakeIndex, 0x7FFF); Quake_SetQuakeValues(sQuakeIndex, 4, 0, 1000, 0); Quake_SetCountdown(sQuakeIndex, 800); @@ -327,12 +327,12 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } break; case 18: - globalCtx->envCtx.unk_EE[0] = 0; - globalCtx->envCtx.gloomySkyMode = 2; + play->envCtx.unk_EE[0] = 0; + play->envCtx.gloomySkyMode = 2; if (gSaveContext.dayTime < 0x4AAB) { gSaveContext.dayTime += 30; } - if (globalCtx->envCtx.unk_EE[1] == 0) { + if (play->envCtx.unk_EE[1] == 0) { gWeatherMode = 0; Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 0); } @@ -359,7 +359,7 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* D_801614B0.a = 255.0f * temp; break; case 24: - globalCtx->roomCtx.curRoom.segment = NULL; + play->roomCtx.curRoom.segment = NULL; break; case 25: gSaveContext.dayTime += 30; @@ -370,44 +370,44 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* case 26: if ((gSaveContext.dayTime < 0x3000) || (gSaveContext.dayTime >= 0x4555)) { if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime < 0xAAAB)) { - globalCtx->envCtx.unk_BF = 1; + play->envCtx.unk_BF = 1; } else if ((gSaveContext.dayTime >= 0xAAAB) && (gSaveContext.dayTime < 0xC556)) { - globalCtx->envCtx.unk_BF = 2; + play->envCtx.unk_BF = 2; } else { - globalCtx->envCtx.unk_BF = 3; + play->envCtx.unk_BF = 3; } } break; case 27: - if (globalCtx->state.frames & 8) { - if (globalCtx->envCtx.adjAmbientColor[0] < 40) { - globalCtx->envCtx.adjAmbientColor[0] += 2; - globalCtx->envCtx.adjLight1Color[1] -= 3; - globalCtx->envCtx.adjLight1Color[2] -= 3; + if (play->state.frames & 8) { + if (play->envCtx.adjAmbientColor[0] < 40) { + play->envCtx.adjAmbientColor[0] += 2; + play->envCtx.adjLight1Color[1] -= 3; + play->envCtx.adjLight1Color[2] -= 3; } } else { - if (globalCtx->envCtx.adjAmbientColor[0] > 2) { - globalCtx->envCtx.adjAmbientColor[0] -= 2; - globalCtx->envCtx.adjLight1Color[1] += 3; - globalCtx->envCtx.adjLight1Color[2] += 3; + if (play->envCtx.adjAmbientColor[0] > 2) { + play->envCtx.adjAmbientColor[0] -= 2; + play->envCtx.adjLight1Color[1] += 3; + play->envCtx.adjLight1Color[2] += 3; } } break; case 28: - globalCtx->unk_11DE9 = 1; + play->unk_11DE9 = 1; break; case 29: - globalCtx->unk_11DE9 = 0; + play->unk_11DE9 = 0; break; case 30: - Flags_SetEnv(globalCtx, 3); + Flags_SetEnv(play, 3); break; case 31: - Flags_SetEnv(globalCtx, 4); + Flags_SetEnv(play, 4); break; case 32: if (sp3F != 0) { - globalCtx->envCtx.sandstormState = 1; + play->envCtx.sandstormState = 1; } func_800788CC(NA_SE_EV_SAND_STORM - SFX_FLAG); break; @@ -429,29 +429,29 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } // Command 4: Set Environment Lighting -void Cutscene_Command_SetLighting(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { +void Cutscene_Command_SetLighting(PlayState* play, CutsceneContext* csCtx, CsCmdEnvLighting* cmd) { if (csCtx->frames == cmd->startFrame) { - globalCtx->envCtx.unk_BF = cmd->setting - 1; - globalCtx->envCtx.unk_D8 = 1.0f; + play->envCtx.unk_BF = cmd->setting - 1; + play->envCtx.unk_D8 = 1.0f; } } // Command 0x56: Play Background Music -void Cutscene_Command_PlayBGM(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicChange* cmd) { +void Cutscene_Command_PlayBGM(PlayState* play, CutsceneContext* csCtx, CsCmdMusicChange* cmd) { if (csCtx->frames == cmd->startFrame) { func_800F595C(cmd->sequence - 1); } } // Command 0x57: Stop Background Music -void Cutscene_Command_StopBGM(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicChange* cmd) { +void Cutscene_Command_StopBGM(PlayState* play, CutsceneContext* csCtx, CsCmdMusicChange* cmd) { if (csCtx->frames == cmd->startFrame) { func_800F59E8(cmd->sequence - 1); } } // Command 0x7C: Fade Background Music over duration -void Cutscene_Command_FadeBGM(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdMusicFade* cmd) { +void Cutscene_Command_FadeBGM(PlayState* play, CutsceneContext* csCtx, CsCmdMusicFade* cmd) { u8 var1; if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) { @@ -466,14 +466,14 @@ void Cutscene_Command_FadeBGM(GlobalContext* globalCtx, CutsceneContext* csCtx, } // Command 9: ? -void Cutscene_Command_09(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdUnknown9* cmd) { +void Cutscene_Command_09(PlayState* play, CutsceneContext* csCtx, CsCmdUnknown9* cmd) { if (csCtx->frames == cmd->startFrame) { func_800AA000(0.0f, cmd->unk_06, cmd->unk_07, cmd->unk_08); } } // Command 0x8C: Set Time of Day & Environment Time -void func_80065134(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) { +void func_80065134(PlayState* play, CutsceneContext* csCtx, CsCmdDayTime* cmd) { s16 temp1; s16 temp2; @@ -487,8 +487,8 @@ void func_80065134(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTim } // Command 0x3E8: Code Execution (& Terminates Cutscene?) -void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { - Player* player = GET_PLAYER(globalCtx); +void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { + Player* player = GET_PLAYER(play); s32 temp = 0; // Automatically skip certain cutscenes when in rando @@ -496,15 +496,15 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt // cmd->base == 24: Dropping a fish for Jabu Jabu // cmd->base == 33: Zelda escaping with impa cutscene bool randoCsSkip = (gSaveContext.n64ddFlag && (cmd->base == 8 || cmd->base == 24 || cmd->base == 33)); - bool debugCsSkip = (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) && + bool debugCsSkip = (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START) && (gSaveContext.fileNum != 0xFEDC) && CVar_GetS32("gDebugEnabled", 0)); - if ((gSaveContext.gameMode != 0) && (gSaveContext.gameMode != 3) && (globalCtx->sceneNum != SCENE_SPOT00) && + if ((gSaveContext.gameMode != 0) && (gSaveContext.gameMode != 3) && (play->sceneNum != SCENE_SPOT00) && (csCtx->frames > 20) && - (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_A) || - CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B) || - CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START)) && - (gSaveContext.fileNum != 0xFEDC) && (globalCtx->sceneLoadFlag == 0)) { + (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_A) || + CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B) || + CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START)) && + (gSaveContext.fileNum != 0xFEDC) && (play->sceneLoadFlag == 0)) { Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); temp = 1; } @@ -525,477 +525,477 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt switch (cmd->base) { case 1: - globalCtx->nextEntranceIndex = 0x00A0; + play->nextEntranceIndex = 0x00A0; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 2: - globalCtx->nextEntranceIndex = 0x00A0; + play->nextEntranceIndex = 0x00A0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 10; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 10; break; case 3: - globalCtx->nextEntranceIndex = 0x0117; + play->nextEntranceIndex = 0x0117; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 10; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 10; break; case 4: - globalCtx->nextEntranceIndex = 0x013D; + play->nextEntranceIndex = 0x013D; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 10; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 10; break; case 5: - globalCtx->nextEntranceIndex = 0x00EE; + play->nextEntranceIndex = 0x00EE; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 10; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 10; break; case 6: - globalCtx->nextEntranceIndex = 0x00A0; + play->nextEntranceIndex = 0x00A0; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 10; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 10; break; case 7: - globalCtx->nextEntranceIndex = 0x00EE; + play->nextEntranceIndex = 0x00EE; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 11; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 11; break; case 8: gSaveContext.fw.set = 0; gSaveContext.respawn[RESPAWN_MODE_TOP].data = 0; if (!(gSaveContext.eventChkInf[4] & 0x20)) { gSaveContext.eventChkInf[4] |= 0x20; - globalCtx->nextEntranceIndex = 0x00A0; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00A0; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->fadeTransition = 11; + play->fadeTransition = 11; } else { if (gSaveContext.sceneSetupIndex < 4) { if (!LINK_IS_ADULT) { - globalCtx->linkAgeOnLoad = 0; + play->linkAgeOnLoad = 0; } else { - globalCtx->linkAgeOnLoad = 1; + play->linkAgeOnLoad = 1; } } - globalCtx->nextEntranceIndex = 0x02CA; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x02CA; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; } break; case 9: - globalCtx->nextEntranceIndex = 0x0117; + play->nextEntranceIndex = 0x0117; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 12; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 12; break; case 10: - globalCtx->nextEntranceIndex = 0x00BB; + play->nextEntranceIndex = 0x00BB; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 11: - globalCtx->nextEntranceIndex = 0x00EE; + play->nextEntranceIndex = 0x00EE; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; break; case 12: - globalCtx->nextEntranceIndex = 0x047A; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x047A; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 13: - globalCtx->nextEntranceIndex = 0x010E; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x010E; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; gSaveContext.nextTransition = 2; break; case 14: - globalCtx->nextEntranceIndex = 0x0457; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0457; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 15: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 16: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 17: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 18: gSaveContext.eventChkInf[4] |= 0x8000; - globalCtx->nextEntranceIndex = 0x0324; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0324; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; gSaveContext.nextTransition = 2; break; case 19: - globalCtx->nextEntranceIndex = 0x013D; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 4; + play->nextEntranceIndex = 0x013D; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 4; gSaveContext.cutsceneIndex = 0x8000; break; case 21: - globalCtx->nextEntranceIndex = 0x0102; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0102; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 22: - Item_Give(globalCtx, ITEM_SONG_REQUIEM); - globalCtx->nextEntranceIndex = 0x0123; - globalCtx->sceneLoadFlag = 0x14; + Item_Give(play, ITEM_SONG_REQUIEM); + play->nextEntranceIndex = 0x0123; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 23: - globalCtx->nextEntranceIndex = 0x00A0; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00A0; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF8; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 24: - globalCtx->nextEntranceIndex = 0x0028; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0028; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 25: - globalCtx->linkAgeOnLoad = 0; - globalCtx->nextEntranceIndex = 0x006B; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 0; + play->nextEntranceIndex = 0x006B; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 26: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 27: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 28: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 29: - globalCtx->nextEntranceIndex = 0x006B; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x006B; + play->sceneLoadFlag = 0x14; gSaveContext.chamberCutsceneNum = 0; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 30: - globalCtx->nextEntranceIndex = 0x006B; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; - Item_Give(globalCtx, ITEM_MEDALLION_FIRE); + play->nextEntranceIndex = 0x006B; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; + Item_Give(play, ITEM_MEDALLION_FIRE); gSaveContext.chamberCutsceneNum = 1; break; case 31: - globalCtx->nextEntranceIndex = 0x006B; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x006B; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.chamberCutsceneNum = 2; break; case 32: - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x00CD; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x00CD; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->fadeTransition = 11; + play->fadeTransition = 11; break; case 33: - globalCtx->nextEntranceIndex = 0x00CD; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x00CD; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; break; case 34: - globalCtx->nextEntranceIndex = 0x00A0; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00A0; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; case 35: - globalCtx->nextEntranceIndex = 0x00CD; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00CD; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; break; case 38: - globalCtx->nextEntranceIndex = 0x00A0; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00A0; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; break; case 39: - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF9; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; break; case 40: - globalCtx->linkAgeOnLoad = 0; - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 0; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFFA; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; break; case 41: - globalCtx->nextEntranceIndex = 0x04E6; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x04E6; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 42: - globalCtx->nextEntranceIndex = 0x00DB; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00DB; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; break; case 43: - globalCtx->nextEntranceIndex = 0x0503; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 4; + play->nextEntranceIndex = 0x0503; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 4; break; case 44: - globalCtx->nextEntranceIndex = 0x0320; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 17; + play->nextEntranceIndex = 0x0320; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 17; break; case 46: gSaveContext.eventChkInf[4] |= 0x8000; - globalCtx->nextEntranceIndex = 0x0324; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 4; + play->nextEntranceIndex = 0x0324; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 4; break; case 47: - Item_Give(globalCtx, ITEM_SONG_NOCTURNE); + Item_Give(play, ITEM_SONG_NOCTURNE); gSaveContext.eventChkInf[5] |= 0x10; - globalCtx->nextEntranceIndex = 0x00DB; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00DB; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; break; case 48: - globalCtx->nextEntranceIndex = 0x01ED; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 15; + play->nextEntranceIndex = 0x01ED; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 15; gSaveContext.nextTransition = 15; break; case 49: - globalCtx->nextEntranceIndex = 0x058C; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 4; + play->nextEntranceIndex = 0x058C; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 4; break; case 50: - globalCtx->nextEntranceIndex = 0x0513; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 17; + play->nextEntranceIndex = 0x0513; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 17; break; case 51: - globalCtx->nextEntranceIndex = 0x00CD; + play->nextEntranceIndex = 0x00CD; gSaveContext.cutsceneIndex = 0xFFF8; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 41; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 41; break; case 52: - globalCtx->nextEntranceIndex = 0x0053; + play->nextEntranceIndex = 0x0053; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 11; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 11; break; case 53: - globalCtx->nextEntranceIndex = 0x050F; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x050F; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; break; case 54: gSaveContext.gameMode = 3; Audio_SetSoundBanksMute(0x6F); - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x0117; + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x0117; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 55: - globalCtx->nextEntranceIndex = 0x0129; + play->nextEntranceIndex = 0x0129; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 56: - globalCtx->nextEntranceIndex = 0x00DB; + play->nextEntranceIndex = 0x00DB; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 57: - globalCtx->nextEntranceIndex = 0x013D; + play->nextEntranceIndex = 0x013D; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 58: - globalCtx->nextEntranceIndex = 0x014D; + play->nextEntranceIndex = 0x014D; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 59: - globalCtx->nextEntranceIndex = 0x0102; + play->nextEntranceIndex = 0x0102; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 60: - globalCtx->nextEntranceIndex = 0x010E; + play->nextEntranceIndex = 0x010E; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 61: - globalCtx->nextEntranceIndex = 0x0108; + play->nextEntranceIndex = 0x0108; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 62: - globalCtx->linkAgeOnLoad = 0; - globalCtx->nextEntranceIndex = 0x00EE; + play->linkAgeOnLoad = 0; + play->nextEntranceIndex = 0x00EE; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 63: - globalCtx->nextEntranceIndex = 0x00EE; + play->nextEntranceIndex = 0x00EE; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 64: - globalCtx->nextEntranceIndex = 0x00CD; + play->nextEntranceIndex = 0x00CD; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 65: - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x0157; + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x0157; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 66: - globalCtx->nextEntranceIndex = 0x0554; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0554; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 67: - globalCtx->nextEntranceIndex = 0x027E; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x027E; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 68: - globalCtx->nextEntranceIndex = 0x00A0; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00A0; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 69: - globalCtx->nextEntranceIndex = 0x05E8; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x05E8; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 70: - globalCtx->nextEntranceIndex = 0x013D; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x013D; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; gSaveContext.nextTransition = 2; break; case 71: gSaveContext.equips.equipment |= 0x0100; - Player_SetEquipmentData(globalCtx, player); + Player_SetEquipmentData(play, player); gSaveContext.equips.equipment |= 0x1000; - Player_SetEquipmentData(globalCtx, player); - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + Player_SetEquipmentData(play, player); + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 72: - globalCtx->nextEntranceIndex = 0x0400; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0400; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; gSaveContext.nextTransition = 2; break; case 73: - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 74: - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; break; case 75: - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 76: - globalCtx->linkAgeOnLoad = 0; - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 0; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 77: - globalCtx->linkAgeOnLoad = 1; - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; + play->linkAgeOnLoad = 1; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 78: - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 79: case 80: @@ -1012,176 +1012,176 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt case 91: case 92: case 93: - globalCtx->nextEntranceIndex = 0x0157; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0157; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 94: - globalCtx->nextEntranceIndex = 0x02AE; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x02AE; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; break; case 95: if ((gSaveContext.eventChkInf[4] & 0x100) && (gSaveContext.eventChkInf[4] & 0x200) && (gSaveContext.eventChkInf[4] & 0x400)) { - globalCtx->nextEntranceIndex = 0x0053; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0053; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; } else { switch (gSaveContext.sceneSetupIndex) { case 8: - globalCtx->nextEntranceIndex = 0x00FC; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x00FC; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 9: - globalCtx->nextEntranceIndex = 0x0147; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0147; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 10: - globalCtx->nextEntranceIndex = 0x0102; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0102; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->fadeTransition = 3; + play->fadeTransition = 3; break; } } break; case 96: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { - globalCtx->nextEntranceIndex = 0x006B; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x006B; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 5; + play->fadeTransition = 5; } else { gSaveContext.eventChkInf[12] |= 0x100; - globalCtx->nextEntranceIndex = 0x0610; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x0610; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; } break; case 97: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - globalCtx->nextEntranceIndex = 0x006B; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x006B; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 5; + play->fadeTransition = 5; } else { - globalCtx->nextEntranceIndex = 0x0580; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x0580; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; } break; case 98: - globalCtx->nextEntranceIndex = 0x0564; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x0564; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; break; case 99: - globalCtx->nextEntranceIndex = 0x0608; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0608; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; gSaveContext.nextTransition = 2; break; case 100: - globalCtx->nextEntranceIndex = 0x00EE; + play->nextEntranceIndex = 0x00EE; gSaveContext.cutsceneIndex = 0xFFF8; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; break; case 101: - globalCtx->nextEntranceIndex = 0x01F5; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 15; + play->nextEntranceIndex = 0x01F5; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 15; break; case 102: - globalCtx->nextEntranceIndex = 0x0590; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0590; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 103: - globalCtx->nextEntranceIndex = 0x00CD; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00CD; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 104: switch (sTitleCsState) { case 0: - globalCtx->nextEntranceIndex = 0x008D; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x008D; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; sTitleCsState++; break; case 1: - globalCtx->nextEntranceIndex = 0x0147; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x0147; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; sTitleCsState++; break; case 2: - globalCtx->nextEntranceIndex = 0x00A0; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00A0; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; sTitleCsState = 0; break; } break; case 105: - globalCtx->nextEntranceIndex = 0x00E4; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = 0x00E4; + play->sceneLoadFlag = 0x14; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; break; case 106: - globalCtx->nextEntranceIndex = 0x0574; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0574; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 107: - globalCtx->nextEntranceIndex = 0x0538; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0538; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 108: - globalCtx->nextEntranceIndex = 0x053C; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x053C; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 109: - globalCtx->nextEntranceIndex = 0x0540; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0540; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 110: - globalCtx->nextEntranceIndex = 0x0544; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0544; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 111: - globalCtx->nextEntranceIndex = 0x0548; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0548; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 112: - globalCtx->nextEntranceIndex = 0x054C; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x054C; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 113: if (Flags_GetEventChkInf(0xBB) && Flags_GetEventChkInf(0xBC) && Flags_GetEventChkInf(0xBD) && Flags_GetEventChkInf(0xBE) && Flags_GetEventChkInf(0xBF) && Flags_GetEventChkInf(0xAD)) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(gTowerBarrierCs); - globalCtx->csCtx.frames = 0; + play->csCtx.segment = SEGMENTED_TO_VIRTUAL(gTowerBarrierCs); + play->csCtx.frames = 0; gSaveContext.cutsceneTrigger = 1; gSaveContext.cutsceneIndex = 0xFFFF; csCtx->state = CS_STATE_UNSKIPPABLE_INIT; @@ -1191,70 +1191,70 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt } break; case 114: - globalCtx->nextEntranceIndex = 0x0185; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0185; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; break; case 115: - globalCtx->nextEntranceIndex = 0x0594; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 2; + play->nextEntranceIndex = 0x0594; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 2; gSaveContext.nextTransition = 2; break; case 116: if (gSaveContext.eventChkInf[12] & 0x100) { - globalCtx->nextEntranceIndex = 0x0580; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x0580; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; } else { - globalCtx->nextEntranceIndex = 0x0610; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x0610; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; } gSaveContext.nextTransition = 3; break; case 117: gSaveContext.gameMode = 3; Audio_SetSoundBanksMute(0x6F); - globalCtx->linkAgeOnLoad = 0; - globalCtx->nextEntranceIndex = 0x00CD; + play->linkAgeOnLoad = 0; + play->nextEntranceIndex = 0x00CD; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; break; case 118: gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = 0x0517; - Gameplay_TriggerVoidOut(globalCtx); + Play_TriggerVoidOut(play); gSaveContext.respawnFlag = -2; gSaveContext.nextTransition = 2; break; case 119: gSaveContext.dayTime = 0x8000; gSaveContext.skyboxTime = 0x8000; - globalCtx->nextEntranceIndex = 0x05F0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = 0x05F0; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; break; } } } // Command 0x2D: Transition Effects -void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) { +void Cutscene_Command_TransitionFX(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) { f32 temp; if ((csCtx->frames >= cmd->startFrame) && (csCtx->frames <= cmd->endFrame)) { - globalCtx->envCtx.fillScreen = true; + play->envCtx.fillScreen = true; temp = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames); switch (cmd->base) { case 1: case 5: - globalCtx->envCtx.screenFillColor[0] = 160; - globalCtx->envCtx.screenFillColor[1] = 160; - globalCtx->envCtx.screenFillColor[2] = 160; + play->envCtx.screenFillColor[0] = 160; + play->envCtx.screenFillColor[1] = 160; + play->envCtx.screenFillColor[2] = 160; if (cmd->base == 1) { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp; + play->envCtx.screenFillColor[3] = 255.0f * temp; if ((temp == 0.0f) && (gSaveContext.entranceIndex == 0x006B)) { Audio_PlaySoundGeneral(NA_SE_SY_WHITE_OUT_S, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); @@ -1263,44 +1263,44 @@ void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* cs (gSaveContext.entranceIndex == 0x0371))) { Audio_PlaySoundGeneral(NA_SE_EV_WHITE_OUT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - } else if ((temp == 0.0f) && (globalCtx->sceneNum == SCENE_GANONTIKA)) { + } else if ((temp == 0.0f) && (play->sceneNum == SCENE_GANONTIKA)) { func_800788CC(NA_SE_EV_WHITE_OUT); } } else { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; } break; case 2: case 6: - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 255; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 255; if (cmd->base == 2) { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp; + play->envCtx.screenFillColor[3] = 255.0f * temp; } else { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; } break; case 3: case 7: - globalCtx->envCtx.screenFillColor[0] = 255; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[0] = 255; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; if (cmd->base == 3) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp; + play->envCtx.screenFillColor[3] = 255.0f * temp; } break; case 4: case 8: - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 255; - globalCtx->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 255; + play->envCtx.screenFillColor[2] = 0; if (cmd->base == 4) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp; + play->envCtx.screenFillColor[3] = 255.0f * temp; } break; case 9: @@ -1308,30 +1308,30 @@ void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* cs break; case 10: case 11: - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; if (cmd->base == 10) { - globalCtx->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; + play->envCtx.screenFillColor[3] = (1.0f - temp) * 255.0f; } else { - globalCtx->envCtx.screenFillColor[3] = 255.0f * temp; + play->envCtx.screenFillColor[3] = 255.0f * temp; } break; case 12: gSaveContext.unk_1410 = 255.0f - (155.0f * temp); break; case 13: - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; - globalCtx->envCtx.screenFillColor[3] = 255.0f - ((1.0f - temp) * 155.0f); + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[3] = 255.0f - ((1.0f - temp) * 155.0f); break; } } } // Command 0x1 & 0x5: Camera Positions -size_t Cutscene_Command_CameraPositions(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { +size_t Cutscene_Command_CameraPositions(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { s32 shouldContinue = true; CsCmdBase* cmdBase = (CsCmdBase*)cmd; size_t size; @@ -1346,12 +1346,12 @@ size_t Cutscene_Command_CameraPositions(GlobalContext* globalCtx, CutsceneContex if (csCtx->unk_1A != 0) { csCtx->unk_18 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - Gameplay_CameraChangeSetting(globalCtx, csCtx->unk_14, CAM_SET_CS_0); - Gameplay_ChangeCameraStatus(globalCtx, D_8015FCC6, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, csCtx->unk_14, CAM_STAT_ACTIVE); - Camera_ResetAnim(Gameplay_GetCamera(globalCtx, csCtx->unk_14)); - Camera_SetCSParams(Gameplay_GetCamera(globalCtx, csCtx->unk_14), csCtx->cameraFocus, - csCtx->cameraPosition, GET_PLAYER(globalCtx), relativeToLink); + Play_CameraChangeSetting(play, csCtx->unk_14, CAM_SET_CS_0); + Play_ChangeCameraStatus(play, D_8015FCC6, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->unk_14, CAM_STAT_ACTIVE); + Camera_ResetAnim(Play_GetCamera(play, csCtx->unk_14)); + Camera_SetCSParams(Play_GetCamera(play, csCtx->unk_14), csCtx->cameraFocus, + csCtx->cameraPosition, GET_PLAYER(play), relativeToLink); } } } @@ -1368,7 +1368,7 @@ size_t Cutscene_Command_CameraPositions(GlobalContext* globalCtx, CutsceneContex } // Command 0x2 & 0x6: Camera Focus Points -size_t Cutscene_Command_CameraFocus(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { +size_t Cutscene_Command_CameraFocus(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { s32 shouldContinue = true; CsCmdBase* cmdBase = (CsCmdBase*)cmd; size_t size; @@ -1383,12 +1383,12 @@ size_t Cutscene_Command_CameraFocus(GlobalContext* globalCtx, CutsceneContext* c if (csCtx->unk_1B != 0) { D_8015FCC0 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - Gameplay_CameraChangeSetting(globalCtx, csCtx->unk_14, CAM_SET_CS_0); - Gameplay_ChangeCameraStatus(globalCtx, D_8015FCC6, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, csCtx->unk_14, CAM_STAT_ACTIVE); - Camera_ResetAnim(Gameplay_GetCamera(globalCtx, csCtx->unk_14)); - Camera_SetCSParams(Gameplay_GetCamera(globalCtx, csCtx->unk_14), csCtx->cameraFocus, - csCtx->cameraPosition, GET_PLAYER(globalCtx), relativeToLink); + Play_CameraChangeSetting(play, csCtx->unk_14, CAM_SET_CS_0); + Play_ChangeCameraStatus(play, D_8015FCC6, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->unk_14, CAM_STAT_ACTIVE); + Camera_ResetAnim(Play_GetCamera(play, csCtx->unk_14)); + Camera_SetCSParams(Play_GetCamera(play, csCtx->unk_14), csCtx->cameraFocus, + csCtx->cameraPosition, GET_PLAYER(play), relativeToLink); } } } @@ -1405,7 +1405,7 @@ size_t Cutscene_Command_CameraFocus(GlobalContext* globalCtx, CutsceneContext* c } // Command 0x7: ? (Related to camera positons) -size_t Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 unused) { +size_t Cutscene_Command_07(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 unused) { CsCmdBase* cmdBase = (CsCmdBase*)cmd; size_t size; Vec3f sp3C; @@ -1423,11 +1423,11 @@ size_t Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* if (csCtx->unk_1A != 0) { D_8015FCC2 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - sp2C = Gameplay_GetCamera(globalCtx, csCtx->unk_14); + sp2C = Play_GetCamera(play, csCtx->unk_14); sp2C->player = NULL; - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, csCtx->unk_14, CAM_STAT_ACTIVE); - Gameplay_CameraChangeSetting(globalCtx, csCtx->unk_14, CAM_SET_FREE0); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->unk_14, CAM_STAT_ACTIVE); + Play_CameraChangeSetting(play, csCtx->unk_14, CAM_SET_FREE0); sp28 = csCtx->cameraFocus->cameraRoll * 1.40625f; Camera_SetParam(sp2C, 64, &sp28); sp3C.x = csCtx->cameraFocus->pos.x; @@ -1436,8 +1436,8 @@ size_t Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* sp30.x = csCtx->cameraPosition->pos.x; sp30.y = csCtx->cameraPosition->pos.y; sp30.z = csCtx->cameraPosition->pos.z; - Gameplay_CameraSetAtEye(globalCtx, csCtx->unk_14, &sp3C, &sp30); - Gameplay_CameraSetFov(globalCtx, csCtx->unk_14, csCtx->cameraPosition->viewAngle); + Play_CameraSetAtEye(play, csCtx->unk_14, &sp3C, &sp30); + Play_CameraSetFov(play, csCtx->unk_14, csCtx->cameraPosition->viewAngle); } } } @@ -1448,7 +1448,7 @@ size_t Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* } // Command 0x8: ? (Related to camera focus points) -size_t Cutscene_Command_08(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 unused) { +size_t Cutscene_Command_08(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 unused) { CsCmdBase* cmdBase = (CsCmdBase*)cmd; size_t size; Vec3f sp3C; @@ -1466,19 +1466,19 @@ size_t Cutscene_Command_08(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* if (csCtx->unk_1B != 0) { D_8015FCC4 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - sp2C = Gameplay_GetCamera(globalCtx, csCtx->unk_14); + sp2C = Play_GetCamera(play, csCtx->unk_14); sp2C->player = NULL; - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_WAIT); - Gameplay_ChangeCameraStatus(globalCtx, csCtx->unk_14, CAM_STAT_ACTIVE); - Gameplay_CameraChangeSetting(globalCtx, csCtx->unk_14, CAM_SET_FREE0); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->unk_14, CAM_STAT_ACTIVE); + Play_CameraChangeSetting(play, csCtx->unk_14, CAM_SET_FREE0); sp3C.x = csCtx->cameraFocus->pos.x; sp3C.y = csCtx->cameraFocus->pos.y; sp3C.z = csCtx->cameraFocus->pos.z; sp30.x = csCtx->cameraPosition->pos.x; sp30.y = csCtx->cameraPosition->pos.y; sp30.z = csCtx->cameraPosition->pos.z; - Gameplay_CameraSetAtEye(globalCtx, csCtx->unk_14, &sp3C, &sp30); - Gameplay_CameraSetFov(globalCtx, csCtx->unk_14, csCtx->cameraPosition->viewAngle); + Play_CameraSetAtEye(play, csCtx->unk_14, &sp3C, &sp30); + Play_CameraSetFov(play, csCtx->unk_14, csCtx->cameraPosition->viewAngle); } } } @@ -1489,7 +1489,7 @@ size_t Cutscene_Command_08(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* } // Command 0x13: Textbox -void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd) { +void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdTextbox* cmd) { u8 dialogState; s16 originalCsFrames; @@ -1498,40 +1498,40 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, if (D_8011E1C0 != cmd->base) { D_8011E1C0 = cmd->base; if ((cmd->type == 3) && CHECK_QUEST_ITEM(QUEST_ZORA_SAPPHIRE)) { - Message_StartTextbox(globalCtx, cmd->textId1, NULL); + Message_StartTextbox(play, cmd->textId1, NULL); } else if ((cmd->type == 4) && CHECK_QUEST_ITEM(QUEST_GORON_RUBY)) { - Message_StartTextbox(globalCtx, cmd->textId1, NULL); + Message_StartTextbox(play, cmd->textId1, NULL); } else { - Message_StartTextbox(globalCtx, cmd->base, NULL); + Message_StartTextbox(play, cmd->base, NULL); } return; } } else { if (D_8011E1C4 != cmd->base) { D_8011E1C4 = cmd->base; - func_8010BD58(globalCtx, cmd->base); + func_8010BD58(play, cmd->base); return; } } if (csCtx->frames >= cmd->endFrame) { originalCsFrames = csCtx->frames; - dialogState = Message_GetState(&globalCtx->msgCtx); + dialogState = Message_GetState(&play->msgCtx); if ((dialogState != TEXT_STATE_CLOSING) && (dialogState != TEXT_STATE_NONE) && (dialogState != TEXT_STATE_SONG_DEMO_DONE) && (dialogState != TEXT_STATE_8)) { csCtx->frames--; - if ((dialogState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(globalCtx)) { - if (globalCtx->msgCtx.choiceIndex == 0) { + if ((dialogState == TEXT_STATE_CHOICE) && Message_ShouldAdvance(play)) { + if (play->msgCtx.choiceIndex == 0) { if (cmd->textId1 != 0xFFFF) { - Message_ContinueTextbox(globalCtx, cmd->textId1); + Message_ContinueTextbox(play, cmd->textId1); } else { csCtx->frames++; } } else { if (cmd->textId2 != 0xFFFF) { - Message_ContinueTextbox(globalCtx, cmd->textId2); + Message_ContinueTextbox(play, cmd->textId2); } else { csCtx->frames++; } @@ -1540,15 +1540,15 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, if (dialogState == TEXT_STATE_9) { if (cmd->textId1 != 0xFFFF) { - Message_ContinueTextbox(globalCtx, cmd->textId1); + Message_ContinueTextbox(play, cmd->textId1); } else { csCtx->frames++; } } if (dialogState == TEXT_STATE_EVENT) { - if (Message_ShouldAdvance(globalCtx)) { - func_8010BD58(globalCtx, cmd->base); + if (Message_ShouldAdvance(play)) { + func_8010BD58(play, cmd->base); } } } @@ -1562,7 +1562,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, } } -void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr) { +void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutscenePtr) { s16 i; s32 totalEntries; s32 cmdType; @@ -1584,7 +1584,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, return; } - if (CVar_GetS32("gDebugEnabled", 0) && CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_DRIGHT)) { + if (CVar_GetS32("gDebugEnabled", 0) && CHECK_BTN_ALL(play->state.input[0].press.button, BTN_DRIGHT)) { csCtx->state = CS_STATE_UNSKIPPABLE_INIT; return; } @@ -1604,7 +1604,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - func_80064824(globalCtx, csCtx, (void*)cutscenePtr); + func_80064824(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1612,7 +1612,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetLighting(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_SetLighting(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1620,7 +1620,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlayBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_PlayBGM(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1628,7 +1628,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_StopBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_StopBGM(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1636,7 +1636,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_FadeBGM(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 12; } break; @@ -1644,7 +1644,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_09(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_09(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 3; } break; @@ -1652,7 +1652,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, memcpy(&cmdEntries, cutscenePtr, sizeof(CutsceneData)); cutscenePtr += sizeof(CutsceneData); for (j = 0; j < cmdEntries; j++) { - func_80065134(globalCtx, csCtx, (void*)cutscenePtr); + func_80065134(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 3; } break; @@ -1864,26 +1864,26 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } break; case CS_CMD_CAM_EYE: - cutscenePtr += Cutscene_Command_CameraPositions(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_CameraPositions(play, csCtx, (void*)cutscenePtr, 0); break; case CS_CMD_CAM_EYE_REL_TO_PLAYER: - cutscenePtr += Cutscene_Command_CameraPositions(globalCtx, csCtx, (void*)cutscenePtr, 1); + cutscenePtr += Cutscene_Command_CameraPositions(play, csCtx, (void*)cutscenePtr, 1); break; case CS_CMD_CAM_AT: - cutscenePtr += Cutscene_Command_CameraFocus(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_CameraFocus(play, csCtx, (void*)cutscenePtr, 0); break; case CS_CMD_CAM_AT_REL_TO_PLAYER: - cutscenePtr += Cutscene_Command_CameraFocus(globalCtx, csCtx, (void*)cutscenePtr, 1); + cutscenePtr += Cutscene_Command_CameraFocus(play, csCtx, (void*)cutscenePtr, 1); break; case CS_CMD_07: - cutscenePtr += Cutscene_Command_07(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_07(play, csCtx, (void*)cutscenePtr, 0); break; case CS_CMD_08: - cutscenePtr += Cutscene_Command_08(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_08(play, csCtx, (void*)cutscenePtr, 0); break; case CS_CMD_TERMINATOR: cutscenePtr += 4; - Cutscene_Command_Terminator(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_Terminator(play, csCtx, (void*)cutscenePtr); cutscenePtr += 8; break; case CS_CMD_TEXTBOX: @@ -1892,14 +1892,14 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, for (j = 0; j < cmdEntries; j++) { cmd = (CsCmdBase*)cutscenePtr; if (cmd->base != 0xFFFF) { - Cutscene_Command_Textbox(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_Textbox(play, csCtx, (void*)cutscenePtr); } cutscenePtr += sizeof(CutsceneData) * 3; } break; case CS_CMD_SCENE_TRANS_FX: cutscenePtr += sizeof(CutsceneData); - Cutscene_Command_TransitionFX(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_TransitionFX(play, csCtx, (void*)cutscenePtr); cutscenePtr += sizeof(CutsceneData) * 2; break; default: @@ -1913,46 +1913,46 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } } -void func_80068C3C(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80068C3C(PlayState* play, CutsceneContext* csCtx) { Gfx* displayList; Gfx* prevDisplayList; if (gSaveContext.cutsceneIndex >= 0xFFF0) { if (BREG(0) != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); prevDisplayList = POLY_OPA_DISP; displayList = Graph_GfxPlusOne(POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, displayList); - Cutscene_DrawDebugInfo(globalCtx, &displayList, csCtx); + Cutscene_DrawDebugInfo(play, &displayList, csCtx); gSPEndDisplayList(displayList++); Graph_BranchDlist(prevDisplayList, displayList); POLY_OPA_DISP = displayList; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } csCtx->frames++; if (dREG(95) != 0) { - Cutscene_ProcessCommands(globalCtx, csCtx, D_8012D1F0); + Cutscene_ProcessCommands(play, csCtx, D_8012D1F0); } else { - Cutscene_ProcessCommands(globalCtx, csCtx, globalCtx->csCtx.segment); + Cutscene_ProcessCommands(play, csCtx, play->csCtx.segment); } } } -void func_80068D84(GlobalContext* globalCtx, CutsceneContext* csCtx) { - if (func_8006472C(globalCtx, csCtx, 0.0f)) { +void func_80068D84(PlayState* play, CutsceneContext* csCtx) { + if (func_8006472C(play, csCtx, 0.0f)) { Audio_SetCutsceneFlag(0); csCtx->state = CS_STATE_IDLE; } } -void func_80068DC0(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80068DC0(PlayState* play, CutsceneContext* csCtx) { s16 i; - if (func_8006472C(globalCtx, csCtx, 0.0f)) { + if (func_8006472C(play, csCtx, 0.0f)) { csCtx->linkAction = NULL; for (i = 0; i < 10; i++) { @@ -1969,12 +1969,12 @@ void func_80068DC0(GlobalContext* globalCtx, CutsceneContext* csCtx) { case 0x028E: case 0x0292: case 0x0476: - Gameplay_CopyCamera(globalCtx, D_8015FCC6, csCtx->unk_14); + Play_CopyCamera(play, D_8015FCC6, csCtx->unk_14); } - Gameplay_ChangeCameraStatus(globalCtx, D_8015FCC6, CAM_STAT_ACTIVE); - Gameplay_ClearCamera(globalCtx, csCtx->unk_14); - func_8005B1A4(globalCtx->cameraPtrs[D_8015FCC6]); + Play_ChangeCameraStatus(play, D_8015FCC6, CAM_STAT_ACTIVE); + Play_ClearCamera(play, csCtx->unk_14); + func_8005B1A4(play->cameraPtrs[D_8015FCC6]); } Audio_SetCutsceneFlag(0); @@ -1982,15 +1982,15 @@ void func_80068DC0(GlobalContext* globalCtx, CutsceneContext* csCtx) { } } -void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) { +void func_80068ECC(PlayState* play, CutsceneContext* csCtx) { u8 i; - if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_IDLE) && !Player_InCsMode(globalCtx)) { + if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_IDLE) && !Player_InCsMode(play)) { gSaveContext.cutsceneIndex = 0xFFFD; } if ((gSaveContext.cutsceneIndex >= 0xFFF0) && (csCtx->state == CS_STATE_IDLE)) { - Flags_UnsetEnv(globalCtx, 0); + Flags_UnsetEnv(play, 0); D_8011E1C0 = 0; D_8011E1C4 = 0; @@ -2013,10 +2013,10 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) { D_8015FCC4 = 0xFFFF; csCtx->unk_1A = 0; csCtx->unk_1B = 0; - D_8015FCC6 = globalCtx->activeCamera; + D_8015FCC6 = play->activeCamera; if (D_8015FCC8 != 0) { - csCtx->unk_14 = Gameplay_CreateSubCamera(globalCtx); + csCtx->unk_14 = Play_CreateSubCamera(play); } if (gSaveContext.cutsceneTrigger == 0) { @@ -2026,14 +2026,14 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) { csCtx->state++; } - func_80068C3C(globalCtx, csCtx); + func_80068C3C(play, csCtx); } gSaveContext.cutsceneTrigger = 0; } } -void func_80069048(GlobalContext* globalCtx) { +void func_80069048(PlayState* play) { s16 i; D_8015FCCC = 0; @@ -2043,13 +2043,13 @@ void func_80069048(GlobalContext* globalCtx) { D_8015FCE4 = 0; } -void func_8006907C(GlobalContext* globalCtx) { +void func_8006907C(PlayState* play) { if (D_8015FCCC != 0) { D_8015FCCC = 0; } } -void Cutscene_HandleEntranceTriggers(GlobalContext* globalCtx) { +void Cutscene_HandleEntranceTriggers(PlayState* play) { EntranceCutscene* entranceCutscene; u8 requiredAge; s16 i; @@ -2079,7 +2079,7 @@ void Cutscene_HandleEntranceTriggers(GlobalContext* globalCtx) { (gSaveContext.cutsceneIndex < 0xFFF0) && ((u8)gSaveContext.linkAge == requiredAge) && (gSaveContext.respawnFlag <= 0)) { Flags_SetEventChkInf(entranceCutscene->flag); - Cutscene_SetSegment(globalCtx, entranceCutscene->segAddr); + Cutscene_SetSegment(play, entranceCutscene->segAddr); gSaveContext.cutsceneTrigger = 2; gSaveContext.showTitleCard = false; break; @@ -2087,7 +2087,7 @@ void Cutscene_HandleEntranceTriggers(GlobalContext* globalCtx) { } } -void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { +void Cutscene_HandleConditionalTriggers(PlayState* play) { osSyncPrintf("\ngame_info.mode=[%d] restart_flag", ((void)0, gSaveContext.respawnFlag)); if ((gSaveContext.gameMode == 0) && (gSaveContext.respawnFlag <= 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) { @@ -2109,7 +2109,7 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { } else if ((gSaveContext.entranceIndex == 0x05E0) && !Flags_GetEventChkInf(0xC1)) { if (!gSaveContext.n64ddFlag) { Flags_SetEventChkInf(0xC1); - Item_Give(globalCtx, ITEM_OCARINA_FAIRY); + Item_Give(play, ITEM_OCARINA_FAIRY); gSaveContext.entranceIndex = 0x011E; gSaveContext.cutsceneIndex = 0xFFF0; } @@ -2137,11 +2137,11 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { } } -void Cutscene_SetSegment(GlobalContext* globalCtx, void* segment) { +void Cutscene_SetSegment(PlayState* play, void* segment) { if (SEGMENT_NUMBER(segment) != 0) { - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(segment); + play->csCtx.segment = SEGMENTED_TO_VIRTUAL(segment); } else { - globalCtx->csCtx.segment = segment; + play->csCtx.segment = segment; } } diff --git a/soh/src/code/z_draw.c b/soh/src/code/z_draw.c index 7d98c8e2c..041c5a0eb 100644 --- a/soh/src/code/z_draw.c +++ b/soh/src/code/z_draw.c @@ -79,40 +79,40 @@ #include "objects/object_st/object_st.h" // "Get Item" Model Draw Functions -void GetItem_DrawMaskOrBombchu(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawSoldOut(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawBlueFire(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawPoes(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawFairy(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawMirrorShield(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawSkullToken(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawEggOrMedallion(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawCompass(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawPotion(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawGoronSword(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawDekuNuts(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawRecoveryHeart(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawFish(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawOpa0(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawOpa0Xlu1(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawXlu01(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawOpa10Xlu2(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawMagicArrow(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawMagicSpell(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawOpa1023(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawOpa10Xlu32(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawSmallRupee(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawScale(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawBulletBag(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawWallet(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawJewel(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawJewelKokiri(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawJewelGoron(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawJewelZora(GlobalContext* globalCtx, s16 drawId); -void GetItem_DrawGenericMusicNote(GlobalContext* globalCtx, s16 drawId); +void GetItem_DrawMaskOrBombchu(PlayState* play, s16 drawId); +void GetItem_DrawSoldOut(PlayState* play, s16 drawId); +void GetItem_DrawBlueFire(PlayState* play, s16 drawId); +void GetItem_DrawPoes(PlayState* play, s16 drawId); +void GetItem_DrawFairy(PlayState* play, s16 drawId); +void GetItem_DrawMirrorShield(PlayState* play, s16 drawId); +void GetItem_DrawSkullToken(PlayState* play, s16 drawId); +void GetItem_DrawEggOrMedallion(PlayState* play, s16 drawId); +void GetItem_DrawCompass(PlayState* play, s16 drawId); +void GetItem_DrawPotion(PlayState* play, s16 drawId); +void GetItem_DrawGoronSword(PlayState* play, s16 drawId); +void GetItem_DrawDekuNuts(PlayState* play, s16 drawId); +void GetItem_DrawRecoveryHeart(PlayState* play, s16 drawId); +void GetItem_DrawFish(PlayState* play, s16 drawId); +void GetItem_DrawOpa0(PlayState* play, s16 drawId); +void GetItem_DrawOpa0Xlu1(PlayState* play, s16 drawId); +void GetItem_DrawXlu01(PlayState* play, s16 drawId); +void GetItem_DrawOpa10Xlu2(PlayState* play, s16 drawId); +void GetItem_DrawMagicArrow(PlayState* play, s16 drawId); +void GetItem_DrawMagicSpell(PlayState* play, s16 drawId); +void GetItem_DrawOpa1023(PlayState* play, s16 drawId); +void GetItem_DrawOpa10Xlu32(PlayState* play, s16 drawId); +void GetItem_DrawSmallRupee(PlayState* play, s16 drawId); +void GetItem_DrawScale(PlayState* play, s16 drawId); +void GetItem_DrawBulletBag(PlayState* play, s16 drawId); +void GetItem_DrawWallet(PlayState* play, s16 drawId); +void GetItem_DrawJewel(PlayState* play, s16 drawId); +void GetItem_DrawJewelKokiri(PlayState* play, s16 drawId); +void GetItem_DrawJewelGoron(PlayState* play, s16 drawId); +void GetItem_DrawJewelZora(PlayState* play, s16 drawId); +void GetItem_DrawGenericMusicNote(PlayState* play, s16 drawId); typedef struct { - /* 0x00 */ void (*drawFunc)(GlobalContext*, s16); + /* 0x00 */ void (*drawFunc)(PlayState*, s16); /* 0x04 */ Gfx* dlists[8]; } DrawItemTableEntry; // size = 0x24 @@ -391,21 +391,21 @@ DrawItemTableEntry sDrawItemTable[] = { * Draw "Get Item" Model * Calls the corresponding draw function for the given draw ID */ -void GetItem_Draw(GlobalContext* globalCtx, s16 drawId) { - sDrawItemTable[drawId].drawFunc(globalCtx, drawId); +void GetItem_Draw(PlayState* play, s16 drawId) { + sDrawItemTable[drawId].drawFunc(play, drawId); } /** * Draw "Get Item" Model from a `GetItemEntry` * Uses the Custom Draw Function if it exists, or just calls `GetItem_Draw` */ -void GetItemEntry_Draw(GlobalContext* globalCtx, GetItemEntry getItemEntry) { +void GetItemEntry_Draw(PlayState* play, GetItemEntry getItemEntry) { // RANDOTODO: Make this more flexible for easier toggling of individual item recolors in the future. if (getItemEntry.drawFunc != NULL && (CVar_GetS32("gRandoMatchKeyColors", 0) || getItemEntry.getItemId == RG_DOUBLE_DEFENSE)) { - getItemEntry.drawFunc(globalCtx, &getItemEntry); + getItemEntry.drawFunc(play, &getItemEntry); } else { - GetItem_Draw(globalCtx, getItemEntry.gid); + GetItem_Draw(play, getItemEntry.gid); } } @@ -416,7 +416,7 @@ void GetItemEntry_Draw(GlobalContext* globalCtx, GetItemEntry getItemEntry) { /* 0x017E */ u8 primOpaColor[3]; /* 0x0181 */ u8 envOpaColor[3]; -void GetItem_DrawJewelKokiri(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawJewelKokiri(PlayState* play, s16 drawId) { primXluColor[2] = 160; primXluColor[0] = 255; primXluColor[1] = 255; @@ -430,10 +430,10 @@ void GetItem_DrawJewelKokiri(GlobalContext* globalCtx, s16 drawId) { envOpaColor[0] = 150; envOpaColor[2] = 0; - GetItem_DrawJewel(globalCtx, drawId); + GetItem_DrawJewel(play, drawId); } -void GetItem_DrawJewelGoron(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawJewelGoron(PlayState* play, s16 drawId) { primXluColor[1] = 170; primXluColor[0] = 255; primXluColor[2] = 255; @@ -447,10 +447,10 @@ void GetItem_DrawJewelGoron(GlobalContext* globalCtx, s16 drawId) { envOpaColor[0] = 150; envOpaColor[2] = 0; - GetItem_DrawJewel(globalCtx, drawId); + GetItem_DrawJewel(play, drawId); } -void GetItem_DrawJewelZora(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawJewelZora(PlayState* play, s16 drawId) { primXluColor[0] = 50; primXluColor[1] = 255; primXluColor[2] = 255; @@ -464,355 +464,355 @@ void GetItem_DrawJewelZora(GlobalContext* globalCtx, s16 drawId) { envOpaColor[0] = 150; envOpaColor[2] = 0; - GetItem_DrawJewel(globalCtx, drawId); + GetItem_DrawJewel(play, drawId); } -void GetItem_DrawJewel(GlobalContext* globalCtx, s16 drawId) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void GetItem_DrawJewel(PlayState* play, s16 drawId) { + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 9, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 % 256, (256 - (0 % 256)) - 1, 64, 64, 1, 0 % 256, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 % 256, (256 - (0 % 256)) - 1, 64, 64, 1, 0 % 256, (256 - (0 % 256)) - 1, 16, 16)); - gSPSegment(POLY_OPA_DISP++, 8, Gfx_TexScroll(globalCtx->state.gfxCtx, (u8)0, (u8)0, 16, 16)); + gSPSegment(POLY_OPA_DISP++, 8, Gfx_TexScroll(play->state.gfxCtx, (u8)0, (u8)0, 16, 16)); Matrix_Push(); Matrix_RotateZYX(0, -0x4000, 0x4000, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2597), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_demo_effect.c", 2597), G_MTX_NOPUSH | G_MTX_LOAD); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_demo_effect.c", 2599), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_demo_effect.c", 2599), G_MTX_NOPUSH | G_MTX_LOAD); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); - // func_8002ED80(&this->actor, globalCtx, 0); + // func_8002ED80(&this->actor, play, 0); gDPSetPrimColor(POLY_XLU_DISP++, 0, 128, primXluColor[0], primXluColor[1], primXluColor[2], 255); gDPSetEnvColor(POLY_XLU_DISP++, envXluColor[0], envXluColor[1], envXluColor[2], 255); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D18(globalCtx->state.gfxCtx); - // func_8002EBCC(&this->actor, globalCtx, 0); + func_80093D18(play->state.gfxCtx); + // func_8002EBCC(&this->actor, play, 0); gDPSetPrimColor(POLY_OPA_DISP++, 0, 128, primOpaColor[0], primOpaColor[1], primOpaColor[2], 255); gDPSetEnvColor(POLY_OPA_DISP++, envOpaColor[0], envOpaColor[1], envOpaColor[2], 255); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawMaskOrBombchu(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMaskOrBombchu(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093BA8(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093BA8(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawSoldOut(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawSoldOut(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 5); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawBlueFire(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawBlueFire(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 0), - 0 * (globalCtx->state.frames * 0), 16, 32, 1, 1 * (globalCtx->state.frames * 1), - 1 * -(globalCtx->state.frames * 8), 16, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0), + 0 * (play->state.frames * 0), 16, 32, 1, 1 * (play->state.frames * 1), + 1 * -(play->state.frames * 8), 16, 32)); Matrix_Push(); Matrix_Translate(-8.0f, -2.0f, 0.0f, MTXMODE_APPLY); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawPoes(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawPoes(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 0), - 0 * (globalCtx->state.frames * 0), 16, 32, 1, 1 * (globalCtx->state.frames * 1), - 1 * -(globalCtx->state.frames * 6), 16, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0), + 0 * (play->state.frames * 0), 16, 32, 1, 1 * (play->state.frames * 1), + 1 * -(play->state.frames * 6), 16, 32)); Matrix_Push(); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawFairy(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawFairy(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 0), - 0 * (globalCtx->state.frames * 0), 32, 32, 1, 1 * (globalCtx->state.frames * 1), - 1 * -(globalCtx->state.frames * 6), 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0), + 0 * (play->state.frames * 0), 32, 32, 1, 1 * (play->state.frames * 1), + 1 * -(play->state.frames * 6), 32, 32)); Matrix_Push(); - Matrix_ReplaceRotation(&globalCtx->billboardMtxF); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawMirrorShield(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMirrorShield(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 0) % 256, - 1 * (globalCtx->state.frames * 2) % 256, 64, 64, 1, - 0 * (globalCtx->state.frames * 0) % 128, 1 * (globalCtx->state.frames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0) % 256, + 1 * (play->state.frames * 2) % 256, 64, 64, 1, + 0 * (play->state.frames * 0) % 128, 1 * (play->state.frames * 1) % 128, 32, 32)); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawSkullToken(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawSkullToken(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 0), - 1 * -(globalCtx->state.frames * 5), 32, 32, 1, 0 * (globalCtx->state.frames * 0), - 0 * (globalCtx->state.frames * 0), 32, 64)); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0), + 1 * -(play->state.frames * 5), 32, 32, 1, 0 * (play->state.frames * 0), + 0 * (play->state.frames * 0), 32, 64)); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawEggOrMedallion(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawEggOrMedallion(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093BA8(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093BA8(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawCompass(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawCompass(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 5); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawPotion(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawPotion(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, -1 * (globalCtx->state.frames * 1), - 1 * (globalCtx->state.frames * 1), 32, 32, 1, -1 * (globalCtx->state.frames * 1), - 1 * (globalCtx->state.frames * 1), 32, 32)); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, -1 * (play->state.frames * 1), + 1 * (play->state.frames * 1), 32, 32, 1, -1 * (play->state.frames * 1), + 1 * (play->state.frames * 1), 32, 32)); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[2]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[3]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[4]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[5]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawGoronSword(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawGoronSword(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 1 * (globalCtx->state.frames * 1), - 0 * (globalCtx->state.frames * 1), 32, 32, 1, 0 * (globalCtx->state.frames * 1), - 0 * (globalCtx->state.frames * 1), 32, 32)); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 1 * (play->state.frames * 1), + 0 * (play->state.frames * 1), 32, 32, 1, 0 * (play->state.frames * 1), + 0 * (play->state.frames * 1), 32, 32)); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawDekuNuts(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawDekuNuts(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 1 * (globalCtx->state.frames * 6), - 1 * (globalCtx->state.frames * 6), 32, 32, 1, 1 * (globalCtx->state.frames * 6), - 1 * (globalCtx->state.frames * 6), 32, 32)); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 1 * (play->state.frames * 6), + 1 * (play->state.frames * 6), 32, 32, 1, 1 * (play->state.frames * 6), + 1 * (play->state.frames * 6), 32, 32)); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawRecoveryHeart(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawRecoveryHeart(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 1), - 1 * -(globalCtx->state.frames * 3), 32, 32, 1, 0 * (globalCtx->state.frames * 1), - 1 * -(globalCtx->state.frames * 2), 32, 32)); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 1), + 1 * -(play->state.frames * 3), 32, 32, 1, 0 * (play->state.frames * 1), + 1 * -(play->state.frames * 2), 32, 32)); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawFish(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawFish(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0 * (globalCtx->state.frames * 0), - 1 * (globalCtx->state.frames * 1), 32, 32, 1, 0 * (globalCtx->state.frames * 0), - 1 * (globalCtx->state.frames * 1), 32, 32)); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0 * (play->state.frames * 0), + 1 * (play->state.frames * 1), 32, 32, 1, 0 * (play->state.frames * 0), + 1 * (play->state.frames * 1), 32, 32)); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawOpa0(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa0(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawOpa0Xlu1(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa0Xlu1(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawGenericMusicNote(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawGenericMusicNote(PlayState* play, s16 drawId) { s32 pad; s16 color_slot = drawId-120; //0 = generic s16* colors[7][3] = { @@ -825,195 +825,195 @@ void GetItem_DrawGenericMusicNote(GlobalContext* globalCtx, s16 drawId) { {146,146,146} //Storms }; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, __FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, __FILE__, __LINE__), G_MTX_MODELVIEW | G_MTX_LOAD); gsDPSetGrayscaleColor(POLY_XLU_DISP++, colors[color_slot][0], colors[color_slot][1], colors[color_slot][2], 255); gsSPGrayscale(POLY_XLU_DISP++, true); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); gsSPGrayscale(POLY_XLU_DISP++, false); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawXlu01(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawXlu01(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawOpa10Xlu2(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa10Xlu2(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawMagicArrow(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMagicArrow(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawMagicSpell(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMagicSpell(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 1 * (globalCtx->state.frames * 2), - 1 * -(globalCtx->state.frames * 6), 32, 32, 1, 1 * (globalCtx->state.frames * 1), - -1 * (globalCtx->state.frames * 2), 32, 32)); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 1 * (play->state.frames * 2), + 1 * -(play->state.frames * 6), 32, 32, 1, 1 * (play->state.frames * 1), + -1 * (play->state.frames * 2), 32, 32)); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawOpa1023(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa1023(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[2]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[3]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawOpa10Xlu32(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa10Xlu32(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawSmallRupee(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawSmallRupee(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Scale(0.7f, 0.7f, 0.7f, MTXMODE_APPLY); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawScale(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawScale(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 1 * (globalCtx->state.frames * 2), - -1 * (globalCtx->state.frames * 2), 64, 64, 1, 1 * (globalCtx->state.frames * 4), - 1 * -(globalCtx->state.frames * 4), 32, 32)); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 1 * (play->state.frames * 2), + -1 * (play->state.frames * 2), 64, 64, 1, 1 * (play->state.frames * 4), + 1 * -(play->state.frames * 4), 32, 32)); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawBulletBag(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawBulletBag(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[3]); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[4]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void GetItem_DrawWallet(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawWallet(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[1]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); @@ -1024,5 +1024,5 @@ void GetItem_DrawWallet(GlobalContext* globalCtx, s16 drawId) { gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[6]); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[7]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/code/z_eff_shield_particle.c b/soh/src/code/z_eff_shield_particle.c index 27032a632..43934f4e0 100644 --- a/soh/src/code/z_eff_shield_particle.c +++ b/soh/src/code/z_eff_shield_particle.c @@ -55,7 +55,7 @@ void EffectShieldParticle_Init(void* thisx, void* initParamsx) { this->lightInfo.type = LIGHT_POINT_NOGLOW; this->lightInfo.params.point = initParams->lightPoint; this->lightNode = - LightContext_InsertLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, &this->lightInfo); + LightContext_InsertLight(Effect_GetPlayState(), &Effect_GetPlayState()->lightCtx, &this->lightInfo); } else { this->lightNode = NULL; } @@ -66,10 +66,10 @@ void EffectShieldParticle_Destroy(void* thisx) { EffectShieldParticle* this = (EffectShieldParticle*)thisx; if ((this != NULL) && (this->lightDecay == true)) { - if (this->lightNode == Effect_GetGlobalCtx()->lightCtx.listHead) { - Effect_GetGlobalCtx()->lightCtx.listHead = this->lightNode->next; + if (this->lightNode == Effect_GetPlayState()->lightCtx.listHead) { + Effect_GetPlayState()->lightCtx.listHead = this->lightNode->next; } - LightContext_RemoveLight(Effect_GetGlobalCtx(), &Effect_GetGlobalCtx()->lightCtx, this->lightNode); + LightContext_RemoveLight(Effect_GetPlayState(), &Effect_GetPlayState()->lightCtx, this->lightNode); } } diff --git a/soh/src/code/z_eff_spark.c b/soh/src/code/z_eff_spark.c index 5ce627508..c96bffa55 100644 --- a/soh/src/code/z_eff_spark.c +++ b/soh/src/code/z_eff_spark.c @@ -134,7 +134,7 @@ s32 EffectSpark_Update(void* thisx) { void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { Vtx* vertices; EffectSpark* this = (EffectSpark*)thisx; - GlobalContext* globalCtx = Effect_GetGlobalCtx(); + PlayState* play = Effect_GetPlayState(); s32 i; s32 j; u8 sp1D3; @@ -216,7 +216,7 @@ void EffectSpark_Draw(void* thisx, GraphicsContext* gfxCtx) { SkinMatrix_SetTranslate(&spEC, elem->position.x, elem->position.y, elem->position.z); temp = ((Rand_ZeroOne() * 2.5f) + 1.5f) / 64.0f; SkinMatrix_SetScale(&spAC, temp, temp, 1.0f); - SkinMatrix_MtxFMtxFMult(&spEC, &globalCtx->billboardMtxF, &sp6C); + SkinMatrix_MtxFMtxFMult(&spEC, &play->billboardMtxF, &sp6C); SkinMatrix_MtxFMtxFMult(&sp6C, &spAC, &sp12C); vertices[j].v.ob[0] = -32; diff --git a/soh/src/code/z_eff_ss_dead.c b/soh/src/code/z_eff_ss_dead.c index f03fcd343..65015b44f 100644 --- a/soh/src/code/z_eff_ss_dead.c +++ b/soh/src/code/z_eff_ss_dead.c @@ -1,11 +1,11 @@ #include "global.h" -void func_80026230(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_80026230(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; Gfx* displayListHead; f32 absCos; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); displayListHead = POLY_OPA_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); @@ -23,15 +23,15 @@ void func_80026230(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_OPA_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80026400(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_80026400(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { Gfx* displayListHead; f32 cos; if (arg3 != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); cos = Math_CosS((0x4000 / arg3) * arg2); displayListHead = POLY_OPA_DISP; @@ -42,27 +42,27 @@ void func_80026400(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_OPA_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void func_80026608(GlobalContext* globalCtx) { +void func_80026608(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80026690(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_80026690(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; Gfx* displayListHead; f32 absCos; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); displayListHead = POLY_XLU_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); @@ -80,14 +80,14 @@ void func_80026690(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_XLU_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80026860(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) { +void func_80026860(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) { f32 cos; Gfx* displayListHead; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); displayListHead = POLY_XLU_DISP; cos = Math_CosS((0x4000 / arg3) * arg2); @@ -98,16 +98,16 @@ void func_80026860(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a POLY_XLU_DISP = displayListHead; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void func_80026A6C(GlobalContext* globalCtx) { +void func_80026A6C(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gDPPipeSync(POLY_XLU_DISP++); - POLY_XLU_DISP = Gameplay_SetFog(globalCtx, POLY_XLU_DISP); + POLY_XLU_DISP = Play_SetFog(play, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/code/z_effect.c b/soh/src/code/z_effect.c index 5c2a12215..9accf8ec1 100644 --- a/soh/src/code/z_effect.c +++ b/soh/src/code/z_effect.c @@ -33,8 +33,8 @@ EffectInfo sEffectInfoTable[] = { }, }; -GlobalContext* Effect_GetGlobalCtx(void) { - return sEffectContext.globalCtx; +PlayState* Effect_GetPlayState(void) { + return sEffectContext.play; } void* Effect_GetByIndex(s32 index) { @@ -77,7 +77,7 @@ void Effect_InitStatus(EffectStatus* status) { status->unk_02 = 0; } -void Effect_InitContext(GlobalContext* globalCtx) { +void Effect_InitContext(PlayState* play) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { @@ -93,10 +93,10 @@ void Effect_InitContext(GlobalContext* globalCtx) { Effect_InitStatus(&sEffectContext.blures[i].status); } - sEffectContext.globalCtx = globalCtx; + sEffectContext.play = play; } -void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) { +void Effect_Add(PlayState* play, s32* pIndex, s32 type, u8 arg3, u8 arg4, void* initParams) { s32 i; u32 slotFound; void* effect = NULL; @@ -104,7 +104,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg *pIndex = TOTAL_EFFECT_COUNT; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(play) != true) { slotFound = false; switch (type) { case EFFECT_SPARK: @@ -178,13 +178,13 @@ void Effect_DrawAll(GraphicsContext* gfxCtx) { } } -void Effect_UpdateAll(GlobalContext* globalCtx) { +void Effect_UpdateAll(PlayState* play) { s32 i; for (i = 0; i < SPARK_COUNT; i++) { if (sEffectContext.sparks[i].status.active) { if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) { - Effect_Delete(globalCtx, i); + Effect_Delete(play, i); } } } @@ -192,7 +192,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { for (i = 0; i < BLURE_COUNT; i++) { if (sEffectContext.blures[i].status.active) { if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) { - Effect_Delete(globalCtx, i + SPARK_COUNT); + Effect_Delete(play, i + SPARK_COUNT); } } } @@ -200,13 +200,13 @@ void Effect_UpdateAll(GlobalContext* globalCtx) { for (i = 0; i < SHIELD_PARTICLE_COUNT; i++) { if (sEffectContext.shieldParticles[i].status.active) { if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) { - Effect_Delete(globalCtx, i + SPARK_COUNT + BLURE_COUNT); + Effect_Delete(play, i + SPARK_COUNT + BLURE_COUNT); } } } } -void Effect_Delete(GlobalContext* globalCtx, s32 index) { +void Effect_Delete(PlayState* play, s32 index) { if (index == TOTAL_EFFECT_COUNT) { return; } @@ -232,7 +232,7 @@ void Effect_Delete(GlobalContext* globalCtx, s32 index) { } } -void Effect_DeleteAll(GlobalContext* globalCtx) { +void Effect_DeleteAll(PlayState* play) { s32 i; osSyncPrintf("エフェクト総て解放\n"); // "All effect release" diff --git a/soh/src/code/z_effect_soft_sprite.c b/soh/src/code/z_effect_soft_sprite.c index e093edf38..96c4c7b7f 100644 --- a/soh/src/code/z_effect_soft_sprite.c +++ b/soh/src/code/z_effect_soft_sprite.c @@ -5,7 +5,7 @@ EffectSsInfo sEffectSsInfo = { 0 }; // "EffectSS2Info" -void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) { +void EffectSs_InitInfo(PlayState* play, s32 tableSize) { u32 i; EffectSs* effectSs; EffectSsOverlay* overlay; @@ -17,7 +17,7 @@ void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) { } sEffectSsInfo.table = - GAMESTATE_ALLOC_MC(&globalCtx->state, tableSize * sizeof(EffectSs)); + GAMESTATE_ALLOC_MC(&play->state, tableSize * sizeof(EffectSs)); ASSERT(sEffectSsInfo.table != NULL); sEffectSsInfo.searchStartIndex = 0; @@ -34,7 +34,7 @@ void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) { } } -void EffectSs_ClearAll(GlobalContext* globalCtx) { +void EffectSs_ClearAll(PlayState* play) { u32 i; EffectSs* effectSs; EffectSsOverlay* overlay; @@ -155,10 +155,10 @@ s32 EffectSs_FindSlot(s32 priority, s32* pIndex) { return 0; } -void EffectSs_Insert(GlobalContext* globalCtx, EffectSs* effectSs) { +void EffectSs_Insert(PlayState* play, EffectSs* effectSs) { s32 index; - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(play) != true) { if (EffectSs_FindSlot(effectSs->priority, &index) == 0) { sEffectSsInfo.searchStartIndex = index + 1; sEffectSsInfo.table[index] = *effectSs; @@ -167,7 +167,7 @@ void EffectSs_Insert(GlobalContext* globalCtx, EffectSs* effectSs) { } // original name: "EffectSoftSprite2_makeEffect" -void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initParams) { +void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams) { s32 index; u32 overlaySize; EffectSsOverlay* overlayEntry; @@ -237,7 +237,7 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init sEffectSsInfo.table[index].priority = priority; sEffectSsInfo.table[index].epoch++; - if (initInfo->init(globalCtx, index, &sEffectSsInfo.table[index], initParams) == 0) { + if (initInfo->init(play, index, &sEffectSsInfo.table[index], initParams) == 0) { osSyncPrintf(VT_FGCOL(GREEN)); // "Construction failed for some reason. The constructor returned an error. // Ceasing effect addition." @@ -249,7 +249,7 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init } } -void EffectSs_Update(GlobalContext* globalCtx, s32 index) { +void EffectSs_Update(PlayState* play, s32 index) { EffectSs* effectSs = &sEffectSsInfo.table[index]; if (effectSs->update != NULL) { @@ -261,11 +261,11 @@ void EffectSs_Update(GlobalContext* globalCtx, s32 index) { effectSs->pos.y += effectSs->velocity.y; effectSs->pos.z += effectSs->velocity.z; - effectSs->update(globalCtx, index, effectSs); + effectSs->update(play, index, effectSs); } } -void EffectSs_UpdateAll(GlobalContext* globalCtx) { +void EffectSs_UpdateAll(PlayState* play) { s32 i; for (i = 0; i < sEffectSsInfo.tableSize; i++) { @@ -278,28 +278,28 @@ void EffectSs_UpdateAll(GlobalContext* globalCtx) { } if (sEffectSsInfo.table[i].life > -1) { - EffectSs_Update(globalCtx, i); + EffectSs_Update(play, i); } } } -void EffectSs_Draw(GlobalContext* globalCtx, s32 index) { +void EffectSs_Draw(PlayState* play, s32 index) { EffectSs* effectSs = &sEffectSsInfo.table[index]; if (effectSs->draw != NULL) { FrameInterpolation_RecordOpenChild(effectSs, effectSs->epoch); - effectSs->draw(globalCtx, index, effectSs); + effectSs->draw(play, index, effectSs); FrameInterpolation_RecordCloseChild(); } } // original name: "EffectSoftSprite2_disp" -void EffectSs_DrawAll(GlobalContext* globalCtx) { - Lights* lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx); +void EffectSs_DrawAll(PlayState* play) { + Lights* lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx); s32 i; - Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL); - Lights_Draw(lights, globalCtx->state.gfxCtx); + Lights_BindAll(lights, play->lightCtx.listHead, NULL); + Lights_Draw(lights, play->state.gfxCtx); for (i = 0; i < sEffectSsInfo.tableSize; i++) { if (sEffectSsInfo.table[i].life > -1) { @@ -322,7 +322,7 @@ void EffectSs_DrawAll(GlobalContext* globalCtx) { EffectSs_Delete(&sEffectSsInfo.table[i]); } else { - EffectSs_Draw(globalCtx, i); + EffectSs_Draw(play, i); } } } diff --git a/soh/src/code/z_effect_soft_sprite_old_init.c b/soh/src/code/z_effect_soft_sprite_old_init.c index e3efdffaa..965e3a1f9 100644 --- a/soh/src/code/z_effect_soft_sprite_old_init.c +++ b/soh/src/code/z_effect_soft_sprite_old_init.c @@ -40,8 +40,8 @@ static Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; // effects that use this draw function are responsible for making sure their regs line up with the usage here -void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* texture) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) { + GraphicsContext* gfxCtx = play->state.gfxCtx; f32 scale; MtxF mfTrans; MtxF mfScale; @@ -49,14 +49,14 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur MtxF mfTrans11DA0; s32 pad1; Mtx* mtx; - void* object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment; + void* object = play->objectCtx.status[this->rgObjBankIdx].segment; OPEN_DISPS(gfxCtx); scale = this->rgScale * 0.0025f; SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z); SkinMatrix_SetScale(&mfScale, scale, scale, scale); - SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0); + SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0); SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult); gSegments[6] = VIRTUAL_TO_PHYSICAL(object); gSPSegment(POLY_XLU_DISP++, 0x06, object); @@ -78,7 +78,7 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur // EffectSsDust Spawn Functions -void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsDust_Spawn(PlayState* play, u16 drawFlags, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life, u8 updateMode) { EffectSsDustInitParams initParams; @@ -94,86 +94,86 @@ void EffectSsDust_Spawn(GlobalContext* globalCtx, u16 drawFlags, Vec3f* pos, Vec initParams.life = life; initParams.updateMode = updateMode; - EffectSs_Spawn(globalCtx, EFFECT_SS_DUST, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DUST, 128, &initParams); } -void func_8002829C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_8002829C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); } -void func_80028304(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_80028304(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); + EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 0); } -void func_8002836C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_8002836C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); } -void func_800283D4(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800283D4(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); } -void func_8002843C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_8002843C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 2, pos, velocity, accel, primColor, envColor, scale, scaleStep, life, 0); } // unused -void func_800284A4(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_800284A4(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); + EffectSsDust_Spawn(play, 0, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); } // unused -void func_80028510(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_80028510(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); + EffectSsDust_Spawn(play, 1, pos, velocity, accel, primColor, envColor, scale, scaleStep, 10, 1); } static Color_RGBA8 sDustBrownPrim = { 170, 130, 90, 255 }; static Color_RGBA8 sDustBrownEnv = { 100, 60, 20, 255 }; -void func_8002857C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); +void func_8002857C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } // unused -void func_800285EC(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); +void func_800285EC(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { + EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0); } -void func_8002865C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); +void func_8002865C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { + EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } -void func_800286CC(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); +void func_800286CC(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { + EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, 10, 0); } -void func_8002873C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void func_8002873C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } -void func_800287AC(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void func_800287AC(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); + EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); } // unused -void func_8002881C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_8002881C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - func_8002829C(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5); + func_8002829C(play, pos, velocity, accel, primColor, envColor, 100, 5); } // unused -void func_80028858(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void func_80028858(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - func_80028304(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5); + func_80028304(play, pos, velocity, accel, primColor, envColor, 100, 5); } void func_80028894(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel) { @@ -196,7 +196,7 @@ void func_80028894(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, accel->z = 0.0f; } -void func_80028990(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { +void func_80028990(PlayState* play, f32 randScale, Vec3f* srcPos) { s32 i; Vec3f pos; Vec3f velocity; @@ -204,11 +204,11 @@ void func_80028990(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { for (i = 0; i < 20; i++) { func_80028894(srcPos, randScale, &pos, &velocity, &accel); - func_8002873C(globalCtx, &pos, &velocity, &accel, 100, 30, 7); + func_8002873C(play, &pos, &velocity, &accel, 100, 30, 7); } } -void func_80028A54(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { +void func_80028A54(PlayState* play, f32 randScale, Vec3f* srcPos) { s32 i; Vec3f pos; Vec3f velocity; @@ -216,25 +216,25 @@ void func_80028A54(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) { for (i = 0; i < 20; i++) { func_80028894(srcPos, randScale, &pos, &velocity, &accel); - func_800287AC(globalCtx, &pos, &velocity, &accel, 100, 30, 7); + func_800287AC(play, &pos, &velocity, &accel, 100, 30, 7); } } // EffectSsKiraKira Spawn Functions -void EffectSsKiraKira_SpawnSmallYellow(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsKiraKira_SpawnSmallYellow(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 primColor = { 255, 255, 200, 255 }; Color_RGBA8 envColor = { 255, 200, 0, 0 }; - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, &primColor, &envColor, 1000, 16); + EffectSsKiraKira_SpawnDispersed(play, pos, velocity, accel, &primColor, &envColor, 1000, 16); } -void EffectSsKiraKira_SpawnSmall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKiraKira_SpawnSmall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); + EffectSsKiraKira_SpawnDispersed(play, pos, velocity, accel, primColor, envColor, 1000, 16); } -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKiraKira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { EffectSsKiraKiraInitParams initParams; @@ -252,10 +252,10 @@ void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f initParams.envColor = *envColor; initParams.alphaStep = (-(255.0f / initParams.life)) + (-(255.0f / initParams.life)); - EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_KIRAKIRA, 128, &initParams); } -void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsKiraKira_SpawnFocused(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { EffectSsKiraKiraInitParams initParams; @@ -271,26 +271,26 @@ void EffectSsKiraKira_SpawnFocused(GlobalContext* globalCtx, Vec3f* pos, Vec3f* Color_RGBA8_Copy(&initParams.envColor, envColor); initParams.alphaStep = (-(255.0f / initParams.life)) + (-(255.0f / initParams.life)); - EffectSs_Spawn(globalCtx, EFFECT_SS_KIRAKIRA, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_KIRAKIRA, 128, &initParams); } // EffectSsBomb Spawn Functions // unused -void EffectSsBomb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsBomb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { EffectSsBombInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); - EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BOMB, 128, &initParams); } // EffectSsBomb2 Spawn Functions // unused -void EffectSsBomb2_SpawnFade(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsBomb2_SpawnFade(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { EffectSsBomb2InitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -300,10 +300,10 @@ void EffectSsBomb2_SpawnFade(GlobalContext* globalCtx, Vec3f* pos, Vec3f* veloci initParams.scaleStep = 0; initParams.drawMode = 0; - EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB2, 10, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BOMB2, 10, &initParams); } -void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { EffectSsBomb2InitParams initParams; @@ -314,12 +314,12 @@ void EffectSsBomb2_SpawnLayered(GlobalContext* globalCtx, Vec3f* pos, Vec3f* vel initParams.scaleStep = scaleStep; initParams.drawMode = 1; - EffectSs_Spawn(globalCtx, EFFECT_SS_BOMB2, 10, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BOMB2, 10, &initParams); } // EffectSsBlast Spawn Functions -void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, +void EffectSsBlast_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep, s16 sclaeStepDecay, s16 life) { EffectSsBlastParams initParams; @@ -333,32 +333,32 @@ void EffectSsBlast_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.sclaeStepDecay = sclaeStepDecay; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_BLAST, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BLAST, 128, &initParams); } -void EffectSsBlast_SpawnWhiteCustomScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsBlast_SpawnWhiteCustomScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { static Color_RGBA8 primColor = { 255, 255, 255, 255 }; static Color_RGBA8 envColor = { 200, 200, 200, 0 }; - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); + EffectSsBlast_Spawn(play, pos, velocity, accel, &primColor, &envColor, scale, scaleStep, 35, life); } -void EffectSsBlast_SpawnShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 life) { - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); + EffectSsBlast_Spawn(play, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); } -void EffectSsBlast_SpawnWhiteShockwave(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsBlast_SpawnWhiteShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { static Color_RGBA8 primColor = { 255, 255, 255, 255 }; static Color_RGBA8 envColor = { 200, 200, 200, 0 }; - EffectSsBlast_SpawnShockwave(globalCtx, pos, velocity, accel, &primColor, &envColor, 10); + EffectSsBlast_SpawnShockwave(play, pos, velocity, accel, &primColor, &envColor, 10); } // EffectSsGSpk Spawn Functions -void EffectSsGSpk_SpawnAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { EffectSsGSpkInitParams initParams; @@ -372,11 +372,11 @@ void EffectSsGSpk_SpawnAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, initParams.scaleStep = scaleStep; initParams.updateMode = 0; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams); } // unused -void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnNoAccel(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 scaleStep) { EffectSsGSpkInitParams initParams; @@ -390,18 +390,18 @@ void EffectSsGSpk_SpawnNoAccel(GlobalContext* globalCtx, Actor* actor, Vec3f* po initParams.scaleStep = scaleStep; initParams.updateMode = 1; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_SPK, 128, &initParams); } -void EffectSsGSpk_SpawnFuse(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { +void EffectSsGSpk_SpawnFuse(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel) { Color_RGBA8 primColor = { 255, 255, 150, 255 }; Color_RGBA8 envColor = { 255, 0, 0, 0 }; - EffectSsGSpk_SpawnSmall(globalCtx, actor, pos, velocity, accel, &primColor, &envColor); + EffectSsGSpk_SpawnSmall(play, actor, pos, velocity, accel, &primColor, &envColor); } // unused -void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnRandColor(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { Color_RGBA8 primColor = { 255, 255, 150, 255 }; Color_RGBA8 envColor = { 255, 0, 0, 0 }; @@ -416,17 +416,17 @@ void EffectSsGSpk_SpawnRandColor(GlobalContext* globalCtx, Actor* actor, Vec3f* envColor.b += randOffset; envColor.a += randOffset; - EffectSsGSpk_SpawnAccel(globalCtx, actor, pos, velocity, accel, &primColor, &envColor, scale, scaleStep); + EffectSsGSpk_SpawnAccel(play, actor, pos, velocity, accel, &primColor, &envColor, scale, scaleStep); } -void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsGSpk_SpawnSmall(PlayState* play, Actor* actor, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsGSpk_SpawnAccel(globalCtx, actor, pos, velocity, accel, primColor, envColor, 100, 5); + EffectSsGSpk_SpawnAccel(play, actor, pos, velocity, accel, primColor, envColor, 100, 5); } // EffectSsDFire Spawn Functions -void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void EffectSsDFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s16 fadeDelay, s32 life) { EffectSsDFireInitParams initParams; @@ -439,17 +439,17 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.fadeDelay = fadeDelay; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_D_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_D_FIRE, 128, &initParams); } -void EffectSsDFire_SpawnFixedScale(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 alpha, +void EffectSsDFire_SpawnFixedScale(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 alpha, s16 fadeDelay) { - EffectSsDFire_Spawn(globalCtx, pos, velocity, accel, 100, 35, alpha, fadeDelay, 8); + EffectSsDFire_Spawn(play, pos, velocity, accel, 100, 35, alpha, fadeDelay, 8); } // EffectSsBubble Spawn Functions -void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, +void EffectSsBubble_Spawn(PlayState* play, Vec3f* pos, f32 yPosOffset, f32 yPosRandScale, f32 xzPosRandScale, f32 scale) { EffectSsBubbleInitParams initParams; @@ -459,12 +459,12 @@ void EffectSsBubble_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 yPosOffset, initParams.xzPosRandScale = xzPosRandScale; initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_BUBBLE, 128, &initParams); } // EffectSsGRipple Spawn Functions -void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 radiusMax, s16 life) { +void EffectSsGRipple_Spawn(PlayState* play, Vec3f* pos, s16 radius, s16 radiusMax, s16 life) { EffectSsGRippleInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -472,12 +472,12 @@ void EffectSsGRipple_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 radius, s16 initParams.radiusMax = radiusMax; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_RIPPLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_RIPPLE, 128, &initParams); } // EffectSsGSplash Spawn Functions -void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, +void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 scale) { EffectSsGSplashInitParams initParams; @@ -493,32 +493,32 @@ void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* pr initParams.customColor = false; } - EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPLASH, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_SPLASH, 128, &initParams); } // EffectSsGMagma Spawn Functions -void EffectSsGMagma_Spawn(GlobalContext* globalCtx, Vec3f* pos) { +void EffectSsGMagma_Spawn(PlayState* play, Vec3f* pos) { EffectSsGMagmaInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); - EffectSs_Spawn(globalCtx, EFFECT_SS_G_MAGMA, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_MAGMA, 128, &initParams); } // EffectSsGFire Spawn Functions -void EffectSsGFire_Spawn(GlobalContext* globalCtx, Vec3f* pos) { +void EffectSsGFire_Spawn(PlayState* play, Vec3f* pos) { EffectSsGFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); - EffectSs_Spawn(globalCtx, EFFECT_SS_G_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_FIRE, 128, &initParams); } // EffectSsLightning Spawn Functions -void EffectSsLightning_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, +void EffectSsLightning_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 yaw, s16 life, s16 numBolts) { EffectSsLightningInitParams initParams; @@ -530,12 +530,12 @@ void EffectSsLightning_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* initParams.life = life; initParams.numBolts = numBolts; - EffectSs_Spawn(globalCtx, EFFECT_SS_LIGHTNING, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_LIGHTNING, 128, &initParams); } // EffectSsDtBubble Spawn Functions -void EffectSsDtBubble_SpawnColorProfile(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsDtBubble_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 life, s16 colorProfile, s16 randXZ) { EffectSsDtBubbleInitParams initParams; @@ -548,10 +548,10 @@ void EffectSsDtBubble_SpawnColorProfile(GlobalContext* globalCtx, Vec3f* pos, Ve initParams.life = life; initParams.randXZ = randXZ; - EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams); } -void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, +void EffectSsDtBubble_SpawnCustomColor(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s16 life, s16 randXZ) { EffectSsDtBubbleInitParams initParams; @@ -565,7 +565,7 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec initParams.randXZ = randXZ; initParams.customColor = true; - EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams); } // EffectSsHahen Spawn Functions @@ -579,7 +579,7 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames */ -void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, +void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, s16 life, Gfx* dList) { EffectSsHahenInitParams initParams; @@ -592,7 +592,7 @@ void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.objId = objId; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_HAHEN, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_HAHEN, 128, &initParams); } /** @@ -604,7 +604,7 @@ void EffectSsHahen_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, * - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will * only live for 200 frames */ -void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, +void EffectSsHahen_SpawnBurst(PlayState* play, Vec3f* pos, f32 burstScale, s16 unused, s16 scale, s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList) { s32 i; Vec3f velocity; @@ -618,7 +618,7 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca velocity.z = (Rand_ZeroOne() - 0.5f) * burstScale; velocity.y = ((Rand_ZeroOne() * 0.5f) + 0.5f) * burstScale; - EffectSsHahen_Spawn(globalCtx, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId, + EffectSsHahen_Spawn(play, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId, life, dList); } } @@ -629,18 +629,18 @@ void EffectSsHahen_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos, f32 burstSca * As child, spawn a broken stick fragment * As adult, spawn a broken sword fragment */ -void EffectSsStick_Spawn(GlobalContext* globalCtx, Vec3f* pos, s16 yaw) { +void EffectSsStick_Spawn(PlayState* play, Vec3f* pos, s16 yaw) { EffectSsStickInitParams initParams; initParams.pos = *pos; initParams.yaw = yaw; - EffectSs_Spawn(globalCtx, EFFECT_SS_STICK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_STICK, 128, &initParams); } // EffectSsSibuki Spawn Functions -void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay, +void EffectSsSibuki_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay, s16 direction, s16 scale) { EffectSsSibukiInitParams initParams; @@ -651,10 +651,10 @@ void EffectSsSibuki_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.direction = direction; initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_SIBUKI, 128, &initParams); } -void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { +void EffectSsSibuki_SpawnBurst(PlayState* play, Vec3f* pos) { s16 i; Vec3f unusedZeroVec1 = { 0.0f, 0.0f, 0.0f }; Vec3f unusedZeroVec2 = { 0.0f, 0.0f, 0.0f }; @@ -662,26 +662,26 @@ void EffectSsSibuki_SpawnBurst(GlobalContext* globalCtx, Vec3f* pos) { s16 randDirection = Rand_ZeroOne() * 1.99f; for (i = 0; i < KREG(19) + 30; i++) { - EffectSsSibuki_Spawn(globalCtx, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40); + EffectSsSibuki_Spawn(play, pos, &zeroVec, &zeroVec, i / (KREG(27) + 6), randDirection, KREG(18) + 40); } } // EffectSsSibuki2 Spawn Functions // unused -void EffectSsSibuki2_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { +void EffectSsSibuki2_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { EffectSsSibuki2InitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); Math_Vec3f_Copy(&initParams.velocity, velocity); Math_Vec3f_Copy(&initParams.accel, accel); initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_SIBUKI2, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_SIBUKI2, 128, &initParams); } // EffectSsGMagma2 Spawn Functions -void EffectSsGMagma2_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, +void EffectSsGMagma2_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 updateRate, s16 drawMode, s16 scale) { EffectSsGMagma2InitParams initParams; @@ -692,38 +692,38 @@ void EffectSsGMagma2_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* pr initParams.drawMode = drawMode; initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_G_MAGMA2, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_G_MAGMA2, 128, &initParams); } // EffectSsStone1 Spawn Functions -void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 arg2) { +void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 arg2) { EffectSsStone1InitParams initParams; initParams.pos = *pos; initParams.unk_C = arg2; - EffectSs_Spawn(globalCtx, EFFECT_SS_STONE1, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_STONE1, 128, &initParams); } // EffectSsHitMark Spawn Functions -void EffectSsHitMark_Spawn(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos) { +void EffectSsHitMark_Spawn(PlayState* play, s32 type, s16 scale, Vec3f* pos) { EffectSsHitMarkInitParams initParams; initParams.type = type; initParams.scale = scale; Math_Vec3f_Copy(&initParams.pos, pos); - EffectSs_Spawn(globalCtx, EFFECT_SS_HITMARK, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_HITMARK, 128, &initParams); } -void EffectSsHitMark_SpawnFixedScale(GlobalContext* globalCtx, s32 type, Vec3f* pos) { - EffectSsHitMark_Spawn(globalCtx, type, 300, pos); +void EffectSsHitMark_SpawnFixedScale(PlayState* play, s32 type, Vec3f* pos) { + EffectSsHitMark_Spawn(play, type, 300, pos); } -void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 scale, Vec3f* pos) { - EffectSsHitMark_Spawn(globalCtx, type, scale, pos); +void EffectSsHitMark_SpawnCustomScale(PlayState* play, s32 type, s16 scale, Vec3f* pos) { + EffectSsHitMark_Spawn(play, type, scale, pos); } // EffectSsFhgFlash Spawn Functions @@ -734,7 +734,7 @@ void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 sc * param changes the color of the ball. Refer to FhgFlashLightBallParam for the options. * Note: this type requires OBJECT_FHG to be loaded */ -void EffectSsFhgFlash_SpawnLightBall(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, +void EffectSsFhgFlash_SpawnLightBall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, u8 param) { EffectSsFhgFlashInitParams initParams; @@ -745,7 +745,7 @@ void EffectSsFhgFlash_SpawnLightBall(GlobalContext* globalCtx, Vec3f* pos, Vec3f initParams.param = param; initParams.type = FHGFLASH_LIGHTBALL; - EffectSs_Spawn(globalCtx, EFFECT_SS_FHG_FLASH, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_FHG_FLASH, 128, &initParams); } /** @@ -756,7 +756,7 @@ void EffectSsFhgFlash_SpawnLightBall(GlobalContext* globalCtx, Vec3f* pos, Vec3f * 1: spawn at one of Player's body parts, chosen at random * 2: spawn at one of Phantom Ganon's body parts, chosen at random */ -void EffectSsFhgFlash_SpawnShock(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, u8 param) { +void EffectSsFhgFlash_SpawnShock(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, u8 param) { EffectSsFhgFlashInitParams initParams; initParams.actor = actor; @@ -765,12 +765,12 @@ void EffectSsFhgFlash_SpawnShock(GlobalContext* globalCtx, Actor* actor, Vec3f* initParams.param = param; initParams.type = FHGFLASH_SHOCK; - EffectSs_Spawn(globalCtx, EFFECT_SS_FHG_FLASH, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_FHG_FLASH, 128, &initParams); } // EffectSsKFire Spawn Functions -void EffectSsKFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type) { +void EffectSsKFire_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scaleMax, u8 type) { EffectSsKFireInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -779,12 +779,12 @@ void EffectSsKFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scaleMax = scaleMax; initParams.type = type; - EffectSs_Spawn(globalCtx, EFFECT_SS_K_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_K_FIRE, 128, &initParams); } // EffectSsSolderSrchBall Spawn Functions -void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, +void EffectSsSolderSrchBall_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16* linkDetected) { EffectSsSolderSrchBallInitParams initParams; @@ -794,12 +794,12 @@ void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v initParams.unused = unused; initParams.linkDetected = linkDetected; - EffectSs_Spawn(globalCtx, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_SOLDER_SRCH_BALL, 128, &initParams); } // EffectSsKakera Spawn Functions -void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, +void EffectSsKakera_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* arg3, s16 gravity, s16 arg5, s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, s16 objId, Gfx* dList) { EffectSsKakeraInitParams initParams; @@ -820,12 +820,12 @@ void EffectSsKakera_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.objId = objId; initParams.dList = dList; - EffectSs_Spawn(globalCtx, EFFECT_SS_KAKERA, 101, &initParams); + EffectSs_Spawn(play, EFFECT_SS_KAKERA, 101, &initParams); } // EffectSsIcePiece Spawn Functions -void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, s32 life) { +void EffectSsIcePiece_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, s32 life) { EffectSsIcePieceInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -833,10 +833,10 @@ void EffectSsIcePiece_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec Math_Vec3f_Copy(&initParams.accel, accel); initParams.scale = scale; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_PIECE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_ICE_PIECE, 128, &initParams); } -void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 scale) { +void EffectSsIcePiece_SpawnBurst(PlayState* play, Vec3f* refPos, f32 scale) { static Vec3f accel = { 0.0f, 0.0f, 0.0f }; static Vec3f vecScales[] = { { 0.0f, 70.0f, 0.0f }, @@ -867,14 +867,14 @@ void EffectSsIcePiece_SpawnBurst(GlobalContext* globalCtx, Vec3f* refPos, f32 sc pos.y += vecScales[i].y; pos.z += vecScales[i].z; - EffectSsIcePiece_Spawn(globalCtx, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity, + EffectSsIcePiece_Spawn(play, &pos, (Rand_ZeroFloat(1.0f) + 0.5f) * ((scale * 1.3f) * 100.0f), &velocity, &accel, 25); } } // EffectSsEnIce Spawn Functions -void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 primR, s16 primG, s16 primB, +void EffectSsEnIce_SpawnFlyingVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 primR, s16 primG, s16 primB, s16 primA, s16 envR, s16 envG, s16 envB, f32 scale) { EffectSsEnIceInitParams initParams; @@ -895,10 +895,10 @@ void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3 Audio_PlayActorSound2(actor, NA_SE_PL_FREEZE_S); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 80, &initParams); } -void EffectSsEnIce_SpawnFlyingVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* pos, s16 primR, s16 primG, s16 primB, +void EffectSsEnIce_SpawnFlyingVec3s(PlayState* play, Actor* actor, Vec3s* pos, s16 primR, s16 primG, s16 primB, s16 primA, s16 envR, s16 envG, s16 envB, f32 scale) { EffectSsEnIceInitParams initParams; @@ -921,10 +921,10 @@ void EffectSsEnIce_SpawnFlyingVec3s(GlobalContext* globalCtx, Actor* actor, Vec3 Audio_PlayActorSound2(actor, NA_SE_PL_FREEZE_S); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 80, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 80, &initParams); } -void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, +void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life) { EffectSsEnIceInitParams initParams; @@ -937,12 +937,12 @@ void EffectSsEnIce_Spawn(GlobalContext* globalCtx, Vec3f* pos, f32 scale, Vec3f* initParams.life = life; initParams.type = 1; - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_ICE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_ICE, 128, &initParams); } // EffectSsFireTail Spawn Functions -void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale, Vec3f* arg4, s16 arg5, +void EffectSsFireTail_Spawn(PlayState* play, Actor* actor, Vec3f* pos, f32 scale, Vec3f* arg4, s16 arg5, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, s16 bodyPart, s32 life) { EffectSsFireTailInitParams initParams; @@ -957,10 +957,10 @@ void EffectSsFireTail_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, initParams.bodyPart = bodyPart; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_FIRE_TAIL, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_FIRE_TAIL, 128, &initParams); } -void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, +void EffectSsFireTail_SpawnFlame(PlayState* play, Actor* actor, Vec3f* pos, f32 arg3, s16 bodyPart, f32 colorIntensity) { static Color_RGBA8 primColor = { 255, 255, 0, 255 }; static Color_RGBA8 envColor = { 255, 0, 0, 255 }; @@ -972,21 +972,21 @@ void EffectSsFireTail_SpawnFlame(GlobalContext* globalCtx, Actor* actor, Vec3f* envColor.b = 0; primColor.r = envColor.r = (s32)(255.0f * colorIntensity); - EffectSsFireTail_Spawn(globalCtx, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor, + EffectSsFireTail_Spawn(play, actor, pos, arg3, &actor->velocity, 15, &primColor, &envColor, (colorIntensity == 1.0f) ? 0 : 1, bodyPart, 1); } -void EffectSsFireTail_SpawnFlameOnPlayer(GlobalContext* globalCtx, f32 scale, s16 bodyPart, f32 colorIntensity) { - Player* player = GET_PLAYER(globalCtx); +void EffectSsFireTail_SpawnFlameOnPlayer(PlayState* play, f32 scale, s16 bodyPart, f32 colorIntensity) { + Player* player = GET_PLAYER(play); - EffectSsFireTail_SpawnFlame(globalCtx, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart, + EffectSsFireTail_SpawnFlame(play, &player->actor, &player->bodyPartsPos[bodyPart], scale, bodyPart, colorIntensity); } // EffectSsEnFire Spawn Functions // note: if bodyPart is greater than -1 the actor MUST have a table of Vec3f positions at offset 0x14C in the instance -void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, +void EffectSsEnFire_SpawnVec3f(PlayState* play, Actor* actor, Vec3f* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart) { EffectSsEnFireInitParams initParams; @@ -1001,11 +1001,11 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po Audio_PlayActorSound2(actor, NA_SE_EV_FLAME_IGNITION); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams); } // note: if bodyPart is greater than -1 the actor MUST have a table of Vec3s positions at offset 0x14C in the instance -void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* pos, s16 scale, s16 arg4, s16 flags, +void EffectSsEnFire_SpawnVec3s(PlayState* play, Actor* actor, Vec3s* pos, s16 scale, s16 arg4, s16 flags, s16 bodyPart) { EffectSsEnFireInitParams initParams; @@ -1022,12 +1022,12 @@ void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* po Audio_PlayActorSound2(actor, NA_SE_EV_FLAME_IGNITION); } - EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams); } // EffectSsExtra Spawn Functions -void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx) { +void EffectSsExtra_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scoreIdx) { EffectSsExtraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -1036,12 +1036,12 @@ void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scale = scale; initParams.scoreIdx = scoreIdx; - EffectSs_Spawn(globalCtx, EFFECT_SS_EXTRA, 100, &initParams); + EffectSs_Spawn(play, EFFECT_SS_EXTRA, 100, &initParams); } // EffectSsFCircle Spawn Functions -void EffectSsFCircle_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s16 radius, s16 height) { +void EffectSsFCircle_Spawn(PlayState* play, Actor* actor, Vec3f* pos, s16 radius, s16 height) { EffectSsFcircleInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -1049,12 +1049,12 @@ void EffectSsFCircle_Spawn(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s initParams.radius = radius; initParams.height = height; - EffectSs_Spawn(globalCtx, EFFECT_SS_FCIRCLE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_FCIRCLE, 128, &initParams); } // EffectSsDeadDb Spawn Functions -void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 primR, s16 primG, s16 primB, s16 primA, s16 envR, s16 envG, s16 envB, s16 unused, s32 arg14, s16 playSound) { EffectSsDeadDbInitParams initParams; @@ -1075,12 +1075,12 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.unk_34 = arg14; initParams.playSound = playSound; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DB, 120, &initParams); } // EffectSsDeadDd Spawn Functions -void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void EffectSsDeadDd_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 primR, s16 primG, s16 primB, s16 alpha, s16 envR, s16 envG, s16 envB, s16 alphaStep, s32 life) { EffectSsDeadDdInitParams initParams; @@ -1101,11 +1101,11 @@ void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.alphaStep = alphaStep; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DD, 120, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DD, 120, &initParams); } // unused -void EffectSsDeadDd_SpawnRandYellow(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, f32 randPosScale, +void EffectSsDeadDd_SpawnRandYellow(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, f32 randPosScale, s32 randIter, s32 life) { EffectSsDeadDdInitParams initParams; @@ -1117,12 +1117,12 @@ void EffectSsDeadDd_SpawnRandYellow(GlobalContext* globalCtx, Vec3f* pos, s16 sc initParams.life = life; initParams.type = 1; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DD, 120, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DD, 120, &initParams); } // EffectSsDeadDs Spawn Functions -void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, +void EffectSsDeadDs_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 alpha, s32 life) { EffectSsDeadDsInitParams initParams; @@ -1133,17 +1133,17 @@ void EffectSsDeadDs_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, initParams.scaleStep = scaleStep; initParams.alpha = alpha; initParams.life = life; - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DS, 100, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_DS, 100, &initParams); } -void EffectSsDeadDs_SpawnStationary(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, +void EffectSsDeadDs_SpawnStationary(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) { - EffectSsDeadDs_Spawn(globalCtx, pos, &sZeroVec, &sZeroVec, scale, scaleStep, alpha, life); + EffectSsDeadDs_Spawn(play, pos, &sZeroVec, &sZeroVec, scale, scaleStep, alpha, life); } // EffectSsDeadSound Spawn Functions -void EffectSsDeadSound_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u16 sfxId, +void EffectSsDeadSound_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u16 sfxId, s16 lowerPriority, s16 repeatMode, s32 life) { EffectSsDeadSoundInitParams initParams; @@ -1156,15 +1156,15 @@ void EffectSsDeadSound_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* veloci initParams.life = life; if (!lowerPriority) { - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_SOUND, 100, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_SOUND, 100, &initParams); } else { - EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_SOUND, 127, &initParams); + EffectSs_Spawn(play, EFFECT_SS_DEAD_SOUND, 127, &initParams); } } -void EffectSsDeadSound_SpawnStationary(GlobalContext* globalCtx, Vec3f* pos, u16 sfxId, s16 lowerPriority, +void EffectSsDeadSound_SpawnStationary(PlayState* play, Vec3f* pos, u16 sfxId, s16 lowerPriority, s16 repeatMode, s32 life) { - EffectSsDeadSound_Spawn(globalCtx, pos, &sZeroVec, &sZeroVec, sfxId, lowerPriority, repeatMode, life); + EffectSsDeadSound_Spawn(play, pos, &sZeroVec, &sZeroVec, sfxId, lowerPriority, repeatMode, life); } // EffectSsIceSmoke Spawn Functions @@ -1174,7 +1174,7 @@ void EffectSsDeadSound_SpawnStationary(GlobalContext* globalCtx, Vec3f* pos, u16 * * Note: this effect requires OBJECT_FZ to be loaded */ -void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { +void EffectSsIceSmoke_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) { EffectSsIceSmokeInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -1182,5 +1182,5 @@ void EffectSsIceSmoke_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocit Math_Vec3f_Copy(&initParams.accel, accel); initParams.scale = scale; - EffectSs_Spawn(globalCtx, EFFECT_SS_ICE_SMOKE, 128, &initParams); + EffectSs_Spawn(play, EFFECT_SS_ICE_SMOKE, 128, &initParams); } diff --git a/soh/src/code/z_elf_message.c b/soh/src/code/z_elf_message.c index 2e847f738..5bf7e9723 100644 --- a/soh/src/code/z_elf_message.c +++ b/soh/src/code/z_elf_message.c @@ -148,12 +148,12 @@ u16 ElfMessage_GetTextFromMsgs(ElfMessage* msg) { } } -u16 ElfMessage_GetSariaText(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +u16 ElfMessage_GetSariaText(PlayState* play) { + Player* player = GET_PLAYER(play); ElfMessage* msgs; if (!LINK_IS_ADULT) { - if (Actor_FindNearby(globalCtx, &player->actor, ACTOR_EN_SA, 4, 800.0f) == NULL) { + if (Actor_FindNearby(play, &player->actor, ACTOR_EN_SA, 4, 800.0f) == NULL) { msgs = sChildSariaMsgs; } else { return 0x0160; // Special text about Saria preferring to talk to you face-to-face @@ -165,10 +165,10 @@ u16 ElfMessage_GetSariaText(GlobalContext* globalCtx) { return ElfMessage_GetTextFromMsgs(msgs); } -u16 ElfMessage_GetCUpText(GlobalContext* globalCtx) { - if (globalCtx->cUpElfMsgs == NULL) { +u16 ElfMessage_GetCUpText(PlayState* play) { + if (play->cUpElfMsgs == NULL) { return 0; } else { - return ElfMessage_GetTextFromMsgs(globalCtx->cUpElfMsgs); + return ElfMessage_GetTextFromMsgs(play->cUpElfMsgs); } } diff --git a/soh/src/code/z_en_a_keep.c b/soh/src/code/z_en_a_keep.c index df9f76a1a..d340422ca 100644 --- a/soh/src/code/z_en_a_keep.c +++ b/soh/src/code/z_en_a_keep.c @@ -5,16 +5,16 @@ #define FLAGS ACTOR_FLAG_4 -void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx); -void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx); -void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnAObj_Init(Actor* thisx, PlayState* play); +void EnAObj_Destroy(Actor* thisx, PlayState* play); +void EnAObj_Update(Actor* thisx, PlayState* play); +void EnAObj_Draw(Actor* thisx, PlayState* play); -void EnAObj_WaitFinishedTalking(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_WaitTalk(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_BlockRot(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_BoulderFragment(EnAObj* this, GlobalContext* globalCtx); -void EnAObj_Block(EnAObj* this, GlobalContext* globalCtx); +void EnAObj_WaitFinishedTalking(EnAObj* this, PlayState* play); +void EnAObj_WaitTalk(EnAObj* this, PlayState* play); +void EnAObj_BlockRot(EnAObj* this, PlayState* play); +void EnAObj_BoulderFragment(EnAObj* this, PlayState* play); +void EnAObj_Block(EnAObj* this, PlayState* play); void EnAObj_SetupWaitTalk(EnAObj* this, s16 type); void EnAObj_SetupBlockRot(EnAObj* this, s16 type); @@ -84,7 +84,7 @@ void EnAObj_SetupAction(EnAObj* this, EnAObjActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Init(Actor* thisx, PlayState* play) { CollisionHeader* colHeader = NULL; s32 pad; EnAObj* this = (EnAObj*)thisx; @@ -131,13 +131,13 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { case A_OBJ_BLOCK_LARGE: case A_OBJ_BLOCK_HUGE: this->dyna.bgId = 1; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BG); + Actor_ChangeCategory(play, &play->actorCtx, thisx, ACTORCAT_BG); EnAObj_SetupBlock(this, thisx->params); break; case A_OBJ_BLOCK_SMALL_ROT: case A_OBJ_BLOCK_LARGE_ROT: this->dyna.bgId = 3; - Actor_ChangeCategory(globalCtx, &globalCtx->actorCtx, thisx, ACTORCAT_BG); + Actor_ChangeCategory(play, &play->actorCtx, thisx, ACTORCAT_BG); EnAObj_SetupBlockRot(this, thisx->params); break; case A_OBJ_UNKNOWN_6: @@ -160,8 +160,8 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { // clang-format on this->focusYoffset = 45.0f; EnAObj_SetupWaitTalk(this, thisx->params); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, thisx, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, thisx, &sCylinderInit); thisx->colChkInfo.mass = MASS_IMMOVABLE; thisx->targetMode = 0; break; @@ -181,25 +181,25 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { if (this->dyna.bgId != BGACTOR_NEG_ONE) { CollisionHeader_GetVirtual(sColHeaders[this->dyna.bgId], &colHeader); - this->dyna.bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, thisx, colHeader); + this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); } } -void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Destroy(Actor* thisx, PlayState* play) { EnAObj* this = (EnAObj*)thisx; - DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + DynaPoly_DeleteBgActor(play, &play->colCtx.dyna, this->dyna.bgId); switch (this->dyna.actor.params) { case A_OBJ_SIGNPOST_OBLONG: case A_OBJ_SIGNPOST_ARROW: - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); break; } } -void EnAObj_WaitFinishedTalking(EnAObj* this, GlobalContext* globalCtx) { - if (Actor_TextboxIsClosing(&this->dyna.actor, globalCtx)) { +void EnAObj_WaitFinishedTalking(EnAObj* this, PlayState* play) { + if (Actor_TextboxIsClosing(&this->dyna.actor, play)) { EnAObj_SetupWaitTalk(this, this->dyna.actor.params); } } @@ -208,17 +208,17 @@ void EnAObj_SetupWaitTalk(EnAObj* this, s16 type) { EnAObj_SetupAction(this, EnAObj_WaitTalk); } -void EnAObj_WaitTalk(EnAObj* this, GlobalContext* globalCtx) { +void EnAObj_WaitTalk(EnAObj* this, PlayState* play) { s16 relYawTowardsPlayer; if (this->dyna.actor.textId != 0) { relYawTowardsPlayer = this->dyna.actor.yawTowardsPlayer - this->dyna.actor.shape.rot.y; if (ABS(relYawTowardsPlayer) < 0x2800 || (this->dyna.actor.params == A_OBJ_SIGNPOST_ARROW && ABS(relYawTowardsPlayer) > 0x5800)) { - if (Actor_ProcessTalkRequest(&this->dyna.actor, globalCtx)) { + if (Actor_ProcessTalkRequest(&this->dyna.actor, play)) { EnAObj_SetupAction(this, EnAObj_WaitFinishedTalking); } else { - func_8002F2F4(&this->dyna.actor, globalCtx); + func_8002F2F4(&this->dyna.actor, play); } } } @@ -232,7 +232,7 @@ void EnAObj_SetupBlockRot(EnAObj* this, s16 type) { EnAObj_SetupAction(this, EnAObj_BlockRot); } -void EnAObj_BlockRot(EnAObj* this, GlobalContext* globalCtx) { +void EnAObj_BlockRot(EnAObj* this, PlayState* play) { if (this->rotateState == 0) { if (this->dyna.unk_160 != 0) { this->rotateState++; @@ -275,7 +275,7 @@ void EnAObj_SetupBoulderFragment(EnAObj* this, s16 type) { EnAObj_SetupAction(this, EnAObj_BoulderFragment); } -void EnAObj_BoulderFragment(EnAObj* this, GlobalContext* globalCtx) { +void EnAObj_BoulderFragment(EnAObj* this, PlayState* play) { Math_SmoothStepToF(&this->dyna.actor.speedXZ, 1.0f, 1.0f, 0.5f, 0.0f); this->dyna.actor.shape.rot.x += this->dyna.actor.world.rot.x >> 1; this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z >> 1; @@ -303,7 +303,7 @@ void EnAObj_SetupBlock(EnAObj* this, s16 type) { EnAObj_SetupAction(this, EnAObj_Block); } -void EnAObj_Block(EnAObj* this, GlobalContext* globalCtx) { +void EnAObj_Block(EnAObj* this, PlayState* play) { this->dyna.actor.speedXZ += this->dyna.unk_150; this->dyna.actor.world.rot.y = this->dyna.unk_158; this->dyna.actor.speedXZ = CLAMP(this->dyna.actor.speedXZ, -2.5f, 2.5f); @@ -318,17 +318,17 @@ void EnAObj_Block(EnAObj* this, GlobalContext* globalCtx) { this->dyna.unk_150 = 0.0f; } -void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Update(Actor* thisx, PlayState* play) { EnAObj* this = (EnAObj*)thisx; - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Actor_MoveForward(&this->dyna.actor); if (this->dyna.actor.gravity != 0.0f) { if (this->dyna.actor.params != A_OBJ_BOULDER_FRAGMENT) { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 5.0f, 40.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 5.0f, 40.0f, 0.0f, 0x1D); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 5.0f, 20.0f, 0.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 5.0f, 20.0f, 0.0f, 0x1D); } } @@ -339,17 +339,17 @@ void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) { case A_OBJ_SIGNPOST_OBLONG: case A_OBJ_SIGNPOST_ARROW: Collider_UpdateCylinder(&this->dyna.actor, &this->collider); - CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); break; } } -void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnAObj_Draw(Actor* thisx, PlayState* play) { s32 type = thisx->params; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); if (type >= A_OBJ_MAX) { type = A_OBJ_BOULDER_FRAGMENT; @@ -359,9 +359,9 @@ void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 1, 60, 60, 60, 50); } - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDLists[type]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/code/z_en_item00.c b/soh/src/code/z_en_item00.c index c6afc2535..8bdf4e3a6 100644 --- a/soh/src/code/z_en_item00.c +++ b/soh/src/code/z_en_item00.c @@ -5,20 +5,20 @@ #define FLAGS 0 -void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx); -void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx); +void EnItem00_Init(Actor* thisx, PlayState* play); +void EnItem00_Destroy(Actor* thisx, PlayState* play); +void EnItem00_Update(Actor* thisx, PlayState* play); +void EnItem00_Draw(Actor* thisx, PlayState* play); -void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx); -void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx); -void func_8001E304(EnItem00* this, GlobalContext* globalCtx); -void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx); +void func_8001DFC8(EnItem00* this, PlayState* play); +void func_8001E1C8(EnItem00* this, PlayState* play); +void func_8001E304(EnItem00* this, PlayState* play); +void func_8001E5C8(EnItem00* this, PlayState* play); -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx); -void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx); +void EnItem00_DrawRupee(EnItem00* this, PlayState* play); +void EnItem00_DrawCollectible(EnItem00* this, PlayState* play); +void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play); +void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play); const ActorInit En_Item00_InitVars = { ACTOR_EN_ITEM00, @@ -330,7 +330,7 @@ void EnItem00_SetupAction(EnItem00* this, EnItem00ActionFunc actionFunc) { this->actionFunc = actionFunc; } -void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Init(Actor* thisx, PlayState* play) { EnItem00* this = (EnItem00*)thisx; s32 pad; f32 yOffset = 980.0f; @@ -346,14 +346,14 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.params &= 0xFF; - if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) { + if (Flags_GetCollectible(play, this->collectibleFlag)) { Actor_Kill(&this->actor); return; } Actor_ProcessInitChain(&this->actor, sInitChain); - Collider_InitCylinder(globalCtx, &this->collider); - Collider_SetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit); + Collider_InitCylinder(play, &this->collider); + Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); this->unk_158 = 1; @@ -397,8 +397,8 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->scale = 0.01f; break; case ITEM00_SHIELD_DEKU: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_1); - Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_1); + Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->scale = 0.5f; yOffset = 0.0f; @@ -406,8 +406,8 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.rot.x = 0x4000; break; case ITEM00_SHIELD_HYLIAN: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2); - Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2); + Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->scale = 0.5f; yOffset = 0.0f; @@ -416,8 +416,8 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { break; case ITEM00_TUNIC_ZORA: case ITEM00_TUNIC_GORON: - this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_CLOTHES); - Actor_SetObjectDependency(globalCtx, &this->actor); + this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_CLOTHES); + Actor_SetObjectDependency(play, &this->actor); Actor_SetScale(&this->actor, 0.5f); this->scale = 0.5f; yOffset = 0.0f; @@ -432,7 +432,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { this->actor.focus.pos = this->actor.world.pos; this->getItemId = GI_NONE; RandomizerCheck randoCheck = - Randomizer_GetCheckFromActor(this->actor.id, globalCtx->sceneNum, this->ogParams); + Randomizer_GetCheckFromActor(this->actor.id, play->sceneNum, this->ogParams); if (gSaveContext.n64ddFlag && randoCheck != RC_UNKNOWN_CHECK) { this->randoGiEntry = @@ -455,41 +455,41 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { switch (this->actor.params) { case ITEM00_RUPEE_GREEN: - Item_Give(globalCtx, ITEM_RUPEE_GREEN); + Item_Give(play, ITEM_RUPEE_GREEN); break; case ITEM00_RUPEE_BLUE: - Item_Give(globalCtx, ITEM_RUPEE_BLUE); + Item_Give(play, ITEM_RUPEE_BLUE); break; case ITEM00_RUPEE_RED: - Item_Give(globalCtx, ITEM_RUPEE_RED); + Item_Give(play, ITEM_RUPEE_RED); break; case ITEM00_RUPEE_PURPLE: - Item_Give(globalCtx, ITEM_RUPEE_PURPLE); + Item_Give(play, ITEM_RUPEE_PURPLE); break; case ITEM00_RUPEE_ORANGE: - Item_Give(globalCtx, ITEM_RUPEE_GOLD); + Item_Give(play, ITEM_RUPEE_GOLD); break; case ITEM00_HEART: - Item_Give(globalCtx, ITEM_HEART); + Item_Give(play, ITEM_HEART); break; case ITEM00_FLEXIBLE: - Health_ChangeBy(globalCtx, 0x70); + Health_ChangeBy(play, 0x70); break; case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: - Item_Give(globalCtx, ITEM_BOMBS_5); + Item_Give(play, ITEM_BOMBS_5); break; case ITEM00_ARROWS_SINGLE: - Item_Give(globalCtx, ITEM_BOW); + Item_Give(play, ITEM_BOW); break; case ITEM00_ARROWS_SMALL: - Item_Give(globalCtx, ITEM_ARROWS_SMALL); + Item_Give(play, ITEM_ARROWS_SMALL); break; case ITEM00_ARROWS_MEDIUM: - Item_Give(globalCtx, ITEM_ARROWS_MEDIUM); + Item_Give(play, ITEM_ARROWS_MEDIUM); break; case ITEM00_ARROWS_LARGE: - Item_Give(globalCtx, ITEM_ARROWS_LARGE); + Item_Give(play, ITEM_ARROWS_LARGE); break; case ITEM00_MAGIC_LARGE: getItemId = GI_MAGIC_SMALL; @@ -498,7 +498,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { getItemId = GI_MAGIC_LARGE; break; case ITEM00_SMALL_KEY: - Item_Give(globalCtx, ITEM_KEY_SMALL); + Item_Give(play, ITEM_KEY_SMALL); break; case ITEM00_SEEDS: getItemId = GI_SEEDS_5; @@ -518,31 +518,31 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_BOMBS_SPECIAL: break; case ITEM00_BOMBCHU: - Item_Give(globalCtx, ITEM_BOMBCHUS_5); + Item_Give(play, ITEM_BOMBCHUS_5); break; } - if (!Actor_HasParent(&this->actor, globalCtx)) { + if (!Actor_HasParent(&this->actor, play)) { if (getItemId != GI_NONE) { if (!gSaveContext.n64ddFlag || this->randoGiEntry.getItemId == GI_NONE) { - func_8002F554(&this->actor, globalCtx, getItemId); + func_8002F554(&this->actor, play, getItemId); } else { - GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, this->randoGiEntry); + GiveItemEntryFromActorWithFixedRange(&this->actor, play, this->randoGiEntry); } } } EnItem00_SetupAction(this, func_8001E5C8); - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); } -void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Destroy(Actor* thisx, PlayState* play) { EnItem00* this = (EnItem00*)thisx; - Collider_DestroyCylinder(globalCtx, &this->collider); + Collider_DestroyCylinder(play, &this->collider); } -void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) { +void func_8001DFC8(EnItem00* this, PlayState* play) { if (!CVar_GetS32("gNewDrops", 0)){ if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk_15A < 0)) || @@ -601,7 +601,7 @@ void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) { } } -void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) { +void func_8001E1C8(EnItem00* this, PlayState* play) { f32 originalVelocity; Vec3f effectPos; @@ -609,11 +609,11 @@ void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) { this->actor.shape.rot.y += 960; } - if (globalCtx->gameplayFrames & 1) { + if (play->gameplayFrames & 1) { effectPos.x = this->actor.world.pos.x + Rand_CenteredFloat(10.0f); effectPos.y = this->actor.world.pos.y + Rand_CenteredFloat(10.0f); effectPos.z = this->actor.world.pos.z + Rand_CenteredFloat(10.0f); - EffectSsKiraKira_SpawnSmall(globalCtx, &effectPos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, + EffectSsKiraKira_SpawnSmall(play, &effectPos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } @@ -629,7 +629,7 @@ void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) { } } -void func_8001E304(EnItem00* this, GlobalContext* globalCtx) { +void func_8001E304(EnItem00* this, PlayState* play) { s32 pad; Vec3f pos; s32 rotOffset; @@ -669,11 +669,11 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) { } } - if (!(globalCtx->gameplayFrames & 1)) { + if (!(play->gameplayFrames & 1)) { pos.x = this->actor.world.pos.x + (Rand_ZeroOne() - 0.5f) * 10.0f; pos.y = this->actor.world.pos.y + (Rand_ZeroOne() - 0.5f) * 10.0f; pos.z = this->actor.world.pos.z + (Rand_ZeroOne() - 0.5f) * 10.0f; - EffectSsKiraKira_SpawnSmall(globalCtx, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, + EffectSsKiraKira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } @@ -685,14 +685,14 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) { } } -void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void func_8001E5C8(EnItem00* this, PlayState* play) { + Player* player = GET_PLAYER(play); if (this->getItemId != GI_NONE) { - if (!Actor_HasParent(&this->actor, globalCtx)) { + if (!Actor_HasParent(&this->actor, play)) { if (!gSaveContext.n64ddFlag) { - func_8002F434(&this->actor, globalCtx, this->getItemId, 50.0f, 80.0f); + func_8002F434(&this->actor, play, this->getItemId, 50.0f, 80.0f); } else { - GiveItemEntryFromActor(&this->actor, globalCtx, this->randoGiEntry, 50.0f, 80.0f); + GiveItemEntryFromActor(&this->actor, play, this->randoGiEntry, 50.0f, 80.0f); } this->unk_15A++; } else { @@ -721,7 +721,7 @@ void func_8001E5C8(EnItem00* this, GlobalContext* globalCtx) { } // The BSS in the function acted weird in the past. It is matching now but might cause issues in the future -void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Update(Actor* thisx, PlayState* play) { static u32 D_80157D90; static s16 D_80157D94[1]; s16* params; @@ -762,7 +762,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { this->unk_156 = this->unk_15A; } - this->actionFunc(this, globalCtx); + this->actionFunc(this, play); Math_SmoothStepToF(&this->actor.scale.x, this->scale, 0.1f, this->scale * 0.1f, 0.0f); temp = &D_80157D90; @@ -771,12 +771,12 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.gravity) { if (this->actor.bgCheckFlags & 0x0003) { - if (*temp != globalCtx->gameplayFrames) { - D_80157D90 = globalCtx->gameplayFrames; + if (*temp != play->gameplayFrames) { + D_80157D90 = play->gameplayFrames; D_80157D94[0] = 0; for (i = 0; i < 50; i++) { - if (globalCtx->colCtx.dyna.bgActorFlags[i] & 1) { - dynaActor = globalCtx->colCtx.dyna.bgActors[i].actor; + if (play->colCtx.dyna.bgActorFlags[i] & 1) { + dynaActor = play->colCtx.dyna.bgActors[i].actor; if ((dynaActor != NULL) && (dynaActor->update != NULL)) { if ((dynaActor->world.pos.x != dynaActor->prevPos.x) || (dynaActor->world.pos.y != dynaActor->prevPos.y) || @@ -795,7 +795,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { } if (sp3A || D_80157D94[0]) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 15.0f, 0x1D); + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 15.0f, 15.0f, 0x1D); if (this->actor.floorHeight <= -10000.0f) { Actor_Kill(&this->actor); @@ -805,7 +805,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { } Collider_UpdateCylinder(&this->actor, &this->collider); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &this->collider.base); + CollisionCheck_SetAC(play, &play->colChkCtx, &this->collider.base); if ((this->actor.params == ITEM00_SHIELD_DEKU) || (this->actor.params == ITEM00_SHIELD_HYLIAN) || (this->actor.params == ITEM00_TUNIC_ZORA) || (this->actor.params == ITEM00_TUNIC_GORON)) { @@ -819,30 +819,30 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (!((this->actor.xzDistToPlayer <= 30.0f) && (this->actor.yDistToPlayer >= -50.0f) && (this->actor.yDistToPlayer <= 50.0f))) { - if (!Actor_HasParent(&this->actor, globalCtx)) { + if (!Actor_HasParent(&this->actor, play)) { return; } } - if (globalCtx->gameOverCtx.state != GAMEOVER_INACTIVE) { + if (play->gameOverCtx.state != GAMEOVER_INACTIVE) { return; } switch (this->actor.params) { case ITEM00_RUPEE_GREEN: - Item_Give(globalCtx, ITEM_RUPEE_GREEN); + Item_Give(play, ITEM_RUPEE_GREEN); break; case ITEM00_RUPEE_BLUE: - Item_Give(globalCtx, ITEM_RUPEE_BLUE); + Item_Give(play, ITEM_RUPEE_BLUE); break; case ITEM00_RUPEE_RED: - Item_Give(globalCtx, ITEM_RUPEE_RED); + Item_Give(play, ITEM_RUPEE_RED); break; case ITEM00_RUPEE_PURPLE: - Item_Give(globalCtx, ITEM_RUPEE_PURPLE); + Item_Give(play, ITEM_RUPEE_PURPLE); break; case ITEM00_RUPEE_ORANGE: - Item_Give(globalCtx, ITEM_RUPEE_GOLD); + Item_Give(play, ITEM_RUPEE_GOLD); break; case ITEM00_STICK: getItemId = GI_STICKS_1; @@ -851,26 +851,26 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { getItemId = GI_NUTS_5; break; case ITEM00_HEART: - Item_Give(globalCtx, ITEM_HEART); + Item_Give(play, ITEM_HEART); break; case ITEM00_FLEXIBLE: - Health_ChangeBy(globalCtx, 0x70); + Health_ChangeBy(play, 0x70); break; case ITEM00_BOMBS_A: case ITEM00_BOMBS_B: - Item_Give(globalCtx, ITEM_BOMBS_5); + Item_Give(play, ITEM_BOMBS_5); break; case ITEM00_ARROWS_SINGLE: - Item_Give(globalCtx, ITEM_BOW); + Item_Give(play, ITEM_BOW); break; case ITEM00_ARROWS_SMALL: - Item_Give(globalCtx, ITEM_ARROWS_SMALL); + Item_Give(play, ITEM_ARROWS_SMALL); break; case ITEM00_ARROWS_MEDIUM: - Item_Give(globalCtx, ITEM_ARROWS_MEDIUM); + Item_Give(play, ITEM_ARROWS_MEDIUM); break; case ITEM00_ARROWS_LARGE: - Item_Give(globalCtx, ITEM_ARROWS_LARGE); + Item_Give(play, ITEM_ARROWS_LARGE); break; case ITEM00_SEEDS: getItemId = GI_SEEDS_5; @@ -905,18 +905,18 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_BOMBS_SPECIAL: break; case ITEM00_BOMBCHU: - Item_Give(globalCtx, ITEM_BOMBCHUS_5); + Item_Give(play, ITEM_BOMBCHUS_5); break; } params = &this->actor.params; - if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { + if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { if (!gSaveContext.n64ddFlag || this->randoGiEntry.getItemId == GI_NONE) { - func_8002F554(&this->actor, globalCtx, getItemId); + func_8002F554(&this->actor, play, getItemId); } else { getItemId = this->randoGiEntry.getItemId; - GiveItemEntryFromActorWithFixedRange(&this->actor, globalCtx, this->randoGiEntry); + GiveItemEntryFromActorWithFixedRange(&this->actor, play, this->randoGiEntry); } } @@ -928,8 +928,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_SHIELD_HYLIAN: case ITEM00_TUNIC_ZORA: case ITEM00_TUNIC_GORON: - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, this->collectibleFlag); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, this->collectibleFlag); Actor_Kill(&this->actor); } return; @@ -938,8 +938,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if ((*params <= ITEM00_RUPEE_RED) || (*params == ITEM00_RUPEE_ORANGE)) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else if (getItemId != GI_NONE) { - if (Actor_HasParent(&this->actor, globalCtx)) { - Flags_SetCollectible(globalCtx, this->collectibleFlag); + if (Actor_HasParent(&this->actor, play)) { + Flags_SetCollectible(play, this->collectibleFlag); Actor_Kill(&this->actor); } return; @@ -947,7 +947,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { Audio_PlaySoundGeneral(NA_SE_SY_GET_ITEM, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Flags_SetCollectible(globalCtx, this->collectibleFlag); + Flags_SetCollectible(play, this->collectibleFlag); this->unk_15A = 15; this->unk_154 = 35; @@ -962,7 +962,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { EnItem00_SetupAction(this, func_8001E5C8); } -void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { +void EnItem00_Draw(Actor* thisx, PlayState* play) { EnItem00* this = (EnItem00*)thisx; f32 mtxScale; @@ -975,7 +975,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_RUPEE_GREEN); + GetItem_Draw(play, GID_RUPEE_GREEN); break; } case ITEM00_RUPEE_BLUE: @@ -985,7 +985,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_RUPEE_BLUE); + GetItem_Draw(play, GID_RUPEE_BLUE); break; } case ITEM00_RUPEE_RED: @@ -995,14 +995,14 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_RUPEE_RED); + GetItem_Draw(play, GID_RUPEE_RED); break; } else { this->actor.shape.shadowScale = 6.0f; Actor_SetScale(&this->actor, 0.015f); this->scale = 0.015f; this->actor.shape.yOffset = 750.0f; - EnItem00_DrawRupee(this, globalCtx); + EnItem00_DrawRupee(this, play); break; } case ITEM00_RUPEE_ORANGE: @@ -1012,14 +1012,14 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_RUPEE_GOLD); + GetItem_Draw(play, GID_RUPEE_GOLD); break; } else { Actor_SetScale(&this->actor, 0.045 - 1e-10); this->actor.shape.shadowScale = 6.0f; this->scale = 0.045 - 1e-10; this->actor.shape.yOffset = 750.0f; - EnItem00_DrawRupee(this, globalCtx); + EnItem00_DrawRupee(this, play); break; } case ITEM00_RUPEE_PURPLE: @@ -1029,14 +1029,14 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_RUPEE_PURPLE); + GetItem_Draw(play, GID_RUPEE_PURPLE); break; } else { Actor_SetScale(&this->actor, 0.03f); this->actor.shape.shadowScale = 6.0f; this->scale = 0.03f; this->actor.shape.yOffset = 750.0f; - EnItem00_DrawRupee(this, globalCtx); + EnItem00_DrawRupee(this, play); break; } case ITEM00_HEART_PIECE: @@ -1046,17 +1046,17 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_HEART_PIECE); + GetItem_Draw(play, GID_HEART_PIECE); } else { this->actor.shape.yOffset = 650.0f; this->actor.shape.shadowScale = 0.03f; Actor_SetScale(&this->actor, 0.02f); this->scale = 0.02f; - EnItem00_DrawHeartPiece(this, globalCtx); + EnItem00_DrawHeartPiece(this, play); } break; case ITEM00_HEART_CONTAINER: - EnItem00_DrawHeartContainer(this, globalCtx); + EnItem00_DrawHeartContainer(this, play); break; case ITEM00_HEART: if (CVar_GetS32("gNewDrops", 0)) { @@ -1065,23 +1065,23 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowScale = 0.3f; Actor_SetScale(&this->actor, 0.3f); this->scale = 0.3f; - GetItem_Draw(globalCtx, GID_HEART); + GetItem_Draw(play, GID_HEART); mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); break; } else { if (this->unk_15A < 0) { if (this->unk_15A == -1) { - s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART); - if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) { + s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART); + if (Object_IsLoaded(&play->objectCtx, bankIndex)) { this->actor.objBankIndex = bankIndex; - Actor_SetObjectDependency(globalCtx, &this->actor); + Actor_SetObjectDependency(play, &this->actor); this->unk_15A = -2; } } else { mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - GetItem_Draw(globalCtx, GID_HEART); + GetItem_Draw(play, GID_HEART); } break; } @@ -1091,7 +1091,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.shadowScale = 6.0f; Actor_SetScale(&this->actor, 0.02f); this->scale = 0.02f; - EnItem00_DrawCollectible(this, globalCtx); + EnItem00_DrawCollectible(this, play); break; } @@ -1102,7 +1102,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_BOMB); + GetItem_Draw(play, GID_BOMB); break; } case ITEM00_BOMBS_B: @@ -1112,7 +1112,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_BOMB); + GetItem_Draw(play, GID_BOMB); break; } case ITEM00_BOMBS_SPECIAL: @@ -1123,7 +1123,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_ARROWS_SMALL); + GetItem_Draw(play, GID_ARROWS_SMALL); break; } case ITEM00_ARROWS_SMALL: @@ -1133,7 +1133,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_ARROWS_SMALL); + GetItem_Draw(play, GID_ARROWS_SMALL); break; } case ITEM00_ARROWS_MEDIUM: @@ -1143,7 +1143,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_ARROWS_MEDIUM); + GetItem_Draw(play, GID_ARROWS_MEDIUM); break; } case ITEM00_ARROWS_LARGE: @@ -1153,7 +1153,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_ARROWS_LARGE); + GetItem_Draw(play, GID_ARROWS_LARGE); break; } case ITEM00_NUTS: @@ -1163,7 +1163,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_NUTS); + GetItem_Draw(play, GID_NUTS); break; } case ITEM00_STICK: @@ -1173,7 +1173,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_STICK); + GetItem_Draw(play, GID_STICK); break; } case ITEM00_MAGIC_LARGE: @@ -1183,7 +1183,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_MAGIC_LARGE); + GetItem_Draw(play, GID_MAGIC_LARGE); break; } case ITEM00_MAGIC_SMALL: @@ -1193,7 +1193,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_MAGIC_SMALL); + GetItem_Draw(play, GID_MAGIC_SMALL); break; } case ITEM00_SEEDS: @@ -1203,7 +1203,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.shape.shadowScale = 0.3f; this->actor.world.rot.x = 0x4000; - GetItem_Draw(globalCtx, GID_SEEDS); + GetItem_Draw(play, GID_SEEDS); break; } case ITEM00_SMALL_KEY: @@ -1213,7 +1213,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.5f; - GetItem_Draw(globalCtx, GID_KEY_SMALL); + GetItem_Draw(play, GID_KEY_SMALL); break; } else { Actor_SetScale(&this->actor, 0.03f); @@ -1224,7 +1224,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.world.rot.x = 0; this->actor.shape.rot.y = 0; } - EnItem00_DrawCollectible(this, globalCtx); + EnItem00_DrawCollectible(this, play); break; } case ITEM00_BOMBCHU: @@ -1234,19 +1234,19 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { this->actor.shape.yOffset = 50.0f; this->actor.world.rot.x = 0x4000; this->actor.shape.shadowScale = 0.3f; - GetItem_Draw(globalCtx, GID_BOMBCHU); + GetItem_Draw(play, GID_BOMBCHU); break; case ITEM00_SHIELD_DEKU: - GetItem_Draw(globalCtx, GID_SHIELD_DEKU); + GetItem_Draw(play, GID_SHIELD_DEKU); break; case ITEM00_SHIELD_HYLIAN: - GetItem_Draw(globalCtx, GID_SHIELD_HYLIAN); + GetItem_Draw(play, GID_SHIELD_HYLIAN); break; case ITEM00_TUNIC_ZORA: - GetItem_Draw(globalCtx, GID_TUNIC_ZORA); + GetItem_Draw(play, GID_TUNIC_ZORA); break; case ITEM00_TUNIC_GORON: - GetItem_Draw(globalCtx, GID_TUNIC_GORON); + GetItem_Draw(play, GID_TUNIC_GORON); break; case ITEM00_FLEXIBLE: break; @@ -1254,7 +1254,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { } } -void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, GetItemEntry giEntry) { +void EnItem00_CustomItemsParticles(Actor* Parent, PlayState* play, GetItemEntry giEntry) { s16 color_slot; switch (giEntry.modIndex) { case MOD_NONE: @@ -1351,20 +1351,20 @@ void EnItem00_CustomItemsParticles(Actor* Parent, GlobalContext* globalCtx, GetI pos.z = Rand_CenteredFloat(32.0f) + Parent->world.pos.z; - EffectSsKiraKira_SpawnDispersed(globalCtx, &pos, &velocity, &accel, &primColor, &envColor, 1000, 50); + EffectSsKiraKira_SpawnDispersed(play, &pos, &velocity, &accel, &primColor, &envColor, 1000, 50); } /** * Draw Function used for Rupee types of En_Item00. */ -void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawRupee(EnItem00* this, PlayState* play) { s32 pad; s32 texIndex; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); + func_80093D18(play->state.gfxCtx); + func_8002EBCC(&this->actor, play, 0); if (this->actor.params <= ITEM00_RUPEE_RED) { texIndex = this->actor.params; @@ -1372,31 +1372,31 @@ void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { texIndex = this->actor.params - 0x10; } - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sRupeeTex[texIndex])); gSPDisplayList(POLY_OPA_DISP++, gRupeeDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw Function used for most collectible types of En_Item00 (ammo, bombs, sticks, nuts, magic...). */ -void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawCollectible(EnItem00* this, PlayState* play) { if (gSaveContext.n64ddFlag && (this->getItemId != GI_NONE || this->actor.params == ITEM00_SMALL_KEY)) { f32 mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - EnItem00_CustomItemsParticles(&this->actor, globalCtx, this->randoGiEntry); - GetItemEntry_Draw(globalCtx, this->randoGiEntry); + EnItem00_CustomItemsParticles(&this->actor, play, this->randoGiEntry); + GetItemEntry_Draw(play, this->randoGiEntry); } else { s32 texIndex = this->actor.params - 3; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); if (this->actor.params == ITEM00_BOMBS_SPECIAL) { texIndex = 1; @@ -1411,58 +1411,58 @@ void EnItem00_DrawCollectible(EnItem00* this, GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sItemDropTex[texIndex])); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } /** * Draw Function used for the Heart Container type of En_Item00. */ -void EnItem00_DrawHeartContainer(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D18(play->state.gfxCtx); + func_8002EBCC(&this->actor, play, 0); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gHeartPieceExteriorDL); - func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + func_8002ED80(&this->actor, play, 0); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gHeartContainerInteriorDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw Function used for the Piece of Heart type of En_Item00. */ -void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) { +void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) { if (gSaveContext.n64ddFlag) { f32 mtxScale = 16.0f; Matrix_Scale(mtxScale, mtxScale, mtxScale, MTXMODE_APPLY); - EnItem00_CustomItemsParticles(&this->actor, globalCtx, this->randoGiEntry); - GetItemEntry_Draw(globalCtx, this->randoGiEntry); + EnItem00_CustomItemsParticles(&this->actor, play, this->randoGiEntry); + GetItemEntry_Draw(play, this->randoGiEntry); } else { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + func_80093D84(play->state.gfxCtx); + func_8002ED80(&this->actor, play, 0); + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -1538,7 +1538,7 @@ s16 func_8001F404(s16 dropId) { // External functions used by other actors to drop collectibles, which usually results in spawning an En_Item00 actor. -EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params) { +EnItem00* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, s16 params) { s32 pad[2]; EnItem00* spawnedActor = NULL; s16 param4000 = params & 0x4000; @@ -1551,9 +1551,9 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 pa if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) { // TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf) - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, + spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); - EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, + EffectSsDeadSound_SpawnStationary(play, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, DEADSOUND_REPEAT_MODE_OFF, 40); } else { if (!param8000) { @@ -1561,7 +1561,7 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 pa } if (params != -1) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, + spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param3F00); if ((spawnedActor != NULL) && !param8000) { spawnedActor->actor.velocity.y = !param4000 ? 8.0f : -2.0f; @@ -1583,7 +1583,7 @@ EnItem00* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, s16 pa return spawnedActor; } -EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 params) { +EnItem00* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s16 params) { EnItem00* spawnedActor = NULL; s32 pad; s16 param4000 = params & 0x4000; @@ -1596,14 +1596,14 @@ EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 p if (((params & 0x00FF) == ITEM00_FLEXIBLE) && !param4000) { // TODO: Prevent the cast to EnItem00 here since this is a different actor (En_Elf) - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, + spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); - EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, + EffectSsDeadSound_SpawnStationary(play, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, DEADSOUND_REPEAT_MODE_OFF, 40); } else { params = func_8001F404(params & 0x00FF); if (params != -1) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, + spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param3F00); if ((spawnedActor != NULL) && !param8000) { spawnedActor->actor.velocity.y = 0.0f; @@ -1618,7 +1618,7 @@ EnItem00* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s16 p return spawnedActor; } -void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) { +void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params) { s32 pad; EnItem00* spawnedActor; s16 dropQuantity; @@ -1667,9 +1667,9 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 if (dropId == ITEM00_FLEXIBLE) { if (gSaveContext.health <= 0x10) { // 1 heart or less - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); - EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, + EffectSsDeadSound_SpawnStationary(play, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, DEADSOUND_REPEAT_MODE_OFF, 40); return; } else if (gSaveContext.health <= 0x30 && !CVar_GetS32("gNoHeartDrops", 0)) { // 3 hearts or less @@ -1715,7 +1715,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 if (!param8000) { dropId = func_8001F404(dropId); if (dropId != 0xFF) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, + spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, dropId); if ((spawnedActor != NULL) && (dropId != 0xFF)) { spawnedActor->actor.velocity.y = 8.0f; @@ -1734,7 +1734,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 } } } else { - Item_DropCollectible(globalCtx, spawnPos, params | 0x8000); + Item_DropCollectible(play, spawnPos, params | 0x8000); } dropQuantity--; } diff --git a/soh/src/code/z_face_reaction.c b/soh/src/code/z_face_reaction.c index d463da4f7..2dbd56df2 100644 --- a/soh/src/code/z_face_reaction.c +++ b/soh/src/code/z_face_reaction.c @@ -63,8 +63,8 @@ u16 sReactionTextIds[][PLAYER_MASK_MAX] = { { 0x0000, 0x7104, 0x7105, 0x7107, 0x7105, 0x710C, 0x7105, 0x7107, 0x7107 }, }; -u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet) { - u8 currentMask = Player_GetMask(globalCtx); +u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet) { + u8 currentMask = Player_GetMask(play); return sReactionTextIds[reactionSet][currentMask]; } diff --git a/soh/src/code/z_fcurve_data_skelanime.c b/soh/src/code/z_fcurve_data_skelanime.c index 98e79387c..2ae49c3dd 100644 --- a/soh/src/code/z_fcurve_data_skelanime.c +++ b/soh/src/code/z_fcurve_data_skelanime.c @@ -11,7 +11,7 @@ void SkelCurve_Clear(SkelAnimeCurve* skelCurve) { skelCurve->unk_0C = 0.0f; } -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, +s32 SkelCurve_Init(PlayState* play, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg, TransformUpdateIndex* transUpdIdx) { if (ResourceMgr_OTRSigCheck(limbListSeg)) @@ -29,7 +29,7 @@ s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurv return 1; } -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { +void SkelCurve_Destroy(PlayState* play, SkelAnimeCurve* skelCurve) { if (skelCurve->transforms != NULL) { ZELDA_ARENA_FREE_DEBUG(skelCurve->transforms); } @@ -44,7 +44,7 @@ void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpd skelCurve->transUpdIdx = transUpdIdx; } -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { +s32 SkelCurve_Update(PlayState* play, SkelAnimeCurve* skelCurve) { s16* transforms; u8* transformRefIdx; TransformUpdateIndex* transformIndex; @@ -99,16 +99,16 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) { return ret; } -void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve, +void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { SkelCurveLimb* limb = SEGMENTED_TO_VIRTUAL(skelCurve->limbList[limbIndex]); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); if (overrideLimbDraw == NULL || - (overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, data))) { + (overrideLimbDraw != NULL && overrideLimbDraw(play, skelCurve, limbIndex, data))) { Vec3f scale; Vec3s rot; Vec3f pos; @@ -135,7 +135,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, dList); } @@ -144,13 +144,13 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, dList); } dList = limb->dList[1]; if (dList != NULL) { - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, dList); } @@ -161,25 +161,25 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, skelCurve, limbIndex, data); + postLimbDraw(play, skelCurve, limbIndex, data); } if (limb->firstChildIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + SkelCurve_DrawLimb(play, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } Matrix_Pop(); if (limb->nextLimbIdx != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + SkelCurve_DrawLimb(play, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, +void SkelCurve_Draw(Actor* actor, PlayState* play, SkelAnimeCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { if (skelCurve->transforms != NULL) { - SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + SkelCurve_DrawLimb(play, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } } diff --git a/soh/src/code/z_game_dlftbls.c b/soh/src/code/z_game_dlftbls.c index 0f5b845d8..d3c3adb79 100644 --- a/soh/src/code/z_game_dlftbls.c +++ b/soh/src/code/z_game_dlftbls.c @@ -15,7 +15,7 @@ GameStateOverlay gGameStateOverlayTable[] = { GAMESTATE_OVERLAY_INTERNAL(TitleSetup_Init, TitleSetup_Destroy, sizeof(GameState)), GAMESTATE_OVERLAY(select, Select_Init, Select_Destroy, sizeof(SelectContext)), GAMESTATE_OVERLAY(title, Title_Init, Title_Destroy, sizeof(TitleContext)), - GAMESTATE_OVERLAY_INTERNAL(Gameplay_Init, Gameplay_Destroy, sizeof(GlobalContext)), + GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Destroy, sizeof(PlayState)), GAMESTATE_OVERLAY(opening, Opening_Init, Opening_Destroy, sizeof(OpeningContext)), GAMESTATE_OVERLAY(file_choose, FileChoose_Init, FileChoose_Destroy, sizeof(FileChooseContext)), }; diff --git a/soh/src/code/z_game_over.c b/soh/src/code/z_game_over.c index bb4be8711..315199000 100644 --- a/soh/src/code/z_game_over.c +++ b/soh/src/code/z_game_over.c @@ -1,23 +1,23 @@ #include "global.h" -void GameOver_Init(GlobalContext* globalCtx) { - globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE; +void GameOver_Init(PlayState* play) { + play->gameOverCtx.state = GAMEOVER_INACTIVE; } -void GameOver_FadeInLights(GlobalContext* globalCtx) { - GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; +void GameOver_FadeInLights(PlayState* play) { + GameOverContext* gameOverCtx = &play->gameOverCtx; if ((gameOverCtx->state >= GAMEOVER_DEATH_WAIT_GROUND && gameOverCtx->state < GAMEOVER_REVIVE_START) || (gameOverCtx->state >= GAMEOVER_REVIVE_RUMBLE && gameOverCtx->state < GAMEOVER_REVIVE_FADE_OUT)) { - Environment_FadeInGameOverLights(globalCtx); + Environment_FadeInGameOverLights(play); } } // This variable cannot be moved into this file as all of z_message_PAL rodata is in the way extern s16 gGameOverTimer; -void GameOver_Update(GlobalContext* globalCtx) { - GameOverContext* gameOverCtx = &globalCtx->gameOverCtx; +void GameOver_Update(PlayState* play) { + GameOverContext* gameOverCtx = &play->gameOverCtx; s16 i; s16 j; s32 v90; @@ -26,7 +26,7 @@ void GameOver_Update(GlobalContext* globalCtx) { switch (gameOverCtx->state) { case GAMEOVER_DEATH_START: - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); gSaveContext.timer1State = 0; gSaveContext.timer2State = 0; @@ -42,7 +42,7 @@ void GameOver_Update(GlobalContext* globalCtx) { for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) { if (gSaveContext.equips.buttonItems[j] == gSpoilingItems[i]) { gSaveContext.equips.buttonItems[j] = gSpoilingItemReverts[i]; - Interface_LoadItemIcon1(globalCtx, j); + Interface_LoadItemIcon1(play, j); } } } @@ -75,7 +75,7 @@ void GameOver_Update(GlobalContext* globalCtx) { } gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0; - Environment_InitGameOverLights(globalCtx); + Environment_InitGameOverLights(play); gGameOverTimer = 20; v90 = VREG(90); v91 = VREG(91); @@ -94,7 +94,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gGameOverTimer--; if (gGameOverTimer == 0) { - globalCtx->pauseCtx.state = 8; + play->pauseCtx.state = 8; gameOverCtx->state++; func_800AA15C(); } @@ -103,7 +103,7 @@ void GameOver_Update(GlobalContext* globalCtx) { case GAMEOVER_REVIVE_START: gameOverCtx->state++; gGameOverTimer = 0; - Environment_InitGameOverLights(globalCtx); + Environment_InitGameOverLights(play); ShrinkWindow_SetVal(0x20); return; @@ -138,7 +138,7 @@ void GameOver_Update(GlobalContext* globalCtx) { break; case GAMEOVER_REVIVE_FADE_OUT: - Environment_FadeOutGameOverLights(globalCtx); + Environment_FadeOutGameOverLights(play); gGameOverTimer--; if (gGameOverTimer == 0) { diff --git a/soh/src/code/z_horse.c b/soh/src/code/z_horse.c index 9537a8146..5d829d3e5 100644 --- a/soh/src/code/z_horse.c +++ b/soh/src/code/z_horse.c @@ -14,7 +14,7 @@ s32 func_8006CFC0(s32 scene) { return 0; } -void func_8006D074(GlobalContext* globalCtx) { +void func_8006D074(PlayState* play) { gSaveContext.horseData.scene = SCENE_SPOT00; gSaveContext.horseData.pos.x = -1840; gSaveContext.horseData.pos.y = 72; @@ -22,7 +22,7 @@ void func_8006D074(GlobalContext* globalCtx) { gSaveContext.horseData.angle = -27353; } -void func_8006D0AC(GlobalContext* globalCtx) { +void func_8006D0AC(PlayState* play) { if (gSaveContext.horseData.scene == SCENE_SPOT06) { gSaveContext.horseData.scene = SCENE_SPOT06; gSaveContext.horseData.pos.x = -2065; @@ -39,7 +39,7 @@ typedef struct { /* 0x0A */ s16 type; } HorseSpawn; -void func_8006D0EC(GlobalContext* globalCtx, Player* player) { +void func_8006D0EC(PlayState* play, Player* player) { s32 i; HorseSpawn horseSpawns[] = { { SCENE_SPOT00, -460, 100, 6640, 0, 2 }, { SCENE_SPOT06, -1929, -1025, 768, 0, 2 }, @@ -48,30 +48,30 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) { }; if ((AREG(6) != 0) && (Flags_GetEventChkInf(0x18) || (DREG(1) != 0))) { - player->rideActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, player->actor.world.pos.x, + player->rideActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z, player->actor.shape.rot.x, player->actor.shape.rot.y, player->actor.shape.rot.z, 9); ASSERT(player->rideActor != NULL); - Actor_MountHorse(globalCtx, player, player->rideActor); - func_8002DE74(globalCtx, player); - gSaveContext.horseData.scene = globalCtx->sceneNum; + Actor_MountHorse(play, player, player->rideActor); + func_8002DE74(play, player); + gSaveContext.horseData.scene = play->sceneNum; - if (globalCtx->sceneNum == SCENE_SPOT12) { + if (play->sceneNum == SCENE_SPOT12) { player->rideActor->room = -1; } - } else if ((globalCtx->sceneNum == SCENE_SPOT12) && (gSaveContext.minigameState == 3)) { + } else if ((play->sceneNum == SCENE_SPOT12) && (gSaveContext.minigameState == 3)) { Actor* horseActor; gSaveContext.minigameState = 0; horseActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 3586.0f, 1413.0f, -402.0f, 0, 0x4000, 0, 1); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, 3586.0f, 1413.0f, -402.0f, 0, 0x4000, 0, 1); horseActor->room = -1; } else if ((gSaveContext.entranceIndex == 1230) && (gSaveContext.eventChkInf[1] & 0x100)) { Actor* horseActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, -25.0f, 0.0f, -1600.0f, 0, -0x4000, 0, 1); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, -25.0f, 0.0f, -1600.0f, 0, -0x4000, 0, 1); ASSERT(horseActor != NULL); - } else if ((globalCtx->sceneNum == gSaveContext.horseData.scene) && + } else if ((play->sceneNum == gSaveContext.horseData.scene) && (((Flags_GetEventChkInf(0x18) != 0) && (!gSaveContext.n64ddFlag || (gSaveContext.n64ddFlag && CHECK_QUEST_ITEM(QUEST_SONG_EPONA) && (INV_CONTENT(ITEM_OCARINA_FAIRY) != ITEM_NONE)))) || DREG(1) != 0)) { @@ -80,11 +80,11 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) { DREG(1)); if (func_8006CFC0(gSaveContext.horseData.scene)) { - Actor* horseActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, + Actor* horseActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, gSaveContext.horseData.pos.x, gSaveContext.horseData.pos.y, gSaveContext.horseData.pos.z, 0, gSaveContext.horseData.angle, 0, 1); ASSERT(horseActor != NULL); - if (globalCtx->sceneNum == SCENE_SPOT12) { + if (play->sceneNum == SCENE_SPOT12) { horseActor->room = -1; } } else { @@ -92,21 +92,21 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) { // "Horse_SetNormal():%d set spot is no good." osSyncPrintf("Horse_SetNormal():%d セットスポットまずいです。\n", gSaveContext.horseData.scene); osSyncPrintf(VT_RST); - func_8006D074(globalCtx); + func_8006D074(play); } - } else if ((globalCtx->sceneNum == SCENE_SPOT20) && !Flags_GetEventChkInf(0x18) && (DREG(1) == 0)) { + } else if ((play->sceneNum == SCENE_SPOT20) && !Flags_GetEventChkInf(0x18) && (DREG(1) == 0)) { Actor* horseActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 0.0f, 0.0f, -500.0f, 0, 0, 0, 1); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, 0.0f, 0.0f, -500.0f, 0, 0, 0, 1); ASSERT(horseActor != NULL); } else if (Flags_GetEventChkInf(0x18) || (DREG(1) != 0)) { for (i = 0; i < ARRAY_COUNT(horseSpawns); i++) { HorseSpawn* horseSpawn = &horseSpawns[i]; - if (horseSpawn->scene == globalCtx->sceneNum) { + if (horseSpawn->scene == play->sceneNum) { Actor* horseActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, horseSpawn->pos.x, horseSpawn->pos.y, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, horseSpawn->pos.x, horseSpawn->pos.y, horseSpawn->pos.z, 0, horseSpawn->angle, 0, horseSpawn->type); ASSERT(horseActor != NULL); - if (globalCtx->sceneNum == SCENE_SPOT12) { + if (play->sceneNum == SCENE_SPOT12) { horseActor->room = -1; } @@ -114,8 +114,8 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) { } } } else if (!Flags_GetEventChkInf(0x18)) { - if ((DREG(1) == 0) && (globalCtx->sceneNum == SCENE_SOUKO) && !IS_DAY) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 0.0f, 0.0f, -60.0f, 0, 0x7360, 0, 1); + if ((DREG(1) == 0) && (play->sceneNum == SCENE_SOUKO) && !IS_DAY) { + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, 0.0f, 0.0f, -60.0f, 0, 0x7360, 0, 1); } } } @@ -128,7 +128,7 @@ typedef struct { /* 0x10 */ s16 type; } struct_8011F9B8; -void func_8006D684(GlobalContext* globalCtx, Player* player) { +void func_8006D684(PlayState* play, Player* player) { s32 pad; s32 i; Vec3s spawnPos; @@ -153,24 +153,24 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) { spawnPos = spawnPositions[3]; } - player->rideActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, spawnPos.x, spawnPos.y, + player->rideActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, spawnPos.x, spawnPos.y, spawnPos.z, 0, player->actor.world.rot.y, 0, 7); ASSERT(player->rideActor != NULL); - Actor_MountHorse(globalCtx, player, player->rideActor); - func_8002DE74(globalCtx, player); - gSaveContext.horseData.scene = globalCtx->sceneNum; - } else if ((globalCtx->sceneNum == SCENE_SPOT20) && ((gSaveContext.eventInf[0] & 0xF) == 6) && + Actor_MountHorse(play, player, player->rideActor); + func_8002DE74(play, player); + gSaveContext.horseData.scene = play->sceneNum; + } else if ((play->sceneNum == SCENE_SPOT20) && ((gSaveContext.eventInf[0] & 0xF) == 6) && (Flags_GetEventChkInf(0x18) == 0) && (DREG(1) == 0)) { player->rideActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 894.0f, 0.0f, -2084.0f, 0, -0x7FFF, 0, 5); + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, 894.0f, 0.0f, -2084.0f, 0, -0x7FFF, 0, 5); ASSERT(player->rideActor != NULL); - Actor_MountHorse(globalCtx, player, player->rideActor); - func_8002DE74(globalCtx, player); - gSaveContext.horseData.scene = globalCtx->sceneNum; + Actor_MountHorse(play, player, player->rideActor); + func_8002DE74(play, player); + gSaveContext.horseData.scene = play->sceneNum; - if (globalCtx->sceneNum == SCENE_SPOT12) { + if (play->sceneNum == SCENE_SPOT12) { player->rideActor->room = -1; } } else { @@ -182,22 +182,22 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) { }; for (i = 0; i < ARRAY_COUNT(D_8011F9B8); i++) { - if ((globalCtx->sceneNum == D_8011F9B8[i].scene) && + if ((play->sceneNum == D_8011F9B8[i].scene) && (((void)0, gSaveContext.cutsceneIndex) == D_8011F9B8[i].cutsceneIndex)) { if (D_8011F9B8[i].type == 7) { - if ((globalCtx->sceneNum == 99) && (((void)0, gSaveContext.cutsceneIndex) == 0xFFF1)) { + if ((play->sceneNum == 99) && (((void)0, gSaveContext.cutsceneIndex) == 0xFFF1)) { D_8011F9B8[i].pos.x = player->actor.world.pos.x; D_8011F9B8[i].pos.y = player->actor.world.pos.y; D_8011F9B8[i].pos.z = player->actor.world.pos.z; } - player->rideActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, + player->rideActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, D_8011F9B8[i].pos.x, D_8011F9B8[i].pos.y, D_8011F9B8[i].pos.z, 0, player->actor.world.rot.y, 0, D_8011F9B8[i].type); ASSERT(player->rideActor != NULL); - Actor_MountHorse(globalCtx, player, player->rideActor); - func_8002DE74(globalCtx, player); + Actor_MountHorse(play, player, player->rideActor); + func_8002DE74(play, player); } else if ((D_8011F9B8[i].type == 5) || (D_8011F9B8[i].type == 6) || (D_8011F9B8[i].type == 8)) { Vec3f sp54; s32 temp = 0; @@ -206,7 +206,7 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) { temp = 0x8000; } - player->rideActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, + player->rideActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, D_8011F9B8[i].pos.x, D_8011F9B8[i].pos.y, D_8011F9B8[i].pos.z, 0, D_8011F9B8[i].angle, 0, D_8011F9B8[i].type | temp); ASSERT(player->rideActor != NULL); @@ -217,16 +217,16 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) { player->actor.shape.rot.x = player->actor.shape.rot.z = 0; player->actor.shape.rot.y = D_8011F9B8[i].angle; - Actor_MountHorse(globalCtx, player, player->rideActor); - func_8002DE74(globalCtx, player); + Actor_MountHorse(play, player, player->rideActor); + func_8002DE74(play, player); sp54.x = player->actor.world.pos.x - 200.0f; sp54.y = player->actor.world.pos.y + 100.0f; sp54.z = player->actor.world.pos.z; - Gameplay_CameraSetAtEye(globalCtx, globalCtx->activeCamera, &player->actor.world.pos, &sp54); + Play_CameraSetAtEye(play, play->activeCamera, &player->actor.world.pos, &sp54); } else { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, D_8011F9B8[i].pos.x, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, D_8011F9B8[i].pos.x, D_8011F9B8[i].pos.y, D_8011F9B8[i].pos.z, 0, D_8011F9B8[i].angle, 0, D_8011F9B8[i].type); } @@ -236,26 +236,26 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) { } } -void func_8006DC68(GlobalContext* globalCtx, Player* player) { +void func_8006DC68(PlayState* play, Player* player) { if (LINK_IS_ADULT) { if (!func_8006CFC0(gSaveContext.horseData.scene)) { osSyncPrintf(VT_COL(RED, WHITE)); // "Horse_Set_Check():%d set spot is no good." osSyncPrintf("Horse_Set_Check():%d セットスポットまずいです。\n", gSaveContext.horseData.scene); osSyncPrintf(VT_RST); - func_8006D074(globalCtx); + func_8006D074(play); } - if (func_8006CFC0(globalCtx->sceneNum)) { + if (func_8006CFC0(play->sceneNum)) { if ((gSaveContext.sceneSetupIndex > 3) || ((gSaveContext.entranceIndex == 0x028A || gSaveContext.entranceIndex == 0x028E || gSaveContext.entranceIndex == 0x0292 || gSaveContext.entranceIndex == 0x0476) && (gSaveContext.respawnFlag == 0)) || - ((globalCtx->sceneNum == SCENE_SPOT20) && ((gSaveContext.eventInf[0] & 0xF) == 6) && + ((play->sceneNum == SCENE_SPOT20) && ((gSaveContext.eventInf[0] & 0xF) == 6) && !Flags_GetEventChkInf(0x18) && (DREG(1) == 0))) { - func_8006D684(globalCtx, player); + func_8006D684(play, player); } else { - func_8006D0EC(globalCtx, player); + func_8006D0EC(play, player); } } } diff --git a/soh/src/code/z_kaleido_manager.c b/soh/src/code/z_kaleido_manager.c index d215d5fa0..92540b3c4 100644 --- a/soh/src/code/z_kaleido_manager.c +++ b/soh/src/code/z_kaleido_manager.c @@ -46,7 +46,7 @@ void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { } } -void KaleidoManager_Init(GlobalContext* globalCtx) { +void KaleidoManager_Init(PlayState* play) { ptrdiff_t largestSize = 0; ptrdiff_t size; u32 i; @@ -62,7 +62,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) { osSyncPrintf("KaleidoArea の最大サイズは %d バイトを確保します\n", largestSize); osSyncPrintf(VT_RST); - sKaleidoAreaPtr = GAMESTATE_ALLOC_MC(&globalCtx->state, largestSize); + sKaleidoAreaPtr = GAMESTATE_ALLOC_MC(&play->state, largestSize); LOG_CHECK_NULL_POINTER("KaleidoArea_allocp", sKaleidoAreaPtr); osSyncPrintf(VT_FGCOL(GREEN)); diff --git a/soh/src/code/z_kaleido_scope_call.c b/soh/src/code/z_kaleido_scope_call.c index 6e7e81651..81e442d8a 100644 --- a/soh/src/code/z_kaleido_scope_call.c +++ b/soh/src/code/z_kaleido_scope_call.c @@ -1,14 +1,14 @@ #include "global.h" #include "vt.h" -void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx); -void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx); +void (*sKaleidoScopeUpdateFunc)(PlayState* play); +void (*sKaleidoScopeDrawFunc)(PlayState* play); f32 gBossMarkScale; u32 D_8016139C; PauseMapMarksData* gLoadedPauseMarkDataTable; -extern void KaleidoScope_Update(GlobalContext* globalCtx); -extern void KaleidoScope_Draw(GlobalContext* globalCtx); +extern void KaleidoScope_Update(PlayState* play); +extern void KaleidoScope_Draw(PlayState* play); void KaleidoScopeCall_LoadPlayer() { KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR]; @@ -30,7 +30,7 @@ void KaleidoScopeCall_LoadPlayer() { } } -void KaleidoScopeCall_Init(GlobalContext* globalCtx) { +void KaleidoScopeCall_Init(PlayState* play) { // "Kaleidoscope replacement construction" osSyncPrintf("カレイド・スコープ入れ替え コンストラクト \n"); @@ -42,19 +42,19 @@ void KaleidoScopeCall_Init(GlobalContext* globalCtx) { LOG_ADDRESS("kaleido_scope_draw", KaleidoScope_Draw); LOG_ADDRESS("kaleido_scope_draw_func", sKaleidoScopeDrawFunc); - KaleidoSetup_Init(globalCtx); + KaleidoSetup_Init(play); } -void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) { +void KaleidoScopeCall_Destroy(PlayState* play) { // "Kaleidoscope replacement destruction" osSyncPrintf("カレイド・スコープ入れ替え デストラクト \n"); - KaleidoSetup_Destroy(globalCtx); + KaleidoSetup_Destroy(play); } -void KaleidoScopeCall_Update(GlobalContext* globalCtx) { +void KaleidoScopeCall_Update(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; - PauseContext* pauseCtx = &globalCtx->pauseCtx; + PauseContext* pauseCtx = &play->pauseCtx; if ((pauseCtx->state != 0) || (pauseCtx->debugState != 0)) { if (pauseCtx->state == 1) { @@ -101,9 +101,9 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { - sKaleidoScopeUpdateFunc(globalCtx); + sKaleidoScopeUpdateFunc(play); - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { osSyncPrintf(VT_FGCOL(GREEN)); // "Kaleido area Kaleidoscope Emission" osSyncPrintf("カレイド領域 カレイドスコープ排出\n"); @@ -117,15 +117,15 @@ void KaleidoScopeCall_Update(GlobalContext* globalCtx) { } } -void KaleidoScopeCall_Draw(GlobalContext* globalCtx) { +void KaleidoScopeCall_Draw(PlayState* play) { KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; if (R_PAUSE_MENU_MODE >= 3) { - if (((globalCtx->pauseCtx.state >= 4) && (globalCtx->pauseCtx.state <= 7)) || - ((globalCtx->pauseCtx.state >= 11) && (globalCtx->pauseCtx.state <= 18))) { + if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) || + ((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 18))) { if (gKaleidoMgrCurOvl == kaleidoScopeOvl) { - sKaleidoScopeDrawFunc(globalCtx); + sKaleidoScopeDrawFunc(play); } } } diff --git a/soh/src/code/z_kaleido_setup.c b/soh/src/code/z_kaleido_setup.c index 644cbb010..83622820c 100644 --- a/soh/src/code/z_kaleido_setup.c +++ b/soh/src/code/z_kaleido_setup.c @@ -8,15 +8,15 @@ s16 sKaleidoSetupKscpPos1[] = { PAUSE_MAP, PAUSE_QUEST, PAUSE_EQUIP, PAUSE_ITEM f32 sKaleidoSetupEyeX1[] = { -64.0f, 0.0f, 64.0f, 0.0f }; f32 sKaleidoSetupEyeZ1[] = { 0.0f, -64.0f, 0.0f, 64.0f }; -void KaleidoSetup_Update(GlobalContext* globalCtx) { - PauseContext* pauseCtx = &globalCtx->pauseCtx; - Input* input = &globalCtx->state.input[0]; +void KaleidoSetup_Update(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; + Input* input = &play->state.input[0]; - if (pauseCtx->state == 0 && pauseCtx->debugState == 0 && globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE && - globalCtx->sceneLoadFlag == 0 && globalCtx->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 && - gSaveContext.nextCutsceneIndex < 0xFFF0 && !Gameplay_InCsMode(globalCtx) && - globalCtx->shootingGalleryStatus <= 1 && gSaveContext.unk_13F0 != 8 && gSaveContext.unk_13F0 != 9 && - (globalCtx->sceneNum != SCENE_BOWLING || !Flags_GetSwitch(globalCtx, 0x38))) { + if (pauseCtx->state == 0 && pauseCtx->debugState == 0 && play->gameOverCtx.state == GAMEOVER_INACTIVE && + play->sceneLoadFlag == 0 && play->transitionMode == 0 && gSaveContext.cutsceneIndex < 0xFFF0 && + gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_InCsMode(play) && + play->shootingGalleryStatus <= 1 && gSaveContext.unk_13F0 != 8 && gSaveContext.unk_13F0 != 9 && + (play->sceneNum != SCENE_BOWLING || !Flags_GetSwitch(play, 0x38))) { if (CVar_GetS32("gCheatEasyPauseBufferFrameAdvance", 0) == 2 && !CHECK_BTN_ALL(input->press.button, BTN_START)) { CVar_SetS32("gCheatEasyPauseBufferFrameAdvance", 0); @@ -71,8 +71,8 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) { } } -void KaleidoSetup_Init(GlobalContext* globalCtx) { - PauseContext* pauseCtx = &globalCtx->pauseCtx; +void KaleidoSetup_Init(PlayState* play) { + PauseContext* pauseCtx = &play->pauseCtx; u64 temp = 0; // Necessary to match pauseCtx->state = 0; @@ -124,8 +124,8 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) { pauseCtx->ocarinaSongIdx = -1; pauseCtx->cursorSpecialPos = 0; - View_Init(&pauseCtx->view, globalCtx->state.gfxCtx); + View_Init(&pauseCtx->view, play->state.gfxCtx); } -void KaleidoSetup_Destroy(GlobalContext* globalCtx) { +void KaleidoSetup_Destroy(PlayState* play) { } diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index b1144d966..1718a487d 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -225,18 +225,18 @@ u16 Environment_GetPixelDepth(s32 x, s32 y) { } void Environment_GraphCallback(GraphicsContext* gfxCtx, void* param) { - GlobalContext* globalCtx = (GlobalContext*)param; + PlayState* play = (PlayState*)param; OTRGetPixelDepthPrepare(D_8015FD7E, D_8015FD80); - Lights_GlowCheckPrepare(globalCtx); + Lights_GlowCheckPrepare(play); D_8011FB44 = Environment_GetPixelDepth(D_8015FD7E, D_8015FD80); - Lights_GlowCheck(globalCtx); + Lights_GlowCheck(play); } -void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 unused) { +void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused) { u8 i; - GlobalContext* globalCtx = globalCtx2; + PlayState* play = play2; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; @@ -246,14 +246,14 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 ((void)0, gSaveContext.nightFlag = 0); } - globalCtx->state.gfxCtx->callback = Environment_GraphCallback; - globalCtx->state.gfxCtx->callbackParam = globalCtx; + play->state.gfxCtx->callback = Environment_GraphCallback; + play->state.gfxCtx->callbackParam = play; Lights_DirectionalSetInfo(&envCtx->dirLight1, 80, 80, 80, 80, 80, 80); - LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &envCtx->dirLight1); + LightContext_InsertLight(play, &play->lightCtx, &envCtx->dirLight1); Lights_DirectionalSetInfo(&envCtx->dirLight2, 80, 80, 80, 80, 80, 80); - LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &envCtx->dirLight2); + LightContext_InsertLight(play, &play->lightCtx, &envCtx->dirLight2); envCtx->skybox1Index = 99; envCtx->skybox2Index = 99; @@ -319,12 +319,12 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 gSaveContext.chamberCutsceneNum = CREG(3) - 1; } - globalCtx->envCtx.unk_EE[0] = 0; - globalCtx->envCtx.unk_EE[1] = 0; - globalCtx->envCtx.unk_EE[2] = 0; - globalCtx->envCtx.unk_EE[3] = 0; + play->envCtx.unk_EE[0] = 0; + play->envCtx.unk_EE[1] = 0; + play->envCtx.unk_EE[2] = 0; + play->envCtx.unk_EE[3] = 0; - globalCtx->envCtx.unk_F2[0] = 0; + play->envCtx.unk_F2[0] = 0; if (gSaveContext.unk_13C3 != 0) { if (((void)0, gSaveContext.sceneSetupIndex) < 4) { @@ -334,8 +334,8 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 envCtx->unk_18 = 1; envCtx->unk_1F = 3; envCtx->unk_20 = 3; - globalCtx->envCtx.unk_EE[3] = 0; - globalCtx->envCtx.unk_EE[2] = 0; + play->envCtx.unk_EE[3] = 0; + play->envCtx.unk_EE[2] = 0; break; case 2: case 3: @@ -344,30 +344,30 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 envCtx->unk_18 = 1; envCtx->unk_1F = 2; envCtx->unk_20 = 2; - globalCtx->envCtx.unk_EE[3] = 0; - globalCtx->envCtx.unk_EE[2] = 0; + play->envCtx.unk_EE[3] = 0; + play->envCtx.unk_EE[2] = 0; break; case 5: envCtx->unk_17 = 1; envCtx->unk_18 = 1; envCtx->unk_1F = 4; envCtx->unk_20 = 4; - globalCtx->envCtx.unk_EE[3] = 0; - globalCtx->envCtx.unk_EE[2] = 0; + play->envCtx.unk_EE[3] = 0; + play->envCtx.unk_EE[2] = 0; break; default: break; } - if (globalCtx->skyboxId == SKYBOX_NORMAL_SKY) { + if (play->skyboxId == SKYBOX_NORMAL_SKY) { if (gWeatherMode == 3) { - globalCtx->envCtx.unk_EE[2] = globalCtx->envCtx.unk_EE[3] = 0x40; + play->envCtx.unk_EE[2] = play->envCtx.unk_EE[3] = 0x40; } else if (gWeatherMode == 4) { - globalCtx->envCtx.unk_EE[0] = 0x14; - globalCtx->envCtx.unk_EE[1] = 0x14; + play->envCtx.unk_EE[0] = 0x14; + play->envCtx.unk_EE[1] = 0x14; } else if (gWeatherMode == 5) { - globalCtx->envCtx.unk_EE[0] = 0x1E; - globalCtx->envCtx.unk_EE[1] = 0x1E; + play->envCtx.unk_EE[0] = 0x1E; + play->envCtx.unk_EE[1] = 0x1E; } } } @@ -397,15 +397,15 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 sLightningBolts[i].state = LIGHTNING_BOLT_INACTIVE; } - globalCtx->roomCtx.unk_74[0] = 0; - globalCtx->roomCtx.unk_74[1] = 0; + play->roomCtx.unk_74[0] = 0; + play->roomCtx.unk_74[1] = 0; - for (i = 0; i < ARRAY_COUNT(globalCtx->csCtx.npcActions); i++) { - globalCtx->csCtx.npcActions[i] = 0; + for (i = 0; i < ARRAY_COUNT(play->csCtx.npcActions); i++) { + play->csCtx.npcActions[i] = 0; } - if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) < 0 && !globalCtx->envCtx.sunMoonDisabled) { - globalCtx->envCtx.sunMoonDisabled = true; + if (Object_GetIndex(&play->objectCtx, OBJECT_GAMEPLAY_FIELD_KEEP) < 0 && !play->envCtx.sunMoonDisabled) { + play->envCtx.sunMoonDisabled = true; // "Sun setting other than field keep! So forced release!" osSyncPrintf(VT_COL(YELLOW, BLACK) "\n\nフィールド常駐以外、太陽設定!よって強制解除!\n" VT_RST); } @@ -600,7 +600,7 @@ void func_8006FB94(EnvironmentContext* envCtx, u8 unused) { extern SkyboxTableEntry sSkyboxTable[]; -void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, EnvironmentContext* envCtx, SkyboxContext* skyboxCtx) { +void Environment_UpdateSkybox(PlayState* play, u8 skyboxId, EnvironmentContext* envCtx, SkyboxContext* skyboxCtx) { size_t size; u8 i; u8 newSkybox1Index = 0xFF; @@ -785,38 +785,38 @@ void Environment_UpdateSkybox(GlobalContext* globalCtx, u8 skyboxId, Environment } } -void Environment_EnableUnderwaterLights(GlobalContext* globalCtx, s32 waterLightsIndex) { +void Environment_EnableUnderwaterLights(PlayState* play, s32 waterLightsIndex) { if (waterLightsIndex == 0x1F) { waterLightsIndex = 0; // "Underwater color is not set in the water poly data!" osSyncPrintf(VT_COL(YELLOW, BLACK) "\n水ポリゴンデータに水中カラーが設定されておりません!" VT_RST); } - if (!globalCtx->envCtx.indoors) { - D_8011FB34 = globalCtx->envCtx.unk_20; + if (!play->envCtx.indoors) { + D_8011FB34 = play->envCtx.unk_20; - if (globalCtx->envCtx.unk_1F != waterLightsIndex) { - globalCtx->envCtx.unk_1F = waterLightsIndex; - globalCtx->envCtx.unk_20 = waterLightsIndex; + if (play->envCtx.unk_1F != waterLightsIndex) { + play->envCtx.unk_1F = waterLightsIndex; + play->envCtx.unk_20 = waterLightsIndex; } } else { - globalCtx->envCtx.blendIndoorLights = false; // instantly switch to water lights - globalCtx->envCtx.unk_BF = waterLightsIndex; + play->envCtx.blendIndoorLights = false; // instantly switch to water lights + play->envCtx.unk_BF = waterLightsIndex; } } -void Environment_DisableUnderwaterLights(GlobalContext* globalCtx) { - if (!globalCtx->envCtx.indoors) { - globalCtx->envCtx.unk_1F = D_8011FB34; - globalCtx->envCtx.unk_20 = D_8011FB34; +void Environment_DisableUnderwaterLights(PlayState* play) { + if (!play->envCtx.indoors) { + play->envCtx.unk_1F = D_8011FB34; + play->envCtx.unk_20 = D_8011FB34; } else { - globalCtx->envCtx.blendIndoorLights = false; // instantly switch to previous lights - globalCtx->envCtx.unk_BF = 0xFF; - globalCtx->envCtx.unk_D8 = 1.0f; + play->envCtx.blendIndoorLights = false; // instantly switch to previous lights + play->envCtx.unk_BF = 0xFF; + play->envCtx.unk_D8 = 1.0f; } } -void Environment_PrintDebugInfo(GlobalContext* globalCtx, Gfx** gfx) { +void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) { GfxPrint printer; s32 pad[2]; @@ -874,10 +874,10 @@ void Environment_PrintDebugInfo(GlobalContext* globalCtx, Gfx** gfx) { #define TIME_ENTRY_1F (D_8011FB48[envCtx->unk_1F][i]) #define TIME_ENTRY_20 (D_8011FB48[envCtx->unk_20][i]) -void func_80075B44(GlobalContext* globalCtx); -void func_800766C4(GlobalContext* globalCtx); +void func_80075B44(PlayState* play); +void func_800766C4(PlayState* play); -void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, LightContext* lightCtx, +void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, PauseContext* pauseCtx, MessageContext* msgCtx, GameOverContext* gameOverCtx, GraphicsContext* gfxCtx) { f32 sp8C; @@ -885,24 +885,24 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li u16 i; u16 j; u16 time; - EnvLightSettings* lightSettingsList = globalCtx->envCtx.lightSettingsList; + EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList; s32 adjustment; if ((((void)0, gSaveContext.gameMode) != 0) && (((void)0, gSaveContext.gameMode) != 3)) { - func_800AA16C(globalCtx); + func_800AA16C(play); } if (pauseCtx->state == 0) { - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { - if (globalCtx->skyboxId == SKYBOX_NORMAL_SKY) { - globalCtx->skyboxCtx.rot.y -= 0.001f; - } else if (globalCtx->skyboxId == SKYBOX_CUTSCENE_MAP) { - globalCtx->skyboxCtx.rot.y -= 0.005f; + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + if (play->skyboxId == SKYBOX_NORMAL_SKY) { + play->skyboxCtx.rot.y -= 0.001f; + } else if (play->skyboxId == SKYBOX_CUTSCENE_MAP) { + play->skyboxCtx.rot.y -= 0.005f; } } - func_800766C4(globalCtx); // increments or decrements unk_EE[1] depending on some condition - func_80075B44(globalCtx); // updates bgm/sfx and other things as the day progresses + func_800766C4(play); // increments or decrements unk_EE[1] depending on some condition + func_80075B44(play); // updates bgm/sfx and other things as the day progresses if (((void)0, gSaveContext.nextDayTime) >= 0xFF00 && ((void)0, gSaveContext.nextDayTime) != 0xFFFF) { gSaveContext.nextDayTime -= 0x10; @@ -919,8 +919,8 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li if ((pauseCtx->state == 0) && (gameOverCtx->state == GAMEOVER_INACTIVE)) { if (((msgCtx->msgLength == 0) && (msgCtx->msgMode == 0)) || (((void)0, gSaveContext.gameMode) == 3)) { - if ((envCtx->unk_1A == 0) && !FrameAdvance_IsEnabled(globalCtx) && - (globalCtx->transitionMode == 0 || ((void)0, gSaveContext.gameMode) != 0)) { + if ((envCtx->unk_1A == 0) && !FrameAdvance_IsEnabled(play) && + (play->transitionMode == 0 || ((void)0, gSaveContext.gameMode) != 0)) { if (IS_DAY || gTimeIncrement >= 0x190) { gSaveContext.dayTime += gTimeIncrement; @@ -950,15 +950,15 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li Gfx* displayList; Gfx* prevDisplayList; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); prevDisplayList = POLY_OPA_DISP; displayList = Graph_GfxPlusOne(POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, displayList); - Environment_PrintDebugInfo(globalCtx, &displayList); + Environment_PrintDebugInfo(play, &displayList); gSPEndDisplayList(displayList++); Graph_BranchDlist(prevDisplayList, displayList); POLY_OPA_DISP = displayList; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if ((envCtx->unk_BF != 0xFF) && (envCtx->unk_DC != 2) && (envCtx->unk_BD != envCtx->unk_BF) && @@ -1294,35 +1294,35 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li } } -void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { +void Environment_DrawSunAndMoon(PlayState* play) { f32 alpha; f32 color; f32 y; f32 scale; f32 temp; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if (globalCtx->csCtx.state != 0) { - Math_SmoothStepToF(&globalCtx->envCtx.sunPos.x, + if (play->csCtx.state != 0) { + Math_SmoothStepToF(&play->envCtx.sunPos.x, -(Math_SinS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f, 1.0f, 0.8f, 0.8f); - Math_SmoothStepToF(&globalCtx->envCtx.sunPos.y, + Math_SmoothStepToF(&play->envCtx.sunPos.y, (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f, 1.0f, 0.8f, 0.8f); //! @bug This should be z. - Math_SmoothStepToF(&globalCtx->envCtx.sunPos.y, + Math_SmoothStepToF(&play->envCtx.sunPos.y, (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 20.0f) * 25.0f, 1.0f, 0.8f, 0.8f); } else { - globalCtx->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.y = +(Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.z = +(Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 20.0f) * 25.0f; + play->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; + play->envCtx.sunPos.y = +(Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; + play->envCtx.sunPos.z = +(Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 20.0f) * 25.0f; } if (gSaveContext.entranceIndex != 0xCD || ((void)0, gSaveContext.sceneSetupIndex) != 5) { - Matrix_Translate(globalCtx->view.eye.x + globalCtx->envCtx.sunPos.x, - globalCtx->view.eye.y + globalCtx->envCtx.sunPos.y, - globalCtx->view.eye.z + globalCtx->envCtx.sunPos.z, MTXMODE_NEW); + Matrix_Translate(play->view.eye.x + play->envCtx.sunPos.x, + play->view.eye.y + play->envCtx.sunPos.y, + play->view.eye.z + play->envCtx.sunPos.z, MTXMODE_NEW); - y = globalCtx->envCtx.sunPos.y / 25.0f; + y = play->envCtx.sunPos.y / 25.0f; temp = y / 80.0f; alpha = temp * 255.0f; @@ -1349,8 +1349,8 @@ void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { scale = (color * 2.0f) + 10.0f; Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); - func_80093AD0(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); + func_80093AD0(play->state.gfxCtx); static Vtx vertices[] = { VTX(-31, -31, 0, 0, 0, 255, 255, 255, 255), @@ -1371,9 +1371,9 @@ void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { gSPVertex(POLY_OPA_DISP++, vertices, 4, 0); gSP2Triangles(POLY_OPA_DISP++, 0, 1, 2, 0, 2, 1, 3, 0); - Matrix_Translate(globalCtx->view.eye.x - globalCtx->envCtx.sunPos.x, - globalCtx->view.eye.y - globalCtx->envCtx.sunPos.y, - globalCtx->view.eye.z - globalCtx->envCtx.sunPos.z, MTXMODE_NEW); + Matrix_Translate(play->view.eye.x - play->envCtx.sunPos.x, + play->view.eye.y - play->envCtx.sunPos.y, + play->view.eye.z - play->envCtx.sunPos.z, MTXMODE_NEW); color = -y / 120.0f; color = CLAMP_MIN(color, 0.0f); @@ -1387,8 +1387,8 @@ void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { alpha = temp * 255.0f; if (alpha > 0.0f) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); - func_8009398C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); + func_8009398C(play->state.gfxCtx); gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 240, 255, 180, alpha); gDPSetEnvColor(POLY_OPA_DISP++, 80, 70, 20, alpha); @@ -1396,20 +1396,20 @@ void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Environment_DrawSunLensFlare(GlobalContext* globalCtx, EnvironmentContext* envCtx, View* view, +void Environment_DrawSunLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f pos, s32 unused) { - if ((globalCtx->envCtx.unk_EE[1] == 0) && (globalCtx->envCtx.unk_17 == 0)) { - Environment_DrawLensFlare(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, pos, 2000, + if ((play->envCtx.unk_EE[1] == 0) && (play->envCtx.unk_17 == 0)) { + Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, pos, 2000, 370, Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f, 400, 1); } } f32 sLensFlareScales[] = { 23.0f, 12.0f, 7.0f, 5.0f, 3.0f, 10.0f, 6.0f, 2.0f, 3.0f, 1.0f }; -void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* envCtx, View* view, +void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, Vec3f pos, s32 unused, s16 scale, f32 colorIntensity, s16 screenFillAlpha, u8 arg9) { s16 i; @@ -1505,7 +1505,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env if (!(cosAngle < 0.0f)) { if (arg9) { u32 shrink = ShrinkWindow_GetCurrentVal(); - func_800C016C(globalCtx, &pos, &screenPos); + func_800C016C(play, &pos, &screenPos); D_8015FD7E = (s16)screenPos.x; D_8015FD80 = (s16)screenPos.y - 5.0f; if (D_8011FB44 != 0xFFFC || screenPos.x < 0.0f || screenPos.y < shrink || screenPos.x > SCREEN_WIDTH || @@ -1520,7 +1520,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); if (arg9) { - temp = Environment_LerpWeight(60, 15, globalCtx->view.fovy); + temp = Environment_LerpWeight(60, 15, play->view.fovy); } Matrix_Translate(-posDirX * i * dist, -posDirY * i * dist, -posDirZ * i * dist, MTXMODE_APPLY); @@ -1540,7 +1540,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env alpha = alpha * lensFlareAlphas[i]; alpha = CLAMP_MIN(alpha, 0.0f); - fogInfluence = (996 - globalCtx->lightCtx.fogNear) / 50.0f; + fogInfluence = (996 - play->lightCtx.fogNear) / 50.0f; fogInfluence = CLAMP_MAX(fogInfluence, 1.0f); @@ -1588,7 +1588,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env alpha = alpha * screenFillAlpha; alpha = CLAMP_MIN(alpha, 0.0f); - fogInfluence = (996 - globalCtx->lightCtx.fogNear) / 50.0f; + fogInfluence = (996 - play->lightCtx.fogNear) / 50.0f; fogInfluence = CLAMP_MAX(fogInfluence, 1.0f); @@ -1622,7 +1622,7 @@ f32 func_800746DC(void) { return Rand_ZeroOne() - 0.5f; } -void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* gfxCtx) { +void Environment_DrawRain(PlayState* play, View* view, GraphicsContext* gfxCtx) { s16 i; s32 pad; Vec3f vec; @@ -1639,9 +1639,9 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* f32 z280; Vec3f unused = { 0.0f, 0.0f, 0.0f }; Vec3f windDirection = { 0.0f, 0.0f, 0.0f }; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); - if (!(globalCtx->cameraPtrs[0]->unk_14C & 0x100) && (globalCtx->envCtx.unk_EE[2] == 0)) { + if (!(play->cameraPtrs[0]->unk_14C & 0x100) && (play->envCtx.unk_EE[2] == 0)) { OPEN_DISPS(gfxCtx); vec.x = view->lookAt.x - view->eye.x; @@ -1661,14 +1661,14 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* x280 = view->eye.x + temp1 * 280.0f; z280 = view->eye.z + temp3 * 280.0f; - if (globalCtx->envCtx.unk_EE[1]) { + if (play->envCtx.unk_EE[1]) { gDPPipeSync(POLY_XLU_DISP++); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 150, 255, 255, 30); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 20); } // draw rain drops - for (i = 0; i < globalCtx->envCtx.unk_EE[1]; i++) { + for (i = 0; i < play->envCtx.unk_EE[1]; i++) { FrameInterpolation_RecordOpenChild("Rain Drop", i); temp2 = Rand_ZeroOne(); @@ -1678,9 +1678,9 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* Matrix_Translate((temp2 - 0.7f) * 100.0f + x50, (temp1 - 0.7f) * 100.0f + y50, (temp3 - 0.7f) * 100.0f + z50, MTXMODE_NEW); - windDirection.x = globalCtx->envCtx.windDirection.x; - windDirection.y = globalCtx->envCtx.windDirection.y; - windDirection.z = globalCtx->envCtx.windDirection.z; + windDirection.x = play->envCtx.windDirection.x; + windDirection.y = play->envCtx.windDirection.y; + windDirection.z = play->envCtx.windDirection.z; vec.x = windDirection.x; vec.y = windDirection.y + 500.0f + Rand_ZeroOne() * 200.0f; @@ -1704,7 +1704,7 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* if (player->actor.world.pos.y < view->eye.y) { u8 firstDone = false; - for (i = 0; i < globalCtx->envCtx.unk_EE[1]; i++) { + for (i = 0; i < play->envCtx.unk_EE[1]; i++) { FrameInterpolation_RecordOpenChild("Droplet Ring", i); if (!firstDone) { @@ -1736,16 +1736,16 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* } } -void func_80074CE8(GlobalContext* globalCtx, u32 arg1) { - if ((globalCtx->envCtx.unk_BD != arg1) && (globalCtx->envCtx.unk_D8 >= 1.0f) && - (globalCtx->envCtx.unk_BF == 0xFF)) { +void func_80074CE8(PlayState* play, u32 arg1) { + if ((play->envCtx.unk_BD != arg1) && (play->envCtx.unk_D8 >= 1.0f) && + (play->envCtx.unk_BF == 0xFF)) { if (arg1 > 30) { arg1 = 0; } - globalCtx->envCtx.unk_D8 = 0.0f; - globalCtx->envCtx.unk_BE = globalCtx->envCtx.unk_BD; - globalCtx->envCtx.unk_BD = arg1; + play->envCtx.unk_D8 = 0.0f; + play->envCtx.unk_BE = play->envCtx.unk_BD; + play->envCtx.unk_BD = arg1; } } @@ -1761,18 +1761,18 @@ void func_80074CE8(GlobalContext* globalCtx, u32 arg1) { * * An example usage of a filter is to dim the skybox in cloudy conditions. */ -void Environment_DrawSkyboxFilters(GlobalContext* globalCtx) { - if (((globalCtx->skyboxId != SKYBOX_NONE) && (globalCtx->lightCtx.fogNear < 980)) || - (globalCtx->skyboxId == SKYBOX_UNSET_1D)) { +void Environment_DrawSkyboxFilters(PlayState* play) { + if (((play->skyboxId != SKYBOX_NONE) && (play->lightCtx.fogNear < 980)) || + (play->skyboxId == SKYBOX_UNSET_1D)) { f32 alpha; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_800938B4(globalCtx->state.gfxCtx); + func_800938B4(play->state.gfxCtx); - alpha = (1000 - globalCtx->lightCtx.fogNear) * 0.02f; + alpha = (1000 - play->lightCtx.fogNear) * 0.02f; - if (globalCtx->skyboxId == SKYBOX_UNSET_1D) { + if (play->skyboxId == SKYBOX_UNSET_1D) { alpha = 1.0f; } @@ -1780,38 +1780,38 @@ void Environment_DrawSkyboxFilters(GlobalContext* globalCtx) { alpha = 1.0f; } - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, globalCtx->lightCtx.fogColor[0], globalCtx->lightCtx.fogColor[1], - globalCtx->lightCtx.fogColor[2], 255.0f * alpha); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, play->lightCtx.fogColor[0], play->lightCtx.fogColor[1], + play->lightCtx.fogColor[2], 255.0f * alpha); gDPFillRectangle(POLY_OPA_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } - if (globalCtx->envCtx.customSkyboxFilter) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (play->envCtx.customSkyboxFilter) { + OPEN_DISPS(play->state.gfxCtx); - func_800938B4(globalCtx->state.gfxCtx); - gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, globalCtx->envCtx.skyboxFilterColor[0], - globalCtx->envCtx.skyboxFilterColor[1], globalCtx->envCtx.skyboxFilterColor[2], - globalCtx->envCtx.skyboxFilterColor[3]); + func_800938B4(play->state.gfxCtx); + gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, play->envCtx.skyboxFilterColor[0], + play->envCtx.skyboxFilterColor[1], play->envCtx.skyboxFilterColor[2], + play->envCtx.skyboxFilterColor[3]); gDPFillRectangle(POLY_OPA_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } -void Environment_DrawLightningFlash(GlobalContext* globalCtx, u8 red, u8 green, u8 blue, u8 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void Environment_DrawLightningFlash(PlayState* play, u8 red, u8 green, u8 blue, u8 alpha) { + OPEN_DISPS(play->state.gfxCtx); - func_800938B4(globalCtx->state.gfxCtx); + func_800938B4(play->state.gfxCtx); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, red, green, blue, alpha); gDPFillRectangle(POLY_OPA_DISP++, 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { - if (globalCtx->envCtx.lightningMode != LIGHTNING_MODE_OFF) { +void Environment_UpdateLightningStrike(PlayState* play) { + if (play->envCtx.lightningMode != LIGHTNING_MODE_OFF) { switch (gLightningStrike.state) { case LIGHTNING_STRIKE_WAIT: // every frame theres a 10% chance of the timer advancing 50 units @@ -1828,7 +1828,7 @@ void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { gLightningStrike.flashAlphaTarget = 200; gLightningStrike.delayTimer = 0.0f; - Environment_AddLightningBolts(globalCtx, + Environment_AddLightningBolts(play, (u8)(Rand_ZeroOne() * (ARRAY_COUNT(sLightningBolts) - 0.1f)) + 1); sLightningFlashAlpha = 0; gLightningStrike.state++; @@ -1839,9 +1839,9 @@ void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { gLightningStrike.flashGreen = 200; gLightningStrike.flashBlue = 255; - globalCtx->envCtx.adjAmbientColor[0] += 80; - globalCtx->envCtx.adjAmbientColor[1] += 80; - globalCtx->envCtx.adjAmbientColor[2] += 100; + play->envCtx.adjAmbientColor[0] += 80; + play->envCtx.adjAmbientColor[1] += 80; + play->envCtx.adjAmbientColor[2] += 100; sLightningFlashAlpha += 100; @@ -1852,26 +1852,26 @@ void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { } break; case LIGHTNING_STRIKE_END: - if (globalCtx->envCtx.adjAmbientColor[0] > 0) { - globalCtx->envCtx.adjAmbientColor[0] -= 10; - globalCtx->envCtx.adjAmbientColor[1] -= 10; + if (play->envCtx.adjAmbientColor[0] > 0) { + play->envCtx.adjAmbientColor[0] -= 10; + play->envCtx.adjAmbientColor[1] -= 10; } - if (globalCtx->envCtx.adjAmbientColor[2] > 0) { - globalCtx->envCtx.adjAmbientColor[2] -= 10; + if (play->envCtx.adjAmbientColor[2] > 0) { + play->envCtx.adjAmbientColor[2] -= 10; } sLightningFlashAlpha -= 10; if (sLightningFlashAlpha <= gLightningStrike.flashAlphaTarget) { - globalCtx->envCtx.adjAmbientColor[0] = 0; - globalCtx->envCtx.adjAmbientColor[1] = 0; - globalCtx->envCtx.adjAmbientColor[2] = 0; + play->envCtx.adjAmbientColor[0] = 0; + play->envCtx.adjAmbientColor[1] = 0; + play->envCtx.adjAmbientColor[2] = 0; gLightningStrike.state = LIGHTNING_STRIKE_WAIT; - if (globalCtx->envCtx.lightningMode == LIGHTNING_MODE_LAST) { - globalCtx->envCtx.lightningMode = LIGHTNING_MODE_OFF; + if (play->envCtx.lightningMode == LIGHTNING_MODE_LAST) { + play->envCtx.lightningMode = LIGHTNING_MODE_OFF; } } break; @@ -1879,7 +1879,7 @@ void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { } if (gLightningStrike.state != LIGHTNING_STRIKE_WAIT) { - Environment_DrawLightningFlash(globalCtx, gLightningStrike.flashRed, gLightningStrike.flashGreen, + Environment_DrawLightningFlash(play, gLightningStrike.flashRed, gLightningStrike.flashGreen, gLightningStrike.flashBlue, sLightningFlashAlpha); } } @@ -1888,7 +1888,7 @@ void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { * Request the number of lightning bolts specified by `num` * Note: only 3 lightning bolts can be active at the same time. */ -void Environment_AddLightningBolts(GlobalContext* globalCtx, u8 num) { +void Environment_AddLightningBolts(PlayState* play, u8 num) { s16 boltsAdded = 0; s16 i; @@ -1907,7 +1907,7 @@ void Environment_AddLightningBolts(GlobalContext* globalCtx, u8 num) { /** * Draw any active lightning bolt entries contained in `sLightningBolts` */ -void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { +void Environment_DrawLightning(PlayState* play, s32 unused) { static void* lightningTextures[] = { gEffLightning1Tex, gEffLightning2Tex, gEffLightning3Tex, gEffLightning4Tex, gEffLightning5Tex, gEffLightning6Tex, @@ -1922,22 +1922,22 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { Vec3f unused1 = { 0.0f, 0.0f, 0.0f }; Vec3f unused2 = { 0.0f, 0.0f, 0.0f }; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { FrameInterpolation_RecordOpenChild("Lightning Bolt", i); switch (sLightningBolts[i].state) { case LIGHTNING_BOLT_START: - dx = globalCtx->view.lookAt.x - globalCtx->view.eye.x; - dz = globalCtx->view.lookAt.z - globalCtx->view.eye.z; + dx = play->view.lookAt.x - play->view.eye.x; + dz = play->view.lookAt.z - play->view.eye.z; x = dx / sqrtf(SQ(dx) + SQ(dz)); z = dz / sqrtf(SQ(dx) + SQ(dz)); - sLightningBolts[i].pos.x = globalCtx->view.eye.x + x * 9500.0f; + sLightningBolts[i].pos.x = play->view.eye.x + x * 9500.0f; sLightningBolts[i].pos.y = Rand_ZeroOne() * 1000.0f + 4000.0f; - sLightningBolts[i].pos.z = globalCtx->view.eye.z + z * 9500.0f; + sLightningBolts[i].pos.z = play->view.eye.z + z * 9500.0f; sLightningBolts[i].offset.x = (Rand_ZeroOne() - 0.5f) * 5000.0f; sLightningBolts[i].offset.y = 0.0f; @@ -1974,10 +1974,10 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { Matrix_Scale(22.0f, 100.0f, 22.0f, MTXMODE_APPLY); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, 255, 255, 255, 128); gDPSetEnvColor(POLY_XLU_DISP++, 0, 255, 255, 128); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(lightningTextures[sLightningBolts[i].textureIndex])); - func_80094C50(globalCtx->state.gfxCtx); + func_80094C50(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, SEG_ADDR(1, 0), G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffLightningDL); } @@ -1985,11 +1985,11 @@ void Environment_DrawLightning(GlobalContext* globalCtx, s32 unused) { FrameInterpolation_RecordCloseChild(); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Environment_PlaySceneSequence(GlobalContext* globalCtx) { - globalCtx->envCtx.unk_E0 = 0xFF; +void Environment_PlaySceneSequence(PlayState* play) { + play->envCtx.unk_E0 = 0xFF; // both lost woods exits on the bridge from kokiri to hyrule field if (((void)0, gSaveContext.entranceIndex) == 0x4DE || ((void)0, gSaveContext.entranceIndex) == 0x5E0) { @@ -1999,94 +1999,94 @@ void Environment_PlaySceneSequence(GlobalContext* globalCtx) { Audio_QueueSeqCmd(SEQ_PLAYER_BGM_MAIN << 24 | (s32)((void)0, gSaveContext.forcedSeqId)); } gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; - } else if (globalCtx->sequenceCtx.seqId == NA_BGM_NO_MUSIC) { - if (globalCtx->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { + } else if (play->sequenceCtx.seqId == NA_BGM_NO_MUSIC) { + if (play->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { return; } - if (((void)0, gSaveContext.natureAmbienceId) != globalCtx->sequenceCtx.natureAmbienceId) { - Audio_PlayNatureAmbienceSequence(globalCtx->sequenceCtx.natureAmbienceId); + if (((void)0, gSaveContext.natureAmbienceId) != play->sequenceCtx.natureAmbienceId) { + Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); } - } else if (globalCtx->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { + } else if (play->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { // "BGM Configuration" - osSyncPrintf("\n\n\nBGM設定game_play->sound_info.BGM=[%d] old_bgm=[%d]\n\n", globalCtx->sequenceCtx.seqId, + osSyncPrintf("\n\n\nBGM設定game_play->sound_info.BGM=[%d] old_bgm=[%d]\n\n", play->sequenceCtx.seqId, ((void)0, gSaveContext.seqId)); - if (((void)0, gSaveContext.seqId) != globalCtx->sequenceCtx.seqId) { - func_800F5550(globalCtx->sequenceCtx.seqId); + if (((void)0, gSaveContext.seqId) != play->sequenceCtx.seqId) { + func_800F5550(play->sequenceCtx.seqId); } } else if (((void)0, gSaveContext.dayTime) > 0x4AAA && ((void)0, gSaveContext.dayTime) < 0xB71D) { - if (((void)0, gSaveContext.seqId) != globalCtx->sequenceCtx.seqId) { - func_800F5550(globalCtx->sequenceCtx.seqId); + if (((void)0, gSaveContext.seqId) != play->sequenceCtx.seqId) { + func_800F5550(play->sequenceCtx.seqId); } - globalCtx->envCtx.unk_E0 = 1; + play->envCtx.unk_E0 = 1; } else { - if (((void)0, gSaveContext.natureAmbienceId) != globalCtx->sequenceCtx.natureAmbienceId) { - Audio_PlayNatureAmbienceSequence(globalCtx->sequenceCtx.natureAmbienceId); + if (((void)0, gSaveContext.natureAmbienceId) != play->sequenceCtx.natureAmbienceId) { + Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); } if (((void)0, gSaveContext.dayTime) > 0xB71C && ((void)0, gSaveContext.dayTime) < 0xCAAC) { - globalCtx->envCtx.unk_E0 = 3; + play->envCtx.unk_E0 = 3; } else if (((void)0, gSaveContext.dayTime) > 0xCAAC || ((void)0, gSaveContext.dayTime) < 0x4555) { - globalCtx->envCtx.unk_E0 = 5; + play->envCtx.unk_E0 = 5; } else { - globalCtx->envCtx.unk_E0 = 7; + play->envCtx.unk_E0 = 7; } } osSyncPrintf("\n-----------------\n", ((void)0, gSaveContext.forcedSeqId)); osSyncPrintf("\n 強制BGM=[%d]", ((void)0, gSaveContext.forcedSeqId)); // "Forced BGM" - osSyncPrintf("\n BGM=[%d]", globalCtx->sequenceCtx.seqId); - osSyncPrintf("\n エンブ=[%d]", globalCtx->sequenceCtx.natureAmbienceId); - osSyncPrintf("\n status=[%d]", globalCtx->envCtx.unk_E0); + osSyncPrintf("\n BGM=[%d]", play->sequenceCtx.seqId); + osSyncPrintf("\n エンブ=[%d]", play->sequenceCtx.natureAmbienceId); + osSyncPrintf("\n status=[%d]", play->envCtx.unk_E0); - Audio_SetEnvReverb(globalCtx->roomCtx.curRoom.echo); + Audio_SetEnvReverb(play->roomCtx.curRoom.echo); } // updates bgm/sfx and other things as the day progresses -void func_80075B44(GlobalContext* globalCtx) { - switch (globalCtx->envCtx.unk_E0) { +void func_80075B44(PlayState* play) { + switch (play->envCtx.unk_E0) { case 0: Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_4 << 4 | NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_1, 0); - if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0) { + if (play->envCtx.unk_EE[0] == 0 && play->envCtx.unk_F2[0] == 0) { osSyncPrintf("\n\n\nNa_StartMorinigBgm\n\n"); - func_800F5510(globalCtx->sequenceCtx.seqId); + func_800F5510(play->sequenceCtx.seqId); } - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; break; case 1: if (gSaveContext.dayTime > 0xB71C) { - if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0) { + if (play->envCtx.unk_EE[0] == 0 && play->envCtx.unk_F2[0] == 0) { Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xF000FF); } - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; } break; case 2: if (gSaveContext.dayTime > 0xC000) { func_800788CC(NA_SE_EV_DOG_CRY_EVENING); - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; } break; case 3: - if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0) { - Audio_PlayNatureAmbienceSequence(globalCtx->sequenceCtx.natureAmbienceId); + if (play->envCtx.unk_EE[0] == 0 && play->envCtx.unk_F2[0] == 0) { + Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_1, 1); } - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; break; case 4: if (gSaveContext.dayTime > 0xCAAB) { - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; } break; case 5: Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_1, 0); - if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0) { + if (play->envCtx.unk_EE[0] == 0 && play->envCtx.unk_F2[0] == 0) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_1 << 4 | NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_1, 1); } - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; break; case 6: if ((gSaveContext.dayTime < 0xCAAC) && (gSaveContext.dayTime > 0x4555)) { @@ -2094,35 +2094,35 @@ void func_80075B44(GlobalContext* globalCtx) { gSaveContext.bgsDayCount++; gSaveContext.dogIsLost = true; func_80078884(NA_SE_EV_CHICKEN_CRY_M); - if ((Inventory_ReplaceItem(globalCtx, ITEM_WEIRD_EGG, ITEM_CHICKEN) || - Inventory_HatchPocketCucco(globalCtx)) && - globalCtx->csCtx.state == 0 && !Player_InCsMode(globalCtx)) { - Message_StartTextbox(globalCtx, 0x3066, NULL); + if ((Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN) || + Inventory_HatchPocketCucco(play)) && + play->csCtx.state == 0 && !Player_InCsMode(play)) { + Message_StartTextbox(play, 0x3066, NULL); } - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; } break; case 7: Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_1 << 4 | NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_1, 0); - if (globalCtx->envCtx.unk_EE[0] == 0 && globalCtx->envCtx.unk_F2[0] == 0) + if (play->envCtx.unk_EE[0] == 0 && play->envCtx.unk_F2[0] == 0) { // OTRTODO: This is where corrupt audio happens. Commenting this out seems to not introduce any side effects? // Further investigation is needed... //Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_4 << 4 | NATURE_CHANNEL_CRITTER_5, //CHANNEL_IO_PORT_1, 1); } - globalCtx->envCtx.unk_E0++; + play->envCtx.unk_E0++; break; case 8: if (gSaveContext.dayTime > 0x4AAB) { - globalCtx->envCtx.unk_E0 = 0; + play->envCtx.unk_E0 = 0; } break; } } -void Environment_DrawCustomLensFlare(GlobalContext* globalCtx) { +void Environment_DrawCustomLensFlare(PlayState* play) { Vec3f pos; if (gCustomLensFlareOn) { @@ -2130,31 +2130,31 @@ void Environment_DrawCustomLensFlare(GlobalContext* globalCtx) { pos.y = gCustomLensFlarePos.y; pos.z = gCustomLensFlarePos.z; - Environment_DrawLensFlare(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, pos, + Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, pos, gLensFlareUnused, gLensFlareScale, gLensFlareColorIntensity, gLensFlareScreenFillAlpha, 0); } } -void Environment_InitGameOverLights(GlobalContext* globalCtx) { +void Environment_InitGameOverLights(PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); sGameOverLightsIntensity = 0; Lights_PointNoGlowSetInfo(&sNGameOverLightInfo, (s16)player->actor.world.pos.x - 10.0f, (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z - 10.0f, 0, 0, 0, 255); - sNGameOverLightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &sNGameOverLightInfo); + sNGameOverLightNode = LightContext_InsertLight(play, &play->lightCtx, &sNGameOverLightInfo); Lights_PointNoGlowSetInfo(&sSGameOverLightInfo, (s16)player->actor.world.pos.x + 10.0f, (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z + 10.0f, 0, 0, 0, 255); - sSGameOverLightNode = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &sSGameOverLightInfo); + sSGameOverLightNode = LightContext_InsertLight(play, &play->lightCtx, &sSGameOverLightInfo); } -void Environment_FadeInGameOverLights(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Environment_FadeInGameOverLights(PlayState* play) { + Player* player = GET_PLAYER(play); s16 i; Lights_PointNoGlowSetInfo(&sNGameOverLightInfo, (s16)player->actor.world.pos.x - 10.0f, @@ -2168,33 +2168,33 @@ void Environment_FadeInGameOverLights(GlobalContext* globalCtx) { sGameOverLightsIntensity += 2; } - if (func_800C0CB8(globalCtx)) { + if (func_800C0CB8(play)) { for (i = 0; i < 3; i++) { - if (globalCtx->envCtx.adjAmbientColor[i] > -255) { - globalCtx->envCtx.adjAmbientColor[i] -= 12; - globalCtx->envCtx.adjLight1Color[i] -= 12; + if (play->envCtx.adjAmbientColor[i] > -255) { + play->envCtx.adjAmbientColor[i] -= 12; + play->envCtx.adjLight1Color[i] -= 12; } - globalCtx->envCtx.adjFogColor[i] = -255; + play->envCtx.adjFogColor[i] = -255; } - if (globalCtx->envCtx.lightSettings.fogFar + globalCtx->envCtx.adjFogFar > 900) { - globalCtx->envCtx.adjFogFar -= 100; + if (play->envCtx.lightSettings.fogFar + play->envCtx.adjFogFar > 900) { + play->envCtx.adjFogFar -= 100; } - if (globalCtx->envCtx.lightSettings.fogNear + globalCtx->envCtx.adjFogNear > 950) { - globalCtx->envCtx.adjFogNear -= 10; + if (play->envCtx.lightSettings.fogNear + play->envCtx.adjFogNear > 950) { + play->envCtx.adjFogNear -= 10; } } else { - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; - globalCtx->envCtx.screenFillColor[3] = sGameOverLightsIntensity; + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[3] = sGameOverLightsIntensity; } } -void Environment_FadeOutGameOverLights(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Environment_FadeOutGameOverLights(PlayState* play) { + Player* player = GET_PLAYER(play); s16 i; if (sGameOverLightsIntensity >= 3) { @@ -2204,8 +2204,8 @@ void Environment_FadeOutGameOverLights(GlobalContext* globalCtx) { } if (sGameOverLightsIntensity == 1) { - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, sNGameOverLightNode); - LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, sSGameOverLightNode); + LightContext_RemoveLight(play, &play->lightCtx, sNGameOverLightNode); + LightContext_RemoveLight(play, &play->lightCtx, sSGameOverLightNode); } else if (sGameOverLightsIntensity >= 2) { Lights_PointNoGlowSetInfo(&sNGameOverLightInfo, (s16)player->actor.world.pos.x - 10.0f, (s16)player->actor.world.pos.y + 10.0f, (s16)player->actor.world.pos.z - 10.0f, @@ -2215,34 +2215,34 @@ void Environment_FadeOutGameOverLights(GlobalContext* globalCtx) { sGameOverLightsIntensity, sGameOverLightsIntensity, sGameOverLightsIntensity, 255); } - if (func_800C0CB8(globalCtx)) { + if (func_800C0CB8(play)) { for (i = 0; i < 3; i++) { - Math_SmoothStepToS(&globalCtx->envCtx.adjAmbientColor[i], 0, 5, 12, 1); - Math_SmoothStepToS(&globalCtx->envCtx.adjLight1Color[i], 0, 5, 12, 1); - globalCtx->envCtx.adjFogColor[i] = 0; + Math_SmoothStepToS(&play->envCtx.adjAmbientColor[i], 0, 5, 12, 1); + Math_SmoothStepToS(&play->envCtx.adjLight1Color[i], 0, 5, 12, 1); + play->envCtx.adjFogColor[i] = 0; } - globalCtx->envCtx.adjFogFar = 0; - globalCtx->envCtx.adjFogNear = 0; + play->envCtx.adjFogFar = 0; + play->envCtx.adjFogNear = 0; } else { - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; - globalCtx->envCtx.screenFillColor[3] = sGameOverLightsIntensity; + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[3] = sGameOverLightsIntensity; if (sGameOverLightsIntensity == 0) { - globalCtx->envCtx.fillScreen = false; + play->envCtx.fillScreen = false; } } } -void func_800766C4(GlobalContext* globalCtx) { - u8 max = MAX(globalCtx->envCtx.unk_EE[0], globalCtx->envCtx.unk_F2[0]); +void func_800766C4(PlayState* play) { + u8 max = MAX(play->envCtx.unk_EE[0], play->envCtx.unk_F2[0]); - if (globalCtx->envCtx.unk_EE[1] != max && ((globalCtx->state.frames % 8) == 0)) { - if (globalCtx->envCtx.unk_EE[1] < max) { - globalCtx->envCtx.unk_EE[1] += 2; + if (play->envCtx.unk_EE[1] != max && ((play->state.frames % 8) == 0)) { + if (play->envCtx.unk_EE[1] < max) { + play->envCtx.unk_EE[1] += 2; } else { - globalCtx->envCtx.unk_EE[1] -= 2; + play->envCtx.unk_EE[1] -= 2; } } } @@ -2292,7 +2292,7 @@ Color_RGB8 sSandstormEnvColors[] = { u16 previousPatchedSandstormScreenSize = 0; -void Environment_PatchSandstorm(GlobalContext* globalCtx) { +void Environment_PatchSandstorm(PlayState* play) { if (previousPatchedSandstormScreenSize == ABS(OTRGetRectDimensionFromLeftEdge(0)) + ABS(OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH))) { return; } @@ -2308,11 +2308,11 @@ void Environment_PatchSandstorm(GlobalContext* globalCtx) { previousPatchedSandstormScreenSize = ABS(OTRGetRectDimensionFromLeftEdge(0)) + ABS(OTRGetRectDimensionFromRightEdge(SCREEN_WIDTH)); } -void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { +void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) { s32 primA1; s32 envA1; - s32 primA = globalCtx->envCtx.sandstormPrimA; - s32 envA = globalCtx->envCtx.sandstormEnvA; + s32 primA = play->envCtx.sandstormPrimA; + s32 envA = play->envCtx.sandstormEnvA; Color_RGBA8 primColor; Color_RGBA8 envColor; s32 pad; @@ -2321,15 +2321,15 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { u16 sp94; u16 sp92; - Environment_PatchSandstorm(globalCtx); + Environment_PatchSandstorm(play); switch (sandstormState) { case 3: - if ((globalCtx->sceneNum == SCENE_SPOT13) && (globalCtx->roomCtx.curRoom.num == 0)) { + if ((play->sceneNum == SCENE_SPOT13) && (play->roomCtx.curRoom.num == 0)) { envA1 = 0; - primA1 = (globalCtx->envCtx.sandstormEnvA > 128) ? 255 : globalCtx->envCtx.sandstormEnvA >> 1; + primA1 = (play->envCtx.sandstormEnvA > 128) ? 255 : play->envCtx.sandstormEnvA >> 1; } else { - primA1 = globalCtx->state.frames % 128; + primA1 = play->state.frames % 128; if (primA1 > 64) { primA1 = 128 - primA1; } @@ -2339,29 +2339,29 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { break; case 1: primA1 = 255; - envA1 = (globalCtx->envCtx.sandstormPrimA >= 255) ? 255 : 128; + envA1 = (play->envCtx.sandstormPrimA >= 255) ? 255 : 128; break; case 2: envA1 = 128; - if (globalCtx->envCtx.sandstormEnvA > 128) { + if (play->envCtx.sandstormEnvA > 128) { primA1 = 0xFF; } else { - primA1 = globalCtx->state.frames % 128; + primA1 = play->state.frames % 128; if (primA1 > 64) { primA1 = 128 - primA1; } primA1 += 73; } if ((primA1 >= primA) && (primA1 != 255)) { - globalCtx->envCtx.sandstormState = 3; + play->envCtx.sandstormState = 3; } break; case 4: envA1 = 0; - primA1 = (globalCtx->envCtx.sandstormEnvA > 128) ? 255 : globalCtx->envCtx.sandstormEnvA >> 1; + primA1 = (play->envCtx.sandstormEnvA > 128) ? 255 : play->envCtx.sandstormEnvA >> 1; if (primA == 0) { - globalCtx->envCtx.sandstormState = 0; + play->envCtx.sandstormState = 0; } break; } @@ -2380,14 +2380,14 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { } else { envA = envA + 9; } - globalCtx->envCtx.sandstormPrimA = primA; - globalCtx->envCtx.sandstormEnvA = envA; + play->envCtx.sandstormPrimA = primA; + play->envCtx.sandstormEnvA = envA; sp98 = (512.0f - (primA + envA)) * (3.0f / 128.0f); if (sp98 > 6.0f) { sp98 = 6.0f; } - if (globalCtx->envCtx.indoors || (globalCtx->envCtx.unk_BF != 0xFF)) { + if (play->envCtx.indoors || (play->envCtx.unk_BF != 0xFF)) { primColor.r = sSandstormPrimColors[1].r; primColor.g = sSandstormPrimColors[1].g; primColor.b = sSandstormPrimColors[1].b; @@ -2418,29 +2418,29 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { sp94 = (s32)(D_8015FDB0 * (9.0f / 6.0f)); sp92 = (s32)(D_8015FDB0 * (6.0f / 6.0f)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_XLU_DISP = func_80093F34(POLY_XLU_DISP); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); - gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, globalCtx->envCtx.sandstormPrimA); - gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, globalCtx->envCtx.sandstormEnvA); + gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA); + gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (u32)sp96 % 0x1000, 0, 0x200, 0x20, 1, (u32)sp94 % 0x1000, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (u32)sp96 % 0x1000, 0, 0x200, 0x20, 1, (u32)sp94 % 0x1000, 0xFFF - ((u32)sp92 % 0x1000), 0x100, 0x40)); gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); D_8015FDB0 += (s32)sp98; } -void Environment_AdjustLights(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { +void Environment_AdjustLights(PlayState* play, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { f32 temp; s32 i; - if (globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_5 && func_800C0CB8(globalCtx)) { + if (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_5 && func_800C0CB8(play)) { arg1 = CLAMP_MIN(arg1, 0.0f); arg1 = CLAMP_MAX(arg1, 1.0f); @@ -2449,18 +2449,18 @@ void Environment_AdjustLights(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 temp = 0.0f; } - globalCtx->envCtx.adjFogNear = (arg2 - globalCtx->envCtx.lightSettings.fogNear) * temp; + play->envCtx.adjFogNear = (arg2 - play->envCtx.lightSettings.fogNear) * temp; if (arg1 == 0.0f) { for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjFogColor[i] = 0; + play->envCtx.adjFogColor[i] = 0; } } else { temp = arg1 * 5.0f; temp = CLAMP_MAX(temp, 1.0f); for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjFogColor[i] = -(s16)(globalCtx->envCtx.lightSettings.fogColor[i] * temp); + play->envCtx.adjFogColor[i] = -(s16)(play->envCtx.lightSettings.fogColor[i] * temp); } } @@ -2471,8 +2471,8 @@ void Environment_AdjustLights(GlobalContext* globalCtx, f32 arg1, f32 arg2, f32 arg1 *= arg4; for (i = 0; i < 3; i++) { - globalCtx->envCtx.adjAmbientColor[i] = -(s16)(globalCtx->envCtx.lightSettings.ambientColor[i] * arg1); - globalCtx->envCtx.adjLight1Color[i] = -(s16)(globalCtx->envCtx.lightSettings.light1Color[i] * arg1); + play->envCtx.adjAmbientColor[i] = -(s16)(play->envCtx.lightSettings.ambientColor[i] * arg1); + play->envCtx.adjLight1Color[i] = -(s16)(play->envCtx.lightSettings.light1Color[i] * arg1); } } } @@ -2503,37 +2503,37 @@ s32 Environment_IsForcedSequenceDisabled(void) { return isDisabled; } -void Environment_PlayStormNatureAmbience(GlobalContext* globalCtx) { - if (globalCtx->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { +void Environment_PlayStormNatureAmbience(PlayState* play) { + if (play->sequenceCtx.natureAmbienceId == NATURE_ID_NONE) { Audio_PlayNatureAmbienceSequence(NATURE_ID_MARKET_NIGHT); } else { - Audio_PlayNatureAmbienceSequence(globalCtx->sequenceCtx.natureAmbienceId); + Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); } Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 1); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_1, 1); } -void Environment_StopStormNatureAmbience(GlobalContext* globalCtx) { +void Environment_StopStormNatureAmbience(PlayState* play) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 0); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_1, 0); if (func_800FA0B4(SEQ_PLAYER_BGM_MAIN) == NA_BGM_NATURE_AMBIENCE) { gSaveContext.seqId = NA_BGM_NATURE_SFX_RAIN; - Environment_PlaySceneSequence(globalCtx); + Environment_PlaySceneSequence(play); } } -void Environment_WarpSongLeave(GlobalContext* globalCtx) { +void Environment_WarpSongLeave(PlayState* play) { gWeatherMode = 0; gSaveContext.cutsceneIndex = 0; gSaveContext.respawnFlag = -3; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.nextTransition = 3; - switch (globalCtx->nextEntranceIndex) { + switch (play->nextEntranceIndex) { case 0x147: Flags_SetEventChkInf(0xB9); break; diff --git a/soh/src/code/z_lifemeter.c b/soh/src/code/z_lifemeter.c index 6e3bbb52b..be093af73 100644 --- a/soh/src/code/z_lifemeter.c +++ b/soh/src/code/z_lifemeter.c @@ -123,8 +123,8 @@ s16 sBeatingHeartsDDEnv[3]; s16 sHeartsDDPrim[2][3]; s16 sHeartsDDEnv[2][3]; -void HealthMeter_Init(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void HealthMeter_Init(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (CVar_GetS32("gHudColors", 1) == 2) { HeartInner = CVar_GetRGB("gCCHeartsPrim", HeartInner_ori); HeartDDInner = CVar_GetRGB("gCCDDHeartsPrim", HeartDDInner_ori); @@ -169,8 +169,8 @@ void HealthMeter_Init(GlobalContext* globalCtx) { sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = HeartDDInner.b; } -void HealthMeter_Update(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void HealthMeter_Update(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; f32 factor = interfaceCtx->unk_1FE * 0.1f; f32 ddFactor; s32 type = 0; @@ -328,13 +328,13 @@ void HealthMeter_Update(GlobalContext* globalCtx) { } -s32 func_80078E18(GlobalContext* globalCtx) { - gSaveContext.health = globalCtx->interfaceCtx.unk_226; +s32 func_80078E18(PlayState* play) { + gSaveContext.health = play->interfaceCtx.unk_226; return 1; } -s32 func_80078E34(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +s32 func_80078E34(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; interfaceCtx->unk_228 = 0x140; interfaceCtx->unk_226 += 0x10; @@ -347,8 +347,8 @@ s32 func_80078E34(GlobalContext* globalCtx) { return 0; } -s32 func_80078E84(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +s32 func_80078E84(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (interfaceCtx->unk_228 != 0) { interfaceCtx->unk_228--; @@ -357,7 +357,7 @@ s32 func_80078E84(GlobalContext* globalCtx) { interfaceCtx->unk_226 -= 0x10; if (interfaceCtx->unk_226 <= 0) { interfaceCtx->unk_226 = 0; - globalCtx->damagePlayer(globalCtx, -(gSaveContext.health + 1)); + play->damagePlayer(play, -(gSaveContext.health + 1)); return 1; } } @@ -419,7 +419,7 @@ s16 getHealthMeterYOffset() { } } -void HealthMeter_Draw(GlobalContext* globalCtx) { +void HealthMeter_Draw(PlayState* play) { s32 pad[5]; void* heartBgImg; u32 curColorSet; @@ -431,8 +431,8 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { f32 temp2; f32 temp3; f32 temp4; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; Vtx* sp154 = interfaceCtx->beatingHeartVtx; s32 curHeartFraction = gSaveContext.health % 0x10; s16 totalHeartCount = gSaveContext.healthCapacity / 0x10; @@ -673,16 +673,16 @@ void HealthMeter_Draw(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx); } -void HealthMeter_HandleCriticalAlarm(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void HealthMeter_HandleCriticalAlarm(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (interfaceCtx->unk_22C != 0) { interfaceCtx->unk_22A--; if (interfaceCtx->unk_22A <= 0) { interfaceCtx->unk_22A = 0; interfaceCtx->unk_22C = 0; - if (CVar_GetS32("gLowHpAlarm", 0) == 0 && !Player_InCsMode(globalCtx) && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && HealthMeter_IsCritical() && !Gameplay_InCsMode(globalCtx)) { + if (CVar_GetS32("gLowHpAlarm", 0) == 0 && !Player_InCsMode(play) && (play->pauseCtx.state == 0) && + (play->pauseCtx.debugState == 0) && HealthMeter_IsCritical() && !Play_InCsMode(play)) { func_80078884(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/soh/src/code/z_lights.c b/soh/src/code/z_lights.c index 57986baf8..740a0d9c8 100644 --- a/soh/src/code/z_lights.c +++ b/soh/src/code/z_lights.c @@ -205,8 +205,8 @@ s32 Lights_FreeNode(LightNode* light) { } } -void LightContext_Init(GlobalContext* globalCtx, LightContext* lightCtx) { - LightContext_InitList(globalCtx, lightCtx); +void LightContext_Init(PlayState* play, LightContext* lightCtx) { + LightContext_InitList(play, lightCtx); LightContext_SetAmbientColor(lightCtx, 80, 80, 80); LightContext_SetFog(lightCtx, 0, 0, 0, 996, 12800); memset(&sLightsBuffer, 0, sizeof(sLightsBuffer)); @@ -233,13 +233,13 @@ Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx) return Lights_New(gfxCtx, lightCtx->ambientColor[0], lightCtx->ambientColor[1], lightCtx->ambientColor[2]); } -void LightContext_InitList(GlobalContext* globalCtx, LightContext* lightCtx) { +void LightContext_InitList(PlayState* play, LightContext* lightCtx) { lightCtx->listHead = NULL; } -void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx) { +void LightContext_DestroyList(PlayState* play, LightContext* lightCtx) { while (lightCtx->listHead != NULL) { - LightContext_RemoveLight(globalCtx, lightCtx, lightCtx->listHead); + LightContext_RemoveLight(play, lightCtx, lightCtx->listHead); lightCtx->listHead = lightCtx->listHead->next; } } @@ -250,7 +250,7 @@ void LightContext_DestroyList(GlobalContext* globalCtx, LightContext* lightCtx) * Note: Due to the limited number of slots in a Lights group, inserting too many lights in the * list may result in older entries not being bound to a Light when calling Lights_BindAll */ -LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* lightCtx, LightInfo* info) { +LightNode* LightContext_InsertLight(PlayState* play, LightContext* lightCtx, LightInfo* info) { LightNode* node; node = Lights_FindBufSlot(); @@ -270,7 +270,7 @@ LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* ligh return node; } -void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* node) { +void LightContext_RemoveLight(PlayState* play, LightContext* lightCtx, LightNode* node) { if (node != NULL) { if (node->prev != NULL) { node->prev->next = node->next; @@ -326,7 +326,7 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient return lights; } -void Lights_GlowCheckPrepare(GlobalContext* globalCtx) { +void Lights_GlowCheckPrepare(PlayState* play) { LightNode* node; LightPoint* params; Vec3f pos; @@ -335,7 +335,7 @@ void Lights_GlowCheckPrepare(GlobalContext* globalCtx) { f32 wX; f32 wY; - node = globalCtx->lightCtx.listHead; + node = play->lightCtx.listHead; while (node != NULL) { params = &node->info->params.point; @@ -348,7 +348,7 @@ void Lights_GlowCheckPrepare(GlobalContext* globalCtx) { pos.x = params->x; pos.y = params->y; pos.z = params->z; - func_8002BE04(globalCtx, &pos, &multDest, &wDest); + func_8002BE04(play, &pos, &multDest, &wDest); wX = multDest.x * wDest; wY = multDest.y * wDest; @@ -364,7 +364,7 @@ void Lights_GlowCheckPrepare(GlobalContext* globalCtx) { } } -void Lights_GlowCheck(GlobalContext* globalCtx) { +void Lights_GlowCheck(PlayState* play) { LightNode* node; LightPoint* params; Vec3f pos; @@ -375,7 +375,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { s32 wZ; s32 zBuf; - node = globalCtx->lightCtx.listHead; + node = play->lightCtx.listHead; while (node != NULL) { params = &node->info->params.point; @@ -388,7 +388,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { pos.x = params->x; pos.y = params->y; pos.z = params->z; - func_8002BE04(globalCtx, &pos, &multDest, &wDest); + func_8002BE04(play, &pos, &multDest, &wDest); params->drawGlow = false; wX = multDest.x * wDest; wY = multDest.y * wDest; @@ -410,13 +410,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { } } -void Lights_DrawGlow(GlobalContext* globalCtx) { +void Lights_DrawGlow(PlayState* play) { s32 pad; LightNode* node; - node = globalCtx->lightCtx.listHead; + node = play->lightCtx.listHead; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); POLY_XLU_DISP = func_800947AC(POLY_XLU_DISP++); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); @@ -439,7 +439,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, params->color[0], params->color[1], params->color[2], 50); Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGlowCircleDL); FrameInterpolation_RecordCloseChild(); @@ -448,5 +448,5 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { node = node->next; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } diff --git a/soh/src/code/z_map_exp.c b/soh/src/code/z_map_exp.c index 0866b5332..33075e3fd 100644 --- a/soh/src/code/z_map_exp.c +++ b/soh/src/code/z_map_exp.c @@ -17,17 +17,17 @@ s16 Left_MM_Margin = 0; s16 Right_MM_Margin = 0; s16 Bottom_MM_Margin = 0; -void Map_SavePlayerInitialInfo(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +void Map_SavePlayerInitialInfo(PlayState* play) { + Player* player = GET_PLAYER(play); sPlayerInitialPosX = player->actor.world.pos.x; sPlayerInitialPosZ = player->actor.world.pos.z; sPlayerInitialDirection = (s16)((0x7FFF - player->actor.shape.rot.y) / 0x400); } -void Map_SetPaletteData(GlobalContext* globalCtx, s16 room) { +void Map_SetPaletteData(PlayState* play, s16 room) { s32 mapIndex = gSaveContext.mapIndex; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 paletteIndex = gMapData->roomPalette[mapIndex][room]; if (interfaceCtx->mapRoomNum == room) { @@ -44,9 +44,9 @@ void Map_SetPaletteData(GlobalContext* globalCtx, s16 room) { interfaceCtx->mapPalette[paletteIndex * 2 + 1] = 0xBF; } -void Map_SetFloorPalettesData(GlobalContext* globalCtx, s16 floor) { +void Map_SetFloorPalettesData(PlayState* play, s16 floor) { s32 mapIndex = gSaveContext.mapIndex; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 room; s16 i; @@ -60,7 +60,7 @@ void Map_SetFloorPalettesData(GlobalContext* globalCtx, s16 floor) { interfaceCtx->mapPalette[31] = 1; } - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: case SCENE_BDAN: @@ -82,7 +82,7 @@ void Map_SetFloorPalettesData(GlobalContext* globalCtx, s16 floor) { for (i = 0; i < gMapData->maxPaletteCount[mapIndex]; i++) { room = gMapData->paletteRoom[mapIndex][floor][i]; if ((room != 0xFF) && (gSaveContext.sceneFlags[mapIndex].rooms & gBitFlags[room])) { - Map_SetPaletteData(globalCtx, room); + Map_SetPaletteData(play, room); } } break; @@ -360,12 +360,12 @@ const char* minimapTableDangeon[] = gIceCavernRoom11MinimapTex, }; -void Map_InitData(GlobalContext* globalCtx, s16 room) { +void Map_InitData(PlayState* play, s16 room) { s32 mapIndex = gSaveContext.mapIndex; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 extendedMapIndex; - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_SPOT00: case SCENE_SPOT01: case SCENE_SPOT02: @@ -387,19 +387,19 @@ void Map_InitData(GlobalContext* globalCtx, s16 room) { case SCENE_SPOT20: case SCENE_GANON_TOU: extendedMapIndex = mapIndex; - if (globalCtx->sceneNum == SCENE_SPOT02) { + if (play->sceneNum == SCENE_SPOT02) { if (CHECK_QUEST_ITEM(QUEST_SONG_NOCTURNE)) { extendedMapIndex = 0x14; } - } else if (globalCtx->sceneNum == SCENE_SPOT06) { + } else if (play->sceneNum == SCENE_SPOT06) { if ((LINK_AGE_IN_YEARS == YEARS_ADULT) && !CHECK_QUEST_ITEM(QUEST_MEDALLION_WATER)) { extendedMapIndex = 0x15; } - } else if (globalCtx->sceneNum == SCENE_SPOT09) { + } else if (play->sceneNum == SCENE_SPOT09) { if ((LINK_AGE_IN_YEARS == YEARS_ADULT) && !((gSaveContext.eventChkInf[9] & 0xF) == 0xF)) { extendedMapIndex = 0x16; } - } else if (globalCtx->sceneNum == SCENE_SPOT12) { + } else if (play->sceneNum == SCENE_SPOT12) { if ((gSaveContext.eventChkInf[9] & 0xF) == 0xF) { extendedMapIndex = 0x17; } @@ -414,7 +414,7 @@ void Map_InitData(GlobalContext* globalCtx, s16 room) { if (sEntranceIconMapIndex < 24) { const char* textureName = minimapTableOW[sEntranceIconMapIndex]; - memcpy(globalCtx->interfaceCtx.mapSegment, ResourceMgr_LoadTexByName(textureName), ResourceMgr_LoadTexSizeByName(textureName)); + memcpy(play->interfaceCtx.mapSegment, ResourceMgr_LoadTexByName(textureName), ResourceMgr_LoadTexSizeByName(textureName)); } interfaceCtx->unk_258 = mapIndex; @@ -442,31 +442,31 @@ void Map_InitData(GlobalContext* globalCtx, s16 room) { osSyncPrintf("デクの樹ダンジョンMAP テクスチャDMA(%x) scene_id_offset=%d VREG(30)=%d\n", room, mapIndex, VREG(30)); osSyncPrintf(VT_RST); - //DmaMgr_SendRequest1(globalCtx->interfaceCtx.mapSegment, + //DmaMgr_SendRequest1(play->interfaceCtx.mapSegment, //(uintptr_t)_map_i_staticSegmentRomStart + //((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0), //0xFF0, __FILE__, __LINE__); const char* textureName = minimapTableDangeon[gMapData->dgnMinimapTexIndexOffset[mapIndex] + room]; - memcpy(globalCtx->interfaceCtx.mapSegment, ResourceMgr_LoadTexByName(textureName), ResourceMgr_LoadTexSizeByName(textureName)); + memcpy(play->interfaceCtx.mapSegment, ResourceMgr_LoadTexByName(textureName), ResourceMgr_LoadTexSizeByName(textureName)); R_COMPASS_OFFSET_X = gMapData->roomCompassOffsetX[mapIndex][room]; R_COMPASS_OFFSET_Y = gMapData->roomCompassOffsetY[mapIndex][room]; - Map_SetFloorPalettesData(globalCtx, VREG(30)); + Map_SetFloorPalettesData(play, VREG(30)); osSyncPrintf("MAP 各階ONチェック\n"); // "MAP Individual Floor ON Check" break; } } -void Map_InitRoomData(GlobalContext* globalCtx, s16 room) { +void Map_InitRoomData(PlayState* play, s16 room) { s32 mapIndex = gSaveContext.mapIndex; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; osSyncPrintf("*******\n*******\nroom_no=%d (%d)(%d)\n*******\n*******\n", room, - mapIndex, globalCtx->sceneNum); + mapIndex, play->sceneNum); if (room >= 0) { - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: case SCENE_BDAN: @@ -489,11 +489,11 @@ void Map_InitRoomData(GlobalContext* globalCtx, s16 room) { osSyncPrintf("ROOM_INF=%d\n", gSaveContext.sceneFlags[mapIndex].rooms); interfaceCtx->mapRoomNum = room; interfaceCtx->unk_25A = mapIndex; - Map_SetPaletteData(globalCtx, room); + Map_SetPaletteData(play, room); osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("部屋部屋=%d\n", room); // "Room Room = %d" osSyncPrintf(VT_RST); - Map_InitData(globalCtx, room); + Map_InitData(play, room); break; } } else { @@ -505,27 +505,27 @@ void Map_InitRoomData(GlobalContext* globalCtx, s16 room) { } } -void Map_Destroy(GlobalContext* globalCtx) { - MapMark_ClearPointers(globalCtx); +void Map_Destroy(PlayState* play) { + MapMark_ClearPointers(play); gMapData = NULL; } -void Map_Init(GlobalContext* globalCtx) { +void Map_Init(PlayState* play) { s32 mapIndex = gSaveContext.mapIndex; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; gMapData = &gMapDataTable; interfaceCtx->unk_258 = -1; interfaceCtx->unk_25A = -1; - interfaceCtx->mapSegment = GAMESTATE_ALLOC_MC(&globalCtx->state, 0x1000); + interfaceCtx->mapSegment = GAMESTATE_ALLOC_MC(&play->state, 0x1000); // "MAP texture initialization scene_data_ID=%d mapSegment=%x" - osSyncPrintf("\n\n\nMAP テクスチャ初期化 scene_data_ID=%d\nmapSegment=%x\n\n", globalCtx->sceneNum, - interfaceCtx->mapSegment, globalCtx); + osSyncPrintf("\n\n\nMAP テクスチャ初期化 scene_data_ID=%d\nmapSegment=%x\n\n", play->sceneNum, + interfaceCtx->mapSegment, play); ASSERT(interfaceCtx->mapSegment != NULL); - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_SPOT00: case SCENE_SPOT01: case SCENE_SPOT02: @@ -546,13 +546,13 @@ void Map_Init(GlobalContext* globalCtx) { case SCENE_SPOT18: case SCENE_SPOT20: case SCENE_GANON_TOU: - mapIndex = globalCtx->sceneNum - SCENE_SPOT00; + mapIndex = play->sceneNum - SCENE_SPOT00; R_MAP_INDEX = gSaveContext.mapIndex = mapIndex; R_COMPASS_SCALE_X = gMapData->owCompassInfo[mapIndex][0]; R_COMPASS_SCALE_Y = gMapData->owCompassInfo[mapIndex][1]; R_COMPASS_OFFSET_X = gMapData->owCompassInfo[mapIndex][2]; R_COMPASS_OFFSET_Y = gMapData->owCompassInfo[mapIndex][3]; - Map_InitData(globalCtx, mapIndex); + Map_InitData(play, mapIndex); R_OW_MINIMAP_X = gMapData->owMinimapPosX[mapIndex]; R_OW_MINIMAP_Y = gMapData->owMinimapPosY[mapIndex]; break; @@ -582,24 +582,24 @@ void Map_Init(GlobalContext* globalCtx) { case SCENE_JYASINBOSS: case SCENE_HAKADAN_BS: mapIndex = - (globalCtx->sceneNum >= SCENE_YDAN_BOSS) ? globalCtx->sceneNum - SCENE_YDAN_BOSS : globalCtx->sceneNum; + (play->sceneNum >= SCENE_YDAN_BOSS) ? play->sceneNum - SCENE_YDAN_BOSS : play->sceneNum; R_MAP_INDEX = gSaveContext.mapIndex = mapIndex; - if ((globalCtx->sceneNum <= SCENE_ICE_DOUKUTO) || (globalCtx->sceneNum >= SCENE_YDAN_BOSS)) { + if ((play->sceneNum <= SCENE_ICE_DOUKUTO) || (play->sceneNum >= SCENE_YDAN_BOSS)) { R_COMPASS_SCALE_X = gMapData->dgnCompassInfo[mapIndex][0]; R_COMPASS_SCALE_Y = gMapData->dgnCompassInfo[mapIndex][1]; R_COMPASS_OFFSET_X = gMapData->dgnCompassInfo[mapIndex][2]; R_COMPASS_OFFSET_Y = gMapData->dgnCompassInfo[mapIndex][3]; R_MAP_TEX_INDEX = R_MAP_TEX_INDEX_BASE = gMapData->dgnMinimapTexIndexBase[mapIndex]; - Map_InitRoomData(globalCtx, globalCtx->roomCtx.curRoom.num); - MapMark_Init(globalCtx); + Map_InitRoomData(play, play->roomCtx.curRoom.num); + MapMark_Init(play); } break; } } -void Minimap_DrawCompassIcons(GlobalContext* globalCtx) { +void Minimap_DrawCompassIcons(PlayState* play) { s32 pad; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s16 tempX, tempZ; const Color_RGB8 LastEntrance_arrow = { 200, 0, 0 }; const Color_RGB8 CurrentPosition_arrow = { 200, 255, 0 }; @@ -613,10 +613,10 @@ void Minimap_DrawCompassIcons(GlobalContext* globalCtx) { Y_Margins_Minimap = 0; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - if (globalCtx->interfaceCtx.minimapAlpha >= 0xAA) { - func_80094A14(globalCtx->state.gfxCtx); + if (play->interfaceCtx.minimapAlpha >= 0xAA) { + func_80094A14(play->state.gfxCtx); //Player current position (yellow arrow) gSPMatrix(OVERLAY_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); @@ -656,7 +656,7 @@ void Minimap_DrawCompassIcons(GlobalContext* globalCtx) { Matrix_RotateX(-1.6f, MTXMODE_APPLY); tempX = (0x7FFF - player->actor.shape.rot.y) / 0x400; Matrix_RotateY(tempX / 10.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (CVar_GetS32("gHudColors", 1) == 2) { @@ -697,7 +697,7 @@ void Minimap_DrawCompassIcons(GlobalContext* globalCtx) { Matrix_Scale(VREG(9) / 100.0f, VREG(9) / 100.0f, VREG(9) / 100.0f, MTXMODE_APPLY); Matrix_RotateX(VREG(52) / 10.0f, MTXMODE_APPLY); Matrix_RotateY(sPlayerInitialDirection / 10.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); if (CVar_GetS32("gHudColors", 1) == 2) { @@ -708,24 +708,24 @@ void Minimap_DrawCompassIcons(GlobalContext* globalCtx) { gSPDisplayList(OVERLAY_DISP++, gCompassArrowDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Minimap_Draw(GlobalContext* globalCtx) { +void Minimap_Draw(PlayState* play) { s32 pad[2]; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s32 mapIndex = gSaveContext.mapIndex; const Color_RGB8 Dungeon_minimap = {100, 255, 255}; const Color_RGB8 Overworld_minimap = {R_MINIMAP_COLOR(0), R_MINIMAP_COLOR(1), R_MINIMAP_COLOR(2)}; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); // If any of these CVars are enabled, disable toggling the minimap with L, unless gEnableMapToggle is set bool enableMapToggle = !(CVar_GetS32("gDebugEnabled", 0) || CVar_GetS32("gMoonJumpOnL", 0) || CVar_GetS32("gTurboOnL", 0)) || CVar_GetS32("gEnableMapToggle", 0); - if (globalCtx->pauseCtx.state < 4) { + if (play->pauseCtx.state < 4) { //Minimap margins s16 X_Margins_Minimap; s16 Y_Margins_Minimap; @@ -737,7 +737,7 @@ void Minimap_Draw(GlobalContext* globalCtx) { Y_Margins_Minimap = 0; } - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: case SCENE_BDAN: @@ -749,7 +749,7 @@ void Minimap_Draw(GlobalContext* globalCtx) { case SCENE_HAKADANCH: case SCENE_ICE_DOUKUTO: if (!R_MINIMAP_DISABLED) { - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); gDPSetCombineLERP(OVERLAY_DISP++, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0, 1, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0); @@ -787,14 +787,14 @@ void Minimap_Draw(GlobalContext* globalCtx) { } if (CHECK_DUNGEON_ITEM(DUNGEON_COMPASS, mapIndex)) { - Minimap_DrawCompassIcons(globalCtx); // Draw icons for the player spawn and current position - func_80094520(globalCtx->state.gfxCtx); - MapMark_Draw(globalCtx); + Minimap_DrawCompassIcons(play); // Draw icons for the player spawn and current position + func_80094520(play->state.gfxCtx); + MapMark_Draw(play); } } - if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_L) && !Gameplay_InCsMode(globalCtx) && enableMapToggle) { - osSyncPrintf("Game_play_demo_mode_check=%d\n", Gameplay_InCsMode(globalCtx)); + if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_L) && !Play_InCsMode(play) && enableMapToggle) { + osSyncPrintf("Game_play_demo_mode_check=%d\n", Play_InCsMode(play)); // clang-format off if (!R_MINIMAP_DISABLED) { Audio_PlaySoundGeneral(NA_SE_SY_CAMERA_ZOOM_UP, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } @@ -826,7 +826,7 @@ void Minimap_Draw(GlobalContext* globalCtx) { case SCENE_SPOT20: case SCENE_GANON_TOU: if (!R_MINIMAP_DISABLED) { - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); if (CVar_GetS32("gHudColors", 1) == 2) {//Overworld minimap @@ -865,8 +865,8 @@ void Minimap_Draw(GlobalContext* globalCtx) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, Overworld_minimap.r, Overworld_minimap.g, Overworld_minimap.b, interfaceCtx->minimapAlpha); } - if (((globalCtx->sceneNum != SCENE_SPOT01) && (globalCtx->sceneNum != SCENE_SPOT04) && - (globalCtx->sceneNum != SCENE_SPOT08)) || + if (((play->sceneNum != SCENE_SPOT01) && (play->sceneNum != SCENE_SPOT04) && + (play->sceneNum != SCENE_SPOT08)) || (LINK_AGE_IN_YEARS != YEARS_ADULT)) { bool Map0 = gMapData->owEntranceIconPosY[sEntranceIconMapIndex] << 2 == 0; s16 IconSize = 8; @@ -941,13 +941,13 @@ void Minimap_Draw(GlobalContext* globalCtx) { } } - if ((globalCtx->sceneNum == SCENE_SPOT08) && (gSaveContext.infTable[26] & gBitFlags[9])) { + if ((play->sceneNum == SCENE_SPOT08) && (gSaveContext.infTable[26] & gBitFlags[9])) { gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD); gSPWideTextureRectangle(OVERLAY_DISP++, entranceX << 2, entranceY << 2, (entranceX + 32) << 2, (entranceY + 8) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - } else if ((globalCtx->sceneNum == SCENE_SPOT08) && CVar_GetS32("gAlwaysShowDungeonMinimapIcon", 0) != 0){ + } else if ((play->sceneNum == SCENE_SPOT08) && CVar_GetS32("gAlwaysShowDungeonMinimapIcon", 0) != 0){ gDPLoadTextureBlock(OVERLAY_DISP++, gMapDungeonEntranceIconTex, G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 8, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, @@ -957,10 +957,10 @@ void Minimap_Draw(GlobalContext* globalCtx) { G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } - Minimap_DrawCompassIcons(globalCtx); // Draw icons for the player spawn and current position + Minimap_DrawCompassIcons(play); // Draw icons for the player spawn and current position } - if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_L) && !Gameplay_InCsMode(globalCtx) && enableMapToggle) { + if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_L) && !Play_InCsMode(play) && enableMapToggle) { // clang-format off if (!R_MINIMAP_DISABLED) { Audio_PlaySoundGeneral(NA_SE_SY_CAMERA_ZOOM_UP, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } @@ -974,18 +974,18 @@ void Minimap_Draw(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } s16 Map_GetFloorTextIndexOffset(s32 mapIndex, s32 floor) { return gMapData->floorTexIndexOffset[mapIndex][floor]; } -void Map_Update(GlobalContext* globalCtx) { +void Map_Update(PlayState* play) { static s16 sLastRoomNum = 99; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 mapIndex = gSaveContext.mapIndex; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 floor; s16 i; @@ -994,8 +994,8 @@ void Map_Update(GlobalContext* globalCtx) { Right_MM_Margin = CVar_GetS32("gHUDMargin_R", 0); Bottom_MM_Margin = CVar_GetS32("gHUDMargin_B", 0); - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { - switch (globalCtx->sceneNum) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: case SCENE_BDAN: @@ -1040,9 +1040,9 @@ void Map_Update(GlobalContext* globalCtx) { // "Layer switching = %x" osSyncPrintf("階層切替=%x\n", interfaceCtx->mapRoomNum); osSyncPrintf(VT_RST); - Map_InitData(globalCtx, interfaceCtx->mapRoomNum); + Map_InitData(play, interfaceCtx->mapRoomNum); gSaveContext.sunsSongState = SUNSSONG_INACTIVE; - Map_SavePlayerInitialInfo(globalCtx); + Map_SavePlayerInitialInfo(play); } } @@ -1056,9 +1056,9 @@ void Map_Update(GlobalContext* globalCtx) { case SCENE_MIZUSIN_BS: case SCENE_JYASINBOSS: case SCENE_HAKADAN_BS: - VREG(30) = gMapData->bossFloor[globalCtx->sceneNum - SCENE_YDAN_BOSS]; + VREG(30) = gMapData->bossFloor[play->sceneNum - SCENE_YDAN_BOSS]; R_MAP_TEX_INDEX = R_MAP_TEX_INDEX_BASE + - gMapData->floorTexIndexOffset[globalCtx->sceneNum - SCENE_YDAN_BOSS][VREG(30)]; + gMapData->floorTexIndexOffset[play->sceneNum - SCENE_YDAN_BOSS][VREG(30)]; break; } } diff --git a/soh/src/code/z_map_mark.c b/soh/src/code/z_map_mark.c index 79540ee20..05e66e1aa 100644 --- a/soh/src/code/z_map_mark.c +++ b/soh/src/code/z_map_mark.c @@ -54,11 +54,11 @@ static MapMarkInfo sMapMarkInfoTable[] = { MapMarkData** sLoadedMarkDataTable; -void MapMark_Init(GlobalContext* globalCtx) { +void MapMark_Init(PlayState* play) { //MapMarkDataOverlay* overlay = &sMapMarkDataOvl; //u32 overlaySize = (uintptr_t)overlay->vramEnd - (uintptr_t)overlay->vramStart; - //overlay->loadedRamAddr = GAMESTATE_ALLOC_MC(&globalCtx->state, overlaySize); + //overlay->loadedRamAddr = GAMESTATE_ALLOC_MC(&play->state, overlaySize); //LOG_CHECK_NULL_POINTER("dlftbl->allocp", overlay->loadedRamAddr); //Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr); @@ -75,12 +75,12 @@ void MapMark_Init(GlobalContext* globalCtx) { //: NULL); } -void MapMark_ClearPointers(GlobalContext* globalCtx) { +void MapMark_ClearPointers(PlayState* play) { //sMapMarkDataOvl.loadedRamAddr = NULL; sLoadedMarkDataTable = NULL; } -void MapMark_DrawForDungeon(GlobalContext* globalCtx) { +void MapMark_DrawForDungeon(PlayState* play) { InterfaceContext* interfaceCtx; MapMarkIconData* mapMarkIconData; MapMarkPoint* markPoint; @@ -90,18 +90,18 @@ void MapMark_DrawForDungeon(GlobalContext* globalCtx) { s32 rectLeft; s32 rectTop; - interfaceCtx = &globalCtx->interfaceCtx; + interfaceCtx = &play->interfaceCtx; - if ((gMapData != NULL) && (globalCtx->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon])) { + if ((gMapData != NULL) && (play->interfaceCtx.mapRoomNum >= gMapData->dgnMinimapCount[dungeon])) { // "Room number exceeded, yikes %d/%d MapMarkDraw processing interrupted" osSyncPrintf(VT_COL(RED, WHITE) "部屋番号がオーバーしてるで,ヤバイで %d/%d \nMapMarkDraw の処理を中断します\n", - VT_RST, globalCtx->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]); + VT_RST, play->interfaceCtx.mapRoomNum, gMapData->dgnMinimapCount[dungeon]); return; } mapMarkIconData = &sLoadedMarkDataTable[dungeon][interfaceCtx->mapRoomNum][0]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); while (true) { if (mapMarkIconData->markType == MAP_MARK_NONE) { @@ -131,7 +131,7 @@ void MapMark_DrawForDungeon(GlobalContext* globalCtx) { markPoint = &mapMarkIconData->points[0]; //Place each chest / boss room icon for (i = 0; i < mapMarkIconData->count; i++) { - if ((mapMarkIconData->markType != MAP_MARK_CHEST) || !Flags_GetTreasure(globalCtx, markPoint->chestFlag)) { + if ((mapMarkIconData->markType != MAP_MARK_CHEST) || !Flags_GetTreasure(play, markPoint->chestFlag)) { //Minimap chest / boss icon const s32 PosX_Minimap_ori = GREG(94) + OTRGetRectDimensionFromRightEdge(markPoint->x+X_Margins_Minimap_ic) + 204; const s32 PosY_Minimap_ori = GREG(95) + markPoint->y + Y_Margins_Minimap_ic + 140; @@ -139,10 +139,10 @@ void MapMark_DrawForDungeon(GlobalContext* globalCtx) { rectTop = (markPoint->y + Y_Margins_Minimap_ic + 140 + CVar_GetS32("gMinimapPosY", 0)); if (CVar_GetS32("gMinimapPosType", 0) == 1) {//Anchor Left if (CVar_GetS32("gMinimapUseMargins", 0) != 0) {X_Margins_Minimap_ic = Left_MC_Margin;}; - if (globalCtx->sceneNum == SCENE_YDAN || globalCtx->sceneNum == SCENE_DDAN || globalCtx->sceneNum == SCENE_BDAN || - globalCtx->sceneNum == SCENE_BMORI1 || globalCtx->sceneNum == SCENE_HIDAN || globalCtx->sceneNum == SCENE_MIZUSIN || - globalCtx->sceneNum == SCENE_JYASINZOU || globalCtx->sceneNum == SCENE_HAKADAN || globalCtx->sceneNum == SCENE_HAKADANCH || - globalCtx->sceneNum == SCENE_ICE_DOUKUTO) { + if (play->sceneNum == SCENE_YDAN || play->sceneNum == SCENE_DDAN || play->sceneNum == SCENE_BDAN || + play->sceneNum == SCENE_BMORI1 || play->sceneNum == SCENE_HIDAN || play->sceneNum == SCENE_MIZUSIN || + play->sceneNum == SCENE_JYASINZOU || play->sceneNum == SCENE_HAKADAN || play->sceneNum == SCENE_HAKADANCH || + play->sceneNum == SCENE_ICE_DOUKUTO) { rectLeft = OTRGetRectDimensionFromLeftEdge(markPoint->x+CVar_GetS32("gMinimapPosX", 0)+204+X_Margins_Minimap_ic); } else { rectLeft = OTRGetRectDimensionFromLeftEdge(markPoint->x+CVar_GetS32("gMinimapPosX", 0)+204+X_Margins_Minimap_ic); @@ -183,11 +183,11 @@ void MapMark_DrawForDungeon(GlobalContext* globalCtx) { mapMarkIconData++; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void MapMark_Draw(GlobalContext* globalCtx) { - switch (globalCtx->sceneNum) { +void MapMark_Draw(PlayState* play) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: case SCENE_BDAN: @@ -203,7 +203,7 @@ void MapMark_Draw(GlobalContext* globalCtx) { case SCENE_BDAN_BOSS: case SCENE_MORIBOSSROOM: case SCENE_FIRE_BS: - MapMark_DrawForDungeon(globalCtx); + MapMark_DrawForDungeon(play); break; } } diff --git a/soh/src/code/z_message_PAL.c b/soh/src/code/z_message_PAL.c index 341bd9372..54854c387 100644 --- a/soh/src/code/z_message_PAL.c +++ b/soh/src/code/z_message_PAL.c @@ -200,12 +200,12 @@ void Message_ResetOcarinaNoteState(void) { } } -void Message_UpdateOcarinaGame(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_UpdateOcarinaGame(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; - globalCtx->msgCtx.msgMode++; + play->msgCtx.msgMode++; - if (globalCtx->msgCtx.msgMode == MSGMODE_MEMORY_GAME_PLAYER_PLAYING) { + if (play->msgCtx.msgMode == MSGMODE_MEMORY_GAME_PLAYER_PLAYING) { Audio_OcaSetInstrument(1); msgCtx->ocarinaStaff = Audio_OcaGetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaNoteBufPos = 0; @@ -221,8 +221,8 @@ void Message_UpdateOcarinaGame(GlobalContext* globalCtx) { Message_ResetOcarinaNoteState(); } -u8 Message_ShouldAdvance(GlobalContext* globalCtx) { - Input* input = &globalCtx->state.input[0]; +u8 Message_ShouldAdvance(PlayState* play) { + Input* input = &play->state.input[0]; bool isB_Held = CVar_GetS32("gSkipText", 0) != 0 ? CHECK_BTN_ALL(input->cur.button, BTN_B) : CHECK_BTN_ALL(input->press.button, BTN_B); @@ -233,8 +233,8 @@ u8 Message_ShouldAdvance(GlobalContext* globalCtx) { return CHECK_BTN_ALL(input->press.button, BTN_A) || isB_Held || CHECK_BTN_ALL(input->press.button, BTN_CUP); } -u8 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { - Input* input = &globalCtx->state.input[0]; +u8 Message_ShouldAdvanceSilent(PlayState* play) { + Input* input = &play->state.input[0]; bool isB_Held = CVar_GetS32("gSkipText", 0) != 0 ? CHECK_BTN_ALL(input->cur.button, BTN_B) : CHECK_BTN_ALL(input->press.button, BTN_B); @@ -246,8 +246,8 @@ u8 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) { * Closes any currently displayed textbox immediately, without waiting for * input from the player. */ -void Message_CloseTextbox(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_CloseTextbox(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; if (msgCtx->msgLength != 0) { msgCtx->stateTimer = 2; @@ -257,10 +257,10 @@ void Message_CloseTextbox(GlobalContext* globalCtx) { } } -void Message_HandleChoiceSelection(GlobalContext* globalCtx, u8 numChoices) { +void Message_HandleChoiceSelection(PlayState* play, u8 numChoices) { static s16 sAnalogStickHeld = false; - MessageContext* msgCtx = &globalCtx->msgCtx; - Input* input = &globalCtx->state.input[0]; + MessageContext* msgCtx = &play->msgCtx; + Input* input = &play->state.input[0]; bool dpad = CVar_GetS32("gDpadText", 0); if ((input->rel.stick_y >= 30 && !sAnalogStickHeld) || (dpad && CHECK_BTN_ALL(input->press.button, BTN_DUP))) { @@ -287,8 +287,8 @@ void Message_HandleChoiceSelection(GlobalContext* globalCtx, u8 numChoices) { (numChoices == 1) ? R_TEXT_CHOICE_YPOS(msgCtx->choiceIndex + 1) : R_TEXT_CHOICE_YPOS(msgCtx->choiceIndex); } -void Message_DrawTextChar(GlobalContext* globalCtx, void* textureImage, Gfx** p) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_DrawTextChar(PlayState* play, void* textureImage, Gfx** p) { + MessageContext* msgCtx = &play->msgCtx; Gfx* gfx = *p; s16 x = msgCtx->textPosX; s16 y = msgCtx->textPosY; @@ -356,7 +356,7 @@ void Message_GrowTextbox(MessageContext* msgCtx) { R_TEXTBOX_X = (R_TEXTBOX_X_TARGET + R_TEXTBOX_WIDTH_TARGET) - (R_TEXTBOX_WIDTH / 2); } -void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { +void Message_FindMessage(PlayState* play, u16 textId) { const char* foundSeg; const char* nextSeg; MessageTableEntry* messageTableEntry = sNesMessageEntryTablePtr; @@ -383,7 +383,7 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { seg = messageTableEntry->segment; while (messageTableEntry->textId != 0xFFFF) { - font = &globalCtx->msgCtx.font; + font = &play->msgCtx.font; if (messageTableEntry->textId == bufferId) { foundSeg = messageTableEntry->segment; @@ -404,7 +404,7 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { // "Message not found!!!" osSyncPrintf(" メッセージが,見つからなかった!!! = %x\n", bufferId); - font = &globalCtx->msgCtx.font; + font = &play->msgCtx.font; messageTableEntry = sNesMessageEntryTablePtr; foundSeg = messageTableEntry->segment; @@ -415,7 +415,7 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { font->msgLength = nextSeg - foundSeg; } -void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { +void Message_FindCreditsMessage(PlayState* play, u16 textId) { const char* foundSeg; const char* nextSeg; const char* seg; @@ -424,7 +424,7 @@ void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) { seg = messageTableEntry->segment; while (messageTableEntry->textId != 0xFFFF) { - font = &globalCtx->msgCtx.font; + font = &play->msgCtx.font; if (messageTableEntry->textId == textId) { foundSeg = messageTableEntry->segment; @@ -527,7 +527,7 @@ void Message_SetTextColor(MessageContext* msgCtx, u16 colorParameter) { } } -void Message_DrawTextboxIcon(GlobalContext* globalCtx, Gfx** p, s16 x, s16 y) { +void Message_DrawTextboxIcon(PlayState* play, Gfx** p, s16 x, s16 y) { static s16 sIconPrimColors[][3] = { { 0, 200, 80 }, { 50, 255, 130 }, @@ -585,7 +585,7 @@ void Message_DrawTextboxIcon(GlobalContext* globalCtx, Gfx** p, s16 x, s16 y) { sIconEnvColors[1][1] = 10; sIconEnvColors[1][2] = 10; } - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; Gfx* gfx = *p; s16 primR; @@ -829,10 +829,10 @@ f32 sFontWidths[144] = { 14.0f, // ? }; -u16 Message_DrawItemIcon(GlobalContext* globalCtx, u16 itemId, Gfx** p, u16 i) { +u16 Message_DrawItemIcon(PlayState* play, u16 itemId, Gfx** p, u16 i) { s32 pad; Gfx* gfx = *p; - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; // clang-format off if (msgCtx->msgMode == MSGMODE_TEXT_DISPLAYING) { Audio_PlaySoundGeneral(0, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } @@ -868,11 +868,11 @@ u16 Message_DrawItemIcon(GlobalContext* globalCtx, u16 itemId, Gfx** p, u16 i) { return i; } -void Message_HandleOcarina(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_HandleOcarina(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; - if (globalCtx->msgCtx.msgMode == MSGMODE_TEXT_DISPLAYING) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + if (play->msgCtx.msgMode == MSGMODE_TEXT_DISPLAYING) { + play->msgCtx.ocarinaMode = OCARINA_MODE_01; if (msgCtx->ocarinaAction == OCARINA_ACTION_SCARECROW_LONG_RECORDING) { msgCtx->msgMode = MSGMODE_SCARECROW_LONG_RECORDING_START; @@ -938,18 +938,18 @@ void Message_HandleOcarina(GlobalContext* globalCtx) { * Draws the text contents of a textbox, up to the current point that has * been scrolled to so far. */ -void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_DrawText(PlayState* play, Gfx** gfxP) { + MessageContext* msgCtx = &play->msgCtx; u16 lookAheadCharacter; u8 character; u16 j; u16 i; u16 sfxHi; u16 charTexIdx; - Font* font = &globalCtx->msgCtx.font; + Font* font = &play->msgCtx.font; Gfx* gfx = *gfxP; - globalCtx->msgCtx.textPosX = R_TEXT_INIT_XPOS; + play->msgCtx.textPosX = R_TEXT_INIT_XPOS; if (sTextIsCredits == false) { msgCtx->textPosY = R_TEXT_INIT_YPOS; @@ -1081,7 +1081,7 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { i += 2; break; case MESSAGE_ITEM_ICON: - i = Message_DrawItemIcon(globalCtx, msgCtx->msgBufDecoded[i + 1], &gfx, i); + i = Message_DrawItemIcon(play, msgCtx->msgBufDecoded[i + 1], &gfx, i); break; case MESSAGE_BACKGROUND: // clang-format off @@ -1170,8 +1170,8 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { Audio_PlaySoundGeneral(NA_SE_SY_MESSAGE_END, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Font_LoadMessageBoxIcon(font, TEXTBOX_ICON_SQUARE); - if (globalCtx->csCtx.state == 0) { - Interface_SetDoAction(globalCtx, DO_ACTION_RETURN); + if (play->csCtx.state == 0) { + Interface_SetDoAction(play, DO_ACTION_RETURN); } } } @@ -1180,7 +1180,7 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { case MESSAGE_OCARINA: msgCtx->textDrawPos = i + 1; if (i + 1 == msgCtx->textDrawPos) { - Message_HandleOcarina(globalCtx); + Message_HandleOcarina(play); *gfxP = gfx; return; } @@ -1191,8 +1191,8 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { msgCtx->textboxEndType = TEXTBOX_ENDTYPE_FADING; msgCtx->stateTimer = msgCtx->msgBufDecoded[++i]; Font_LoadMessageBoxIcon(font, TEXTBOX_ICON_SQUARE); - if (globalCtx->csCtx.state == 0) { - Interface_SetDoAction(globalCtx, DO_ACTION_RETURN); + if (play->csCtx.state == 0) { + Interface_SetDoAction(play, DO_ACTION_RETURN); } } *gfxP = gfx; @@ -1219,7 +1219,7 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { msgCtx->textDelayTimer == msgCtx->textDelay) { Audio_PlaySoundGeneral(0, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - Message_DrawTextChar(globalCtx, &font->charTexBuf[charTexIdx], &gfx); + Message_DrawTextChar(play, &font->charTexBuf[charTexIdx], &gfx); charTexIdx += FONT_CHAR_TEX_SIZE; msgCtx->textPosX += (s32)(sFontWidths[character - ' '] * (R_TEXT_CHAR_SCALE / 100.0f)); @@ -1235,11 +1235,11 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { *gfxP = gfx; } -void Message_LoadItemIcon(GlobalContext* globalCtx, u16 itemId, s16 y) { +void Message_LoadItemIcon(PlayState* play, u16 itemId, s16 y) { static s16 sIconItem32XOffsets[] = { 74, 74, 74 }; static s16 sIconItem24XOffsets[] = { 72, 72, 72 }; - MessageContext* msgCtx = &globalCtx->msgCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (itemId == ITEM_DUNGEON_MAP) { interfaceCtx->mapPalette[30] = 0xFF; @@ -1266,7 +1266,7 @@ void Message_LoadItemIcon(GlobalContext* globalCtx, u16 itemId, s16 y) { msgCtx->choiceNum = 1; } -void Message_Decode(GlobalContext* globalCtx) { +void Message_Decode(PlayState* play) { u8 temp_s2; u8 phi_s1; u16 phi_s0_3; @@ -1278,22 +1278,22 @@ void Message_Decode(GlobalContext* globalCtx) { s16 i; s16 digits[4]; f32 timeInSeconds; - MessageContext* msgCtx = &globalCtx->msgCtx; - Font* font = &globalCtx->msgCtx.font; + MessageContext* msgCtx = &play->msgCtx; + Font* font = &play->msgCtx.font; if ((msgCtx->msgMode >= MSGMODE_OCARINA_STARTING && msgCtx->msgMode <= MSGMODE_OCARINA_AWAIT_INPUT) || msgCtx->textBoxType == TEXTBOX_TYPE_OCARINA) { // TODO: Figure out what specific textures to invalidate to prevent the ocarina textboxes from flashing - gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, NULL); + gSPInvalidateTexCache(play->state.gfxCtx->polyOpa.p++, NULL); } else { for (u32 i = 0; i < FONT_CHAR_TEX_SIZE * 120; i += FONT_CHAR_TEX_SIZE) { if (&font->charTexBuf[i] != NULL) { - gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, &font->charTexBuf[i]); + gSPInvalidateTexCache(play->state.gfxCtx->polyOpa.p++, &font->charTexBuf[i]); } } } - globalCtx->msgCtx.textDelayTimer = 0; - globalCtx->msgCtx.textUnskippable = globalCtx->msgCtx.textDelay = globalCtx->msgCtx.textDelayTimer = 0; + play->msgCtx.textDelayTimer = 0; + play->msgCtx.textUnskippable = play->msgCtx.textDelay = play->msgCtx.textDelayTimer = 0; sTextFade = false; while (true) { @@ -1619,7 +1619,7 @@ void Message_Decode(GlobalContext* globalCtx) { msgCtx->msgBufDecoded[++decodedBufPos] = font->msgBuf[msgCtx->msgBufPos + 1]; osSyncPrintf("ITEM_NO=(%d) (%d)\n", msgCtx->msgBufDecoded[decodedBufPos], font->msgBuf[msgCtx->msgBufPos + 1]); - Message_LoadItemIcon(globalCtx, font->msgBuf[msgCtx->msgBufPos + 1], R_TEXTBOX_Y + 10); + Message_LoadItemIcon(play, font->msgBuf[msgCtx->msgBufPos + 1], R_TEXTBOX_Y + 10); } else if (temp_s2 == MESSAGE_BACKGROUND) { msgCtx->textboxBackgroundIdx = font->msgBuf[msgCtx->msgBufPos + 1] * 2; msgCtx->textboxBackgroundForeColorIdx = (font->msgBuf[msgCtx->msgBufPos + 2] & 0xF0) >> 4; @@ -1673,9 +1673,9 @@ void Message_Decode(GlobalContext* globalCtx) { extern const char* msgStaticTbl[]; -void Message_OpenText(GlobalContext* globalCtx, u16 textId) { +void Message_OpenText(PlayState* play, u16 textId) { static s16 messageStaticIndices[] = { 0, 1, 3, 2 }; - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; s16 textBoxType; @@ -1690,11 +1690,11 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { if ((msgCtx->msgMode >= MSGMODE_OCARINA_STARTING && msgCtx->msgMode <= MSGMODE_OCARINA_AWAIT_INPUT) || msgCtx->textBoxType == TEXTBOX_TYPE_OCARINA) { // TODO: Figure out what specific textures to invalidate to prevent the ocarina textboxes from flashing - gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, NULL); + gSPInvalidateTexCache(play->state.gfxCtx->polyOpa.p++, NULL); } else { for (u32 i = 0; i < FONT_CHAR_TEX_SIZE * 120; i += FONT_CHAR_TEX_SIZE) { if (&font->charTexBuf[i] != NULL) { - gSPInvalidateTexCache(globalCtx->state.gfxCtx->polyOpa.p++, &font->charTexBuf[i]); + gSPInvalidateTexCache(play->state.gfxCtx->polyOpa.p++, &font->charTexBuf[i]); } } } @@ -1737,10 +1737,10 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } // RANDOTODO: Use this for ice trap messages - if (CustomMessage_RetrieveIfExists(globalCtx)) { + if (CustomMessage_RetrieveIfExists(play)) { osSyncPrintf("Found custom message"); } else if (sTextIsCredits) { - Message_FindCreditsMessage(globalCtx, textId); + Message_FindCreditsMessage(play, textId); msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; memcpy(font->msgBuf, src, font->msgLength); @@ -1759,10 +1759,10 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { (textId == 0x4C || textId == 0xA4)) || // 4D == Hylian Shield textId == 0x4D)) { - Message_FindMessage(globalCtx, textId); + Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength = GetEquipNowMessage(font->msgBuf, font->msgOffset, sizeof(font->msgBuf)); } else { - Message_FindMessage(globalCtx, textId); + Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; char* src = (uintptr_t)font->msgOffset; memcpy(font->msgBuf, src, font->msgLength); @@ -1807,8 +1807,8 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { msgCtx->msgBufPos = msgCtx->unk_E3D0 = msgCtx->textDrawPos = 0; } -void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* actor) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_StartTextbox(PlayState* play, u16 textId, Actor* actor) { + MessageContext* msgCtx = &play->msgCtx; osSyncPrintf(VT_FGCOL(BLUE)); // "Message" @@ -1820,19 +1820,19 @@ void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* actor) { // so we need to switch the order of these lines if (gSaveContext.n64ddFlag && textId == 0x2053) { msgCtx->talkActor = actor; - Message_OpenText(globalCtx, textId); + Message_OpenText(play, textId); } else { - Message_OpenText(globalCtx, textId); + Message_OpenText(play, textId); msgCtx->talkActor = actor; } msgCtx->msgMode = MSGMODE_TEXT_START; msgCtx->stateTimer = 0; msgCtx->textDelayTimer = 0; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; + play->msgCtx.ocarinaMode = OCARINA_MODE_00; } -void Message_ContinueTextbox(GlobalContext* globalCtx, u16 textId) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_ContinueTextbox(PlayState* play, u16 textId) { + MessageContext* msgCtx = &play->msgCtx; osSyncPrintf(VT_FGCOL(GREEN)); // "Message" @@ -1840,7 +1840,7 @@ void Message_ContinueTextbox(GlobalContext* globalCtx, u16 textId) { osSyncPrintf(VT_RST); msgCtx->msgLength = 0; - Message_OpenText(globalCtx, textId); + Message_OpenText(play, textId); msgCtx->msgMode = MSGMODE_NONE; msgCtx->textboxColorAlphaCurrent = msgCtx->textboxColorAlphaTarget; msgCtx->msgMode = MSGMODE_TEXT_CONTINUING; @@ -1848,13 +1848,13 @@ void Message_ContinueTextbox(GlobalContext* globalCtx, u16 textId) { msgCtx->textboxEndType = msgCtx->msgBufPos = msgCtx->unk_E3D0 = msgCtx->textDrawPos = msgCtx->textDelayTimer = 0; msgCtx->textColorAlpha = 255; - if (YREG(31) == 0 && globalCtx->interfaceCtx.unk_1FA == 0) { - Interface_SetDoAction(globalCtx, DO_ACTION_NEXT); + if (YREG(31) == 0 && play->interfaceCtx.unk_1FA == 0) { + Interface_SetDoAction(play, DO_ACTION_NEXT); } msgCtx->textboxColorAlphaCurrent = msgCtx->textboxColorAlphaTarget; } -void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { +void Message_StartOcarina(PlayState* play, u16 ocarinaActionId) { static u16 sOcarinaSongFlagsMap[] = { (1 << OCARINA_SONG_MINUET), (1 << OCARINA_SONG_BOLERO), (1 << OCARINA_SONG_SERENADE), (1 << OCARINA_SONG_REQUIEM), (1 << OCARINA_SONG_NOCTURNE), (1 << OCARINA_SONG_PRELUDE), @@ -1862,7 +1862,7 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { (1 << OCARINA_SONG_SUNS), (1 << OCARINA_SONG_TIME), (1 << OCARINA_SONG_STORMS), (1 << OCARINA_SONG_SCARECROW), }; - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; s32 textId; s16 j; s16 i; @@ -1894,11 +1894,11 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { osSyncPrintf(VT_FGCOL(RED) "☆☆☆☆☆ オカリナ番号=%d(%d) ☆☆☆☆☆\n" VT_RST, ocarinaActionId, 2); noStop = false; if (ocarinaActionId >= 0x893) { - Message_OpenText(globalCtx, ocarinaActionId); // You played the [song name] + Message_OpenText(play, ocarinaActionId); // You played the [song name] textId = ocarinaActionId + 0x86E; } else if (ocarinaActionId == OCARINA_ACTION_MEMORY_GAME) { msgCtx->ocarinaAction = ocarinaActionId; - Message_OpenText(globalCtx, 0x86D); // Play using [A] and [C]. + Message_OpenText(play, 0x86D); // Play using [A] and [C]. textId = ocarinaActionId + 0x86E; } else if (ocarinaActionId == OCARINA_ACTION_FREE_PLAY || ocarinaActionId >= OCARINA_ACTION_CHECK_SARIA) { osSyncPrintf("ocarina_set 000000000000000000 = %d\n", ocarinaActionId); @@ -1907,10 +1907,10 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { Audio_PlaySoundGeneral(NA_SE_SY_TRE_BOX_APPEAR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } if (ocarinaActionId == OCARINA_ACTION_SCARECROW_PLAYBACK) { - Message_OpenText(globalCtx, 0x86F); // Ocarina + Message_OpenText(play, 0x86F); // Ocarina textId = ocarinaActionId + 0x86E; } else { - Message_OpenText(globalCtx, 0x86E); // Play using [A] and [C]; [B] to Stop. + Message_OpenText(play, 0x86E); // Play using [A] and [C]; [B] to Stop. textId = ocarinaActionId + 0x86E; } } else { @@ -1918,19 +1918,19 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { noStop = true; if (ocarinaActionId >= OCARINA_ACTION_PLAYBACK_MINUET) { osSyncPrintf("222222222\n"); - Message_OpenText(globalCtx, 0x86D); // Play using [A] and [C]. + Message_OpenText(play, 0x86D); // Play using [A] and [C]. textId = ocarinaActionId + 0x86E; } else { osSyncPrintf("333333333\n"); textId = ocarinaActionId + 0x86E; - Message_OpenText(globalCtx, textId); // Play using [A] and [C]; [B] to Stop. + Message_OpenText(play, textId); // Play using [A] and [C]; [B] to Stop. } } msgCtx->talkActor = NULL; // "Ocarina Mode" osSyncPrintf("オカリナモード = %d (%x)\n", msgCtx->ocarinaAction, textId); msgCtx->textDelayTimer = 0; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_00; + play->msgCtx.ocarinaMode = OCARINA_MODE_00; R_TEXTBOX_X = 34; R_TEXTBOX_Y = 142; R_TEXTBOX_TEXWIDTH = 512; @@ -1946,7 +1946,7 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { } msgCtx->textboxColorAlphaCurrent = msgCtx->textboxColorAlphaTarget; if (noStop == false) { - Interface_LoadActionLabelB(globalCtx, DO_ACTION_STOP); + Interface_LoadActionLabelB(play, DO_ACTION_STOP); noStop = gSaveContext.unk_13EA; Interface_ChangeAlpha(0xA); gSaveContext.unk_13EA = noStop; @@ -1961,7 +1961,7 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { msgCtx->textBoxType = TEXTBOX_TYPE_BLUE; } else if (ocarinaActionId == OCARINA_ACTION_MEMORY_GAME) { Interface_ChangeAlpha(1); - Message_Decode(globalCtx); + Message_Decode(play); msgCtx->msgMode = MSGMODE_MEMORY_GAME_START; } else if (ocarinaActionId == OCARINA_ACTION_SCARECROW_LONG_PLAYBACK) { // "?????Recording Playback / Recording Playback / Recording Playback / Recording Playback -> " @@ -1979,18 +1979,18 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { Interface_ChangeAlpha(1); } for (k = 0, j = 0; j < 48; j++, k += 0x80) { - func_8006EE50(&globalCtx->msgCtx.font, 0x8140, k); + func_8006EE50(&play->msgCtx.font, 0x8140, k); } } -void func_8010BD58(GlobalContext* globalCtx, u16 ocarinaActionId) { - globalCtx->msgCtx.unk_E40E = 0; - Message_StartOcarina(globalCtx, ocarinaActionId); +void func_8010BD58(PlayState* play, u16 ocarinaActionId) { + play->msgCtx.unk_E40E = 0; + Message_StartOcarina(play, ocarinaActionId); } -void func_8010BD88(GlobalContext* globalCtx, u16 ocarinaActionId) { - globalCtx->msgCtx.unk_E40E = 1; - Message_StartOcarina(globalCtx, ocarinaActionId); +void func_8010BD88(PlayState* play, u16 ocarinaActionId) { + play->msgCtx.unk_E40E = 1; + Message_StartOcarina(play, ocarinaActionId); } u8 Message_GetState(MessageContext* msgCtx) { @@ -2028,8 +2028,8 @@ u8 Message_GetState(MessageContext* msgCtx) { return state; } -void Message_DrawTextBox(GlobalContext* globalCtx, Gfx** p) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_DrawTextBox(PlayState* play, Gfx** p) { + MessageContext* msgCtx = &play->msgCtx; Gfx* gfx = *p; gSPInvalidateTexCache(gfx++, msgCtx->textboxSegment); @@ -2078,7 +2078,7 @@ void Message_SetView(View* view) { /** * Draws the textbox in full and updates ocarina state */ -void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { +void Message_DrawMain(PlayState* play, Gfx** p) { static s16 sOcarinaEffectActorIds[] = { ACTOR_OCEFF_WIPE3, ACTOR_OCEFF_WIPE2, ACTOR_OCEFF_WIPE, ACTOR_OCEFF_SPOT, ACTOR_OCEFF_WIPE, ACTOR_OCEFF_STORM, ACTOR_OCEFF_WIPE4, @@ -2176,10 +2176,10 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { NA_BGM_OCA_NOCTURNE, NA_BGM_OCA_LIGHT, NA_BGM_OCA_SARIA, NA_BGM_OCA_EPONA, NA_BGM_OCA_ZELDA, NA_BGM_OCA_SUNS, NA_BGM_OCA_TIME, NA_BGM_OCA_STORM, }; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - MessageContext* msgCtx = &globalCtx->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; u16 noteBufPos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; Gfx* gfx = *p; s16 r; @@ -2202,7 +2202,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { u16 pad1; u16 j; - gSPSegment(gfx++, 0x02, globalCtx->interfaceCtx.parameterSegment); + gSPSegment(gfx++, 0x02, play->interfaceCtx.parameterSegment); gSPSegment(gfx++, 0x07, msgCtx->textboxSegment); if (msgCtx->msgLength != 0) { @@ -2211,7 +2211,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { msgCtx->textBoxType < TEXTBOX_TYPE_NONE_BOTTOM) { Message_SetView(&msgCtx->view); func_8009457C(&gfx); - Message_DrawTextBox(globalCtx, &gfx); + Message_DrawTextBox(play, &gfx); } func_8009457C(&gfx); @@ -2220,8 +2220,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { gDPSetCombineLERP(gfx++, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE, TEXEL0, 0, PRIMITIVE, 0); - bool isB_Held = CVar_GetS32("gSkipText", 0) != 0 ? CHECK_BTN_ALL(globalCtx->state.input[0].cur.button, BTN_B) - : CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B); + bool isB_Held = CVar_GetS32("gSkipText", 0) != 0 ? CHECK_BTN_ALL(play->state.input[0].cur.button, BTN_B) + : CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B); switch (msgCtx->msgMode) { case MSGMODE_TEXT_START: @@ -2232,19 +2232,19 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { case MSGMODE_TEXT_CONTINUING: if (msgCtx->stateTimer == 1) { for (j = 0, i = 0; i < 48; i++, j += 0x80) { - func_8006EE50(&globalCtx->msgCtx.font, 0x8140, j); + func_8006EE50(&play->msgCtx.font, 0x8140, j); } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); } break; case MSGMODE_TEXT_DISPLAYING: case MSGMODE_TEXT_DELAYED_BREAK: - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_TEXT_AWAIT_INPUT: case MSGMODE_TEXT_AWAIT_NEXT: - Message_DrawText(globalCtx, &gfx); - Message_DrawTextboxIcon(globalCtx, &gfx, R_TEXTBOX_END_XPOS, R_TEXTBOX_END_YPOS); + Message_DrawText(play, &gfx); + Message_DrawTextboxIcon(play, &gfx, R_TEXTBOX_END_XPOS, R_TEXTBOX_END_YPOS); break; case MSGMODE_OCARINA_STARTING: case MSGMODE_SONG_DEMONSTRATION_STARTING: @@ -2252,7 +2252,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_OcaSetInstrument(1); msgCtx->ocarinaStaff = Audio_OcaGetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaNoteBufPos = 0; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; Message_ResetOcarinaNoteState(); sOcarinaNoteFlashTimer = 3; sOcarinaNoteFlashColorIdx = 1; @@ -2286,7 +2286,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } if (msgCtx->ocarinaAction != OCARINA_ACTION_FREE_PLAY && msgCtx->ocarinaAction != OCARINA_ACTION_CHECK_NOWARP) { - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); } break; case MSGMODE_OCARINA_PLAYING: @@ -2320,7 +2320,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } else { // "Ocarina_Flog Correct Example Performance" osSyncPrintf("Ocarina_Flog 正解模範演奏=%x\n", msgCtx->lastPlayedSong); - Message_ContinueTextbox(globalCtx, 0x86F); // Ocarina + Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; msgCtx->stateTimer = 10; @@ -2338,7 +2338,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } else { // "Ocarina_Flog Correct Example Performance" osSyncPrintf("Ocarina_Flog 正解模範演奏=%x\n", msgCtx->lastPlayedSong); - Message_ContinueTextbox(globalCtx, 0x86F); // Ocarina + Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; msgCtx->stateTimer = 10; @@ -2349,7 +2349,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } else if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY) { // "Ocarina_Free Correct Example Performance" osSyncPrintf("Ocarina_Free 正解模範演奏=%x\n", msgCtx->lastPlayedSong); - Message_ContinueTextbox(globalCtx, 0x86F); // Ocarina + Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; msgCtx->stateTimer = 10; @@ -2374,12 +2374,12 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { msgCtx->msgMode = MSGMODE_OCARINA_FAIL; } else if (isB_Held) { Audio_OcaSetInstrument(0); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - Message_CloseTextbox(globalCtx); + play->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_CloseTextbox(play); } if (msgCtx->ocarinaAction != OCARINA_ACTION_FREE_PLAY && msgCtx->ocarinaAction != OCARINA_ACTION_CHECK_NOWARP) { - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); } break; case MSGMODE_OCARINA_CORRECT_PLAYBACK: @@ -2602,30 +2602,30 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { if (msgCtx->msgMode == MSGMODE_OCARINA_CORRECT_PLAYBACK) { // "Correct Example Performance" osSyncPrintf("正解模範演奏=%x\n", msgCtx->lastPlayedSong); - Message_ContinueTextbox(globalCtx, 0x86F); // Ocarina + Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; msgCtx->stateTimer = 1; } else if (msgCtx->msgMode == MSGMODE_SONG_PLAYBACK_SUCCESS) { if (msgCtx->lastPlayedSong >= OCARINA_SONG_SARIAS) { - Message_ContinueTextbox(globalCtx, 0x86F); // Ocarina + Message_ContinueTextbox(play, 0x86F); // Ocarina msgCtx->msgMode = MSGMODE_SONG_PLAYED; msgCtx->textBoxType = TEXTBOX_TYPE_OCARINA; msgCtx->stateTimer = 1; } else { - Message_CloseTextbox(globalCtx); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_CloseTextbox(play); + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } } else { - Message_CloseTextbox(globalCtx); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_03; + Message_CloseTextbox(play); + play->msgCtx.ocarinaMode = OCARINA_MODE_03; } } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_OCARINA_FAIL: case MSGMODE_SONG_PLAYBACK_FAIL: - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); case MSGMODE_OCARINA_FAIL_NO_TEXT: msgCtx->stateTimer--; if (msgCtx->stateTimer == 0) { @@ -2633,8 +2633,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { if (msgCtx->msgMode == MSGMODE_SONG_PLAYBACK_FAIL) { // "kokokokokoko" osSyncPrintf("ここここここ\n"); - Message_ContinueTextbox(globalCtx, 0x88B); // red X background - Message_Decode(globalCtx); + Message_ContinueTextbox(play, 0x88B); // red X background + Message_Decode(play); msgCtx->msgMode = MSGMODE_SONG_PLAYBACK_NOTES_DROP; } else { msgCtx->msgMode = MSGMODE_OCARINA_NOTES_DROP; @@ -2670,14 +2670,14 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { osSyncPrintf("Na_StopOcarinaMode();\n"); osSyncPrintf("Na_StopOcarinaMode();\n"); osSyncPrintf(VT_RST); - Message_Decode(globalCtx); + Message_Decode(play); msgCtx->msgMode = MSGMODE_SETUP_DISPLAY_SONG_PLAYED; msgCtx->ocarinaStaff = Audio_OcaGetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaNoteBufPos = 0; Message_ResetOcarinaNoteState(); if (msgCtx->lastPlayedSong >= OCARINA_SONG_SARIAS && msgCtx->lastPlayedSong < OCARINA_SONG_MEMORY_GAME) { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, + Actor_Spawn(&play->actorCtx, play, sOcarinaEffectActorIds[msgCtx->lastPlayedSong - OCARINA_SONG_SARIAS], player->actor.world.pos.x, player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, sOcarinaEffectActorParams[msgCtx->lastPlayedSong - OCARINA_SONG_SARIAS]); @@ -2686,10 +2686,10 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { break; case MSGMODE_SETUP_DISPLAY_SONG_PLAYED: if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || - globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME || - globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS || - globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) { - Message_DrawText(globalCtx, &gfx); + play->msgCtx.lastPlayedSong == OCARINA_SONG_TIME || + play->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS || + play->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) { + Message_DrawText(play, &gfx); Audio_OcaSetInstrument(1); Audio_OcaSetInstrument(1); Audio_OcaSetSongPlayback(msgCtx->lastPlayedSong + 1, 1); @@ -2701,7 +2701,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_PlayFanfare(sOcarinaSongFanfares[msgCtx->lastPlayedSong]); Audio_SetSoundBanksMute(0x20); } - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY) { msgCtx->ocarinaAction = OCARINA_ACTION_FREE_PLAY_DONE; } @@ -2733,36 +2733,36 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { sOcarinaNoteBufPos = 0; msgCtx->msgMode = MSGMODE_SONG_DEMONSTRATION; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_DISPLAY_SONG_PLAYED_TEXT_BEGIN: - Message_ContinueTextbox(globalCtx, msgCtx->lastPlayedSong + 0x893); // You played [song name] - Message_Decode(globalCtx); + Message_ContinueTextbox(play, msgCtx->lastPlayedSong + 0x893); // You played [song name] + Message_Decode(play); msgCtx->msgMode = MSGMODE_DISPLAY_SONG_PLAYED_TEXT; - if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_TIME - || globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS || - globalCtx->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) { + if (CVar_GetS32("gFastOcarinaPlayback", 0) == 0 || play->msgCtx.lastPlayedSong == OCARINA_SONG_TIME + || play->msgCtx.lastPlayedSong == OCARINA_SONG_STORMS || + play->msgCtx.lastPlayedSong == OCARINA_SONG_SUNS) { msgCtx->stateTimer = 20; } else { msgCtx->stateTimer = 1; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_DISPLAY_SONG_PLAYED_TEXT: msgCtx->stateTimer--; if (msgCtx->stateTimer == 0) { msgCtx->msgMode = MSGMODE_SONG_PLAYED_ACT_BEGIN; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SONG_PLAYED_ACT_BEGIN: Audio_OcaSetInstrument(0); Message_ResetOcarinaNoteState(); msgCtx->msgMode = MSGMODE_SONG_PLAYED_ACT; msgCtx->stateTimer = 2; - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SONG_PLAYED_ACT: msgCtx->stateTimer--; @@ -2771,17 +2771,17 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { (msgCtx->ocarinaAction < OCARINA_ACTION_PLAYBACK_MINUET || msgCtx->ocarinaAction >= OCARINA_ACTION_PLAYBACK_SARIA)) { if (msgCtx->disableWarpSongs || (interfaceCtx->restrictions.warpSongs == 3 && !gSaveContext.n64ddFlag)) { - Message_StartTextbox(globalCtx, 0x88C, NULL); // "You can't warp here!" - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_StartTextbox(play, 0x88C, NULL); // "You can't warp here!" + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } else if ((gSaveContext.eventInf[0] & 0xF) != 1) { - Message_StartTextbox(globalCtx, msgCtx->lastPlayedSong + 0x88D, + Message_StartTextbox(play, msgCtx->lastPlayedSong + 0x88D, NULL); // "Warp to [place name]?" - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; } else { - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); } } else { - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); if (msgCtx->lastPlayedSong == OCARINA_SONG_EPONAS) { DREG(53) = 1; } @@ -2789,31 +2789,31 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { osSyncPrintf("☆☆☆ocarina=%d message->ocarina_no=%d ", msgCtx->lastPlayedSong, msgCtx->ocarinaAction); if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY_DONE) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; if (msgCtx->lastPlayedSong == OCARINA_SONG_SCARECROW) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_0B; + play->msgCtx.ocarinaMode = OCARINA_MODE_0B; } } else if (msgCtx->ocarinaAction >= OCARINA_ACTION_CHECK_MINUET) { osSyncPrintf(VT_FGCOL(YELLOW)); osSyncPrintf("Ocarina_PC_Wind=%d(%d) ☆☆☆ ", OCARINA_ACTION_CHECK_MINUET, msgCtx->ocarinaAction - OCARINA_ACTION_CHECK_MINUET); if (msgCtx->lastPlayedSong + OCARINA_ACTION_CHECK_MINUET == msgCtx->ocarinaAction) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_03; + play->msgCtx.ocarinaMode = OCARINA_MODE_03; } else { - globalCtx->msgCtx.ocarinaMode = msgCtx->lastPlayedSong - 1; + play->msgCtx.ocarinaMode = msgCtx->lastPlayedSong - 1; } } else { osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("Ocarina_C_Wind=%d(%d) ☆☆☆ ", OCARINA_ACTION_PLAYBACK_MINUET, msgCtx->ocarinaAction - OCARINA_ACTION_PLAYBACK_MINUET); if (msgCtx->lastPlayedSong + OCARINA_ACTION_PLAYBACK_MINUET == msgCtx->ocarinaAction) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_03; + play->msgCtx.ocarinaMode = OCARINA_MODE_03; } else { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } } osSyncPrintf(VT_RST); - osSyncPrintf("→ OCARINA_MODE=%d\n", globalCtx->msgCtx.ocarinaMode); + osSyncPrintf("→ OCARINA_MODE=%d\n", play->msgCtx.ocarinaMode); } } break; @@ -2840,7 +2840,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } } case MSGMODE_SONG_DEMONSTRATION_DONE: - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SONG_PLAYBACK: msgCtx->ocarinaStaff = Audio_OcaGetPlayingStaff(); @@ -2856,7 +2856,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { msgCtx->msgMode = MSGMODE_SONG_PLAYBACK_SUCCESS; if (!gSaveContext.n64ddFlag) { - Item_Give(globalCtx, ITEM_SONG_MINUET + gOcarinaSongItemMap[msgCtx->ocarinaStaff->state]); + Item_Give(play, ITEM_SONG_MINUET + gOcarinaSongItemMap[msgCtx->ocarinaStaff->state]); } osSyncPrintf(VT_FGCOL(YELLOW)); @@ -2872,12 +2872,12 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { msgCtx->stateTimer = 10; msgCtx->msgMode = MSGMODE_SONG_PLAYBACK_FAIL; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_OCARINA_AWAIT_INPUT: - Message_DrawText(globalCtx, &gfx); - if (Message_ShouldAdvance(globalCtx)) { - func_8010BD58(globalCtx, msgCtx->ocarinaAction); + Message_DrawText(play, &gfx); + if (Message_ShouldAdvance(play)) { + func_8010BD58(play, msgCtx->ocarinaAction); } break; case MSGMODE_SCARECROW_LONG_RECORDING_START: @@ -2890,7 +2890,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { sOcarinaNoteBufLen = 0; Message_ResetOcarinaNoteState(); msgCtx->msgMode = MSGMODE_SCARECROW_LONG_RECORDING_ONGOING; - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SCARECROW_LONG_RECORDING_ONGOING: msgCtx->ocarinaStaff = Audio_OcaGetRecordingStaff(); @@ -2924,8 +2924,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { osSyncPrintf("aaaaaaaaaaaaaa\n"); Audio_OcaSetRecordingState(0); msgCtx->stateTimer = 10; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; - Message_CloseTextbox(globalCtx); + play->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_CloseTextbox(play); // "Recording complete!!!!!!!!!Recording Complete" osSyncPrintf("録音終了!!!!!!!!!録音終了\n"); osSyncPrintf(VT_FGCOL(YELLOW)); @@ -2938,7 +2938,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { osSyncPrintf(VT_RST); osSyncPrintf("\n====================================================================\n"); } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SCARECROW_LONG_PLAYBACK: case MSGMODE_SCARECROW_PLAYBACK: @@ -2963,8 +2963,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { if (msgCtx->ocarinaStaff->state == 0) { osSyncPrintf("bbbbbbbbbbb\n"); Audio_OcaSetInstrument(0); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_0F; - Message_CloseTextbox(globalCtx); + play->msgCtx.ocarinaMode = OCARINA_MODE_0F; + Message_CloseTextbox(play); } } else { msgCtx->stateTimer--; @@ -2974,7 +2974,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_OcaSetRecordingState(2); Audio_OcaSetInstrument(1); msgCtx->msgMode = MSGMODE_SCARECROW_RECORDING_ONGOING; - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SCARECROW_RECORDING_ONGOING: msgCtx->ocarinaStaff = Audio_OcaGetRecordingStaff(); @@ -3006,16 +3006,16 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_OcaSetRecordingState(0); Audio_PlaySoundGeneral(NA_SE_SY_OCARINA_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); msgCtx->msgMode = MSGMODE_SCARECROW_RECORDING_FAILED; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SCARECROW_RECORDING_FAILED: osSyncPrintf("cccccccccccc\n"); Audio_OcaSetInstrument(0); - Message_StartTextbox(globalCtx, 0x40AD, NULL); // Bonooru doesn't remember your song - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + Message_StartTextbox(play, 0x40AD, NULL); // Bonooru doesn't remember your song + play->msgCtx.ocarinaMode = OCARINA_MODE_04; break; case MSGMODE_MEMORY_GAME_START: Audio_OcaSetInstrument(1); @@ -3078,7 +3078,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_PlaySoundGeneral(NA_SE_SY_OCARINA_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); msgCtx->stateTimer = 10; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_03; + play->msgCtx.ocarinaMode = OCARINA_MODE_03; } else if (msgCtx->ocarinaStaff->state == 0xD) { // "Musical round succeeded!!!!!!!!!" osSyncPrintf("輪唱成功!!!!!!!!!\n"); @@ -3086,7 +3086,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { msgCtx->msgMode = MSGMODE_MEMORY_GAME_ROUND_SUCCESS; msgCtx->stateTimer = 30; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_MEMORY_GAME_ROUND_SUCCESS: msgCtx->ocarinaStaff = Audio_OcaGetPlayingStaff(); @@ -3105,10 +3105,10 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Message_ResetOcarinaNoteState(); msgCtx->msgMode = MSGMODE_MEMORY_GAME_START_NEXT_ROUND; } else { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_0F; + play->msgCtx.ocarinaMode = OCARINA_MODE_0F; } } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_MEMORY_GAME_START_NEXT_ROUND: if (!Audio_IsSfxPlaying(NA_SE_SY_METRONOME)) { @@ -3122,7 +3122,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_OcaSetInstrument(1); msgCtx->ocarinaStaff = Audio_OcaGetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaNoteBufPos = 0; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; Message_ResetOcarinaNoteState(); func_800ECC04(sOcarinaSongBitFlags + 0xC000); msgCtx->msgMode = MSGMODE_FROGS_PLAYING; @@ -3138,16 +3138,16 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { case MSGMODE_FROGS_WAITING: break; case MSGMODE_TEXT_DONE: - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); switch (msgCtx->textboxEndType) { case TEXTBOX_ENDTYPE_2_CHOICE: - Message_HandleChoiceSelection(globalCtx, 1); - Message_DrawTextboxIcon(globalCtx, &gfx, msgCtx->textPosX, msgCtx->textPosY); + Message_HandleChoiceSelection(play, 1); + Message_DrawTextboxIcon(play, &gfx, msgCtx->textPosX, msgCtx->textPosY); break; case TEXTBOX_ENDTYPE_3_CHOICE: - Message_HandleChoiceSelection(globalCtx, 2); - Message_DrawTextboxIcon(globalCtx, &gfx, msgCtx->textPosX, msgCtx->textPosY); + Message_HandleChoiceSelection(play, 2); + Message_DrawTextboxIcon(play, &gfx, msgCtx->textPosX, msgCtx->textPosY); break; case TEXTBOX_ENDTYPE_PERSISTENT: if (msgCtx->textId >= 0x6D && msgCtx->textId < 0x73) { @@ -3160,7 +3160,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { break; case TEXTBOX_ENDTYPE_EVENT: default: - Message_DrawTextboxIcon(globalCtx, &gfx, R_TEXTBOX_END_XPOS, R_TEXTBOX_END_YPOS); + Message_DrawTextboxIcon(play, &gfx, R_TEXTBOX_END_XPOS, R_TEXTBOX_END_YPOS); case TEXTBOX_ENDTYPE_FADING: break; } @@ -3285,7 +3285,7 @@ void Message_DrawDebugVariableChanged(s16* var, GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -void Message_DrawDebugText(GlobalContext* globalCtx, Gfx** p) { +void Message_DrawDebugText(PlayState* play, Gfx** p) { s32 pad; GfxPrint printer; s32 pad1; @@ -3298,38 +3298,38 @@ void Message_DrawDebugText(GlobalContext* globalCtx, Gfx** p) { GfxPrint_SetPos(&printer, 14, 26); GfxPrint_Printf(&printer, "%s", "="); GfxPrint_SetPos(&printer, 16, 26); - GfxPrint_Printf(&printer, "%x", globalCtx->msgCtx.textId); + GfxPrint_Printf(&printer, "%x", play->msgCtx.textId); *p = GfxPrint_Close(&printer); GfxPrint_Destroy(&printer); } -void Message_Draw(GlobalContext* globalCtx) { +void Message_Draw(PlayState* play) { Gfx* plusOne; Gfx* polyOpaP; s16 watchVar; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); watchVar = gSaveContext.scarecrowCustomSongSet; - Message_DrawDebugVariableChanged(&watchVar, globalCtx->state.gfxCtx); - if (BREG(0) != 0 && globalCtx->msgCtx.textId != 0) { + Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx); + if (BREG(0) != 0 && play->msgCtx.textId != 0) { plusOne = Graph_GfxPlusOne(polyOpaP = POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, plusOne); - Message_DrawDebugText(globalCtx, &plusOne); + Message_DrawDebugText(play, &plusOne); gSPEndDisplayList(plusOne++); Graph_BranchDlist(polyOpaP, plusOne); POLY_OPA_DISP = plusOne; } plusOne = Graph_GfxPlusOne(polyOpaP = POLY_OPA_DISP); gSPDisplayList(OVERLAY_DISP++, plusOne); - Message_DrawMain(globalCtx, &plusOne); + Message_DrawMain(play, &plusOne); gSPEndDisplayList(plusOne++); Graph_BranchDlist(polyOpaP, plusOne); POLY_OPA_DISP = plusOne; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Message_Update(GlobalContext* globalCtx) { +void Message_Update(PlayState* play) { static s16 sTextboxXPositions[] = { 34, 34, 34, 34, 34, 34, }; @@ -3352,10 +3352,10 @@ void Message_Update(GlobalContext* globalCtx) { }; static u8 D_80153D74 = 0; static u16 D_80153D78 = 0; - MessageContext* msgCtx = &globalCtx->msgCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - Player* player = GET_PLAYER(globalCtx); - Input* input = &globalCtx->state.input[0]; + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + Input* input = &play->state.input[0]; s16 var; s16 focusScreenPosX; s16 averageY = 0; @@ -3365,7 +3365,7 @@ void Message_Update(GlobalContext* globalCtx) { if (BREG(0) != 0) { if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN) && CHECK_BTN_ALL(input->cur.button, BTN_L)) { osSyncPrintf("msgno=%d\n", D_80153D78); - Message_StartTextbox(globalCtx, R_MESSAGE_DEBUGGER_TEXTID, NULL); + Message_StartTextbox(play, R_MESSAGE_DEBUGGER_TEXTID, NULL); D_80153D78 = (D_80153D78 + 1) % 10; } if (R_MESSAGE_DEBUGGER_SELECT != 0) { @@ -3376,7 +3376,7 @@ void Message_Update(GlobalContext* globalCtx) { if (entry->textId == R_MESSAGE_DEBUGGER_TEXTID) { // "The message was found! !! !!" osSyncPrintf(" メッセージが,見つかった!!! = %x\n", R_MESSAGE_DEBUGGER_TEXTID); - Message_StartTextbox(globalCtx, R_MESSAGE_DEBUGGER_TEXTID, NULL); + Message_StartTextbox(play, R_MESSAGE_DEBUGGER_TEXTID, NULL); R_MESSAGE_DEBUGGER_TEXTID++; R_MESSAGE_DEBUGGER_SELECT = 0; return; @@ -3404,7 +3404,7 @@ void Message_Update(GlobalContext* globalCtx) { if (D_8014B2F4 >= 4) { var = true; } - } else if (YREG(15) != 0 || globalCtx->sceneNum == SCENE_HAIRAL_NIWA) { + } else if (YREG(15) != 0 || play->sceneNum == SCENE_HAIRAL_NIWA) { var = true; } else if (D_8014B2F4 >= 4 || msgCtx->talkActor == NULL) { var = true; @@ -3412,9 +3412,9 @@ void Message_Update(GlobalContext* globalCtx) { if (var) { if (msgCtx->talkActor != NULL) { - Actor_GetScreenPos(globalCtx, &GET_PLAYER(globalCtx)->actor, &focusScreenPosX, + Actor_GetScreenPos(play, &GET_PLAYER(play)->actor, &focusScreenPosX, &playerFocusScreenPosY); - Actor_GetScreenPos(globalCtx, msgCtx->talkActor, &focusScreenPosX, &actorFocusScreenPosY); + Actor_GetScreenPos(play, msgCtx->talkActor, &focusScreenPosX, &actorFocusScreenPosY); if (playerFocusScreenPosY >= actorFocusScreenPosY) { averageY = ((playerFocusScreenPosY - actorFocusScreenPosY) / 2) + actorFocusScreenPosY; @@ -3431,14 +3431,14 @@ void Message_Update(GlobalContext* globalCtx) { var = msgCtx->textBoxType; if (!msgCtx->textBoxPos) { // variable position - if (YREG(15) != 0 || globalCtx->sceneNum == SCENE_HAIRAL_NIWA) { + if (YREG(15) != 0 || play->sceneNum == SCENE_HAIRAL_NIWA) { if (averageY < XREG(92)) { R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var]; } else { R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var]; } - } else if (globalCtx->sceneNum == SCENE_MARKET_DAY || globalCtx->sceneNum == SCENE_MARKET_NIGHT || - globalCtx->sceneNum == SCENE_MARKET_RUINS) { + } else if (play->sceneNum == SCENE_MARKET_DAY || play->sceneNum == SCENE_MARKET_NIGHT || + play->sceneNum == SCENE_MARKET_RUINS) { if (averageY < XREG(93)) { R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var]; } else { @@ -3490,11 +3490,11 @@ void Message_Update(GlobalContext* globalCtx) { case MSGMODE_TEXT_STARTING: msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG; if (YREG(31) == 0) { - Interface_SetDoAction(globalCtx, DO_ACTION_NEXT); + Interface_SetDoAction(play, DO_ACTION_NEXT); } break; case MSGMODE_TEXT_NEXT_MSG: - Message_Decode(globalCtx); + Message_Decode(play); if (sTextFade) { Interface_ChangeAlpha(1); } @@ -3506,7 +3506,7 @@ void Message_Update(GlobalContext* globalCtx) { case MSGMODE_TEXT_CONTINUING: msgCtx->stateTimer--; if (msgCtx->stateTimer == 0) { - Message_Decode(globalCtx); + Message_Decode(play); } break; case MSGMODE_TEXT_DISPLAYING: @@ -3517,7 +3517,7 @@ void Message_Update(GlobalContext* globalCtx) { } break; case MSGMODE_TEXT_AWAIT_INPUT: - if (YREG(31) == 0 && Message_ShouldAdvance(globalCtx)) { + if (YREG(31) == 0 && Message_ShouldAdvance(play)) { msgCtx->msgMode = MSGMODE_TEXT_DISPLAYING; msgCtx->textDrawPos++; } @@ -3529,7 +3529,7 @@ void Message_Update(GlobalContext* globalCtx) { } break; case MSGMODE_TEXT_AWAIT_NEXT: - if (Message_ShouldAdvance(globalCtx)) { + if (Message_ShouldAdvance(play)) { msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG; msgCtx->textUnskippable = false; msgCtx->msgBufPos++; @@ -3539,29 +3539,29 @@ void Message_Update(GlobalContext* globalCtx) { if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_FADING) { msgCtx->stateTimer--; if (msgCtx->stateTimer == 0) { - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); } } else if (msgCtx->textboxEndType != TEXTBOX_ENDTYPE_PERSISTENT && msgCtx->textboxEndType != TEXTBOX_ENDTYPE_EVENT && YREG(31) == 0) { if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_2_CHOICE && - globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01) { - if (Message_ShouldAdvance(globalCtx)) { - osSyncPrintf("OCARINA_MODE=%d -> ", globalCtx->msgCtx.ocarinaMode); - globalCtx->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04; + play->msgCtx.ocarinaMode == OCARINA_MODE_01) { + if (Message_ShouldAdvance(play)) { + osSyncPrintf("OCARINA_MODE=%d -> ", play->msgCtx.ocarinaMode); + play->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04; osSyncPrintf("InRaceSeq=%d(%d) OCARINA_MODE=%d --> ", gSaveContext.eventInf[0] & 0xF, 1, - globalCtx->msgCtx.ocarinaMode); - Message_CloseTextbox(globalCtx); - osSyncPrintf("OCARINA_MODE=%d\n", globalCtx->msgCtx.ocarinaMode); + play->msgCtx.ocarinaMode); + Message_CloseTextbox(play); + osSyncPrintf("OCARINA_MODE=%d\n", play->msgCtx.ocarinaMode); } - } else if (Message_ShouldAdvanceSilent(globalCtx)) { + } else if (Message_ShouldAdvanceSilent(play)) { osSyncPrintf("select=%d\n", msgCtx->textboxEndType); if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_HAS_NEXT) { Audio_PlaySoundGeneral(NA_SE_SY_MESSAGE_PASS, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Message_ContinueTextbox(globalCtx, sNextTextId); + Message_ContinueTextbox(play, sNextTextId); } else { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); } } } @@ -3580,15 +3580,15 @@ void Message_Update(GlobalContext* globalCtx) { msgCtx->textId == 0x2015 || msgCtx->textId == 0x3040) { gSaveContext.unk_13EE = 0x32; } - if (globalCtx->csCtx.state == 0) { + if (play->csCtx.state == 0) { osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("day_time=%x active_camera=%d ", gSaveContext.cutsceneIndex, globalCtx->activeCamera); + osSyncPrintf("day_time=%x active_camera=%d ", gSaveContext.cutsceneIndex, play->activeCamera); if (msgCtx->textId != 0x2061 && msgCtx->textId != 0x2025 && msgCtx->textId != 0x208C && ((msgCtx->textId < 0x88D || msgCtx->textId >= 0x893) || msgCtx->choiceIndex != 0) && (msgCtx->textId != 0x3055 && gSaveContext.cutsceneIndex < 0xFFF0)) { osSyncPrintf("=== day_time=%x ", ((void)0, gSaveContext.cutsceneIndex)); - if (globalCtx->activeCamera == MAIN_CAM) { + if (play->activeCamera == MAIN_CAM) { if (gSaveContext.unk_13EE == 0 || gSaveContext.unk_13EE == 1 || gSaveContext.unk_13EE == 2) { gSaveContext.unk_13EE = 0x32; } @@ -3605,7 +3605,7 @@ void Message_Update(GlobalContext* globalCtx) { if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_PERSISTENT) { msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_02; + play->msgCtx.ocarinaMode = OCARINA_MODE_02; } else { msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT; } @@ -3624,16 +3624,16 @@ void Message_Update(GlobalContext* globalCtx) { player->naviActor->flags |= 0x10000; } if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY_DONE && - (globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_01 || - globalCtx->msgCtx.ocarinaMode == OCARINA_MODE_0B)) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + (play->msgCtx.ocarinaMode == OCARINA_MODE_01 || + play->msgCtx.ocarinaMode == OCARINA_MODE_0B)) { + play->msgCtx.ocarinaMode = OCARINA_MODE_04; if (msgCtx->unk_E3F2 == OCARINA_SONG_SUNS) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; } } } sLastPlayedSong = 0xFF; - osSyncPrintf("OCARINA_MODE=%d chk_ocarina_no=%d\n", globalCtx->msgCtx.ocarinaMode, msgCtx->unk_E3F2); + osSyncPrintf("OCARINA_MODE=%d chk_ocarina_no=%d\n", play->msgCtx.ocarinaMode, msgCtx->unk_E3F2); break; case MSGMODE_PAUSED: break; diff --git a/soh/src/code/z_onepointdemo.c b/soh/src/code/z_onepointdemo.c index 5dcdeb2e4..704c28585 100644 --- a/soh/src/code/z_onepointdemo.c +++ b/soh/src/code/z_onepointdemo.c @@ -56,10 +56,10 @@ void OnePointCutscene_SetCsCamPoints(Camera* camera, s16 actionParameters, s16 i onePointCamData->initTimer = initTimer; } -s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Actor* actor, s16 timer) { - Camera* csCam = globalCtx->cameraPtrs[camIdx]; - Camera* childCam = globalCtx->cameraPtrs[csCam->childCamIdx]; - Camera* mainCam = globalCtx->cameraPtrs[MAIN_CAM]; +s32 OnePointCutscene_SetInfo(PlayState* play, s16 camIdx, s16 csId, Actor* actor, s16 timer) { + Camera* csCam = play->cameraPtrs[camIdx]; + Camera* childCam = play->cameraPtrs[csCam->childCamIdx]; + Camera* mainCam = play->cameraPtrs[MAIN_CAM]; Player* player = mainCam->player; VecSph spD0; s32 i; @@ -75,9 +75,9 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act if (timer < 20) { timer = 20; } - D_801208EC[0].atTargetInit = globalCtx->view.lookAt; - D_801208EC[0].eyeTargetInit = globalCtx->view.eye; - D_801208EC[0].fovTargetInit = globalCtx->view.fovy; + D_801208EC[0].atTargetInit = play->view.lookAt; + D_801208EC[0].eyeTargetInit = play->view.eye; + D_801208EC[0].fovTargetInit = play->view.fovy; D_801208EC[1].atTargetInit = mainCam->at; D_801208EC[1].eyeTargetInit = mainCam->eye; D_801208EC[1].fovTargetInit = mainCam->fov; @@ -88,12 +88,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801208EC; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 1030: - D_80120964[0].atTargetInit = globalCtx->view.lookAt; - D_80120964[0].eyeTargetInit = globalCtx->view.eye; - D_80120964[0].fovTargetInit = globalCtx->view.fovy; + D_80120964[0].atTargetInit = play->view.lookAt; + D_80120964[0].eyeTargetInit = play->view.eye; + D_80120964[0].fovTargetInit = play->view.fovy; OLib_Vec3fDiffToVecSphGeo(&spD0, &mainCam->at, &mainCam->eye); D_80120964[1].eyeTargetInit.y = BINANG_TO_DEGF(spD0.yaw); D_80120964[1].timerInit = timer - 1; @@ -101,12 +101,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80120964; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 5000: - D_801209B4[0].atTargetInit = D_801209B4[1].atTargetInit = globalCtx->view.lookAt; - D_801209B4[0].eyeTargetInit = globalCtx->view.eye; - D_801209B4[0].fovTargetInit = D_801209B4[2].fovTargetInit = globalCtx->view.fovy; + D_801209B4[0].atTargetInit = D_801209B4[1].atTargetInit = play->view.lookAt; + D_801209B4[0].eyeTargetInit = play->view.eye; + D_801209B4[0].fovTargetInit = D_801209B4[2].fovTargetInit = play->view.fovy; OLib_Vec3fDiffToVecSphGeo(&spD0, &actor->focus.pos, &mainCam->at); spD0.r = mainCam->dist; OnePointCutscene_AddVecSphToVec3f(&D_801209B4[1].eyeTargetInit, &D_801209B4[1].atTargetInit, &spD0); @@ -115,29 +115,29 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801209B4; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 5010: - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_ATTENTION); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &mainCam->at, &mainCam->eye); + func_800C0808(play, camIdx, player, CAM_SET_CS_ATTENTION); + Play_CameraSetAtEye(play, camIdx, &mainCam->at, &mainCam->eye); csCam->roll = 0; break; case 9500: csInfo->keyFrames = D_80120A54; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 2260: D_80120ACC[0].atTargetInit.x = D_80120ACC[2].atTargetInit.x = - ((mainCam->globalCtx->state.frames & 1) ? -10.0f : 10.0f) + (Rand_ZeroOne() * 8.0f); + ((mainCam->play->state.frames & 1) ? -10.0f : 10.0f) + (Rand_ZeroOne() * 8.0f); D_80120ACC[0].eyeTargetInit.x = D_80120ACC[2].eyeTargetInit.x = - ((mainCam->globalCtx->state.frames & 1) ? 20.0f : -20.0f) + (Rand_ZeroOne() * 5.0f); + ((mainCam->play->state.frames & 1) ? 20.0f : -20.0f) + (Rand_ZeroOne() * 5.0f); csInfo->keyFrames = D_80120ACC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 2270: csInfo->keyFrames = D_80120B94; @@ -153,8 +153,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act } D_80120B94[camIdx - 1].eyeTargetInit.y = - ((mainCam->globalCtx->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + ((mainCam->play->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 5); Quake_SetSpeed(i, 400); @@ -174,8 +174,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act } } D_80120D4C[camIdx - 1].eyeTargetInit.y = - ((mainCam->globalCtx->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + ((mainCam->play->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 5); Quake_SetSpeed(i, 400); @@ -186,7 +186,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80120E64; csInfo->keyFrameCnt = 8; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 5); Quake_SetSpeed(i, 400); @@ -202,13 +202,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80120FA4; csInfo->keyFrameCnt = 6; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 2340: csInfo->keyFrames = D_80121094; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 5); Quake_SetSpeed(i, 400); @@ -219,7 +219,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_8012110C; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 2200: { s16 sp82; @@ -227,15 +227,15 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act s16 sp7E; s16 sp7C; - Actor_GetScreenPos(globalCtx, &player->actor, &sp82, &sp7E); - Actor_GetScreenPos(globalCtx, actor, &sp80, &sp7C); + Actor_GetScreenPos(play, &player->actor, &sp82, &sp7E); + Actor_GetScreenPos(play, actor, &sp80, &sp7C); if ((sp82 > 0) && (sp82 < 320) && (sp7E > 0) && (sp7E < 240) && (sp80 > 0) && (sp80 < 320) && (sp7C > 0) && (sp7C < 240) && - !OnePointCutscene_BgCheckLineTest(&globalCtx->colCtx, &actor->focus.pos, &player->actor.focus.pos)) { - D_80121184[0].atTargetInit.x = (globalCtx->view.lookAt.x + actor->focus.pos.x) * 0.5f; - D_80121184[0].atTargetInit.y = (globalCtx->view.lookAt.y + actor->focus.pos.y) * 0.5f; - D_80121184[0].atTargetInit.z = (globalCtx->view.lookAt.z + actor->focus.pos.z) * 0.5f; - D_80121184[0].eyeTargetInit = globalCtx->view.eye; + !OnePointCutscene_BgCheckLineTest(&play->colCtx, &actor->focus.pos, &player->actor.focus.pos)) { + D_80121184[0].atTargetInit.x = (play->view.lookAt.x + actor->focus.pos.x) * 0.5f; + D_80121184[0].atTargetInit.y = (play->view.lookAt.y + actor->focus.pos.y) * 0.5f; + D_80121184[0].atTargetInit.z = (play->view.lookAt.z + actor->focus.pos.z) * 0.5f; + D_80121184[0].eyeTargetInit = play->view.eye; D_80121184[0].eyeTargetInit.y = player->actor.focus.pos.y + 20.0f; D_80121184[0].fovTargetInit = mainCam->fov * 0.75f; @@ -255,13 +255,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801211D4; csInfo->keyFrameCnt = 2; } - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_UNK3); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_UNK3); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); } break; case 2290: { Actor* rideActor = player->rideActor; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); if (rideActor != NULL) { rideActor->freezeTimer = 180; } @@ -269,42 +269,42 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80121224; csInfo->keyFrameCnt = 6; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); } break; case 5120: - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); csInfo->keyFrames = D_80121314; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4510: D_8012133C[0].eyeTargetInit = actor->world.pos; D_8012133C[0].eyeTargetInit.y = player->actor.world.pos.y + 40.0f; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); csInfo->keyFrames = D_8012133C; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4500: Actor_GetFocus(&spA0, actor); spC0 = spA0.pos; - spC0.y = OnePointCutscene_RaycastFloor(&globalCtx->colCtx, &spC0) + 40.0f; + spC0.y = OnePointCutscene_RaycastFloor(&play->colCtx, &spC0) + 40.0f; spD0.r = 150.0f; spD0.yaw = spA0.rot.y; spD0.pitch = 0x3E8; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); - func_8002DF54(globalCtx, NULL, 8); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); + func_8002DF54(play, NULL, 8); csCam->roll = 0; csCam->fov = 50.0f; if (csCam->childCamIdx != SUBCAM_FREE) { - OnePointCutscene_EndCutscene(globalCtx, csCam->childCamIdx); + OnePointCutscene_EndCutscene(play, csCam->childCamIdx); } break; case 2210: @@ -314,34 +314,34 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act if (Rand_ZeroOne() < 0.0f) { D_801213B4[3].eyeTargetInit.x = -D_801213B4[3].eyeTargetInit.x; } - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); csInfo->keyFrames = D_801213B4; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 1010: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &childCam->at, &childCam->eye); - Gameplay_CameraSetFov(globalCtx, camIdx, childCam->fov); - Gameplay_SetCameraRoll(globalCtx, camIdx, childCam->roll); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &childCam->at, &childCam->eye); + Play_CameraSetFov(play, camIdx, childCam->fov); + Play_SetCameraRoll(play, camIdx, childCam->roll); break; case 9601: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_CS_3); - Gameplay_CameraChangeSetting(globalCtx, MAIN_CAM, mainCam->prevSetting); + Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3); + Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting); OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120398); break; case 9602: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_CS_3); - Gameplay_CameraChangeSetting(globalCtx, MAIN_CAM, mainCam->prevSetting); + Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3); + Play_CameraChangeSetting(play, MAIN_CAM, mainCam->prevSetting); OnePointCutscene_SetCsCamPoints(csCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120434); break; case 4175: csInfo->keyFrames = D_8012147C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4180: spC0.x = -1881.0f; @@ -350,24 +350,24 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spB4.x = -1979.0f; spB4.y = 703.0f; spB4.z = -269.0f; - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 6; csCam->fov = 75.0f; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); break; case 3040: - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); D_8012151C[0].timerInit = timer - 1; csInfo->keyFrames = D_8012151C; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3020: D_8012156C[1].timerInit = timer - 1; - if (mainCam->globalCtx->state.frames & 1) { + if (mainCam->play->state.frames & 1) { D_8012156C[0].atTargetInit.x = -D_8012156C[0].atTargetInit.x; D_8012156C[0].eyeTargetInit.x = -D_8012156C[0].eyeTargetInit.x; D_8012156C[1].atTargetInit.x = -D_8012156C[1].atTargetInit.x; @@ -380,8 +380,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_8012156C; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); - func_8002DF54(globalCtx, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); break; case 3010: D_801215BC[0].timerInit = timer; @@ -389,13 +389,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801215BC; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3070: csInfo->keyFrames = D_801215E4; csInfo->keyFrameCnt = 10; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 3); Quake_SetSpeed(i, 22000); @@ -406,34 +406,34 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80121774; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3090: - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); csInfo->keyFrames = D_80121814; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3100: VEC_SET(spB4, 0.0f, -280.0f, -1400.0f); Actor_GetFocus(&spA0, actor); spC0 = spA0.pos; - func_800C0808(globalCtx, camIdx, player, CAM_SET_PIVOT_VERTICAL); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + func_800C0808(play, camIdx, player, CAM_SET_PIVOT_VERTICAL); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0; csCam->fov = 70.0f; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); break; case 3380: case 3065: csInfo->keyFrames = D_801218B4; csInfo->keyFrameCnt = 2; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 1); Quake_SetSpeed(i, 24000); @@ -444,12 +444,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80121904; csInfo->keyFrameCnt = 2; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3050: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_CS_3); - func_8002DF54(globalCtx, &player->actor, 5); + Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3); + func_8002DF54(play, &player->actor, 5); OnePointCutscene_SetCsCamPoints(csCam, D_80120304 | 0x2000, D_80120300, D_8012013C, D_8012021C); func_80078884(NA_SE_SY_CORRECT_CHIME); OnePointCutscene_Vec3sToVec3f(&mainCam->at, &D_8012013C[D_801202FC - 2].pos); @@ -478,26 +478,26 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csCam->unk_14C |= 2; csInfo->keyFrameCnt = 2; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3130: csInfo->keyFrames = D_80121A44; csInfo->keyFrameCnt = 12; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); csCam->unk_14C |= 2; break; case 3140: - D_80121C24[0].atTargetInit = globalCtx->view.lookAt; - D_80121C24[0].eyeTargetInit = globalCtx->view.eye; - D_80121C24[0].fovTargetInit = globalCtx->view.fovy; + D_80121C24[0].atTargetInit = play->view.lookAt; + D_80121C24[0].eyeTargetInit = play->view.eye; + D_80121C24[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_80121C24; csInfo->keyFrameCnt = 7; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3150: spC0.x = 1890.0f; @@ -506,11 +506,11 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spB4.x = 1729.0f; spB4.y = 995.0f; spB4.z = -1405.0f; - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0x50; csCam->fov = 55.0f; - func_8002DF38(globalCtx, &player->actor, 8); + func_8002DF38(play, &player->actor, 8); break; case 3170: Actor_GetWorld(&spA0, actor); @@ -521,12 +521,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act Actor_GetWorld(&spA0, &player->actor); spD0.yaw = OnePointCutscene_Vec3fYaw(&spC0, &spA0.pos) - 0x7D0; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); - Gameplay_CopyCamera(globalCtx, MAIN_CAM, camIdx); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); + Play_CopyCamera(play, MAIN_CAM, camIdx); csCam->roll = -1; csCam->fov = 55.0f; - func_8002DF38(globalCtx, actor, 1); + func_8002DF38(play, actor, 1); break; case 3160: Actor_GetWorld(&spA0, actor); @@ -535,11 +535,11 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spD0.yaw = spA0.rot.y; spD0.r = 150.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0; csCam->fov = 55.0f; - func_8002DF38(globalCtx, &player->actor, 8); + func_8002DF38(play, &player->actor, 8); break; case 3180: Actor_GetWorldPosShapeRot(&spA0, actor); @@ -549,16 +549,16 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spD0.yaw = spA0.rot.y; spD0.pitch = -0xAF0; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0; csCam->fov = 60.0f; - func_8002DF38(globalCtx, actor, 1); + func_8002DF38(play, actor, 1); break; case 3190: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FOREST_DEFEAT_POE); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FOREST_DEFEAT_POE); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); - func_8002DF38(globalCtx, actor, 0xC); + func_8002DF38(play, actor, 0xC); break; case 3230: spC0.x = 120.0f; @@ -567,11 +567,11 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spB4.x = 80.0f; spB4.y = 445.0f; spB4.z = -1425.0f; - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0x1E; csCam->fov = 75.0f; - func_8002DF38(globalCtx, &player->actor, 8); + func_8002DF38(play, &player->actor, 8); Actor_GetWorldPosShapeRot(&spA0, actor); Actor_GetFocus(&sp8C, &player->actor); spC0.x = sp8C.pos.x; @@ -581,7 +581,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spD0.pitch = 0x5DC; spD0.r = 120.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Gameplay_CameraSetAtEye(globalCtx, MAIN_CAM, &spC0, &spB4); + Play_CameraSetAtEye(play, MAIN_CAM, &spC0, &spB4); i = Quake_Add(csCam, 3); Quake_SetSpeed(i, 22000); @@ -596,27 +596,27 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act spD0.yaw = spA0.rot.y + 0x7FFF; spD0.r = 300.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0; csCam->fov = 45.0f; - func_8002DF38(globalCtx, &player->actor, 8); + func_8002DF38(play, &player->actor, 8); break; case 3220: Actor_GetFocus(&spA0, actor); spC0 = spA0.pos; - func_800C0808(globalCtx, camIdx, player, CAM_SET_PIVOT_VERTICAL); + func_800C0808(play, camIdx, player, CAM_SET_PIVOT_VERTICAL); Actor_GetWorld(&spA0, &player->actor); OLib_Vec3fDiffToVecSphGeo(&spD0, &spC0, &spA0.pos); spD0.yaw += 0x3E8; spD0.r = 400.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); spB4.y = spA0.pos.y + 60.0f; - Gameplay_CameraSetAtEye(globalCtx, camIdx, &spC0, &spB4); + Play_CameraSetAtEye(play, camIdx, &spC0, &spB4); csCam->roll = 0; csCam->fov = 75.0f; player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = spD0.yaw + 0x7FFF; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); break; case 3240: D_80121D3C[2].timerInit = timer - 5; @@ -624,12 +624,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80121D3C; csInfo->keyFrameCnt = 3; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 6001: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_CS_3); - func_8002DF54(globalCtx, NULL, 8); + Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3); + func_8002DF54(play, NULL, 8); Actor_GetWorld(&spA0, actor); if (spA0.pos.z > -750.0f) { OnePointCutscene_SetCsCamPoints(csCam, D_801208E8, D_801208E4, D_801206A0, D_80120820); @@ -643,8 +643,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act Quake_SetCountdown(i, D_801208E4 - 10); break; case 3400: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_CS_3); - func_8002DF38(globalCtx, &player->actor, 8); + Play_CameraChangeSetting(play, camIdx, CAM_SET_CS_3); + func_8002DF38(play, &player->actor, 8); OnePointCutscene_SetCsCamPoints(csCam, D_8012069C | 0x2000, D_80120698, D_801204D4, D_801205B4); OnePointCutscene_Vec3sToVec3f(&mainCam->eye, &D_801205B4[D_80120694 - 2].pos); OnePointCutscene_Vec3sToVec3f(&mainCam->at, &D_801204D4[D_80120694 - 2].pos); @@ -660,13 +660,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80121DB4; csInfo->keyFrameCnt = 9; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3310: - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FIRE_STAIRCASE); - func_8002DF54(globalCtx, NULL, 8); - Gameplay_CopyCamera(globalCtx, camIdx, MAIN_CAM); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FIRE_STAIRCASE); + func_8002DF54(play, NULL, 8); + Play_CopyCamera(play, camIdx, MAIN_CAM); i = Quake_Add(csCam, 1); Quake_SetSpeed(i, 32000); @@ -674,16 +674,16 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act Quake_SetCountdown(i, timer); break; case 3290: - D_80121F1C[0].atTargetInit = globalCtx->view.lookAt; - D_80121F1C[0].eyeTargetInit = globalCtx->view.eye; - D_80121F1C[0].fovTargetInit = globalCtx->view.fovy; + D_80121F1C[0].atTargetInit = play->view.lookAt; + D_80121F1C[0].eyeTargetInit = play->view.eye; + D_80121F1C[0].fovTargetInit = play->view.fovy; Actor_GetFocus(&spA0, actor); player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = spA0.rot.y; csInfo->keyFrames = D_80121F1C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 3); Quake_SetSpeed(i, 12000); @@ -691,15 +691,15 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act Quake_SetCountdown(i, 5); break; case 3340: - D_80121FBC[0].atTargetInit = globalCtx->view.lookAt; - D_80121FBC[0].eyeTargetInit = globalCtx->view.eye; - D_80121FBC[0].fovTargetInit = globalCtx->view.fovy; + D_80121FBC[0].atTargetInit = play->view.lookAt; + D_80121FBC[0].eyeTargetInit = play->view.eye; + D_80121FBC[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_80121FBC; csInfo->keyFrameCnt = 4; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 3); Quake_SetSpeed(i, 12000); @@ -710,13 +710,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_8012205C; csInfo->keyFrameCnt = 3; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3350: - D_801220D4[0].atTargetInit = globalCtx->view.lookAt; - D_801220D4[0].eyeTargetInit = globalCtx->view.eye; - D_801220D4[0].fovTargetInit = globalCtx->view.fovy; + D_801220D4[0].atTargetInit = play->view.lookAt; + D_801220D4[0].eyeTargetInit = play->view.eye; + D_801220D4[0].fovTargetInit = play->view.fovy; if (actor->world.pos.x > 0.0f) { D_801220D4[1].rollTargetInit = -D_801220D4[1].rollTargetInit; D_801220D4[2].rollTargetInit = -D_801220D4[2].rollTargetInit; @@ -725,26 +725,26 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act D_801220D4[1].eyeTargetInit.y = 80.0f; D_801220D4[1].eyeTargetInit.x = -D_801220D4[1].eyeTargetInit.x; } - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); csInfo->keyFrames = D_801220D4; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3330: csInfo->keyFrames = D_8012219C; csInfo->keyFrameCnt = 7; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3410: csInfo->keyFrames = D_801222B4; csInfo->keyFrameCnt = 5; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 1); Quake_SetSpeed(i, 32000); @@ -755,8 +755,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_8012237C; csInfo->keyFrameCnt = 2; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 1); Quake_SetSpeed(i, 32000); @@ -767,8 +767,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801223CC; csInfo->keyFrameCnt = 6; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); player->stateFlags1 |= 0x20000000; player->actor.freezeTimer = 90; @@ -781,8 +781,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801224BC; csInfo->keyFrameCnt = 7; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 1); Quake_SetSpeed(i, 32000); @@ -799,70 +799,70 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act } player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = 0x3FFC; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); - func_8002DF54(globalCtx, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); break; case 4110: csInfo->keyFrames = D_8012269C; csInfo->keyFrameCnt = 3; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4120: - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); D_80122714[1].timerInit = 80; csInfo->keyFrames = D_80122714; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4140: csInfo->keyFrames = D_801227B4; csInfo->keyFrameCnt = 6; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); break; case 4150: csInfo->keyFrames = D_801228A4; csInfo->keyFrameCnt = 5; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4160: csInfo->keyFrames = D_8012296C; csInfo->keyFrameCnt = 4; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4170: csInfo->keyFrames = D_80122A0C; csInfo->keyFrameCnt = 2; - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4190: csInfo->keyFrames = D_80122A5C; csInfo->keyFrameCnt = 8; - func_8002DF38(globalCtx, &player->actor, 8); + func_8002DF38(play, &player->actor, 8); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4200: csInfo->keyFrames = D_80122B9C; csInfo->keyFrameCnt = 3; - func_8002DF38(globalCtx, &player->actor, 8); + func_8002DF38(play, &player->actor, 8); Camera_ChangeMode(mainCam, CAM_MODE_NORMAL); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4210: player->actor.freezeTimer = timer; @@ -870,7 +870,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80122C14; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); i = Quake_Add(csCam, 3); Quake_SetSpeed(i, 12000); @@ -881,8 +881,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = (player->actor.world.pos.z < -15.0f) ? D_80122C3C : D_80122C64; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); - func_8002DF38(globalCtx, &player->actor, 1); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 1); i = Quake_Add(csCam, 3); Quake_SetSpeed(i, 12000); @@ -893,38 +893,38 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80122C8C; csInfo->keyFrameCnt = 1; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3260: - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); D_80122CB4[1].timerInit = timer - 5; csInfo->keyFrames = D_80122CB4; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 3261: - func_8002DF54(globalCtx, NULL, 8); + func_8002DF54(play, NULL, 8); D_80122D04[1].timerInit = timer - 10; csInfo->keyFrames = D_80122D04; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 8010: csInfo->keyFrames = D_80122D54; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 8002: csInfo->keyFrames = D_80122DCC; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 8700: Actor_GetFocus(&spA0, actor); @@ -935,16 +935,16 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80122E44[timer & 1]; csInfo->keyFrameCnt = 7; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 1100: { - s32 tempDiff = globalCtx->state.frames - sPrevFrameCs1100; + s32 tempDiff = play->state.frames - sPrevFrameCs1100; if ((tempDiff > 3600) || (tempDiff < -3600)) { csInfo->keyFrames = D_80123074; csInfo->keyFrameCnt = 5; } else { - if (globalCtx->state.frames & 1) { + if (play->state.frames & 1) { D_8012313C[0].rollTargetInit = -D_8012313C[0].rollTargetInit; D_8012313C[0].atTargetInit.y = -D_8012313C[0].atTargetInit.y; D_8012313C[0].eyeTargetInit.y = -D_8012313C[0].eyeTargetInit.y; @@ -953,22 +953,22 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_8012313C; csInfo->keyFrameCnt = 3; } - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); - sPrevFrameCs1100 = globalCtx->state.frames; + func_800C0808(play, camIdx, player, CAM_SET_CS_C); + sPrevFrameCs1100 = play->state.frames; } break; case 9806: csCam->timer = -99; - if (func_800C0CB8(globalCtx)) { - func_800C0808(globalCtx, camIdx, player, CAM_SET_TURN_AROUND); + if (func_800C0CB8(play)) { + func_800C0808(play, camIdx, player, CAM_SET_TURN_AROUND); csCam->data2 = 0xC; } else { - Gameplay_CopyCamera(globalCtx, camIdx, MAIN_CAM); - Gameplay_CameraChangeSetting(globalCtx, camIdx, CAM_SET_FREE2); + Play_CopyCamera(play, camIdx, MAIN_CAM); + Play_CameraChangeSetting(play, camIdx, CAM_SET_FREE2); } break; case 9908: - if (func_800C0CB8(globalCtx)) { + if (func_800C0CB8(play)) { D_801231B4[0].eyeTargetInit.z = D_801231B4[1].eyeTargetInit.z = !LINK_IS_ADULT ? 100.0f : 120.0f; if (player->stateFlags1 & 0x08000000) { @@ -987,7 +987,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801231B4; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); } else { D_80123254[1].timerInit = timer - 1; D_80123254[0].fovTargetInit = mainCam->fov; @@ -997,60 +997,60 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80123254; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); } break; case 1000: - D_801232A4[0].atTargetInit = globalCtx->view.lookAt; - D_801232A4[0].eyeTargetInit = globalCtx->view.eye; - D_801232A4[0].fovTargetInit = globalCtx->view.fovy; + D_801232A4[0].atTargetInit = play->view.lookAt; + D_801232A4[0].eyeTargetInit = play->view.eye; + D_801232A4[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_801232A4; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 8603: csInfo->keyFrames = D_801232CC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 8604: csInfo->keyFrames = D_80123394; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4000: csInfo->keyFrames = D_8012345C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4010: csInfo->keyFrames = D_801234FC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4011: csInfo->keyFrames = D_801235C4; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4020: csInfo->keyFrames = D_8012368C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4021: csInfo->keyFrames = D_8012372C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 4022: csCam->timer = D_801237CC[0].timerInit + D_801237CC[3].timerInit + D_801237CC[1].timerInit + @@ -1059,12 +1059,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801237CC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 9703: - D_80123894[0].atTargetInit = globalCtx->view.lookAt; - D_80123894[0].eyeTargetInit = globalCtx->view.eye; - D_80123894[0].fovTargetInit = globalCtx->view.fovy; + D_80123894[0].atTargetInit = play->view.lookAt; + D_80123894[0].eyeTargetInit = play->view.eye; + D_80123894[0].fovTargetInit = play->view.fovy; if (LINK_IS_ADULT) { D_80123894[1].atTargetInit.y = 60.0f; D_80123894[1].eyeTargetInit.y = 52.0f; @@ -1073,27 +1073,27 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_80123894; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 9704: - D_8012390C[0].atTargetInit = globalCtx->view.lookAt; - D_8012390C[0].eyeTargetInit = globalCtx->view.eye; - D_8012390C[0].fovTargetInit = globalCtx->view.fovy; + D_8012390C[0].atTargetInit = play->view.lookAt; + D_8012390C[0].eyeTargetInit = play->view.eye; + D_8012390C[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_8012390C; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 9705: - D_8012395C[0].atTargetInit = globalCtx->view.lookAt; - D_8012395C[0].eyeTargetInit = globalCtx->view.eye; - D_8012395C[0].fovTargetInit = globalCtx->view.fovy; + D_8012395C[0].atTargetInit = play->view.lookAt; + D_8012395C[0].eyeTargetInit = play->view.eye; + D_8012395C[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_8012395C; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, player, CAM_SET_CS_C); + func_800C0808(play, camIdx, player, CAM_SET_CS_C); break; case 5110: D_801239D4[1].timerInit = 10; @@ -1101,7 +1101,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act csInfo->keyFrames = D_801239D4; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, camIdx, (Player*)actor, CAM_SET_CS_C); + func_800C0808(play, camIdx, (Player*)actor, CAM_SET_CS_C); break; default: osSyncPrintf(VT_COL(RED, WHITE) "onepointdemo camera: demo number not found !! (%d)\n" VT_RST, csId); @@ -1110,11 +1110,11 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 camIdx, s16 csId, Act return 0; } -s16 OnePointCutscene_SetAsChild(GlobalContext* globalCtx, s16 newCamIdx, s16 parentCamIdx) { - s16 prevCamIdx = globalCtx->cameraPtrs[parentCamIdx]->childCamIdx; +s16 OnePointCutscene_SetAsChild(PlayState* play, s16 newCamIdx, s16 parentCamIdx) { + s16 prevCamIdx = play->cameraPtrs[parentCamIdx]->childCamIdx; - globalCtx->cameraPtrs[newCamIdx]->parentCamIdx = parentCamIdx; - globalCtx->cameraPtrs[parentCamIdx]->childCamIdx = newCamIdx; + play->cameraPtrs[newCamIdx]->parentCamIdx = parentCamIdx; + play->cameraPtrs[parentCamIdx]->childCamIdx = newCamIdx; return prevCamIdx; } @@ -1123,8 +1123,8 @@ s16 OnePointCutscene_SetAsChild(GlobalContext* globalCtx, s16 newCamIdx, s16 par * Removes a cutscene camera from the list. Returns the parent cam if the removed camera is active, otherwise returns * SUBCAM_NONE */ -s32 OnePointCutscene_RemoveCamera(GlobalContext* globalCtx, s16 camIdx) { - Camera* camera = globalCtx->cameraPtrs[camIdx]; +s32 OnePointCutscene_RemoveCamera(PlayState* play, s16 camIdx) { + Camera* camera = play->cameraPtrs[camIdx]; s32 nextCamIdx; if (camera->thisIdx == CHILD_CAM(camera)->parentCamIdx) { @@ -1133,11 +1133,11 @@ s32 OnePointCutscene_RemoveCamera(GlobalContext* globalCtx, s16 camIdx) { if (camera->thisIdx == PARENT_CAM(camera)->childCamIdx) { PARENT_CAM(camera)->childCamIdx = camera->childCamIdx; } - nextCamIdx = (globalCtx->activeCamera == camIdx) ? camera->parentCamIdx : SUBCAM_NONE; + nextCamIdx = (play->activeCamera == camIdx) ? camera->parentCamIdx : SUBCAM_NONE; camera->parentCamIdx = MAIN_CAM; camera->childCamIdx = camera->parentCamIdx; camera->timer = -1; - Gameplay_ClearCamera(camera->globalCtx, camera->thisIdx); + Play_ClearCamera(camera->play, camera->thisIdx); return nextCamIdx; } @@ -1151,16 +1151,16 @@ s32 OnePointCutscene_RemoveCamera(GlobalContext* globalCtx, s16 camIdx) { * cutscene queue in front of the specified camera, then all lower priority demos in front of it are removed from the * queue. */ -s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* actor, s16 parentCamIdx) { +s16 OnePointCutscene_Init(PlayState* play, s16 csId, s16 timer, Actor* actor, s16 parentCamIdx) { s16 temp1; s16 temp2; s16 csCamIdx; Camera* csCam; if (parentCamIdx == SUBCAM_ACTIVE) { - parentCamIdx = globalCtx->activeCamera; + parentCamIdx = play->activeCamera; } - csCamIdx = Gameplay_CreateSubCamera(globalCtx); + csCamIdx = Play_CreateSubCamera(play); if (csCamIdx == SUBCAM_NONE) { osSyncPrintf(VT_COL(RED, WHITE) "onepoint demo: error: too many cameras ... give up! type=%d\n" VT_RST, csId); return SUBCAM_NONE; @@ -1168,58 +1168,58 @@ s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* // Inserts the cutscene camera into the cutscene queue in front of parentCam - vChildCamIdx = globalCtx->cameraPtrs[parentCamIdx]->childCamIdx; + vChildCamIdx = play->cameraPtrs[parentCamIdx]->childCamIdx; vCsStatus = CAM_STAT_ACTIVE; if (vChildCamIdx >= SUBCAM_FIRST) { - OnePointCutscene_SetAsChild(globalCtx, vChildCamIdx, csCamIdx); + OnePointCutscene_SetAsChild(play, vChildCamIdx, csCamIdx); vCsStatus = CAM_STAT_WAIT; } else { Interface_ChangeAlpha(2); } - OnePointCutscene_SetAsChild(globalCtx, csCamIdx, parentCamIdx); + OnePointCutscene_SetAsChild(play, csCamIdx, parentCamIdx); - csCam = globalCtx->cameraPtrs[csCamIdx]; + csCam = play->cameraPtrs[csCamIdx]; csCam->timer = timer; csCam->target = actor; - csCam->at = globalCtx->view.lookAt; - csCam->eye = globalCtx->view.eye; - csCam->fov = globalCtx->view.fovy; + csCam->at = play->view.lookAt; + csCam->eye = play->view.eye; + csCam->fov = play->view.fovy; csCam->csId = csId; if (parentCamIdx == MAIN_CAM) { - Gameplay_ChangeCameraStatus(globalCtx, parentCamIdx, CAM_STAT_UNK3); + Play_ChangeCameraStatus(play, parentCamIdx, CAM_STAT_UNK3); } else { - Gameplay_ChangeCameraStatus(globalCtx, parentCamIdx, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, parentCamIdx, CAM_STAT_WAIT); } - OnePointCutscene_SetInfo(globalCtx, csCamIdx, csId, actor, timer); - Gameplay_ChangeCameraStatus(globalCtx, csCamIdx, vCsStatus); + OnePointCutscene_SetInfo(play, csCamIdx, csId, actor, timer); + Play_ChangeCameraStatus(play, csCamIdx, vCsStatus); // Removes all lower priority cutscenes in front of this cutscene from the queue. vCurCamIdx = csCamIdx; - vNextCamIdx = globalCtx->cameraPtrs[csCamIdx]->childCamIdx; + vNextCamIdx = play->cameraPtrs[csCamIdx]->childCamIdx; while (vNextCamIdx >= SUBCAM_FIRST) { - s16 nextCsId = globalCtx->cameraPtrs[vNextCamIdx]->csId; - s16 thisCsId = globalCtx->cameraPtrs[csCamIdx]->csId; + s16 nextCsId = play->cameraPtrs[vNextCamIdx]->csId; + s16 thisCsId = play->cameraPtrs[csCamIdx]->csId; if ((nextCsId / 100) < (thisCsId / 100)) { osSyncPrintf(VT_COL(YELLOW, BLACK) "onepointdemo camera[%d]: killed 'coz low priority (%d < %d)\n" VT_RST, vNextCamIdx, nextCsId, thisCsId); - if (globalCtx->cameraPtrs[vNextCamIdx]->csId != 5010) { - if ((vNextCamIdx = OnePointCutscene_RemoveCamera(globalCtx, vNextCamIdx)) != SUBCAM_NONE) { - Gameplay_ChangeCameraStatus(globalCtx, vNextCamIdx, CAM_STAT_ACTIVE); + if (play->cameraPtrs[vNextCamIdx]->csId != 5010) { + if ((vNextCamIdx = OnePointCutscene_RemoveCamera(play, vNextCamIdx)) != SUBCAM_NONE) { + Play_ChangeCameraStatus(play, vNextCamIdx, CAM_STAT_ACTIVE); } } else { vCurCamIdx = vNextCamIdx; - OnePointCutscene_EndCutscene(globalCtx, vNextCamIdx); + OnePointCutscene_EndCutscene(play, vNextCamIdx); } } else { vCurCamIdx = vNextCamIdx; } - vNextCamIdx = globalCtx->cameraPtrs[vCurCamIdx]->childCamIdx; + vNextCamIdx = play->cameraPtrs[vCurCamIdx]->childCamIdx; } return csCamIdx; } @@ -1227,17 +1227,17 @@ s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* /** * Ends the cutscene in camIdx by setting its timer to 0. For attention cutscenes, it is set to 5 instead. */ -s16 OnePointCutscene_EndCutscene(GlobalContext* globalCtx, s16 camIdx) { +s16 OnePointCutscene_EndCutscene(PlayState* play, s16 camIdx) { if (camIdx == SUBCAM_ACTIVE) { - camIdx = globalCtx->activeCamera; + camIdx = play->activeCamera; } - if (globalCtx->cameraPtrs[camIdx] != NULL) { - osSyncPrintf("onepointdemo camera[%d]: delete timer=%d next=%d\n", camIdx, globalCtx->cameraPtrs[camIdx]->timer, - globalCtx->cameraPtrs[camIdx]->parentCamIdx); - if (globalCtx->cameraPtrs[camIdx]->csId == 5010) { - globalCtx->cameraPtrs[camIdx]->timer = 5; + if (play->cameraPtrs[camIdx] != NULL) { + osSyncPrintf("onepointdemo camera[%d]: delete timer=%d next=%d\n", camIdx, play->cameraPtrs[camIdx]->timer, + play->cameraPtrs[camIdx]->parentCamIdx); + if (play->cameraPtrs[camIdx]->csId == 5010) { + play->cameraPtrs[camIdx]->timer = 5; } else { - globalCtx->cameraPtrs[camIdx]->timer = 0; + play->cameraPtrs[camIdx]->timer = 0; } } return camIdx; @@ -1251,7 +1251,7 @@ s16 OnePointCutscene_EndCutscene(GlobalContext* globalCtx, s16 camIdx) { /** * Adds an attention cutscene to the cutscene queue. */ -s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { +s32 OnePointCutscene_Attention(PlayState* play, Actor* actor) { Camera* parentCam; s32 temp1; s32 temp2; @@ -1263,7 +1263,7 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { } sUnused = -1; - parentCam = globalCtx->cameraPtrs[MAIN_CAM]; + parentCam = play->cameraPtrs[MAIN_CAM]; if (parentCam->mode == CAM_MODE_FOLLOWBOOMERANG) { osSyncPrintf(VT_COL(YELLOW, BLACK) "actor attention demo camera: change mode BOOKEEPON -> NORMAL\n" VT_RST); Camera_ChangeMode(parentCam, CAM_MODE_NORMAL); @@ -1274,7 +1274,7 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { vLastHigherCat = -1; while (parentCam->childCamIdx != SUBCAM_FREE) { - parentCam = globalCtx->cameraPtrs[parentCam->childCamIdx]; + parentCam = play->cameraPtrs[parentCam->childCamIdx]; if (parentCam == NULL) { break; } else if (parentCam->setting != CAM_SET_CS_ATTENTION) { @@ -1314,11 +1314,11 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { case ACTORCAT_BOSS: default: osSyncPrintf(VT_COL(YELLOW, BLACK) "actor attention demo camera: %d: unkown part of actor %d\n" VT_RST, - globalCtx->state.frames, actor->category); + play->state.frames, actor->category); timer = 30; break; } - osSyncPrintf(VT_FGCOL(CYAN) "%06u:" VT_RST " actor attention demo camera: request %d ", globalCtx->state.frames, + osSyncPrintf(VT_FGCOL(CYAN) "%06u:" VT_RST " actor attention demo camera: request %d ", play->state.frames, actor->category); // If the previous attention cutscene has an actor in the same category, skip this actor. @@ -1327,12 +1327,12 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { return SUBCAM_NONE; } osSyncPrintf("→ " VT_FGCOL(BLUE) "○" VT_RST " (%d)\n", actor->id); - vCsCamIdx = OnePointCutscene_Init(globalCtx, 5010, timer, actor, vParentCamIdx); + vCsCamIdx = OnePointCutscene_Init(play, 5010, timer, actor, vParentCamIdx); if (vCsCamIdx == SUBCAM_NONE) { osSyncPrintf(VT_COL(RED, WHITE) "actor attention demo: give up! \n" VT_RST, actor->id); return SUBCAM_NONE; } else { - s32* data = (s32*)&globalCtx->cameraPtrs[vCsCamIdx]->data1; + s32* data = (s32*)&play->cameraPtrs[vCsCamIdx]->data1; *data = NA_SE_SY_CORRECT_CHIME; return vCsCamIdx; @@ -1342,11 +1342,11 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { /** * Adds an attention cutscene to the cutscene queue with the specified sound effect */ -s32 OnePointCutscene_AttentionSetSfx(GlobalContext* globalCtx, Actor* actor, s32 sfxId) { - s32 csCamIdx = OnePointCutscene_Attention(globalCtx, actor); +s32 OnePointCutscene_AttentionSetSfx(PlayState* play, Actor* actor, s32 sfxId) { + s32 csCamIdx = OnePointCutscene_Attention(play, actor); if (csCamIdx != SUBCAM_NONE) { - s32* data = (s32*)&globalCtx->cameraPtrs[csCamIdx]->data1; + s32* data = (s32*)&play->cameraPtrs[csCamIdx]->data1; *data = sfxId; } @@ -1363,11 +1363,11 @@ void OnePointCutscene_DisableAttention() { sDisableAttention = true; } -s32 OnePointCutscene_CheckForCategory(GlobalContext* globalCtx, s32 category) { - Camera* parentCam = globalCtx->cameraPtrs[MAIN_CAM]; +s32 OnePointCutscene_CheckForCategory(PlayState* play, s32 category) { + Camera* parentCam = play->cameraPtrs[MAIN_CAM]; while (parentCam->childCamIdx != SUBCAM_FREE) { - parentCam = globalCtx->cameraPtrs[parentCam->childCamIdx]; + parentCam = play->cameraPtrs[parentCam->childCamIdx]; if ((parentCam == NULL) || (parentCam->setting != CAM_SET_CS_ATTENTION)) { break; } else if (category == parentCam->target->category) { @@ -1378,5 +1378,5 @@ s32 OnePointCutscene_CheckForCategory(GlobalContext* globalCtx, s32 category) { } // unused, also empty. -void OnePointCutscene_Noop(GlobalContext* globalCtx, s32 arg1) { +void OnePointCutscene_Noop(PlayState* play, s32 arg1) { } diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index ba59b8d47..0a8d11a4b 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -232,8 +232,8 @@ void Interface_ChangeAlpha(u16 alphaType) { } } -void func_80082644(GlobalContext* globalCtx, s16 alpha) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_80082644(PlayState* play, s16 alpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (gSaveContext.buttonStatus[0] == BTN_DISABLED) { if (interfaceCtx->bAlpha != 70) { @@ -326,11 +326,11 @@ void func_80082644(GlobalContext* globalCtx, s16 alpha) { } } -void func_8008277C(GlobalContext* globalCtx, s16 maxAlpha, s16 alpha) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_8008277C(PlayState* play, s16 maxAlpha, s16 alpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (gSaveContext.unk_13E7 != 0) { - func_80082644(globalCtx, alpha); + func_80082644(play, alpha); return; } @@ -371,8 +371,8 @@ void func_8008277C(GlobalContext* globalCtx, s16 maxAlpha, s16 alpha) { } } -void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_80082850(PlayState* play, s16 maxAlpha) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 alpha = 255 - maxAlpha; switch (gSaveContext.unk_13E8) { @@ -443,7 +443,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->aAlpha = maxAlpha; } - func_8008277C(globalCtx, maxAlpha, alpha); + func_8008277C(play, maxAlpha, alpha); if ((interfaceCtx->magicAlpha != 0) && (interfaceCtx->magicAlpha > maxAlpha)) { interfaceCtx->magicAlpha = maxAlpha; @@ -513,7 +513,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { break; case 5: - func_8008277C(globalCtx, maxAlpha, alpha); + func_8008277C(play, maxAlpha, alpha); if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > maxAlpha)) { interfaceCtx->minimapAlpha = maxAlpha; @@ -533,7 +533,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { break; case 6: - func_8008277C(globalCtx, maxAlpha, alpha); + func_8008277C(play, maxAlpha, alpha); if (interfaceCtx->aAlpha != 255) { interfaceCtx->aAlpha = alpha; @@ -547,7 +547,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->magicAlpha = alpha; } - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_SPOT00: case SCENE_SPOT01: case SCENE_SPOT02: @@ -586,7 +586,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { interfaceCtx->minimapAlpha = maxAlpha; } - func_80082644(globalCtx, alpha); + func_80082644(play, alpha); if (interfaceCtx->healthAlpha != 255) { interfaceCtx->healthAlpha = alpha; @@ -798,7 +798,7 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { break; case 13: - func_8008277C(globalCtx, maxAlpha, alpha); + func_8008277C(play, maxAlpha, alpha); if ((interfaceCtx->minimapAlpha != 0) && (interfaceCtx->minimapAlpha > maxAlpha)) { interfaceCtx->minimapAlpha = maxAlpha; @@ -819,24 +819,24 @@ void func_80082850(GlobalContext* globalCtx, s16 maxAlpha) { break; } - if ((globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) && (interfaceCtx->minimapAlpha >= 255)) { + if ((play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_1) && (interfaceCtx->minimapAlpha >= 255)) { interfaceCtx->minimapAlpha = 255; } } -void func_80083108(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; - Player* player = GET_PLAYER(globalCtx); - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_80083108(PlayState* play) { + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 i; s16 sp28 = 0; if ((gSaveContext.cutsceneIndex < 0xFFF0) || - ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.cutsceneIndex == 0xFFF0))) { + ((play->sceneNum == SCENE_SPOT20) && (gSaveContext.cutsceneIndex == 0xFFF0))) { gSaveContext.unk_13E7 = 0; - if ((player->stateFlags1 & 0x00800000) || (globalCtx->shootingGalleryStatus > 1) || - ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { + if ((player->stateFlags1 & 0x00800000) || (play->shootingGalleryStatus > 1) || + ((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38))) { if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { gSaveContext.unk_13E7 = 1; @@ -853,22 +853,22 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[0] != ITEM_NONE)) { gSaveContext.buttonStatus[0] = gSaveContext.equips.buttonItems[0]; - if ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38)) { + if ((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38)) { gSaveContext.equips.buttonItems[0] = ITEM_BOMBCHU; - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } else { gSaveContext.equips.buttonItems[0] = ITEM_BOW; - if (globalCtx->shootingGalleryStatus > 1) { + if (play->shootingGalleryStatus > 1) { if (LINK_AGE_IN_YEARS == YEARS_CHILD) { gSaveContext.equips.buttonItems[0] = ITEM_SLINGSHOT; } - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } else { if (gSaveContext.inventory.items[SLOT_BOW] == ITEM_NONE) { gSaveContext.equips.buttonItems[0] = ITEM_NONE; } else { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } } @@ -880,13 +880,13 @@ void func_80083108(GlobalContext* globalCtx) { Interface_ChangeAlpha(6); } - if (globalCtx->transitionMode != 0) { + if (play->transitionMode != 0) { Interface_ChangeAlpha(1); } else if (gSaveContext.minigameState == 1) { Interface_ChangeAlpha(8); - } else if (globalCtx->shootingGalleryStatus > 1) { + } else if (play->shootingGalleryStatus > 1) { Interface_ChangeAlpha(8); - } else if ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38)) { + } else if ((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38)) { Interface_ChangeAlpha(8); } else if (player->stateFlags1 & 0x00800000) { Interface_ChangeAlpha(12); @@ -896,16 +896,16 @@ void func_80083108(GlobalContext* globalCtx) { Interface_ChangeAlpha(12); } } - } else if (globalCtx->sceneNum == SCENE_KENJYANOMA) { + } else if (play->sceneNum == SCENE_KENJYANOMA) { Interface_ChangeAlpha(1); - } else if (globalCtx->sceneNum == SCENE_TURIBORI) { + } else if (play->sceneNum == SCENE_TURIBORI) { gSaveContext.unk_13E7 = 2; - if (globalCtx->interfaceCtx.unk_260 != 0) { + if (play->interfaceCtx.unk_260 != 0) { if (gSaveContext.equips.buttonItems[0] != ITEM_FISHING_POLE) { gSaveContext.buttonStatus[0] = gSaveContext.equips.buttonItems[0]; gSaveContext.equips.buttonItems[0] = ITEM_FISHING_POLE; gSaveContext.unk_13EA = 0; - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); Interface_ChangeAlpha(12); } @@ -917,7 +917,7 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.unk_13EA = 0; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = @@ -941,7 +941,7 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = gSaveContext.buttonStatus[8] = BTN_DISABLED; - } else if ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) { + } else if ((func_8008F2F8(play) >= 2) && (func_8008F2F8(play) < 5)) { if (gSaveContext.buttonStatus[0] != BTN_DISABLED) { sp28 = 1; } @@ -957,7 +957,7 @@ void func_80083108(GlobalContext* globalCtx) { } gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] = BTN_ENABLED; - } else if (func_8008F2F8(globalCtx) == 2) { + } else if (func_8008F2F8(play) == 2) { if ((gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) && (gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)) { if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { @@ -1028,7 +1028,7 @@ void func_80083108(GlobalContext* globalCtx) { } if (sp28) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); sp28 = 0; } @@ -1065,7 +1065,7 @@ void func_80083108(GlobalContext* globalCtx) { sp28 = 1; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } } else if ((gSaveContext.buttonStatus[0] & 0xFF) == BTN_DISABLED) { @@ -1088,7 +1088,7 @@ void func_80083108(GlobalContext* globalCtx) { sp28 = 1; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } } else { @@ -1269,7 +1269,7 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[i] <= ITEM_BOOTS_HOVER)) && // (tunics/boots) on C-buttons !((gSaveContext.equips.buttonItems[i] >= ITEM_WEIRD_EGG) && (gSaveContext.equips.buttonItems[i] <= ITEM_CLAIM_CHECK))) { - if ((globalCtx->sceneNum != SCENE_TAKARAYA) || + if ((play->sceneNum != SCENE_TAKARAYA) || (gSaveContext.equips.buttonItems[i] != ITEM_LENS)) { if (gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(i)] == BTN_ENABLED) { sp28 = 1; @@ -1312,7 +1312,7 @@ void func_80083108(GlobalContext* globalCtx) { if (sp28) { gSaveContext.unk_13EA = 0; - if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0)) { + if ((play->sceneLoadFlag == 0) && (play->transitionMode == 0)) { Interface_ChangeAlpha(50); osSyncPrintf("???????? alpha_change( 50 ); ?????\n"); } else { @@ -1321,8 +1321,8 @@ void func_80083108(GlobalContext* globalCtx) { } } -void Interface_SetSceneRestrictions(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_SetSceneRestrictions(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 i; u8 currentScene; @@ -1338,10 +1338,10 @@ void Interface_SetSceneRestrictions(GlobalContext* globalCtx) { i = 0; // "Data settings related to button display scene_data_ID=%d\n" - osSyncPrintf("ボタン表示関係データ設定 scene_data_ID=%d\n", globalCtx->sceneNum); + osSyncPrintf("ボタン表示関係データ設定 scene_data_ID=%d\n", play->sceneNum); do { - currentScene = (u8)globalCtx->sceneNum; + currentScene = (u8)play->sceneNum; if (sRestrictionFlags[i].scene == currentScene) { interfaceCtx->restrictions.hGauge = (sRestrictionFlags[i].flags1 & 0xC0) >> 6; interfaceCtx->restrictions.bButton = (sRestrictionFlags[i].flags1 & 0x30) >> 4; @@ -1537,8 +1537,8 @@ void Inventory_SwapAgeEquipment(void) { } } -void Interface_InitHorsebackArchery(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_InitHorsebackArchery(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; gSaveContext.minigameState = 1; interfaceCtx->unk_23C = interfaceCtx->unk_240 = interfaceCtx->unk_242 = 0; @@ -1546,7 +1546,7 @@ void Interface_InitHorsebackArchery(GlobalContext* globalCtx) { interfaceCtx->hbaAmmo = 20; } -void func_800849EC(GlobalContext* globalCtx) { +void func_800849EC(PlayState* play) { gSaveContext.inventory.equipment |= gBitFlags[2] << gEquipShifts[EQUIP_SWORD]; gSaveContext.inventory.equipment ^= 8 << gEquipShifts[EQUIP_SWORD]; @@ -1556,11 +1556,11 @@ void func_800849EC(GlobalContext* globalCtx) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; } - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } -void Interface_LoadItemIcon1(GlobalContext* globalCtx, u16 button) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_LoadItemIcon1(PlayState* play, u16 button) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_160, interfaceCtx->iconItemSegment + button * 0x1000, @@ -1569,8 +1569,8 @@ void Interface_LoadItemIcon1(GlobalContext* globalCtx, u16 button) { osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } -void Interface_LoadItemIcon2(GlobalContext* globalCtx, u16 button) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_LoadItemIcon2(PlayState* play, u16 button) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; osCreateMesgQueue(&interfaceCtx->loadQueue, &interfaceCtx->loadMsg, OS_MESG_BLOCK); DmaMgr_SendRequest2(&interfaceCtx->dmaRequest_180, interfaceCtx->iconItemSegment + button * 0x1000, @@ -1579,7 +1579,7 @@ void Interface_LoadItemIcon2(GlobalContext* globalCtx, u16 button) { osRecvMesg(&interfaceCtx->loadQueue, NULL, OS_MESG_BLOCK); } -void func_80084BF4(GlobalContext* globalCtx, u16 flag) { +void func_80084BF4(PlayState* play, u16 flag) { if (flag) { if ((gSaveContext.equips.buttonItems[0] == ITEM_SLINGSHOT) || (gSaveContext.equips.buttonItems[0] == ITEM_BOW) || (gSaveContext.equips.buttonItems[0] == ITEM_BOMBCHU) || @@ -1590,12 +1590,12 @@ void func_80084BF4(GlobalContext* globalCtx, u16 flag) { (gSaveContext.equips.buttonItems[0] == ITEM_BOMBCHU) || (gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } else if (gSaveContext.equips.buttonItems[0] == ITEM_NONE) { if ((gSaveContext.equips.buttonItems[0] != ITEM_NONE) || (gSaveContext.infTable[29] == 0)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } @@ -1609,22 +1609,22 @@ void func_80084BF4(GlobalContext* globalCtx, u16 flag) { gSaveContext.buttonStatus[3] = BTN_ENABLED; gSaveContext.buttonStatus[5] = gSaveContext.buttonStatus[6] = gSaveContext.buttonStatus[7] = gSaveContext.buttonStatus[8] = BTN_ENABLED; - func_80083108(globalCtx); + func_80083108(play); } } /** * @brief Adds the given item to Link's inventory. * - * NOTE: This function has been edited to be safe to use with a NULL globalCtx. - * If you need to add to this function, be sure you check if the globalCtx is not + * NOTE: This function has been edited to be safe to use with a NULL play. + * If you need to add to this function, be sure you check if the play is not * NULL before doing any operations requiring it. * - * @param globalCtx + * @param play * @param item * @return u8 */ -u8 Item_Give(GlobalContext* globalCtx, u8 item) { +u8 Item_Give(PlayState* play, u8 item) { static s16 sAmmoRefillCounts[] = { 5, 10, 20, 30, 5, 10, 30, 0, 5, 20, 1, 5, 20, 50, 200, 10 }; s16 i; s16 slot; @@ -1647,10 +1647,10 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf(VT_RST); if (item == ITEM_MEDALLION_WATER) { - func_8006D0AC(globalCtx); + func_8006D0AC(play); } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_SONG_MINUET) && (item <= ITEM_SONG_STORMS)) { gSaveContext.inventory.questItems |= gBitFlags[item - ITEM_SONG_MINUET + QUEST_SONG_MINUET]; @@ -1662,7 +1662,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { gBitFlags[item - ITEM_SONG_MINUET + QUEST_SONG_MINUET], gBitFlags[item - ITEM_SONG_MINUET]); osSyncPrintf(VT_RST); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_KOKIRI_EMERALD) && (item <= ITEM_ZORA_SAPPHIRE)) { gSaveContext.inventory.questItems |= gBitFlags[item - ITEM_KOKIRI_EMERALD + QUEST_KOKIRI_EMERALD]; @@ -1671,7 +1671,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf("精霊石 = %x\n", gSaveContext.inventory.questItems); // "Spiritual Stones = %x" osSyncPrintf(VT_RST); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item == ITEM_STONE_OF_AGONY) || (item == ITEM_GERUDO_CARD)) { gSaveContext.inventory.questItems |= gBitFlags[item - ITEM_STONE_OF_AGONY + QUEST_STONE_OF_AGONY]; @@ -1680,7 +1680,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf("アイテム = %x\n", gSaveContext.inventory.questItems); // "Items = %x" osSyncPrintf(VT_RST); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_SKULL_TOKEN) { gSaveContext.inventory.questItems |= gBitFlags[item - ITEM_SKULL_TOKEN + QUEST_SKULL_TOKEN]; @@ -1691,7 +1691,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf("Nコイン = %x(%d)\n", gSaveContext.inventory.questItems, gSaveContext.inventory.gsTokens); osSyncPrintf(VT_RST); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_SWORD_KOKIRI) && (item <= ITEM_SWORD_BGS)) { gSaveContext.inventory.equipment |= gBitFlags[item - ITEM_SWORD_KOKIRI] << gEquipShifts[EQUIP_SWORD]; @@ -1708,8 +1708,8 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, 0); + if (play != NULL) { + Interface_LoadItemIcon1(play, 0); } } } @@ -1718,33 +1718,33 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; gSaveContext.equips.equipment &= 0xFFF0; gSaveContext.equips.equipment |= 0x0002; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, 0); + if (play != NULL) { + Interface_LoadItemIcon1(play, 0); } } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_SHIELD_DEKU) && (item <= ITEM_SHIELD_MIRROR)) { gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_SHIELD_DEKU] << gEquipShifts[EQUIP_SHIELD]); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_TUNIC_KOKIRI) && (item <= ITEM_TUNIC_ZORA)) { gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_TUNIC_KOKIRI] << gEquipShifts[EQUIP_TUNIC]); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_BOOTS_KOKIRI) && (item <= ITEM_BOOTS_HOVER)) { gSaveContext.inventory.equipment |= (gBitFlags[item - ITEM_BOOTS_KOKIRI] << gEquipShifts[EQUIP_BOOTS]); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item == ITEM_KEY_BOSS) || (item == ITEM_COMPASS) || (item == ITEM_DUNGEON_MAP)) { // Boss Key, Compass, and Dungeon Map exceptions for rando. // Rando should never be able to get here for Link's Pocket unless something goes wrong, - // but we check for a globalCtx here so the game won't crash if we do somehow get here. - if (gSaveContext.n64ddFlag && globalCtx != NULL) { - if (globalCtx->sceneNum == 13) { // ganon's castle -> ganon's tower + // but we check for a play here so the game won't crash if we do somehow get here. + if (gSaveContext.n64ddFlag && play != NULL) { + if (play->sceneNum == 13) { // ganon's castle -> ganon's tower gSaveContext.inventory.dungeonItems[10] |= 1; - } else if (globalCtx->sceneNum == 92) { // Desert Colossus -> Spirit Temple. + } else if (play->sceneNum == 92) { // Desert Colossus -> Spirit Temple. gSaveContext.inventory.dungeonItems[6] |= gBitFlags[item - ITEM_KEY_BOSS]; } else { gSaveContext.inventory.dungeonItems[gSaveContext.mapIndex] |= gBitFlags[item - ITEM_KEY_BOSS]; @@ -1752,35 +1752,35 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } else { gSaveContext.inventory.dungeonItems[gSaveContext.mapIndex] |= gBitFlags[item - ITEM_KEY_BOSS]; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_KEY_SMALL) { // Small key exceptions for rando with keysanity off. // Rando should never be able to get here for Link's Pocket unless something goes wrong, - // but we check for a globalCtx here so the game won't crash if we do somehow get here. - if (gSaveContext.n64ddFlag && globalCtx != NULL) { - if (globalCtx->sceneNum == 10) { // ganon's tower -> ganon's castle + // but we check for a play here so the game won't crash if we do somehow get here. + if (gSaveContext.n64ddFlag && play != NULL) { + if (play->sceneNum == 10) { // ganon's tower -> ganon's castle gSaveContext.sohStats.dungeonKeys[13]++; if (gSaveContext.inventory.dungeonKeys[13] < 0) { gSaveContext.inventory.dungeonKeys[13] = 1; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { gSaveContext.inventory.dungeonKeys[13]++; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } - if (globalCtx->sceneNum == 92) { // Desert Colossus -> Spirit Temple. + if (play->sceneNum == 92) { // Desert Colossus -> Spirit Temple. gSaveContext.sohStats.dungeonKeys[6]++; if (gSaveContext.inventory.dungeonKeys[6] < 0) { gSaveContext.inventory.dungeonKeys[6] = 1; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { gSaveContext.inventory.dungeonKeys[6]++; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } @@ -1788,11 +1788,11 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { gSaveContext.sohStats.dungeonKeys[gSaveContext.mapIndex]++; if (gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] < 0) { gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex] = 1; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { gSaveContext.inventory.dungeonKeys[gSaveContext.mapIndex]++; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } else if ((item == ITEM_QUIVER_30) || (item == ITEM_BOW)) { @@ -1800,7 +1800,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { Inventory_ChangeUpgrade(UPG_QUIVER, 1); INV_CONTENT(ITEM_BOW) = ITEM_BOW; AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 1); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { AMMO(ITEM_BOW)++; @@ -1811,29 +1811,29 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } else if (item == ITEM_QUIVER_40) { Inventory_ChangeUpgrade(UPG_QUIVER, 2); AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_QUIVER_50) { Inventory_ChangeUpgrade(UPG_QUIVER, 3); AMMO(ITEM_BOW) = CAPACITY(UPG_QUIVER, 3); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BULLET_BAG_40) { Inventory_ChangeUpgrade(UPG_BULLET_BAG, 2); AMMO(ITEM_SLINGSHOT) = CAPACITY(UPG_BULLET_BAG, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BULLET_BAG_50) { Inventory_ChangeUpgrade(UPG_BULLET_BAG, 3); AMMO(ITEM_SLINGSHOT) = CAPACITY(UPG_BULLET_BAG, 3); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BOMB_BAG_20) { if (CUR_UPG_VALUE(UPG_BOMB_BAG) == 0) { Inventory_ChangeUpgrade(UPG_BOMB_BAG, 1); INV_CONTENT(ITEM_BOMB) = ITEM_BOMB; AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 1); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { AMMO(ITEM_BOMB)++; @@ -1844,46 +1844,46 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } else if (item == ITEM_BOMB_BAG_30) { Inventory_ChangeUpgrade(UPG_BOMB_BAG, 2); AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BOMB_BAG_40) { Inventory_ChangeUpgrade(UPG_BOMB_BAG, 3); AMMO(ITEM_BOMB) = CAPACITY(UPG_BOMB_BAG, 3); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BRACELET) { Inventory_ChangeUpgrade(UPG_STRENGTH, 1); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_GAUNTLETS_SILVER) { Inventory_ChangeUpgrade(UPG_STRENGTH, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_GAUNTLETS_GOLD) { Inventory_ChangeUpgrade(UPG_STRENGTH, 3); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_SCALE_SILVER) { Inventory_ChangeUpgrade(UPG_SCALE, 1); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_SCALE_GOLDEN) { Inventory_ChangeUpgrade(UPG_SCALE, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_WALLET_ADULT) { Inventory_ChangeUpgrade(UPG_WALLET, 1); if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_FULL_WALLETS)) { Rupees_ChangeBy(200); } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_WALLET_GIANT) { Inventory_ChangeUpgrade(UPG_WALLET, 2); if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_FULL_WALLETS)) { Rupees_ChangeBy(500); } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_STICK_UPGRADE_20) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { @@ -1891,7 +1891,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } Inventory_ChangeUpgrade(UPG_STICKS, 2); AMMO(ITEM_STICK) = CAPACITY(UPG_STICKS, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_STICK_UPGRADE_30) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { @@ -1899,7 +1899,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } Inventory_ChangeUpgrade(UPG_STICKS, 3); AMMO(ITEM_STICK) = CAPACITY(UPG_STICKS, 3); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_NUT_UPGRADE_30) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { @@ -1907,7 +1907,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } Inventory_ChangeUpgrade(UPG_NUTS, 2); AMMO(ITEM_NUT) = CAPACITY(UPG_NUTS, 2); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_NUT_UPGRADE_40) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { @@ -1915,7 +1915,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } Inventory_ChangeUpgrade(UPG_NUTS, 3); AMMO(ITEM_NUT) = CAPACITY(UPG_NUTS, 3); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_LONGSHOT) { INV_CONTENT(item) = item; @@ -1923,8 +1923,8 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) { gSaveContext.equips.buttonItems[i] = ITEM_LONGSHOT; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, i); + if (play != NULL) { + Interface_LoadItemIcon1(play, i); } } } @@ -1933,8 +1933,8 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < ARRAY_COUNT(gSaveContext.adultEquips.buttonItems); i++) { if (gSaveContext.adultEquips.buttonItems[i] == ITEM_HOOKSHOT) { gSaveContext.adultEquips.buttonItems[i] = ITEM_LONGSHOT; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, i); + if (play != NULL) { + Interface_LoadItemIcon1(play, i); } } } @@ -1943,13 +1943,13 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < ARRAY_COUNT(gSaveContext.childEquips.buttonItems); i++) { if (gSaveContext.childEquips.buttonItems[i] == ITEM_HOOKSHOT) { gSaveContext.childEquips.buttonItems[i] = ITEM_LONGSHOT; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, i); + if (play != NULL) { + Interface_LoadItemIcon1(play, i); } } } } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_STICK) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { @@ -2002,40 +2002,40 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if ((AMMO(ITEM_BOMB) += 1) > CUR_CAPACITY(UPG_BOMB_BAG)) { AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item >= ITEM_BOMBS_5) && (item <= ITEM_BOMBS_30)) { if ((AMMO(ITEM_BOMB) += sAmmoRefillCounts[item - ITEM_BOMBS_5]) > CUR_CAPACITY(UPG_BOMB_BAG)) { AMMO(ITEM_BOMB) = CUR_CAPACITY(UPG_BOMB_BAG); } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BOMBCHU) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; AMMO(ITEM_BOMBCHU) = 10; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { AMMO(ITEM_BOMBCHU) += 10; if (AMMO(ITEM_BOMBCHU) > 50) { AMMO(ITEM_BOMBCHU) = 50; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } else if ((item == ITEM_BOMBCHUS_5) || (item == ITEM_BOMBCHUS_20)) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { INV_CONTENT(ITEM_BOMBCHU) = ITEM_BOMBCHU; AMMO(ITEM_BOMBCHU) += sAmmoRefillCounts[item - ITEM_BOMBCHUS_5 + 8]; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else { AMMO(ITEM_BOMBCHU) += sAmmoRefillCounts[item - ITEM_BOMBCHUS_5 + 8]; if (AMMO(ITEM_BOMBCHU) > 50) { AMMO(ITEM_BOMBCHU) = 50; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } else if ((item >= ITEM_ARROWS_SMALL) && (item <= ITEM_ARROWS_LARGE)) { @@ -2047,13 +2047,13 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf("%d本 Item_MaxGet=%d\n", AMMO(ITEM_BOW), CUR_CAPACITY(UPG_QUIVER)); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_BOW; } else if (item == ITEM_SLINGSHOT) { Inventory_ChangeUpgrade(UPG_BULLET_BAG, 1); INV_CONTENT(ITEM_SLINGSHOT) = ITEM_SLINGSHOT; AMMO(ITEM_SLINGSHOT) = 30; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_SEEDS) { AMMO(ITEM_SLINGSHOT) += 5; @@ -2064,11 +2064,11 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (!(gSaveContext.itemGetInf[1] & 8)) { gSaveContext.itemGetInf[1] |= 8; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_SEEDS; } else if (item == ITEM_SEEDS_30) { AMMO(ITEM_SLINGSHOT) += 30; @@ -2079,15 +2079,15 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (!(gSaveContext.itemGetInf[1] & 8)) { gSaveContext.itemGetInf[1] |= 8; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_SEEDS; } else if (item == ITEM_OCARINA_FAIRY) { INV_CONTENT(ITEM_OCARINA_FAIRY) = ITEM_OCARINA_FAIRY; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_OCARINA_TIME) { INV_CONTENT(ITEM_OCARINA_TIME) = ITEM_OCARINA_TIME; @@ -2095,7 +2095,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) { gSaveContext.equips.buttonItems[i] = ITEM_OCARINA_TIME; - Interface_LoadItemIcon1(globalCtx, i); + Interface_LoadItemIcon1(play, i); } } @@ -2104,8 +2104,8 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < ARRAY_COUNT(gSaveContext.adultEquips.buttonItems); i++) { if (gSaveContext.adultEquips.buttonItems[i] == ITEM_OCARINA_FAIRY) { gSaveContext.adultEquips.buttonItems[i] = ITEM_OCARINA_TIME; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, i); + if (play != NULL) { + Interface_LoadItemIcon1(play, i); } } } @@ -2114,13 +2114,13 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < ARRAY_COUNT(gSaveContext.childEquips.buttonItems); i++) { if (gSaveContext.childEquips.buttonItems[i] == ITEM_OCARINA_FAIRY) { gSaveContext.childEquips.buttonItems[i] = ITEM_OCARINA_TIME; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, i); + if (play != NULL) { + Interface_LoadItemIcon1(play, i); } } } } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BEAN) { if (gSaveContext.inventory.items[slot] == ITEM_NONE) { @@ -2131,66 +2131,66 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { AMMO(ITEM_BEAN)++; BEANS_BOUGHT++; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if ((item == ITEM_HEART_PIECE_2) || (item == ITEM_HEART_PIECE)) { gSaveContext.inventory.questItems += 1 << (QUEST_HEART_PIECE + 4); gSaveContext.sohStats.heartPieces++; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_HEART_CONTAINER) { gSaveContext.healthCapacity += 0x10; gSaveContext.health += 0x10; gSaveContext.sohStats.heartContainers++; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_HEART) { osSyncPrintf("回復ハート回復ハート回復ハート\n"); // "Recovery Heart" - if (globalCtx != NULL) { - Health_ChangeBy(globalCtx, 0x10); + if (play != NULL) { + Health_ChangeBy(play, 0x10); } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return item; } else if (item == ITEM_MAGIC_SMALL) { if (gSaveContext.unk_13F0 != 10) { - if (globalCtx != NULL) { - Magic_Fill(globalCtx); + if (play != NULL) { + Magic_Fill(play); } } - if (globalCtx != NULL) { - func_80087708(globalCtx, 12, 5); + if (play != NULL) { + func_80087708(play, 12, 5); } if (!(gSaveContext.infTable[25] & 0x100)) { gSaveContext.infTable[25] |= 0x100; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return item; } else if (item == ITEM_MAGIC_LARGE) { if (gSaveContext.unk_13F0 != 10) { - if (globalCtx != NULL) { - Magic_Fill(globalCtx); + if (play != NULL) { + Magic_Fill(play); } } - if (globalCtx != NULL) { - func_80087708(globalCtx, 24, 5); + if (play != NULL) { + func_80087708(play, 24, 5); } if (!(gSaveContext.infTable[25] & 0x100)) { gSaveContext.infTable[25] |= 0x100; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return item; } else if ((item >= ITEM_RUPEE_GREEN) && (item <= ITEM_INVALID_8)) { Rupees_ChangeBy(sAmmoRefillCounts[item - ITEM_RUPEE_GREEN + 10]); - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } else if (item == ITEM_BOTTLE) { temp = SLOT(item); @@ -2198,7 +2198,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 0; i < 4; i++) { if (gSaveContext.inventory.items[temp + i] == ITEM_NONE) { gSaveContext.inventory.items[temp + i] = item; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } @@ -2221,8 +2221,8 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (int buttonIndex = 1; buttonIndex < ARRAY_COUNT(gSaveContext.equips.buttonItems); buttonIndex++) { if ((temp + i) == gSaveContext.equips.cButtonSlots[buttonIndex - 1]) { gSaveContext.equips.buttonItems[buttonIndex] = item; - if (globalCtx != NULL) { - Interface_LoadItemIcon2(globalCtx, buttonIndex); + if (play != NULL) { + Interface_LoadItemIcon2(play, buttonIndex); } gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(buttonIndex)] = BTN_ENABLED; break; @@ -2230,7 +2230,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { } gSaveContext.inventory.items[temp + i] = item; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } @@ -2238,7 +2238,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 0; i < 4; i++) { if (gSaveContext.inventory.items[temp + i] == ITEM_NONE) { gSaveContext.inventory.items[temp + i] = item; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } @@ -2260,19 +2260,19 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (temp == gSaveContext.equips.buttonItems[i]) { if (item != ITEM_SOLD_OUT) { gSaveContext.equips.buttonItems[i] = item; - if (globalCtx != NULL) { - Interface_LoadItemIcon1(globalCtx, i); + if (play != NULL) { + Interface_LoadItemIcon1(play, i); } } else { gSaveContext.equips.buttonItems[i] = ITEM_NONE; } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } } } - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return ITEM_NONE; } @@ -2280,11 +2280,11 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf("Item_Register(%d)=%d %d\n", slot, item, temp); INV_CONTENT(item) = item; - PerformAutosave(globalCtx, item); + PerformAutosave(play, item); return temp; } -u16 Randomizer_Item_Give(GlobalContext* globalCtx, GetItemEntry giEntry) { +u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) { uint16_t item = giEntry.itemId; uint16_t temp; uint16_t i; @@ -2294,7 +2294,7 @@ u16 Randomizer_Item_Give(GlobalContext* globalCtx, GetItemEntry giEntry) { if (item == RG_MAGIC_SINGLE) { gSaveContext.magicAcquired = true; gSaveContext.unk_13F6 = 0x30; - Magic_Fill(globalCtx); + Magic_Fill(play); return RG_NONE; } else if (item == RG_MAGIC_DOUBLE) { if (!gSaveContext.magicAcquired) { @@ -2303,7 +2303,7 @@ u16 Randomizer_Item_Give(GlobalContext* globalCtx, GetItemEntry giEntry) { gSaveContext.doubleMagic = true; gSaveContext.unk_13F6 = 0x60; gSaveContext.magicLevel = 0; - Magic_Fill(globalCtx); + Magic_Fill(play); return RG_NONE; } @@ -2630,10 +2630,10 @@ u8 Item_CheckObtainability(u8 item) { return gSaveContext.inventory.items[slot]; } -void PerformAutosave(GlobalContext* globalCtx, u8 item) { +void PerformAutosave(PlayState* play, u8 item) { if (CVar_GetS32("gAutosave", 0)) { if (CVar_GetS32("gAutosaveAllItems", 0)) { - Gameplay_PerformSave(globalCtx); + Play_PerformSave(play); } else if (CVar_GetS32("gAutosaveMajorItems", 1)) { switch (item) { case ITEM_STICK: @@ -2669,11 +2669,11 @@ void PerformAutosave(GlobalContext* globalCtx, u8 item) { case ITEM_SEEDS_30: break; case ITEM_SWORD_MASTER: - if (globalCtx->sceneNum == SCENE_GANON_DEMO) { + if (play->sceneNum == SCENE_GANON_DEMO) { break; } default: - Gameplay_PerformSave(globalCtx); + Play_PerformSave(play); break; } } @@ -2699,7 +2699,7 @@ void Inventory_DeleteItem(u16 item, u16 invSlot) { } } -s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u16 oldItem, u16 newItem) { +s32 Inventory_ReplaceItem(PlayState* play, u16 oldItem, u16 newItem) { s16 i; for (i = 0; i < ARRAY_COUNT(gSaveContext.inventory.items); i++) { @@ -2709,7 +2709,7 @@ s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u16 oldItem, u16 newItem) { for (i = 1; i < ARRAY_COUNT(gSaveContext.equips.buttonItems); i++) { if (gSaveContext.equips.buttonItems[i] == oldItem) { gSaveContext.equips.buttonItems[i] = newItem; - Interface_LoadItemIcon1(globalCtx, i); + Interface_LoadItemIcon1(play, i); break; } } @@ -2763,7 +2763,7 @@ s32 Inventory_HasSpecificBottle(u8 bottleItem) { } } -void Inventory_UpdateBottleItem(GlobalContext* globalCtx, u8 item, u8 button) { +void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 button) { osSyncPrintf("item_no=%x, c_no=%x, Pt=%x Item_Register=%x\n", item, button, gSaveContext.equips.cButtonSlots[button - 1], gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]]); @@ -2777,13 +2777,13 @@ void Inventory_UpdateBottleItem(GlobalContext* globalCtx, u8 item, u8 button) { gSaveContext.inventory.items[gSaveContext.equips.cButtonSlots[button - 1]] = item; gSaveContext.equips.buttonItems[button] = item; - Interface_LoadItemIcon1(globalCtx, button); + Interface_LoadItemIcon1(play, button); - globalCtx->pauseCtx.cursorItem[PAUSE_ITEM] = item; + play->pauseCtx.cursorItem[PAUSE_ITEM] = item; gSaveContext.buttonStatus[BUTTON_STATUS_INDEX(button)] = BTN_ENABLED; } -s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { +s32 Inventory_ConsumeFairy(PlayState* play) { s32 bottleSlot = SLOT(ITEM_FAIRY); s16 i; s16 j; @@ -2793,7 +2793,7 @@ s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { for (j = 1; j < ARRAY_COUNT(gSaveContext.equips.buttonItems); j++) { if (gSaveContext.equips.buttonItems[j] == ITEM_FAIRY) { gSaveContext.equips.buttonItems[j] = ITEM_BOTTLE; - Interface_LoadItemIcon1(globalCtx, j); + Interface_LoadItemIcon1(play, j); i = 0; bottleSlot = gSaveContext.equips.cButtonSlots[j - 1]; break; @@ -2808,9 +2808,9 @@ s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { return 0; } -bool Inventory_HatchPocketCucco(GlobalContext* globalCtx) { +bool Inventory_HatchPocketCucco(PlayState* play) { if (!gSaveContext.n64ddFlag) { - return Inventory_ReplaceItem(globalCtx, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO); + return Inventory_ReplaceItem(play, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO); } if (!PLAYER_HAS_SHUFFLED_ADULT_TRADE_ITEM(ITEM_POCKET_EGG)) { @@ -2819,7 +2819,7 @@ bool Inventory_HatchPocketCucco(GlobalContext* globalCtx) { gSaveContext.adultTradeItems &= ~ADULT_TRADE_FLAG(ITEM_POCKET_EGG); gSaveContext.adultTradeItems |= ADULT_TRADE_FLAG(ITEM_POCKET_CUCCO); - Inventory_ReplaceItem(globalCtx, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO); + Inventory_ReplaceItem(play, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO); return 1; } @@ -2883,9 +2883,9 @@ void Interface_LoadActionLabel(InterfaceContext* interfaceCtx, u16 action, s16 l } } -void Interface_SetDoAction(GlobalContext* globalCtx, u16 action) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - PauseContext* pauseCtx = &globalCtx->pauseCtx; +void Interface_SetDoAction(PlayState* play, u16 action) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; + PauseContext* pauseCtx = &play->pauseCtx; if (interfaceCtx->unk_1F0 != action) { interfaceCtx->unk_1F0 = action; @@ -2898,11 +2898,11 @@ void Interface_SetDoAction(GlobalContext* globalCtx, u16 action) { } } -void Interface_SetNaviCall(GlobalContext* globalCtx, u16 naviCallState) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_SetNaviCall(PlayState* play, u16 naviCallState) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (((naviCallState == 0x1D) || (naviCallState == 0x1E)) && !interfaceCtx->naviCalling && - (globalCtx->csCtx.state == CS_STATE_IDLE)) { + (play->csCtx.state == CS_STATE_IDLE)) { if (!CVar_GetS32("gDisableNaviCallAudio", 0)) { // clang-format off if (naviCallState == 0x1E) { Audio_PlaySoundGeneral(NA_SE_VO_NAVY_CALL, &D_801333D4, 4, @@ -2922,8 +2922,8 @@ void Interface_SetNaviCall(GlobalContext* globalCtx, u16 naviCallState) { } } -void Interface_LoadActionLabelB(GlobalContext* globalCtx, u16 action) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_LoadActionLabelB(PlayState* play, u16 action) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; char* doAction = actionsTbl[action]; char newName[512]; @@ -2966,7 +2966,7 @@ void Interface_LoadActionLabelB(GlobalContext* globalCtx, u16 action) { interfaceCtx->unk_1FA = 1; } -s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) { +s32 Health_ChangeBy(PlayState* play, s16 healthChange) { u16 heartCount; u16 healthLevel; @@ -3101,7 +3101,7 @@ void Inventory_ChangeAmmo(s16 item, s16 ammoChange) { osSyncPrintf("合計 = (%d)\n", AMMO(item)); // "Total = (%d)" } -void Magic_Fill(GlobalContext* globalCtx) { +void Magic_Fill(PlayState* play) { if (gSaveContext.magicAcquired) { gSaveContext.unk_13F2 = gSaveContext.unk_13F0; gSaveContext.unk_13F6 = (gSaveContext.doubleMagic + 1) * 0x30; @@ -3109,7 +3109,7 @@ void Magic_Fill(GlobalContext* globalCtx) { } } -void func_800876C8(GlobalContext* globalCtx) { +void func_800876C8(PlayState* play) { if ((gSaveContext.unk_13F0 != 8) && (gSaveContext.unk_13F0 != 9)) { if (gSaveContext.unk_13F0 == 10) { gSaveContext.unk_13F2 = gSaveContext.unk_13F0; @@ -3118,7 +3118,7 @@ void func_800876C8(GlobalContext* globalCtx) { } } -s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { +s32 func_80087708(PlayState* play, s16 arg1, s16 arg2) { if (!gSaveContext.magicAcquired) { return 0; } @@ -3135,7 +3135,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 2: if ((gSaveContext.unk_13F0 == 0) || (gSaveContext.unk_13F0 == 7)) { if (gSaveContext.unk_13F0 == 7) { - globalCtx->actorCtx.lensActive = false; + play->actorCtx.lensActive = false; } gSaveContext.unk_13F8 = gSaveContext.magic - arg1; gSaveContext.unk_13F0 = 1; @@ -3147,7 +3147,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 1: if ((gSaveContext.unk_13F0 == 0) || (gSaveContext.unk_13F0 == 7)) { if (gSaveContext.unk_13F0 == 7) { - globalCtx->actorCtx.lensActive = false; + play->actorCtx.lensActive = false; } gSaveContext.unk_13F8 = gSaveContext.magic - arg1; gSaveContext.unk_13F0 = 6; @@ -3159,7 +3159,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 3: if (gSaveContext.unk_13F0 == 0) { if (gSaveContext.magic != 0) { - globalCtx->interfaceCtx.unk_230 = 80; + play->interfaceCtx.unk_230 = 80; gSaveContext.unk_13F0 = 7; return 1; } else { @@ -3175,7 +3175,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { case 4: if ((gSaveContext.unk_13F0 == 0) || (gSaveContext.unk_13F0 == 7)) { if (gSaveContext.unk_13F0 == 7) { - globalCtx->actorCtx.lensActive = false; + play->actorCtx.lensActive = false; } gSaveContext.unk_13F8 = gSaveContext.magic - arg1; gSaveContext.unk_13F0 = 4; @@ -3201,7 +3201,7 @@ s32 func_80087708(GlobalContext* globalCtx, s16 arg1, s16 arg2) { return 0; } -void Interface_UpdateMagicBar(GlobalContext* globalCtx) { +void Interface_UpdateMagicBar(PlayState* play) { static s16 sMagicBorderColors[][3] = { { 255, 255, 255 }, { 150, 150, 150 }, @@ -3234,8 +3234,8 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { static s16 sMagicBorderIndexes[] = { 0, 1, 1, 0 }; static s16 sMagicBorderRatio = 2; static s16 sMagicBorderStep = 1; - MessageContext* msgCtx = &globalCtx->msgCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 borderChangeR; s16 borderChangeG; s16 borderChangeB; @@ -3350,9 +3350,9 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { break; case 7: - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && - (msgCtx->msgMode == MSGMODE_NONE) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && - (globalCtx->sceneLoadFlag == 0) && (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx)) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + (msgCtx->msgMode == MSGMODE_NONE) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->sceneLoadFlag == 0) && (play->transitionMode == 0) && !Play_InCsMode(play)) { bool hasLens = false; for (int buttonIndex = 1; buttonIndex < (CVar_GetS32("gDpadEquips", 0) != 0) ? ARRAY_COUNT(gSaveContext.equips.buttonItems) : 4; buttonIndex++) { if (gSaveContext.equips.buttonItems[buttonIndex] == ITEM_LENS) { @@ -3360,10 +3360,10 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { break; } } - if ((gSaveContext.magic == 0) || ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) || + if ((gSaveContext.magic == 0) || ((func_8008F2F8(play) >= 2) && (func_8008F2F8(play) < 5)) || !hasLens || - !globalCtx->actorCtx.lensActive) { - globalCtx->actorCtx.lensActive = false; + !play->actorCtx.lensActive) { + play->actorCtx.lensActive = false; Audio_PlaySoundGeneral(NA_SE_SY_GLASSMODE_OFF, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); gSaveContext.unk_13F0 = 0; @@ -3434,12 +3434,12 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { } } -void Interface_DrawLineupTick(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_DrawLineupTick(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); gDPSetEnvColor(OVERLAY_DISP++, 255, 255, 255, 255); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, 255); @@ -3453,17 +3453,17 @@ void Interface_DrawLineupTick(GlobalContext* globalCtx) { gDPPipeSync(OVERLAY_DISP++); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Interface_DrawMagicBar(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_DrawMagicBar(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 magicDrop = R_MAGIC_BAR_LARGE_Y-R_MAGIC_BAR_SMALL_Y+2; s16 magicBarY; Color_RGB8 magicbar_yellow = {250,250,0}; //Magic bar being used Color_RGB8 magicbar_green = {R_MAGIC_FILL_COLOR(0),R_MAGIC_FILL_COLOR(1),R_MAGIC_FILL_COLOR(2)}; //Magic bar fill - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (gSaveContext.magicLevel != 0) { s16 X_Margins; @@ -3534,7 +3534,7 @@ void Interface_DrawMagicBar(GlobalContext* globalCtx) { rMagicFillX = rMagicFillX_original; } - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); if (CVar_GetS32("gHudColors", 1) == 2) {//Original game add color there so to prevent miss match we make it all white :) gDPSetEnvColor(OVERLAY_DISP++, 255, 255, 255, 255); @@ -3604,7 +3604,7 @@ void Interface_DrawMagicBar(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void func_80088AA0(s16 arg0) { @@ -3620,7 +3620,7 @@ void func_80088AA0(s16 arg0) { } } -void func_80088AF0(GlobalContext* globalCtx) { +void func_80088AF0(PlayState* play) { if (gSaveContext.timer2State != 0) { if (gSaveContext.eventInf[1] & 1) { gSaveContext.timer2Value = 239; @@ -3655,12 +3655,12 @@ void Interface_DrawActionLabel(GraphicsContext* gfxCtx, void* texture) { CLOSE_DISPS(gfxCtx); } -void Interface_DrawItemButtons(GlobalContext* globalCtx) { +void Interface_DrawItemButtons(PlayState* play) { static void* cUpLabelTextures[] = { gNaviCUpENGTex, gNaviCUpENGTex, gNaviCUpENGTex }; static s16 startButtonLeftPos[] = { 132, 130, 130 }; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - Player* player = GET_PLAYER(globalCtx); - PauseContext* pauseCtx = &globalCtx->pauseCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); + PauseContext* pauseCtx = &play->pauseCtx; s16 temp; // Used as both an alpha value and a button index s16 dxdy; s16 width; @@ -3913,7 +3913,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { C_Down_BTN_Pos[0] = OTRGetRectDimensionFromRightEdge(C_Down_BTN_Pos_ori[0]); } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); // B Button Color & Texture // Also loads the Item Button Texture reused by other buttons afterwards @@ -3977,7 +3977,7 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { G_TX_RENDERTILE, 0, 0, R_ITEM_BTN_DD(3) << 1, R_ITEM_BTN_DD(3) << 1); if ((pauseCtx->state < 8) || (pauseCtx->state >= 18)) { - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { + if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) { // Start Button Texture, Color & Label gDPPipeSync(OVERLAY_DISP++); @@ -4029,23 +4029,23 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { gDPSetEnvColor(OVERLAY_DISP++, 0, 0, 0, 0); Matrix_Translate(PosX_StartBtn-160+((Start_BTN_Scale+Start_BTN_Scale/3)*11.5f), (PosY_StartBtn-120+((Start_BTN_Scale+Start_BTN_Scale/3)*11.5f)) * -1, 1.0f, MTXMODE_NEW); Matrix_Scale(Start_BTN_Scale+(Start_BTN_Scale/3), Start_BTN_Scale+(Start_BTN_Scale/3), Start_BTN_Scale+(Start_BTN_Scale/3), MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[4], 4, 0); - Interface_DrawActionLabel(globalCtx->state.gfxCtx, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE() * 2); + Interface_DrawActionLabel(play->state.gfxCtx, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE() * 2); gDPPipeSync(OVERLAY_DISP++); } } - if (interfaceCtx->naviCalling && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && - (globalCtx->csCtx.state == CS_STATE_IDLE)) { + if (interfaceCtx->naviCalling && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + (play->csCtx.state == CS_STATE_IDLE)) { if (!sCUpInvisible) { // C-Up Button Texture, Color & Label (Navi Text) gDPPipeSync(OVERLAY_DISP++); if ((gSaveContext.unk_13EA == 1) || (gSaveContext.unk_13EA == 2) || (gSaveContext.unk_13EA == 5)) { temp = 0; - } else if ((player->stateFlags1 & 0x00200000) || (func_8008F2F8(globalCtx) == 4) || + } else if ((player->stateFlags1 & 0x00200000) || (func_8008F2F8(play) == 4) || (player->stateFlags2 & 0x00040000)) { temp = 70; } else { @@ -4216,16 +4216,16 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } int16_t gItemIconWidth[] = { 30, 24, 24, 24, 16, 16, 16, 16 }; int16_t gItemIconDD[] = { 550, 680, 680, 680, 1024, 1024, 1024, 1024 }; -void Interface_DrawItemIconTexture(GlobalContext* globalCtx, void* texture, s16 button) { - OPEN_DISPS(globalCtx->state.gfxCtx); - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { + OPEN_DISPS(play->state.gfxCtx); + GraphicsContext* gfxCtx = play->state.gfxCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 X_Margins_CL; s16 X_Margins_CR; s16 X_Margins_CD; @@ -4418,7 +4418,7 @@ void Interface_DrawItemIconTexture(GlobalContext* globalCtx, void* texture, s16 (ItemIconPos[button][1] + gItemIconWidth[button]) << 2, G_TX_RENDERTILE, 0, 0, gItemIconDD[button] << 1, gItemIconDD[button] << 1); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } const char* _gAmmoDigit0Tex[] = @@ -4432,7 +4432,7 @@ static int16_t gItemAmmoX[] = { B_BUTTON_X + 2, C_LEFT_BUTTON_X + 1, C_DOWN_BUTT static int16_t gItemAmmoY[] = { B_BUTTON_Y + 18, C_LEFT_BUTTON_Y + 17, C_DOWN_BUTTON_Y + 17, C_RIGHT_BUTTON_Y + 17, DPAD_UP_Y + 11, DPAD_DOWN_Y + 11, DPAD_LEFT_Y + 11, DPAD_RIGHT_Y + 11 }; -void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { +void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { s16 i; s16 ammo; s16 X_Margins_CL; @@ -4611,7 +4611,7 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { ItemIconPos[3][1] = ItemIconPos_ori[3][1]; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); i = gSaveContext.equips.buttonItems[button]; @@ -4628,11 +4628,11 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { gDPPipeSync(OVERLAY_DISP++); if ((button == 0) && (gSaveContext.minigameState == 1)) { - ammo = globalCtx->interfaceCtx.hbaAmmo; - } else if ((button == 0) && (globalCtx->shootingGalleryStatus > 1)) { - ammo = globalCtx->shootingGalleryStatus - 1; - } else if ((button == 0) && (globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38)) { - ammo = globalCtx->bombchuBowlingStatus; + ammo = play->interfaceCtx.hbaAmmo; + } else if ((button == 0) && (play->shootingGalleryStatus > 1)) { + ammo = play->shootingGalleryStatus - 1; + } else if ((button == 0) && (play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38)) { + ammo = play->bombchuBowlingStatus; if (ammo < 0) { ammo = 0; } @@ -4663,19 +4663,19 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Interface_DrawActionButton(GlobalContext* globalCtx, f32 x, f32 y) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_DrawActionButton(PlayState* play, f32 x, f32 y) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Translate(-137.0f + x, 97.0f - y, XREG(18) / 10.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateX(interfaceCtx->unk_1F4 / 10000.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[0], 4, 0); @@ -4685,14 +4685,14 @@ void Interface_DrawActionButton(GlobalContext* globalCtx, f32 x, f32 y) { gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Interface_InitVertices(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_InitVertices(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 i; - interfaceCtx->actionVtx = Graph_Alloc(globalCtx->state.gfxCtx, 8 * sizeof(Vtx)); + interfaceCtx->actionVtx = Graph_Alloc(play->state.gfxCtx, 8 * sizeof(Vtx)); // clang-format off interfaceCtx->actionVtx[0].v.ob[0] = @@ -4741,7 +4741,7 @@ void Interface_InitVertices(GlobalContext* globalCtx) { interfaceCtx->actionVtx[5].v.tc[0] = interfaceCtx->actionVtx[7].v.tc[0] = 1536; interfaceCtx->actionVtx[6].v.tc[1] = interfaceCtx->actionVtx[7].v.tc[1] = 512; - interfaceCtx->beatingHeartVtx = Graph_Alloc(globalCtx->state.gfxCtx, 4 * sizeof(Vtx)); + interfaceCtx->beatingHeartVtx = Graph_Alloc(play->state.gfxCtx, 4 * sizeof(Vtx)); interfaceCtx->beatingHeartVtx[0].v.ob[0] = interfaceCtx->beatingHeartVtx[2].v.ob[0] = -8; interfaceCtx->beatingHeartVtx[1].v.ob[0] = interfaceCtx->beatingHeartVtx[3].v.ob[0] = 8; @@ -4771,8 +4771,8 @@ void Interface_InitVertices(GlobalContext* globalCtx) { } /* -void func_8008A8B8(GlobalContext* globalCtx, s32 topY, s32 bottomY, s32 leftX, s32 rightX) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void func_8008A8B8(PlayState* play, s32 topY, s32 bottomY, s32 leftX, s32 rightX) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; Vec3f eye; Vec3f lookAt; Vec3f up; @@ -4809,7 +4809,7 @@ const char* digitTextures[] = gCounterDigit4Tex, gCounterDigit5Tex, gCounterDigit6Tex, gCounterDigit7Tex, gCounterDigit8Tex }; -void Interface_Draw(GlobalContext* globalCtx) { +void Interface_Draw(PlayState* play) { static s16 magicArrowEffectsR[] = { 255, 100, 255 }; static s16 magicArrowEffectsG[] = { 0, 100, 255 }; static s16 magicArrowEffectsB[] = { 0, 255, 100 }; @@ -4843,23 +4843,23 @@ void Interface_Draw(GlobalContext* globalCtx) { static s16 D_8015FFE4; static s16 D_8015FFE6; static s16 timerDigits[5]; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - PauseContext* pauseCtx = &globalCtx->pauseCtx; - MessageContext* msgCtx = &globalCtx->msgCtx; - Player* player = GET_PLAYER(globalCtx); + InterfaceContext* interfaceCtx = &play->interfaceCtx; + PauseContext* pauseCtx = &play->pauseCtx; + MessageContext* msgCtx = &play->msgCtx; + Player* player = GET_PLAYER(play); s16 svar1; s16 svar2; s16 svar3; s16 svar4; s16 svar5; s16 svar6; - bool fullUi = !CVar_GetS32("gMinimalUI", 0) || !R_MINIMAP_DISABLED || globalCtx->pauseCtx.state != 0; + bool fullUi = !CVar_GetS32("gMinimalUI", 0) || !R_MINIMAP_DISABLED || play->pauseCtx.state != 0; if (chaosEffectNoUI) { return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); // Invalidate Do Action textures as they may have changed gSPInvalidateTexCache(OVERLAY_DISP++, interfaceCtx->doActionSegment); @@ -4871,13 +4871,13 @@ void Interface_Draw(GlobalContext* globalCtx) { gSPSegment(OVERLAY_DISP++, 0x0B, interfaceCtx->mapSegment); if (pauseCtx->debugState == 0) { - Interface_InitVertices(globalCtx); + Interface_InitVertices(play); func_8008A994(interfaceCtx); if (fullUi || gSaveContext.health != gSaveContext.healthCapacity) { - HealthMeter_Draw(globalCtx); + HealthMeter_Draw(play); } - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); if (fullUi) { // Rupee Icon @@ -4942,7 +4942,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, rColor.r, rColor.g, rColor.b, interfaceCtx->magicAlpha); OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, PosX_RC, PosY_RC, 16, 16, 1 << 10, 1 << 10); - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_BMORI1: case SCENE_HIDAN: case SCENE_MIZUSIN: @@ -5073,23 +5073,23 @@ void Interface_Draw(GlobalContext* globalCtx) { } if (CVar_GetS32("gDrawLineupTick", 0)) { - Interface_DrawLineupTick(globalCtx); + Interface_DrawLineupTick(play); } if (fullUi || gSaveContext.unk_13F0 > 0) { - Interface_DrawMagicBar(globalCtx); + Interface_DrawMagicBar(play); } - Minimap_Draw(globalCtx); + Minimap_Draw(play); if ((R_PAUSE_MENU_MODE != 2) && (R_PAUSE_MENU_MODE != 3)) { - func_8002C124(&globalCtx->actorCtx.targetCtx, globalCtx); // Draw Z-Target + func_8002C124(&play->actorCtx.targetCtx, play); // Draw Z-Target } - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); if (fullUi) { - Interface_DrawItemButtons(globalCtx); + Interface_DrawItemButtons(play); } gDPPipeSync(OVERLAY_DISP++); @@ -5101,20 +5101,20 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { if (fullUi) { - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[0]], 0); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[0]], 0); } - if ((player->stateFlags1 & 0x00800000) || (globalCtx->shootingGalleryStatus > 1) || - ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { + if ((player->stateFlags1 & 0x00800000) || (play->shootingGalleryStatus > 1) || + ((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38))) { if (!fullUi) { - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[0]], 0); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[0]], 0); } gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 0, interfaceCtx->bAlpha); + Interface_DrawAmmoCount(play, 0, interfaceCtx->bAlpha); } } } else { @@ -5182,11 +5182,11 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[1] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cLeftAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[1]], 1); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[1]], 1); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 1, interfaceCtx->cLeftAlpha); + Interface_DrawAmmoCount(play, 1, interfaceCtx->cLeftAlpha); } gDPPipeSync(OVERLAY_DISP++); @@ -5195,11 +5195,11 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[2] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cDownAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[2]], 2); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[2]], 2); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 2, interfaceCtx->cDownAlpha); + Interface_DrawAmmoCount(play, 2, interfaceCtx->cDownAlpha); } gDPPipeSync(OVERLAY_DISP++); @@ -5208,11 +5208,11 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[3] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->cRightAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[3]], 3); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[3]], 3); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 3, interfaceCtx->cRightAlpha); + Interface_DrawAmmoCount(play, 3, interfaceCtx->cRightAlpha); } if (CVar_GetS32("gDpadEquips", 0) != 0) { @@ -5271,49 +5271,49 @@ void Interface_Draw(GlobalContext* globalCtx) { if (gSaveContext.equips.buttonItems[4] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadUpAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[4]], 4); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[4]], 4); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 4, interfaceCtx->dpadUpAlpha); + Interface_DrawAmmoCount(play, 4, interfaceCtx->dpadUpAlpha); } // DPad-Down Button Icon & Ammo Count if (gSaveContext.equips.buttonItems[5] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadDownAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[5]], 5); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[5]], 5); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 5, interfaceCtx->dpadDownAlpha); + Interface_DrawAmmoCount(play, 5, interfaceCtx->dpadDownAlpha); } // DPad-Left Button Icon & Ammo Count if (gSaveContext.equips.buttonItems[6] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadLeftAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[6]], 6); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[6]], 6); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 6, interfaceCtx->dpadLeftAlpha); + Interface_DrawAmmoCount(play, 6, interfaceCtx->dpadLeftAlpha); } // DPad-Right Button Icon & Ammo Count if (gSaveContext.equips.buttonItems[7] < 0xF0) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->dpadRightAlpha); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); - Interface_DrawItemIconTexture(globalCtx, gItemIcons[gSaveContext.equips.buttonItems[7]], 7); + Interface_DrawItemIconTexture(play, gItemIcons[gSaveContext.equips.buttonItems[7]], 7); gDPPipeSync(OVERLAY_DISP++); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); - Interface_DrawAmmoCount(globalCtx, 7, interfaceCtx->dpadRightAlpha); + Interface_DrawAmmoCount(play, 7, interfaceCtx->dpadRightAlpha); } } // A Button - func_80094A14(globalCtx->state.gfxCtx); + func_80094A14(play->state.gfxCtx); const Color_RGB8 A_Button_Colors = {R_A_BTN_COLOR(0), R_A_BTN_COLOR(1), R_A_BTN_COLOR(2)}; s16 X_Margins_BtnA; s16 Y_Margins_BtnA; @@ -5366,7 +5366,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, CVar_GetRGB("gCCABtnPrim", A_Button_Colors).r,CVar_GetRGB("gCCABtnPrim", A_Button_Colors).g,CVar_GetRGB("gCCABtnPrim", A_Button_Colors).b, interfaceCtx->aAlpha); } if (fullUi) { - Interface_DrawActionButton(globalCtx, PosX_BtnA, PosY_BtnA); + Interface_DrawActionButton(play, PosX_BtnA, PosY_BtnA); } gDPPipeSync(OVERLAY_DISP++); gSPSetGeometryMode(OVERLAY_DISP++, G_CULL_BACK); @@ -5377,14 +5377,14 @@ void Interface_Draw(GlobalContext* globalCtx) { Matrix_Translate(-138.0f + rAIconX, rAIconY, WREG(46 + gSaveContext.language) / 10.0f, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateX(interfaceCtx->unk_1F4 / 10000.0f, MTXMODE_APPLY); - gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[4], 4, 0); if ((interfaceCtx->unk_1EC < 2) || (interfaceCtx->unk_1EC == 3)) { - Interface_DrawActionLabel(globalCtx->state.gfxCtx, interfaceCtx->doActionSegment); + Interface_DrawActionLabel(play->state.gfxCtx, interfaceCtx->doActionSegment); } else { - Interface_DrawActionLabel(globalCtx->state.gfxCtx, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE()); + Interface_DrawActionLabel(play->state.gfxCtx, interfaceCtx->doActionSegment + DO_ACTION_TEX_SIZE()); } gDPPipeSync(OVERLAY_DISP++); @@ -5395,7 +5395,7 @@ void Interface_Draw(GlobalContext* globalCtx) { if ((pauseCtx->state == 6) && (pauseCtx->unk_1E4 == 3)) { // Inventory Equip Effects gSPSegment(OVERLAY_DISP++, 0x08, pauseCtx->iconItemSegment); - func_80094A14(globalCtx->state.gfxCtx); + func_80094A14(play->state.gfxCtx); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATERGBA_PRIM, G_CC_MODULATERGBA_PRIM); gSPMatrix(OVERLAY_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); @@ -5441,9 +5441,9 @@ void Interface_Draw(GlobalContext* globalCtx) { gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); } - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { if (gSaveContext.minigameState != 1) { // Carrots rendering if the action corresponds to riding a horse if (interfaceCtx->unk_1EE == 8 && !CVar_GetS32("gInfiniteEpona", 0)) { @@ -5540,12 +5540,12 @@ void Interface_Draw(GlobalContext* globalCtx) { } } - if ((gSaveContext.timer2State == 5) && (Message_GetState(&globalCtx->msgCtx) == TEXT_STATE_EVENT)) { + if ((gSaveContext.timer2State == 5) && (Message_GetState(&play->msgCtx) == TEXT_STATE_EVENT)) { // Trade quest timer reached 0 D_8015FFE6 = 40; gSaveContext.cutsceneIndex = 0; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->fadeTransition = 3; + play->sceneLoadFlag = 0x14; + play->fadeTransition = 3; gSaveContext.timer2State = 0; if ((gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI) && @@ -5564,25 +5564,25 @@ void Interface_Draw(GlobalContext* globalCtx) { if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { gSaveContext.eventInf[0] &= 0x7F80; osSyncPrintf("EVENT_INF=%x\n", gSaveContext.eventInf[0]); - globalCtx->nextEntranceIndex = spoilingItemEntrances[svar1]; + play->nextEntranceIndex = spoilingItemEntrances[svar1]; INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; for (svar2 = 1; svar2 < ARRAY_COUNT(gSaveContext.equips.buttonItems); svar2++) { if (gSaveContext.equips.buttonItems[svar2] == gSpoilingItems[svar1]) { gSaveContext.equips.buttonItems[svar2] = gSpoilingItemReverts[svar1]; - Interface_LoadItemIcon1(globalCtx, svar2); + Interface_LoadItemIcon1(play, svar2); } } } } } - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && - (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == MSGMODE_NONE) && - !(player->stateFlags2 & 0x01000000) && (globalCtx->sceneLoadFlag == 0) && - (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx) && (gSaveContext.minigameState != 1) && - (globalCtx->shootingGalleryStatus <= 1) && - !((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (msgCtx->msgMode == MSGMODE_NONE) && + !(player->stateFlags2 & 0x01000000) && (play->sceneLoadFlag == 0) && + (play->transitionMode == 0) && !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && + (play->shootingGalleryStatus <= 1) && + !((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38))) { svar6 = 0; switch (gSaveContext.timer1State) { case 1: @@ -5672,7 +5672,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gSaveContext.timer1State = 10; if (D_80125A5C != 0) { gSaveContext.health = 0; - globalCtx->damagePlayer(globalCtx, -(gSaveContext.health + 2)); + play->damagePlayer(play, -(gSaveContext.health + 2)); } D_80125A5C = 0; } else if (gSaveContext.timer1Value > 60) { @@ -5836,16 +5836,16 @@ void Interface_Draw(GlobalContext* globalCtx) { osSyncPrintf("TOTAL_EVENT_TM=%d\n", gSaveContext.timer2Value); if (gSaveContext.timer2Value <= 0) { - if (!Flags_GetSwitch(globalCtx, 0x37) || - ((globalCtx->sceneNum != SCENE_GANON_DEMO) && - (globalCtx->sceneNum != SCENE_GANON_FINAL) && - (globalCtx->sceneNum != SCENE_GANON_SONOGO) && - (globalCtx->sceneNum != SCENE_GANONTIKA_SONOGO))) { + if (!Flags_GetSwitch(play, 0x37) || + ((play->sceneNum != SCENE_GANON_DEMO) && + (play->sceneNum != SCENE_GANON_FINAL) && + (play->sceneNum != SCENE_GANON_SONOGO) && + (play->sceneNum != SCENE_GANONTIKA_SONOGO))) { D_8015FFE6 = 40; gSaveContext.timer2State = 5; gSaveContext.cutsceneIndex = 0; - Message_StartTextbox(globalCtx, 0x71B0, NULL); - func_8002DF54(globalCtx, NULL, 8); + Message_StartTextbox(play, 0x71B0, NULL); + func_8002DF54(play, NULL, 8); } else { D_8015FFE6 = 40; gSaveContext.timer2State = 6; @@ -5868,7 +5868,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gSaveContext.timer2Value++; if (gSaveContext.eventInf[1] & 1) { if (gSaveContext.timer2Value == 240) { - Message_StartTextbox(globalCtx, 0x6083, NULL); + Message_StartTextbox(play, 0x6083, NULL); gSaveContext.eventInf[1] &= ~1; gSaveContext.timer2State = 0; } @@ -5981,7 +5981,7 @@ void Interface_Draw(GlobalContext* globalCtx) { } if (pauseCtx->debugState == 3) { - FlagSet_Update(globalCtx); + FlagSet_Update(play); } if (interfaceCtx->unk_244 != 0) { @@ -5991,19 +5991,19 @@ void Interface_Draw(GlobalContext* globalCtx) { gDPFillRectangle(OVERLAY_DISP++, 0, 0, gScreenWidth - 1, gScreenHeight - 1); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Interface_Update(GlobalContext* globalCtx) { +void Interface_Update(PlayState* play) { static u8 D_80125B60 = 0; static s16 sPrevTimeIncrement = 0; - MessageContext* msgCtx = &globalCtx->msgCtx; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - Player* player = GET_PLAYER(globalCtx); + MessageContext* msgCtx = &play->msgCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + Player* player = GET_PLAYER(play); s16 alpha; s16 alpha1; u16 action; - Input* debugInput = &globalCtx->state.input[2]; + Input* debugInput = &play->state.input[2]; Top_HUD_Margin = CVar_GetS32("gHUDMargin_T", 0); Left_HUD_Margin = CVar_GetS32("gHUDMargin_L", 0); @@ -6021,13 +6021,13 @@ void Interface_Update(GlobalContext* globalCtx) { osSyncPrintf("J_N=%x J_N=%x\n", gSaveContext.language, &gSaveContext.language); } - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0)) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0)) { if ((gSaveContext.minigameState == 1) || (gSaveContext.sceneSetupIndex < 4) || - ((globalCtx->sceneNum == SCENE_SPOT20) && (gSaveContext.sceneSetupIndex == 4))) { + ((play->sceneNum == SCENE_SPOT20) && (gSaveContext.sceneSetupIndex == 4))) { if ((msgCtx->msgMode == MSGMODE_NONE) || - ((msgCtx->msgMode != MSGMODE_NONE) && (globalCtx->sceneNum == SCENE_BOWLING))) { - if (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) { - func_80083108(globalCtx); + ((msgCtx->msgMode != MSGMODE_NONE) && (play->sceneNum == SCENE_BOWLING))) { + if (play->gameOverCtx.state == GAMEOVER_INACTIVE) { + func_80083108(play); } } } @@ -6052,7 +6052,7 @@ void Interface_Update(GlobalContext* globalCtx) { alpha = 0; } - func_80082850(globalCtx, alpha); + func_80082850(play, alpha); gSaveContext.unk_13EC++; if (alpha == 0) { @@ -6071,7 +6071,7 @@ void Interface_Update(GlobalContext* globalCtx) { } osSyncPrintf("case 50 : alpha=%d alpha1=%d\n", alpha, alpha1); - func_80082644(globalCtx, alpha1); + func_80082644(play, alpha1); if (interfaceCtx->healthAlpha != 255) { interfaceCtx->healthAlpha = alpha1; @@ -6081,7 +6081,7 @@ void Interface_Update(GlobalContext* globalCtx) { interfaceCtx->magicAlpha = alpha1; } - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_SPOT00: case SCENE_SPOT01: case SCENE_SPOT02: @@ -6123,13 +6123,13 @@ void Interface_Update(GlobalContext* globalCtx) { break; case 52: gSaveContext.unk_13E8 = 1; - func_80082850(globalCtx, 0); + func_80082850(play, 0); gSaveContext.unk_13E8 = 0; default: break; } - Map_Update(globalCtx); + Map_Update(play); if (gSaveContext.healthAccumulator != 0) { gSaveContext.healthAccumulator -= 4; @@ -6149,24 +6149,24 @@ void Interface_Update(GlobalContext* globalCtx) { } } - HealthMeter_HandleCriticalAlarm(globalCtx); - D_80125A58 = func_8008F2F8(globalCtx); + HealthMeter_HandleCriticalAlarm(play); + D_80125A58 = func_8008F2F8(play); if (D_80125A58 == 1) { if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == 2 || CVar_GetS32("gSuperTunic", 0) != 0) { D_80125A58 = 0; } - } else if ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) { + } else if ((func_8008F2F8(play) >= 2) && (func_8008F2F8(play) < 5)) { if (CUR_EQUIP_VALUE(EQUIP_TUNIC) == 3 || CVar_GetS32("gSuperTunic", 0) != 0) { D_80125A58 = 0; } } - HealthMeter_Update(globalCtx); + HealthMeter_Update(play); - if ((gSaveContext.timer1State >= 3) && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && - (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & 0x01000000) && (globalCtx->sceneLoadFlag == 0) && - (globalCtx->transitionMode == 0) && !Gameplay_InCsMode(globalCtx)) {} + if ((gSaveContext.timer1State >= 3) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & 0x01000000) && (play->sceneLoadFlag == 0) && + (play->transitionMode == 0) && !Play_InCsMode(play)) {} if (gSaveContext.rupeeAccumulator != 0) { if (gSaveContext.rupeeAccumulator > 0) { @@ -6245,10 +6245,10 @@ void Interface_Update(GlobalContext* globalCtx) { WREG(7) = interfaceCtx->unk_1F4; - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && - (msgCtx->msgMode == MSGMODE_NONE) && (globalCtx->sceneLoadFlag == 0) && - (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->transitionMode == 0) && - ((globalCtx->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(globalCtx))) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + (msgCtx->msgMode == MSGMODE_NONE) && (play->sceneLoadFlag == 0) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionMode == 0) && + ((play->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(play))) { if ((gSaveContext.magicAcquired != 0) && (gSaveContext.magicLevel == 0)) { gSaveContext.magicLevel = gSaveContext.doubleMagic + 1; gSaveContext.unk_13F0 = 8; @@ -6261,7 +6261,7 @@ void Interface_Update(GlobalContext* globalCtx) { osSyncPrintf(VT_RST); } - Interface_UpdateMagicBar(globalCtx); + Interface_UpdateMagicBar(play); } if (gSaveContext.timer1State == 0) { @@ -6315,11 +6315,11 @@ void Interface_Update(GlobalContext* globalCtx) { // exit out of ocarina mode after suns song finishes playing if ((msgCtx->ocarinaAction != OCARINA_ACTION_CHECK_NOWARP_DONE) && (gSaveContext.sunsSongState == SUNSSONG_START)) { - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } // handle suns song in areas where time moves - if (globalCtx->envCtx.timeIncrement != 0) { + if (play->envCtx.timeIncrement != 0) { if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { D_80125B60 = 0; if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime <= 0xC001)) { @@ -6333,35 +6333,35 @@ void Interface_Update(GlobalContext* globalCtx) { if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime <= 0xC001)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gTimeIncrement = sPrevTimeIncrement; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } } else if (gSaveContext.dayTime > 0xC001) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gTimeIncrement = sPrevTimeIncrement; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } - } else if ((globalCtx->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_1) && + } else if ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_1) && (interfaceCtx->restrictions.sunsSong != 3)) { if ((gSaveContext.dayTime >= 0x4555) && (gSaveContext.dayTime < 0xC001)) { gSaveContext.nextDayTime = 0; - globalCtx->fadeTransition = 4; + play->fadeTransition = 4; gSaveContext.nextTransition = 2; - globalCtx->unk_11DE9 = 1; + play->unk_11DE9 = 1; } else { gSaveContext.nextDayTime = 0x8001; - globalCtx->fadeTransition = 5; + play->fadeTransition = 5; gSaveContext.nextTransition = 3; - globalCtx->unk_11DE9 = 1; + play->unk_11DE9 = 1; } - if (globalCtx->sceneNum == SCENE_SPOT13) { - globalCtx->fadeTransition = 14; + if (play->sceneNum == SCENE_SPOT13) { + play->fadeTransition = 14; gSaveContext.nextTransition = 14; } gSaveContext.respawnFlag = -2; - globalCtx->nextEntranceIndex = gSaveContext.entranceIndex; - globalCtx->sceneLoadFlag = 0x14; + play->nextEntranceIndex = gSaveContext.entranceIndex; + play->sceneLoadFlag = 0x14; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; func_800F6964(30); gSaveContext.seqId = (u8)NA_BGM_DISABLED; diff --git a/soh/src/code/z_path.c b/soh/src/code/z_path.c index 8ff42c07a..3b4ec7d0e 100644 --- a/soh/src/code/z_path.c +++ b/soh/src/code/z_path.c @@ -1,10 +1,10 @@ #include "global.h" -Path* Path_GetByIndex(GlobalContext* globalCtx, s16 index, s16 max) { +Path* Path_GetByIndex(PlayState* play, s16 index, s16 max) { Path* path; if (index != max) { - path = &globalCtx->setupPathList[index]; + path = &play->setupPathList[index]; } else { path = NULL; } diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 6729e9f55..a1d0a1722 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -25,40 +25,40 @@ s16 D_801614C8; u64 D_801614D0[0xA00]; #endif -GlobalContext* gGlobalCtx; +PlayState* gPlayState; -void func_800BC450(GlobalContext* globalCtx) { - Camera_ChangeDataIdx(GET_ACTIVE_CAM(globalCtx), globalCtx->unk_1242B - 1); +void func_800BC450(PlayState* play) { + Camera_ChangeDataIdx(GET_ACTIVE_CAM(play), play->unk_1242B - 1); } -void func_800BC490(GlobalContext* globalCtx, s16 point) { +void func_800BC490(PlayState* play, s16 point) { ASSERT(point == 1 || point == 2); - globalCtx->unk_1242B = point; + play->unk_1242B = point; if ((YREG(15) != 0x10) && (gSaveContext.cutsceneIndex < 0xFFF0)) { Audio_PlaySoundGeneral((point == 1) ? NA_SE_SY_CAMERA_ZOOM_DOWN : NA_SE_SY_CAMERA_ZOOM_UP, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } - func_800BC450(globalCtx); + func_800BC450(play); } -s32 func_800BC56C(GlobalContext* globalCtx, s16 arg1) { - return (arg1 == globalCtx->unk_1242B); +s32 func_800BC56C(PlayState* play, s16 arg1) { + return (arg1 == play->unk_1242B); } // original name: "Game_play_shop_pr_vr_switch_set" -void func_800BC590(GlobalContext* globalCtx) { +void func_800BC590(PlayState* play) { osSyncPrintf("Game_play_shop_pr_vr_switch_set()\n"); if (YREG(15) == 0x10) { - globalCtx->unk_1242B = 2; + play->unk_1242B = 2; } } -void func_800BC5E0(GlobalContext* globalCtx, s32 transitionType) { - TransitionContext* transitionCtx = &globalCtx->transitionCtx; +void func_800BC5E0(PlayState* play, s32 transitionType) { + TransitionContext* transitionCtx = &play->transitionCtx; memset(transitionCtx,0, sizeof(TransitionContext)); @@ -121,22 +121,22 @@ void func_800BC5E0(GlobalContext* globalCtx, s32 transitionType) { break; case 9: case 10: - globalCtx->transitionMode = 4; + play->transitionMode = 4; break; case 11: - globalCtx->transitionMode = 10; + play->transitionMode = 10; break; case 12: - globalCtx->transitionMode = 7; + play->transitionMode = 7; break; case 14: - globalCtx->transitionMode = 12; + play->transitionMode = 12; break; case 15: - globalCtx->transitionMode = 14; + play->transitionMode = 14; break; case 16: - globalCtx->transitionMode = 16; + play->transitionMode = 16; break; default: Fault_AddHungupAndCrash(__FILE__, __LINE__); @@ -145,94 +145,94 @@ void func_800BC5E0(GlobalContext* globalCtx, s32 transitionType) { } } -void func_800BC88C(GlobalContext* globalCtx) { - globalCtx->transitionCtx.transitionType = -1; +void func_800BC88C(PlayState* play) { + play->transitionCtx.transitionType = -1; } -Gfx* Gameplay_SetFog(GlobalContext* globalCtx, Gfx* gfx) { - return Gfx_SetFog2(gfx, globalCtx->lightCtx.fogColor[0], globalCtx->lightCtx.fogColor[1], - globalCtx->lightCtx.fogColor[2], 0, globalCtx->lightCtx.fogNear, 1000); +Gfx* Play_SetFog(PlayState* play, Gfx* gfx) { + return Gfx_SetFog2(gfx, play->lightCtx.fogColor[0], play->lightCtx.fogColor[1], + play->lightCtx.fogColor[2], 0, play->lightCtx.fogNear, 1000); } -void Gameplay_Destroy(GameState* thisx) { - GlobalContext* globalCtx = (GlobalContext*)thisx; - Player* player = GET_PLAYER(globalCtx); +void Play_Destroy(GameState* thisx) { + PlayState* play = (PlayState*)thisx; + Player* player = GET_PLAYER(play); - globalCtx->state.gfxCtx->callback = NULL; - globalCtx->state.gfxCtx->callbackParam = 0; + play->state.gfxCtx->callback = NULL; + play->state.gfxCtx->callbackParam = 0; SREG(91) = 0; R_PAUSE_MENU_MODE = 0; - PreRender_Destroy(&globalCtx->pauseBgPreRender); - Effect_DeleteAll(globalCtx); - EffectSs_ClearAll(globalCtx); - CollisionCheck_DestroyContext(globalCtx, &globalCtx->colChkCtx); + PreRender_Destroy(&play->pauseBgPreRender); + Effect_DeleteAll(play); + EffectSs_ClearAll(play); + CollisionCheck_DestroyContext(play, &play->colChkCtx); if (gTrnsnUnkState == 3) { TransitionUnk_Destroy(&sTrnsnUnk); gTrnsnUnkState = 0; } - if (globalCtx->transitionMode == 3) { - globalCtx->transitionCtx.destroy(&globalCtx->transitionCtx.data); - func_800BC88C(globalCtx); - globalCtx->transitionMode = 0; + if (play->transitionMode == 3) { + play->transitionCtx.destroy(&play->transitionCtx.data); + func_800BC88C(play); + play->transitionMode = 0; } ShrinkWindow_Destroy(); - TransitionFade_Destroy(&globalCtx->transitionFade); + TransitionFade_Destroy(&play->transitionFade); VisMono_Destroy(&D_80161498); - if (gSaveContext.linkAge != globalCtx->linkAgeOnLoad) { + if (gSaveContext.linkAge != play->linkAgeOnLoad) { Inventory_SwapAgeEquipment(); - Player_SetEquipmentData(globalCtx, player); + Player_SetEquipmentData(play, player); } - func_80031C3C(&globalCtx->actorCtx, globalCtx); - func_80110990(globalCtx); - KaleidoScopeCall_Destroy(globalCtx); + func_80031C3C(&play->actorCtx, play); + func_80110990(play); + KaleidoScopeCall_Destroy(play); KaleidoManager_Destroy(); ZeldaArena_Cleanup(); Fault_RemoveClient(&D_801614B8); disableBetaQuest(); - gGlobalCtx = NULL; + gPlayState = NULL; } -void GivePlayerRandoRewardSongOfTime(GlobalContext* globalCtx, RandomizerCheck check) { - Player* player = GET_PLAYER(globalCtx); +void GivePlayerRandoRewardSongOfTime(PlayState* play, RandomizerCheck check) { + Player* player = GET_PLAYER(play); - if (gSaveContext.entranceIndex == 0x050F && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && - !Flags_GetTreasure(globalCtx, 0x1F) && gSaveContext.nextTransition == 0xFF && !gSaveContext.pendingIceTrapCount) { + if (gSaveContext.entranceIndex == 0x050F && player != NULL && !Player_InBlockingCsMode(play, player) && + !Flags_GetTreasure(play, 0x1F) && gSaveContext.nextTransition == 0xFF && !gSaveContext.pendingIceTrapCount) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); - GiveItemEntryWithoutActor(globalCtx, getItemEntry); + GiveItemEntryWithoutActor(play, getItemEntry); player->pendingFlag.flagID = 0x1F; player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } } -void GivePlayerRandoRewardNocturne(GlobalContext* globalCtx, RandomizerCheck check) { - Player* player = GET_PLAYER(globalCtx); +void GivePlayerRandoRewardNocturne(PlayState* play, RandomizerCheck check) { + Player* player = GET_PLAYER(play); if ((gSaveContext.entranceIndex == 0x00DB || gSaveContext.entranceIndex == 0x0191 || gSaveContext.entranceIndex == 0x0195) && LINK_IS_ADULT && CHECK_QUEST_ITEM(QUEST_MEDALLION_FOREST) && CHECK_QUEST_ITEM(QUEST_MEDALLION_FIRE) && CHECK_QUEST_ITEM(QUEST_MEDALLION_WATER) && player != NULL && - !Player_InBlockingCsMode(globalCtx, player) && !Flags_GetEventChkInf(0xAA)) { + !Player_InBlockingCsMode(play, player) && !Flags_GetEventChkInf(0xAA)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_NOCTURNE_OF_SHADOW); - GiveItemEntryWithoutActor(globalCtx, getItemEntry); + GiveItemEntryWithoutActor(play, getItemEntry); player->pendingFlag.flagID = 0xAA; player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF; } } -void GivePlayerRandoRewardRequiem(GlobalContext* globalCtx, RandomizerCheck check) { - Player* player = GET_PLAYER(globalCtx); +void GivePlayerRandoRewardRequiem(PlayState* play, RandomizerCheck check) { + Player* player = GET_PLAYER(play); if ((gSaveContext.gameMode == 0) && (gSaveContext.respawnFlag <= 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) { if ((gSaveContext.entranceIndex == 0x01E1) && !Flags_GetEventChkInf(0xAC) && player != NULL && - !Player_InBlockingCsMode(globalCtx, player)) { + !Player_InBlockingCsMode(play, player)) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_SONG_OF_TIME); - GiveItemEntryWithoutActor(globalCtx, getItemEntry); + GiveItemEntryWithoutActor(play, getItemEntry); player->pendingFlag.flagID = 0xAC; player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF; } @@ -325,8 +325,8 @@ u8 CheckDungeonCount() { return dungeonCount; } -void GivePlayerRandoRewardZeldaLightArrowsGift(GlobalContext* globalCtx, RandomizerCheck check) { - Player* player = GET_PLAYER(globalCtx); +void GivePlayerRandoRewardZeldaLightArrowsGift(PlayState* play, RandomizerCheck check) { + Player* player = GET_PLAYER(play); u8 meetsRequirements = 0; @@ -365,35 +365,35 @@ void GivePlayerRandoRewardZeldaLightArrowsGift(GlobalContext* globalCtx, Randomi if (meetsRequirements && LINK_IS_ADULT && (gEntranceTable[((void)0, gSaveContext.entranceIndex)].scene == SCENE_TOKINOMA) && - !Flags_GetTreasure(globalCtx, 0x1E) && player != NULL && !Player_InBlockingCsMode(globalCtx, player) && - globalCtx->sceneLoadFlag == 0) { + !Flags_GetTreasure(play, 0x1E) && player != NULL && !Player_InBlockingCsMode(play, player) && + play->sceneLoadFlag == 0) { GetItemEntry getItem = Randomizer_GetItemFromKnownCheck(check, GI_ARROW_LIGHT); - if (GiveItemEntryWithoutActor(globalCtx, getItem)) { + if (GiveItemEntryWithoutActor(play, getItem)) { player->pendingFlag.flagID = 0x1E; player->pendingFlag.flagType = FLAG_SCENE_TREASURE; } } } -void GivePlayerRandoRewardSariaGift(GlobalContext* globalCtx, RandomizerCheck check) { - Player* player = GET_PLAYER(globalCtx); +void GivePlayerRandoRewardSariaGift(PlayState* play, RandomizerCheck check) { + Player* player = GET_PLAYER(play); if (gSaveContext.entranceIndex == 0x05E0) { GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_ZELDAS_LULLABY); - if (!Flags_GetEventChkInf(0xC1) && player != NULL && !Player_InBlockingCsMode(globalCtx, player)) { - GiveItemEntryWithoutActor(globalCtx, getItemEntry); + if (!Flags_GetEventChkInf(0xC1) && player != NULL && !Player_InBlockingCsMode(play, player)) { + GiveItemEntryWithoutActor(play, getItemEntry); player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF; player->pendingFlag.flagID = 0xC1; } } } -void Gameplay_Init(GameState* thisx) { - GlobalContext* globalCtx = (GlobalContext*)thisx; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void Play_Init(GameState* thisx) { + PlayState* play = (PlayState*)thisx; + GraphicsContext* gfxCtx = play->state.gfxCtx; enableBetaQuest(); - gGlobalCtx = globalCtx; - //globalCtx->state.gfxCtx = NULL; + gPlayState = play; + //play->state.gfxCtx = NULL; uintptr_t zAlloc; uintptr_t zAllocAligned; size_t zAllocSize; @@ -417,8 +417,8 @@ void Gameplay_Init(GameState* thisx) { if (gSaveContext.entranceIndex == -1) { gSaveContext.entranceIndex = 0; - globalCtx->state.running = false; - SET_NEXT_GAMESTATE(&globalCtx->state, Opening_Init, OpeningContext); + play->state.running = false; + SET_NEXT_GAMESTATE(&play->state, Opening_Init, OpeningContext); return; } @@ -426,37 +426,37 @@ void Gameplay_Init(GameState* thisx) { // OTRTODO allocate double the normal amount of memory // This is to avoid some parts of the game, like loading actors, causing OoM // This is potionally unavoidable due to struct size differences, but is x2 the right amount? - GameState_Realloc(&globalCtx->state, 0x1D4790 * 2); - KaleidoManager_Init(globalCtx); - View_Init(&globalCtx->view, gfxCtx); + GameState_Realloc(&play->state, 0x1D4790 * 2); + KaleidoManager_Init(play); + View_Init(&play->view, gfxCtx); Audio_SetExtraFilter(0); Quake_Init(); - for (i = 0; i < ARRAY_COUNT(globalCtx->cameraPtrs); i++) { - globalCtx->cameraPtrs[i] = NULL; + for (i = 0; i < ARRAY_COUNT(play->cameraPtrs); i++) { + play->cameraPtrs[i] = NULL; } - Camera_Init(&globalCtx->mainCamera, &globalCtx->view, &globalCtx->colCtx, globalCtx); - Camera_ChangeStatus(&globalCtx->mainCamera, CAM_STAT_ACTIVE); + Camera_Init(&play->mainCamera, &play->view, &play->colCtx, play); + Camera_ChangeStatus(&play->mainCamera, CAM_STAT_ACTIVE); for (i = 0; i < 3; i++) { - Camera_Init(&globalCtx->subCameras[i], &globalCtx->view, &globalCtx->colCtx, globalCtx); - Camera_ChangeStatus(&globalCtx->subCameras[i], CAM_STAT_UNK100); - } - - globalCtx->cameraPtrs[MAIN_CAM] = &globalCtx->mainCamera; - globalCtx->cameraPtrs[MAIN_CAM]->uid = 0; - globalCtx->activeCamera = MAIN_CAM; - func_8005AC48(&globalCtx->mainCamera, 0xFF); - func_80112098(globalCtx); - Message_Init(globalCtx); - GameOver_Init(globalCtx); - SoundSource_InitAll(globalCtx); - Effect_InitContext(globalCtx); - EffectSs_InitInfo(globalCtx, 0x55); - CollisionCheck_InitContext(globalCtx, &globalCtx->colChkCtx); - AnimationContext_Reset(&globalCtx->animationCtx); - func_8006450C(globalCtx, &globalCtx->csCtx); + Camera_Init(&play->subCameras[i], &play->view, &play->colCtx, play); + Camera_ChangeStatus(&play->subCameras[i], CAM_STAT_UNK100); + } + + play->cameraPtrs[MAIN_CAM] = &play->mainCamera; + play->cameraPtrs[MAIN_CAM]->uid = 0; + play->activeCamera = MAIN_CAM; + func_8005AC48(&play->mainCamera, 0xFF); + func_80112098(play); + Message_Init(play); + GameOver_Init(play); + SoundSource_InitAll(play); + Effect_InitContext(play); + EffectSs_InitInfo(play, 0x55); + CollisionCheck_InitContext(play, &play->colChkCtx); + AnimationContext_Reset(&play->animationCtx); + func_8006450C(play, &play->csCtx); if (gSaveContext.nextCutsceneIndex != 0xFFEF) { gSaveContext.cutsceneIndex = gSaveContext.nextCutsceneIndex; @@ -478,11 +478,11 @@ void Gameplay_Init(GameState* thisx) { gSaveContext.nightFlag = 0; } - Cutscene_HandleConditionalTriggers(globalCtx); + Cutscene_HandleConditionalTriggers(play); if (gSaveContext.gameMode != 0 || gSaveContext.cutsceneIndex >= 0xFFF0) { gSaveContext.nayrusLoveTimer = 0; - func_800876C8(globalCtx); + func_800876C8(play); gSaveContext.sceneSetupIndex = (gSaveContext.cutsceneIndex & 0xF) + 4; } else if (!LINK_IS_ADULT && IS_DAY) { gSaveContext.sceneSetupIndex = 0; @@ -508,24 +508,24 @@ void Gameplay_Init(GameState* thisx) { gSaveContext.sceneSetupIndex = (gSaveContext.eventChkInf[4] & 0x100) ? 3 : 2; } - Gameplay_SpawnScene( - globalCtx, + Play_SpawnScene( + play, gEntranceTable[((void)0, gSaveContext.entranceIndex) + ((void)0, gSaveContext.sceneSetupIndex)].scene, gEntranceTable[((void)0, gSaveContext.sceneSetupIndex) + ((void)0, gSaveContext.entranceIndex)].spawn); osSyncPrintf("\nSCENE_NO=%d COUNTER=%d\n", ((void)0, gSaveContext.entranceIndex), gSaveContext.sceneSetupIndex); - Cutscene_HandleEntranceTriggers(globalCtx); - KaleidoScopeCall_Init(globalCtx); - func_801109B0(globalCtx); + Cutscene_HandleEntranceTriggers(play); + KaleidoScopeCall_Init(play); + func_801109B0(play); if (gSaveContext.nextDayTime != 0xFFFF) { if (gSaveContext.nextDayTime == 0x8001) { gSaveContext.totalDays++; gSaveContext.bgsDayCount++; gSaveContext.dogIsLost = true; - if (Inventory_ReplaceItem(globalCtx, ITEM_WEIRD_EGG, ITEM_CHICKEN) || - Inventory_HatchPocketCucco(globalCtx)) { - Message_StartTextbox(globalCtx, 0x3066, NULL); + if (Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN) || + Inventory_HatchPocketCucco(play)) { + Message_StartTextbox(play, 0x3066, NULL); } gSaveContext.nextDayTime = 0xFFFE; } else { @@ -535,52 +535,52 @@ void Gameplay_Init(GameState* thisx) { SREG(91) = -1; R_PAUSE_MENU_MODE = 0; - PreRender_Init(&globalCtx->pauseBgPreRender); - PreRender_SetValuesSave(&globalCtx->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0); - PreRender_SetValues(&globalCtx->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); + PreRender_Init(&play->pauseBgPreRender); + PreRender_SetValuesSave(&play->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 0); + PreRender_SetValues(&play->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0); gTrnsnUnkState = 0; - globalCtx->transitionMode = 0; + play->transitionMode = 0; if (CVar_GetS32("gSceneTransitions", 255)!= 255){ - globalCtx->transitionMode = CVar_GetS32("gSceneTransitions", 0); + play->transitionMode = CVar_GetS32("gSceneTransitions", 0); gSaveContext.nextTransition = CVar_GetS32("gSceneTransitions", 0); - globalCtx->fadeTransition = CVar_GetS32("gSceneTransitions", 0); + play->fadeTransition = CVar_GetS32("gSceneTransitions", 0); } - FrameAdvance_Init(&globalCtx->frameAdvCtx); + FrameAdvance_Init(&play->frameAdvCtx); Rand_Seed((u32)osGetTime()); - Matrix_Init(&globalCtx->state); - globalCtx->state.main = Gameplay_Main; - globalCtx->state.destroy = Gameplay_Destroy; - globalCtx->sceneLoadFlag = -0x14; - globalCtx->unk_11E16 = 0xFF; - globalCtx->unk_11E18 = 0; - globalCtx->unk_11DE9 = 0; + Matrix_Init(&play->state); + play->state.main = Play_Main; + play->state.destroy = Play_Destroy; + play->sceneLoadFlag = -0x14; + play->unk_11E16 = 0xFF; + play->unk_11E18 = 0; + play->unk_11DE9 = 0; if (gSaveContext.gameMode != 1) { if (gSaveContext.nextTransition == 0xFF) { - globalCtx->fadeTransition = + play->fadeTransition = (gEntranceTable[((void)0, gSaveContext.entranceIndex) + tempSetupIndex].field >> 7) & 0x7F; // Fade In } else { - globalCtx->fadeTransition = gSaveContext.nextTransition; + play->fadeTransition = gSaveContext.nextTransition; gSaveContext.nextTransition = 0xFF; } } else { - globalCtx->fadeTransition = 6; + play->fadeTransition = 6; } ShrinkWindow_Init(); - TransitionFade_Init(&globalCtx->transitionFade); - TransitionFade_SetType(&globalCtx->transitionFade, 3); - TransitionFade_SetColor(&globalCtx->transitionFade, RGBA8(160, 160, 160, 255)); - TransitionFade_Start(&globalCtx->transitionFade); + TransitionFade_Init(&play->transitionFade); + TransitionFade_SetType(&play->transitionFade, 3); + TransitionFade_SetColor(&play->transitionFade, RGBA8(160, 160, 160, 255)); + TransitionFade_Start(&play->transitionFade); VisMono_Init(&D_80161498); D_801614B0.a = 0; - Flags_UnsetAllEnv(globalCtx); + Flags_UnsetAllEnv(play); - osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetSize(&globalCtx->state.tha)); - zAllocSize = THA_GetSize(&globalCtx->state.tha); - zAlloc = GAMESTATE_ALLOC_MC(&globalCtx->state, zAllocSize); + osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetSize(&play->state.tha)); + zAllocSize = THA_GetSize(&play->state.tha); + zAlloc = GAMESTATE_ALLOC_MC(&play->state, zAllocSize); zAllocAligned = (zAlloc + 8) & ~0xF; ZeldaArena_Init(zAllocAligned, zAllocSize - zAllocAligned + zAlloc); // "Zelda Heap" @@ -588,22 +588,22 @@ void Gameplay_Init(GameState* thisx) { (s32)(zAllocAligned + zAllocSize) - (s32)(zAllocAligned - zAlloc)); Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL); - func_800304DC(globalCtx, &globalCtx->actorCtx, globalCtx->linkActorEntry); + func_800304DC(play, &play->actorCtx, play->linkActorEntry); - while (!func_800973FC(globalCtx, &globalCtx->roomCtx)) { + while (!func_800973FC(play, &play->roomCtx)) { ; // Empty Loop } - player = GET_PLAYER(globalCtx); - Camera_InitPlayerSettings(&globalCtx->mainCamera, player); - Camera_ChangeMode(&globalCtx->mainCamera, CAM_MODE_NORMAL); + player = GET_PLAYER(play); + Camera_InitPlayerSettings(&play->mainCamera, player); + Camera_ChangeMode(&play->mainCamera, CAM_MODE_NORMAL); // OTRTODO: Bounds check cameraDataList to guard against scenes spawning the player with // an out of bounds background camera index. This requires adding an extra field to the // CollisionHeader struct to save the length of cameraDataList. // Fixes Dodongo's Cavern blue warp crash. { - CollisionHeader* colHeader = BgCheck_GetCollisionHeader(&globalCtx->colCtx, BGCHECK_SCENE); + CollisionHeader* colHeader = BgCheck_GetCollisionHeader(&play->colCtx, BGCHECK_SCENE); // If the player's start cam is out of bounds, set it to 0xFF so it isn't used. if (colHeader != NULL && ((player->actor.params & 0xFF) >= colHeader->cameraDataListLen)) { @@ -614,23 +614,23 @@ void Gameplay_Init(GameState* thisx) { playerStartCamId = player->actor.params & 0xFF; if (playerStartCamId != 0xFF) { osSyncPrintf("player has start camera ID (" VT_FGCOL(BLUE) "%d" VT_RST ")\n", playerStartCamId); - Camera_ChangeDataIdx(&globalCtx->mainCamera, playerStartCamId); + Camera_ChangeDataIdx(&play->mainCamera, playerStartCamId); } if (YREG(15) == 32) { - globalCtx->unk_1242B = 2; + play->unk_1242B = 2; } else if (YREG(15) == 16) { - globalCtx->unk_1242B = 1; + play->unk_1242B = 1; } else { - globalCtx->unk_1242B = 0; + play->unk_1242B = 0; } - Interface_SetSceneRestrictions(globalCtx); - Environment_PlaySceneSequence(globalCtx); - gSaveContext.seqId = globalCtx->sequenceCtx.seqId; - gSaveContext.natureAmbienceId = globalCtx->sequenceCtx.natureAmbienceId; - func_8002DF18(globalCtx, GET_PLAYER(globalCtx)); - AnimationContext_Update(globalCtx, &globalCtx->animationCtx); + Interface_SetSceneRestrictions(play); + Environment_PlaySceneSequence(play); + gSaveContext.seqId = play->sequenceCtx.seqId; + gSaveContext.natureAmbienceId = play->sequenceCtx.natureAmbienceId; + func_8002DF18(play, GET_PLAYER(play)); + AnimationContext_Update(play, &play->animationCtx); gSaveContext.respawnFlag = 0; #if 0 if (dREG(95) != 0) { @@ -641,14 +641,14 @@ void Gameplay_Init(GameState* thisx) { #endif } -void Gameplay_Update(GlobalContext* globalCtx) { +void Play_Update(PlayState* play) { s32 pad1; s32 sp80; Input* input; u32 i; s32 pad2; - input = globalCtx->state.input; + input = play->state.input; if ((SREG(1) < 0) || (DREG(0) != 0)) { SREG(1) = 0; @@ -673,17 +673,17 @@ void Gameplay_Update(GlobalContext* globalCtx) { ActorOverlayTable_LogPrint(); } - if (CVar_GetS32("gFreeCamera", 0) && Player_InCsMode(globalCtx)) { - globalCtx->manualCamera = false; + if (CVar_GetS32("gFreeCamera", 0) && Player_InCsMode(play)) { + play->manualCamera = false; } - gSegments[4] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment); - gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); - gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); + gSegments[4] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.mainKeepIndex].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); + gSegments[2] = VIRTUAL_TO_PHYSICAL(play->sceneSegment); - if (FrameAdvance_Update(&globalCtx->frameAdvCtx, &input[1])) { - if ((globalCtx->transitionMode == 0) && (globalCtx->sceneLoadFlag != 0)) { - globalCtx->transitionMode = 1; + if (FrameAdvance_Update(&play->frameAdvCtx, &input[1])) { + if ((play->transitionMode == 0) && (play->sceneLoadFlag != 0)) { + play->transitionMode = 1; } if (gTrnsnUnkState != 0) { @@ -704,10 +704,10 @@ void Gameplay_Update(GlobalContext* globalCtx) { } } - if (globalCtx->transitionMode) { - switch (globalCtx->transitionMode) { + if (play->transitionMode) { + switch (play->transitionMode) { case 1: - if (globalCtx->sceneLoadFlag != -0x14) { + if (play->sceneLoadFlag != -0x14) { s16 sp6E = 0; Interface_ChangeAlpha(1); @@ -715,10 +715,10 @@ void Gameplay_Update(GlobalContext* globalCtx) { sp6E = (gSaveContext.cutsceneIndex & 0xF) + 4; } - if (!(gEntranceTable[globalCtx->nextEntranceIndex + sp6E].field & 0x8000)) { // Continue BGM Off + if (!(gEntranceTable[play->nextEntranceIndex + sp6E].field & 0x8000)) { // Continue BGM Off // "Sound initalized. 111" osSyncPrintf("\n\n\nサウンドイニシャル来ました。111"); - if ((globalCtx->fadeTransition < 56) && !Environment_IsForcedSequenceDisabled()) { + if ((play->fadeTransition < 56) && !Environment_IsForcedSequenceDisabled()) { // "Sound initalized. 222" osSyncPrintf("\n\n\nサウンドイニシャル来ました。222"); func_800F6964(0x14); @@ -729,107 +729,107 @@ void Gameplay_Update(GlobalContext* globalCtx) { } if (CREG(11) == 0) { - func_800BC5E0(globalCtx, globalCtx->fadeTransition); + func_800BC5E0(play, play->fadeTransition); } else { - func_800BC5E0(globalCtx, CREG(12)); + func_800BC5E0(play, CREG(12)); } - if (globalCtx->transitionMode >= 4) { + if (play->transitionMode >= 4) { break; } case 2: - globalCtx->transitionCtx.init(&globalCtx->transitionCtx.data); + play->transitionCtx.init(&play->transitionCtx.data); - if ((globalCtx->transitionCtx.transitionType >> 5) == 1) { - globalCtx->transitionCtx.setType(&globalCtx->transitionCtx.data, - globalCtx->transitionCtx.transitionType | 0x80); + if ((play->transitionCtx.transitionType >> 5) == 1) { + play->transitionCtx.setType(&play->transitionCtx.data, + play->transitionCtx.transitionType | 0x80); } gSaveContext.unk_1419 = 14; - if ((globalCtx->transitionCtx.transitionType == 8) || - (globalCtx->transitionCtx.transitionType == 9)) { + if ((play->transitionCtx.transitionType == 8) || + (play->transitionCtx.transitionType == 9)) { gSaveContext.unk_1419 = 28; } gSaveContext.fadeDuration = 60; - if ((globalCtx->transitionCtx.transitionType == 4) || - (globalCtx->transitionCtx.transitionType == 5)) { + if ((play->transitionCtx.transitionType == 4) || + (play->transitionCtx.transitionType == 5)) { gSaveContext.fadeDuration = 20; - } else if ((globalCtx->transitionCtx.transitionType == 6) || - (globalCtx->transitionCtx.transitionType == 7)) { + } else if ((play->transitionCtx.transitionType == 6) || + (play->transitionCtx.transitionType == 7)) { gSaveContext.fadeDuration = 150; - } else if (globalCtx->transitionCtx.transitionType == 17) { + } else if (play->transitionCtx.transitionType == 17) { gSaveContext.fadeDuration = 2; } - if ((globalCtx->transitionCtx.transitionType == 3) || - (globalCtx->transitionCtx.transitionType == 5) || - (globalCtx->transitionCtx.transitionType == 7) || - (globalCtx->transitionCtx.transitionType == 13) || - (globalCtx->transitionCtx.transitionType == 17)) { - globalCtx->transitionCtx.setColor(&globalCtx->transitionCtx.data, RGBA8(160, 160, 160, 255)); - if (globalCtx->transitionCtx.setEnvColor != NULL) { - globalCtx->transitionCtx.setEnvColor(&globalCtx->transitionCtx.data, + if ((play->transitionCtx.transitionType == 3) || + (play->transitionCtx.transitionType == 5) || + (play->transitionCtx.transitionType == 7) || + (play->transitionCtx.transitionType == 13) || + (play->transitionCtx.transitionType == 17)) { + play->transitionCtx.setColor(&play->transitionCtx.data, RGBA8(160, 160, 160, 255)); + if (play->transitionCtx.setEnvColor != NULL) { + play->transitionCtx.setEnvColor(&play->transitionCtx.data, RGBA8(160, 160, 160, 255)); } - } else if (globalCtx->transitionCtx.transitionType == 18) { - globalCtx->transitionCtx.setColor(&globalCtx->transitionCtx.data, RGBA8(140, 140, 100, 255)); - if (globalCtx->transitionCtx.setEnvColor != NULL) { - globalCtx->transitionCtx.setEnvColor(&globalCtx->transitionCtx.data, + } else if (play->transitionCtx.transitionType == 18) { + play->transitionCtx.setColor(&play->transitionCtx.data, RGBA8(140, 140, 100, 255)); + if (play->transitionCtx.setEnvColor != NULL) { + play->transitionCtx.setEnvColor(&play->transitionCtx.data, RGBA8(140, 140, 100, 255)); } - } else if (globalCtx->transitionCtx.transitionType == 19) { - globalCtx->transitionCtx.setColor(&globalCtx->transitionCtx.data, RGBA8(70, 100, 110, 255)); - if (globalCtx->transitionCtx.setEnvColor != NULL) { - globalCtx->transitionCtx.setEnvColor(&globalCtx->transitionCtx.data, + } else if (play->transitionCtx.transitionType == 19) { + play->transitionCtx.setColor(&play->transitionCtx.data, RGBA8(70, 100, 110, 255)); + if (play->transitionCtx.setEnvColor != NULL) { + play->transitionCtx.setEnvColor(&play->transitionCtx.data, RGBA8(70, 100, 110, 255)); } } else { - globalCtx->transitionCtx.setColor(&globalCtx->transitionCtx.data, RGBA8(0, 0, 0, 0)); - if (globalCtx->transitionCtx.setEnvColor != NULL) { - globalCtx->transitionCtx.setEnvColor(&globalCtx->transitionCtx.data, RGBA8(0, 0, 0, 0)); + play->transitionCtx.setColor(&play->transitionCtx.data, RGBA8(0, 0, 0, 0)); + if (play->transitionCtx.setEnvColor != NULL) { + play->transitionCtx.setEnvColor(&play->transitionCtx.data, RGBA8(0, 0, 0, 0)); } } - if (globalCtx->sceneLoadFlag == -0x14) { - globalCtx->transitionCtx.setType(&globalCtx->transitionCtx.data, 1); + if (play->sceneLoadFlag == -0x14) { + play->transitionCtx.setType(&play->transitionCtx.data, 1); } else { - globalCtx->transitionCtx.setType(&globalCtx->transitionCtx.data, 2); + play->transitionCtx.setType(&play->transitionCtx.data, 2); } - globalCtx->transitionCtx.start(&globalCtx->transitionCtx); + play->transitionCtx.start(&play->transitionCtx); - if (globalCtx->transitionCtx.transitionType == 13) { - globalCtx->transitionMode = 11; + if (play->transitionCtx.transitionType == 13) { + play->transitionMode = 11; } else { - globalCtx->transitionMode = 3; + play->transitionMode = 3; } break; case 3: - if (globalCtx->transitionCtx.isDone(&globalCtx->transitionCtx) != 0) { - if (globalCtx->transitionCtx.transitionType >= 56) { - if (globalCtx->sceneLoadFlag == -0x14) { - globalCtx->transitionCtx.destroy(&globalCtx->transitionCtx); - func_800BC88C(globalCtx); - globalCtx->transitionMode = 0; + if (play->transitionCtx.isDone(&play->transitionCtx) != 0) { + if (play->transitionCtx.transitionType >= 56) { + if (play->sceneLoadFlag == -0x14) { + play->transitionCtx.destroy(&play->transitionCtx); + func_800BC88C(play); + play->transitionMode = 0; } - } else if (globalCtx->sceneLoadFlag != -0x14) { - globalCtx->state.running = 0; + } else if (play->sceneLoadFlag != -0x14) { + play->state.running = 0; if (gSaveContext.gameMode != 2) { - SET_NEXT_GAMESTATE(&globalCtx->state, Gameplay_Init, GlobalContext); - gSaveContext.entranceIndex = globalCtx->nextEntranceIndex; + SET_NEXT_GAMESTATE(&play->state, Play_Init, PlayState); + gSaveContext.entranceIndex = play->nextEntranceIndex; if (gSaveContext.minigameState == 1) { gSaveContext.minigameState = 3; } } else { - SET_NEXT_GAMESTATE(&globalCtx->state, FileChoose_Init, FileChooseContext); + SET_NEXT_GAMESTATE(&play->state, FileChoose_Init, FileChooseContext); } } else { - globalCtx->transitionCtx.destroy(&globalCtx->transitionCtx); - func_800BC88C(globalCtx); - globalCtx->transitionMode = 0; + play->transitionCtx.destroy(&play->transitionCtx); + func_800BC88C(play); + play->transitionMode = 0; if (gTrnsnUnkState == 3) { TransitionUnk_Destroy(&sTrnsnUnk); gTrnsnUnkState = 0; @@ -837,54 +837,54 @@ void Gameplay_Update(GlobalContext* globalCtx) { } // Don't autosave in grottos or cutscenes - if (CVar_GetS32("gAutosave", 0) && (globalCtx->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (globalCtx->sceneNum != SCENE_KAKUSIANA) && (gSaveContext.cutsceneIndex == 0)) { - Gameplay_PerformSave(globalCtx); + if (CVar_GetS32("gAutosave", 0) && (play->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (play->sceneNum != SCENE_KAKUSIANA) && (gSaveContext.cutsceneIndex == 0)) { + Play_PerformSave(play); } } - globalCtx->sceneLoadFlag = 0; + play->sceneLoadFlag = 0; } else { - globalCtx->transitionCtx.update(&globalCtx->transitionCtx.data, R_UPDATE_RATE); + play->transitionCtx.update(&play->transitionCtx.data, R_UPDATE_RATE); } break; } - switch (globalCtx->transitionMode) { + switch (play->transitionMode) { case 4: D_801614C8 = 0; - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = 160; - globalCtx->envCtx.screenFillColor[1] = 160; - globalCtx->envCtx.screenFillColor[2] = 160; - if (globalCtx->sceneLoadFlag != -0x14) { - globalCtx->envCtx.screenFillColor[3] = 0; - globalCtx->transitionMode = 5; + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = 160; + play->envCtx.screenFillColor[1] = 160; + play->envCtx.screenFillColor[2] = 160; + if (play->sceneLoadFlag != -0x14) { + play->envCtx.screenFillColor[3] = 0; + play->transitionMode = 5; } else { - globalCtx->envCtx.screenFillColor[3] = 255; - globalCtx->transitionMode = 6; + play->envCtx.screenFillColor[3] = 255; + play->transitionMode = 6; } break; case 5: - globalCtx->envCtx.screenFillColor[3] = (D_801614C8 / 20.0f) * 255.0f; + play->envCtx.screenFillColor[3] = (D_801614C8 / 20.0f) * 255.0f; if (D_801614C8 >= 20 && 1) { - globalCtx->state.running = 0; - SET_NEXT_GAMESTATE(&globalCtx->state, Gameplay_Init, GlobalContext); - gSaveContext.entranceIndex = globalCtx->nextEntranceIndex; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + play->state.running = 0; + SET_NEXT_GAMESTATE(&play->state, Play_Init, PlayState); + gSaveContext.entranceIndex = play->nextEntranceIndex; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } else { D_801614C8++; } break; case 6: - globalCtx->envCtx.screenFillColor[3] = (1 - D_801614C8 / 20.0f) * 255.0f; + play->envCtx.screenFillColor[3] = (1 - D_801614C8 / 20.0f) * 255.0f; if (D_801614C8 >= 20 && 1) { gTrnsnUnkState = 0; R_UPDATE_RATE = 3; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; - globalCtx->envCtx.fillScreen = false; + play->sceneLoadFlag = 0; + play->transitionMode = 0; + play->envCtx.fillScreen = false; } else { D_801614C8++; } @@ -892,117 +892,117 @@ void Gameplay_Update(GlobalContext* globalCtx) { case 7: D_801614C8 = 0; - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = 170; - globalCtx->envCtx.screenFillColor[1] = 160; - globalCtx->envCtx.screenFillColor[2] = 150; - if (globalCtx->sceneLoadFlag != -0x14) { - globalCtx->envCtx.screenFillColor[3] = 0; - globalCtx->transitionMode = 5; + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = 170; + play->envCtx.screenFillColor[1] = 160; + play->envCtx.screenFillColor[2] = 150; + if (play->sceneLoadFlag != -0x14) { + play->envCtx.screenFillColor[3] = 0; + play->transitionMode = 5; } else { - globalCtx->envCtx.screenFillColor[3] = 255; - globalCtx->transitionMode = 6; + play->envCtx.screenFillColor[3] = 255; + play->transitionMode = 6; } break; case 10: - if (globalCtx->sceneLoadFlag != -0x14) { - globalCtx->state.running = 0; - SET_NEXT_GAMESTATE(&globalCtx->state, Gameplay_Init, GlobalContext); - gSaveContext.entranceIndex = globalCtx->nextEntranceIndex; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + if (play->sceneLoadFlag != -0x14) { + play->state.running = 0; + SET_NEXT_GAMESTATE(&play->state, Play_Init, PlayState); + gSaveContext.entranceIndex = play->nextEntranceIndex; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } else { gTrnsnUnkState = 0; R_UPDATE_RATE = 3; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } break; case 11: if (gSaveContext.unk_1410 != 0) { - globalCtx->transitionMode = 3; + play->transitionMode = 3; } break; case 12: - if (globalCtx->sceneLoadFlag != -0x14) { - globalCtx->envCtx.sandstormState = 1; - globalCtx->transitionMode = 13; + if (play->sceneLoadFlag != -0x14) { + play->envCtx.sandstormState = 1; + play->transitionMode = 13; } else { - globalCtx->envCtx.sandstormState = 2; - globalCtx->envCtx.sandstormPrimA = 255; - globalCtx->envCtx.sandstormEnvA = 255; - globalCtx->transitionMode = 13; + play->envCtx.sandstormState = 2; + play->envCtx.sandstormPrimA = 255; + play->envCtx.sandstormEnvA = 255; + play->transitionMode = 13; } break; case 13: Audio_PlaySoundGeneral(NA_SE_EV_SAND_STORM - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - if (globalCtx->sceneLoadFlag == -0x14) { - if (globalCtx->envCtx.sandstormPrimA < 110) { + if (play->sceneLoadFlag == -0x14) { + if (play->envCtx.sandstormPrimA < 110) { gTrnsnUnkState = 0; R_UPDATE_RATE = 3; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } } else { - if (globalCtx->envCtx.sandstormEnvA == 255) { - globalCtx->state.running = 0; - SET_NEXT_GAMESTATE(&globalCtx->state, Gameplay_Init, GlobalContext); - gSaveContext.entranceIndex = globalCtx->nextEntranceIndex; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + if (play->envCtx.sandstormEnvA == 255) { + play->state.running = 0; + SET_NEXT_GAMESTATE(&play->state, Play_Init, PlayState); + gSaveContext.entranceIndex = play->nextEntranceIndex; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } } break; case 14: - if (globalCtx->sceneLoadFlag == -0x14) { - globalCtx->envCtx.sandstormState = 4; - globalCtx->envCtx.sandstormPrimA = 255; - globalCtx->envCtx.sandstormEnvA = 255; + if (play->sceneLoadFlag == -0x14) { + play->envCtx.sandstormState = 4; + play->envCtx.sandstormPrimA = 255; + play->envCtx.sandstormEnvA = 255; // "It's here!!!!!!!!!" LOG_STRING("来た!!!!!!!!!!!!!!!!!!!!!"); - globalCtx->transitionMode = 15; + play->transitionMode = 15; } else { - globalCtx->transitionMode = 12; + play->transitionMode = 12; } break; case 15: Audio_PlaySoundGeneral(NA_SE_EV_SAND_STORM - SFX_FLAG, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); - if (globalCtx->sceneLoadFlag == -0x14) { - if (globalCtx->envCtx.sandstormPrimA <= 0) { + if (play->sceneLoadFlag == -0x14) { + if (play->envCtx.sandstormPrimA <= 0) { gTrnsnUnkState = 0; R_UPDATE_RATE = 3; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } } break; case 16: D_801614C8 = 0; - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = 0; - globalCtx->envCtx.screenFillColor[1] = 0; - globalCtx->envCtx.screenFillColor[2] = 0; - globalCtx->envCtx.screenFillColor[3] = 255; - globalCtx->transitionMode = 17; + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = 0; + play->envCtx.screenFillColor[1] = 0; + play->envCtx.screenFillColor[2] = 0; + play->envCtx.screenFillColor[3] = 255; + play->transitionMode = 17; break; case 17: if (gSaveContext.unk_1410 != 0) { - globalCtx->envCtx.screenFillColor[3] = gSaveContext.unk_1410; + play->envCtx.screenFillColor[3] = gSaveContext.unk_1410; if (gSaveContext.unk_1410 < 0x65) { gTrnsnUnkState = 0; R_UPDATE_RATE = 3; - globalCtx->sceneLoadFlag = 0; - globalCtx->transitionMode = 0; + play->sceneLoadFlag = 0; + play->transitionMode = 0; } } break; @@ -1018,28 +1018,28 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1); } - if ((gSaveContext.gameMode == 0) && (globalCtx->msgCtx.msgMode == MSGMODE_NONE) && - (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) { - KaleidoSetup_Update(globalCtx); + if ((gSaveContext.gameMode == 0) && (play->msgCtx.msgMode == MSGMODE_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE)) { + KaleidoSetup_Update(play); } if (1 && HREG(63)) { LOG_NUM("1", 1); } - sp80 = (globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0); + sp80 = (play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0); if (1 && HREG(63)) { LOG_NUM("1", 1); } - AnimationContext_Reset(&globalCtx->animationCtx); + AnimationContext_Reset(&play->animationCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - Object_UpdateBank(&globalCtx->objectCtx); + Object_UpdateBank(&play->objectCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); @@ -1050,83 +1050,83 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1); } - globalCtx->gameplayFrames++; + play->gameplayFrames++; func_800AA178(1); - if (globalCtx->actorCtx.freezeFlashTimer && (globalCtx->actorCtx.freezeFlashTimer-- < 5)) { - osSyncPrintf("FINISH=%d\n", globalCtx->actorCtx.freezeFlashTimer); - if ((globalCtx->actorCtx.freezeFlashTimer > 0) && - ((globalCtx->actorCtx.freezeFlashTimer % 2) != 0)) { - globalCtx->envCtx.fillScreen = true; - globalCtx->envCtx.screenFillColor[0] = globalCtx->envCtx.screenFillColor[1] = - globalCtx->envCtx.screenFillColor[2] = 150; - globalCtx->envCtx.screenFillColor[3] = 80; + if (play->actorCtx.freezeFlashTimer && (play->actorCtx.freezeFlashTimer-- < 5)) { + osSyncPrintf("FINISH=%d\n", play->actorCtx.freezeFlashTimer); + if ((play->actorCtx.freezeFlashTimer > 0) && + ((play->actorCtx.freezeFlashTimer % 2) != 0)) { + play->envCtx.fillScreen = true; + play->envCtx.screenFillColor[0] = play->envCtx.screenFillColor[1] = + play->envCtx.screenFillColor[2] = 150; + play->envCtx.screenFillColor[3] = 80; } else { - globalCtx->envCtx.fillScreen = false; + play->envCtx.fillScreen = false; } } else { if (1 && HREG(63)) { LOG_NUM("1", 1); } - func_800973FC(globalCtx, &globalCtx->roomCtx); + func_800973FC(play, &play->roomCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - CollisionCheck_AT(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_AT(play, &play->colChkCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - CollisionCheck_OC(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_OC(play, &play->colChkCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - CollisionCheck_Damage(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_Damage(play, &play->colChkCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx); + CollisionCheck_ClearContext(play, &play->colChkCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - if (globalCtx->unk_11DE9 == 0) { - Actor_UpdateAll(globalCtx, &globalCtx->actorCtx); + if (play->unk_11DE9 == 0) { + Actor_UpdateAll(play, &play->actorCtx); } if (1 && HREG(63)) { LOG_NUM("1", 1); } - func_80064558(globalCtx, &globalCtx->csCtx); + func_80064558(play, &play->csCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - func_800645A0(globalCtx, &globalCtx->csCtx); + func_800645A0(play, &play->csCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - Effect_UpdateAll(globalCtx); + Effect_UpdateAll(play); if (1 && HREG(63)) { LOG_NUM("1", 1); } - EffectSs_UpdateAll(globalCtx); + EffectSs_UpdateAll(play); if (1 && HREG(63)) { LOG_NUM("1", 1); @@ -1140,63 +1140,63 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1); } - func_80095AA0(globalCtx, &globalCtx->roomCtx.curRoom, &input[1], 0); + func_80095AA0(play, &play->roomCtx.curRoom, &input[1], 0); if (1 && HREG(63)) { LOG_NUM("1", 1); } - func_80095AA0(globalCtx, &globalCtx->roomCtx.prevRoom, &input[1], 1); + func_80095AA0(play, &play->roomCtx.prevRoom, &input[1], 1); if (1 && HREG(63)) { LOG_NUM("1", 1); } - if (globalCtx->unk_1242B != 0) { + if (play->unk_1242B != 0) { if (CHECK_BTN_ALL(input[0].press.button, BTN_CUP)) { - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { + if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) { // "Changing viewpoint is prohibited due to the kaleidoscope" osSyncPrintf(VT_FGCOL(CYAN) "カレイドスコープ中につき視点変更を禁止しております\n" VT_RST); - } else if (Player_InCsMode(globalCtx)) { + } else if (Player_InCsMode(play)) { // "Changing viewpoint is prohibited during the cutscene" osSyncPrintf(VT_FGCOL(CYAN) "デモ中につき視点変更を禁止しております\n" VT_RST); } else if (YREG(15) == 0x10) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } else { - func_800BC490(globalCtx, globalCtx->unk_1242B ^ 3); + func_800BC490(play, play->unk_1242B ^ 3); } } - func_800BC450(globalCtx); + func_800BC450(play); } if (1 && HREG(63)) { LOG_NUM("1", 1); } - SkyboxDraw_Update(&globalCtx->skyboxCtx); + SkyboxDraw_Update(&play->skyboxCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { + if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) { if (1 && HREG(63)) { LOG_NUM("1", 1); } - KaleidoScopeCall_Update(globalCtx); - } else if (globalCtx->gameOverCtx.state != GAMEOVER_INACTIVE) { + KaleidoScopeCall_Update(play); + } else if (play->gameOverCtx.state != GAMEOVER_INACTIVE) { if (1 && HREG(63)) { LOG_NUM("1", 1); } - GameOver_Update(globalCtx); + GameOver_Update(play); } else { if (1 && HREG(63)) { LOG_NUM("1", 1); } - Message_Update(globalCtx); + Message_Update(play); } if (1 && HREG(63)) { @@ -1207,19 +1207,19 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1); } - Interface_Update(globalCtx); + Interface_Update(play); if (1 && HREG(63)) { LOG_NUM("1", 1); } - AnimationContext_Update(globalCtx, &globalCtx->animationCtx); + AnimationContext_Update(play, &play->animationCtx); if (1 && HREG(63)) { LOG_NUM("1", 1); } - SoundSource_UpdateAll(globalCtx); + SoundSource_UpdateAll(play); if (1 && HREG(63)) { LOG_NUM("1", 1); @@ -1231,7 +1231,7 @@ void Gameplay_Update(GlobalContext* globalCtx) { LOG_NUM("1", 1); } - TransitionFade_Update(&globalCtx->transitionFade, R_UPDATE_RATE); + TransitionFade_Update(&play->transitionFade, R_UPDATE_RATE); } else { goto skip; } @@ -1250,23 +1250,23 @@ skip: s32 pad3[5]; s32 i; - globalCtx->nextCamera = globalCtx->activeCamera; + play->nextCamera = play->activeCamera; if (1 && HREG(63)) { LOG_NUM("1", 1); } for (i = 0; i < NUM_CAMS; i++) { - if ((i != globalCtx->nextCamera) && (globalCtx->cameraPtrs[i] != NULL)) { + if ((i != play->nextCamera) && (play->cameraPtrs[i] != NULL)) { if (1 && HREG(63)) { LOG_NUM("1", 1); } - Camera_Update(globalCtx->cameraPtrs[i]); + Camera_Update(play->cameraPtrs[i]); } } - Camera_Update(globalCtx->cameraPtrs[globalCtx->nextCamera]); + Camera_Update(play->cameraPtrs[play->nextCamera]); if (1 && HREG(63)) { LOG_NUM("1", 1); @@ -1277,87 +1277,87 @@ skip: LOG_NUM("1", 1); } - Environment_Update(globalCtx, &globalCtx->envCtx, &globalCtx->lightCtx, &globalCtx->pauseCtx, &globalCtx->msgCtx, - &globalCtx->gameOverCtx, globalCtx->state.gfxCtx); + Environment_Update(play, &play->envCtx, &play->lightCtx, &play->pauseCtx, &play->msgCtx, + &play->gameOverCtx, play->state.gfxCtx); if (gSaveContext.n64ddFlag) { - GivePlayerRandoRewardSariaGift(globalCtx, RC_LW_GIFT_FROM_SARIA); - GivePlayerRandoRewardSongOfTime(globalCtx, RC_SONG_FROM_OCARINA_OF_TIME); - GivePlayerRandoRewardZeldaLightArrowsGift(globalCtx, RC_TOT_LIGHT_ARROWS_CUTSCENE); - GivePlayerRandoRewardNocturne(globalCtx, RC_SHEIK_IN_KAKARIKO); - GivePlayerRandoRewardRequiem(globalCtx, RC_SHEIK_AT_COLOSSUS); + GivePlayerRandoRewardSariaGift(play, RC_LW_GIFT_FROM_SARIA); + GivePlayerRandoRewardSongOfTime(play, RC_SONG_FROM_OCARINA_OF_TIME); + GivePlayerRandoRewardZeldaLightArrowsGift(play, RC_TOT_LIGHT_ARROWS_CUTSCENE); + GivePlayerRandoRewardNocturne(play, RC_SHEIK_IN_KAKARIKO); + GivePlayerRandoRewardRequiem(play, RC_SHEIK_AT_COLOSSUS); } } -void Gameplay_DrawOverlayElements(GlobalContext* globalCtx) { - if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) { - KaleidoScopeCall_Draw(globalCtx); +void Play_DrawOverlayElements(PlayState* play) { + if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) { + KaleidoScopeCall_Draw(play); } if (gSaveContext.gameMode == 0) { - Interface_Draw(globalCtx); + Interface_Draw(play); } - Message_Draw(globalCtx); + Message_Draw(play); - if (globalCtx->gameOverCtx.state != GAMEOVER_INACTIVE) { - GameOver_FadeInLights(globalCtx); + if (play->gameOverCtx.state != GAMEOVER_INACTIVE) { + GameOver_FadeInLights(play); } } -void Gameplay_Draw(GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void Play_Draw(PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; Lights* sp228; Vec3f sp21C; OPEN_DISPS(gfxCtx); - gSegments[4] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment); - gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); - gSegments[2] = VIRTUAL_TO_PHYSICAL(globalCtx->sceneSegment); + gSegments[4] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.mainKeepIndex].segment); + gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); + gSegments[2] = VIRTUAL_TO_PHYSICAL(play->sceneSegment); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gSPSegment(POLY_XLU_DISP++, 0x00, NULL); gSPSegment(OVERLAY_DISP++, 0x00, NULL); - gSPSegment(POLY_OPA_DISP++, 0x04, globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x04, globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment); - gSPSegment(OVERLAY_DISP++, 0x04, globalCtx->objectCtx.status[globalCtx->objectCtx.mainKeepIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x04, play->objectCtx.status[play->objectCtx.mainKeepIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x04, play->objectCtx.status[play->objectCtx.mainKeepIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x04, play->objectCtx.status[play->objectCtx.mainKeepIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x05, globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); - gSPSegment(POLY_XLU_DISP++, 0x05, globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); - gSPSegment(OVERLAY_DISP++, 0x05, globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); + gSPSegment(POLY_OPA_DISP++, 0x05, play->objectCtx.status[play->objectCtx.subKeepIndex].segment); + gSPSegment(POLY_XLU_DISP++, 0x05, play->objectCtx.status[play->objectCtx.subKeepIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x05, play->objectCtx.status[play->objectCtx.subKeepIndex].segment); - gSPSegment(POLY_OPA_DISP++, 0x02, globalCtx->sceneSegment); - gSPSegment(POLY_XLU_DISP++, 0x02, globalCtx->sceneSegment); - gSPSegment(OVERLAY_DISP++, 0x02, globalCtx->sceneSegment); + gSPSegment(POLY_OPA_DISP++, 0x02, play->sceneSegment); + gSPSegment(POLY_XLU_DISP++, 0x02, play->sceneSegment); + gSPSegment(OVERLAY_DISP++, 0x02, play->sceneSegment); func_80095248(gfxCtx, 0, 0, 0); if ((HREG(80) != 10) || (HREG(82) != 0)) { - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP); - POLY_XLU_DISP = Gameplay_SetFog(globalCtx, POLY_XLU_DISP); - POLY_KAL_DISP = Gameplay_SetFog(globalCtx, POLY_KAL_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); + POLY_XLU_DISP = Play_SetFog(play, POLY_XLU_DISP); + POLY_KAL_DISP = Play_SetFog(play, POLY_KAL_DISP); - func_800AA460(&globalCtx->view, globalCtx->view.fovy, globalCtx->view.zNear, globalCtx->lightCtx.fogFar); - func_800AAA50(&globalCtx->view, 15); + func_800AA460(&play->view, play->view.fovy, play->view.zNear, play->lightCtx.fogFar); + func_800AAA50(&play->view, 15); // The billboard matrix temporarily stores the viewing matrix - Matrix_MtxToMtxF(&globalCtx->view.viewing, &globalCtx->billboardMtxF); - Matrix_MtxToMtxF(&globalCtx->view.projection, &globalCtx->viewProjectionMtxF); - Matrix_Mult(&globalCtx->viewProjectionMtxF, MTXMODE_NEW); + Matrix_MtxToMtxF(&play->view.viewing, &play->billboardMtxF); + Matrix_MtxToMtxF(&play->view.projection, &play->viewProjectionMtxF); + Matrix_Mult(&play->viewProjectionMtxF, MTXMODE_NEW); // The billboard is still a viewing matrix at this stage - Matrix_Mult(&globalCtx->billboardMtxF, MTXMODE_APPLY); - Matrix_Get(&globalCtx->viewProjectionMtxF); - globalCtx->billboardMtxF.mf[0][3] = globalCtx->billboardMtxF.mf[1][3] = globalCtx->billboardMtxF.mf[2][3] = - globalCtx->billboardMtxF.mf[3][0] = globalCtx->billboardMtxF.mf[3][1] = globalCtx->billboardMtxF.mf[3][2] = + Matrix_Mult(&play->billboardMtxF, MTXMODE_APPLY); + Matrix_Get(&play->viewProjectionMtxF); + play->billboardMtxF.mf[0][3] = play->billboardMtxF.mf[1][3] = play->billboardMtxF.mf[2][3] = + play->billboardMtxF.mf[3][0] = play->billboardMtxF.mf[3][1] = play->billboardMtxF.mf[3][2] = 0.0f; // This transpose is where the viewing matrix is properly converted into a billboard matrix - Matrix_Transpose(&globalCtx->billboardMtxF); - globalCtx->billboardMtx = Matrix_MtxFToMtx(MATRIX_CHECKFLOATS(&globalCtx->billboardMtxF), + Matrix_Transpose(&play->billboardMtxF); + play->billboardMtx = Matrix_MtxFToMtx(MATRIX_CHECKFLOATS(&play->billboardMtxF), Graph_Alloc(gfxCtx, sizeof(Mtx))); - gSPSegment(POLY_OPA_DISP++, 0x01, globalCtx->billboardMtx); + gSPSegment(POLY_OPA_DISP++, 0x01, play->billboardMtx); if ((HREG(80) != 10) || (HREG(92) != 0)) { Gfx* gfxP; @@ -1367,8 +1367,8 @@ void Gameplay_Draw(GlobalContext* globalCtx) { gSPDisplayList(OVERLAY_DISP++, gfxP); gsSPGrayscale(gfxP++, false); - if ((globalCtx->transitionMode == 3) || (globalCtx->transitionMode == 11) || - (globalCtx->transitionCtx.transitionType >= 56)) { + if ((play->transitionMode == 3) || (play->transitionMode == 11) || + (play->transitionCtx.transitionType >= 56)) { View view; View_Init(&view, gfxCtx); @@ -1377,10 +1377,10 @@ void Gameplay_Draw(GlobalContext* globalCtx) { SET_FULLSCREEN_VIEWPORT(&view); func_800AB9EC(&view, 15, &gfxP); - globalCtx->transitionCtx.draw(&globalCtx->transitionCtx.data, &gfxP); + play->transitionCtx.draw(&play->transitionCtx.data, &gfxP); } - TransitionFade_Draw(&globalCtx->transitionFade, &gfxP); + TransitionFade_Draw(&play->transitionFade, &gfxP); if (D_801614B0.a > 0) { gsDPSetGrayscaleColor(gfxP++, D_801614B0.r, D_801614B0.g, D_801614B0.b, D_801614B0.a); @@ -1397,14 +1397,14 @@ void Gameplay_Draw(GlobalContext* globalCtx) { TransitionUnk_Draw(&sTrnsnUnk, &sp88); POLY_OPA_DISP = sp88; - goto Gameplay_Draw_DrawOverlayElements; + goto Play_Draw_DrawOverlayElements; } else { - PreRender_SetValues(&globalCtx->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, + PreRender_SetValues(&play->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer); if (R_PAUSE_MENU_MODE == 2) { MsgEvent_SendNullTask(); - PreRender_Calc(&globalCtx->pauseBgPreRender); + PreRender_Calc(&play->pauseBgPreRender); R_PAUSE_MENU_MODE = 3; } else if (R_PAUSE_MENU_MODE >= 4) { R_PAUSE_MENU_MODE = 0; @@ -1413,50 +1413,50 @@ void Gameplay_Draw(GlobalContext* globalCtx) { if (R_PAUSE_MENU_MODE == 3) { Gfx* sp84 = POLY_OPA_DISP; - //func_800C24BC(&globalCtx->pauseBgPreRender, &sp84); + //func_800C24BC(&play->pauseBgPreRender, &sp84); POLY_OPA_DISP = sp84; - //goto Gameplay_Draw_DrawOverlayElements; + //goto Play_Draw_DrawOverlayElements; } //else { s32 sp80; if ((HREG(80) != 10) || (HREG(83) != 0)) { - if (globalCtx->skyboxId && (globalCtx->skyboxId != SKYBOX_UNSET_1D) && - !globalCtx->envCtx.skyboxDisabled) { - if ((globalCtx->skyboxId == SKYBOX_NORMAL_SKY) || - (globalCtx->skyboxId == SKYBOX_CUTSCENE_MAP)) { - Environment_UpdateSkybox(globalCtx, globalCtx->skyboxId, &globalCtx->envCtx, &globalCtx->skyboxCtx); - - SkyboxDraw_Draw(&globalCtx->skyboxCtx, gfxCtx, globalCtx->skyboxId, - globalCtx->envCtx.skyboxBlend, globalCtx->view.eye.x, globalCtx->view.eye.y, - globalCtx->view.eye.z); - } else if (globalCtx->skyboxCtx.unk_140 == 0) { - SkyboxDraw_Draw(&globalCtx->skyboxCtx, gfxCtx, globalCtx->skyboxId, 0, - globalCtx->view.eye.x, globalCtx->view.eye.y, globalCtx->view.eye.z); + if (play->skyboxId && (play->skyboxId != SKYBOX_UNSET_1D) && + !play->envCtx.skyboxDisabled) { + if ((play->skyboxId == SKYBOX_NORMAL_SKY) || + (play->skyboxId == SKYBOX_CUTSCENE_MAP)) { + Environment_UpdateSkybox(play, play->skyboxId, &play->envCtx, &play->skyboxCtx); + + SkyboxDraw_Draw(&play->skyboxCtx, gfxCtx, play->skyboxId, + play->envCtx.skyboxBlend, play->view.eye.x, play->view.eye.y, + play->view.eye.z); + } else if (play->skyboxCtx.unk_140 == 0) { + SkyboxDraw_Draw(&play->skyboxCtx, gfxCtx, play->skyboxId, 0, + play->view.eye.x, play->view.eye.y, play->view.eye.z); } } } if ((HREG(80) != 10) || (HREG(90) & 2)) { - if (!globalCtx->envCtx.sunMoonDisabled) { - Environment_DrawSunAndMoon(globalCtx); + if (!play->envCtx.sunMoonDisabled) { + Environment_DrawSunAndMoon(play); } } if ((HREG(80) != 10) || (HREG(90) & 1)) { - Environment_DrawSkyboxFilters(globalCtx); + Environment_DrawSkyboxFilters(play); } if ((HREG(80) != 10) || (HREG(90) & 4)) { - Environment_UpdateLightningStrike(globalCtx); - Environment_DrawLightning(globalCtx, 0); + Environment_UpdateLightningStrike(play); + Environment_DrawLightning(play, 0); } if ((HREG(80) != 10) || (HREG(90) & 8)) { - sp228 = LightContext_NewLights(&globalCtx->lightCtx, gfxCtx); - Lights_BindAll(sp228, globalCtx->lightCtx.listHead, NULL); + sp228 = LightContext_NewLights(&play->lightCtx, gfxCtx); + Lights_BindAll(sp228, play->lightCtx.listHead, NULL); Lights_Draw(sp228, gfxCtx); } @@ -1467,48 +1467,48 @@ void Gameplay_Draw(GlobalContext* globalCtx) { } else { sp80 = HREG(84); } - Scene_Draw(globalCtx); - Room_Draw(globalCtx, &globalCtx->roomCtx.curRoom, sp80 & 3); - Room_Draw(globalCtx, &globalCtx->roomCtx.prevRoom, sp80 & 3); + Scene_Draw(play); + Room_Draw(play, &play->roomCtx.curRoom, sp80 & 3); + Room_Draw(play, &play->roomCtx.prevRoom, sp80 & 3); } } if ((HREG(80) != 10) || (HREG(83) != 0)) { - if ((globalCtx->skyboxCtx.unk_140 != 0) && - (GET_ACTIVE_CAM(globalCtx)->setting != CAM_SET_PREREND_FIXED)) { + if ((play->skyboxCtx.unk_140 != 0) && + (GET_ACTIVE_CAM(play)->setting != CAM_SET_PREREND_FIXED)) { Vec3f sp74; - Camera_GetSkyboxOffset(&sp74, GET_ACTIVE_CAM(globalCtx)); - SkyboxDraw_Draw(&globalCtx->skyboxCtx, gfxCtx, globalCtx->skyboxId, 0, - globalCtx->view.eye.x + sp74.x, globalCtx->view.eye.y + sp74.y, - globalCtx->view.eye.z + sp74.z); + Camera_GetSkyboxOffset(&sp74, GET_ACTIVE_CAM(play)); + SkyboxDraw_Draw(&play->skyboxCtx, gfxCtx, play->skyboxId, 0, + play->view.eye.x + sp74.x, play->view.eye.y + sp74.y, + play->view.eye.z + sp74.z); } } - if (globalCtx->envCtx.unk_EE[1] != 0) { - Environment_DrawRain(globalCtx, &globalCtx->view, gfxCtx); + if (play->envCtx.unk_EE[1] != 0) { + Environment_DrawRain(play, &play->view, gfxCtx); } if ((HREG(80) != 10) || (HREG(84) != 0)) { - Environment_FillScreen(gfxCtx, 0, 0, 0, globalCtx->unk_11E18, FILL_SCREEN_OPA); + Environment_FillScreen(gfxCtx, 0, 0, 0, play->unk_11E18, FILL_SCREEN_OPA); } - if ((globalCtx->pauseCtx.state != 0) && (HREG(80) != 10) || (HREG(89) != 0)) { - Gameplay_DrawOverlayElements(globalCtx); + if ((play->pauseCtx.state != 0) && (HREG(80) != 10) || (HREG(89) != 0)) { + Play_DrawOverlayElements(play); } if ((HREG(80) != 10) || (HREG(85) != 0)) { - func_800315AC(globalCtx, &globalCtx->actorCtx); + func_800315AC(play, &play->actorCtx); } if ((HREG(80) != 10) || (HREG(86) != 0)) { - if (!globalCtx->envCtx.sunMoonDisabled) { - sp21C.x = globalCtx->view.eye.x + globalCtx->envCtx.sunPos.x; - sp21C.y = globalCtx->view.eye.y + globalCtx->envCtx.sunPos.y; - sp21C.z = globalCtx->view.eye.z + globalCtx->envCtx.sunPos.z; - Environment_DrawSunLensFlare(globalCtx, &globalCtx->envCtx, &globalCtx->view, gfxCtx, sp21C, 0); + if (!play->envCtx.sunMoonDisabled) { + sp21C.x = play->view.eye.x + play->envCtx.sunPos.x; + sp21C.y = play->view.eye.y + play->envCtx.sunPos.y; + sp21C.z = play->view.eye.z + play->envCtx.sunPos.z; + Environment_DrawSunLensFlare(play, &play->envCtx, &play->view, gfxCtx, sp21C, 0); } - Environment_DrawCustomLensFlare(globalCtx); + Environment_DrawCustomLensFlare(play); } if ((HREG(80) != 10) || (HREG(87) != 0)) { @@ -1517,11 +1517,11 @@ void Gameplay_Draw(GlobalContext* globalCtx) { FILL_SCREEN_OPA | FILL_SCREEN_XLU); } - switch (globalCtx->envCtx.fillScreen) { + switch (play->envCtx.fillScreen) { case 1: Environment_FillScreen( - gfxCtx, globalCtx->envCtx.screenFillColor[0], globalCtx->envCtx.screenFillColor[1], - globalCtx->envCtx.screenFillColor[2], globalCtx->envCtx.screenFillColor[3], + gfxCtx, play->envCtx.screenFillColor[0], play->envCtx.screenFillColor[1], + play->envCtx.screenFillColor[2], play->envCtx.screenFillColor[3], FILL_SCREEN_OPA | FILL_SCREEN_XLU); break; default: @@ -1530,52 +1530,52 @@ void Gameplay_Draw(GlobalContext* globalCtx) { } if ((HREG(80) != 10) || (HREG(88) != 0)) { - if (globalCtx->envCtx.sandstormState != 0) { - Environment_DrawSandstorm(globalCtx, globalCtx->envCtx.sandstormState); + if (play->envCtx.sandstormState != 0) { + Environment_DrawSandstorm(play, play->envCtx.sandstormState); } } if ((HREG(80) != 10) || (HREG(93) != 0)) { - DebugDisplay_DrawObjects(globalCtx); + DebugDisplay_DrawObjects(play); } if ((R_PAUSE_MENU_MODE == 1) || (gTrnsnUnkState == 1)) { Gfx* sp70 = OVERLAY_DISP; - globalCtx->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; - globalCtx->pauseBgPreRender.fbufSave = (u16*)gZBuffer; - func_800C1F20(&globalCtx->pauseBgPreRender, &sp70); + play->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; + play->pauseBgPreRender.fbufSave = (u16*)gZBuffer; + func_800C1F20(&play->pauseBgPreRender, &sp70); if (R_PAUSE_MENU_MODE == 1) { - globalCtx->pauseBgPreRender.cvgSave = (u8*)gfxCtx->curFrameBuffer; - func_800C20B4(&globalCtx->pauseBgPreRender, &sp70); + play->pauseBgPreRender.cvgSave = (u8*)gfxCtx->curFrameBuffer; + func_800C20B4(&play->pauseBgPreRender, &sp70); R_PAUSE_MENU_MODE = 2; } else { gTrnsnUnkState = 2; } OVERLAY_DISP = sp70; - globalCtx->unk_121C7 = 2; + play->unk_121C7 = 2; SREG(33) |= 1; } else if (R_PAUSE_MENU_MODE != 3) { - Gameplay_Draw_DrawOverlayElements: + Play_Draw_DrawOverlayElements: if ((HREG(80) != 10) || (HREG(89) != 0)) { - Gameplay_DrawOverlayElements(globalCtx); + Play_DrawOverlayElements(play); } } } } } - if (globalCtx->view.unk_124 != 0) { - Camera_Update(GET_ACTIVE_CAM(globalCtx)); - func_800AB944(&globalCtx->view); - globalCtx->view.unk_124 = 0; - if (globalCtx->skyboxId && (globalCtx->skyboxId != SKYBOX_UNSET_1D) && !globalCtx->envCtx.skyboxDisabled) { - SkyboxDraw_UpdateMatrix(&globalCtx->skyboxCtx, globalCtx->view.eye.x, globalCtx->view.eye.y, - globalCtx->view.eye.z); + if (play->view.unk_124 != 0) { + Camera_Update(GET_ACTIVE_CAM(play)); + func_800AB944(&play->view); + play->view.unk_124 = 0; + if (play->skyboxId && (play->skyboxId != SKYBOX_UNSET_1D) && !play->envCtx.skyboxDisabled) { + SkyboxDraw_UpdateMatrix(&play->skyboxCtx, play->view.eye.x, play->view.eye.y, + play->view.eye.z); } } - Camera_Finish(GET_ACTIVE_CAM(globalCtx)); + Camera_Finish(GET_ACTIVE_CAM(play)); { Gfx* prevDisplayList = POLY_OPA_DISP; @@ -1589,7 +1589,7 @@ void Gameplay_Draw(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx); } -time_t Gameplay_GetRealTime() { +time_t Play_GetRealTime() { time_t t1, t2; struct tm* tms; time(&t1); @@ -1601,8 +1601,8 @@ time_t Gameplay_GetRealTime() { return t1 - t2; } -void Gameplay_Main(GameState* thisx) { - GlobalContext* globalCtx = (GlobalContext*)thisx; +void Play_Main(GameState* thisx) { + PlayState* play = (PlayState*)thisx; if (CVar_GetS32("gCheatEasyPauseBufferFrameAdvance", 0)) { CVar_SetS32("gCheatEasyPauseBufferFrameAdvance", CVar_GetS32("gCheatEasyPauseBufferFrameAdvance", 0) - 1); @@ -1611,7 +1611,7 @@ void Gameplay_Main(GameState* thisx) { CVar_SetS32("gPauseBufferBlockInputFrame", CVar_GetS32("gPauseBufferBlockInputFrame", 0) - 1); } - D_8012D1F8 = &globalCtx->state.input[0]; + D_8012D1F8 = &play->state.input[0]; DebugDisplay_Init(); @@ -1637,7 +1637,7 @@ void Gameplay_Main(GameState* thisx) { } if ((HREG(80) != 10) || (HREG(81) != 0)) { - Gameplay_Update(globalCtx); + Play_Update(play); } if (1 && HREG(63)) { @@ -1645,7 +1645,7 @@ void Gameplay_Main(GameState* thisx) { } FrameInterpolation_StartRecord(); - Gameplay_Draw(globalCtx); + Play_Draw(play); FrameInterpolation_StopRecord(); if (1 && HREG(63)) { @@ -1656,7 +1656,7 @@ void Gameplay_Main(GameState* thisx) { const int maxRealDaySeconds = 86400; const int maxInGameDayTicks = 65536; - int secs = (int)Gameplay_GetRealTime(); + int secs = (int)Play_GetRealTime(); float percent = (float)secs / (float)maxRealDaySeconds; int newIngameTime = maxInGameDayTicks * percent; @@ -1672,11 +1672,11 @@ u8 PlayerGrounded(Player* player) { } // original name: "Game_play_demo_mode_check" -s32 Gameplay_InCsMode(GlobalContext* globalCtx) { - return (globalCtx->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(globalCtx); +s32 Play_InCsMode(PlayState* play) { + return (play->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(play); } -f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) { +f32 func_800BFCB8(PlayState* play, MtxF* mf, Vec3f* vec) { CollisionPoly poly; f32 temp1; f32 temp2; @@ -1687,7 +1687,7 @@ f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) { f32 nz; s32 pad[5]; - floorY = BgCheck_AnyRaycastFloor1(&globalCtx->colCtx, &poly, vec); + floorY = BgCheck_AnyRaycastFloor1(&play->colCtx, &poly, vec); if (floorY > BGCHECK_Y_MIN) { nx = COLPOLY_GET_NORMAL(poly.normal.x); @@ -1742,66 +1742,66 @@ f32 func_800BFCB8(GlobalContext* globalCtx, MtxF* mf, Vec3f* vec) { return floorY; } -void* Gameplay_LoadFile(GlobalContext* globalCtx, RomFile* file) { +void* Play_LoadFile(PlayState* play, RomFile* file) { size_t size; void* allocp; size = file->vromEnd - file->vromStart; - allocp = GAMESTATE_ALLOC_MC(&globalCtx->state, size); + allocp = GAMESTATE_ALLOC_MC(&play->state, size); DmaMgr_SendRequest1(allocp, file->vromStart, size, __FILE__, __LINE__); return allocp; } -void Gameplay_InitEnvironment(GlobalContext* globalCtx, s16 skyboxId) { - Skybox_Init(&globalCtx->state, &globalCtx->skyboxCtx, skyboxId); - Environment_Init(globalCtx, &globalCtx->envCtx, 0); +void Play_InitEnvironment(PlayState* play, s16 skyboxId) { + Skybox_Init(&play->state, &play->skyboxCtx, skyboxId); + Environment_Init(play, &play->envCtx, 0); } -void Gameplay_InitScene(GlobalContext* globalCtx, s32 spawn) +void Play_InitScene(PlayState* play, s32 spawn) { - globalCtx->curSpawn = spawn; - globalCtx->linkActorEntry = NULL; - globalCtx->unk_11DFC = NULL; - globalCtx->setupEntranceList = NULL; - globalCtx->setupExitList = NULL; - globalCtx->cUpElfMsgs = NULL; - globalCtx->setupPathList = NULL; - globalCtx->numSetupActors = 0; - Object_InitBank(globalCtx, &globalCtx->objectCtx); - LightContext_Init(globalCtx, &globalCtx->lightCtx); - TransitionActor_InitContext(&globalCtx->state, &globalCtx->transiActorCtx); - func_80096FD4(globalCtx, &globalCtx->roomCtx.curRoom); + play->curSpawn = spawn; + play->linkActorEntry = NULL; + play->unk_11DFC = NULL; + play->setupEntranceList = NULL; + play->setupExitList = NULL; + play->cUpElfMsgs = NULL; + play->setupPathList = NULL; + play->numSetupActors = 0; + Object_InitBank(play, &play->objectCtx); + LightContext_Init(play, &play->lightCtx); + TransitionActor_InitContext(&play->state, &play->transiActorCtx); + func_80096FD4(play, &play->roomCtx.curRoom); YREG(15) = 0; gSaveContext.worldMapArea = 0; - Scene_ExecuteCommands(globalCtx, globalCtx->sceneSegment); - Gameplay_InitEnvironment(globalCtx, globalCtx->skyboxId); + Scene_ExecuteCommands(play, play->sceneSegment); + Play_InitEnvironment(play, play->skyboxId); } -void Gameplay_SpawnScene(GlobalContext* globalCtx, s32 sceneNum, s32 spawn) { +void Play_SpawnScene(PlayState* play, s32 sceneNum, s32 spawn) { - OTRGameplay_SpawnScene(globalCtx, sceneNum, spawn); + OTRPlay_SpawnScene(play, sceneNum, spawn); } -void func_800C016C(GlobalContext* globalCtx, Vec3f* src, Vec3f* dest) { +void func_800C016C(PlayState* play, Vec3f* src, Vec3f* dest) { f32 temp; - Matrix_Mult(&globalCtx->viewProjectionMtxF, MTXMODE_NEW); + Matrix_Mult(&play->viewProjectionMtxF, MTXMODE_NEW); Matrix_MultVec3f(src, dest); - temp = globalCtx->viewProjectionMtxF.ww + - (globalCtx->viewProjectionMtxF.wx * src->x + globalCtx->viewProjectionMtxF.wy * src->y + - globalCtx->viewProjectionMtxF.wz * src->z); + temp = play->viewProjectionMtxF.ww + + (play->viewProjectionMtxF.wx * src->x + play->viewProjectionMtxF.wy * src->y + + play->viewProjectionMtxF.wz * src->z); dest->x = 160.0f + ((dest->x / temp) * 160.0f); dest->y = 120.0f + ((dest->y / temp) * 120.0f); } -s16 Gameplay_CreateSubCamera(GlobalContext* globalCtx) { +s16 Play_CreateSubCamera(PlayState* play) { s16 i; for (i = SUBCAM_FIRST; i < NUM_CAMS; i++) { - if (globalCtx->cameraPtrs[i] == NULL) { + if (play->cameraPtrs[i] == NULL) { break; } } @@ -1815,37 +1815,37 @@ s16 Gameplay_CreateSubCamera(GlobalContext* globalCtx) { CYAN) " " VT_RST "\n", i); - globalCtx->cameraPtrs[i] = &globalCtx->subCameras[i - SUBCAM_FIRST]; - Camera_Init(globalCtx->cameraPtrs[i], &globalCtx->view, &globalCtx->colCtx, globalCtx); - globalCtx->cameraPtrs[i]->thisIdx = i; + play->cameraPtrs[i] = &play->subCameras[i - SUBCAM_FIRST]; + Camera_Init(play->cameraPtrs[i], &play->view, &play->colCtx, play); + play->cameraPtrs[i]->thisIdx = i; return i; } -s16 Gameplay_GetActiveCamId(GlobalContext* globalCtx) { - return globalCtx->activeCamera; +s16 Play_GetActiveCamId(PlayState* play) { + return play->activeCamera; } -s16 Gameplay_ChangeCameraStatus(GlobalContext* globalCtx, s16 camId, s16 status) { - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; +s16 Play_ChangeCameraStatus(PlayState* play, s16 camId, s16 status) { + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; if (status == CAM_STAT_ACTIVE) { - globalCtx->activeCamera = camIdx; + play->activeCamera = camIdx; } - return Camera_ChangeStatus(globalCtx->cameraPtrs[camIdx], status); + return Camera_ChangeStatus(play->cameraPtrs[camIdx], status); } -void Gameplay_ClearCamera(GlobalContext* globalCtx, s16 camId) { - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; +void Play_ClearCamera(PlayState* play, s16 camId) { + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; if (camIdx == MAIN_CAM) { osSyncPrintf(VT_COL(RED, WHITE) "camera control: error: never clear camera !!\n" VT_RST); } - if (globalCtx->cameraPtrs[camIdx] != NULL) { - Camera_ChangeStatus(globalCtx->cameraPtrs[camIdx], CAM_STAT_UNK100); - globalCtx->cameraPtrs[camIdx] = NULL; + if (play->cameraPtrs[camIdx] != NULL) { + Camera_ChangeStatus(play->cameraPtrs[camIdx], CAM_STAT_UNK100); + play->cameraPtrs[camIdx] = NULL; osSyncPrintf("camera control: " VT_BGCOL(CYAN) " " VT_COL(WHITE, BLUE) " clear sub camera [%d] " VT_BGCOL( CYAN) " " VT_RST "\n", camIdx); @@ -1854,28 +1854,28 @@ void Gameplay_ClearCamera(GlobalContext* globalCtx, s16 camId) { } } -void Gameplay_ClearAllSubCameras(GlobalContext* globalCtx) { +void Play_ClearAllSubCameras(PlayState* play) { s16 i; for (i = SUBCAM_FIRST; i < NUM_CAMS; i++) { - if (globalCtx->cameraPtrs[i] != NULL) { - Gameplay_ClearCamera(globalCtx, i); + if (play->cameraPtrs[i] != NULL) { + Play_ClearCamera(play, i); } } - globalCtx->activeCamera = MAIN_CAM; + play->activeCamera = MAIN_CAM; } -Camera* Gameplay_GetCamera(GlobalContext* globalCtx, s16 camId) { - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; +Camera* Play_GetCamera(PlayState* play, s16 camId) { + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; - return globalCtx->cameraPtrs[camIdx]; + return play->cameraPtrs[camIdx]; } -s32 Gameplay_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye) { +s32 Play_CameraSetAtEye(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye) { s32 ret = 0; - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; - Camera* camera = globalCtx->cameraPtrs[camIdx]; + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; + Camera* camera = play->cameraPtrs[camIdx]; Player* player; ret |= Camera_SetParam(camera, 1, at); @@ -1898,10 +1898,10 @@ s32 Gameplay_CameraSetAtEye(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3 return ret; } -s32 Gameplay_CameraSetAtEyeUp(GlobalContext* globalCtx, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up) { +s32 Play_CameraSetAtEyeUp(PlayState* play, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up) { s32 ret = 0; - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; - Camera* camera = globalCtx->cameraPtrs[camIdx]; + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; + Camera* camera = play->cameraPtrs[camIdx]; Player* player; ret |= Camera_SetParam(camera, 1, at); @@ -1926,66 +1926,66 @@ s32 Gameplay_CameraSetAtEyeUp(GlobalContext* globalCtx, s16 camId, Vec3f* at, Ve return ret; } -s32 Gameplay_CameraSetFov(GlobalContext* globalCtx, s16 camId, f32 fov) { - s32 ret = Camera_SetParam(globalCtx->cameraPtrs[camId], 0x20, &fov) & 1; +s32 Play_CameraSetFov(PlayState* play, s16 camId, f32 fov) { + s32 ret = Camera_SetParam(play->cameraPtrs[camId], 0x20, &fov) & 1; return ret; } -s32 Gameplay_SetCameraRoll(GlobalContext* globalCtx, s16 camId, s16 roll) { - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; - Camera* camera = globalCtx->cameraPtrs[camIdx]; +s32 Play_SetCameraRoll(PlayState* play, s16 camId, s16 roll) { + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; + Camera* camera = play->cameraPtrs[camIdx]; camera->roll = roll; return 1; } -void Gameplay_CopyCamera(GlobalContext* globalCtx, s16 camId1, s16 camId2) { - s16 camIdx2 = (camId2 == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId2; - s16 camIdx1 = (camId1 == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId1; +void Play_CopyCamera(PlayState* play, s16 camId1, s16 camId2) { + s16 camIdx2 = (camId2 == SUBCAM_ACTIVE) ? play->activeCamera : camId2; + s16 camIdx1 = (camId1 == SUBCAM_ACTIVE) ? play->activeCamera : camId1; - Camera_Copy(globalCtx->cameraPtrs[camIdx1], globalCtx->cameraPtrs[camIdx2]); + Camera_Copy(play->cameraPtrs[camIdx1], play->cameraPtrs[camIdx2]); } -s32 func_800C0808(GlobalContext* globalCtx, s16 camId, Player* player, s16 setting) { +s32 func_800C0808(PlayState* play, s16 camId, Player* player, s16 setting) { Camera* camera; - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; - camera = globalCtx->cameraPtrs[camIdx]; + camera = play->cameraPtrs[camIdx]; Camera_InitPlayerSettings(camera, player); return Camera_ChangeSetting(camera, setting); } -s32 Gameplay_CameraChangeSetting(GlobalContext* globalCtx, s16 camId, s16 setting) { - return Camera_ChangeSetting(Gameplay_GetCamera(globalCtx, camId), setting); +s32 Play_CameraChangeSetting(PlayState* play, s16 camId, s16 setting) { + return Camera_ChangeSetting(Play_GetCamera(play, camId), setting); } -void func_800C08AC(GlobalContext* globalCtx, s16 camId, s16 arg2) { - s16 camIdx = (camId == SUBCAM_ACTIVE) ? globalCtx->activeCamera : camId; +void func_800C08AC(PlayState* play, s16 camId, s16 arg2) { + s16 camIdx = (camId == SUBCAM_ACTIVE) ? play->activeCamera : camId; s16 i; - Gameplay_ClearCamera(globalCtx, camIdx); + Play_ClearCamera(play, camIdx); for (i = SUBCAM_FIRST; i < NUM_CAMS; i++) { - if (globalCtx->cameraPtrs[i] != NULL) { + if (play->cameraPtrs[i] != NULL) { osSyncPrintf( VT_COL(RED, WHITE) "camera control: error: return to main, other camera left. %d cleared!!\n" VT_RST, i); - Gameplay_ClearCamera(globalCtx, i); + Play_ClearCamera(play, i); } } if (arg2 <= 0) { - Gameplay_ChangeCameraStatus(globalCtx, MAIN_CAM, CAM_STAT_ACTIVE); - globalCtx->cameraPtrs[MAIN_CAM]->childCamIdx = globalCtx->cameraPtrs[MAIN_CAM]->parentCamIdx = SUBCAM_FREE; + Play_ChangeCameraStatus(play, MAIN_CAM, CAM_STAT_ACTIVE); + play->cameraPtrs[MAIN_CAM]->childCamIdx = play->cameraPtrs[MAIN_CAM]->parentCamIdx = SUBCAM_FREE; } else { - OnePointCutscene_Init(globalCtx, 1020, arg2, NULL, MAIN_CAM); + OnePointCutscene_Init(play, 1020, arg2, NULL, MAIN_CAM); } } -s16 Gameplay_CameraGetUID(GlobalContext* globalCtx, s16 camId) { - Camera* camera = globalCtx->cameraPtrs[camId]; +s16 Play_CameraGetUID(PlayState* play, s16 camId) { + Camera* camera = play->cameraPtrs[camId]; if (camera != NULL) { return camera->uid; @@ -1994,8 +1994,8 @@ s16 Gameplay_CameraGetUID(GlobalContext* globalCtx, s16 camId) { } } -s16 func_800C09D8(GlobalContext* globalCtx, s16 camId, s16 arg2) { - Camera* camera = globalCtx->cameraPtrs[camId]; +s16 func_800C09D8(PlayState* play, s16 camId, s16 arg2) { + Camera* camera = play->cameraPtrs[camId]; if (camera != NULL) { return 0; @@ -2008,16 +2008,16 @@ s16 func_800C09D8(GlobalContext* globalCtx, s16 camId, s16 arg2) { } } -void Gameplay_SaveSceneFlags(GlobalContext* globalCtx) { - SavedSceneFlags* savedSceneFlags = &gSaveContext.sceneFlags[globalCtx->sceneNum]; +void Play_SaveSceneFlags(PlayState* play) { + SavedSceneFlags* savedSceneFlags = &gSaveContext.sceneFlags[play->sceneNum]; - savedSceneFlags->chest = globalCtx->actorCtx.flags.chest; - savedSceneFlags->swch = globalCtx->actorCtx.flags.swch; - savedSceneFlags->clear = globalCtx->actorCtx.flags.clear; - savedSceneFlags->collect = globalCtx->actorCtx.flags.collect; + savedSceneFlags->chest = play->actorCtx.flags.chest; + savedSceneFlags->swch = play->actorCtx.flags.swch; + savedSceneFlags->clear = play->actorCtx.flags.clear; + savedSceneFlags->collect = play->actorCtx.flags.collect; } -void Gameplay_SetRespawnData(GlobalContext* globalCtx, s32 respawnMode, s16 entranceIndex, s32 roomIndex, +void Play_SetRespawnData(PlayState* play, s32 respawnMode, s16 entranceIndex, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw) { RespawnData* respawnData = &gSaveContext.respawn[respawnMode]; @@ -2026,65 +2026,65 @@ void Gameplay_SetRespawnData(GlobalContext* globalCtx, s32 respawnMode, s16 entr respawnData->pos = *pos; respawnData->yaw = yaw; respawnData->playerParams = playerParams; - respawnData->tempSwchFlags = globalCtx->actorCtx.flags.tempSwch; - respawnData->tempCollectFlags = globalCtx->actorCtx.flags.tempCollect; + respawnData->tempSwchFlags = play->actorCtx.flags.tempSwch; + respawnData->tempCollectFlags = play->actorCtx.flags.tempCollect; } -void Gameplay_SetupRespawnPoint(GlobalContext* globalCtx, s32 respawnMode, s32 playerParams) { - Player* player = GET_PLAYER(globalCtx); +void Play_SetupRespawnPoint(PlayState* play, s32 respawnMode, s32 playerParams) { + Player* player = GET_PLAYER(play); s32 entranceIndex; s8 roomIndex; - if ((globalCtx->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (globalCtx->sceneNum != SCENE_KAKUSIANA)) { - roomIndex = globalCtx->roomCtx.curRoom.num; + if ((play->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (play->sceneNum != SCENE_KAKUSIANA)) { + roomIndex = play->roomCtx.curRoom.num; entranceIndex = gSaveContext.entranceIndex; - Gameplay_SetRespawnData(globalCtx, respawnMode, entranceIndex, roomIndex, playerParams, + Play_SetRespawnData(play, respawnMode, entranceIndex, roomIndex, playerParams, &player->actor.world.pos, player->actor.shape.rot.y); } } -void Gameplay_TriggerVoidOut(GlobalContext* globalCtx) { - gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags = globalCtx->actorCtx.flags.tempSwch; - gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.tempCollect; +void Play_TriggerVoidOut(PlayState* play) { + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags = play->actorCtx.flags.tempSwch; + gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = play->actorCtx.flags.tempCollect; gSaveContext.respawnFlag = 1; - globalCtx->sceneLoadFlag = 0x14; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex; - globalCtx->fadeTransition = 2; + play->sceneLoadFlag = 0x14; + play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex; + play->fadeTransition = 2; } -void Gameplay_LoadToLastEntrance(GlobalContext* globalCtx) { +void Play_LoadToLastEntrance(PlayState* play) { gSaveContext.respawnFlag = -1; - globalCtx->sceneLoadFlag = 0x14; + play->sceneLoadFlag = 0x14; - if ((globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO) || (globalCtx->sceneNum == SCENE_GANON_DEMO)) { - globalCtx->nextEntranceIndex = 0x043F; - Item_Give(globalCtx, ITEM_SWORD_MASTER); + if ((play->sceneNum == SCENE_GANON_SONOGO) || (play->sceneNum == SCENE_GANON_FINAL) || + (play->sceneNum == SCENE_GANONTIKA_SONOGO) || (play->sceneNum == SCENE_GANON_DEMO)) { + play->nextEntranceIndex = 0x043F; + Item_Give(play, ITEM_SWORD_MASTER); } else if ((gSaveContext.entranceIndex == 0x028A) || (gSaveContext.entranceIndex == 0x028E) || (gSaveContext.entranceIndex == 0x0292) || (gSaveContext.entranceIndex == 0x0476)) { - globalCtx->nextEntranceIndex = 0x01F9; + play->nextEntranceIndex = 0x01F9; } else { - globalCtx->nextEntranceIndex = gSaveContext.entranceIndex; + play->nextEntranceIndex = gSaveContext.entranceIndex; } - globalCtx->fadeTransition = 2; + play->fadeTransition = 2; } -void Gameplay_TriggerRespawn(GlobalContext* globalCtx) { - Gameplay_SetupRespawnPoint(globalCtx, RESPAWN_MODE_DOWN, 0xDFF); - Gameplay_LoadToLastEntrance(globalCtx); +void Play_TriggerRespawn(PlayState* play) { + Play_SetupRespawnPoint(play, RESPAWN_MODE_DOWN, 0xDFF); + Play_LoadToLastEntrance(play); } -s32 func_800C0CB8(GlobalContext* globalCtx) { - return (globalCtx->roomCtx.curRoom.meshHeader->base.type != 1) && (YREG(15) != 0x20) && (YREG(15) != 0x30) && - (YREG(15) != 0x40) && (globalCtx->sceneNum != SCENE_HAIRAL_NIWA); +s32 func_800C0CB8(PlayState* play) { + return (play->roomCtx.curRoom.meshHeader->base.type != 1) && (YREG(15) != 0x20) && (YREG(15) != 0x30) && + (YREG(15) != 0x40) && (play->sceneNum != SCENE_HAIRAL_NIWA); } -s32 FrameAdvance_IsEnabled(GlobalContext* globalCtx) { - return !!globalCtx->frameAdvCtx.enabled; +s32 FrameAdvance_IsEnabled(PlayState* play) { + return !!play->frameAdvCtx.enabled; } -s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw) { +s32 func_800C0D34(PlayState* play, Actor* actor, s16* yaw) { TransitionActorEntry* transitionActor; s32 frontRoom; @@ -2092,7 +2092,7 @@ s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw) { return 0; } - transitionActor = &globalCtx->transiActorCtx.list[(u16)actor->params >> 10]; + transitionActor = &play->transiActorCtx.list[(u16)actor->params >> 10]; frontRoom = transitionActor->sides[0].room; if (frontRoom == transitionActor->sides[1].room) { @@ -2108,7 +2108,7 @@ s32 func_800C0D34(GlobalContext* globalCtx, Actor* actor, s16* yaw) { return 1; } -s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* pos) { +s32 func_800C0DB4(PlayState* play, Vec3f* pos) { WaterBox* waterBox; CollisionPoly* poly; Vec3f waterSurfacePos; @@ -2116,27 +2116,27 @@ s32 func_800C0DB4(GlobalContext* globalCtx, Vec3f* pos) { waterSurfacePos = *pos; - if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, + if (WaterBox_GetSurface1(play, &play->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y, &waterBox) == true && pos->y < waterSurfacePos.y && - BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN) { + BgCheck_EntityRaycastFloor3(&play->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN) { return true; } else { return false; } } -void Gameplay_PerformSave(GlobalContext* globalCtx) { - if (globalCtx != NULL && gSaveContext.fileNum != 0xFF) { - Gameplay_SaveSceneFlags(globalCtx); - gSaveContext.savedSceneNum = globalCtx->sceneNum; +void Play_PerformSave(PlayState* play) { + if (play != NULL && gSaveContext.fileNum != 0xFF) { + Play_SaveSceneFlags(play); + gSaveContext.savedSceneNum = play->sceneNum; if (gSaveContext.temporaryWeapon) { gSaveContext.equips.buttonItems[0] = ITEM_NONE; - GET_PLAYER(globalCtx)->currentSwordItem = ITEM_NONE; + GET_PLAYER(play)->currentSwordItem = ITEM_NONE; Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_NONE); Save_SaveFile(); gSaveContext.equips.buttonItems[0] = ITEM_SWORD_KOKIRI; - GET_PLAYER(globalCtx)->currentSwordItem = ITEM_SWORD_KOKIRI; + GET_PLAYER(play)->currentSwordItem = ITEM_SWORD_KOKIRI; Inventory_ChangeEquipment(EQUIP_SWORD, PLAYER_SWORD_KOKIRI); } else { Save_SaveFile(); diff --git a/soh/src/code/z_player_call.c b/soh/src/code/z_player_call.c index 3d9ff0c98..901280787 100644 --- a/soh/src/code/z_player_call.c +++ b/soh/src/code/z_player_call.c @@ -2,20 +2,20 @@ #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_2 | ACTOR_FLAG_4 | ACTOR_FLAG_5 | ACTOR_FLAG_25 | ACTOR_FLAG_26) -void (*sPlayerCallInitFunc)(Actor* thisx, GlobalContext* globalCtx); -void (*sPlayerCallDestroyFunc)(Actor* thisx, GlobalContext* globalCtx); -void (*sPlayerCallUpdateFunc)(Actor* thisx, GlobalContext* globalCtx); -void (*sPlayerCallDrawFunc)(Actor* thisx, GlobalContext* globalCtx); +void (*sPlayerCallInitFunc)(Actor* thisx, PlayState* play); +void (*sPlayerCallDestroyFunc)(Actor* thisx, PlayState* play); +void (*sPlayerCallUpdateFunc)(Actor* thisx, PlayState* play); +void (*sPlayerCallDrawFunc)(Actor* thisx, PlayState* play); -void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx); -void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx); -void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx); -void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx); +void PlayerCall_Init(Actor* thisx, PlayState* play); +void PlayerCall_Destroy(Actor* thisx, PlayState* play); +void PlayerCall_Update(Actor* thisx, PlayState* play); +void PlayerCall_Draw(Actor* thisx, PlayState* play); -void Player_Init(Actor* thisx, GlobalContext* globalCtx); -void Player_Destroy(Actor* thisx, GlobalContext* globalCtx); -void Player_Update(Actor* thisx, GlobalContext* globalCtx); -void Player_Draw(Actor* thisx, GlobalContext* globalCtx); +void Player_Init(Actor* thisx, PlayState* play); +void Player_Destroy(Actor* thisx, PlayState* play); +void Player_Update(Actor* thisx, PlayState* play); +void Player_Draw(Actor* thisx, PlayState* play); const ActorInit Player_InitVars = { ACTOR_PLAYER, @@ -37,23 +37,23 @@ void PlayerCall_InitFuncPtrs(void) { sPlayerCallDrawFunc = KaleidoManager_GetRamAddr(Player_Draw); } -void PlayerCall_Init(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Init(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); PlayerCall_InitFuncPtrs(); - sPlayerCallInitFunc(thisx, globalCtx); + sPlayerCallInitFunc(thisx, play); } -void PlayerCall_Destroy(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Destroy(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); - sPlayerCallDestroyFunc(thisx, globalCtx); + sPlayerCallDestroyFunc(thisx, play); } -void PlayerCall_Update(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Update(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); - sPlayerCallUpdateFunc(thisx, globalCtx); + sPlayerCallUpdateFunc(thisx, play); } -void PlayerCall_Draw(Actor* thisx, GlobalContext* globalCtx) { +void PlayerCall_Draw(Actor* thisx, PlayState* play) { KaleidoScopeCall_LoadPlayer(); - sPlayerCallDrawFunc(thisx, globalCtx); + sPlayerCallDrawFunc(thisx, play); } diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index e187707c4..29cdb05ca 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -285,7 +285,7 @@ Vec3f sGetItemRefPos; s32 D_80160014; s32 D_80160018; -void Player_SetBootData(GlobalContext* globalCtx, Player* this) { +void Player_SetBootData(PlayState* play, Player* this) { s32 currentBoots; s16* bootRegs; @@ -324,21 +324,21 @@ void Player_SetBootData(GlobalContext* globalCtx, Player* this) { IREG(69) = bootRegs[15]; MREG(95) = bootRegs[16]; - if (globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_2) { + if (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_2) { REG(45) = 500; } } -s32 Player_InBlockingCsMode(GlobalContext* globalCtx, Player* this) { - return (this->stateFlags1 & 0x20000080) || (this->csMode != 0) || (globalCtx->sceneLoadFlag == 0x14) || +s32 Player_InBlockingCsMode(PlayState* play, Player* this) { + return (this->stateFlags1 & 0x20000080) || (this->csMode != 0) || (play->sceneLoadFlag == 0x14) || (this->stateFlags1 & 1) || (this->stateFlags3 & 0x80) || ((gSaveContext.unk_13F0 != 0) && (Player_ActionToMagicSpell(this, this->itemActionParam) >= 0)); } -s32 Player_InCsMode(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +s32 Player_InCsMode(PlayState* play) { + Player* this = GET_PLAYER(play); - return Player_InBlockingCsMode(globalCtx, this) || (this->unk_6AD == 4); + return Player_InBlockingCsMode(play, this) || (this->unk_6AD == 4); } s32 func_8008E9C4(Player* this) { @@ -413,19 +413,19 @@ void func_8008EC70(Player* this) { this->unk_6AD = 0; } -void Player_SetEquipmentData(GlobalContext* globalCtx, Player* this) { +void Player_SetEquipmentData(PlayState* play, Player* this) { if (this->csMode != 0x56) { this->currentShield = CUR_EQUIP_VALUE(EQUIP_SHIELD); this->currentTunic = CUR_EQUIP_VALUE(EQUIP_TUNIC) - 1; this->currentBoots = CUR_EQUIP_VALUE(EQUIP_BOOTS) - 1; this->currentSwordItem = B_BTN_ITEM; Player_SetModelGroup(this, Player_ActionToModelGroup(this, this->heldItemActionParam)); - Player_SetBootData(globalCtx, this); + Player_SetBootData(play, this); } } -void Player_UpdateBottleHeld(GlobalContext* globalCtx, Player* this, s32 item, s32 actionParam) { - Inventory_UpdateBottleItem(globalCtx, item, this->heldItemButton); +void Player_UpdateBottleHeld(PlayState* play, Player* this, s32 item, s32 actionParam) { + Inventory_UpdateBottleItem(play, item, this->heldItemButton); if (item != ITEM_BOTTLE) { this->heldItemId = item; @@ -451,30 +451,30 @@ void func_8008EE08(Player* this) { func_8008EDF0(this); } -void func_8008EEAC(GlobalContext* globalCtx, Actor* actor) { - Player* this = GET_PLAYER(globalCtx); +void func_8008EEAC(PlayState* play, Actor* actor) { + Player* this = GET_PLAYER(play); func_8008EE08(this); this->unk_664 = actor; this->unk_684 = actor; this->stateFlags1 |= 0x10000; - Camera_SetParam(Gameplay_GetCamera(globalCtx, 0), 8, actor); - Camera_ChangeMode(Gameplay_GetCamera(globalCtx, 0), 2); + Camera_SetParam(Play_GetCamera(play, 0), 8, actor); + Camera_ChangeMode(Play_GetCamera(play, 0), 2); } -s32 func_8008EF30(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +s32 func_8008EF30(PlayState* play) { + Player* this = GET_PLAYER(play); return (this->stateFlags1 & 0x800000); } -s32 func_8008EF44(GlobalContext* globalCtx, s32 ammo) { - globalCtx->shootingGalleryStatus = ammo + 1; +s32 func_8008EF44(PlayState* play, s32 ammo) { + play->shootingGalleryStatus = ammo + 1; return 1; } -s32 Player_IsBurningStickInRange(GlobalContext* globalCtx, Vec3f* pos, f32 xzRange, f32 yRange) { - Player* this = GET_PLAYER(globalCtx); +s32 Player_IsBurningStickInRange(PlayState* play, Vec3f* pos, f32 xzRange, f32 yRange) { + Player* this = GET_PLAYER(play); Vec3f diff; s32 pad; @@ -498,28 +498,28 @@ s32 Player_GetStrength(void) { } } -u8 Player_GetMask(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +u8 Player_GetMask(PlayState* play) { + Player* this = GET_PLAYER(play); return this->currentMask; } -Player* Player_UnsetMask(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +Player* Player_UnsetMask(PlayState* play) { + Player* this = GET_PLAYER(play); this->currentMask = PLAYER_MASK_NONE; return this; } -s32 Player_HasMirrorShieldEquipped(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +s32 Player_HasMirrorShieldEquipped(PlayState* play) { + Player* this = GET_PLAYER(play); return (this->currentShield == PLAYER_SHIELD_MIRROR); } -s32 Player_HasMirrorShieldSetToDraw(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +s32 Player_HasMirrorShieldSetToDraw(PlayState* play) { + Player* this = GET_PLAYER(play); return (this->rightHandType == 10) && (this->currentShield == PLAYER_SHIELD_MIRROR); } @@ -612,12 +612,12 @@ return_neg: return -1; } -s32 func_8008F2F8(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +s32 func_8008F2F8(PlayState* play) { + Player* this = GET_PLAYER(play); TextTriggerEntry* triggerEntry; s32 var; - if (globalCtx->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { // Room is hot + if (play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) { // Room is hot var = 0; } else if ((this->unk_840 > 80) && ((this->currentBoots == PLAYER_BOOTS_IRON) || (this->unk_840 >= 300))) { // Deep underwater @@ -629,14 +629,14 @@ s32 func_8008F2F8(GlobalContext* globalCtx) { } // Trigger general textboxes under certain conditions, like "It's so hot in here!" - if (!Player_InCsMode(globalCtx)) { + if (!Player_InCsMode(play)) { triggerEntry = &sTextTriggers[var]; if ((triggerEntry->flag != 0) && !(gSaveContext.textTriggerFlags & triggerEntry->flag) && (((var == 0) && (this->currentTunic != PLAYER_TUNIC_GORON && CVar_GetS32("gSuperTunic", 0) == 0)) || (((var == 1) || (var == 3)) && (this->currentBoots == PLAYER_BOOTS_IRON) && (this->currentTunic != PLAYER_TUNIC_ZORA && CVar_GetS32("gSuperTunic", 0) == 0)))) { - Message_StartTextbox(globalCtx, triggerEntry->textId, NULL); + Message_StartTextbox(play, triggerEntry->textId, NULL); gSaveContext.textTriggerFlags |= triggerEntry->flag; } } @@ -712,14 +712,14 @@ Gfx* sBootDListGroups[][2] = { { gLinkAdultLeftHoverBootDL, gLinkAdultRightHoverBootDL }, }; -void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, +void func_8008F470(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, s32 boots, s32 face, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* data) { Color_RGB8* color; s32 eyeIndex = (jointTable[22].x & 0xF) - 1; s32 mouthIndex = (jointTable[22].x >> 4) - 1; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (eyeIndex < 0) { eyeIndex = sEyeMouthIndexes[face][0]; @@ -775,7 +775,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, sDListsLodOffset = lod * 2; - SkelAnime_DrawFlexLod(globalCtx, skeleton, jointTable, dListCount, overrideLimbDraw, postLimbDraw, data, lod); + SkelAnime_DrawFlexLod(play, skeleton, jointTable, dListCount, overrideLimbDraw, postLimbDraw, data, lod); if ((overrideLimbDraw != func_800902F0) && (overrideLimbDraw != func_80090440) && (gSaveContext.gameMode != 3)) { if (LINK_IS_ADULT) { @@ -815,7 +815,7 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } Vec3f D_8012602C = { 0.0f, 0.0f, 0.0f }; @@ -832,7 +832,7 @@ f32 D_80126068[] = { 5.0f, 3.0f }; Vec3f D_80126070 = { 0.0f, -300.0f, 0.0f }; -void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, +void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, s32 thighLimbIndex, s32 shinLimbIndex, s32 footLimbIndex) { Vec3f spA4; Vec3f sp98; @@ -875,7 +875,7 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, footprintPos.y += 15.0f; - sp80 = BgCheck_EntityRaycastFloor4(&globalCtx->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74; + sp80 = BgCheck_EntityRaycastFloor4(&play->colCtx, &sp88, &sp84, &this->actor, &footprintPos) + sp74; if (sp98.y < sp80) { sp70 = sp98.x - spA4.x; @@ -915,17 +915,17 @@ void func_8008F87C(GlobalContext* globalCtx, Player* this, SkelAnime* skelAnime, skelAnime->jointTable[shinLimbIndex].z = skelAnime->jointTable[shinLimbIndex].z + temp1; skelAnime->jointTable[footLimbIndex].z = skelAnime->jointTable[footLimbIndex].z + temp2 - temp1; - temp3 = func_80041D4C(&globalCtx->colCtx, sp88, sp84); + temp3 = func_80041D4C(&play->colCtx, sp88, sp84); - if ((temp3 >= 2) && (temp3 < 4) && !SurfaceType_IsWallDamage(&globalCtx->colCtx, sp88, sp84)) { + if ((temp3 >= 2) && (temp3 < 4) && !SurfaceType_IsWallDamage(&play->colCtx, sp88, sp84)) { footprintPos.y = sp80; - EffectSsGFire_Spawn(globalCtx, &footprintPos); + EffectSsGFire_Spawn(play, &footprintPos); } } } } -s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 func_8008FCC8(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; if (limbIndex == PLAYER_LIMB_ROOT) { @@ -977,10 +977,10 @@ s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p Matrix_RotateZ(this->unk_6C0 * (M_PI / 0x8000), MTXMODE_APPLY); } } else if (limbIndex == PLAYER_LIMB_L_THIGH) { - func_8008F87C(globalCtx, this, &this->skelAnime, pos, rot, PLAYER_LIMB_L_THIGH, PLAYER_LIMB_L_SHIN, + func_8008F87C(play, this, &this->skelAnime, pos, rot, PLAYER_LIMB_L_THIGH, PLAYER_LIMB_L_SHIN, PLAYER_LIMB_L_FOOT); } else if (limbIndex == PLAYER_LIMB_R_THIGH) { - func_8008F87C(globalCtx, this, &this->skelAnime, pos, rot, PLAYER_LIMB_R_THIGH, PLAYER_LIMB_R_SHIN, + func_8008F87C(play, this, &this->skelAnime, pos, rot, PLAYER_LIMB_R_THIGH, PLAYER_LIMB_R_SHIN, PLAYER_LIMB_R_FOOT); return false; } else { @@ -991,10 +991,10 @@ s32 func_8008FCC8(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -s32 func_80090014(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 func_80090014(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; - if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, thisx)) { + if (!func_8008FCC8(play, limbIndex, dList, pos, rot, thisx)) { if (limbIndex == PLAYER_LIMB_L_HAND) { Gfx** dLists = this->leftHandDLists; @@ -1054,10 +1054,10 @@ s32 func_80090014(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { +s32 func_800902F0(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; - if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, thisx)) { + if (!func_8008FCC8(play, limbIndex, dList, pos, rot, thisx)) { if (this->unk_6AD != 2) { *dList = NULL; } else if (limbIndex == PLAYER_LIMB_L_FOREARM) { @@ -1079,19 +1079,19 @@ s32 func_800902F0(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p return false; } -s32 func_80090440(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { - if (!func_8008FCC8(globalCtx, limbIndex, dList, pos, rot, thisx)) { +s32 func_80090440(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { + if (!func_8008FCC8(play, limbIndex, dList, pos, rot, thisx)) { *dList = NULL; } return false; } -u8 func_80090480(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, +u8 func_80090480(PlayState* play, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, Vec3f* newBase) { if (weaponInfo->active == 0) { if (collider != NULL) { - Collider_ResetQuadAT(globalCtx, &collider->base); + Collider_ResetQuadAT(play, &collider->base); } Math_Vec3f_Copy(&weaponInfo->tip, newTip); Math_Vec3f_Copy(&weaponInfo->base, newBase); @@ -1101,13 +1101,13 @@ u8 func_80090480(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* w (weaponInfo->tip.z == newTip->z) && (weaponInfo->base.x == newBase->x) && (weaponInfo->base.y == newBase->y) && (weaponInfo->base.z == newBase->z)) { if (collider != NULL) { - Collider_ResetQuadAT(globalCtx, &collider->base); + Collider_ResetQuadAT(play, &collider->base); } return 0; } else { if (collider != NULL) { Collider_SetQuadVertices(collider, newBase, newTip, &weaponInfo->base, &weaponInfo->tip); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &collider->base); + CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); } Math_Vec3f_Copy(&weaponInfo->base, newBase); Math_Vec3f_Copy(&weaponInfo->tip, newTip); @@ -1116,7 +1116,7 @@ u8 func_80090480(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* w } } -void func_80090604(GlobalContext* globalCtx, Player* this, ColliderQuad* collider, Vec3f* quadSrc) { +void func_80090604(PlayState* play, Player* this, ColliderQuad* collider, Vec3f* quadSrc) { static u8 shieldColTypes[PLAYER_SHIELD_MAX] = { COLTYPE_METAL, COLTYPE_WOOD, @@ -1135,8 +1135,8 @@ void func_80090604(GlobalContext* globalCtx, Player* this, ColliderQuad* collide Matrix_MultVec3f(&quadSrc[3], &quadDest[3]); Collider_SetQuadVertices(collider, &quadDest[0], &quadDest[1], &quadDest[2], &quadDest[3]); - CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &collider->base); - CollisionCheck_SetAT(globalCtx, &globalCtx->colChkCtx, &collider->base); + CollisionCheck_SetAC(play, &play->colChkCtx, &collider->base); + CollisionCheck_SetAT(play, &play->colChkCtx, &collider->base); } } @@ -1150,29 +1150,29 @@ Vec3f D_801260A4[3] = { { 0.0f, -400.0f, 1000.0f }, }; -void func_800906D4(GlobalContext* globalCtx, Player* this, Vec3f* newTipPos) { +void func_800906D4(PlayState* play, Player* this, Vec3f* newTipPos) { Vec3f newBasePos[3]; Matrix_MultVec3f(&D_801260A4[0], &newBasePos[0]); Matrix_MultVec3f(&D_801260A4[1], &newBasePos[1]); Matrix_MultVec3f(&D_801260A4[2], &newBasePos[2]); - if (func_80090480(globalCtx, NULL, &this->swordInfo[0], &newTipPos[0], &newBasePos[0]) && + if (func_80090480(play, NULL, &this->swordInfo[0], &newTipPos[0], &newBasePos[0]) && !(this->stateFlags1 & 0x400000)) { EffectBlure_AddVertex(Effect_GetByIndex(this->swordEffectIndex), &this->swordInfo[0].tip, &this->swordInfo[0].base); } if ((this->swordState > 0) && ((this->swordAnimation < 0x18) || (this->stateFlags2 & 0x20000))) { - func_80090480(globalCtx, &this->swordQuads[0], &this->swordInfo[1], &newTipPos[1], &newBasePos[1]); - func_80090480(globalCtx, &this->swordQuads[1], &this->swordInfo[2], &newTipPos[2], &newBasePos[2]); + func_80090480(play, &this->swordQuads[0], &this->swordInfo[1], &newTipPos[1], &newBasePos[1]); + func_80090480(play, &this->swordQuads[1], &this->swordInfo[2], &newTipPos[2], &newBasePos[2]); } } -void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPos, s32 drawIdPlusOne) { +void Player_DrawGetItemImpl(PlayState* play, Player* this, Vec3f* refPos, s32 drawIdPlusOne) { f32 height = (this->exchangeItemId != EXCH_ITEM_NONE) ? 6.0f : 14.0f; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSegments[6] = VIRTUAL_TO_PHYSICAL(this->giObjectSegment); @@ -1181,27 +1181,27 @@ void Player_DrawGetItemImpl(GlobalContext* globalCtx, Player* this, Vec3f* refPo Matrix_Translate(refPos->x + (3.3f * Math_SinS(this->actor.shape.rot.y)), refPos->y + height, refPos->z + ((3.3f + (IREG(90) / 10.0f)) * Math_CosS(this->actor.shape.rot.y)), MTXMODE_NEW); - Matrix_RotateZYX(0, globalCtx->gameplayFrames * 1000, 0, MTXMODE_APPLY); + Matrix_RotateZYX(0, play->gameplayFrames * 1000, 0, MTXMODE_APPLY); Matrix_Scale(0.2f, 0.2f, 0.2f, MTXMODE_APPLY); if (!(this->getItemEntry.modIndex == MOD_RANDOMIZER && this->getItemEntry.getItemId == RG_ICE_TRAP)) { // RANDOTODO: Make this more flexible for easier toggling of individual item recolors in the future. if (this->getItemEntry.drawFunc != NULL && (CVar_GetS32("gRandoMatchKeyColors", 0) || this->getItemEntry.getItemId == RG_DOUBLE_DEFENSE)) { - this->getItemEntry.drawFunc(globalCtx, &this->getItemEntry); + this->getItemEntry.drawFunc(play, &this->getItemEntry); } else { - GetItem_Draw(globalCtx, drawIdPlusOne - 1); + GetItem_Draw(play, drawIdPlusOne - 1); } } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void Player_DrawGetItem(GlobalContext* globalCtx, Player* this) { +void Player_DrawGetItem(PlayState* play, Player* this) { //if (!this->giObjectLoading || !osRecvMesg(&this->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK)) // OTRTODO: Do something about osRecvMesg here... { this->giObjectLoading = false; - Player_DrawGetItemImpl(globalCtx, this, &sGetItemRefPos, ABS(this->unk_862)); + Player_DrawGetItemImpl(play, this, &sGetItemRefPos, ABS(this->unk_862)); } } @@ -1221,7 +1221,7 @@ void func_80090A28(Player* this, Vec3f* vecs) { Matrix_MultVec3f(&D_80126098, &vecs[2]); } -void Player_DrawHookshotReticle(GlobalContext* globalCtx, Player* this, f32 arg2) { +void Player_DrawHookshotReticle(PlayState* play, Player* this, f32 arg2) { static Vec3f D_801260C8 = { -500.0f, -100.0f, 0.0f }; CollisionPoly* sp9C; s32 bgId; @@ -1237,24 +1237,24 @@ void Player_DrawHookshotReticle(GlobalContext* globalCtx, Player* this, f32 arg2 D_801260C8.z = arg2; Matrix_MultVec3f(&D_801260C8, &sp80); - if (BgCheck_AnyLineTest3(&globalCtx->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &bgId)) { - OPEN_DISPS(globalCtx->state.gfxCtx); + if (BgCheck_AnyLineTest3(&play->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &bgId)) { + OPEN_DISPS(play->state.gfxCtx); WORLD_OVERLAY_DISP = Gfx_CallSetupDL(WORLD_OVERLAY_DISP, 0x07); - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp74, &sp68, &sp64); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sp74, &sp68, &sp64); sp60 = (sp64 < 200.0f) ? 0.08f : (sp64 / 200.0f) * 0.08f; Matrix_Translate(sp74.x, sp74.y, sp74.z, MTXMODE_NEW); Matrix_Scale(sp60, sp60, sp60, MTXMODE_APPLY); - gSPMatrix(WORLD_OVERLAY_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(WORLD_OVERLAY_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(WORLD_OVERLAY_DISP++, 0x06, globalCtx->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(WORLD_OVERLAY_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); gSPDisplayList(WORLD_OVERLAY_DISP++, gLinkAdultHookshotReticleDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } } @@ -1308,7 +1308,7 @@ Vec3f D_801261E0[] = { { 200.0f, 200.0f, 0.0f }, }; -void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void func_80090D20(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; if (*dList != NULL) { @@ -1324,14 +1324,14 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (this->itemActionParam == PLAYER_AP_STICK) { Vec3f sp124[3]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (this->actor.scale.y >= 0.0f) { D_80126080.x = this->unk_85C * 5000.0f; func_80090A28(this, sp124); if (this->swordState != 0) { EffectBlure_ChangeType(Effect_GetByIndex(this->swordEffectIndex), 7); // default sword type - func_800906D4(globalCtx, this, sp124); + func_800906D4(play, this, sp124); } else { Math_Vec3f_Copy(&this->swordInfo[0].tip, &sp124[0]); } @@ -1341,11 +1341,11 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Matrix_RotateZYX(-0x8000, 0, 0x4000, MTXMODE_APPLY); Matrix_Scale(1.0f, this->unk_85C, 1.0f, MTXMODE_APPLY); - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gLinkChildLinkDekuStickDL); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else if ((this->actor.scale.y >= 0.0f) && (this->swordState != 0)) { Vec3f spE4[3]; @@ -1360,18 +1360,18 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } func_80090A28(this, spE4); - func_800906D4(globalCtx, this, spE4); + func_800906D4(play, this, spE4); } else if ((*dList != NULL) && (this->leftHandType == 7)) { Color_RGB8* bottleColor = &sBottleColors[Player_ActionToBottle(this, this->itemActionParam)]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetEnvColor(POLY_XLU_DISP++, bottleColor->r, bottleColor->g, bottleColor->b, 0); gSPDisplayList(POLY_XLU_DISP++, sBottleDLists[(gSaveContext.linkAge)]); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } if (this->actor.scale.y >= 0.0f) { @@ -1407,7 +1407,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } else if ((this->rightHandType == 11) || (this->rightHandType == 12)) { BowStringData* stringData = &sBowStringData[gSaveContext.linkAge]; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); Matrix_Translate(stringData->pos.x, stringData->pos.y, stringData->pos.z, MTXMODE_APPLY); @@ -1438,16 +1438,16 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* Matrix_RotateZ(this->unk_858 * -0.2f, MTXMODE_APPLY); } - gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), + gSPMatrix(POLY_XLU_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, stringData->dList); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } else if ((this->actor.scale.y >= 0.0f) && (this->rightHandType == 10)) { Matrix_Get(&this->shieldMf); - func_80090604(globalCtx, this, &this->shieldQuad, D_80126154); + func_80090604(play, this, &this->shieldQuad, D_80126154); } if (this->actor.scale.y >= 0.0f) { @@ -1468,7 +1468,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (func_8002DD78(this) != 0) { Matrix_Translate(500.0f, 300.0f, 0.0f, MTXMODE_APPLY); Player_DrawHookshotReticle( - globalCtx, this, (this->heldItemActionParam == PLAYER_AP_HOOKSHOT) ? 38600.0f : 77600.0f); + play, this, (this->heldItemActionParam == PLAYER_AP_HOOKSHOT) ? 38600.0f : 77600.0f); } } } @@ -1491,7 +1491,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* if (limbIndex == PLAYER_LIMB_SHEATH) { if ((this->rightHandType != 10) && (this->rightHandType != 0xFF)) { if (Player_IsChildWithHylianShield(this)) { - func_80090604(globalCtx, this, &this->shieldQuad, D_8012619C); + func_80090604(play, this, &this->shieldQuad, D_8012619C); } Matrix_TranslateRotateZYX(&D_801261CC, &D_801261D8); @@ -1507,7 +1507,7 @@ void func_80090D20(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* } } -u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { +u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { s16 linkObjectId = gLinkObjectIds[gSaveContext.linkAge]; size_t size; void* ptr; @@ -1525,7 +1525,7 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { gSegments[4] = VIRTUAL_TO_PHYSICAL(segment + 0x3800); gSegments[6] = VIRTUAL_TO_PHYSICAL(segment + 0x8800); - SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[gSaveContext.linkAge], &gPlayerAnim_link_normal_wait, 9, + SkelAnime_InitLink(play, skelAnime, gPlayerSkelHeaders[gSaveContext.linkAge], &gPlayerAnim_link_normal_wait, 9, ptr, ptr, PLAYER_LIMB_MAX); return size + 0x8800 + 0x90; @@ -1533,7 +1533,7 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { u8 D_801261F8[] = { 2, 2, 5 }; -s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* arg) { +s32 func_80091880(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* arg) { u8* ptr = arg; u8 modelGroup = D_801261F8[ptr[0] > 0 ? ptr[0] - 1 : 0]; s32 type; @@ -1583,7 +1583,7 @@ s32 func_80091880(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* p #include <overlays/actors/ovl_Demo_Effect/z_demo_effect.h> -void Pause_DrawTriforceSpot(GlobalContext* globalCtx, s32 showLightColumn) { +void Pause_DrawTriforceSpot(PlayState* play, s32 showLightColumn) { static DemoEffect triforce; static s16 rotation = 0; @@ -1592,12 +1592,12 @@ void Pause_DrawTriforceSpot(GlobalContext* globalCtx, s32 showLightColumn) { triforce.triforceSpot.lightColumnOpacity = showLightColumn ? 244 : 0; triforce.triforceSpot.rotation = rotation; - DemoEffect_DrawTriforceSpot(&triforce, globalCtx); + DemoEffect_DrawTriforceSpot(&triforce, play); rotation += 0x03E8; } -void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, +void func_80091A24(PlayState* play, void* seg04, void* seg06, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots, s32 width, s32 height, Vec3f* eye, Vec3f* at, f32 fovy, void* img1, void* img2) { static Vp viewport = { 128, 224, 511, 0, 128, 224, 511, 0 }; @@ -1608,10 +1608,10 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime Gfx* xluRef; Gfx* kalRef; u16 perspNorm; - Mtx* perspMtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx)); - Mtx* lookAtMtx = Graph_Alloc(globalCtx->state.gfxCtx, sizeof(Mtx)); + Mtx* perspMtx = Graph_Alloc(play->state.gfxCtx, sizeof(Mtx)); + Mtx* lookAtMtx = Graph_Alloc(play->state.gfxCtx, sizeof(Mtx)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x00, NULL); @@ -1653,15 +1653,15 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime gSPSetLights1(POLY_OPA_DISP++, lights1); - func_80093C80(globalCtx); + func_80093C80(play); POLY_OPA_DISP = Gfx_SetFog2(POLY_OPA_DISP++, 0, 0, 0, 0, 997, 1000); - func_8002EABC(pos, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx); + func_8002EABC(pos, &play->view.eye, &lightDir, play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0x0C, gCullBackDList); - func_8008F470(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, + func_8008F470(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, func_80091880, NULL, &sp12C); if (CVar_GetS32("gPauseTriforce", 0)) { @@ -1673,15 +1673,15 @@ void func_80091A24(GlobalContext* globalCtx, void* seg04, void* seg06, SkelAnime Gfx* ohNo = POLY_XLU_DISP; POLY_XLU_DISP = POLY_OPA_DISP; - Pause_DrawTriforceSpot(globalCtx, 1); + Pause_DrawTriforceSpot(play, 1); POLY_OPA_DISP = POLY_XLU_DISP; POLY_XLU_DISP = ohNo; } - POLY_OPA_DISP = Gameplay_SetFog(globalCtx, POLY_OPA_DISP++); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP++); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } uintptr_t SelectedAnim = 0; // Current Animaiton on the menu @@ -1689,9 +1689,9 @@ s16 EquipedStance; // Link's current mode (Two handed, One handed...) s16 FrameCountSinceLastAnim = 0; // Time since last animation s16 MinFrameCount; // Frame to wait before checking if we need to change the animation -void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, +void func_8009214C(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, s32 tunic, s32 shield, s32 boots) { - Input* p1Input = &globalCtx->state.input[0]; + Input* p1Input = &play->state.input[0]; Vec3f eye = { 0.0f, 0.0f, -400.0f }; Vec3f at = { 0.0f, 0.0f, 0.0f }; Vec3s* destTable; @@ -1888,11 +1888,11 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, } if (skelAnime->animation != anim) { - LinkAnimation_Change(globalCtx, skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_LOOP, + LinkAnimation_Change(play, skelAnime, anim, 1.0f, 0.0f, Animation_GetLastFrame(anim), ANIMMODE_LOOP, -6.0f); } - LinkAnimation_Update(globalCtx, skelAnime); + LinkAnimation_Update(play, skelAnime); if (!LINK_IS_ADULT) { // Link is placed too far up by default when animating @@ -1924,7 +1924,7 @@ void func_8009214C(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, } - func_80091A24(globalCtx, segment + 0x3800, segment + 0x8800, skelAnime, pos, rot, scale, sword, tunic, shield, - boots, 64, 112, &eye, &at, 60.0f, globalCtx->state.gfxCtx->curFrameBuffer, - globalCtx->state.gfxCtx->curFrameBuffer + 0x1C00); + func_80091A24(play, segment + 0x3800, segment + 0x8800, skelAnime, pos, rot, scale, sword, tunic, shield, + boots, 64, 112, &eye, &at, 60.0f, play->state.gfxCtx->curFrameBuffer, + play->state.gfxCtx->curFrameBuffer + 0x1C00); } diff --git a/soh/src/code/z_quake.c b/soh/src/code/z_quake.c index 997d068c0..4cb9b7aa5 100644 --- a/soh/src/code/z_quake.c +++ b/soh/src/code/z_quake.c @@ -319,9 +319,9 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { s32 ret; u32 eq; Vec3f vec; - GlobalContext* globalCtx; + PlayState* play; - globalCtx = camera->globalCtx; + play = camera->play; vec.x = 0.0f; vec.y = 0.0f; vec.z = 0.0f; @@ -344,7 +344,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) { for (idx = 0; idx < ARRAY_COUNT(sQuakeRequest); idx++) { req = &sQuakeRequest[idx]; if (req->callbackIdx != 0) { - if (globalCtx->cameraPtrs[req->camPtrIdx] == NULL) { + if (play->cameraPtrs[req->camPtrIdx] == NULL) { osSyncPrintf(VT_COL(YELLOW, BLACK) "quake: stopped! 'coz camera [%d] killed!!\n" VT_RST, req->camPtrIdx); Quake_Remove(req); diff --git a/soh/src/code/z_rcp.c b/soh/src/code/z_rcp.c index c6a50cf94..fa7fd71ad 100644 --- a/soh/src/code/z_rcp.c +++ b/soh/src/code/z_rcp.c @@ -1007,12 +1007,12 @@ void func_80093C14(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx); } -void func_80093C80(GlobalContext* globalCtx) { - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; +void func_80093C80(PlayState* play) { + GraphicsContext* gfxCtx = play->state.gfxCtx; func_80093D18(gfxCtx); - if (globalCtx->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_3) { + if (play->roomCtx.curRoom.behaviorType1 == ROOM_BEHAVIOR_TYPE1_3) { OPEN_DISPS(gfxCtx); gDPSetColorDither(POLY_OPA_DISP++, G_CD_DISABLE); diff --git a/soh/src/code/z_room.c b/soh/src/code/z_room.c index 593406d69..e1a3ca1aa 100644 --- a/soh/src/code/z_room.c +++ b/soh/src/code/z_room.c @@ -1,9 +1,9 @@ #include "global.h" #include "vt.h" -void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags); -void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags); -void func_80096F6C(GlobalContext* globalCtx, Room* room, u32 flags); +void func_80095AB4(PlayState* play, Room* room, u32 flags); +void func_80095D04(PlayState* play, Room* room, u32 flags); +void func_80096F6C(PlayState* play, Room* room, u32 flags); Vec3f D_801270A0 = { 0.0f, 0.0f, 0.0f }; @@ -22,34 +22,34 @@ Gfx D_801270B0[] = { gsSPEndDisplayList(), }; -void (*sRoomDrawHandlers[])(GlobalContext* globalCtx, Room* room, u32 flags) = { +void (*sRoomDrawHandlers[])(PlayState* play, Room* room, u32 flags) = { func_80095AB4, func_80096F6C, func_80095D04, }; -void func_80095AA0(GlobalContext* globalCtx, Room* room, Input* arg2, UNK_TYPE arg3) { +void func_80095AA0(PlayState* play, Room* room, Input* arg2, UNK_TYPE arg3) { } // Room Draw Polygon Type 0 -void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags) { +void func_80095AB4(PlayState* play, Room* room, u32 flags) { s32 i; PolygonType0* polygon0; PolygonDlist* polygonDlist; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (flags & 1) { - func_800342EC(&D_801270A0, globalCtx); + func_800342EC(&D_801270A0, play); gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); - func_80093C80(globalCtx); + func_80093C80(play); gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); } if (flags & 2) { - func_8003435C(&D_801270A0, globalCtx); + func_8003435C(&D_801270A0, play); gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); } @@ -67,7 +67,7 @@ void func_80095AB4(GlobalContext* globalCtx, Room* room, u32 flags) { polygonDlist++; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #define SHAPE_SORT_MAX 64 @@ -80,7 +80,7 @@ typedef struct struct_80095D04 { } struct_80095D04; // size = 0x10 // Room Draw Polygon Type 2 -void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { +void func_80095D04(PlayState* play, Room* room, u32 flags) { PolygonType2* polygon2; PolygonDlist2* polygonDlist; struct_80095D04 spB8[SHAPE_SORT_MAX]; @@ -99,17 +99,17 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { PolygonDlist2* temp; f32 temp_f2; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (flags & 1) { - func_800342EC(&D_801270A0, globalCtx); + func_800342EC(&D_801270A0, play); //gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); - func_80093C80(globalCtx); + func_80093C80(play); gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); } if (flags & 2) { - func_8003435C(&D_801270A0, globalCtx); + func_8003435C(&D_801270A0, play); //gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); } @@ -124,11 +124,11 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { sp90.x = polygonDlist->pos.x; sp90.y = polygonDlist->pos.y; sp90.z = polygonDlist->pos.z; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &sp90, &sp84, &sp80); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &sp90, &sp84, &sp80); if (-(f32)polygonDlist->unk_06 < sp84.z) { temp_f2 = sp84.z - polygonDlist->unk_06; - if (temp_f2 < globalCtx->lightCtx.fogFar) { + if (temp_f2 < play->lightCtx.fogFar) { phi_v0 = spB4; spA4->unk_00 = polygonDlist; spA4->unk_04 = temp_f2; @@ -214,7 +214,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { iREG(88) = sp9C - 1; - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } #define JPEG_MARKER 0xFFD8FFE0 @@ -332,7 +332,7 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h } // Room Draw Polygon Type 1 - Single Format -void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { +void func_80096680(PlayState* play, Room* room, u32 flags) { Camera* camera; Gfx* spA8; PolygonType1* polygon1; @@ -342,9 +342,9 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { u32 sp94; u32 sp90; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - camera = GET_ACTIVE_CAM(globalCtx); + camera = GET_ACTIVE_CAM(play); sp9C = (camera->setting == CAM_SET_PREREND_FIXED); polygon1 = &room->meshHeader->polygon1; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); @@ -356,7 +356,7 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); if (sp94) { - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, polygonDlist->opa); } @@ -383,15 +383,15 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { if (sp90) { gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, polygonDlist->xlu); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { +BgImage* func_80096A74(PolygonType1* polygon1, PlayState* play) { Camera* camera; s32 camId; s16 camId2; @@ -399,7 +399,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { BgImage* bgImage; s32 i; - camera = GET_ACTIVE_CAM(globalCtx); + camera = GET_ACTIVE_CAM(play); camId = camera->camDataIdx; if (camId == -1 && CVar_GetS32("gNoRestrictItems", 0)) { // This prevents a crash when using items that change the @@ -408,12 +408,12 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { } // jfifid - camId2 = func_80041C10(&globalCtx->colCtx, camId, BGCHECK_SCENE)[2].y; + camId2 = func_80041C10(&play->colCtx, camId, BGCHECK_SCENE)[2].y; if (camId2 >= 0) { camId = camId2; } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); player->actor.params = (player->actor.params & 0xFF00) | camId; bgImage = SEGMENTED_TO_VIRTUAL(polygon1->multi.list); @@ -432,7 +432,7 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { } // Room Draw Polygon Type 1 - Multi Format -void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { +void func_80096B6C(PlayState* play, Room* room, u32 flags) { Camera* camera; Gfx* spA8; PolygonType1* polygon1; @@ -443,13 +443,13 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { u32 sp90; u32 sp8C; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - camera = GET_ACTIVE_CAM(globalCtx); + camera = GET_ACTIVE_CAM(play); sp98 = (camera->setting == CAM_SET_PREREND_FIXED); polygon1 = &room->meshHeader->polygon1; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); - bgImage = func_80096A74(polygon1, globalCtx); + bgImage = func_80096A74(polygon1, play); sp94 = (flags & 1) && sp98 && bgImage->source && !(SREG(25) & 1); sp90 = (flags & 1) && polygonDlist->opa && !(SREG(25) & 2); sp8C = (flags & 2) && polygonDlist->xlu && !(SREG(25) & 4); @@ -458,7 +458,7 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); if (sp90) { - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, polygonDlist->opa); } @@ -484,35 +484,35 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { if (sp8C) { gSPSegment(POLY_XLU_DISP++, 0x03, room->segment); - func_80093D84(globalCtx->state.gfxCtx); + func_80093D84(play->state.gfxCtx); gSPMatrix(POLY_XLU_DISP++, &gMtxClear, G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, polygonDlist->xlu); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Room Draw Polygon Type 1 -void func_80096F6C(GlobalContext* globalCtx, Room* room, u32 flags) { +void func_80096F6C(PlayState* play, Room* room, u32 flags) { PolygonType1* polygon1 = &room->meshHeader->polygon1; if (polygon1->format == 1) { - func_80096680(globalCtx, room, flags); + func_80096680(play, room, flags); } else if (polygon1->format == 2) { - func_80096B6C(globalCtx, room, flags); + func_80096B6C(play, room, flags); } else { LOG_HUNGUP_THREAD(); } } -void func_80096FD4(GlobalContext* globalCtx, Room* room) { +void func_80096FD4(PlayState* play, Room* room) { room->num = -1; room->segment = NULL; } -u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { +u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { u32 maxRoomSize = 0; - RomFile* roomList = globalCtx->roomList; + RomFile* roomList = play->roomList; u32 roomSize; s32 i; s32 j; @@ -522,7 +522,7 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { u32 backRoomSize; u32 cumulRoomSize; - for (i = 0; i < globalCtx->numRooms; i++) { + for (i = 0; i < play->numRooms; i++) { roomSize = roomList[i].vromEnd - roomList[i].vromStart; osSyncPrintf("ROOM%d size=%d\n", i, roomSize); if (maxRoomSize < roomSize) { @@ -530,13 +530,13 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { } } - if (globalCtx->transiActorCtx.numActors != 0) { - RomFile* roomList = globalCtx->roomList; - TransitionActorEntry* transitionActor = &globalCtx->transiActorCtx.list[0]; + if (play->transiActorCtx.numActors != 0) { + RomFile* roomList = play->roomList; + TransitionActorEntry* transitionActor = &play->transiActorCtx.list[0]; - LOG_NUM("game_play->room_rom_address.num", globalCtx->numRooms); + LOG_NUM("game_play->room_rom_address.num", play->numRooms); - for (j = 0; j < globalCtx->transiActorCtx.numActors; j++) { + for (j = 0; j < play->transiActorCtx.numActors; j++) { frontRoom = transitionActor->sides[0].room; backRoom = transitionActor->sides[1].room; frontRoomSize = (frontRoom < 0) ? 0 : roomList[frontRoom].vromEnd - roomList[frontRoom].vromStart; @@ -555,7 +555,7 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { osSyncPrintf(VT_FGCOL(YELLOW)); // "Room buffer size=%08x(%5.1fK)" osSyncPrintf("部屋バッファサイズ=%08x(%5.1fK)\n", maxRoomSize, maxRoomSize / 1024.0f); - roomCtx->bufPtrs[0] = GAMESTATE_ALLOC_MC(&globalCtx->state, maxRoomSize); + roomCtx->bufPtrs[0] = GAMESTATE_ALLOC_MC(&play->state, maxRoomSize); // "Room buffer initial pointer=%08x" osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]); roomCtx->bufPtrs[1] = (void*)((intptr_t)roomCtx->bufPtrs[0] + maxRoomSize); @@ -566,16 +566,16 @@ u32 func_80096FE8(GlobalContext* globalCtx, RoomContext* roomCtx) { roomCtx->status = 0; frontRoom = gSaveContext.respawnFlag > 0 ? ((void)0, gSaveContext.respawn[gSaveContext.respawnFlag - 1].roomIndex) - : globalCtx->setupEntranceList[globalCtx->curSpawn].room; - func_8009728C(globalCtx, roomCtx, frontRoom); + : play->setupEntranceList[play->curSpawn].room; + func_8009728C(play, roomCtx, frontRoom); return maxRoomSize; } -s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { +s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { size_t size; - return OTRfunc_8009728C(globalCtx, roomCtx, roomNum); + return OTRfunc_8009728C(play, roomCtx, roomNum); if (roomCtx->status == 0) { roomCtx->prevRoom = roomCtx->curRoom; @@ -583,13 +583,13 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { roomCtx->curRoom.segment = NULL; roomCtx->status = 1; - ASSERT(roomNum < globalCtx->numRooms); + ASSERT(roomNum < play->numRooms); - size = globalCtx->roomList[roomNum].vromEnd - globalCtx->roomList[roomNum].vromStart; + size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; roomCtx->unk_34 = (void*)ALIGN16((intptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); - DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, globalCtx->roomList[roomNum].vromStart, size, 0, + DmaMgr_SendRequest2(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, &roomCtx->loadQueue, OS_MESG_PTR(NULL), __FILE__, __LINE__); roomCtx->unk_30 ^= 1; @@ -599,8 +599,8 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { return 0; } -s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { - return OTRfunc_800973FC(globalCtx, roomCtx); +s32 func_800973FC(PlayState* play, RoomContext* roomCtx) { + return OTRfunc_800973FC(play, roomCtx); if (roomCtx->status == 1) { @@ -609,9 +609,9 @@ s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { roomCtx->curRoom.segment = roomCtx->unk_34; gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->unk_34); - Scene_ExecuteCommands(globalCtx, roomCtx->curRoom.segment); - Player_SetBootData(globalCtx, GET_PLAYER(globalCtx)); - Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx); + Scene_ExecuteCommands(play, roomCtx->curRoom.segment); + Player_SetBootData(play, GET_PLAYER(play)); + Actor_SpawnTransitionActors(play, &play->actorCtx); return 1; } @@ -622,23 +622,23 @@ s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { return 1; } -void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags) { +void Room_Draw(PlayState* play, Room* room, u32 flags) { if (room->segment != NULL) { gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment); ASSERT(room->meshHeader->base.type < ARRAY_COUNTU(sRoomDrawHandlers)); - sRoomDrawHandlers[room->meshHeader->base.type](globalCtx, room, flags); + sRoomDrawHandlers[room->meshHeader->base.type](play, room, flags); } } -void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx) { +void func_80097534(PlayState* play, RoomContext* roomCtx) { roomCtx->prevRoom.num = -1; roomCtx->prevRoom.segment = NULL; - func_80031B14(globalCtx, &globalCtx->actorCtx); - Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx); - Map_InitRoomData(globalCtx, roomCtx->curRoom.num); - if (!((globalCtx->sceneNum >= SCENE_SPOT00) && (globalCtx->sceneNum <= SCENE_SPOT20))) { - Map_SavePlayerInitialInfo(globalCtx); + func_80031B14(play, &play->actorCtx); + Actor_SpawnTransitionActors(play, &play->actorCtx); + Map_InitRoomData(play, roomCtx->curRoom.num); + if (!((play->sceneNum >= SCENE_SPOT00) && (play->sceneNum <= SCENE_SPOT20))) { + Map_SavePlayerInitialInfo(play); } - Audio_SetEnvReverb(globalCtx->roomCtx.curRoom.echo); + Audio_SetEnvReverb(play->roomCtx.curRoom.echo); } diff --git a/soh/src/code/z_sample.c b/soh/src/code/z_sample.c index edb823988..0387d986b 100644 --- a/soh/src/code/z_sample.c +++ b/soh/src/code/z_sample.c @@ -2,7 +2,7 @@ void Sample_HandleStateChange(SampleContext* this) { if (CHECK_BTN_ALL(this->state.input[0].press.button, BTN_START)) { - SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); this->state.running = false; } } diff --git a/soh/src/code/z_scene.c b/soh/src/code/z_scene.c index 145d039a1..d975c08ab 100644 --- a/soh/src/code/z_scene.c +++ b/soh/src/code/z_scene.c @@ -31,24 +31,24 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) { return objectCtx->num - 1; } -void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) { - GlobalContext* globalCtx2 = globalCtx; // Needs to be a new variable to match (possibly a sub struct?) +void Object_InitBank(PlayState* play, ObjectContext* objectCtx) { + PlayState* play2 = play; // Needs to be a new variable to match (possibly a sub struct?) size_t spaceSize; s32 i; - if (globalCtx2->sceneNum == SCENE_SPOT00) { + if (play2->sceneNum == SCENE_SPOT00) { spaceSize = 1024000; - } else if (globalCtx2->sceneNum == SCENE_GANON_DEMO) { + } else if (play2->sceneNum == SCENE_GANON_DEMO) { if (gSaveContext.sceneSetupIndex != 4) { spaceSize = 1177600; } else { spaceSize = 1024000; } - } else if (globalCtx2->sceneNum == SCENE_JYASINBOSS) { + } else if (play2->sceneNum == SCENE_JYASINBOSS) { spaceSize = 1075200; - } else if (globalCtx2->sceneNum == SCENE_KENJYANOMA) { + } else if (play2->sceneNum == SCENE_KENJYANOMA) { spaceSize = 1075200; - } else if (globalCtx2->sceneNum == SCENE_GANON_BOSS) { + } else if (play2->sceneNum == SCENE_GANON_BOSS) { spaceSize = 1075200; } else { spaceSize = 1024000; @@ -68,7 +68,7 @@ void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) { osSyncPrintf(VT_RST); objectCtx->spaceStart = objectCtx->status[0].segment = - GAMESTATE_ALLOC_MC(&globalCtx->state, spaceSize); + GAMESTATE_ALLOC_MC(&play->state, spaceSize); objectCtx->spaceEnd = (void*)((uintptr_t)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP); @@ -160,7 +160,7 @@ void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) { return nextPtr; } -s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) { +s32 Scene_ExecuteCommands(PlayState* play, SceneCmd* sceneCmd) { u32 cmdCode; while (true) { @@ -173,7 +173,7 @@ s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) { } if (cmdCode < ARRAY_COUNT(gSceneCmdHandlers)) { - gSceneCmdHandlers[cmdCode](globalCtx, sceneCmd); + gSceneCmdHandlers[cmdCode](play, sceneCmd); } else { osSyncPrintf(VT_FGCOL(RED)); osSyncPrintf("code の値が異常です\n"); // "code variable is abnormal" @@ -184,29 +184,29 @@ s32 Scene_ExecuteCommands(GlobalContext* globalCtx, SceneCmd* sceneCmd) { return 0; } -void Scene_CommandSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) { - ActorEntry* linkEntry = globalCtx->linkActorEntry = (ActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->spawnList.segment) + - globalCtx->setupEntranceList[globalCtx->curSpawn].spawn; +void Scene_CommandSpawnList(PlayState* play, SceneCmd* cmd) { + ActorEntry* linkEntry = play->linkActorEntry = (ActorEntry*)SEGMENTED_TO_VIRTUAL(cmd->spawnList.segment) + + play->setupEntranceList[play->curSpawn].spawn; s16 linkObjectId; - globalCtx->linkAgeOnLoad = ((void)0, gSaveContext.linkAge); + play->linkAgeOnLoad = ((void)0, gSaveContext.linkAge); linkObjectId = gLinkObjectIds[((void)0, gSaveContext.linkAge)]; gActorOverlayTable[linkEntry->id].initInfo->objectId = linkObjectId; - Object_Spawn(&globalCtx->objectCtx, linkObjectId); + Object_Spawn(&play->objectCtx, linkObjectId); } -void Scene_CommandActorList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numSetupActors = cmd->actorList.num; - globalCtx->setupActorList = SEGMENTED_TO_VIRTUAL(cmd->actorList.segment); +void Scene_CommandActorList(PlayState* play, SceneCmd* cmd) { + play->numSetupActors = cmd->actorList.num; + play->setupActorList = SEGMENTED_TO_VIRTUAL(cmd->actorList.segment); } -void Scene_CommandUnused2(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); +void Scene_CommandUnused2(PlayState* play, SceneCmd* cmd) { + play->unk_11DFC = SEGMENTED_TO_VIRTUAL(cmd->unused02.segment); } -void Scene_CommandCollisionHeader(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandCollisionHeader(PlayState* play, SceneCmd* cmd) { CollisionHeader* colHeader = SEGMENTED_TO_VIRTUAL(cmd->colHeader.segment); colHeader->vtxList = SEGMENTED_TO_VIRTUAL(colHeader->vtxList); @@ -215,41 +215,41 @@ void Scene_CommandCollisionHeader(GlobalContext* globalCtx, SceneCmd* cmd) { colHeader->cameraDataList = SEGMENTED_TO_VIRTUAL(colHeader->cameraDataList); colHeader->waterBoxes = SEGMENTED_TO_VIRTUAL(colHeader->waterBoxes); - BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader); + BgCheck_Allocate(&play->colCtx, play, colHeader); } -void Scene_CommandRoomList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->numRooms = cmd->roomList.num; - globalCtx->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.segment); +void Scene_CommandRoomList(PlayState* play, SceneCmd* cmd) { + play->numRooms = cmd->roomList.num; + play->roomList = SEGMENTED_TO_VIRTUAL(cmd->roomList.segment); } -void Scene_CommandEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupEntranceList = SEGMENTED_TO_VIRTUAL(cmd->entranceList.segment); +void Scene_CommandEntranceList(PlayState* play, SceneCmd* cmd) { + play->setupEntranceList = SEGMENTED_TO_VIRTUAL(cmd->entranceList.segment); } -void Scene_CommandSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) { if (cmd->specialFiles.keepObjectId != OBJECT_INVALID) { - globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.keepObjectId); - gSegments[5] = VIRTUAL_TO_PHYSICAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment); + play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.keepObjectId); + gSegments[5] = VIRTUAL_TO_PHYSICAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment); } if (cmd->specialFiles.cUpElfMsgNum != 0) { - globalCtx->cUpElfMsgs = Gameplay_LoadFile(globalCtx, &sNaviMsgFiles[cmd->specialFiles.cUpElfMsgNum - 1]); + play->cUpElfMsgs = Play_LoadFile(play, &sNaviMsgFiles[cmd->specialFiles.cUpElfMsgNum - 1]); } } -void Scene_CommandRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.curRoom.behaviorType1 = cmd->roomBehavior.gpFlag1; - globalCtx->roomCtx.curRoom.behaviorType2 = cmd->roomBehavior.gpFlag2 & 0xFF; - globalCtx->roomCtx.curRoom.lensMode = (cmd->roomBehavior.gpFlag2 >> 8) & 1; - globalCtx->msgCtx.disableWarpSongs = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; +void Scene_CommandRoomBehavior(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.behaviorType1 = cmd->roomBehavior.gpFlag1; + play->roomCtx.curRoom.behaviorType2 = cmd->roomBehavior.gpFlag2 & 0xFF; + play->roomCtx.curRoom.lensMode = (cmd->roomBehavior.gpFlag2 >> 8) & 1; + play->msgCtx.disableWarpSongs = (cmd->roomBehavior.gpFlag2 >> 0xA) & 1; } -void Scene_CommandMeshHeader(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.curRoom.meshHeader = SEGMENTED_TO_VIRTUAL(cmd->mesh.segment); +void Scene_CommandMeshHeader(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.meshHeader = SEGMENTED_TO_VIRTUAL(cmd->mesh.segment); } -void Scene_CommandObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandObjectList(PlayState* play, SceneCmd* cmd) { s32 i; s32 j; s32 k; @@ -260,19 +260,19 @@ void Scene_CommandObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { void* nextPtr; k = 0; - i = globalCtx->objectCtx.unk_09; - firstStatus = &globalCtx->objectCtx.status[0]; - status = &globalCtx->objectCtx.status[i]; + i = play->objectCtx.unk_09; + firstStatus = &play->objectCtx.status[0]; + status = &play->objectCtx.status[i]; - while (i < globalCtx->objectCtx.num) { + while (i < play->objectCtx.num) { if (status->id != *objectEntry) { - status2 = &globalCtx->objectCtx.status[i]; - for (j = i; j < globalCtx->objectCtx.num; j++) { + status2 = &play->objectCtx.status[i]; + for (j = i; j < play->objectCtx.num; j++) { status2->id = OBJECT_INVALID; status2++; } - globalCtx->objectCtx.num = i; - func_80031A28(globalCtx, &globalCtx->actorCtx); + play->objectCtx.num = i; + func_80031A28(play, &play->actorCtx); continue; } @@ -286,7 +286,7 @@ void Scene_CommandObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { ASSERT(cmd->objectList.num <= OBJECT_EXCHANGE_BANK_MAX); while (k < cmd->objectList.num) { - nextPtr = func_800982FC(&globalCtx->objectCtx, i, *objectEntry); + nextPtr = func_800982FC(&play->objectCtx, i, *objectEntry); if (i < OBJECT_EXCHANGE_BANK_MAX - 1) { firstStatus[i + 1].segment = nextPtr; } @@ -295,69 +295,69 @@ void Scene_CommandObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { objectEntry++; } - globalCtx->objectCtx.num = i; + play->objectCtx.num = i; } -void Scene_CommandLightList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandLightList(PlayState* play, SceneCmd* cmd) { s32 i; LightInfo* lightInfo = SEGMENTED_TO_VIRTUAL(cmd->lightList.segment); for (i = 0; i < cmd->lightList.num; i++) { - LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo); + LightContext_InsertLight(play, &play->lightCtx, lightInfo); lightInfo++; } } -void Scene_CommandPathList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupPathList = SEGMENTED_TO_VIRTUAL(cmd->pathList.segment); +void Scene_CommandPathList(PlayState* play, SceneCmd* cmd) { + play->setupPathList = SEGMENTED_TO_VIRTUAL(cmd->pathList.segment); } -void Scene_CommandTransitionActorList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->transiActorCtx.numActors = cmd->transiActorList.num; - globalCtx->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.segment); +void Scene_CommandTransitionActorList(PlayState* play, SceneCmd* cmd) { + play->transiActorCtx.numActors = cmd->transiActorList.num; + play->transiActorCtx.list = SEGMENTED_TO_VIRTUAL(cmd->transiActorList.segment); } void TransitionActor_InitContext(GameState* state, TransitionActorContext* transiActorCtx) { transiActorCtx->numActors = 0; } -void Scene_CommandLightSettingsList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num; - globalCtx->envCtx.lightSettingsList = SEGMENTED_TO_VIRTUAL(cmd->lightSettingList.segment); +void Scene_CommandLightSettingsList(PlayState* play, SceneCmd* cmd) { + play->envCtx.numLightSettings = cmd->lightSettingList.num; + play->envCtx.lightSettingsList = SEGMENTED_TO_VIRTUAL(cmd->lightSettingList.segment); } -void Scene_CommandSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->skyboxId = cmd->skyboxSettings.skyboxId; - globalCtx->envCtx.unk_17 = globalCtx->envCtx.unk_18 = cmd->skyboxSettings.unk_05; - globalCtx->envCtx.indoors = cmd->skyboxSettings.unk_06; +void Scene_CommandSkyboxSettings(PlayState* play, SceneCmd* cmd) { + play->skyboxId = cmd->skyboxSettings.skyboxId; + play->envCtx.unk_17 = play->envCtx.unk_18 = cmd->skyboxSettings.unk_05; + play->envCtx.indoors = cmd->skyboxSettings.unk_06; } -void Scene_CommandSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk_04; - globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk_05; +void Scene_CommandSkyboxDisables(PlayState* play, SceneCmd* cmd) { + play->envCtx.skyboxDisabled = cmd->skyboxDisables.unk_04; + play->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk_05; } -void Scene_CommandTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandTimeSettings(PlayState* play, SceneCmd* cmd) { if ((cmd->timeSettings.hour != 0xFF) && (cmd->timeSettings.min != 0xFF)) { gSaveContext.skyboxTime = gSaveContext.dayTime = ((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / ((f32)(24 * 60) / 0x10000); } if (cmd->timeSettings.unk_06 != 0xFF) { - globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk_06; + play->envCtx.timeIncrement = cmd->timeSettings.unk_06; } else { - globalCtx->envCtx.timeIncrement = 0; + play->envCtx.timeIncrement = 0; } if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) { - gTimeIncrement = globalCtx->envCtx.timeIncrement; + gTimeIncrement = play->envCtx.timeIncrement; } - globalCtx->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 20.0f) * 25.0f; + play->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; + play->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 120.0f) * 25.0f; + play->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.dayTime) - 0x8000) * 20.0f) * 25.0f; - if (((globalCtx->envCtx.timeIncrement == 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) || + if (((play->envCtx.timeIncrement == 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) || (gSaveContext.entranceIndex == 0x0604)) { gSaveContext.skyboxTime = ((void)0, gSaveContext.dayTime); if ((gSaveContext.skyboxTime >= 0x2AAC) && (gSaveContext.skyboxTime < 0x4555)) { @@ -372,39 +372,39 @@ void Scene_CommandTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) { } } -void Scene_CommandWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandWindSettings(PlayState* play, SceneCmd* cmd) { s8 x = cmd->windSettings.x; s8 y = cmd->windSettings.y; s8 z = cmd->windSettings.z; - globalCtx->envCtx.windDirection.x = x; - globalCtx->envCtx.windDirection.y = y; - globalCtx->envCtx.windDirection.z = z; + play->envCtx.windDirection.x = x; + play->envCtx.windDirection.y = y; + play->envCtx.windDirection.z = z; - globalCtx->envCtx.windSpeed = cmd->windSettings.unk_07; + play->envCtx.windSpeed = cmd->windSettings.unk_07; } -void Scene_CommandExitList(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->setupExitList = SEGMENTED_TO_VIRTUAL(cmd->exitList.segment); +void Scene_CommandExitList(PlayState* play, SceneCmd* cmd) { + play->setupExitList = SEGMENTED_TO_VIRTUAL(cmd->exitList.segment); } -void Scene_CommandUndefined9(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandUndefined9(PlayState* play, SceneCmd* cmd) { } -void Scene_CommandSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->sequenceCtx.seqId = cmd->soundSettings.seqId; - globalCtx->sequenceCtx.natureAmbienceId = cmd->soundSettings.natureAmbienceId; +void Scene_CommandSoundSettings(PlayState* play, SceneCmd* cmd) { + play->sequenceCtx.seqId = cmd->soundSettings.seqId; + play->sequenceCtx.natureAmbienceId = cmd->soundSettings.natureAmbienceId; if (gSaveContext.seqId == (u8)NA_BGM_DISABLED) { Audio_QueueSeqCmd(cmd->soundSettings.specId | 0xF0000000); } } -void Scene_CommandEchoSettings(GlobalContext* globalCtx, SceneCmd* cmd) { - globalCtx->roomCtx.curRoom.echo = cmd->echoSettings.echo; +void Scene_CommandEchoSettings(PlayState* play, SceneCmd* cmd) { + play->roomCtx.curRoom.echo = cmd->echoSettings.echo; } -void Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandAlternateHeaderList(PlayState* play, SceneCmd* cmd) { s32 pad; SceneCmd* altHeader; @@ -416,7 +416,7 @@ void Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { altHeader = ((SceneCmd**)SEGMENTED_TO_VIRTUAL(cmd->altHeaders.segment))[gSaveContext.sceneSetupIndex - 1]; if (altHeader != NULL) { - Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader)); + Scene_ExecuteCommands(play, SEGMENTED_TO_VIRTUAL(altHeader)); (cmd + 1)->base.code = SCENE_CMD_ID_END; } else { // "Coughh! There is no specified dataaaaa!" @@ -430,7 +430,7 @@ void Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { osSyncPrintf("\nそこで、大人の昼データを使用するでええっす!!"); if (altHeader != NULL) { - Scene_ExecuteCommands(globalCtx, SEGMENTED_TO_VIRTUAL(altHeader)); + Scene_ExecuteCommands(play, SEGMENTED_TO_VIRTUAL(altHeader)); (cmd + 1)->base.code = SCENE_CMD_ID_END; } } @@ -438,24 +438,24 @@ void Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { } } -void Scene_CommandCutsceneData(GlobalContext* globalCtx, SceneCmd* cmd) { - osSyncPrintf("\ngame_play->demo_play.data=[%x]", globalCtx->csCtx.segment); - globalCtx->csCtx.segment = SEGMENTED_TO_VIRTUAL(cmd->cutsceneData.segment); +void Scene_CommandCutsceneData(PlayState* play, SceneCmd* cmd) { + osSyncPrintf("\ngame_play->demo_play.data=[%x]", play->csCtx.segment); + play->csCtx.segment = SEGMENTED_TO_VIRTUAL(cmd->cutsceneData.segment); } // Camera & World Map Area -void Scene_CommandMiscSettings(GlobalContext* globalCtx, SceneCmd* cmd) { +void Scene_CommandMiscSettings(PlayState* play, SceneCmd* cmd) { YREG(15) = cmd->miscSettings.cameraMovement; gSaveContext.worldMapArea = cmd->miscSettings.area; - if ((globalCtx->sceneNum == SCENE_SHOP1) || (globalCtx->sceneNum == SCENE_SYATEKIJYOU)) { + if ((play->sceneNum == SCENE_SHOP1) || (play->sceneNum == SCENE_SYATEKIJYOU)) { if (LINK_AGE_IN_YEARS == YEARS_ADULT) { gSaveContext.worldMapArea = 1; } } - if (((globalCtx->sceneNum >= SCENE_SPOT00) && (globalCtx->sceneNum <= SCENE_GANON_TOU)) || - ((globalCtx->sceneNum >= SCENE_ENTRA) && (globalCtx->sceneNum <= SCENE_SHRINE_R))) { + if (((play->sceneNum >= SCENE_SPOT00) && (play->sceneNum <= SCENE_GANON_TOU)) || + ((play->sceneNum >= SCENE_ENTRA) && (play->sceneNum <= SCENE_SHRINE_R))) { if (gSaveContext.cutsceneIndex < 0xFFF0) { gSaveContext.worldMapAreaData |= gBitFlags[gSaveContext.worldMapArea]; osSyncPrintf("000 area_arrival=%x (%d)\n", gSaveContext.worldMapAreaData, @@ -464,7 +464,7 @@ void Scene_CommandMiscSettings(GlobalContext* globalCtx, SceneCmd* cmd) { } } -void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(GlobalContext*, SceneCmd*) = { +void (*gSceneCmdHandlers[SCENE_CMD_ID_MAX])(PlayState*, SceneCmd*) = { Scene_CommandSpawnList, // SCENE_CMD_ID_SPAWN_LIST Scene_CommandActorList, // SCENE_CMD_ID_ACTOR_LIST Scene_CommandUnused2, // SCENE_CMD_ID_UNUSED_2 diff --git a/soh/src/code/z_scene_table.c b/soh/src/code/z_scene_table.c index 9bf710af1..33e58dbd0 100644 --- a/soh/src/code/z_scene_table.c +++ b/soh/src/code/z_scene_table.c @@ -956,34 +956,34 @@ Gfx sDefaultDisplayList[] = { }; // Computes next entrance index based on age and day time to set the fade out transition -void func_800994A0(GlobalContext* globalCtx) { +void func_800994A0(PlayState* play) { s16 computedEntranceIndex; if (!IS_DAY) { if (!LINK_IS_ADULT) { - computedEntranceIndex = globalCtx->nextEntranceIndex + 1; + computedEntranceIndex = play->nextEntranceIndex + 1; } else { - computedEntranceIndex = globalCtx->nextEntranceIndex + 3; + computedEntranceIndex = play->nextEntranceIndex + 3; } } else { if (!LINK_IS_ADULT) { - computedEntranceIndex = globalCtx->nextEntranceIndex; + computedEntranceIndex = play->nextEntranceIndex; } else { - computedEntranceIndex = globalCtx->nextEntranceIndex + 2; + computedEntranceIndex = play->nextEntranceIndex + 2; } } - globalCtx->fadeTransition = gEntranceTable[computedEntranceIndex].field & 0x7F; // Fade out + play->fadeTransition = gEntranceTable[computedEntranceIndex].field & 0x7F; // Fade out } // Scene Draw Config 0 -void func_80099550(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_80099550(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, sDefaultDisplayList); gSPDisplayList(POLY_XLU_DISP++, sDefaultDisplayList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* D_8012A2F8[] = { @@ -992,13 +992,13 @@ void* D_8012A2F8[] = { }; // Scene Draw Config 19 -void func_800995DC(GlobalContext* globalCtx) { - u32 gameplayFrames = globalCtx->gameplayFrames; +void func_800995DC(PlayState* play) { + u32 gameplayFrames = play->gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (gameplayFrames % 128), (gameplayFrames * 1) % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (gameplayFrames % 128), (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_XLU_DISP++); @@ -1008,24 +1008,24 @@ void func_800995DC(GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8[gSaveContext.nightFlag])); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 28 -void func_80099760(GlobalContext* globalCtx) { +void func_80099760(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 2) % 256, 0, 64, 32, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 2) % 256, 0, 64, 32, 1, 0, (gameplayFrames * 2) % 128, 64, 32)); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* gDCEntranceTextures[] = { @@ -1038,21 +1038,21 @@ void* sDCLavaFloorTextures[] = { }; // Scene Draw Config 20 - Dodongo's Cavern -void func_80099878(GlobalContext* globalCtx) { +void func_80099878(PlayState* play) { u32 gameplayFrames; s32 pad; - Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 2 * sizeof(Gfx[3])); + Gfx* displayListHead = Graph_Alloc(play->state.gfxCtx, 2 * sizeof(Gfx[3])); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures[gSaveContext.nightFlag])); gSPSegment(POLY_OPA_DISP++, 0x09, SEGMENTED_TO_VIRTUAL(sDCLavaFloorTextures[(s32)(gameplayFrames & 14) >> 1])); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 0, 64, 32, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 0, 64, 32, 1, 0, (gameplayFrames * 1) % 128, 64, 32)); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 128, 32, 32, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 128, 32, 32, 1, 0, (gameplayFrames * 2) % 128, 32, 32)); { s32 pad2[2]; } @@ -1065,25 +1065,25 @@ void func_80099878(GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 255, 255, 255, globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_LEFT]); + gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.unk_74[BGDODOAGO_EYE_LEFT]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 255, 255, 255, globalCtx->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT]); + gDPSetEnvColor(displayListHead++, 255, 255, 255, play->roomCtx.unk_74[BGDODOAGO_EYE_RIGHT]); gSPEndDisplayList(displayListHead); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 30 -void func_80099BD8(GlobalContext* globalCtx) { +void func_80099BD8(PlayState* play) { f32 temp; - Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 18 * sizeof(Gfx)); + Gfx* displayListHead = Graph_Alloc(play->state.gfxCtx, 18 * sizeof(Gfx)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - temp = globalCtx->roomCtx.unk_74[0] / 255.0f; + temp = play->roomCtx.unk_74[0] / 255.0f; gSPSegment(POLY_XLU_DISP++, 0x08, displayListHead); gSPSegment(POLY_OPA_DISP++, 0x08, displayListHead); @@ -1100,7 +1100,7 @@ void func_80099BD8(GlobalContext* globalCtx) { gSPSegment(POLY_OPA_DISP++, 0x0A, displayListHead); gSPSegment(POLY_XLU_DISP++, 0x0A, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, globalCtx->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0B, displayListHead); @@ -1108,7 +1108,7 @@ void func_80099BD8(GlobalContext* globalCtx) { gDPSetPrimColor(displayListHead++, 0, 0, 89 + (u8)(166.0f * temp), 89 + (u8)(166.0f * temp), 89 + (u8)(166.0f * temp), 255); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, globalCtx->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0C, displayListHead); @@ -1116,16 +1116,16 @@ void func_80099BD8(GlobalContext* globalCtx) { gDPSetPrimColor(displayListHead++, 0, 0, 255 + (u8)(179.0f * temp), 255 + (u8)(179.0f * temp), 255 + (u8)(179.0f * temp), 255); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, globalCtx->roomCtx.unk_74[0]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[0]); gSPEndDisplayList(displayListHead++); gSPSegment(POLY_OPA_DISP++, 0x0D, displayListHead); gSPSegment(POLY_XLU_DISP++, 0x0D, displayListHead); gDPPipeSync(displayListHead++); - gDPSetEnvColor(displayListHead++, 0, 0, 0, globalCtx->roomCtx.unk_74[1]); + gDPSetEnvColor(displayListHead++, 0, 0, 0, play->roomCtx.unk_74[1]); gSPEndDisplayList(displayListHead); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if (gSaveContext.sceneSetupIndex == 5) { gCustomLensFlareOn = true; @@ -1139,25 +1139,25 @@ void func_80099BD8(GlobalContext* globalCtx) { } // Scene Draw Config 31 -void func_8009A45C(GlobalContext* globalCtx) { +void func_8009A45C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 64, 256, 16)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 64, 256, 16)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (gameplayFrames % 128), (gameplayFrames * 1) % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (gameplayFrames % 128), (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment( POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (gameplayFrames * 1) % 128, 32, 32)); - gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (gameplayFrames * 1) % 128, 32, 32)); + gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0C, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 50) % 2048, 8, 512, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 50) % 2048, 8, 512, 1, 0, (gameplayFrames * 60) % 2048, 8, 512)); gSPSegment(POLY_OPA_DISP++, 0x0D, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (gameplayFrames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); @@ -1165,26 +1165,26 @@ void func_8009A45C(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 32 -void func_8009A798(GlobalContext* globalCtx) { +void func_8009A798(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 2) % 256, 64, 64)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 2) % 256, 64, 64)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (gameplayFrames * 1) % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (gameplayFrames * 1) % 128, (gameplayFrames * 1) % 256, 32, 64, 1, 0, 0, 32, 128)); gDPPipeSync(POLY_OPA_DISP++); @@ -1193,21 +1193,21 @@ void func_8009A798(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 33 -void func_8009A9DC(GlobalContext* globalCtx) { +void func_8009A9DC(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 256, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 256, 32, 64, 1, gameplayFrames % 128, (gameplayFrames * 3) % 256, 32, 64)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -1216,17 +1216,17 @@ void func_8009A9DC(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 48 -void func_8009AB98(GlobalContext* globalCtx) { +void func_8009AB98(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames % 64, 256, 16)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, gameplayFrames % 64, 256, 16)); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); @@ -1234,20 +1234,20 @@ void func_8009AB98(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 39 -void func_8009ACA8(GlobalContext* globalCtx) { +void func_8009ACA8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32)); - gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames % 64, 256, 16)); + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TexScroll(play->state.gfxCtx, 0, gameplayFrames % 64, 256, 16)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1255,24 +1255,24 @@ void func_8009ACA8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 24 -void func_8009AE30(GlobalContext* globalCtx) { +void func_8009AE30(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; - if (globalCtx->sceneNum == SCENE_HAKADAN_BS) { + if (play->sceneNum == SCENE_HAKADAN_BS) { gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 2) % 128, 0, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 2) % 128, 0, 32, 32, 1, (gameplayFrames * 2) % 128, 0, 32, 32)); } else { gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 2) % 128, 0, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 2) % 128, 0, 32, 32, 1, (gameplayFrames * 2) % 128, 0, 32, 32)); } @@ -1282,7 +1282,7 @@ void func_8009AE30(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sThievesHideoutEntranceTextures[] = { @@ -1291,19 +1291,19 @@ void* sThievesHideoutEntranceTextures[] = { }; // Scene Draw Config 40 -void func_8009AFE0(GlobalContext* globalCtx) { +void func_8009AFE0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 3) % 128, 32, 32)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 3) % 128, 32, 32)); { s32 pad[2]; } gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures[gSaveContext.nightFlag])); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* D_8012A330[] = { @@ -1312,123 +1312,123 @@ void* D_8012A330[] = { }; // Scene Draw Config 23 (Water Temple) -void func_8009B0FC(GlobalContext* globalCtx) { +void func_8009B0FC(PlayState* play) { u32 gameplayFrames; s32 spB0; s32 spAC; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - spB0 = (globalCtx->roomCtx.unk_74[1] >> 8) & 0xFF; - spAC = globalCtx->roomCtx.unk_74[1] & 0xFF; - gameplayFrames = globalCtx->gameplayFrames; + spB0 = (play->roomCtx.unk_74[1] >> 8) & 0xFF; + spAC = play->roomCtx.unk_74[1] & 0xFF; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A330[gSaveContext.nightFlag])); if (spB0 == 1) { gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, spAC)); } else if (spB0 < 1) { gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 255)); } else { gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 160)); } if (spB0 == 2) { gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, spAC)); } else if (spB0 < 2) { gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 255)); } else { gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 160)); } if (spB0 != 0) { gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 160)); gSPSegment(POLY_OPA_DISP++, 0x0B, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 3, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 3, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 180)); } else { gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 128, 0, 32, 32, 1, 0, 0, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, (gameplayFrames * 1) % 128, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 160 + (s32)((spAC / 200.0f) * 95.0f))); gSPSegment(POLY_OPA_DISP++, 0x0B, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 3, 0, 32, 32, 1, 0, 0, 32, 32, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 3, 0, 32, 32, 1, 0, 0, 32, 32, 0, 0, 0, 185 + (s32)((spAC / 200.0f) * 70.0f))); } gSPSegment(POLY_XLU_DISP++, 0x0C, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, gameplayFrames * 1, 32, 32, 1, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 1, gameplayFrames * 1, 32, 32, 1, 0, 127 - (gameplayFrames * 1), 32, 32, 0, 0, 0, 128)); gSPSegment(POLY_XLU_DISP++, 0x0D, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames * 4, 0, 32, 32, 1, + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 4, 0, 32, 32, 1, gameplayFrames * 4, 0, 32, 32, 0, 0, 0, 128)); { s32 pad[2]; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 29 -void func_8009B86C(GlobalContext* globalCtx) { +void func_8009B86C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, gameplayFrames * 1, 0, 32, 32, 1, 0, 0, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); - gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, globalCtx->roomCtx.unk_74[0]); + gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, play->roomCtx.unk_74[0]); gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 145); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 34 -void func_8009B9BC(GlobalContext* globalCtx) { +void func_8009B9BC(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames % 64, 4, 16)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, gameplayFrames % 64, 4, 16)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 35 -void func_8009BAA4(GlobalContext* globalCtx) { +void func_8009BAA4(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32)); - if (globalCtx->sceneNum == SCENE_HAIRAL_NIWA) { + if (play->sceneNum == SCENE_HAIRAL_NIWA) { gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 10) % 256, 32, 64)); + Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 10) % 256, 32, 64)); } gDPPipeSync(POLY_OPA_DISP++); @@ -1437,30 +1437,30 @@ void func_8009BAA4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 36 -void func_8009BC44(GlobalContext* globalCtx) { +void func_8009BC44(PlayState* play) { u32 gameplayFrames; s8 sp83; - sp83 = coss((globalCtx->gameplayFrames * 1500) & 0xFFFF) >> 8; + sp83 = coss((play->gameplayFrames * 1500) & 0xFFFF) >> 8; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; - if (globalCtx->sceneNum == SCENE_GANON_TOU) { + if (play->sceneNum == SCENE_GANON_TOU) { gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 64, 64)); + Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 64, 64)); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 255 - (gameplayFrames * 1) % 256, 64, 64, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 255 - (gameplayFrames * 1) % 256, 64, 64, 1, 0, (gameplayFrames * 1) % 256, 64, 64)); } gSPSegment(POLY_OPA_DISP++, 0x0B, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 255 - (gameplayFrames * 1) % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 255 - (gameplayFrames * 1) % 128, (gameplayFrames * 1) % 128, 32, 32, 1, (gameplayFrames * 1) % 128, (gameplayFrames * 1) % 128, 32, 32)); @@ -1474,22 +1474,22 @@ void func_8009BC44(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, sp83, sp83, sp83, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Screen Shake for Ganon's Tower Collapse -void func_8009BEEC(GlobalContext* globalCtx) { +void func_8009BEEC(PlayState* play) { s32 var; - if (globalCtx->gameplayFrames % 128 == 13) { - var = Quake_Add(GET_ACTIVE_CAM(globalCtx), 2); + if (play->gameplayFrames % 128 == 13) { + var = Quake_Add(GET_ACTIVE_CAM(play), 2); Quake_SetSpeed(var, 10000); Quake_SetQuakeValues(var, 4, 0, 0, 0); Quake_SetCountdown(var, 127); } - if ((globalCtx->gameplayFrames % 64 == 0) && (Rand_ZeroOne() > 0.6f)) { - var = Quake_Add(GET_ACTIVE_CAM(globalCtx), 3); + if ((play->gameplayFrames % 64 == 0) && (Rand_ZeroOne() > 0.6f)) { + var = Quake_Add(GET_ACTIVE_CAM(play), 3); Quake_SetSpeed(var, 32000.0f + (Rand_ZeroOne() * 3000.0f)); Quake_SetQuakeValues(var, 10.0f - (Rand_ZeroOne() * 9.0f), 0, 0, 0); Quake_SetCountdown(var, 48.0f - (Rand_ZeroOne() * 15.0f)); @@ -1497,23 +1497,23 @@ void func_8009BEEC(GlobalContext* globalCtx) { } // Scene Draw Config 38 -void func_8009C0AC(GlobalContext* globalCtx) { +void func_8009C0AC(PlayState* play) { u32 gameplayFrames; s8 sp7B; - sp7B = coss((globalCtx->gameplayFrames * 1500) & 0xFFFF) >> 8; + sp7B = coss((play->gameplayFrames * 1500) & 0xFFFF) >> 8; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 512, 64, 128, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 512, 64, 128, 1, 0, 511 - (gameplayFrames * 1) % 512, 64, 128)); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 256, 32, 64, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 256, 32, 64, 1, 0, 255 - (gameplayFrames * 1) % 256, 32, 64)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 20) % 2048, 16, 512, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 20) % 2048, 16, 512, 1, 0, (gameplayFrames * 30) % 2048, 16, 512)); gDPPipeSync(POLY_OPA_DISP++); @@ -1526,12 +1526,12 @@ void func_8009C0AC(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, sp7B, sp7B, sp7B, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); - if (Flags_GetSwitch(globalCtx, 0x37)) { - if ((globalCtx->sceneNum == SCENE_GANON_DEMO) || (globalCtx->sceneNum == SCENE_GANON_FINAL) || - (globalCtx->sceneNum == SCENE_GANON_SONOGO) || (globalCtx->sceneNum == SCENE_GANONTIKA_SONOGO)) { - func_8009BEEC(globalCtx); + if (Flags_GetSwitch(play, 0x37)) { + if ((play->sceneNum == SCENE_GANON_DEMO) || (play->sceneNum == SCENE_GANON_FINAL) || + (play->sceneNum == SCENE_GANON_SONOGO) || (play->sceneNum == SCENE_GANONTIKA_SONOGO)) { + func_8009BEEC(play); } } } @@ -1542,18 +1542,18 @@ void* sIceCavernEntranceTextures[] = { }; // Scene Draw Config 37 -void func_8009C3EC(GlobalContext* globalCtx) { +void func_8009C3EC(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures[gSaveContext.nightFlag])); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); { s32 pad[2]; } @@ -1564,25 +1564,25 @@ void func_8009C3EC(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 42 -void func_8009C608(GlobalContext* globalCtx) { +void func_8009C608(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 64, 256, 16)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 64, 256, 16)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 60) % 2048, 8, 512, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 60) % 2048, 8, 512, 1, 0, (gameplayFrames * 50) % 2048, 8, 512)); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (gameplayFrames * 1) % 128, 0, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (gameplayFrames * 1) % 128, 0, 32, 32, 1, (gameplayFrames * 1) % 128, 0, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0B, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 1023 - (gameplayFrames * 6) % 1024, 16, 256, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 1023 - (gameplayFrames * 6) % 1024, 16, 256, 1, 0, 1023 - (gameplayFrames * 3) % 1024, 16, 256)); gDPPipeSync(POLY_OPA_DISP++); @@ -1591,23 +1591,23 @@ void func_8009C608(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 43 -void func_8009C8B8(GlobalContext* globalCtx) { +void func_8009C8B8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, (gameplayFrames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, 255 - (gameplayFrames * 10) % 256, 32, 64)); + Gfx_TexScroll(play->state.gfxCtx, 0, 255 - (gameplayFrames * 10) % 256, 32, 64)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1615,18 +1615,18 @@ void func_8009C8B8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 47 -void func_8009CAC0(GlobalContext* globalCtx) { +void func_8009CAC0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -1635,7 +1635,7 @@ void func_8009CAC0(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sGTGEntranceTextures[] = { @@ -1644,18 +1644,18 @@ void* sGTGEntranceTextures[] = { }; // Scene Draw Config 27 -void func_8009CC00(GlobalContext* globalCtx) { +void func_8009CC00(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures[gSaveContext.nightFlag])); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); { s32 pad[2]; } @@ -1666,7 +1666,7 @@ void func_8009CC00(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } Gfx* Gfx_TwoTexScrollPrimColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, @@ -1689,17 +1689,17 @@ Gfx* Gfx_TwoTexScrollPrimColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y } // Scene Draw Config 50 -void func_8009CF84(GlobalContext* globalCtx) { +void func_8009CF84(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScrollPrimColor(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, + Gfx_TwoTexScrollPrimColor(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 255, 255, 255, - globalCtx->roomCtx.unk_74[0] + 127)); + play->roomCtx.unk_74[0] + 127)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1707,24 +1707,24 @@ void func_8009CF84(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 41 -void func_8009D0E8(GlobalContext* globalCtx) { +void func_8009D0E8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TexScroll(globalCtx->state.gfxCtx, 127 - (gameplayFrames * 4) % 128, 0, 32, 32)); - gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 5) % 64, 16, 16)); + Gfx_TexScroll(play->state.gfxCtx, 127 - (gameplayFrames * 4) % 128, 0, 32, 32)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 5) % 64, 16, 16)); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, 63 - (gameplayFrames * 2) % 64, 16, 16)); + Gfx_TexScroll(play->state.gfxCtx, 0, 63 - (gameplayFrames * 2) % 64, 16, 16)); gSPSegment( POLY_XLU_DISP++, 0x0B, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 127 - (gameplayFrames * 3) % 128, 32, 32, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 127 - (gameplayFrames * 3) % 128, 32, 32, 1, 0, 0, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1732,7 +1732,7 @@ void func_8009D0E8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sLonLonHouseEntranceTextures[] = { @@ -1741,8 +1741,8 @@ void* sLonLonHouseEntranceTextures[] = { }; // Scene Draw Config 44 -void func_8009D31C(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_8009D31C(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); { s32 pad[2]; } @@ -1754,7 +1754,7 @@ void func_8009D31C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sGuardHouseView2Textures[] = { @@ -1767,10 +1767,10 @@ void* sGuardHouseView1Textures[] = { }; // Scene Draw Config 45 -void func_8009D438(GlobalContext* globalCtx) { +void func_8009D438(PlayState* play) { s32 var; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (LINK_IS_ADULT) { var = 1; @@ -1787,19 +1787,19 @@ void func_8009D438(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 46 -void func_8009D5B4(GlobalContext* globalCtx) { +void func_8009D5B4(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 3) % 128, 32, 32)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_OPA_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 3) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 1023 - (gameplayFrames * 3) % 1024, 16, 256, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 1023 - (gameplayFrames * 3) % 1024, 16, 256, 1, 0, 1023 - (gameplayFrames * 6) % 1024, 16, 256)); gDPPipeSync(POLY_OPA_DISP++); @@ -1808,7 +1808,7 @@ void func_8009D5B4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sForestTempleEntranceTextures[] = { @@ -1817,18 +1817,18 @@ void* sForestTempleEntranceTextures[] = { }; // Scene Draw Config 22 -void func_8009D758(GlobalContext* globalCtx) { +void func_8009D758(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures[gSaveContext.nightFlag])); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); { s32 pad[2]; } @@ -1839,7 +1839,7 @@ void func_8009D758(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sSpiritTempleEntranceTextures[] = { @@ -1848,31 +1848,31 @@ void* sSpiritTempleEntranceTextures[] = { }; // Scene Draw Config 25 -void func_8009D974(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_8009D974(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); { s32 pad[2]; } gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures[gSaveContext.nightFlag])); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 1 -void func_8009DA30(GlobalContext* globalCtx) { +void func_8009DA30(PlayState* play) { u32 gameplayFrames; Gfx* displayListHead; - displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 3 * sizeof(Gfx)); + displayListHead = Graph_Alloc(play->state.gfxCtx, 3 * sizeof(Gfx)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -1887,21 +1887,21 @@ void func_8009DA30(GlobalContext* globalCtx) { gSPEndDisplayList(displayListHead); } else { if (gSaveContext.dayTime > 0xC555) { - if (globalCtx->roomCtx.unk_74[0] != 255) { - Math_StepToS(&globalCtx->roomCtx.unk_74[0], 255, 5); + if (play->roomCtx.unk_74[0] != 255) { + Math_StepToS(&play->roomCtx.unk_74[0], 255, 5); } } else if (gSaveContext.dayTime >= 0x4000) { - if (globalCtx->roomCtx.unk_74[0] != 0) { - Math_StepToS(&globalCtx->roomCtx.unk_74[0], 0, 10); + if (play->roomCtx.unk_74[0] != 0) { + Math_StepToS(&play->roomCtx.unk_74[0], 0, 10); } } - gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, globalCtx->roomCtx.unk_74[0]); + gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.unk_74[0]); gSPDisplayList(displayListHead++, spot00_room_0DL_012B20); gSPEndDisplayList(displayListHead); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sKakarikoWindowTextures[] = { @@ -1910,8 +1910,8 @@ void* sKakarikoWindowTextures[] = { }; // Scene Draw Config 2 -void func_8009DD5C(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_8009DD5C(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); { s32 pad[2]; } @@ -1923,24 +1923,24 @@ void func_8009DD5C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 3 -void func_8009DE78(GlobalContext* globalCtx) { +void func_8009DE78(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 6) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 6) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 6) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -1949,11 +1949,11 @@ void func_8009DE78(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 4 -void func_8009E0B8(GlobalContext* globalCtx) { +void func_8009E0B8(PlayState* play) { u32 gameplayFrames; u8 spA3; u16 spA0; @@ -1961,16 +1961,16 @@ void func_8009E0B8(GlobalContext* globalCtx) { spA3 = 128; spA0 = 500; - displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 6 * sizeof(Gfx)); + displayListHead = Graph_Alloc(play->state.gfxCtx, 6 * sizeof(Gfx)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -1980,9 +1980,9 @@ void func_8009E0B8(GlobalContext* globalCtx) { gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); if (gSaveContext.sceneSetupIndex == 4) { - spA3 = 255 - (u8)globalCtx->roomCtx.unk_74[0]; + spA3 = 255 - (u8)play->roomCtx.unk_74[0]; } else if (gSaveContext.sceneSetupIndex == 6) { - spA0 = globalCtx->roomCtx.unk_74[0] + 500; + spA0 = play->roomCtx.unk_74[0] + 500; } else if (((gSaveContext.sceneSetupIndex < 4) || LINK_IS_ADULT) && (gSaveContext.eventChkInf[0] & 0x80)) { spA0 = 2150; } @@ -1999,34 +1999,34 @@ void func_8009E0B8(GlobalContext* globalCtx) { gSPEndDisplayList(displayListHead); gSPSegment(POLY_OPA_DISP++, 0x0C, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (s16)(-globalCtx->roomCtx.unk_74[0] * 0.02f), 32, 16, 1, - 0, (s16)(-globalCtx->roomCtx.unk_74[0] * 0.02f), 32, 16)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (s16)(-play->roomCtx.unk_74[0] * 0.02f), 32, 16, 1, + 0, (s16)(-play->roomCtx.unk_74[0] * 0.02f), 32, 16)); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 5 -void func_8009E54C(GlobalContext* globalCtx) { +void func_8009E54C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if ((gSaveContext.sceneSetupIndex > 3) || (LINK_IS_ADULT && !(gSaveContext.eventChkInf[6] & 0x200))) { - globalCtx->roomCtx.unk_74[0] = 87; + play->roomCtx.unk_74[0] = 87; } - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, gameplayFrames, gameplayFrames, 32, 32, 1, 0, 0, 32, - 32, 0, 0, 0, globalCtx->roomCtx.unk_74[0] + 168)); + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames, gameplayFrames, 32, 32, 1, 0, 0, 32, + 32, 0, 0, 0, play->roomCtx.unk_74[0] + 168)); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScrollEnvColor(globalCtx->state.gfxCtx, 0, -gameplayFrames, -gameplayFrames, 32, 32, 1, 0, 0, - 16, 64, 0, 0, 0, globalCtx->roomCtx.unk_74[0] + 168)); + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, -gameplayFrames, -gameplayFrames, 32, 32, 1, 0, 0, + 16, 64, 0, 0, 0, play->roomCtx.unk_74[0] + 168)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sZorasDomainEntranceTextures[] = { @@ -2035,18 +2035,18 @@ void* sZorasDomainEntranceTextures[] = { }; // Scene Draw Config 6 -void func_8009E730(GlobalContext* globalCtx) { +void func_8009E730(PlayState* play) { u32 gameplayFrames; u32 var; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; var = 127 - (gameplayFrames * 1) % 128; if (LINK_IS_ADULT) { var = 0; } - gSPSegment(POLY_OPA_DISP++, 0x0C, Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 64, 32, 1, 0, var, 64, 32)); + gSPSegment(POLY_OPA_DISP++, 0x0C, Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 64, 32, 1, 0, var, 64, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -2055,23 +2055,23 @@ void func_8009E730(GlobalContext* globalCtx) { { s32 pad[2]; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 7 -void func_8009E8C0(GlobalContext* globalCtx) { +void func_8009E8C0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 128, 0, 32, 32, 1, 0, 0, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 1) % 128, 0, 32, 32, 1, 0, 0, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 255 - (gameplayFrames * 2) % 256, 64, 64, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 255 - (gameplayFrames * 2) % 256, 64, 64, 1, 0, 255 - (gameplayFrames * 2) % 256, 64, 64)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 128, 32, 32, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 128, 32, 32, 1, 0, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -2080,33 +2080,33 @@ void func_8009E8C0(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 8 -void func_8009EAD8(GlobalContext* globalCtx) { +void func_8009EAD8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 3) % 1024, 32, 256, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 3) % 1024, 32, 256, 1, 0, (gameplayFrames * 3) % 1024, 32, 256)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 256, 64, 64, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 256, 64, 64, 1, 0, (gameplayFrames * 1) % 256, 64, 64)); gSPSegment(POLY_XLU_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 2) % 128, 32, 32, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 2) % 128, 32, 32, 1, 0, (gameplayFrames * 2) % 128, 32, 32)); gSPSegment( POLY_OPA_DISP++, 0x0B, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (gameplayFrames * 3) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (gameplayFrames * 3) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0C, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 128, 32, 32, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 128, 32, 32, 1, 0, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x0D, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 64, 16, 16, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (gameplayFrames * 1) % 64, 16, 16, 1, 0, (gameplayFrames * 1) % 64, 16, 16)); gDPPipeSync(POLY_OPA_DISP++); @@ -2115,21 +2115,21 @@ void func_8009EAD8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 9 -void func_8009EE44(GlobalContext* globalCtx) { +void func_8009EE44(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames % 128, 0, 32, 16, 1, gameplayFrames % 128, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, gameplayFrames % 128, 0, 32, 16, 1, gameplayFrames % 128, 0, 32, 16)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, gameplayFrames % 128, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, gameplayFrames % 128, 32, 32, 1, gameplayFrames % 128, gameplayFrames % 128, 32, 32)); gDPPipeSync(POLY_XLU_DISP++); @@ -2142,26 +2142,26 @@ void func_8009EE44(GlobalContext* globalCtx) { if (gSaveContext.n64ddFlag && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE)) { playerHasCojiro = PLAYER_HAS_SHUFFLED_ADULT_TRADE_ITEM(ITEM_COJIRO); } - if ((globalCtx->roomCtx.unk_74[0] == 0) && playerHasCojiro) { - if (globalCtx->roomCtx.unk_74[1] == 50) { - func_8002F7DC(&GET_PLAYER(globalCtx)->actor, NA_SE_EV_CHICKEN_CRY_M); - globalCtx->roomCtx.unk_74[0] = 1; + if ((play->roomCtx.unk_74[0] == 0) && playerHasCojiro) { + if (play->roomCtx.unk_74[1] == 50) { + func_8002F7DC(&GET_PLAYER(play)->actor, NA_SE_EV_CHICKEN_CRY_M); + play->roomCtx.unk_74[0] = 1; } - globalCtx->roomCtx.unk_74[1]++; + play->roomCtx.unk_74[1]++; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 10 -void func_8009F074(GlobalContext* globalCtx) { +void func_8009F074(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - gameplayFrames % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - gameplayFrames % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -2169,7 +2169,7 @@ void func_8009F074(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* D_8012A380[] = { @@ -2178,28 +2178,28 @@ void* D_8012A380[] = { }; // Scene Draw Config 11 -void func_8009F1B4(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_8009F1B4(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); { s32 pad[2]; } gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380[gSaveContext.nightFlag])); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 12 -void func_8009F270(GlobalContext* globalCtx) { +void func_8009F270(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -2208,21 +2208,21 @@ void func_8009F270(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 13 -void func_8009F40C(GlobalContext* globalCtx) { +void func_8009F40C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 32)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -2231,14 +2231,14 @@ void func_8009F40C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 14 -void func_8009F5D4(GlobalContext* globalCtx) { - Gfx* displayListHead = Graph_Alloc(globalCtx->state.gfxCtx, 3 * sizeof(Gfx)); +void func_8009F5D4(PlayState* play) { + Gfx* displayListHead = Graph_Alloc(play->state.gfxCtx, 3 * sizeof(Gfx)); - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_XLU_DISP++, 0x08, displayListHead); @@ -2246,16 +2246,16 @@ void func_8009F5D4(GlobalContext* globalCtx) { gSPEndDisplayList(displayListHead); } else { if (gSaveContext.dayTime > 0xC000) { - if (globalCtx->roomCtx.unk_74[0] != 255) { - Math_StepToS(&globalCtx->roomCtx.unk_74[0], 255, 5); + if (play->roomCtx.unk_74[0] != 255) { + Math_StepToS(&play->roomCtx.unk_74[0], 255, 5); } } else if (gSaveContext.dayTime >= 0x4000) { - if (globalCtx->roomCtx.unk_74[0] != 0) { - Math_StepToS(&globalCtx->roomCtx.unk_74[0], 0, 10); + if (play->roomCtx.unk_74[0] != 0) { + Math_StepToS(&play->roomCtx.unk_74[0], 0, 10); } } - gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, globalCtx->roomCtx.unk_74[0]); + gDPSetPrimColor(displayListHead++, 0, 0, 255, 255, 255, play->roomCtx.unk_74[0]); gSPDisplayList(displayListHead++, spot16_room_0DL_00AA48); gSPEndDisplayList(displayListHead); } @@ -2266,23 +2266,23 @@ void func_8009F5D4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 15 -void func_8009F7D4(GlobalContext* globalCtx) { - s8 sp6F = coss((globalCtx->gameplayFrames * 1500) & 0xFFFF) >> 8; - s8 sp6E = coss((globalCtx->gameplayFrames * 1500) & 0xFFFF) >> 8; +void func_8009F7D4(PlayState* play) { + s8 sp6F = coss((play->gameplayFrames * 1500) & 0xFFFF) >> 8; + s8 sp6E = coss((play->gameplayFrames * 1500) & 0xFFFF) >> 8; u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; sp6F = (sp6F >> 1) + 192; sp6E = (sp6E >> 1) + 192; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -2291,7 +2291,7 @@ void func_8009F7D4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sGoronCityEntranceTextures[] = { @@ -2300,14 +2300,14 @@ void* sGoronCityEntranceTextures[] = { }; // Scene Draw Config 16 -void func_8009F9D0(GlobalContext* globalCtx) { +void func_8009F9D0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 127 - gameplayFrames % 128, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 127 - gameplayFrames % 128, 32, 32, 1, gameplayFrames % 128, 0, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -2320,7 +2320,7 @@ void func_8009F9D0(GlobalContext* globalCtx) { { s32 pad[2]; } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } void* sLonLonRanchWindowTextures[] = { @@ -2329,8 +2329,8 @@ void* sLonLonRanchWindowTextures[] = { }; // Scene Draw Config 17 -void func_8009FB74(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx); +void func_8009FB74(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx); { s32 pad[2]; } @@ -2342,21 +2342,21 @@ void func_8009FB74(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 18 -void func_8009FC90(GlobalContext* globalCtx) { +void func_8009FC90(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 127 - gameplayFrames % 128, 32, 32, 1, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 127 - gameplayFrames % 128, 32, 32, 1, 127 - gameplayFrames % 128, 0, 32, 32)); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 3) % 128, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, (gameplayFrames * 3) % 128, 127 - (gameplayFrames * 6) % 128, 32, 32, 1, (gameplayFrames * 6) % 128, 127 - (gameplayFrames * 3) % 128, 32, 32)); @@ -2366,30 +2366,30 @@ void func_8009FC90(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 64); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } f32 D_8012A398 = 0.0f; -void func_8009FE58(GlobalContext* globalCtx) { +void func_8009FE58(PlayState* play) { static s16 D_8012A39C = 538; static s16 D_8012A3A0 = 4272; u32 gameplayFrames; f32 temp; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; - if (globalCtx->sceneNum == SCENE_BDAN) { + gameplayFrames = play->gameplayFrames; + if (play->sceneNum == SCENE_BDAN) { gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames % 128, (gameplayFrames * 2) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, gameplayFrames % 128, (gameplayFrames * 2) % 128, 32, 32, 1, 127 - gameplayFrames % 128, (gameplayFrames * 2) % 128, 32, 32)); gSPSegment(POLY_OPA_DISP++, 0x0B, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 255 - (gameplayFrames * 4) % 256, 32, 64, 1, 0, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 255 - (gameplayFrames * 4) % 256, 32, 64, 1, 0, 255 - (gameplayFrames * 4) % 256, 32, 64)); } else { gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TexScroll(globalCtx->state.gfxCtx, (127 - (gameplayFrames * 1)) % 128, + Gfx_TexScroll(play->state.gfxCtx, (127 - (gameplayFrames * 1)) % 128, (gameplayFrames * 1) % 128, 32, 32)); } @@ -2399,75 +2399,75 @@ void func_8009FE58(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - if (FrameAdvance_IsEnabled(globalCtx) != true) { + if (FrameAdvance_IsEnabled(play) != true) { D_8012A39C += 1820; D_8012A3A0 += 1820; temp = 0.020000001f; - if (globalCtx->pauseCtx.state == 0) { - View_SetDistortionOrientation(&globalCtx->view, + if (play->pauseCtx.state == 0) { + View_SetDistortionOrientation(&play->view, ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_CosS(D_8012A39C), ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_SinS(D_8012A39C), ((360.00018f / 65535.0f) * (M_PI / 180.0f)) * temp * Math_SinS(D_8012A3A0)); - View_SetDistortionScale(&globalCtx->view, 1.f + (0.79999995f * temp * Math_SinS(D_8012A3A0)), + View_SetDistortionScale(&play->view, 1.f + (0.79999995f * temp * Math_SinS(D_8012A3A0)), 1.f + (0.39999998f * temp * Math_CosS(D_8012A3A0)), 1.f + (1 * temp * Math_CosS(D_8012A39C))); - View_SetDistortionSpeed(&globalCtx->view, 0.95f); + View_SetDistortionSpeed(&play->view, 0.95f); } - switch (globalCtx->roomCtx.unk_74[0]) { + switch (play->roomCtx.unk_74[0]) { case 0: break; case 1: - if (globalCtx->roomCtx.unk_74[1] < 1200) { - globalCtx->roomCtx.unk_74[1] += 200; + if (play->roomCtx.unk_74[1] < 1200) { + play->roomCtx.unk_74[1] += 200; } else { - globalCtx->roomCtx.unk_74[0]++; + play->roomCtx.unk_74[0]++; } break; case 2: - if (globalCtx->roomCtx.unk_74[1] > 0) { - globalCtx->roomCtx.unk_74[1] -= 30; + if (play->roomCtx.unk_74[1] > 0) { + play->roomCtx.unk_74[1] -= 30; } else { - globalCtx->roomCtx.unk_74[1] = 0; - globalCtx->roomCtx.unk_74[0] = 0; + play->roomCtx.unk_74[1] = 0; + play->roomCtx.unk_74[0] = 0; } break; } - if (globalCtx->pauseCtx.state == 0) { - D_8012A398 += 0.15f + (globalCtx->roomCtx.unk_74[1] * 0.001f); + if (play->pauseCtx.state == 0) { + D_8012A398 += 0.15f + (play->roomCtx.unk_74[1] * 0.001f); } } - if (globalCtx->roomCtx.curRoom.num == 2) { + if (play->roomCtx.curRoom.num == 2) { Matrix_Scale(1.0f, sinf(D_8012A398) * 0.8f, 1.0f, MTXMODE_NEW); } else { Matrix_Scale(1.005f, sinf(D_8012A398) * 0.8f, 1.005f, MTXMODE_NEW); } - gSPSegment(POLY_OPA_DISP++, 0x0D, MATRIX_NEWMTX(globalCtx->state.gfxCtx)); + gSPSegment(POLY_OPA_DISP++, 0x0D, MATRIX_NEWMTX(play->state.gfxCtx)); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 26 -void func_800A0334(GlobalContext* globalCtx) { +void func_800A0334(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 512, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 512, 32, 128, 1, gameplayFrames % 128, (gameplayFrames * 1) % 512, 32, 128)); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); @@ -2476,29 +2476,29 @@ void func_800A0334(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } // Scene Draw Config 52 -void func_800A055C(GlobalContext* globalCtx) { - func_8009BEEC(globalCtx); +void func_800A055C(PlayState* play) { + func_8009BEEC(play); } // Scene Draw Config 51 -void func_800A057C(GlobalContext* globalCtx) { - func_8009BEEC(globalCtx); +void func_800A057C(PlayState* play) { + func_8009BEEC(play); } // Scene Draw Config 49 -void func_800A059C(GlobalContext* globalCtx) { +void func_800A059C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TexScroll(globalCtx->state.gfxCtx, 127 - (gameplayFrames * 2) % 128, 0, 32, 64)); - gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 2) % 512, 128, 128)); + Gfx_TexScroll(play->state.gfxCtx, 127 - (gameplayFrames * 2) % 128, 0, 32, 64)); + gSPSegment(POLY_OPA_DISP++, 0x09, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 2) % 512, 128, 128)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -2506,10 +2506,10 @@ void func_800A059C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } -void (*sSceneDrawHandlers[])(GlobalContext*) = { +void (*sSceneDrawHandlers[])(PlayState*) = { func_80099550, func_8009DA30, func_8009DD5C, func_8009DE78, func_8009E0B8, func_8009E54C, func_8009E730, func_8009E8C0, func_8009EAD8, func_8009EE44, func_8009F074, func_8009F1B4, func_8009F270, func_8009F40C, func_8009F5D4, func_8009F7D4, func_8009F9D0, func_8009FB74, func_8009FC90, func_800995DC, func_80099878, @@ -2520,7 +2520,7 @@ void (*sSceneDrawHandlers[])(GlobalContext*) = { func_800A059C, func_8009CF84, func_800A057C, func_800A055C, }; -void Scene_Draw(GlobalContext* globalCtx) { +void Scene_Draw(PlayState* play) { if (HREG(80) == 17) { if (HREG(95) != 17) { HREG(95) = 17; @@ -2539,19 +2539,19 @@ void Scene_Draw(GlobalContext* globalCtx) { HREG(94) = 0; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); if (HREG(81) == 1) { gSPDisplayList(POLY_OPA_DISP++, sDefaultDisplayList); gSPDisplayList(POLY_XLU_DISP++, sDefaultDisplayList); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); if (HREG(82) == 1) { - sSceneDrawHandlers[globalCtx->sceneConfig](globalCtx); + sSceneDrawHandlers[play->sceneConfig](play); } } else { - sSceneDrawHandlers[globalCtx->sceneConfig](globalCtx); + sSceneDrawHandlers[play->sceneConfig](play); } } diff --git a/soh/src/code/z_skelanime.c b/soh/src/code/z_skelanime.c index cc969be45..ddfd99716 100644 --- a/soh/src/code/z_skelanime.c +++ b/soh/src/code/z_skelanime.c @@ -3,8 +3,8 @@ #define ANIM_INTERP 1 -s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime); -s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime); +s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime); +s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime); s32 SkelAnime_LoopFull(SkelAnime* skelAnime); s32 SkelAnime_Once(SkelAnime* skelAnime); s32 SkelAnime_LoopPartial(SkelAnime* skelAnime); @@ -18,14 +18,14 @@ static u32 sAnimQueueFlags; * Draw a limb of type `LodLimb` * Near or far display list is specified via `lod` */ -void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) { LodLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); limb = (LodLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]); @@ -38,36 +38,36 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele dList = limb->dLists[lod]; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dList); } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList, &rot, arg); + postLimbDraw(play, limbIndex, &dList, &rot, arg); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod); + SkelAnime_DrawLimbLod(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod); + SkelAnime_DrawLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw all limbs of type `LodLimb` in a given skeleton * Near or far display list is specified via `lod` */ -void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) { LodLimb* rootLimb; s32 pad; @@ -82,7 +82,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -94,32 +94,32 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa rot = jointTable[1]; dList = rootLimb->dLists[lod]; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dList); } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList, &rot, arg); + postLimbDraw(play, 1, &dList, &rot, arg); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod); } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw a limb of type `LodLimb` contained within a flexible skeleton * Near or far display list is specified via `lod` */ -void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod, Mtx** mtx) { LodLimb* limb; @@ -141,15 +141,15 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dLists[lod]; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { MATRIX_TOMTX(*mtx); { - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, newDList); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } (*mtx)++; } else if (limbDList != NULL) { @@ -158,17 +158,17 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, arg); + postLimbDraw(play, limbIndex, &limbDList, &rot, arg); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawFlexLimbLod(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod, mtx); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawFlexLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod, mtx); } } @@ -178,7 +178,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +void SkelAnime_DrawFlexLod(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) { LodLimb* rootLimb; s32 pad; @@ -186,7 +186,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); + Mtx* mtx = Graph_Alloc(play->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -195,7 +195,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0xD, mtx); Matrix_Push(); @@ -209,7 +209,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dLists[lod]; - if ((overrideLimbDraw == 0) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg)) { + if ((overrideLimbDraw == 0) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { MATRIX_TOMTX(mtx); @@ -224,29 +224,29 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, arg); + postLimbDraw(play, 1, &limbDList, &rot, arg); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawFlexLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod, &mtx); } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw a limb of type `StandardLimb` to the polyOpa buffer */ -void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) { StandardLimb* limb; Gfx* dList; Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); limb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]); @@ -257,34 +257,34 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele pos.z = limb->jointPos.z; dList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dList); } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList, &rot, arg); + postLimbDraw(play, limbIndex, &dList, &rot, arg); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg); + SkelAnime_DrawLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg); + SkelAnime_DrawLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer */ -void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) { StandardLimb* rootLimb; s32 pad; @@ -299,7 +299,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); rootLimb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]); @@ -311,31 +311,31 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa rot = jointTable[1]; dList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dList); } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList, &rot, arg); + postLimbDraw(play, 1, &dList, &rot, arg); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg); + SkelAnime_DrawLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg); } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** * Draw a limb of type `StandardLimb` contained within a flexible skeleton to the polyOpa buffer */ -void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, Mtx** limbMatricies) { StandardLimb* limb; @@ -344,7 +344,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); Matrix_Push(); @@ -358,7 +358,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { MATRIX_TOMTX(*limbMatricies); @@ -372,21 +372,21 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, arg); + postLimbDraw(play, limbIndex, &limbDList, &rot, arg); } if (limb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawFlexLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, limbMatricies); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawFlexLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, limbMatricies); } - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -394,7 +394,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +void SkelAnime_DrawFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) { StandardLimb* rootLimb; s32 pad; @@ -402,7 +402,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(Mtx)); + Mtx* mtx = Graph_Alloc(play->state.gfxCtx, dListCount * sizeof(Mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -411,7 +411,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi return; } - OPEN_DISPS(globalCtx->state.gfxCtx); + OPEN_DISPS(play->state.gfxCtx); gSPSegment(POLY_OPA_DISP++, 0xD, mtx); @@ -427,7 +427,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, arg)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { MATRIX_TOMTX(mtx); @@ -441,16 +441,16 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, arg); + postLimbDraw(play, 1, &limbDList, &rot, arg); } if (rootLimb->child != LIMB_DONE) { - SkelAnime_DrawFlexLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + SkelAnime_DrawFlexLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, &mtx); } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx); + CLOSE_DISPS(play->state.gfxCtx); } /** @@ -507,7 +507,7 @@ s16 Animation_GetLastFrame(void* animation) { /** * Draw a limb of type `StandardLimb` to the specified display buffer */ -Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +Gfx* SkelAnime_DrawLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx) { StandardLimb* limb; Gfx* dList; @@ -527,27 +527,27 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton dList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, arg, &gfx)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, arg, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfx++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(gfx++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(gfx++, dList); } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &dList, &rot, arg, &gfx); + postLimbDraw(play, limbIndex, &dList, &rot, arg, &gfx); } if (limb->child != LIMB_DONE) { gfx = - SkelAnime_DrawLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); + SkelAnime_DrawLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + gfx = SkelAnime_DrawLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); } @@ -557,7 +557,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton /** * Draw all limbs of type `StandardLimb` in a given skeleton to the specified display buffer */ -Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, +Gfx* SkelAnime_Draw(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx) { StandardLimb* rootLimb; s32 pad; @@ -585,20 +585,20 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable dList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, arg, &gfx)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, arg, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (dList != NULL) { - gSPMatrix(gfx++, MATRIX_NEWMTX(globalCtx->state.gfxCtx), G_MTX_LOAD); + gSPMatrix(gfx++, MATRIX_NEWMTX(play->state.gfxCtx), G_MTX_LOAD); gSPDisplayList(gfx++, dList); } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &dList, &rot, arg, &gfx); + postLimbDraw(play, 1, &dList, &rot, arg, &gfx); } if (rootLimb->child != LIMB_DONE) { - gfx = SkelAnime_DrawLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + gfx = SkelAnime_DrawLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); } @@ -610,7 +610,7 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable /** * Draw a limb of type `StandardLimb` contained within a flexible skeleton to the specified display buffer */ -Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable, +Gfx* SkelAnime_DrawFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Mtx** mtx, Gfx* gfx) { StandardLimb* limb; @@ -630,7 +630,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel pos.z = limb->jointPos.z; newDList = limbDList = limb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, arg, &gfx)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, arg, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { MATRIX_TOMTX(*mtx); @@ -643,17 +643,17 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, arg, &gfx); + postLimbDraw(play, limbIndex, &limbDList, &rot, arg, &gfx); } if (limb->child != LIMB_DONE) { - gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + gfx = SkelAnime_DrawFlexLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, mtx, gfx); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + gfx = SkelAnime_DrawFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, mtx, gfx); } @@ -665,7 +665,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel * Limbs in a flexible skeleton have meshes that can stretch to line up with other limbs. * An array of matrices is dynamically allocated so each limb can access any transform to ensure its meshes line up. */ -Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, +Gfx* SkelAnime_DrawFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* arg, Gfx* gfx) { StandardLimb* rootLimb; s32 pad; @@ -673,7 +673,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT Gfx* limbDList; Vec3f pos; Vec3s rot; - Mtx* mtx = Graph_Alloc(globalCtx->state.gfxCtx, dListCount * sizeof(*mtx)); + Mtx* mtx = Graph_Alloc(play->state.gfxCtx, dListCount * sizeof(*mtx)); if (skeleton == NULL) { osSyncPrintf(VT_FGCOL(RED)); @@ -695,7 +695,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT newDList = limbDList = rootLimb->dList; - if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, arg, &gfx)) { + if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, arg, &gfx)) { Matrix_TranslateRotateZYX(&pos, &rot); if (newDList != NULL) { MATRIX_TOMTX(mtx); @@ -708,10 +708,10 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT } } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, 1, &limbDList, &rot, arg, &gfx); + postLimbDraw(play, 1, &limbDList, &rot, arg, &gfx); } if (rootLimb->child != LIMB_DONE) { - gfx = SkelAnime_DrawFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, + gfx = SkelAnime_DrawFlexLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, &mtx, gfx); } @@ -815,14 +815,14 @@ void AnimationContext_Reset(AnimationContext* animationCtx) { /** * Shifts the queue flag to the next queue */ -void AnimationContext_SetNextQueue(GlobalContext* globalCtx) { +void AnimationContext_SetNextQueue(PlayState* play) { sAnimQueueFlags <<= 1; } /** * Disables the current animation queue. Only load and move actor requests will be processed for that queue. */ -void AnimationContext_DisableQueue(GlobalContext* globalCtx) { +void AnimationContext_DisableQueue(PlayState* play) { sDisableAnimQueueFlags |= sAnimQueueFlags; } @@ -843,7 +843,7 @@ AnimationEntry* AnimationContext_AddEntry(AnimationContext* animationCtx, Animat /** * Requests loading frame data from the Link animation into frameTable */ -void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader* animation, s32 frame, s32 limbCount, +void AnimationContext_SetLoadFrame(PlayState* play, LinkAnimationHeader* animation, s32 frame, s32 limbCount, Vec3s* frameTable) { if (CVar_GetS32("gN64WeirdFrames", 0) && frame < 0) { Vec3s* src = (Vec3s*)getN64WeirdFrame((sizeof(Vec3s) * limbCount + 2) * frame); @@ -851,7 +851,7 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader return; } - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_LOADFRAME); + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_LOADFRAME); if (entry != NULL) { @@ -891,8 +891,8 @@ void AnimationContext_SetLoadFrame(GlobalContext* globalCtx, LinkAnimationHeader /** * Requests copying all vectors from src frame table into dst frame table */ -void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYALL); +void AnimationContext_SetCopyAll(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYALL); if (entry != NULL) { entry->data.copy.queueFlag = sAnimQueueFlags; @@ -905,8 +905,8 @@ void AnimationContext_SetCopyAll(GlobalContext* globalCtx, s32 vecCount, Vec3s* /** * Requests interpolating between base and mod frame tables with the given weight, placing the result in base */ -void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_INTERP); +void AnimationContext_SetInterp(PlayState* play, s32 vecCount, Vec3s* base, Vec3s* mod, f32 weight) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_INTERP); if (entry != NULL) { entry->data.interp.queueFlag = sAnimQueueFlags; @@ -920,8 +920,8 @@ void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* b /** * Requests copying vectors from src frame table to dst frame table whose copy flag is true */ -void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYTRUE); +void AnimationContext_SetCopyTrue(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYTRUE); if (entry != NULL) { entry->data.copy1.queueFlag = sAnimQueueFlags; @@ -935,8 +935,8 @@ void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s* /** * Requests copying vectors from src frame table to dst frame table whose copy flag is false */ -void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_COPYFALSE); +void AnimationContext_SetCopyFalse(PlayState* play, s32 vecCount, Vec3s* dst, Vec3s* src, u8* copyFlag) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_COPYFALSE); if (entry != NULL) { entry->data.copy0.queueFlag = sAnimQueueFlags; @@ -950,8 +950,8 @@ void AnimationContext_SetCopyFalse(GlobalContext* globalCtx, s32 vecCount, Vec3s /** * Requests moving an actor according to the translation of its root limb */ -void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelAnime* skelAnime, f32 arg3) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_MOVEACTOR); +void AnimationContext_SetMoveActor(PlayState* play, Actor* actor, SkelAnime* skelAnime, f32 arg3) { + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_MOVEACTOR); if (entry != NULL) { entry->data.move.actor = actor; @@ -963,7 +963,7 @@ void AnimationContext_SetMoveActor(GlobalContext* globalCtx, Actor* actor, SkelA /** * Receives the request for Link's animation frame data */ -void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_LoadFrame(PlayState* play, AnimationEntryData* data) { AnimEntryLoadFrame* entry = &data->load; osRecvMesg(&entry->msgQueue, NULL, OS_MESG_BLOCK); @@ -972,7 +972,7 @@ void AnimationContext_LoadFrame(GlobalContext* globalCtx, AnimationEntryData* da /** * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table */ -void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_CopyAll(PlayState* play, AnimationEntryData* data) { AnimEntryCopyAll* entry = &data->copy; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -989,7 +989,7 @@ void AnimationContext_CopyAll(GlobalContext* globalCtx, AnimationEntryData* data /** * If the entry's queue is enabled, interpolates between the base and mod frame tables, placing the result in base */ -void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_Interp(PlayState* play, AnimationEntryData* data) { AnimEntryInterp* entry = &data->interp; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1000,7 +1000,7 @@ void AnimationContext_Interp(GlobalContext* globalCtx, AnimationEntryData* data) /** * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is true */ -void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_CopyTrue(PlayState* play, AnimationEntryData* data) { AnimEntryCopyTrue* entry = &data->copy1; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1020,7 +1020,7 @@ void AnimationContext_CopyTrue(GlobalContext* globalCtx, AnimationEntryData* dat /** * If the entry's queue is enabled, copies all vectors from src frame table to dst frame table whose copy flag is false */ -void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_CopyFalse(PlayState* play, AnimationEntryData* data) { AnimEntryCopyFalse* entry = &data->copy0; if (!(entry->queueFlag & sDisableAnimQueueFlags)) { @@ -1040,7 +1040,7 @@ void AnimationContext_CopyFalse(GlobalContext* globalCtx, AnimationEntryData* da /** * Moves an actor according to the translation of its root limb */ -void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* data) { +void AnimationContext_MoveActor(PlayState* play, AnimationEntryData* data) { AnimEntryMoveActor* entry = &data->move; Actor* actor = entry->actor; Vec3f diff; @@ -1054,7 +1054,7 @@ void AnimationContext_MoveActor(GlobalContext* globalCtx, AnimationEntryData* da /** * Performs all requests in the animation queue, then resets the queue flags. */ -void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animationCtx) { +void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx) { static AnimationEntryCallback animFuncs[] = { AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp, AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor, @@ -1062,7 +1062,7 @@ void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animati AnimationEntry* entry; for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { - animFuncs[entry->type](globalCtx, &entry->data); + animFuncs[entry->type](play, &entry->data); } sAnimQueueFlags = 1; @@ -1073,7 +1073,7 @@ void AnimationContext_Update(GlobalContext* globalCtx, AnimationContext* animati * Initializes a skeleton to be used with Link animations to a looping animation, dynamically allocating the frame * tables if not given. */ -void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, +void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, LinkAnimationHeader* animation, s32 flags, Vec3s* jointTable, Vec3s* morphTable, s32 limbBufCount) { if (ResourceMgr_OTRSigCheck(skeletonHeaderSeg) != 0) @@ -1121,7 +1121,7 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel osSyncPrintf(VT_RST); } - LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); + LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, 0.0f); } /** @@ -1140,15 +1140,15 @@ void LinkAnimation_SetUpdateFunction(SkelAnime* skelAnime) { * Advances the current Link animation and updates all frame tables. If the animation plays once, returns true when it * finishes. */ -s32 LinkAnimation_Update(GlobalContext* globalCtx, SkelAnime* skelAnime) { - return skelAnime->update(globalCtx, skelAnime); +s32 LinkAnimation_Update(PlayState* play, SkelAnime* skelAnime) { + return skelAnime->update(play, skelAnime); } /** * Requests an interpolation between the pose in jointTable to the one in morphTable, advancing the morph but not the * animation frame */ -s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { +s32 LinkAnimation_Morph(PlayState* play, SkelAnime* skelAnime) { f32 prevMorphWeight = skelAnime->morphWeight; f32 updateRate = R_UPDATE_RATE * 0.5f; @@ -1158,7 +1158,7 @@ s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { LinkAnimation_SetUpdateFunction(skelAnime); } - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, 1.0f - (skelAnime->morphWeight / prevMorphWeight)); return 0; } @@ -1167,8 +1167,8 @@ s32 LinkAnimation_Morph(GlobalContext* globalCtx, SkelAnime* skelAnime) { * Requests a load of the next frame of a Link animation, advances the morph, and requests an interpolation between * jointTable and morphTable */ -void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetLoadFrame(globalCtx, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, +void LinkAnimation_AnimateFrame(PlayState* play, SkelAnime* skelAnime) { + AnimationContext_SetLoadFrame(play, skelAnime->animation, skelAnime->curFrame, skelAnime->limbCount, skelAnime->jointTable); if (skelAnime->morphWeight != 0) { f32 updateRate = R_UPDATE_RATE * 0.5f; @@ -1177,7 +1177,7 @@ void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) if (skelAnime->morphWeight <= 0.0f) { skelAnime->morphWeight = 0.0f; } else { - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, skelAnime->morphWeight); } } @@ -1186,7 +1186,7 @@ void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime) /** * Advances a Link animation that loops over its full length */ -s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime) { +s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime) { f32 updateRate = R_UPDATE_RATE * 0.5f; skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1195,18 +1195,18 @@ s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime) { } else if (skelAnime->animLength <= skelAnime->curFrame) { skelAnime->curFrame -= skelAnime->animLength; } - LinkAnimation_AnimateFrame(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(play, skelAnime); return 0; } /** * Advances a Link animation that stops at endFrame and returns true when it is reached. */ -s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime) { +s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime) { f32 updateRate = R_UPDATE_RATE * 0.5f; if (skelAnime->curFrame == skelAnime->endFrame) { - LinkAnimation_AnimateFrame(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(play, skelAnime); return 1; } skelAnime->curFrame += skelAnime->playSpeed * updateRate; @@ -1217,14 +1217,14 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime) { } else if (skelAnime->animLength <= skelAnime->curFrame) { skelAnime->curFrame -= skelAnime->animLength; } - LinkAnimation_AnimateFrame(globalCtx, skelAnime); + LinkAnimation_AnimateFrame(play, skelAnime); return 0; } /** * Sets a new morph and resets the morph weight for the current animation. */ -void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morphFrames) { +void Animation_SetMorph(PlayState* play, SkelAnime* skelAnime, f32 morphFrames) { skelAnime->morphWeight = 1.0f; skelAnime->morphRate = 1.0f / morphFrames; } @@ -1235,7 +1235,7 @@ void Animation_SetMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 morp * animation, then start the new animation. Negative morph frames start the new animation immediately, modified by the * pose immediately before the animation change. */ -void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, +void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed, f32 startFrame, f32 endFrame, u8 mode, f32 morphFrames) { LinkAnimationHeader* ogAnim = animation; @@ -1254,14 +1254,14 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn morphFrames = -morphFrames; } else { skelAnime->update = LinkAnimation_Morph; - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, + AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->morphTable); } skelAnime->morphWeight = 1.0f; skelAnime->morphRate = 1.0f / morphFrames; } else { LinkAnimation_SetUpdateFunction(skelAnime); - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)startFrame, skelAnime->limbCount, + AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->jointTable); skelAnime->morphWeight = 0.0f; } @@ -1278,105 +1278,105 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn /** * Immediately changes to a Link animation that plays once at the default speed. */ -void LinkAnimation_PlayOnce(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation) { - LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, +void LinkAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) { + LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); } /** * Immediately changes to a Link animation that plays once at the specified speed. */ -void LinkAnimation_PlayOnceSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, +void LinkAnimation_PlayOnceSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed) { - LinkAnimation_Change(globalCtx, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(animation), + LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_ONCE, 0.0f); } /** * Immediately changes to a Link animation that loops at the default speed. */ -void LinkAnimation_PlayLoop(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation) { - LinkAnimation_Change(globalCtx, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, +void LinkAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) { + LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, 0.0f); } /** * Immediately changes to a Link animation that loops at the specified speed. */ -void LinkAnimation_PlayLoopSetSpeed(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, +void LinkAnimation_PlayLoopSetSpeed(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed) { - LinkAnimation_Change(globalCtx, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(animation), + LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(animation), ANIMMODE_LOOP, 0.0f); } /** * Requests copying jointTable to morphTable */ -void LinkAnimation_CopyJointToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetCopyAll(globalCtx, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); +void LinkAnimation_CopyJointToMorph(PlayState* play, SkelAnime* skelAnime) { + AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->morphTable, skelAnime->jointTable); } /** * Requests copying morphTable to jointTable * unused */ -void LinkAnimation_CopyMorphToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime) { - AnimationContext_SetCopyAll(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); +void LinkAnimation_CopyMorphToJoint(PlayState* play, SkelAnime* skelAnime) { + AnimationContext_SetCopyAll(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable); } /** * Requests loading frame data from the Link animation into morphTable */ -void LinkAnimation_LoadToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, +void LinkAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); + AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); } /** * Requests loading frame data from the Link animation into jointTable */ -void LinkAnimation_LoadToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, +void LinkAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); + AnimationContext_SetLoadFrame(play, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); } /** * Requests interpolating between jointTable and morphTable, placing the result in jointTable */ -void LinkAnimation_InterpJointMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, f32 weight) { - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); +void LinkAnimation_InterpJointMorph(PlayState* play, SkelAnime* skelAnime, f32 weight) { + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, skelAnime->morphTable, weight); } /** * Requests loading frame data from the Link animations and blending them, placing the result in jointTable */ -void LinkAnimation_BlendToJoint(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, +void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable) { Vec3s* alignedBlendTable; - AnimationContext_SetLoadFrame(globalCtx, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); + AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); alignedBlendTable = (Vec3s*)ALIGN16((uintptr_t)blendTable); - AnimationContext_SetLoadFrame(globalCtx, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); + AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); } /** * Requests loading frame data from the Link animations and blending them, placing the result in morphTable */ -void LinkAnimation_BlendToMorph(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation1, +void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation1, f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, Vec3s* blendTable) { Vec3s* alignedBlendTable; - AnimationContext_SetLoadFrame(globalCtx, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); + AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); alignedBlendTable = (Vec3s*)ALIGN16((uintptr_t)blendTable); - AnimationContext_SetLoadFrame(globalCtx, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); - AnimationContext_SetInterp(globalCtx, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); + AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); + AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); } /** @@ -1426,7 +1426,7 @@ s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) { /** * Initializes a normal skeleton to a looping animation, dynamically allocating the frame tables if not provided. */ -s32 SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +s32 SkelAnime_Init(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { if (ResourceMgr_OTRSigCheck(skeletonHeaderSeg)) skeletonHeaderSeg = ResourceMgr_LoadSkeletonByName(skeletonHeaderSeg); @@ -1459,7 +1459,7 @@ s32 SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeade /** * Initializes a flex skeleton to a looping animation, dynamically allocating the frame tables if not given. */ -s32 SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, +s32 SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { if (ResourceMgr_OTRSigCheck(skeletonHeaderSeg) != 0) skeletonHeaderSeg = ResourceMgr_LoadSkeletonByName(skeletonHeaderSeg); @@ -1496,7 +1496,7 @@ s32 SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkele /** * Initializes a skeleton with SkinLimbs to a looping animation, dynamically allocating the frame tables. */ -s32 SkelAnime_InitSkin(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, +s32 SkelAnime_InitSkin(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation) { if (ResourceMgr_OTRSigCheck(skeletonHeaderSeg) != 0) animation = ResourceMgr_LoadAnimByName(skeletonHeaderSeg); @@ -1909,7 +1909,7 @@ s32 Animation_OnFrame(SkelAnime* skelAnime, f32 frame) { /** * Frees the frame tables for a skelAnime with dynamically allocated tables. */ -void SkelAnime_Free(SkelAnime* skelAnime, GlobalContext* globalCtx) { +void SkelAnime_Free(SkelAnime* skelAnime, PlayState* play) { if (skelAnime->jointTable != NULL) { ZELDA_ARENA_FREE_DEBUG(skelAnime->jointTable); } else { diff --git a/soh/src/code/z_skin.c b/soh/src/code/z_skin.c index bd5f2288c..c8d0ce8df 100644 --- a/soh/src/code/z_skin.c +++ b/soh/src/code/z_skin.c @@ -185,12 +185,12 @@ void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dlis CLOSE_DISPS(gfxCtx); } -void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void Skin_DrawImpl(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { s32 i; s32 segmentType; SkinLimb** skeleton; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; s32 pad; OPEN_DISPS(gfxCtx); @@ -218,7 +218,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD s32 shouldDraw = true; if (overrideLimbDraw != NULL) { - shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin); + shouldDraw = overrideLimbDraw(actor, play, i, skin); } segmentType = ((SkinLimb*)SEGMENTED_TO_VIRTUAL(skeleton[i]))->segmentType; @@ -231,7 +231,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD } if (postDraw != NULL) { - postDraw(actor, globalCtx, skin); + postDraw(actor, play, skin); } close_disps: @@ -239,26 +239,26 @@ close_disps: } // allows specifying PostLimbDraw and setTranslation -void func_800A6330(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0); +void func_800A6330(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) { + Skin_DrawImpl(actor, play, skin, postDraw, NULL, setTranslation, false, 0); } // allows specifying OverrideLimbDraw, PostLimbDraw and setTranslation -void func_800A6360(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void func_800A6360(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); + Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, false, 0); } // allows specifying OverrideLimbDraw, PostLimbDraw, setTranslation, and arg6 -void func_800A6394(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void func_800A6394(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); + Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, arg6, 0); } // allows specifying all variables -void func_800A63CC(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, +void func_800A63CC(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) { - Skin_DrawImpl(actor, globalCtx, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); + Skin_DrawImpl(actor, play, skin, postDraw, overrideLimbDraw, setTranslation, arg6, drawFlags); } void Skin_GetLimbPos(Skin* skin, s32 limbIndex, Vec3f* offset, Vec3f* dst) { diff --git a/soh/src/code/z_skin_awb.c b/soh/src/code/z_skin_awb.c index 81f4bcbab..f3a2e6390 100644 --- a/soh/src/code/z_skin_awb.c +++ b/soh/src/code/z_skin_awb.c @@ -4,7 +4,7 @@ /** * Initialises the Vtx buffers used for limb at index `limbIndex` */ -void Skin_InitAnimatedLimb(GlobalContext* globalCtx, Skin* skin, s32 limbIndex) { +void Skin_InitAnimatedLimb(PlayState* play, Skin* skin, s32 limbIndex) { s32 i; SkinLimb** skeleton = SEGMENTED_TO_VIRTUAL(skin->skeletonHeader->segment); SkinAnimatedLimbData* animatedLimbData = @@ -36,7 +36,7 @@ void Skin_InitAnimatedLimb(GlobalContext* globalCtx, Skin* skin, s32 limbIndex) * Initializes a skin skeleton to looping animation, dynamically allocating the frame tables, * and dynamically allocating and initializing the Vtx and SkinLimbVtx buffers for its animated limbs */ -void Skin_Init(GlobalContext* globalCtx, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader) { +void Skin_Init(PlayState* play, Skin* skin, SkeletonHeader* skeletonHeader, AnimationHeader* animationHeader) { if (ResourceMgr_OTRSigCheck(skeletonHeader)) skeletonHeader = ResourceMgr_LoadSkeletonByName(skeletonHeader); @@ -77,17 +77,17 @@ void Skin_Init(GlobalContext* globalCtx, Skin* skin, SkeletonHeader* skeletonHea ZELDA_ARENA_MALLOC_DEBUG(animatedLimbData->totalVtxCount * sizeof(Vtx)); ASSERT(vtxEntry->buf[1] != NULL); - Skin_InitAnimatedLimb(globalCtx, skin, i); + Skin_InitAnimatedLimb(play, skin, i); } } - SkelAnime_InitSkin(globalCtx, &skin->skelAnime, skeletonHeader, animationHeader); + SkelAnime_InitSkin(play, &skin->skelAnime, skeletonHeader, animationHeader); } /** * Frees the dynamically allocated Vtx and SkinLimbVtx buffers and tables */ -void Skin_Free(GlobalContext* globalCtx, Skin* skin) { +void Skin_Free(PlayState* play, Skin* skin) { if (skin->vtxTable != NULL) { s32 i; @@ -106,7 +106,7 @@ void Skin_Free(GlobalContext* globalCtx, Skin* skin) { ZELDA_ARENA_FREE_DEBUG(skin->vtxTable); } - SkelAnime_Free(&skin->skelAnime, globalCtx); + SkelAnime_Free(&skin->skelAnime, play); } } diff --git a/soh/src/code/z_sound_source.c b/soh/src/code/z_sound_source.c index ce54ee393..16e3fee5b 100644 --- a/soh/src/code/z_sound_source.c +++ b/soh/src/code/z_sound_source.c @@ -1,24 +1,24 @@ #include "global.h" -void SoundSource_InitAll(GlobalContext* globalCtx) { - SoundSource* sources = &globalCtx->soundSources[0]; +void SoundSource_InitAll(PlayState* play) { + SoundSource* sources = &play->soundSources[0]; s32 i; // clang-format off - for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { sources[i].countdown = 0; } + for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { sources[i].countdown = 0; } // clang-format on } -void SoundSource_UpdateAll(GlobalContext* globalCtx) { - SoundSource* source = &globalCtx->soundSources[0]; +void SoundSource_UpdateAll(PlayState* play) { + SoundSource* source = &play->soundSources[0]; s32 i; - for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { if (source->countdown != 0) { if (DECR(source->countdown) == 0) { Audio_StopSfxByPos(&source->projectedPos); } else { - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos); + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos); } } @@ -26,15 +26,15 @@ void SoundSource_UpdateAll(GlobalContext* globalCtx) { } } -void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, s32 duration, u16 sfxId) { +void SoundSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, s32 duration, u16 sfxId) { s32 countdown; SoundSource* source; s32 smallestCountdown = 0xFFFF; SoundSource* backupSource; s32 i; - source = &globalCtx->soundSources[0]; - for (i = 0; i < ARRAY_COUNT(globalCtx->soundSources); i++) { + source = &play->soundSources[0]; + for (i = 0; i < ARRAY_COUNT(play->soundSources); i++) { if (source->countdown == 0) { break; } @@ -49,7 +49,7 @@ void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPo } // If no sound source is available, replace the sound source with the smallest remaining countdown - if (i >= ARRAY_COUNT(globalCtx->soundSources)) { + if (i >= ARRAY_COUNT(play->soundSources)) { source = backupSource; Audio_StopSfxByPos(&source->projectedPos); } @@ -57,6 +57,6 @@ void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPo source->worldPos = *worldPos; source->countdown = duration; - SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos); + SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos); Audio_PlaySoundGeneral(sfxId, &source->projectedPos, 4, &D_801333E0, &D_801333E0, &D_801333E8); } diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index b43515386..a2017ce9a 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -32,7 +32,7 @@ void Sram_InitDebugSave(void) { // RANDOTODO replace most of these GiveLink functions with calls to // Item_Give in z_parameter, we'll need to update Item_Give to ensure -// nothing breaks when calling it without a valid globalCtx first +// nothing breaks when calling it without a valid play first void GiveLinkRupees(int numOfRupees) { int maxRupeeCount; if (CUR_UPG_VALUE(UPG_WALLET) == 0) { diff --git a/soh/src/code/z_vr_box.c b/soh/src/code/z_vr_box.c index 6a3ebb1dd..70e6fe31d 100644 --- a/soh/src/code/z_vr_box.c +++ b/soh/src/code/z_vr_box.c @@ -592,7 +592,7 @@ SkyboxTableEntry sSkyboxTable[] = }, }; -void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyboxId) { +void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { size_t size; s16 i; u8 sp41; // imageIdx @@ -613,16 +613,16 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox if (gSaveContext.skyboxTime >= D_8011FC1C[phi_v1][i].startTime && (gSaveContext.skyboxTime < D_8011FC1C[phi_v1][i].endTime || D_8011FC1C[phi_v1][i].endTime == 0xFFFF)) { - globalCtx->envCtx.skybox1Index = sp41 = D_8011FC1C[phi_v1][i].skybox1Index; - globalCtx->envCtx.skybox2Index = sp40 = D_8011FC1C[phi_v1][i].skybox2Index; + play->envCtx.skybox1Index = sp41 = D_8011FC1C[phi_v1][i].skybox1Index; + play->envCtx.skybox2Index = sp40 = D_8011FC1C[phi_v1][i].skybox2Index; if (D_8011FC1C[phi_v1][i].blend != 0) { - globalCtx->envCtx.skyboxBlend = + play->envCtx.skyboxBlend = Environment_LerpWeight(D_8011FC1C[phi_v1][i].endTime, D_8011FC1C[phi_v1][i].startTime, ((void)0, gSaveContext.skyboxTime)) * 255.0f; } else { - globalCtx->envCtx.skyboxBlend = 0; + play->envCtx.skyboxBlend = 0; } break; } @@ -944,13 +944,13 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox } void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) { - GlobalContext* globalCtx = (GlobalContext*)state; + PlayState* play = (PlayState*)state; skyboxCtx->skyboxId = skyboxId; skyboxCtx->unk_140 = 0; skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f; - Skybox_Setup(globalCtx, skyboxCtx, skyboxId); + Skybox_Setup(play, skyboxCtx, skyboxId); osSyncPrintf("\n\n\n********************\n\n\n" "TYPE=%d" "\n\n\n********************\n\n\n", |
