diff options
Diffstat (limited to 'src/code')
57 files changed, 4783 insertions, 4939 deletions
diff --git a/src/code/code_80043480.c b/src/code/code_80043480.c index eda615d35..3ba733e26 100644 --- a/src/code/code_80043480.c +++ b/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/src/code/code_8006C3A0.c b/src/code/code_8006C3A0.c index 928b13443..8943d8b93 100644 --- a/src/code/code_8006C3A0.c +++ b/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 < ARRAY_COUNT(globalCtx->envFlags); i++) { - globalCtx->envFlags[i] = 0; + for (i = 0; i < ARRAY_COUNT(play->envFlags); i++) { + 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/src/code/code_80097A00.c b/src/code/code_80097A00.c index bf9d205fa..68c51e7e2 100644 --- a/src/code/code_80097A00.c +++ b/src/code/code_80097A00.c @@ -229,8 +229,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 equipValue = gSaveContext.equips.equipment & gEquipMasks[equipment]; @@ -252,8 +252,8 @@ u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) { gSaveContext.infTable[INFTABLE_1DX_INDEX] = 1; } - Player_SetEquipmentData(globalCtx, player); - globalCtx->pauseCtx.cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; + Player_SetEquipmentData(play, player); + play->pauseCtx.cursorSpecialPos = PAUSE_CURSOR_PAGE_LEFT; } return equipValue; diff --git a/src/code/db_camera.c b/src/code/db_camera.c index d48c416a6..1e5564a31 100644 --- a/src/code/db_camera.c +++ b/src/code/db_camera.c @@ -1,7 +1,7 @@ #include "ultra64.h" #include "global.h" -static GlobalContext* sGlobalCtx; +static PlayState* sPlay; // TODO: cleanup these arrays and UB access char* D_8012CEE0[] = { GFXP_KATAKANA "キ-フレ-ム" GFXP_HIRAGANA "ガ" }; @@ -346,7 +346,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(sPlay->state.input[2].press.button, BTN_CRIGHT)) { sDbCamAnim.keyframe = 0; sDbCamAnim.unk_0A = 1; sDbCamAnim.curFrame = 0.0f; @@ -522,7 +522,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; + sPlay = cameraPtr->play; dbCamera->sub.mode = 0; dbCamera->sub.nFrames = -1; dbCamera->sub.nPoints = 1; @@ -597,7 +597,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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->state.input[2].cur.button, (BTN_DRIGHT | BTN_L)) || + CHECK_BTN_ALL(sPlay->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(sPlay->state.input[2].cur.button, (BTN_DLEFT | BTN_L)) || + CHECK_BTN_ALL(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->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(sPlay->state.input[2].cur.button, BTN_R)) { if (dbCamera->unk_00 == 0) { dbCamera->sub.unk_104A = cam->inputDir; *sp7C = cam->at; @@ -932,13 +932,13 @@ 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(sPlay->state.input[2].press.button, BTN_R) && + CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); 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(sPlay->state.input[2].press.button, BTN_R)) { if (dbCamera->sub.unkIdx == 0x80) { Audio_PlaySoundGeneral(NA_SE_SY_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -955,8 +955,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 = sPlay->state.input[2].rel.stick_y; + temp_f2_2 = sPlay->state.input[2].rel.stick_x; pitch = CAM_DEG_TO_BINANG((SQ(temp_f0_5) / 600.0f) * 0.8f); yaw = CAM_DEG_TO_BINANG((SQ(temp_f2_2) / 600.0f) * 0.8f); if (!D_80161144) { @@ -977,7 +977,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { DbCamera_CalcUpFromPitchYawRoll(&dbCamera->unk_1C, spF4.pitch, spF4.yaw, CAM_DEG_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(sPlay->state.input[2].cur.button, BTN_CRIGHT)) { cam->inputDir = dbCamera->sub.unk_104A; new_var2 = OLib_Vec3fDist(&cam->at, &cam->eye); cam->at = *sp7C; @@ -991,12 +991,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(sPlay->state.input[2].cur.button, BTN_CRIGHT) && + !CHECK_BTN_ALL(sPlay->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(sPlay->state.input[2].press.button, BTN_CRIGHT) && + CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); osSyncPrintf("@@@\n@@@\n@@@/* *** spline point data ** start here *** */\n@@@\n"); @@ -1006,14 +1006,14 @@ 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(sPlay->state.input[2].press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); 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(sPlay->state.input[2].press.button, BTN_CUP) && + CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.unkIdx > 0) { @@ -1022,7 +1022,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(sPlay->state.input[2].press.button, BTN_CUP)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.unkIdx > 0) { @@ -1043,8 +1043,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(sPlay->state.input[2].cur.button, BTN_L) && + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CDOWN)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) { @@ -1053,7 +1053,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(sPlay->state.input[2].press.button, BTN_CDOWN)) { Audio_PlaySoundGeneral(NA_SE_IT_SWORD_IMPACT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.unkIdx < (dbCamera->sub.nPoints - 1)) { @@ -1123,7 +1123,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(sPlay->state.input[2].press.button, BTN_DUP)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.unk_0A == 0) { @@ -1132,7 +1132,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(sPlay->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.unk_0A == 5) { @@ -1141,12 +1141,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(sPlay->state.input[2].press.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); switch (dbCamera->sub.unk_0A) { case 1: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame -= 5; } else { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame--; @@ -1178,7 +1178,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(sPlay->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 { @@ -1190,7 +1190,7 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_DLEFT)) { if ((D_8012D10C++ % 5) == 0) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, @@ -1199,7 +1199,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(sPlay->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 { @@ -1208,7 +1208,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(sPlay->state.input[2].cur.button, BTN_L)) { dbCamera->sub.nFrames -= 10; } else { dbCamera->sub.nFrames--; @@ -1230,13 +1230,13 @@ void DbCamera_Update(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); switch (dbCamera->sub.unk_0A) { case 1: - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame += 5; } else { dbCamera->sub.lookAt[dbCamera->sub.unkIdx].nextPointFrame++; @@ -1267,7 +1267,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(sPlay->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 { @@ -1278,7 +1278,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(sPlay->state.input[2].cur.button, BTN_DRIGHT)) { if ((D_8012D10C++ % 5) == 0) { Audio_PlaySoundGeneral(NA_SE_SY_ATTENTION_ON, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, @@ -1287,7 +1287,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(sPlay->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 { @@ -1296,7 +1296,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(sPlay->state.input[2].cur.button, BTN_L)) { dbCamera->sub.nFrames += 10; } else { dbCamera->sub.nFrames++; @@ -1398,11 +1398,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) { @@ -1416,14 +1416,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); } } } @@ -1433,7 +1433,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(sPlay->state.input[2].press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->unk_78 = (dbCamera->unk_78 + 1) % 3; @@ -1482,18 +1482,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); } } @@ -1862,8 +1862,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(sPlay->state.input[2].press.button, BTN_DLEFT) || + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlToggleSwitch ^= 1; @@ -1876,7 +1876,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(sPlay->state.input[2].press.button, BTN_A)) { if (dbCamera->sub.demoCtrlToggleSwitch == 0) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1898,7 +1898,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(sPlay->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlMenu = 0; @@ -1934,8 +1934,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(sPlay->state.input[2].press.button, BTN_A) || + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (dbCamera->sub.demoCtrlMenu == DEMO_CTRL_MENU(ACTION_LOAD, MENU_SUCCESS)) { @@ -1957,8 +1957,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(sPlay->state.input[2].press.button, BTN_A) || + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlMenu -= 9; @@ -1993,7 +1993,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(sPlay->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (sCurFileIdx >= 4) { @@ -2010,7 +2010,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(sPlay->state.input[2].press.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (sCurFileIdx <= 0) { @@ -2053,24 +2053,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(sPlay->state.input[2].press.button, BTN_DUP)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx - 1) % 4u; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DDOWN)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlActionIdx = (dbCamera->sub.demoCtrlActionIdx + 1) % 4u; } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_A)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_A)) { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); 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(sPlay->state.input[2].press.button, BTN_B)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlActionIdx = ACTION_E; @@ -2080,9 +2080,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(sPlay->state.input[2].press.button, BTN_B) || + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DUP) || + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -2096,14 +2096,14 @@ 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(sPlay->state.input[2].press.button, BTN_DUP)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); 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(sPlay->state.input[2].press.button, BTN_DDOWN)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); dbCamera->sub.demoCtrlMenu = DEMO_CTRL_MENU(ACTION_E, MENU_INFO); @@ -2117,7 +2117,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(sPlay->state.input[2].press.button, BTN_CUP)) { if (D_8016110C > 0) { D_8016110C--; } @@ -2125,7 +2125,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(sPlay->state.input[2].press.button, BTN_CDOWN)) { if (D_8016110C < 14) { D_8016110C++; } @@ -2133,7 +2133,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(sPlay->state.input[2].press.button, BTN_CLEFT)) { sDbCamAnim.unk_0A = 0; Interface_ChangeAlpha(2); ShrinkWindow_SetVal(0); @@ -2153,7 +2153,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(sPlay->state.input[1].press.button, BTN_CRIGHT)) { D_8015FCC8 = 0; gSaveContext.cutsceneIndex = 0xFFFD; gSaveContext.cutsceneTrigger = 1; @@ -2167,7 +2167,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_L)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_L)) { if (sp74[sCurFileIdx] == '?') { sLastFileIdx = -1; D_801612EA = '*'; @@ -2176,7 +2176,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { D_801612EA = sDbCameraCuts[idx1].letter; } if (1) {} - } else if (!CHECK_BTN_ALL(sGlobalCtx->state.input[2].cur.button, BTN_L)) { + } else if (!CHECK_BTN_ALL(sPlay->state.input[2].cur.button, BTN_L)) { if (sLastFileIdx != -1) { switch (sp74[sCurFileIdx]) { case '?': @@ -2218,7 +2218,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(sPlay->state.input[2].press.button, BTN_A)) { if (sp74[sCurFileIdx] == '?') { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -2229,7 +2229,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_B)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_B)) { if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') { Audio_PlaySoundGeneral(NA_SE_SY_CANCEL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -2238,7 +2238,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_R)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_R)) { if (sp74[sCurFileIdx] != '?' && sp74[sCurFileIdx] != '-') { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -2262,7 +2262,7 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DRIGHT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); if (sCurFileIdx == 0x1E) { @@ -2271,22 +2271,22 @@ s32 DbCamera_UpdateDemoControl(DbCamera* dbCamera, Camera* cam) { sCurFileIdx++; } } - if (CHECK_BTN_ALL(sGlobalCtx->state.input[2].press.button, BTN_DLEFT)) { + if (CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_DLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); 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(sPlay->state.input[2].cur.button, BTN_L) && + CHECK_BTN_ALL(sPlay->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(sPlay->state.input[2].cur.button, BTN_L) && + CHECK_BTN_ALL(sPlay->state.input[2].press.button, BTN_CLEFT)) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); for (i = 0; i < ARRAY_COUNT(sDbCameraCuts) - 1; i++) { @@ -2295,7 +2295,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(sPlay->state.input[2].press.button, BTN_CRIGHT)) { sDbCamAnim.curFrame = 0.0f; sDbCamAnim.keyframe = 0; sDbCamAnim.unk_04 = 0.0f; diff --git a/src/code/flg_set.c b/src/code/flg_set.c index 55850d5b0..8d7814cfa 100644 --- a/src/code/flg_set.c +++ b/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, "../flg_set.c", 241); diff --git a/src/code/sys_math3d.c b/src/code/sys_math3d.c index 12b59fb5c..7b409ce09 100644 --- a/src/code/sys_math3d.c +++ b/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/src/code/z_actor.c b/src/code/z_actor.c index 6a5560d6b..4a45d50ab 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -17,7 +17,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; @@ -26,7 +26,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, "../z_actor.c", 1553); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 1553); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -53,35 +53,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, "../z_actor.c", 1588), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 1588), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 1594); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 1594); } } } -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, "../z_actor.c", 1661); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 1661); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u32)(((arg3 * 0.00005f) > 1.0f ? 1.0f : (arg3 * 0.00005f)) * arg4) & 0xFF); @@ -93,14 +93,13 @@ 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, "../z_actor.c", 1687), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 1687), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 1693); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 1693); } -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) { @@ -111,7 +110,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; } @@ -133,7 +132,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx Vec3f* feetPosPtr = actor->shape.feetPos; f32* floorHeightPtr = floorHeight; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 1741); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 1741); POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C); @@ -143,7 +142,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.feetFloorFlag <<= 1; distToFloor = feetPosPtr->y - *floorHeightPtr; @@ -166,7 +165,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); } } @@ -179,7 +178,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); } } @@ -202,7 +201,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 1831); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 1831); } } @@ -215,8 +214,8 @@ void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* lef } } -void Actor_ProjectPos(GlobalContext* globalCtx, Vec3f* src, Vec3f* xyzDest, f32* cappedInvWDest) { - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, src, xyzDest, cappedInvWDest); +void Actor_ProjectPos(PlayState* play, Vec3f* src, Vec3f* xyzDest, f32* cappedInvWDest) { + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, src, xyzDest, cappedInvWDest); *cappedInvWDest = (*cappedInvWDest < 1.0f) ? 1.0f : (1.0f / *cappedInvWDest); } @@ -247,12 +246,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; @@ -268,7 +267,7 @@ void func_8002BE98(TargetContext* targetCtx, s32 actorCategory, GlobalContext* g } } -void Actor_SetNaviToActor(TargetContext* targetCtx, Actor* actor, s32 actorCategory, GlobalContext* globalCtx) { +void Actor_SetNaviToActor(TargetContext* targetCtx, Actor* actor, s32 actorCategory, PlayState* play) { NaviColor* naviColor = &sNaviColorList[actorCategory]; targetCtx->naviRefPos.x = actor->focus.pos.x; targetCtx->naviRefPos.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y); @@ -283,7 +282,7 @@ void Actor_SetNaviToActor(TargetContext* targetCtx, Actor* actor, s32 actorCateg 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; @@ -291,14 +290,14 @@ void func_8002C0C0(TargetContext* targetCtx, Actor* actor, GlobalContext* global targetCtx->bgmEnemy = NULL; targetCtx->unk_4B = 0; targetCtx->unk_4C = 0; - Actor_SetNaviToActor(targetCtx, actor, actor->category, globalCtx); - func_8002BE98(targetCtx, actor->category, globalCtx); + Actor_SetNaviToActor(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, "../z_actor.c", 2029); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2029); if (targetCtx->unk_48 != 0) { TargetContextEntry* entry; @@ -314,7 +313,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { f32 var2; s32 i; - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); spCE = 0xFF; var1 = 1.0f; @@ -336,7 +335,7 @@ void func_8002C124(TargetContext* targetCtx, GlobalContext* globalCtx) { spCE = targetCtx->unk_48; } - Actor_ProjectPos(globalCtx, &targetCtx->targetCenterPos, &projTargetCenter, &projTargetCappedInvW); + Actor_ProjectPos(play, &targetCtx->targetCenterPos, &projTargetCenter, &projTargetCappedInvW); projTargetCenter.x = (160 * (projTargetCenter.x * projTargetCappedInvW)) * var1; projTargetCenter.x = CLAMP(projTargetCenter.x, -320.0f, 320.0f); @@ -377,7 +376,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, "../z_actor.c", 2116), + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 2116), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL); Matrix_Pop(); @@ -400,19 +399,19 @@ 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(BINANG_TO_RAD((u16)(globalCtx->gameplayFrames * 3000)), MTXMODE_APPLY); + Matrix_RotateY(BINANG_TO_RAD((u16)(play->gameplayFrames * 3000)), 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, "../z_actor.c", 2153), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 2153), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 2158); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 2158); } -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; @@ -431,7 +430,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; } @@ -467,11 +466,11 @@ void func_8002C7BC(TargetContext* targetCtx, Player* player, Actor* actorArg, Gl targetCtx->naviRefPos.y += temp3 * temp1; targetCtx->naviRefPos.z += temp4 * temp1; } else { - Actor_SetNaviToActor(targetCtx, unkActor, actorCategory, globalCtx); + Actor_SetNaviToActor(targetCtx, unkActor, actorCategory, play); } if ((actorArg != NULL) && (targetCtx->unk_4B == 0)) { - Actor_ProjectPos(globalCtx, &actorArg->focus.pos, &projectedFocusPos, &cappedInvWDest); + Actor_ProjectPos(play, &actorArg->focus.pos, &projectedFocusPos, &cappedInvWDest); if (((projectedFocusPos.z <= 0.0f) || (1.0f <= fabsf(projectedFocusPos.x * cappedInvWDest))) || (1.0f <= fabsf(projectedFocusPos.y * cappedInvWDest))) { actorArg = NULL; @@ -480,7 +479,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) { @@ -515,154 +514,154 @@ 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 TitleCard_Init(GlobalContext* globalCtx, TitleCardContext* titleCtx) { +void TitleCard_Init(PlayState* play, TitleCardContext* titleCtx) { titleCtx->durationTimer = titleCtx->delayTimer = titleCtx->intensity = 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) { titleCtx->texture = texture; titleCtx->x = x; @@ -673,9 +672,9 @@ void TitleCard_InitBossName(GlobalContext* globalCtx, TitleCardContext* titleCtx titleCtx->delayTimer = 0; } -void TitleCard_InitPlaceName(GlobalContext* globalCtx, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, - s32 width, s32 height, s32 delay) { - SceneTableEntry* loadedScene = globalCtx->loadedScene; +void TitleCard_InitPlaceName(PlayState* play, TitleCardContext* titleCtx, void* texture, s32 x, s32 y, s32 width, + s32 height, s32 delay) { + SceneTableEntry* loadedScene = play->loadedScene; u32 size = loadedScene->titleFile.vromEnd - loadedScene->titleFile.vromStart; if ((size != 0) && (size <= 0x3000)) { @@ -691,7 +690,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) { if (DECR(titleCtx->delayTimer) == 0) { if (DECR(titleCtx->durationTimer) == 0) { Math_StepToS(&titleCtx->alpha, 0, 30); @@ -703,7 +702,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; @@ -720,7 +719,7 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { titleY = (titleCtx->y * 4) - (height * 2); doubleWidth = width * 2; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 2824); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 2824); textureLanguageOffset = width * height * gSaveContext.language; height = (width * height > 0x1000) ? 0x1000 / width : height; @@ -750,12 +749,12 @@ void TitleCard_Draw(GlobalContext* globalCtx, TitleCardContext* titleCtx) { titleSecondY + (height * 4) - 1, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 2880); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 2880); } } -s32 TitleCard_Clear(GlobalContext* globalCtx, TitleCardContext* titleCtx) { - if ((globalCtx->actorCtx.titleCtx.delayTimer != 0) || (globalCtx->actorCtx.titleCtx.alpha != 0)) { +s32 TitleCard_Clear(PlayState* play, TitleCardContext* titleCtx) { + if ((play->actorCtx.titleCtx.delayTimer != 0) || (play->actorCtx.titleCtx.alpha != 0)) { titleCtx->durationTimer = 0; titleCtx->delayTimer = 0; return false; @@ -798,11 +797,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); @@ -818,19 +817,19 @@ 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)) { - Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + 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; @@ -979,26 +978,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 & PLAYER_STATE1_11) || 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 & PLAYER_STATE2_3; } -s32 func_8002DDF4(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +s32 func_8002DDF4(PlayState* play) { + Player* player = GET_PLAYER(play); return player->stateFlags2 & PLAYER_STATE2_12; } -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; @@ -1008,13 +1007,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(Play_GetCamera(globalCtx, CAM_ID_MAIN), 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, CAM_ID_MAIN), 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 |= PLAYER_STATE1_23; horse->child = &player->actor; @@ -1024,12 +1023,12 @@ s32 func_8002DEEC(Player* player) { return (player->stateFlags1 & (PLAYER_STATE1_7 | PLAYER_STATE1_29)) || (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; @@ -1038,10 +1037,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; @@ -1061,8 +1060,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) { @@ -1169,14 +1168,13 @@ 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); + actor->floorHeight = BgCheck_EntityRaycastFloor5(play, &play->colCtx, &actor->floorPoly, &floorBgId, actor, arg2); actor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_GROUND_STRICT); if (actor->floorHeight <= BGCHECK_Y_MIN) { @@ -1212,11 +1210,11 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3) } actor->bgCheckFlags |= BGCHECKFLAG_GROUND; - func_80043334(&globalCtx->colCtx, actor, actor->floorBgId); + func_80043334(&play->colCtx, actor, actor->floorBgId); } } else { // actor is above ground if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND) && (floorHeightDiff >= -11.0f)) { - func_80043334(&globalCtx->colCtx, actor, actor->floorBgId); + func_80043334(&play->colCtx, actor, actor->floorBgId); } return func_8002E234(actor, floorHeightDiff, arg3); @@ -1225,7 +1223,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; @@ -1240,15 +1238,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 & BGCHECKFLAG_GROUND)) { - func_800433A4(&globalCtx->colCtx, actor->floorBgId, actor); + func_800433A4(&play->colCtx, actor->floorBgId, actor); } if (flags & UPDBGCHECKINFO_FLAG_0) { if ((!(flags & UPDBGCHECKINFO_FLAG_7) && - 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 & UPDBGCHECKINFO_FLAG_7) && - 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); @@ -1265,7 +1263,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe if (flags & UPDBGCHECKINFO_FLAG_1) { 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 |= BGCHECKFLAG_CEILING; actor->world.pos.y = (sp58 + sp74) - 10.0f; @@ -1276,10 +1274,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe if (flags & UPDBGCHECKINFO_FLAG_2) { 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, - &waterBoxYSurface, &waterBox)) { + 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) { actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH); @@ -1290,9 +1288,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 |= BGCHECKFLAG_WATER; @@ -1356,60 +1354,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, "../z_actor.c", 4384); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 4384); gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); gSPEndDisplayList(displayListHead); gSPSegment(POLY_OPA_DISP++, 0x07, displayList); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 4394); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 4394); } } -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, "../z_actor.c", 4429); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 4429); gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10); gSPEndDisplayList(displayListHead); gSPSegment(POLY_XLU_DISP++, 0x07, displayList); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 4439); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 4439); } } @@ -1497,7 +1495,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; @@ -1506,11 +1504,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)))) { @@ -1524,44 +1522,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 cappedInvW; - Actor_ProjectPos(globalCtx, &actor->focus.pos, &projectedPos, &cappedInvW); + Actor_ProjectPos(play, &actor->focus.pos, &projectedPos, &cappedInvW); *x = projectedPos.x * cappedInvW * (SCREEN_WIDTH / 2) + (SCREEN_WIDTH / 2); *y = projectedPos.y * cappedInvW * -(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 { @@ -1569,8 +1567,8 @@ u32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) { } } -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 & (PLAYER_STATE1_7 | PLAYER_STATE1_12 | PLAYER_STATE1_13 | PLAYER_STATE1_14 | PLAYER_STATE1_18 | PLAYER_STATE1_19 | PLAYER_STATE1_20 | PLAYER_STATE1_21)) && @@ -1595,15 +1593,15 @@ s32 func_8002F434(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzR return false; } -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 { @@ -1611,7 +1609,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) { @@ -1626,15 +1624,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 { @@ -1642,8 +1640,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 & (PLAYER_STATE1_7 | PLAYER_STATE1_11 | PLAYER_STATE1_12 | PLAYER_STATE1_13 | PLAYER_STATE1_14 | @@ -1656,7 +1654,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 { @@ -1664,8 +1662,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; @@ -1674,20 +1672,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) { @@ -1699,7 +1697,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 & BGCHECKFLAG_WATER) { @@ -1709,7 +1707,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); @@ -1752,10 +1750,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; } @@ -1769,7 +1767,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) { @@ -1796,16 +1794,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, "../z_actor.c", 5308); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 5308); params = gSaveContext.respawn[RESPAWN_MODE_TOP].data; @@ -1860,8 +1858,8 @@ 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, - &effectEnvCol, 1000, 16); + EffectSsKiraKira_SpawnDispersed(play, &effectPos, &effectVel, &effectAccel, &effectPrimCol, &effectEnvCol, + 1000, 16); if (D_8015BC18 == 0.0f) { gSaveContext.respawn[RESPAWN_MODE_TOP] = gSaveContext.respawn[RESPAWN_MODE_DOWN]; @@ -1879,9 +1877,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); @@ -1905,10 +1903,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); @@ -1917,22 +1915,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(BINANG_TO_RAD_ALT2((globalCtx->gameplayFrames * 1500) & 0xFFFF), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 5458), + Matrix_RotateZ(BINANG_TO_RAD_ALT2((play->gameplayFrames * 1500) & 0xFFFF), MTXMODE_APPLY); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 5458), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); Matrix_Pop(); - Matrix_RotateZ(BINANG_TO_RAD_ALT2(~((globalCtx->gameplayFrames * 1200) & 0xFFFF)), MTXMODE_APPLY); + Matrix_RotateZ(BINANG_TO_RAD_ALT2(~((play->gameplayFrames * 1200) & 0xFFFF)), MTXMODE_APPLY); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_actor.c", 5463), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 5463), G_MTX_MODELVIEW | G_MTX_LOAD | G_MTX_NOPUSH); gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } @@ -1941,34 +1939,34 @@ void Actor_DrawFaroresWindPointer(GlobalContext* globalCtx) { ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y) + yOffset, ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z), 255, 255, 255, lightRadius); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 5474); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 5474); } } -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]; bzero(actorCtx, 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++) { @@ -1982,13 +1980,13 @@ void func_800304DC(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorCtx->flags.clear = savedSceneFlags->clear; actorCtx->flags.collect = savedSceneFlags->collect; - TitleCard_Init(globalCtx, &actorCtx->titleCtx); + TitleCard_Init(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] = { @@ -2006,7 +2004,7 @@ u32 D_80116068[ACTORCAT_MAX] = { PLAYER_STATE1_6 | PLAYER_STATE1_7 | PLAYER_STATE1_28, }; -void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { +void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) { Actor* refActor; Actor* actor; Player* player; @@ -2017,7 +2015,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 @@ -2027,12 +2025,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) { @@ -2040,10 +2038,10 @@ 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, - refActor->world.pos.y + 100.0f, refActor->world.pos.z, 0, 0, 0, 1); + 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); } sp80 = &D_80116068[0]; @@ -2068,13 +2066,13 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { actor->sfx = 0; if (actor->init != NULL) { - if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { - Actor_SetObjectDependency(globalCtx, actor); - actor->init(actor, globalCtx); + if (Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) { + 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)) || @@ -2084,9 +2082,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 { @@ -2109,12 +2107,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); @@ -2124,7 +2122,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (i == ACTORCAT_BG) { - DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); + DynaPoly_Setup(play, &play->colCtx.dyna); } } @@ -2143,9 +2141,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) { @@ -2170,34 +2168,34 @@ 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"); - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 6035); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 6035); - 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); 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 }; @@ -2211,27 +2209,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, "../z_actor.c", 6119); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 6119); Fault_RemoveClient(&faultClient); } @@ -2276,12 +2274,12 @@ void Actor_DrawLensOverlay(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_actor.c", 6183); } -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, "../z_actor.c", 6197); @@ -2289,7 +2287,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 | @@ -2332,13 +2330,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)" @@ -2362,11 +2360,11 @@ void Actor_DrawLensActors(GlobalContext* globalCtx, s32 numInvisibleActors, Acto CLOSE_DISPS(gfxCtx, "../z_actor.c", 6284); } -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 ((arg2->z > -actor->uncullZoneScale) && (arg2->z < (actor->uncullZoneForward + actor->uncullZoneScale))) { @@ -2382,7 +2380,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; @@ -2391,7 +2389,7 @@ void func_800315AC(GlobalContext* globalCtx, ActorContext* actorCtx) { invisibleActorCounter = 0; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 6336); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 6336); actorListEntry = &actorCtx->actorLists[0]; @@ -2408,7 +2406,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); } @@ -2419,7 +2417,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; @@ -2431,15 +2429,15 @@ 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, "invisible_actor_counter < INVISIBLE_ACTOR_MAX", "../z_actor.c", 6464); 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; } } @@ -2451,47 +2449,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, "../z_actor.c", 6563); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 6563); } -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; @@ -2501,7 +2499,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; @@ -2514,20 +2512,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 { @@ -2536,21 +2534,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; } } @@ -2564,8 +2562,8 @@ void func_80031C3C(ActorContext* actorCtx, GlobalContext* globalCtx) { actorCtx->absoluteSpace = NULL; } - Play_SaveSceneFlags(globalCtx); - func_80030488(globalCtx); + Play_SaveSceneFlags(play); + func_80030488(play); ActorOverlayTable_Cleanup(); } @@ -2594,7 +2592,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--; @@ -2615,9 +2613,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; @@ -2658,8 +2656,8 @@ void Actor_FreeOverlay(ActorOverlay* actorOverlay) { osSyncPrintf(VT_RST); } -Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ, - s16 rotX, s16 rotY, s16 rotZ, s16 params) { +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; ActorInit* actorInit; @@ -2742,10 +2740,10 @@ 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) || - ((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); @@ -2788,7 +2786,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; @@ -2800,15 +2798,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, - 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* 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, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params); if (spawnedActor == NULL) { return NULL; @@ -2824,46 +2822,46 @@ 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) { - return Actor_Spawn(actorCtx, globalCtx, actorEntry->id, actorEntry->pos.x, actorEntry->pos.y, actorEntry->pos.z, +Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play) { + return 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); } -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 : ""; @@ -2874,7 +2872,7 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC if ((player != NULL) && (actor == player->unk_664)) { func_8008EDF0(player); - Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0); + Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), 0); } if (actor == actorCtx->targetCtx.arrowPointedActor) { @@ -2890,9 +2888,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); ZeldaArena_FreeDebug(actor, "../z_actor.c", 7242); @@ -2910,11 +2908,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); } @@ -2926,7 +2924,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; @@ -2950,10 +2948,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, - &sp80, 1, 1, 1, 1, &sp7C) || - SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C))) { + 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(&play->colCtx, sp80, sp7C))) { if (actor->targetPriority != 0) { if (actor->targetPriority < D_8015BBF8) { D_8015BBEC = actor; @@ -2976,7 +2974,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; @@ -2984,20 +2982,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++; } } @@ -3032,9 +3030,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) { @@ -3066,7 +3064,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; @@ -3107,9 +3105,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]); @@ -3130,7 +3128,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; @@ -3154,8 +3152,8 @@ 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, - mtx->yw, mtx->zw, 0, 0, objBankIndex, type); + spawnedEnPart = (EnPart*)Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, mtx->xw, mtx->yw, + mtx->zw, 0, 0, objBankIndex, type); if (spawnedEnPart != NULL) { Matrix_MtxFToYXZRotS(&bodyBreak->matrices[bodyBreak->count], &spawnedEnPart->actor.shape.rot, 0); @@ -3175,7 +3173,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 }; @@ -3194,12 +3192,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); } } @@ -3207,7 +3205,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 }; @@ -3225,14 +3223,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; @@ -3241,8 +3239,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)) { @@ -3263,8 +3261,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); } @@ -3275,7 +3273,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; @@ -3284,7 +3282,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; @@ -3322,10 +3320,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: @@ -3405,7 +3403,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; @@ -3420,7 +3418,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, UPDBGCHECKINFO_FLAG_2); + Actor_UpdateBgCheckInfo(play, actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); Math_Vec3f_Copy(&actor->world.pos, &prevActorPos); @@ -3433,8 +3431,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 & PLAYER_STATE1_4) && actor->isTargeted) { return true; @@ -3446,8 +3444,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 & PLAYER_STATE1_4) && !actor->isTargeted) { return true; @@ -3472,13 +3470,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, "../z_actor.c", 8120); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 8120); if (0) {} // Necessary to match @@ -3490,7 +3488,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); @@ -3501,37 +3499,36 @@ 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, "../z_actor.c", 8149), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 8149), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8155); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8155); } -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) { @@ -3562,7 +3559,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; @@ -3574,7 +3571,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) { entry = &sDoorLocksInfo[type]; chainRotZ = entry->chainsRotZInit; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8265); + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 8265); Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY); Matrix_Get(&baseMtxF); @@ -3591,7 +3588,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, "../z_actor.c", 8299), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 8299), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, entry->chainDL); @@ -3607,15 +3604,14 @@ 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, "../z_actor.c", 8314), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_actor.c", 8314), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, entry->lockDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8319); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8319); } -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) { @@ -3627,52 +3623,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; } @@ -3851,45 +3847,45 @@ Gfx* func_80034B54(GraphicsContext* gfxCtx) { return displayList; } -void func_80034BA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, - PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8831); +void func_80034BA0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, + Actor* actor, s16 alpha) { + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 8831); - 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, "../z_actor.c", 8860); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8860); } -void func_80034CC4(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, - PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_actor.c", 8876); +void func_80034CC4(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, + Actor* actor, s16 alpha) { + OPEN_DISPS(play->state.gfxCtx, "../z_actor.c", 8876); - 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, "../z_actor.c", 8904); + CLOSE_DISPS(play->state.gfxCtx, "../z_actor.c", 8904); } -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); } @@ -3920,8 +3916,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++) { @@ -3930,15 +3926,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 & BGCHECKFLAG_GROUND)) { Actor_MoveForward(actor); @@ -3947,18 +3943,18 @@ 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->colChkInfo.cylRadius, + play, actor, actor->colChkInfo.cylHeight, actor->colChkInfo.cylRadius, actor->colChkInfo.cylRadius, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); return ret; @@ -3966,8 +3962,8 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) { #include "z_cheap_proc.c" -u8 func_800353E8(GlobalContext* globalCtx) { - Player* player = GET_PLAYER(globalCtx); +u8 func_800353E8(PlayState* play) { + Player* player = GET_PLAYER(play); return player->unk_845; } @@ -3977,8 +3973,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))) { @@ -3995,8 +3991,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; @@ -4011,7 +4007,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; @@ -4024,7 +4020,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 }; @@ -4037,12 +4033,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->meleeWeaponState != 0) && (player->meleeWeaponAnimation == PLAYER_MWA_HAMMER_FORWARD)) { @@ -4140,13 +4136,12 @@ 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) { +Actor* func_800358DC(Actor* actor, Vec3f* spawnPos, Vec3s* spawnRot, f32* arg3, s32 timer, s16* unused, PlayState* play, + s16 params, s32 arg8) { EnPart* spawnedEnPart; - spawnedEnPart = - (EnPart*)Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, spawnPos->x, spawnPos->y, - spawnPos->z, spawnRot->x, spawnRot->y, actor->objBankIndex, params); + spawnedEnPart = (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; spawnedEnPart->actor.speedXZ = arg3[0]; @@ -4192,8 +4187,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; } @@ -4225,7 +4220,7 @@ void Flags_SetInfTable(s32 flag) { SET_INFTABLE(flag); } -u32 func_80035BFC(GlobalContext* globalCtx, s16 arg1) { +u32 func_80035BFC(PlayState* play, s16 arg1) { u16 retTextId = 0; switch (arg1) { @@ -4515,7 +4510,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(INFTABLE_6A)) { retTextId = 0x7004; @@ -5224,24 +5219,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(INFTABLE_2A)) { - 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(INFTABLE_2B)) { - func_80035B18(globalCtx, actor, 0x1037); + func_80035B18(play, actor, 0x1037); } else { - func_80035B18(globalCtx, actor, 0x1041); + func_80035B18(play, actor, 0x1041); } } ret = 0; @@ -5249,58 +5244,58 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { case 0x1038: if (msgCtx->choiceIndex == 0) { if (Flags_GetInfTable(INFTABLE_2E)) { - 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(INFTABLE_2F)) { - 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(INFTABLE_30)) { - 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(INFTABLE_2A); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x1037); + func_80035B18(play, actor, 0x1037); Flags_SetInfTable(INFTABLE_2B); } } if (msgCtx->choiceTextId == 0x1038) { if (msgCtx->choiceIndex == 0) { - func_80035B18(globalCtx, actor, 0x1039); + func_80035B18(play, actor, 0x1039); Flags_SetInfTable(INFTABLE_2E); } if (msgCtx->choiceIndex == 1) { - func_80035B18(globalCtx, actor, 0x103A); + func_80035B18(play, actor, 0x103A); Flags_SetInfTable(INFTABLE_2F); } if (msgCtx->choiceIndex == 2) { - func_80035B18(globalCtx, actor, 0x103B); + func_80035B18(play, actor, 0x103B); Flags_SetInfTable(INFTABLE_30); } } @@ -5308,10 +5303,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; @@ -5319,14 +5314,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(INFTABLE_9A); ret = 0; @@ -5334,10 +5329,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; @@ -5346,7 +5341,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; @@ -5354,14 +5349,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(EVENTCHKINF_12)) { break; } - func_80035B18(globalCtx, actor, 0x2044); + func_80035B18(play, actor, 0x2044); ret = 0; break; case 0x205A: @@ -5369,52 +5364,52 @@ s32 func_800374E0(GlobalContext* globalCtx, Actor* actor, u16 textId) { case 0x300A: if (msgCtx->choiceIndex == 0) { if (Flags_GetEventChkInf(EVENTCHKINF_22)) { - 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(INFTABLE_113)) { - 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; } @@ -5422,31 +5417,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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); msgCtx->msgMode = MSGMODE_TEXT_CLOSING; @@ -5458,25 +5453,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 (0) {} // Necessary to match @@ -5496,12 +5491,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); } } @@ -5540,8 +5535,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; @@ -5550,8 +5545,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 == ENTR_SPOT04_0))) { + if (!(((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) && (gSaveContext.entranceIndex == ENTR_SPOT04_0))) { var = actor->yawTowardsPlayer - actor->shape.rot.y; abs_var = ABS(var); if (abs_var >= 0x4300) { @@ -5560,9 +5554,8 @@ s32 func_80038154(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar } } - if (((globalCtx->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) && - (gSaveContext.entranceIndex == ENTR_SPOT04_0)) { - sp2C = globalCtx->view.eye; + if (((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) && (gSaveContext.entranceIndex == ENTR_SPOT04_0)) { + sp2C = play->view.eye; } else { sp2C = player->actor.focus.pos; } @@ -5572,8 +5565,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; @@ -5581,8 +5574,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 == ENTR_SPOT04_0))) { + if (!(((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) && (gSaveContext.entranceIndex == ENTR_SPOT04_0))) { var = actor->yawTowardsPlayer - actor->shape.rot.y; abs_var = ABS(var); if (abs_var >= 0x4300) { @@ -5591,9 +5583,8 @@ s32 func_80038290(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, Vec3s* ar } } - if (((globalCtx->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) && - (gSaveContext.entranceIndex == ENTR_SPOT04_0)) { - sp24 = globalCtx->view.eye; + if (((play->csCtx.state != CS_STATE_IDLE) || gDbgCamEnabled) && (gSaveContext.entranceIndex == ENTR_SPOT04_0)) { + sp24 = play->view.eye; } else { sp24 = player->actor.focus.pos; } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index f3a11e896..4d871982f 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -93,7 +93,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; } @@ -101,8 +101,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, "psst->tbl != NULL", "../z_bgcheck.c", 1811); @@ -1344,7 +1344,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; @@ -1428,7 +1428,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, @@ -1437,7 +1437,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; } } @@ -1491,7 +1491,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 }, @@ -1512,7 +1512,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; @@ -1527,7 +1527,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); @@ -1538,7 +1538,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; @@ -1551,7 +1551,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; @@ -1566,7 +1566,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) { LogUtils_HungupThread("../z_bgcheck.c", 4176); @@ -1599,15 +1599,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); } /** @@ -1650,7 +1650,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; @@ -1695,7 +1695,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; @@ -1735,11 +1735,10 @@ 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, - Vec3f* pos) { +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); } /** @@ -1763,9 +1762,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); } /** @@ -2412,14 +2411,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->short_slist_node_tbl != NULL", "../z_bgcheck.c", 5975); - this->polyCheckTbl = GameState_Alloc(&globalCtx->state, numPolys, "../z_bgcheck.c", 5979); + this->polyCheckTbl = GameState_Alloc(&play->state, numPolys, "../z_bgcheck.c", 5979); ASSERT(this->polyCheckTbl != NULL, "this->polygon_check != NULL", "../z_bgcheck.c", 5981); } @@ -2506,7 +2505,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); @@ -2549,8 +2548,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, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6247); } @@ -2564,15 +2563,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, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6277); } /** * Update BgActor's prevTransform */ -void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor) { +void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) { bgActor->prevTransform = bgActor->curTransform; } @@ -2589,39 +2588,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, - CollisionHeader* colHeader) { +s32 DynaPoly_SetBgActor(PlayState* play, DynaCollisionContext* dyna, Actor* actor, CollisionHeader* colHeader) { s32 bgId; s32 foundSlot = false; @@ -2662,28 +2660,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; @@ -2693,7 +2691,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)); @@ -2718,7 +2716,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; @@ -2727,14 +2725,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; @@ -2915,13 +2913,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; @@ -2933,7 +2931,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; @@ -2953,7 +2951,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) { @@ -2961,14 +2959,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; } } @@ -2976,7 +2974,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; @@ -2985,12 +2983,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]); } } } @@ -3129,10 +3127,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; @@ -3787,7 +3785,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; @@ -3795,7 +3793,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); } } @@ -4173,9 +4171,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; @@ -4183,7 +4181,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); } /** @@ -4191,7 +4189,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; @@ -4204,7 +4202,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) { @@ -4225,7 +4223,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; @@ -4242,7 +4240,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) { @@ -4302,8 +4300,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, - WaterBox** outWaterBox) { +s32 func_800425B0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) { CollisionHeader* colHeader = colCtx->colHeader; u32 room; WaterBox* curWaterBox; @@ -4315,7 +4312,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)) { @@ -4371,8 +4368,8 @@ 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, - SSList* ssList, u8 r, u8 g, u8 b) { +void BgCheck_DrawDynaPolyList(PlayState* play, CollisionContext* colCtx, DynaCollisionContext* dyna, SSList* ssList, + u8 r, u8 g, u8 b) { s16 curPolyId; CollisionPoly* poly; SSNode* curNode; @@ -4405,7 +4402,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; } @@ -4418,25 +4415,23 @@ 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, - 0, 0); + 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, - 0); + 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, - 255); + BgCheck_DrawDynaPolyList(play, colCtx, &colCtx->dyna, &colCtx->dyna.bgActors[bgId].dynaLookup.floor, 0, 0, 255); } } /** * 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++) { @@ -4444,14 +4439,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; @@ -4476,13 +4471,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; @@ -4491,7 +4486,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; } @@ -4503,17 +4498,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/src/code/z_camera.c b/src/code/z_camera.c index f7b675c35..7e8abdda2 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -215,7 +215,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; @@ -278,7 +278,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; @@ -363,7 +363,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) && @@ -382,7 +382,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 @@ -418,7 +418,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; @@ -453,14 +453,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); } /** @@ -473,9 +473,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; @@ -496,13 +496,12 @@ 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) == - BGCHECK_Y_MIN) { + 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); } /** @@ -519,8 +518,8 @@ 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, - waterY, &waterBox)) { + 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; return -1; @@ -532,8 +531,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 index, or no CameraSettingType return -2; } @@ -554,8 +553,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, - &waterBox)) { + 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; } @@ -566,7 +564,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; } @@ -608,7 +606,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); @@ -1638,7 +1636,7 @@ s32 Camera_Normal1(Camera* camera) { } // crit wiggle - 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; } @@ -1805,7 +1803,7 @@ s32 Camera_Normal2(Camera* camera) { if (camera->status == CAM_STAT_ACTIVE) { bgChk.pos = *eyeNext; - if (!camera->globalCtx->envCtx.skyboxDisabled || roData->interfaceFlags & 0x10) { + if (!camera->play->envCtx.skyboxDisabled || roData->interfaceFlags & 0x10) { Camera_BGCheckInfo(camera, at, &bgChk); *eye = bgChk.pos; } else { @@ -2140,7 +2138,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 || roData->interfaceFlags & 0x10) { + if (!camera->play->envCtx.skyboxDisabled || roData->interfaceFlags & 0x10) { Camera_BGCheckInfo(camera, at, &sp6C); *eye = sp6C.pos; } else { @@ -2950,7 +2948,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 || roData->flags & 1) { + if (!camera->play->envCtx.skyboxDisabled || roData->flags & 1) { Camera_BGCheckInfo(camera, at, &spBC); } else if (roData->flags & 2) { func_80043F94(camera, at, &spBC); @@ -3277,7 +3275,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 || roData->interfaceFlags & 1) { + if (!camera->play->envCtx.skyboxDisabled || roData->interfaceFlags & 1) { Camera_BGCheckInfo(camera, at, &sp8C); } else if (roData->interfaceFlags & 2) { func_80043F94(camera, at, &sp8C); @@ -3343,9 +3341,9 @@ s32 Camera_KeepOn3(Camera* camera) { return 1; } if (RELOAD_PARAMS(camera)) { - if (camera->globalCtx->view.unk_124 == 0) { + if (camera->play->view.unk_124 == 0) { camera->unk_14C |= 0x20; - camera->globalCtx->view.unk_124 = camera->camId | 0x50; + camera->play->view.unk_124 = camera->camId | 0x50; return 1; } camera->unk_14C &= ~0x20; @@ -3433,7 +3431,7 @@ s32 Camera_KeepOn3(Camera* camera) { Camera_Vec3fVecSphGeoAdd(&lineChkPointB, &rwData->atTarget, &atToEyeAdj); if (!(roData->flags & 0x80)) { while (i < angleCnt) { - if (!CollisionCheck_LineOCCheck(camera->globalCtx, &camera->globalCtx->colChkCtx, &rwData->atTarget, + if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &rwData->atTarget, &lineChkPointB, colChkActors, 2) && !Camera_BGCheck(camera, &rwData->atTarget, &lineChkPointB)) { break; @@ -3517,15 +3515,15 @@ s32 Camera_KeepOn4(Camera* camera) { KeepOn4ReadWriteData* rwData = &camera->paramData.keep4.rwData; s32 pad; f32 playerHeight; - Player* player = GET_PLAYER(camera->globalCtx); + Player* player = GET_PLAYER(camera->play); s16 angleCnt; s32 i; if (RELOAD_PARAMS(camera)) { - 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->camId | 0x50; + camera->play->view.unk_124 = camera->camId | 0x50; return 1; } rwData->unk_14 = *temp_s0; @@ -3538,7 +3536,7 @@ s32 Camera_KeepOn4(Camera* camera) { camera->animState = 20; camera->unk_14C |= 0x20; camera->unk_14C &= ~(0x4 | 0x2); - camera->globalCtx->view.unk_124 = camera->camId | 0x50; + camera->play->view.unk_124 = camera->camId | 0x50; return 1; } @@ -3656,7 +3654,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 > (roData->unk_00 + D_8015BD50.y)) { D_8015BD50.y = temp_f0_2 + 10.0f; } else { @@ -3716,8 +3714,8 @@ s32 Camera_KeepOn4(Camera* camera) { if (!(roData->unk_1C & 1)) { angleCnt = ARRAY_COUNT(D_8011D3B0); for (i = 0; i < angleCnt; i++) { - if (!CollisionCheck_LineOCCheck(camera->globalCtx, &camera->globalCtx->colChkCtx, &D_8015BD50, - &D_8015BD70, spCC, sp9C) && + if (!CollisionCheck_LineOCCheck(camera->play, &camera->play->colChkCtx, &D_8015BD50, &D_8015BD70, + spCC, sp9C) && !Camera_BGCheck(camera, &D_8015BD50, &D_8015BD70)) { break; } @@ -4204,8 +4202,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->camId | 0x50; + if (camera->play->view.unk_124 == 0) { + camera->play->view.unk_124 = camera->camId | 0x50; return true; } @@ -4266,7 +4264,7 @@ s32 Camera_Subj3(Camera* camera) { *eye = *eyeNext; rwData->animTimer--; - if (!camera->globalCtx->envCtx.skyboxDisabled) { + if (!camera->play->envCtx.skyboxDisabled) { Camera_BGCheck(camera, at, eye); } else { func_80044340(camera, at, eye); @@ -4333,8 +4331,8 @@ s32 Camera_Subj4(Camera* camera) { Camera_CopyPREGToModeValues(camera); } - if (camera->globalCtx->view.unk_124 == 0) { - camera->globalCtx->view.unk_124 = (camera->camId | 0x50); + if (camera->play->view.unk_124 == 0) { + camera->play->view.unk_124 = (camera->camId | 0x50); rwData->unk_24 = camera->xzSpeed; return true; } @@ -5128,11 +5126,11 @@ s32 Camera_Unique9(Camera* camera) { Camera_UpdateInterface(0xF000 | ((rwData->curKeyFrame->unk_01 & 0xF) << 8)); } else if (camera->player->stateFlags1 & PLAYER_STATE1_27 && 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", rwData->curKeyFrame->unk_01); - func_8002DF38(camera->globalCtx, camera->target, rwData->curKeyFrame->unk_01); + func_8002DF38(camera->play, camera->target, rwData->curKeyFrame->unk_01); } } } else { @@ -5151,9 +5149,9 @@ s32 Camera_Unique9(Camera* camera) { rwData->atTarget = rwData->curKeyFrame->atTargetInit; } else if (atInitFlags == 2) { if (rwData->isNewKeyFrame) { - rwData->atTarget.x = camera->globalCtx->view.at.x + rwData->curKeyFrame->atTargetInit.x; - rwData->atTarget.y = camera->globalCtx->view.at.y + rwData->curKeyFrame->atTargetInit.y; - rwData->atTarget.z = camera->globalCtx->view.at.z + rwData->curKeyFrame->atTargetInit.z; + rwData->atTarget.x = camera->play->view.at.x + rwData->curKeyFrame->atTargetInit.x; + rwData->atTarget.y = camera->play->view.at.y + rwData->curKeyFrame->atTargetInit.y; + rwData->atTarget.z = camera->play->view.at.z + rwData->curKeyFrame->atTargetInit.z; } } else if (atInitFlags == 3) { if (rwData->isNewKeyFrame) { @@ -5233,9 +5231,9 @@ s32 Camera_Unique9(Camera* camera) { rwData->eyeTarget = rwData->curKeyFrame->eyeTargetInit; } else if (eyeInitFlags == 0x200) { if (rwData->isNewKeyFrame) { - rwData->eyeTarget.x = camera->globalCtx->view.eye.x + rwData->curKeyFrame->eyeTargetInit.x; - rwData->eyeTarget.y = camera->globalCtx->view.eye.y + rwData->curKeyFrame->eyeTargetInit.y; - rwData->eyeTarget.z = camera->globalCtx->view.eye.z + rwData->curKeyFrame->eyeTargetInit.z; + rwData->eyeTarget.x = camera->play->view.eye.x + rwData->curKeyFrame->eyeTargetInit.x; + rwData->eyeTarget.y = camera->play->view.eye.y + rwData->curKeyFrame->eyeTargetInit.y; + rwData->eyeTarget.z = camera->play->view.eye.z + rwData->curKeyFrame->eyeTargetInit.z; } } else if (eyeInitFlags == 0x300) { if (rwData->isNewKeyFrame) { @@ -5322,7 +5320,7 @@ s32 Camera_Unique9(Camera* camera) { } if (rwData->curKeyFrame->initFlags == 2) { - rwData->fovTarget = camera->globalCtx->view.fovy; + rwData->fovTarget = camera->play->view.fovy; rwData->rollTarget = 0; } else if (rwData->curKeyFrame->initFlags == 0) { rwData->fovTarget = camera->fov; @@ -5477,12 +5475,12 @@ s32 Camera_Unique9(Camera* camera) { // Change the parent camera (or default)'s mode to normal s32 camIdx = camera->parentCamId <= CAM_ID_NONE ? CAM_ID_MAIN : camera->parentCamId; - 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->parentCamId <= CAM_ID_NONE ? CAM_ID_MAIN : camera->parentCamId; - Camera* cam = camera->globalCtx->cameraPtrs[camIdx]; + Camera* cam = camera->play->cameraPtrs[camIdx]; *eye = *eyeNext; Camera_Copy(cam, camera); @@ -5603,8 +5601,8 @@ s32 Camera_Demo1(Camera* camera) { rwData->curFrame = 0.0f; camera->animState++; // "absolute" : "relative" - osSyncPrintf(VT_SGR("1") "%06u:" VT_RST " camera: spline demo: start %s \n", - camera->globalCtx->state.frames, *relativeToPlayer == 0 ? "絶対" : "相対"); + osSyncPrintf(VT_SGR("1") "%06u:" VT_RST " camera: spline demo: start %s \n", camera->play->state.frames, + *relativeToPlayer == 0 ? "絶対" : "相対"); if (PREG(93)) { Camera_DebugPrintSplineArray("CENTER", 5, csAtPoints); @@ -5700,7 +5698,7 @@ s32 Camera_Demo3(Camera* camera) { sp68.x = rwData->initialAt.x + (Math_SinS(angle) * 40.0f); sp68.y = rwData->initialAt.y + 40.0f; sp68.z = rwData->initialAt.z + (Math_CosS(angle) * 40.0f); - if (camera->globalCtx->state.frames & 1) { + if (camera->play->state.frames & 1) { angle -= 0x3FFF; rwData->yawDir = 1; } else { @@ -5899,7 +5897,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, &targetScreenPosX, &targetScreenPosY); + Actor_GetScreenPos(camera->play, camera->target, &targetScreenPosX, &targetScreenPosY); eyeTargetDist = OLib_Vec3fDist(&camera->targetPosRot.pos, &camera->eye); OLib_Vec3fDiffToVecSphGeo(&eyePlayerGeo, &playerhead.pos, &camera->eyeNext); sp4A = eyePlayerGeo.yaw - playerTargetGeo.yaw; @@ -5997,7 +5995,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; @@ -6050,7 +6048,7 @@ s32 Camera_Demo5(Camera* camera) { ONEPOINT_CS_INFO(camera)->keyFrames = D_8011D9F4; ONEPOINT_CS_INFO(camera)->keyFrameCnt = ARRAY_COUNT(D_8011D9F4); if (camera->parentCamId != CAM_ID_MAIN) { - 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; } @@ -6061,12 +6059,12 @@ s32 Camera_Demo5(Camera* camera) { } } - framesDiff = sDemo5PrevSfxFrame - camera->globalCtx->state.frames; + framesDiff = sDemo5PrevSfxFrame - camera->play->state.frames; if ((framesDiff > 50) || (framesDiff < -50)) { func_80078884(camera->data1); } - sDemo5PrevSfxFrame = camera->globalCtx->state.frames; + sDemo5PrevSfxFrame = camera->play->state.frames; if (camera->player->stateFlags1 & PLAYER_STATE1_27 && (player->currentBoots != PLAYER_BOOTS_IRON)) { // swimming, and not iron boots @@ -6076,21 +6074,21 @@ s32 Camera_Demo5(Camera* camera) { } else { sp4A = playerhead.rot.y - playerTargetGeo.yaw; if (camera->target->category == ACTORCAT_PLAYER) { - framesDiff = camera->globalCtx->state.frames - sDemo5PrevAction12Frame; + framesDiff = camera->play->state.frames - sDemo5PrevAction12Frame; if (player->stateFlags1 & PLAYER_STATE1_11) { // holding object over head. - func_8002DF54(camera->globalCtx, camera->target, 8); + func_8002DF54(camera->play, camera->target, 8); } else if (ABS(framesDiff) > 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; @@ -6111,7 +6109,7 @@ s32 Camera_Demo6(Camera* camera) { s16 stateTimers[4]; Demo6ReadWriteData* rwData = &camera->paramData.demo6.rwData; - mainCam = Play_GetCamera(camera->globalCtx, CAM_ID_MAIN); + mainCam = Play_GetCamera(camera->play, CAM_ID_MAIN); camFocus = camera->target; stateTimers[1] = 0x37; stateTimers[2] = 0x46; @@ -6145,7 +6143,7 @@ s32 Camera_Demo6(Camera* camera) { camera->animState++; case 1: if (stateTimers[camera->animState] < rwData->animTimer) { - func_8002DF54(camera->globalCtx, &camera->player->actor, 8); + func_8002DF54(camera->play, &camera->player->actor, 8); Actor_GetWorld(&focusPosRot, camFocus); rwData->atTarget.x = focusPosRot.pos.x; rwData->atTarget.y = focusPosRot.pos.y - 20.0f; @@ -6216,7 +6214,7 @@ s32 Camera_Demo9(Camera* camera) { f32* camFOV = &camera->fov; Demo9ReadWriteData* rwData = &camera->paramData.demo9.rwData; - mainCam = Play_GetCamera(camera->globalCtx, CAM_ID_MAIN); + mainCam = Play_GetCamera(camera->play, CAM_ID_MAIN); mainCamPlayerPosRot = &mainCam->playerPosRot; if (RELOAD_PARAMS(camera) || R_RELOAD_CAM_PARAMS) { values = sCameraSettings[camera->setting].cameraModes[camera->mode].values; @@ -6306,7 +6304,7 @@ s32 Camera_Demo9(Camera* camera) { if (rwData->finishAction == 0x2000) { // finish action = 0x2000, run OnePointCs 0x3FC (Dramatic Return to Link) onePointTimer = onePointCamData->initTimer < 50 ? 5 : onePointCamData->initTimer / 5; - OnePointCutscene_Init(camera->globalCtx, 1020, onePointTimer, NULL, camera->parentCamId); + OnePointCutscene_Init(camera->play, 1020, onePointTimer, NULL, camera->parentCamId); } } else { // finish action = 0x1000, copy the current camera's values to the @@ -6529,7 +6527,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 rwData->index = 3; } else if (playerPosRot->pos.x < 1500.0f) { @@ -6754,7 +6752,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 = rwData->targetYaw + yaw; eyeAdjustment.r = 200.0f * yNormal; Camera_Vec3fVecSphGeoAdd(eyeNext, at, &eyeAdjustment); @@ -6826,12 +6824,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 = ZeldaArena_MallocDebug(sizeof(*newCamera), "../z_camera.c", 9370); 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); } @@ -6847,7 +6845,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; @@ -6867,7 +6865,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++; @@ -6877,7 +6875,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; } @@ -6926,11 +6924,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; @@ -6941,8 +6939,7 @@ void func_80057FC4(Camera* camera) { camera->prevSetting = camera->setting = CAM_SET_NORMAL0; break; default: - osSyncPrintf("camera: room type: default set etc (%d)\n", - camera->globalCtx->roomCtx.curRoom.behaviorType1); + osSyncPrintf("camera: room type: default set etc (%d)\n", 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; @@ -7005,7 +7002,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; @@ -7059,13 +7056,13 @@ void Camera_PrintSettings(Camera* camera) { char sp48[8]; s32 i; - if ((OREG(0) & 1) && (camera->globalCtx->activeCamId == camera->camId) && !gDbgCamEnabled) { + if ((OREG(0) & 1) && (camera->play->activeCamId == camera->camId) && !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; @@ -7091,7 +7088,7 @@ void Camera_PrintSettings(Camera* camera) { sp58[i] = '\0'; sp48[i] = '\0'; - sp48[camera->globalCtx->activeCamId] = 'a'; + sp48[camera->play->activeCamId] = 'a'; func_8006376C(3, 0x16, 5, sp58); func_8006376C(3, 0x16, 1, sp48); func_8006376C(3, 0x17, 5, "S:"); @@ -7205,7 +7202,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; } @@ -7228,7 +7225,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; @@ -7237,7 +7234,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); } @@ -7251,7 +7248,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; } @@ -7261,7 +7258,7 @@ s32 Camera_UpdateHotRoom(Camera* camera) { s32 Camera_DbgChangeMode(Camera* camera) { s32 changeDir = 0; - if (!gDbgCamEnabled && camera->globalCtx->activeCamId == CAM_ID_MAIN) { + if (!gDbgCamEnabled && camera->play->activeCamId == CAM_ID_MAIN) { 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); @@ -7357,17 +7354,17 @@ void Camera_UpdateDistortion(Camera* camera) { depthPhase += CAM_DEG_TO_BINANG(depthPhaseStep); screenPlanePhase += CAM_DEG_TO_BINANG(screenPlanePhaseStep); - View_SetDistortionOrientation(&camera->globalCtx->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_SetDistortionOrientation(&camera->play->view, Math_CosS(depthPhase) * 0.0f, Math_SinS(depthPhase) * 0.0f, + Math_SinS(screenPlanePhase) * 0.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; } } @@ -7388,7 +7385,7 @@ Vec3s Camera_Update(Camera* camera) { QuakeCamCalc quake; Player* player; - player = camera->globalCtx->cameraPtrs[CAM_ID_MAIN]->player; + player = camera->play->cameraPtrs[CAM_ID_MAIN]->player; if (R_DBG_CAM_UPDATE) { osSyncPrintf("camera: in %x\n", camera); @@ -7415,8 +7412,8 @@ Vec3s Camera_Update(Camera* camera) { spAC = curPlayerPosRot.pos; spAC.y += Player_GetHeight(camera->player); - playerGroundY = BgCheck_EntityRaycastFloor5(camera->globalCtx, &camera->globalCtx->colCtx, &playerFloorPoly, - &bgId, &camera->player->actor, &spAC); + playerGroundY = BgCheck_EntityRaycastFloor5(camera->play, &camera->play->colCtx, &playerFloorPoly, &bgId, + &camera->player->actor, &spAC); if (playerGroundY != BGCHECK_Y_MIN) { // player is above ground. sOOBTimer = 0; @@ -7499,10 +7496,10 @@ Vec3s Camera_Update(Camera* camera) { D_8011D3F0--; sCameraInterfaceFlags = 0x3200; Camera_UpdateInterface(sCameraInterfaceFlags); - } else if (camera->globalCtx->transitionMode != TRANS_MODE_OFF) { + } else if (camera->play->transitionMode != TRANS_MODE_OFF) { 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 { @@ -7511,7 +7508,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) { @@ -7526,16 +7523,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); - View_LookAt(&camera->globalCtx->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); + View_LookAt(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); if (R_DBG_CAM_UPDATE) { osSyncPrintf("camera: debug out\n"); } @@ -7580,13 +7577,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; - View_LookAt(&camera->globalCtx->view, &viewEye, &viewAt, &viewUp); + camera->play->view.fovy = viewFov; + View_LookAt(&camera->play->view, &viewEye, &viewAt, &viewUp); camera->camDir.x = eyeAtAngle.pitch; camera->camDir.y = eyeAtAngle.yaw; camera->camDir.z = 0; @@ -7627,18 +7624,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[CAM_ID_MAIN]; - Player* player = GET_PLAYER(camera->globalCtx); + Camera* mainCam = camera->play->cameraPtrs[CAM_ID_MAIN]; + Player* player = GET_PLAYER(camera->play); if (camera->timer == 0) { - Play_ChangeCameraStatus(camera->globalCtx, camera->parentCamId, CAM_STAT_ACTIVE); + Play_ChangeCameraStatus(camera->play, camera->parentCamId, CAM_STAT_ACTIVE); if ((camera->parentCamId == CAM_ID_MAIN) && (camera->csId != 0)) { player->actor.freezeTimer = 0; player->stateFlags1 &= ~PLAYER_STATE1_29; if (player->csMode != 0) { - func_8002DF54(camera->globalCtx, &player->actor, 7); + func_8002DF54(camera->play, &player->actor, 7); osSyncPrintf("camera: player demo end!!\n"); } @@ -7659,9 +7656,9 @@ void Camera_Finish(Camera* camera) { camera->childCamId = camera->parentCamId = CAM_ID_MAIN; camera->timer = -1; - camera->globalCtx->envCtx.fillScreen = false; + camera->play->envCtx.fillScreen = false; - Play_ClearCamera(camera->globalCtx, camera->camId); + Play_ClearCamera(camera->play, camera->camId); } } @@ -7675,7 +7672,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) { @@ -7777,7 +7774,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); @@ -7824,7 +7821,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; } @@ -7871,7 +7868,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->camId, sCameraSettingNames[camera->setting]); return setting; @@ -8198,9 +8195,9 @@ s32 func_8005B198(void) { s16 func_8005B1A4(Camera* camera) { camera->unk_14C |= 0x8; - if ((camera->camId == CAM_ID_MAIN) && (camera->globalCtx->activeCamId != CAM_ID_MAIN)) { - GET_ACTIVE_CAM(camera->globalCtx)->unk_14C |= 0x8; - return camera->globalCtx->activeCamId; + if ((camera->camId == CAM_ID_MAIN) && (camera->play->activeCamId != CAM_ID_MAIN)) { + GET_ACTIVE_CAM(camera->play)->unk_14C |= 0x8; + return camera->play->activeCamId; } return camera->camId; diff --git a/src/code/z_camera_data.c b/src/code/z_camera_data.c index 1f457888e..f7bd99549 100644 --- a/src/code/z_camera_data.c +++ b/src/code/z_camera_data.c @@ -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/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.c index d611c08d2..772ef3ec6 100644 --- a/src/code/z_cheap_proc.c +++ b/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, "../z_cheap_proc.c", 214); +void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) { + OPEN_DISPS(play->state.gfxCtx, "../z_cheap_proc.c", 214); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 216), + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_cheap_proc.c", 216), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 219); + CLOSE_DISPS(play->state.gfxCtx, "../z_cheap_proc.c", 219); } -void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 228); +void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist) { + OPEN_DISPS(play->state.gfxCtx, "../z_cheap_proc.c", 228); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 230), + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_cheap_proc.c", 230), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 233); + CLOSE_DISPS(play->state.gfxCtx, "../z_cheap_proc.c", 233); } diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c index 6d63f4ffb..f0e54f095 100644 --- a/src/code/z_collision_check.c +++ b/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, "../z_collision_check.c", 757); } -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_MAX, }; @@ -109,14 +109,14 @@ s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) { return true; } -s32 Collider_DestroyBase(GlobalContext* globalCtx, Collider* collider) { +s32 Collider_DestroyBase(PlayState* play, Collider* collider) { return true; } /** * 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 true; } -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 true; } -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 true; } -s32 Collider_DestroyTouch(GlobalContext* globalCtx, ColliderTouch* touch) { +s32 Collider_DestroyTouch(PlayState* play, ColliderTouch* touch) { return true; } -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 true; } -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 true; } -s32 Collider_DestroyBump(GlobalContext* globalCtx, ColliderBump* bump) { +s32 Collider_DestroyBump(PlayState* play, ColliderBump* bump) { return true; } -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 true; } -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 true; } -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 true; } -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 true; } -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,56 +268,55 @@ s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElemen return true; } -s32 Collider_DestroyJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* element) { +s32 Collider_DestroyJntSphElementDim(PlayState* play, ColliderJntSphElementDim* element) { return true; } -s32 Collider_SetJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dest, - ColliderJntSphElementDimInit* src) { +s32 Collider_SetJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dest, ColliderJntSphElementDimInit* src) { dest->limb = src->limb; dest->modelSphere = src->modelSphere; dest->scale = src->scale * 0.01f; return true; } -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 true; } -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 true; } -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 true; } -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 true; } -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 true; } -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 true; } /** * 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 true; @@ -326,12 +325,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 +344,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 +360,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 = ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1443); @@ -379,8 +378,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 true; } @@ -389,12 +388,11 @@ 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, - ColliderJntSphInitType1* src) { +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 = ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1490); @@ -408,8 +406,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 true; } @@ -418,11 +416,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 = ZeldaArena_MallocDebug(src->count * sizeof(ColliderJntSphElement), "../z_collision_check.c", 1551); @@ -435,8 +433,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 true; } @@ -444,20 +442,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, "pclobj_jntsph->elem_tbl != NULL", "../z_collision_check.c", 1603); 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 true; } @@ -465,14 +463,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 true; } @@ -480,14 +478,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 true; } @@ -495,30 +493,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 true; } -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 true; } -s32 Collider_DestroyCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) { +s32 Collider_DestroyCylinderDim(PlayState* play, Cylinder16* dim) { return true; } -s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dest, Cylinder16* src) { +s32 Collider_SetCylinderDim(PlayState* play, Cylinder16* dest, Cylinder16* src) { *dest = *src; return true; } @@ -526,20 +524,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 true; } /** * 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 true; } @@ -547,70 +545,68 @@ 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, - ColliderCylinderInitToActor* src) { - Collider_SetBaseToActor(globalCtx, &collider->base, &src->base); - Collider_SetInfo(globalCtx, &collider->info, &src->info); - Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim); +s32 Collider_SetCylinderToActor(PlayState* play, ColliderCylinder* collider, ColliderCylinderInitToActor* src) { + Collider_SetBaseToActor(play, &collider->base, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return true; } /** * 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 true; } /** * Sets up the ColliderCylinder using the values in src. */ -s32 Collider_SetCylinder(GlobalContext* globalCtx, 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); +s32 Collider_SetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src) { + Collider_SetBase(play, &collider->base, actor, &src->base); + Collider_SetInfo(play, &collider->info, &src->info); + Collider_SetCylinderDim(play, &collider->dim, &src->dim); return true; } /** * 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 true; } /** * 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 true; } /** * 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 true; } -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 +616,11 @@ s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { return true; } -s32 Collider_DestroyTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) { +s32 Collider_DestroyTrisElementDim(PlayState* play, TriNorm* dim) { return true; } -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 +641,44 @@ s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dest, Collider return true; } -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 true; } -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 true; } -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 true; } -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 true; } -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 true; } -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 true; } /** * 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 true; @@ -692,12 +688,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 +707,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 +724,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 = ZeldaArena_MallocDebug(dest->count * sizeof(ColliderTrisElement), "../z_collision_check.c", 2156); if (dest->elements == NULL) { @@ -744,8 +740,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 true; } @@ -754,11 +750,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 = ZeldaArena_MallocDebug(dest->count * sizeof(ColliderTrisElement), "../z_collision_check.c", 2207); @@ -772,8 +768,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 true; } @@ -781,20 +777,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, "pclobj_tris->elem_tbl != NULL", "../z_collision_check.c", 2258); 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 true; } @@ -802,13 +798,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 true; } @@ -816,13 +812,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 true; } @@ -830,18 +826,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 true; } -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 +849,11 @@ s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { return true; } -s32 Collider_DestroyQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_DestroyQuadDim(PlayState* play, ColliderQuadDim* dim) { return true; } -s32 Collider_ResetQuadACDist(GlobalContext* globalCtx, ColliderQuadDim* dim) { +s32 Collider_ResetQuadACDist(PlayState* play, ColliderQuadDim* dim) { dim->acDistSq = 1.0e38f; return true; } @@ -871,7 +867,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 +879,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 true; } /** * 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 true; } /** * 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 true; } /** * 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 true; } /** * 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 true; } /** * 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 true; } /** * 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 true; } @@ -958,7 +954,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 acDistSq; Vec3f dcMid; @@ -970,10 +966,10 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3 if (acDistSq < quad->dim.acDistSq) { quad->dim.acDistSq = acDistSq; 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 +980,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 +992,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 true; } @@ -1004,7 +1000,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* globalCtx, OcLine* ocLine, Vec3f* a, Vec3f* b) { +s32 Collider_SetLinePoints(PlayState* play, OcLine* ocLine, Vec3f* a, Vec3f* b) { Math_Vec3f_Copy(&ocLine->line.a, a); Math_Vec3f_Copy(&ocLine->line.b, b); return true; @@ -1014,9 +1010,9 @@ s32 Collider_SetLinePoints(GlobalContext* globalCtx, OcLine* ocLine, Vec3f* a, V * 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 true; } @@ -1024,7 +1020,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 true; } @@ -1032,21 +1028,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 +1072,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 |= SAC_ENABLE; } /** * 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 &= ~SAC_ENABLE; } @@ -1091,7 +1087,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 +1101,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], - &tris->elements[i].dim.vtx[1], &tris->elements[i].dim.vtx[2]); + 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 +1127,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 +1170,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_MAX, "pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 2997); - sATResetFuncs[collider->shape](globalCtx, collider); + sATResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1203,13 +1199,12 @@ 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 index) { +s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index) { ASSERT(collider->shape < COLSHAPE_MAX, "pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3037); - 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 +1238,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_MAX, "pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3114); - sACResetFuncs[collider->shape](globalCtx, collider); + sACResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1272,13 +1267,12 @@ 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 index) { +s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index) { ASSERT(collider->shape < COLSHAPE_MAX, "pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3153); - 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 +1306,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_MAX, "pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3229); - sOCResetFuncs[collider->shape](globalCtx, collider); + sOCResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1343,13 +1337,12 @@ 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 index) { - if (FrameAdvance_IsEnabled(globalCtx) == true) { +s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, s32 index) { + if (FrameAdvance_IsEnabled(play) == true) { return -1; } ASSERT(collider->shape < COLSHAPE_MAX, "pcl_obj->data_type <= CL_DATA_LBL_SWRD", "../z_collision_check.c", 3274); - sOCResetFuncs[collider->shape](globalCtx, collider); + sOCResetFuncs[collider->shape](play, collider); if (collider->actor != NULL && collider->actor->update == NULL) { return -1; } @@ -1377,13 +1370,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 +1421,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 sparkInit; s32 effectIndex; @@ -1481,14 +1474,14 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3 sparkInit.speed = 8.0f; sparkInit.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); } /** * 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 sparkInit; s32 effectIndex; @@ -1534,42 +1527,42 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec sparkInit.speed = 8.0f; sparkInit.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); } /** * 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1578,14 +1571,14 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } } 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1594,7 +1587,7 @@ void CollisionCheck_HitSolid(GlobalContext* globalCtx, ColliderInfo* info, Colli &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } } 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1641,8 +1634,8 @@ 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, - ColliderInfo* acInfo, Vec3f* hitPos) { +void CollisionCheck_HitEffects(PlayState* play, Collider* at, ColliderInfo* atInfo, Collider* ac, ColliderInfo* acInfo, + Vec3f* hitPos) { if (acInfo->bumperFlags & BUMP_NO_HITMARK) { return; } @@ -1650,27 +1643,27 @@ 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1692,7 +1685,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); @@ -1722,7 +1715,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 true; @@ -1731,7 +1724,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; @@ -1773,8 +1766,8 @@ 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, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, &acPos, + &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; } @@ -1787,7 +1780,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; @@ -1830,8 +1823,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } } @@ -1841,7 +1833,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; @@ -1884,8 +1876,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos, &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { break; } @@ -1897,7 +1888,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; @@ -1927,8 +1918,8 @@ 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, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atSph->info, &atPos, &ac->base, &acTri->info, &acPos, + &hitPos); return; } } @@ -1939,7 +1930,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; @@ -1967,8 +1958,8 @@ 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, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, &acPos, + &hitPos); if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) { return; } @@ -1981,7 +1972,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 tri1; static TriNorm tri2; @@ -2014,8 +2005,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } } @@ -2025,7 +2015,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 tri1; static TriNorm tri2; @@ -2049,7 +2039,7 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont } if (Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &tri1, &hitPos) == true || Math3D_TriVsSphIntersect(&acElem->dim.worldSphere, &tri2, &hitPos) == true) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2063,7 +2053,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; @@ -2077,8 +2067,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, - Collider* colAC) { +void CollisionCheck_AC_CylVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderCylinder* ac = (ColliderCylinder*)colAC; f32 deadSpace; @@ -2110,7 +2099,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); } } } @@ -2118,8 +2107,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, - Collider* colAC) { +void CollisionCheck_AC_CylVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { ColliderCylinder* at = (ColliderCylinder*)colAT; ColliderTris* ac = (ColliderTris*)colAC; ColliderTrisElement* acElem; @@ -2145,8 +2133,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atpos, &ac->base, &acElem->info, &acPos, &hitPos); return; } } @@ -2156,8 +2143,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, - Collider* colAC) { +void CollisionCheck_AC_TrisVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f hitPos; ColliderTris* at = (ColliderTris*)colAT; ColliderTrisElement* atItem; @@ -2182,8 +2168,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } } @@ -2193,8 +2178,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, - Collider* colAC) { +void CollisionCheck_AC_CylVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm tri1; static TriNorm tri2; static Vec3f hitPos; @@ -2218,7 +2202,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, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos1, &ac->base, &ac->info, &acPos1, &hitPos); } else if (Math3D_CylTriVsIntersect(&at->dim, &tri2, &hitPos) == true) { Vec3f atPos2; Vec3f acPos2; @@ -2227,7 +2211,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, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos2, &ac->base, &ac->info, &acPos2, &hitPos); } } } @@ -2238,8 +2222,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, - Collider* colAC) { +void CollisionCheck_AC_QuadVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm tri1; static TriNorm tri2; static Vec3f hitPos; @@ -2256,7 +2239,7 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext Math3D_TriNorm(&tri1, &at->dim.quad[2], &at->dim.quad[3], &at->dim.quad[1]); Math3D_TriNorm(&tri2, &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]); if (Math3D_CylTriVsIntersect(&ac->dim, &tri1, &hitPos) == true) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos1; Vec3f acPos1; @@ -2264,13 +2247,12 @@ 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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos1, &ac->base, &ac->info, &acPos1, &hitPos); return; } } if (Math3D_CylTriVsIntersect(&ac->dim, &tri2, &hitPos) == true) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos2; Vec3f acPos2; @@ -2278,8 +2260,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos2, &ac->base, &ac->info, &acPos2, &hitPos); } } } @@ -2293,8 +2274,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, - Collider* colAC) { +void CollisionCheck_AC_TrisVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f hitPos; ColliderTris* at = (ColliderTris*)colAT; ColliderTrisElement* atItem; @@ -2323,8 +2303,8 @@ 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, - &acPos, &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &acElem->info, &acPos, + &hitPos); return; } } @@ -2340,8 +2320,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, - Collider* colAC) { +void CollisionCheck_AC_TrisVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f hitPos; static TriNorm tri1; static TriNorm tri2; @@ -2373,8 +2352,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &atItem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } } @@ -2384,8 +2362,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, - Collider* colAC) { +void CollisionCheck_AC_QuadVsTris(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static Vec3f hitPos; static TriNorm tri1; static TriNorm tri2; @@ -2408,7 +2385,7 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex } if (Math3D_TriVsTriIntersect(&tri1, &acElem->dim, &hitPos) == true || Math3D_TriVsTriIntersect(&tri2, &acElem->dim, &hitPos) == true) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2421,7 +2398,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, &hitPos); return; } @@ -2433,8 +2410,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, - Collider* colAC) { +void CollisionCheck_AC_QuadVsQuad(PlayState* play, CollisionCheckContext* colChkCtx, Collider* colAT, Collider* colAC) { static TriNorm acTris[2]; static Vec3f hitPos; static TriNorm atTris[2]; @@ -2461,7 +2437,7 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex for (i = 0; i < 2; i++) { for (j = 0; j < 2; j++) { if (Math3D_TriVsTriIntersect(&atTris[j], &acTris[i], &hitPos) == true) { - if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) { + if (Collider_QuadSetNearestAC(play, at, &hitPos)) { Vec3f atPos; Vec3f acPos; @@ -2477,8 +2453,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, - &hitPos); + CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos); return; } } @@ -2489,7 +2464,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; @@ -2498,8 +2473,8 @@ 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, - &element->info, &hitPos); + CollisionCheck_HitEffects(play, element->info.acHit, element->info.acHitInfo, &jntSph->base, &element->info, + &hitPos); element->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; return; } @@ -2509,14 +2484,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; } @@ -2525,7 +2500,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; @@ -2534,8 +2509,8 @@ 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, - &element->info, &hitPos); + CollisionCheck_HitEffects(play, element->info.acHit, element->info.acHitInfo, &tris->base, &element->info, + &hitPos); element->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK; return; } @@ -2545,14 +2520,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; } } @@ -2567,7 +2542,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++) { @@ -2577,7 +2552,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); } } } @@ -2596,7 +2571,7 @@ static ColChkVsFunc sACVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { /** * 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++) { @@ -2610,7 +2585,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); } } } @@ -2622,7 +2597,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) { @@ -2635,10 +2610,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); } /** @@ -2752,8 +2727,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, - Collider* r) { +void CollisionCheck_OC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderJntSphElement* leftElem; ColliderJntSph* right = (ColliderJntSph*)r; @@ -2786,8 +2760,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, - Collider* r) { +void CollisionCheck_OC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { ColliderJntSph* left = (ColliderJntSph*)l; ColliderJntSphElement* leftElem; ColliderCylinder* right = (ColliderCylinder*)r; @@ -2816,15 +2789,14 @@ 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, - Collider* r) { - CollisionCheck_OC_JntSphVsCyl(globalCtx, colChkCtx, r, l); +void CollisionCheck_OC_CylVsJntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* l, Collider* r) { + 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; @@ -2886,7 +2858,7 @@ static ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = { * 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; @@ -2906,7 +2878,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); } } } @@ -2978,7 +2950,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; @@ -3018,13 +2990,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); } } } @@ -3032,29 +3004,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[COLSHAPE_MAX] = { @@ -3068,7 +3040,7 @@ static ColChkApplyFunc sApplyDamageFuncs[COLSHAPE_MAX] = { * 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++) { @@ -3080,15 +3052,15 @@ 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, - Vec3f* a, Vec3f* b) { +s32 CollisionCheck_LineOC_JntSph(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a, + Vec3f* b) { static Linef lineSeg; ColliderJntSph* jntSph = (ColliderJntSph*)collider; s32 i; @@ -3111,7 +3083,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 intersectA; static Vec3f intersectB; @@ -3137,8 +3109,8 @@ static ColChkLineFunc sOCLineCheckFuncs[COLSHAPE_MAX] = { * 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, - Actor** exclusions, s32 numExclusions) { +s32 CollisionCheck_LineOC(PlayState* play, CollisionCheckContext* colChkCtx, Vec3f* a, Vec3f* b, Actor** exclusions, + s32 numExclusions) { ColChkLineFunc lineCheck; Collider** col; s32 i; @@ -3164,7 +3136,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; } @@ -3177,17 +3149,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); } /** @@ -3242,10 +3214,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. @@ -3284,7 +3256,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 sparkInit; s32 effectIndex; @@ -3330,14 +3302,14 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) { sparkInit.speed = 8.0f; sparkInit.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); } /** * 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 sparkInit; s32 effectIndex; @@ -3383,13 +3355,13 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) { sparkInit.speed = 8.0f; sparkInit.gravity = -1.0f; - Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); + Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &sparkInit); } /** * 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 metalInit = { 16, { 0, 0, 0 }, @@ -3415,14 +3387,14 @@ void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) { metalInit.lightPoint.y = metalInit.position.y; metalInit.lightPoint.z = metalInit.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &metalInit); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &metalInit); } /** * 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } @@ -3430,8 +3402,8 @@ void CollisionCheck_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* v /** * 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, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } @@ -3439,14 +3411,14 @@ void CollisionCheck_SpawnShieldParticlesMetalSound(GlobalContext* globalCtx, Vec /** * 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 woodInit = { 16, { 0, 0, 0 }, @@ -3472,7 +3444,7 @@ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v, woodInit.lightPoint.y = woodInit.position.y; woodInit.lightPoint.z = woodInit.position.z; - Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &woodInit); + Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &woodInit); Audio_PlaySoundGeneral(NA_SE_IT_REFLECTION_WOOD, actorPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } diff --git a/src/code/z_construct.c b/src/code/z_construct.c index cbf9983ad..f4ce2ad7c 100644 --- a/src/code/z_construct.c +++ b/src/code/z_construct.c @@ -1,11 +1,11 @@ #include "global.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; u16 doActionOffset; u8 temp; @@ -13,7 +13,7 @@ void func_801109B0(GlobalContext* globalCtx) { 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; @@ -32,7 +32,7 @@ void func_801109B0(GlobalContext* globalCtx) { // "Permanent PARAMETER Segment = %x" osSyncPrintf("常駐PARAMETERセグメント=%x\n", parameterSize); - interfaceCtx->parameterSegment = GameState_Alloc(&globalCtx->state, parameterSize, "../z_construct.c", 159); + interfaceCtx->parameterSegment = GameState_Alloc(&play->state, parameterSize, "../z_construct.c", 159); osSyncPrintf("parameter->parameterSegment=%x\n", interfaceCtx->parameterSegment); @@ -40,7 +40,7 @@ void func_801109B0(GlobalContext* globalCtx) { DmaMgr_SendRequest1(interfaceCtx->parameterSegment, (u32)_parameter_staticSegmentRomStart, parameterSize, "../z_construct.c", 162); - interfaceCtx->doActionSegment = GameState_Alloc(&globalCtx->state, 0x480, "../z_construct.c", 166); + interfaceCtx->doActionSegment = GameState_Alloc(&play->state, 0x480, "../z_construct.c", 166); osSyncPrintf("DOアクション テクスチャ初期=%x\n", 0x480); // "DO Action Texture Initialization" osSyncPrintf("parameter->do_actionSegment=%x\n", interfaceCtx->doActionSegment); @@ -69,7 +69,7 @@ void func_801109B0(GlobalContext* globalCtx) { DmaMgr_SendRequest1(interfaceCtx->doActionSegment + 0x300, (u32)_do_action_staticSegmentRomStart + doActionOffset, 0x180, "../z_construct.c", 178); - interfaceCtx->iconItemSegment = GameState_Alloc(&globalCtx->state, 0x4000, "../z_construct.c", 190); + interfaceCtx->iconItemSegment = GameState_Alloc(&play->state, 0x4000, "../z_construct.c", 190); // "Icon Item Texture Initialization = %x" osSyncPrintf("アイコンアイテム テクスチャ初期=%x\n", 0x4000); @@ -146,8 +146,8 @@ void func_801109B0(GlobalContext* globalCtx) { osSyncPrintf("PARAMETER領域=%x\n", parameterSize + 0x5300); // "Parameter Area = %x" - Health_InitMeter(globalCtx); - Map_Init(globalCtx); + Health_InitMeter(play); + Map_Init(play); interfaceCtx->unk_23C = interfaceCtx->unk_242 = 0; @@ -164,29 +164,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(&globalCtx->state, 0x2200, "../z_construct.c", 349); + msgCtx->textboxSegment = GameState_Alloc(&play->state, 0x2200, "../z_construct.c", 349); osSyncPrintf("message->fukidashiSegment=%x\n", msgCtx->textboxSegment); osSyncPrintf("吹き出しgame_alloc=%x\n", 0x2200); // "Textbox game_alloc=%x" ASSERT(msgCtx->textboxSegment != NULL, "message->fukidashiSegment != NULL", "../z_construct.c", 352); - Font_LoadOrderedFont(&globalCtx->msgCtx.font); + Font_LoadOrderedFont(&play->msgCtx.font); YREG(31) = 0; } @@ -600,6 +600,6 @@ void func_80111070(void) { VREG(92) = -63; } -void func_80112098(GlobalContext* globalCtx) { +void func_80112098(PlayState* play) { func_80111070(); } diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c index c405d58df..c24f94654 100644 --- a/src/code/z_debug_display.c +++ b/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, "../z_debug_display.c", 169); +void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_debug_display.c", 169); - 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, "../z_debug_display.c", 189), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_debug_display.c", 189), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gDebugSpriteDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_debug_display.c", 192); + CLOSE_DISPS(play->state.gfxCtx, "../z_debug_display.c", 192); } -void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_debug_display.c", 211); +void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* dlist, PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_debug_display.c", 211); - 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, "../z_debug_display.c", 228), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_debug_display.c", 228), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, dlist); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_debug_display.c", 231); + CLOSE_DISPS(play->state.gfxCtx, "../z_debug_display.c", 231); } diff --git a/src/code/z_demo.c b/src/code/z_demo.c index f7bc14e79..f5b730a0e 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -32,14 +32,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, @@ -103,9 +103,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]; @@ -125,30 +125,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)) { @@ -164,7 +164,7 @@ void func_800645A0(GlobalContext* globalCtx, CutsceneContext* csCtx) { gSaveContext.cutsceneTrigger = 1; } - if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->transitionTrigger == TRANS_TRIGGER_START)) { + if ((gSaveContext.cutsceneTrigger != 0) && (play->transitionTrigger == TRANS_TRIGGER_START)) { gSaveContext.cutsceneTrigger = 0; } @@ -175,42 +175,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; @@ -229,60 +229,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.precipitation[PRECIP_RAIN_MAX] = 20; + play->envCtx.precipitation[PRECIP_RAIN_MAX] = 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 == ENTR_TOKINOMA_0) { - 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.changeSkyboxState = CHANGE_SKYBOX_REQUESTED; - globalCtx->envCtx.skyboxConfig = 1; - globalCtx->envCtx.changeSkyboxNextConfig = 0; - globalCtx->envCtx.changeSkyboxTimer = 60; - globalCtx->envCtx.changeLightEnabled = true; - globalCtx->envCtx.lightConfig = 0; - globalCtx->envCtx.changeLightNextConfig = 1; - globalCtx->envCtx.changeLightTimer = globalCtx->envCtx.changeDuration = 60; + play->envCtx.changeSkyboxState = CHANGE_SKYBOX_REQUESTED; + play->envCtx.skyboxConfig = 1; + play->envCtx.changeSkyboxNextConfig = 0; + play->envCtx.changeSkyboxTimer = 60; + play->envCtx.changeLightEnabled = true; + play->envCtx.lightConfig = 0; + play->envCtx.changeLightNextConfig = 1; + play->envCtx.changeLightTimer = play->envCtx.changeDuration = 60; } 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.precipitation[PRECIP_SNOW_MAX] = 16; + play->envCtx.precipitation[PRECIP_SNOW_MAX] = 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: @@ -293,27 +293,26 @@ 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, - 144, 24, 20); + 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); @@ -325,12 +324,12 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* } break; case 18: - globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; - globalCtx->envCtx.stormRequest = STORM_REQUEST_STOP; + play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; + play->envCtx.stormRequest = STORM_REQUEST_STOP; if (gSaveContext.dayTime < CLOCK_TIME(7, 0)) { gSaveContext.dayTime += 30; } - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] == 0) { + if (play->envCtx.precipitation[PRECIP_RAIN_CUR] == 0) { gWeatherMode = WEATHER_MODE_CLEAR; Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_RAIN, CHANNEL_IO_PORT_1, 0); } @@ -357,7 +356,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; @@ -368,45 +367,45 @@ void func_80064824(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* case 26: if ((gSaveContext.dayTime < CLOCK_TIME(4, 30)) || (gSaveContext.dayTime >= CLOCK_TIME(6, 30))) { if ((gSaveContext.dayTime >= CLOCK_TIME(6, 30)) && (gSaveContext.dayTime < CLOCK_TIME(16, 0))) { - globalCtx->envCtx.lightSettingOverride = 1; + play->envCtx.lightSettingOverride = 1; } else if ((gSaveContext.dayTime >= CLOCK_TIME(16, 0)) && (gSaveContext.dayTime <= CLOCK_TIME(18, 30))) { - globalCtx->envCtx.lightSettingOverride = 2; + play->envCtx.lightSettingOverride = 2; } else { - globalCtx->envCtx.lightSettingOverride = 3; + play->envCtx.lightSettingOverride = 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 = true; + play->unk_11DE9 = true; break; case 29: - globalCtx->unk_11DE9 = false; + play->unk_11DE9 = false; 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 = SANDSTORM_FILL; + play->envCtx.sandstormState = SANDSTORM_FILL; } func_800788CC(NA_SE_EV_SAND_STORM - SFX_FLAG); break; @@ -428,29 +427,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.lightSettingOverride = cmd->setting - 1; - globalCtx->envCtx.lightBlend = 1.0f; + play->envCtx.lightSettingOverride = cmd->setting - 1; + play->envCtx.lightBlend = 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)) { @@ -465,14 +464,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; @@ -486,23 +485,23 @@ 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; - 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->transitionTrigger == TRANS_TRIGGER_OFF)) { + (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->transitionTrigger == TRANS_TRIGGER_OFF)) { Audio_PlaySoundGeneral(NA_SE_SY_PIECE_OF_HEART, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); temp = 1; } if ((csCtx->frames == cmd->startFrame) || (temp != 0) || - ((csCtx->frames > 20) && CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_START) && + ((csCtx->frames > 20) && CHECK_BTN_ALL(play->state.input[0].press.button, BTN_START) && (gSaveContext.fileNum != 0xFEDC))) { csCtx->state = CS_STATE_UNSKIPPABLE_EXEC; Audio_SetCutsceneFlag(0); @@ -518,477 +517,477 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt switch (cmd->base) { case 1: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 2: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FILL_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FILL_WHITE; break; case 3: - globalCtx->nextEntranceIndex = ENTR_SPOT09_0; + play->nextEntranceIndex = ENTR_SPOT09_0; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FILL_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FILL_WHITE; break; case 4: - globalCtx->nextEntranceIndex = ENTR_SPOT16_0; + play->nextEntranceIndex = ENTR_SPOT16_0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FILL_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FILL_WHITE; break; case 5: - globalCtx->nextEntranceIndex = ENTR_SPOT04_0; + play->nextEntranceIndex = ENTR_SPOT04_0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FILL_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FILL_WHITE; break; case 6: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FILL_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FILL_WHITE; break; case 7: - globalCtx->nextEntranceIndex = ENTR_SPOT04_0; + play->nextEntranceIndex = ENTR_SPOT04_0; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_INSTANT; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_INSTANT; break; case 8: gSaveContext.fw.set = 0; gSaveContext.respawn[RESPAWN_MODE_TOP].data = 0; if (!GET_EVENTCHKINF(EVENTCHKINF_45)) { SET_EVENTCHKINF(EVENTCHKINF_45); - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionType = TRANS_TYPE_INSTANT; + play->transitionType = TRANS_TYPE_INSTANT; } else { if (gSaveContext.sceneSetupIndex < 4) { if (!LINK_IS_ADULT) { - globalCtx->linkAgeOnLoad = LINK_AGE_ADULT; + play->linkAgeOnLoad = LINK_AGE_ADULT; } else { - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; + play->linkAgeOnLoad = LINK_AGE_CHILD; } } - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_TOKINOMA_2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } break; case 9: - globalCtx->nextEntranceIndex = ENTR_SPOT09_0; + play->nextEntranceIndex = ENTR_SPOT09_0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FILL_BROWN; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FILL_BROWN; break; case 10: - globalCtx->nextEntranceIndex = ENTR_LINK_HOME_0; + play->nextEntranceIndex = ENTR_LINK_HOME_0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 11: - globalCtx->nextEntranceIndex = ENTR_SPOT04_0; + play->nextEntranceIndex = ENTR_SPOT04_0; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 12: - globalCtx->nextEntranceIndex = ENTR_SPOT16_5; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT16_5; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 13: - globalCtx->nextEntranceIndex = ENTR_SPOT08_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT08_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 14: - globalCtx->nextEntranceIndex = ENTR_SPOT04_11; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT04_11; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 15: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 16: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 17: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 18: SET_EVENTCHKINF(EVENTCHKINF_4F); - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_4; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_TOKINOMA_4; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 19: - globalCtx->nextEntranceIndex = ENTR_SPOT16_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->nextEntranceIndex = ENTR_SPOT16_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; gSaveContext.cutsceneIndex = 0x8000; break; case 21: - globalCtx->nextEntranceIndex = ENTR_SPOT06_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT06_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 22: - Item_Give(globalCtx, ITEM_SONG_REQUIEM); - globalCtx->nextEntranceIndex = ENTR_SPOT11_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + Item_Give(play, ITEM_SONG_REQUIEM); + play->nextEntranceIndex = ENTR_SPOT11_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 23: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF8; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 24: - globalCtx->nextEntranceIndex = ENTR_BDAN_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_BDAN_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 25: - globalCtx->linkAgeOnLoad = LINK_AGE_ADULT; - globalCtx->nextEntranceIndex = ENTR_KENJYANOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_ADULT; + play->nextEntranceIndex = ENTR_KENJYANOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 26: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 27: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 28: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 29: - globalCtx->nextEntranceIndex = ENTR_KENJYANOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_KENJYANOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.chamberCutsceneNum = 0; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 30: - globalCtx->nextEntranceIndex = ENTR_KENJYANOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; - Item_Give(globalCtx, ITEM_MEDALLION_FIRE); + play->nextEntranceIndex = ENTR_KENJYANOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; + Item_Give(play, ITEM_MEDALLION_FIRE); gSaveContext.chamberCutsceneNum = 1; break; case 31: - globalCtx->nextEntranceIndex = ENTR_KENJYANOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_KENJYANOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.chamberCutsceneNum = 2; break; case 32: - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_SPOT00_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionType = TRANS_TYPE_INSTANT; + play->transitionType = TRANS_TYPE_INSTANT; break; case 33: - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT00_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 34: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 35: - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT00_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 38: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 39: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF9; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 40: - globalCtx->linkAgeOnLoad = LINK_AGE_ADULT; - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_ADULT; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFFA; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 41: - globalCtx->nextEntranceIndex = ENTR_SPOT06_5; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT06_5; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 42: - globalCtx->nextEntranceIndex = ENTR_SPOT01_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT01_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 43: - globalCtx->nextEntranceIndex = ENTR_HAKASITARELAY_2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->nextEntranceIndex = ENTR_HAKASITARELAY_2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 44: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_3; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE_INSTANT; + play->nextEntranceIndex = ENTR_TOKINOMA_3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE_INSTANT; break; case 46: SET_EVENTCHKINF(EVENTCHKINF_4F); - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_4; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->nextEntranceIndex = ENTR_TOKINOMA_4; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 47: - Item_Give(globalCtx, ITEM_SONG_NOCTURNE); + Item_Give(play, ITEM_SONG_NOCTURNE); SET_EVENTCHKINF(EVENTCHKINF_54); - globalCtx->nextEntranceIndex = ENTR_SPOT01_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT01_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 48: - globalCtx->nextEntranceIndex = ENTR_SPOT11_4; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_SANDSTORM_END; + play->nextEntranceIndex = ENTR_SPOT11_4; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_SANDSTORM_END; gSaveContext.nextTransitionType = TRANS_TYPE_SANDSTORM_END; break; case 49: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_5; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->nextEntranceIndex = ENTR_TOKINOMA_5; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; break; case 50: - globalCtx->nextEntranceIndex = ENTR_SPOT01_13; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE_INSTANT; + play->nextEntranceIndex = ENTR_SPOT01_13; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE_INSTANT; break; case 51: - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; + play->nextEntranceIndex = ENTR_SPOT00_0; gSaveContext.cutsceneIndex = 0xFFF8; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_CIRCLE(TCA_NORMAL, TCC_WHITE, TCS_SLOW); + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_CIRCLE(TCA_NORMAL, TCC_WHITE, TCS_SLOW); break; case 52: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; + play->nextEntranceIndex = ENTR_TOKINOMA_0; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_INSTANT; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_INSTANT; break; case 53: - globalCtx->nextEntranceIndex = ENTR_SPOT00_16; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT00_16; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 54: gSaveContext.gameMode = 3; Audio_SetSoundBanksMute(0x6F); - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_SPOT09_0; + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_SPOT09_0; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 55: - globalCtx->nextEntranceIndex = ENTR_SPOT12_0; + play->nextEntranceIndex = ENTR_SPOT12_0; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 56: - globalCtx->nextEntranceIndex = ENTR_SPOT01_0; + play->nextEntranceIndex = ENTR_SPOT01_0; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 57: - globalCtx->nextEntranceIndex = ENTR_SPOT16_0; + play->nextEntranceIndex = ENTR_SPOT16_0; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 58: - globalCtx->nextEntranceIndex = ENTR_SPOT18_0; + play->nextEntranceIndex = ENTR_SPOT18_0; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 59: - globalCtx->nextEntranceIndex = ENTR_SPOT06_0; + play->nextEntranceIndex = ENTR_SPOT06_0; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 60: - globalCtx->nextEntranceIndex = ENTR_SPOT08_0; + play->nextEntranceIndex = ENTR_SPOT08_0; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 61: - globalCtx->nextEntranceIndex = ENTR_SPOT07_0; + play->nextEntranceIndex = ENTR_SPOT07_0; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 62: - globalCtx->linkAgeOnLoad = LINK_AGE_ADULT; - globalCtx->nextEntranceIndex = ENTR_SPOT04_0; + play->linkAgeOnLoad = LINK_AGE_ADULT; + play->nextEntranceIndex = ENTR_SPOT04_0; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 63: - globalCtx->nextEntranceIndex = ENTR_SPOT04_0; + play->nextEntranceIndex = ENTR_SPOT04_0; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 64: - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; + play->nextEntranceIndex = ENTR_SPOT00_0; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 65: - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_SPOT20_0; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 66: - globalCtx->nextEntranceIndex = ENTR_SPOT01_14; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT01_14; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 67: - globalCtx->nextEntranceIndex = ENTR_SPOT00_9; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT00_9; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 68: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 69: - globalCtx->nextEntranceIndex = ENTR_SPOT04_12; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT04_12; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 70: - globalCtx->nextEntranceIndex = ENTR_SPOT16_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT16_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 71: gSaveContext.equips.equipment |= EQUIP_VALUE_TUNIC_KOKIRI << (EQUIP_TYPE_TUNIC * 4); - Player_SetEquipmentData(globalCtx, player); + Player_SetEquipmentData(play, player); gSaveContext.equips.equipment |= EQUIP_VALUE_BOOTS_KOKIRI << (EQUIP_TYPE_BOOTS * 4); - Player_SetEquipmentData(globalCtx, player); - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + Player_SetEquipmentData(play, player); + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 72: - globalCtx->nextEntranceIndex = ENTR_NAKANIWA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_NAKANIWA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 73: - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 74: - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; case 75: - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF4; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 76: - globalCtx->linkAgeOnLoad = LINK_AGE_ADULT; - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_ADULT; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF5; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 77: - globalCtx->linkAgeOnLoad = LINK_AGE_CHILD; - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->linkAgeOnLoad = LINK_AGE_CHILD; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 78: - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 79: case 80: @@ -1005,177 +1004,177 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt case 91: case 92: case 93: - globalCtx->nextEntranceIndex = ENTR_SPOT20_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT20_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 94: - globalCtx->nextEntranceIndex = ENTR_SPOT20_1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT20_1; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 95: if (GET_EVENTCHKINF(EVENTCHKINF_48) && GET_EVENTCHKINF(EVENTCHKINF_49) && GET_EVENTCHKINF(EVENTCHKINF_4A)) { - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_TOKINOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; } else { switch (gSaveContext.sceneSetupIndex) { case 8: - globalCtx->nextEntranceIndex = ENTR_SPOT05_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT05_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 9: - globalCtx->nextEntranceIndex = ENTR_SPOT17_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT17_0; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 10: - globalCtx->nextEntranceIndex = ENTR_SPOT06_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT06_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF0; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; } } break; case 96: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW)) { - globalCtx->nextEntranceIndex = ENTR_KENJYANOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_KENJYANOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE_FAST; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; } else { SET_EVENTCHKINF(EVENTCHKINF_C8); - globalCtx->nextEntranceIndex = ENTR_SPOT11_8; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT11_8; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } break; case 97: if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT)) { - globalCtx->nextEntranceIndex = ENTR_KENJYANOMA_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_KENJYANOMA_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE_FAST; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; } else { - globalCtx->nextEntranceIndex = ENTR_SPOT02_8; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT02_8; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; } break; case 98: - globalCtx->nextEntranceIndex = ENTR_SPOT17_5; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT17_5; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; case 99: - globalCtx->nextEntranceIndex = ENTR_SPOT05_3; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT05_3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 100: - globalCtx->nextEntranceIndex = ENTR_SPOT04_0; + play->nextEntranceIndex = ENTR_SPOT04_0; gSaveContext.cutsceneIndex = 0xFFF8; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; case 101: - globalCtx->nextEntranceIndex = ENTR_SPOT11_6; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_SANDSTORM_END; + play->nextEntranceIndex = ENTR_SPOT11_6; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_SANDSTORM_END; break; case 102: - globalCtx->nextEntranceIndex = ENTR_TOKINOMA_6; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_TOKINOMA_6; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 103: - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT00_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF3; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 104: switch (sTitleCsState) { case 0: - globalCtx->nextEntranceIndex = ENTR_JYASINBOSS_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_JYASINBOSS_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF2; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; sTitleCsState++; break; case 1: - globalCtx->nextEntranceIndex = ENTR_SPOT17_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT17_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; sTitleCsState++; break; case 2: - globalCtx->nextEntranceIndex = ENTR_HIRAL_DEMO_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_HIRAL_DEMO_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF6; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; sTitleCsState = 0; break; } break; case 105: - globalCtx->nextEntranceIndex = ENTR_SPOT02_0; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = ENTR_SPOT02_0; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.cutsceneIndex = 0xFFF1; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 106: - globalCtx->nextEntranceIndex = ENTR_HAKAANA_OUKE_1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_HAKAANA_OUKE_1; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 107: - globalCtx->nextEntranceIndex = ENTR_GANONTIKA_2; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_GANONTIKA_2; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 108: - globalCtx->nextEntranceIndex = ENTR_GANONTIKA_3; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_GANONTIKA_3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 109: - globalCtx->nextEntranceIndex = ENTR_GANONTIKA_4; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_GANONTIKA_4; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 110: - globalCtx->nextEntranceIndex = ENTR_GANONTIKA_5; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_GANONTIKA_5; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 111: - globalCtx->nextEntranceIndex = ENTR_GANONTIKA_6; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_GANONTIKA_6; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 112: - globalCtx->nextEntranceIndex = ENTR_GANONTIKA_7; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_GANONTIKA_7; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 113: if (Flags_GetEventChkInf(EVENTCHKINF_BB) && Flags_GetEventChkInf(EVENTCHKINF_BC) && Flags_GetEventChkInf(EVENTCHKINF_BD) && Flags_GetEventChkInf(EVENTCHKINF_BE) && Flags_GetEventChkInf(EVENTCHKINF_BF) && Flags_GetEventChkInf(EVENTCHKINF_AD)) { - 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; @@ -1185,70 +1184,70 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt } break; case 114: - globalCtx->nextEntranceIndex = ENTR_SPOT00_3; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT00_3; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; break; case 115: - globalCtx->nextEntranceIndex = ENTR_SPOT00_17; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK; + play->nextEntranceIndex = ENTR_SPOT00_17; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_BLACK; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 116: if (GET_EVENTCHKINF(EVENTCHKINF_C8)) { - globalCtx->nextEntranceIndex = ENTR_SPOT02_8; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT02_8; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; } else { - globalCtx->nextEntranceIndex = ENTR_SPOT11_8; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_SPOT11_8; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; } gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; break; case 117: gSaveContext.gameMode = 3; Audio_SetSoundBanksMute(0x6F); - globalCtx->linkAgeOnLoad = LINK_AGE_ADULT; - globalCtx->nextEntranceIndex = ENTR_SPOT00_0; + play->linkAgeOnLoad = LINK_AGE_ADULT; + play->nextEntranceIndex = ENTR_SPOT00_0; gSaveContext.cutsceneIndex = 0xFFF7; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; break; case 118: gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = ENTR_GANON_DEMO_0; - Play_TriggerVoidOut(globalCtx); + Play_TriggerVoidOut(play); gSaveContext.respawnFlag = -2; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; break; case 119: gSaveContext.dayTime = CLOCK_TIME(12, 0); gSaveContext.skyboxTime = CLOCK_TIME(12, 0); - globalCtx->nextEntranceIndex = ENTR_NAKANIWA_1; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = ENTR_NAKANIWA_1; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; 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 == ENTR_KENJYANOMA_0)) { Audio_PlaySoundGeneral(NA_SE_SY_WHITE_OUT_S, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -1257,47 +1256,47 @@ void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* cs (gSaveContext.entranceIndex == ENTR_YOUSEI_IZUMI_YOKO_0))) { Audio_PlaySoundGeneral(NA_SE_EV_WHITE_OUT, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - } 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; @@ -1307,13 +1306,13 @@ void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* cs 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; @@ -1322,17 +1321,17 @@ void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* cs 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 Eye Points -s32 Cutscene_Command_CameraEyePoints(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { +s32 Cutscene_Command_CameraEyePoints(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { s32 shouldContinue = 1; CsCmdBase* cmdBase = (CsCmdBase*)cmd; s32 size; @@ -1347,12 +1346,12 @@ s32 Cutscene_Command_CameraEyePoints(GlobalContext* globalCtx, CutsceneContext* if (csCtx->unk_1A != 0) { csCtx->unk_18 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - Play_CameraChangeSetting(globalCtx, csCtx->subCamId, CAM_SET_CS_0); - Play_ChangeCameraStatus(globalCtx, sReturnToCamId, CAM_STAT_WAIT); - Play_ChangeCameraStatus(globalCtx, csCtx->subCamId, CAM_STAT_ACTIVE); - Camera_ResetAnim(Play_GetCamera(globalCtx, csCtx->subCamId)); - Camera_SetCSParams(Play_GetCamera(globalCtx, csCtx->subCamId), csCtx->subCamLookAtPoints, - csCtx->subCamEyePoints, GET_PLAYER(globalCtx), relativeToLink); + Play_CameraChangeSetting(play, csCtx->subCamId, CAM_SET_CS_0); + Play_ChangeCameraStatus(play, sReturnToCamId, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); + Camera_ResetAnim(Play_GetCamera(play, csCtx->subCamId)); + Camera_SetCSParams(Play_GetCamera(play, csCtx->subCamId), csCtx->subCamLookAtPoints, + csCtx->subCamEyePoints, GET_PLAYER(play), relativeToLink); } } } @@ -1369,7 +1368,7 @@ s32 Cutscene_Command_CameraEyePoints(GlobalContext* globalCtx, CutsceneContext* } // Command 0x2 & 0x6: Camera At Points -s32 Cutscene_Command_CameraLookAtPoints(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { +s32 Cutscene_Command_CameraLookAtPoints(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 relativeToLink) { s32 shouldContinue = 1; CsCmdBase* cmdBase = (CsCmdBase*)cmd; s32 size; @@ -1384,12 +1383,12 @@ s32 Cutscene_Command_CameraLookAtPoints(GlobalContext* globalCtx, CutsceneContex if (csCtx->unk_1B != 0) { D_8015FCC0 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - Play_CameraChangeSetting(globalCtx, csCtx->subCamId, CAM_SET_CS_0); - Play_ChangeCameraStatus(globalCtx, sReturnToCamId, CAM_STAT_WAIT); - Play_ChangeCameraStatus(globalCtx, csCtx->subCamId, CAM_STAT_ACTIVE); - Camera_ResetAnim(Play_GetCamera(globalCtx, csCtx->subCamId)); - Camera_SetCSParams(Play_GetCamera(globalCtx, csCtx->subCamId), csCtx->subCamLookAtPoints, - csCtx->subCamEyePoints, GET_PLAYER(globalCtx), relativeToLink); + Play_CameraChangeSetting(play, csCtx->subCamId, CAM_SET_CS_0); + Play_ChangeCameraStatus(play, sReturnToCamId, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); + Camera_ResetAnim(Play_GetCamera(play, csCtx->subCamId)); + Camera_SetCSParams(Play_GetCamera(play, csCtx->subCamId), csCtx->subCamLookAtPoints, + csCtx->subCamEyePoints, GET_PLAYER(play), relativeToLink); } } } @@ -1406,7 +1405,7 @@ s32 Cutscene_Command_CameraLookAtPoints(GlobalContext* globalCtx, CutsceneContex } // Command 0x7: ? (Related to camera positons) -s32 Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 unused) { +s32 Cutscene_Command_07(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 unused) { CsCmdBase* cmdBase = (CsCmdBase*)cmd; s32 size; Vec3f sp3C; @@ -1424,11 +1423,11 @@ s32 Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cm if (csCtx->unk_1A != 0) { D_8015FCC2 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - subCam = Play_GetCamera(globalCtx, csCtx->subCamId); + subCam = Play_GetCamera(play, csCtx->subCamId); subCam->player = NULL; - Play_ChangeCameraStatus(globalCtx, CAM_ID_MAIN, CAM_STAT_WAIT); - Play_ChangeCameraStatus(globalCtx, csCtx->subCamId, CAM_STAT_ACTIVE); - Play_CameraChangeSetting(globalCtx, csCtx->subCamId, CAM_SET_FREE0); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); + Play_CameraChangeSetting(play, csCtx->subCamId, CAM_SET_FREE0); sp28 = csCtx->subCamLookAtPoints->cameraRoll * 1.40625f; Camera_SetParam(subCam, 64, &sp28); sp3C.x = csCtx->subCamLookAtPoints->pos.x; @@ -1437,8 +1436,8 @@ s32 Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cm sp30.x = csCtx->subCamEyePoints->pos.x; sp30.y = csCtx->subCamEyePoints->pos.y; sp30.z = csCtx->subCamEyePoints->pos.z; - Play_CameraSetAtEye(globalCtx, csCtx->subCamId, &sp3C, &sp30); - Play_CameraSetFov(globalCtx, csCtx->subCamId, csCtx->subCamEyePoints->viewAngle); + Play_CameraSetAtEye(play, csCtx->subCamId, &sp3C, &sp30); + Play_CameraSetFov(play, csCtx->subCamId, csCtx->subCamEyePoints->viewAngle); } } } @@ -1449,7 +1448,7 @@ s32 Cutscene_Command_07(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cm } // Command 0x8: ? (Related to camera focus points) -s32 Cutscene_Command_08(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cmd, u8 unused) { +s32 Cutscene_Command_08(PlayState* play, CutsceneContext* csCtx, u8* cmd, u8 unused) { CsCmdBase* cmdBase = (CsCmdBase*)cmd; s32 size; Vec3f sp3C; @@ -1467,19 +1466,19 @@ s32 Cutscene_Command_08(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cm if (csCtx->unk_1B != 0) { D_8015FCC4 = cmdBase->startFrame; if (D_8015FCC8 != 0) { - subCam = Play_GetCamera(globalCtx, csCtx->subCamId); + subCam = Play_GetCamera(play, csCtx->subCamId); subCam->player = NULL; - Play_ChangeCameraStatus(globalCtx, CAM_ID_MAIN, CAM_STAT_WAIT); - Play_ChangeCameraStatus(globalCtx, csCtx->subCamId, CAM_STAT_ACTIVE); - Play_CameraChangeSetting(globalCtx, csCtx->subCamId, CAM_SET_FREE0); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, csCtx->subCamId, CAM_STAT_ACTIVE); + Play_CameraChangeSetting(play, csCtx->subCamId, CAM_SET_FREE0); sp3C.x = csCtx->subCamLookAtPoints->pos.x; sp3C.y = csCtx->subCamLookAtPoints->pos.y; sp3C.z = csCtx->subCamLookAtPoints->pos.z; sp30.x = csCtx->subCamEyePoints->pos.x; sp30.y = csCtx->subCamEyePoints->pos.y; sp30.z = csCtx->subCamEyePoints->pos.z; - Play_CameraSetAtEye(globalCtx, csCtx->subCamId, &sp3C, &sp30); - Play_CameraSetFov(globalCtx, csCtx->subCamId, csCtx->subCamEyePoints->viewAngle); + Play_CameraSetAtEye(play, csCtx->subCamId, &sp3C, &sp30); + Play_CameraSetFov(play, csCtx->subCamId, csCtx->subCamEyePoints->viewAngle); } } } @@ -1490,7 +1489,7 @@ s32 Cutscene_Command_08(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cm } // 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; @@ -1499,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++; } @@ -1541,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); } } } @@ -1563,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; @@ -1582,7 +1581,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, return; } - if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_DRIGHT)) { + if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_DRIGHT)) { csCtx->state = CS_STATE_UNSKIPPABLE_INIT; return; } @@ -1600,7 +1599,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - func_80064824(globalCtx, csCtx, (void*)cutscenePtr); + func_80064824(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0x30; } break; @@ -1608,7 +1607,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_SetLighting(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_SetLighting(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0x30; } break; @@ -1616,7 +1615,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_PlayBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_PlayBGM(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0x30; } break; @@ -1624,7 +1623,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_StopBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_StopBGM(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0x30; } break; @@ -1632,7 +1631,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_FadeBGM(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_FadeBGM(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0x30; } break; @@ -1640,7 +1639,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - Cutscene_Command_09(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_09(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0xC; } break; @@ -1648,7 +1647,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, MemCpy(&cmdEntries, cutscenePtr, 4); cutscenePtr += 4; for (j = 0; j < cmdEntries; j++) { - func_80065134(globalCtx, csCtx, (void*)cutscenePtr); + func_80065134(play, csCtx, (void*)cutscenePtr); cutscenePtr += 0xC; } break; @@ -1860,26 +1859,26 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, } break; case CS_CMD_CAM_EYE: - cutscenePtr += Cutscene_Command_CameraEyePoints(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_CameraEyePoints(play, csCtx, (void*)cutscenePtr, 0); break; case CS_CMD_CAM_EYE_REL_TO_PLAYER: - cutscenePtr += Cutscene_Command_CameraEyePoints(globalCtx, csCtx, (void*)cutscenePtr, 1); + cutscenePtr += Cutscene_Command_CameraEyePoints(play, csCtx, (void*)cutscenePtr, 1); break; case CS_CMD_CAM_AT: - cutscenePtr += Cutscene_Command_CameraLookAtPoints(globalCtx, csCtx, (void*)cutscenePtr, 0); + cutscenePtr += Cutscene_Command_CameraLookAtPoints(play, csCtx, (void*)cutscenePtr, 0); break; case CS_CMD_CAM_AT_REL_TO_PLAYER: - cutscenePtr += Cutscene_Command_CameraLookAtPoints(globalCtx, csCtx, (void*)cutscenePtr, 1); + cutscenePtr += Cutscene_Command_CameraLookAtPoints(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: @@ -1888,14 +1887,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 += 0xC; } break; case CS_CMD_SCENE_TRANS_FX: cutscenePtr += 4; - Cutscene_Command_TransitionFX(globalCtx, csCtx, (void*)cutscenePtr); + Cutscene_Command_TransitionFX(play, csCtx, (void*)cutscenePtr); cutscenePtr += 8; break; default: @@ -1909,7 +1908,7 @@ 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; @@ -1919,39 +1918,39 @@ void func_80068C3C(GlobalContext* globalCtx, CutsceneContext* csCtx) { if (0) {} // Also necessary to match if (BREG(0) != 0) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_demo.c", 4101); + OPEN_DISPS(play->state.gfxCtx, "../z_demo.c", 4101); 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, "../z_demo.c", 4108); + CLOSE_DISPS(play->state.gfxCtx, "../z_demo.c", 4108); } 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++) { @@ -1968,12 +1967,12 @@ void func_80068DC0(GlobalContext* globalCtx, CutsceneContext* csCtx) { case 0x028E: case 0x0292: case 0x0476: - Play_CopyCamera(globalCtx, sReturnToCamId, csCtx->subCamId); + Play_CopyCamera(play, sReturnToCamId, csCtx->subCamId); } - Play_ChangeCameraStatus(globalCtx, sReturnToCamId, CAM_STAT_ACTIVE); - Play_ClearCamera(globalCtx, csCtx->subCamId); - func_8005B1A4(globalCtx->cameraPtrs[sReturnToCamId]); + Play_ChangeCameraStatus(play, sReturnToCamId, CAM_STAT_ACTIVE); + Play_ClearCamera(play, csCtx->subCamId); + func_8005B1A4(play->cameraPtrs[sReturnToCamId]); } Audio_SetCutsceneFlag(0); @@ -1981,15 +1980,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; @@ -2012,10 +2011,10 @@ void func_80068ECC(GlobalContext* globalCtx, CutsceneContext* csCtx) { D_8015FCC4 = 0xFFFF; csCtx->unk_1A = 0; csCtx->unk_1B = 0; - sReturnToCamId = globalCtx->activeCamId; + sReturnToCamId = play->activeCamId; if (D_8015FCC8 != 0) { - csCtx->subCamId = Play_CreateSubCamera(globalCtx); + csCtx->subCamId = Play_CreateSubCamera(play); } if (gSaveContext.cutsceneTrigger == 0) { @@ -2025,14 +2024,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; @@ -2042,13 +2041,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; @@ -2066,7 +2065,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; @@ -2074,7 +2073,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)) { @@ -2089,7 +2088,7 @@ void Cutscene_HandleConditionalTriggers(GlobalContext* globalCtx) { gSaveContext.cutsceneIndex = 0xFFF0; } else if ((gSaveContext.entranceIndex == ENTR_SPOT10_9) && !Flags_GetEventChkInf(EVENTCHKINF_C1)) { Flags_SetEventChkInf(EVENTCHKINF_C1); - Item_Give(globalCtx, ITEM_OCARINA_FAIRY); + Item_Give(play, ITEM_OCARINA_FAIRY); gSaveContext.entranceIndex = ENTR_SPOT10_0; gSaveContext.cutsceneIndex = 0xFFF0; } else if (CHECK_QUEST_ITEM(QUEST_MEDALLION_SPIRIT) && CHECK_QUEST_ITEM(QUEST_MEDALLION_SHADOW) && @@ -2107,10 +2106,10 @@ 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/src/code/z_draw.c b/src/code/z_draw.c index 20ff39b0b..3631f4c14 100644 --- a/src/code/z_draw.c +++ b/src/code/z_draw.c @@ -79,35 +79,35 @@ #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_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); typedef struct { - /* 0x00 */ void (*drawFunc)(GlobalContext*, s16); + /* 0x00 */ void (*drawFunc)(PlayState*, s16); /* 0x04 */ Gfx* dlists[8]; } DrawItemTableEntry; // size = 0x24 @@ -373,501 +373,448 @@ 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); } // All remaining functions in this file are draw functions referenced in the table and called by the function above -void GetItem_DrawMaskOrBombchu(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMaskOrBombchu(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 556); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 556); - func_80093BA8(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 560), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093BA8(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 560), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 565); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 565); } -void GetItem_DrawSoldOut(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawSoldOut(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 572); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 572); POLY_XLU_DISP = Gfx_CallSetupDL(POLY_XLU_DISP, 5); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 576), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 576), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 581); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 581); } -void GetItem_DrawBlueFire(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawBlueFire(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 588); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 588); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 592), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 592), 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, "../z_draw.c", 615), - G_MTX_MODELVIEW | G_MTX_LOAD); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 615), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 621); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 621); } -void GetItem_DrawPoes(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawPoes(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 628); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 628); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 632), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 632), 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, "../z_draw.c", 641), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 641), 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, "../z_draw.c", 656), - G_MTX_MODELVIEW | G_MTX_LOAD); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 656), 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, "../z_draw.c", 663); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 663); } -void GetItem_DrawFairy(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawFairy(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 670); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 670); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 674), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 674), 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, "../z_draw.c", 683), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 683), 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, "../z_draw.c", 698), - G_MTX_MODELVIEW | G_MTX_LOAD); + Matrix_ReplaceRotation(&play->billboardMtxF); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 698), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 704); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 704); } -void GetItem_DrawMirrorShield(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMirrorShield(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 712); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 712); - 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, - 32)); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 723), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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(play->state.gfxCtx, "../z_draw.c", 723), 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, "../z_draw.c", 730), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 730), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 735); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 735); } -void GetItem_DrawSkullToken(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawSkullToken(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 742); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 742); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 746), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 746), 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, "../z_draw.c", 760), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 760), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 765); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 765); } -void GetItem_DrawEggOrMedallion(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawEggOrMedallion(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 772); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 772); - func_80093BA8(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 776), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093BA8(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 776), 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, "../z_draw.c", 783); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 783); } -void GetItem_DrawCompass(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawCompass(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 811); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 811); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 815), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 815), 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, "../z_draw.c", 822), - G_MTX_MODELVIEW | G_MTX_LOAD); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 822), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 827); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 827); } -void GetItem_DrawPotion(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawPotion(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 834); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 834); - 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, "../z_draw.c", 845), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 845), 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, "../z_draw.c", 855), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 855), 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, "../z_draw.c", 861); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 861); } -void GetItem_DrawGoronSword(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawGoronSword(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 868); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 868); - 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, "../z_draw.c", 878), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 878), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 883); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 883); } -void GetItem_DrawDekuNuts(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawDekuNuts(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 890); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 890); - 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, "../z_draw.c", 901), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 901), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 906); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 906); } -void GetItem_DrawRecoveryHeart(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawRecoveryHeart(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 913); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 913); - 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, "../z_draw.c", 924), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 924), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 929); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 929); } -void GetItem_DrawFish(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawFish(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 936); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 936); - 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, "../z_draw.c", 947), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 947), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 952); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 952); } -void GetItem_DrawOpa0(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa0(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 959); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 959); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 963), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 963), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDrawItemTable[drawId].dlists[0]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 968); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 968); } -void GetItem_DrawOpa0Xlu1(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa0Xlu1(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 975); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 975); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 979), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 979), 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, "../z_draw.c", 986), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 986), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[1]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 991); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 991); } -void GetItem_DrawXlu01(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawXlu01(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 998); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 998); - func_80093D84(globalCtx->state.gfxCtx); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1002), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1002), 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, "../z_draw.c", 1008); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1008); } -void GetItem_DrawOpa10Xlu2(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa10Xlu2(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1015); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1015); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1019), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1019), 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, "../z_draw.c", 1027), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1027), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, sDrawItemTable[drawId].dlists[2]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1032); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1032); } -void GetItem_DrawMagicArrow(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMagicArrow(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1039); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1039); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1043), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1043), 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, "../z_draw.c", 1050), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1050), 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, "../z_draw.c", 1056); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1056); } -void GetItem_DrawMagicSpell(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawMagicSpell(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1063); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1063); - 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, "../z_draw.c", 1074), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 1074), 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, "../z_draw.c", 1081); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1081); } -void GetItem_DrawOpa1023(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa1023(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1088); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1088); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1092), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1092), 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, "../z_draw.c", 1100); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1100); } -void GetItem_DrawOpa10Xlu32(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawOpa10Xlu32(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1108); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1108); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1112), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1112), 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, "../z_draw.c", 1120), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1120), 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, "../z_draw.c", 1126); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1126); } -void GetItem_DrawSmallRupee(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawSmallRupee(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1133); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1133); Matrix_Scale(0.7f, 0.7f, 0.7f, MTXMODE_APPLY); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1140), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1140), 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, "../z_draw.c", 1148), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1148), 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, "../z_draw.c", 1154); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1154); } -void GetItem_DrawScale(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawScale(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1162); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1162); - 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, "../z_draw.c", 1173), - G_MTX_MODELVIEW | G_MTX_LOAD); + 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, "../z_draw.c", 1173), 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, "../z_draw.c", 1181); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1181); } -void GetItem_DrawBulletBag(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawBulletBag(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1188); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1188); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1192), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1192), 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, "../z_draw.c", 1200), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D84(play->state.gfxCtx); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1200), 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, "../z_draw.c", 1207); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1207); } -void GetItem_DrawWallet(GlobalContext* globalCtx, s16 drawId) { +void GetItem_DrawWallet(PlayState* play, s16 drawId) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_draw.c", 1214); + OPEN_DISPS(play->state.gfxCtx, "../z_draw.c", 1214); - func_80093D18(globalCtx->state.gfxCtx); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_draw.c", 1218), - G_MTX_MODELVIEW | G_MTX_LOAD); + func_80093D18(play->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_draw.c", 1218), 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]); @@ -877,5 +824,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, "../z_draw.c", 1230); + CLOSE_DISPS(play->state.gfxCtx, "../z_draw.c", 1230); } diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c index fad499286..cafee2655 100644 --- a/src/code/z_eff_shield_particle.c +++ b/src/code/z_eff_shield_particle.c @@ -52,7 +52,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; } @@ -63,10 +63,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/src/code/z_eff_spark.c b/src/code/z_eff_spark.c index cfe8f628f..cc4910fa9 100644 --- a/src/code/z_eff_spark.c +++ b/src/code/z_eff_spark.c @@ -131,7 +131,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; @@ -210,7 +210,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/src/code/z_eff_ss_dead.c b/src/code/z_eff_ss_dead.c index af2c6ee73..444712d6b 100644 --- a/src/code/z_eff_ss_dead.c +++ b/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, "../z_eff_ss_dead.c", 113); + OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 113); displayListHead = POLY_OPA_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); @@ -25,15 +25,15 @@ void func_80026230(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a if (1) {} // Necessary to match - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 129); + CLOSE_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 129); } -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, "../z_eff_ss_dead.c", 141); + OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 141); cos = Math_CosS((0x4000 / arg3) * arg2); displayListHead = POLY_OPA_DISP; @@ -46,27 +46,27 @@ void func_80026400(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a if (1) {} // Necessary to match - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 153); + CLOSE_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 153); } } -void func_80026608(GlobalContext* globalCtx) { +void func_80026608(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 159); + OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 159); gDPPipeSync(POLY_OPA_DISP++); - POLY_OPA_DISP = Play_SetFog(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 164); + CLOSE_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 164); } -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, "../z_eff_ss_dead.c", 178); + OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 178); displayListHead = POLY_XLU_DISP; cos = Math_CosS((0x8000 / arg3) * arg2); @@ -86,14 +86,14 @@ void func_80026690(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a if (1) {} // Necessary to match - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 194); + CLOSE_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 194); } -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, "../z_eff_ss_dead.c", 201); + OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 201); displayListHead = POLY_XLU_DISP; cos = Math_CosS((0x4000 / arg3) * arg2); @@ -106,16 +106,16 @@ void func_80026860(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a if (1) {} // Necessary to match - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 212); + CLOSE_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 212); } -void func_80026A6C(GlobalContext* globalCtx) { +void func_80026A6C(PlayState* play) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 217); + OPEN_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 217); gDPPipeSync(POLY_XLU_DISP++); - POLY_XLU_DISP = Play_SetFog(globalCtx, POLY_XLU_DISP); + POLY_XLU_DISP = Play_SetFog(play, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_eff_ss_dead.c", 222); + CLOSE_DISPS(play->state.gfxCtx, "../z_eff_ss_dead.c", 222); } diff --git a/src/code/z_effect.c b/src/code/z_effect.c index d024d0892..a72fbc494 100644 --- a/src/code/z_effect.c +++ b/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: @@ -181,13 +181,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); } } } @@ -195,7 +195,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); } } } @@ -203,13 +203,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; } @@ -235,7 +235,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/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index a51d3ea07..004f4af02 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -3,7 +3,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; @@ -14,8 +14,7 @@ void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) { (u32)overlay->vramEnd - (u32)overlay->vramStart, overlay->vromEnd - overlay->vromStart); } - sEffectSsInfo.table = - GameState_Alloc(&globalCtx->state, tableSize * sizeof(EffectSs), "../z_effect_soft_sprite.c", 289); + sEffectSsInfo.table = GameState_Alloc(&play->state, tableSize * sizeof(EffectSs), "../z_effect_soft_sprite.c", 289); ASSERT(sEffectSsInfo.table != NULL, "EffectSS2Info.data_table != NULL", "../z_effect_soft_sprite.c", 290); sEffectSsInfo.searchStartIndex = 0; @@ -32,7 +31,7 @@ void EffectSs_InitInfo(GlobalContext* globalCtx, s32 tableSize) { } } -void EffectSs_ClearAll(GlobalContext* globalCtx) { +void EffectSs_ClearAll(PlayState* play) { u32 i; EffectSs* effectSs; EffectSsOverlay* overlay; @@ -153,10 +152,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; @@ -165,7 +164,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; @@ -234,7 +233,7 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init sEffectSsInfo.table[index].type = type; sEffectSsInfo.table[index].priority = priority; - 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." @@ -246,7 +245,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) { @@ -258,11 +257,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++) { @@ -275,26 +274,26 @@ 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) { - effectSs->draw(globalCtx, index, effectSs); + effectSs->draw(play, index, effectSs); } } // 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) { @@ -317,7 +316,7 @@ void EffectSs_DrawAll(GlobalContext* globalCtx) { EffectSs_Delete(&sEffectSsInfo.table[i]); } else { - EffectSs_Draw(globalCtx, i); + EffectSs_Draw(play, i); } } } diff --git a/src/code/z_effect_soft_sprite_old_init.c b/src/code/z_effect_soft_sprite_old_init.c index 8d052a8bf..04966a357 100644 --- a/src/code/z_effect_soft_sprite_old_init.c +++ b/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, "../z_effect_soft_sprite_old_init.c", 196); 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,84 @@ 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, - s16 life) { - EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); +void func_8002873C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { + 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, - s16 life) { - EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, scale, scaleStep, life, 0); +void func_800287AC(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep, s16 life) { + 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 +194,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 +202,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,26 +214,26 @@ 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, - Color_RGBA8* primColor, Color_RGBA8* envColor) { - EffectSsKiraKira_SpawnDispersed(globalCtx, pos, velocity, accel, primColor, envColor, 1000, 16); +void EffectSsKiraKira_SpawnSmall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor) { + EffectSsKiraKira_SpawnDispersed(play, pos, velocity, accel, primColor, envColor, 1000, 16); } -void EffectSsKiraKira_SpawnDispersed(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { +void EffectSsKiraKira_SpawnDispersed(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 scale, s32 life) { EffectSsKiraKiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -252,11 +250,11 @@ 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, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, s32 life) { +void EffectSsKiraKira_SpawnFocused(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 scale, s32 life) { EffectSsKiraKiraInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -271,26 +269,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,11 +298,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, - s16 scaleStep) { +void EffectSsBomb2_SpawnLayered(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep) { EffectSsBomb2InitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -314,12 +311,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 +330,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, - Color_RGBA8* primColor, Color_RGBA8* envColor, s16 life) { - EffectSsBlast_Spawn(globalCtx, pos, velocity, accel, primColor, envColor, 100, 375, 35, life); +void EffectSsBlast_SpawnShockwave(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s16 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 +369,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,19 +387,19 @@ 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, - s16 scale, s16 scaleStep) { +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 }; s32 randOffset = (Rand_ZeroOne() * 20.0f) - 10.0f; @@ -416,17 +413,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 +436,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 +456,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,13 +469,13 @@ 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, - s16 type, s16 scale) { +void EffectSsGSplash_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 type, + s16 scale) { EffectSsGSplashInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -493,33 +490,33 @@ 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, - s16 scale, s16 yaw, s16 life, s16 numBolts) { +void EffectSsLightning_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 scale, + s16 yaw, s16 life, s16 numBolts) { EffectSsLightningInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -530,13 +527,13 @@ 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, - s16 life, s16 colorProfile, s16 randXZ) { +void EffectSsDtBubble_SpawnColorProfile(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 life, + s16 colorProfile, s16 randXZ) { EffectSsDtBubbleInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -548,10 +545,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 +562,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,8 +576,8 @@ 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, - s16 objId, s16 life, Gfx* dList) { +void EffectSsHahen_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 unused, s16 scale, s16 objId, + s16 life, Gfx* dList) { EffectSsHahenInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -592,7 +589,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,8 +601,8 @@ 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, - s16 randScaleRange, s16 count, s16 objId, s16 life, Gfx* dList) { +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; Vec3f accel; @@ -618,8 +615,8 @@ 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, - life, dList); + EffectSsHahen_Spawn(play, pos, &velocity, &accel, unused, Rand_S16Offset(scale, randScaleRange), objId, life, + dList); } } @@ -629,19 +626,19 @@ 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, - s16 direction, s16 scale) { +void EffectSsSibuki_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 moveDelay, s16 direction, + s16 scale) { EffectSsSibukiInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -651,10 +648,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,27 +659,27 @@ 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, - s16 updateRate, s16 drawMode, s16 scale) { +void EffectSsGMagma2_Spawn(PlayState* play, Vec3f* pos, Color_RGBA8* primColor, Color_RGBA8* envColor, s16 updateRate, + s16 drawMode, s16 scale) { EffectSsGMagma2InitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -692,38 +689,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,8 +731,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, - u8 param) { +void EffectSsFhgFlash_SpawnLightBall(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, u8 param) { EffectSsFhgFlashInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -745,7 +741,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 +752,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 +761,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 +775,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,14 +790,14 @@ 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, - s16 arg6, s16 arg7, s16 arg8, s16 scale, s16 arg10, s16 arg11, s32 life, s16 colorIdx, - s16 objId, Gfx* dList) { +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; Math_Vec3f_Copy(&initParams.pos, pos); @@ -820,12 +816,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 +829,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 +863,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, - &accel, 25); + 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 +891,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,11 +917,11 @@ 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, - Color_RGBA8* primColor, Color_RGBA8* envColor, s32 life) { +void EffectSsEnIce_Spawn(PlayState* play, Vec3f* pos, f32 scale, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor, + Color_RGBA8* envColor, s32 life) { EffectSsEnIceInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -937,12 +933,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 +953,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 +968,20 @@ 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, - colorIntensity); + 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 +996,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 +1017,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 +1031,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 +1044,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 +1070,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 +1096,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 +1112,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,18 +1128,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, - s32 life) { - EffectSsDeadDs_Spawn(globalCtx, pos, &sZeroVec, &sZeroVec, scale, scaleStep, alpha, life); +void EffectSsDeadDs_SpawnStationary(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 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, - s16 lowerPriority, s16 repeatMode, s32 life) { +void EffectSsDeadSound_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, u16 sfxId, s16 lowerPriority, + s16 repeatMode, s32 life) { EffectSsDeadSoundInitParams initParams; Math_Vec3f_Copy(&initParams.pos, pos); @@ -1156,15 +1150,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, - s16 repeatMode, s32 life) { - EffectSsDeadSound_Spawn(globalCtx, pos, &sZeroVec, &sZeroVec, sfxId, lowerPriority, repeatMode, life); +void EffectSsDeadSound_SpawnStationary(PlayState* play, Vec3f* pos, u16 sfxId, s16 lowerPriority, s16 repeatMode, + s32 life) { + EffectSsDeadSound_Spawn(play, pos, &sZeroVec, &sZeroVec, sfxId, lowerPriority, repeatMode, life); } // EffectSsIceSmoke Spawn Functions @@ -1174,7 +1168,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 +1176,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/src/code/z_elf_message.c b/src/code/z_elf_message.c index 62c6ddb2f..0d119e1ce 100644 --- a/src/code/z_elf_message.c +++ b/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/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c index bab295577..2bfd53cc2 100644 --- a/src/code/z_en_a_keep.c +++ b/src/code/z_en_a_keep.c @@ -4,16 +4,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); @@ -82,7 +82,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; @@ -129,13 +129,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: @@ -157,8 +157,8 @@ void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) { thisx->flags |= ACTOR_FLAG_0 | ACTOR_FLAG_3; 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; @@ -178,25 +178,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); } } @@ -205,17 +205,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); } } } @@ -229,7 +229,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++; @@ -272,7 +272,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; @@ -301,7 +301,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); @@ -316,19 +316,19 @@ 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, + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 5.0f, 40.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); } else { - Actor_UpdateBgCheckInfo(globalCtx, &this->dyna.actor, 5.0f, 20.0f, 0.0f, + Actor_UpdateBgCheckInfo(play, &this->dyna.actor, 5.0f, 20.0f, 0.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); } @@ -341,17 +341,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, "../z_en_a_keep.c", 701); + OPEN_DISPS(play->state.gfxCtx, "../z_en_a_keep.c", 701); - func_80093D18(globalCtx->state.gfxCtx); + func_80093D18(play->state.gfxCtx); if (type >= A_OBJ_MAX) { type = A_OBJ_BOULDER_FRAGMENT; @@ -361,9 +361,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, "../z_en_a_keep.c", 712), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_a_keep.c", 712), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, sDLists[type]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_a_keep.c", 715); + CLOSE_DISPS(play->state.gfxCtx, "../z_en_a_keep.c", 715); } diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c index 196a1c8eb..f1b69c759 100644 --- a/src/code/z_en_item00.c +++ b/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, @@ -136,7 +136,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; @@ -149,14 +149,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; @@ -236,8 +236,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; @@ -245,8 +245,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; @@ -255,8 +255,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; @@ -286,41 +286,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; @@ -329,7 +329,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; @@ -350,21 +350,21 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) { break; } - if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { - func_8002F554(&this->actor, globalCtx, getItemId); + if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { + func_8002F554(&this->actor, play, getItemId); } 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 ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk_15A < 0)) || (this->actor.params == ITEM00_HEART_PIECE)) { this->actor.shape.rot.y += 960; @@ -410,7 +410,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; @@ -418,11 +418,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); } @@ -438,7 +438,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; @@ -477,12 +477,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, - &sEffectEnvColor); + EffectSsKiraKira_SpawnSmall(play, &pos, &sEffectVelocity, &sEffectAccel, &sEffectPrimColor, &sEffectEnvColor); } if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { @@ -493,12 +492,12 @@ 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)) { - func_8002F434(&this->actor, globalCtx, this->getItemId, 50.0f, 80.0f); + if (!Actor_HasParent(&this->actor, play)) { + func_8002F434(&this->actor, play, this->getItemId, 50.0f, 80.0f); this->unk_15A++; } else { this->getItemId = GI_NONE; @@ -526,7 +525,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; @@ -546,7 +545,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; @@ -555,12 +554,12 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { if (this->actor.gravity) { if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { - 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) || @@ -579,7 +578,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { } if (sp3A || D_80157D94[0]) { - Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 10.0f, 15.0f, 15.0f, + Actor_UpdateBgCheckInfo(play, &this->actor, 10.0f, 15.0f, 15.0f, UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); @@ -591,7 +590,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)) { @@ -605,30 +604,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; @@ -637,26 +636,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; @@ -694,8 +693,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { params = &this->actor.params; - if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, globalCtx)) { - func_8002F554(&this->actor, globalCtx, getItemId); + if ((getItemId != GI_NONE) && !Actor_HasParent(&this->actor, play)) { + func_8002F554(&this->actor, play, getItemId); } switch (*params) { @@ -706,8 +705,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; @@ -717,8 +716,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { Audio_PlaySoundGeneral(NA_SE_SY_GET_RUPY, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } 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; @@ -727,7 +726,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - Flags_SetCollectible(globalCtx, this->collectibleFlag); + Flags_SetCollectible(play, this->collectibleFlag); this->unk_15A = 15; this->unk_154 = 35; @@ -742,7 +741,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; @@ -753,28 +752,28 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_RUPEE_RED: case ITEM00_RUPEE_ORANGE: case ITEM00_RUPEE_PURPLE: - EnItem00_DrawRupee(this, globalCtx); + EnItem00_DrawRupee(this, play); break; case ITEM00_HEART_PIECE: - 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 (this->unk_15A < 0) { if (this->unk_15A == -1) { - s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART); + s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART); - if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) { + 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; } @@ -791,19 +790,19 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { case ITEM00_MAGIC_SMALL: case ITEM00_SEEDS: case ITEM00_SMALL_KEY: - EnItem00_DrawCollectible(this, globalCtx); + EnItem00_DrawCollectible(this, play); 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; @@ -814,14 +813,14 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) { /** * 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, "../z_en_item00.c", 1546); + OPEN_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1546); - 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; @@ -829,25 +828,25 @@ void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) { texIndex = this->actor.params - 0x10; } - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1562), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_item00.c", 1562), 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, "../z_en_item00.c", 1568); + CLOSE_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1568); } /** * 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) { s32 texIndex = this->actor.params - 3; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1594); + OPEN_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1594); - POLY_OPA_DISP = Play_SetFog(globalCtx, POLY_OPA_DISP); + POLY_OPA_DISP = Play_SetFog(play, POLY_OPA_DISP); if (this->actor.params == ITEM00_BOMBS_SPECIAL) { texIndex = 1; @@ -859,51 +858,51 @@ 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, "../z_en_item00.c", 1607), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_item00.c", 1607), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, gItemDropDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1611); + CLOSE_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1611); } /** * 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, "../z_en_item00.c", 1623); + OPEN_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1623); - func_80093D18(globalCtx->state.gfxCtx); - func_8002EBCC(&this->actor, globalCtx, 0); - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1634), + func_80093D18(play->state.gfxCtx); + func_8002EBCC(&this->actor, play, 0); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_item00.c", 1634), 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, "../z_en_item00.c", 1644), + func_80093D84(play->state.gfxCtx); + func_8002ED80(&this->actor, play, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_item00.c", 1644), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gHeartContainerInteriorDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1647); + CLOSE_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1647); } /** * 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) { s32 pad; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1658); + OPEN_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1658); - func_80093D84(globalCtx->state.gfxCtx); - func_8002ED80(&this->actor, globalCtx, 0); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_en_item00.c", 1670), + func_80093D84(play->state.gfxCtx); + func_8002ED80(&this->actor, play, 0); + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_en_item00.c", 1670), G_MTX_MODELVIEW | G_MTX_LOAD); gSPDisplayList(POLY_XLU_DISP++, gHeartPieceInteriorDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_en_item00.c", 1673); + CLOSE_DISPS(play->state.gfxCtx, "../z_en_item00.c", 1673); } /** @@ -942,7 +941,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; @@ -953,18 +952,18 @@ 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, - spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); - EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, - DEADSOUND_REPEAT_MODE_OFF, 40); + 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(play, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, DEADSOUND_REPEAT_MODE_OFF, + 40); } else { if (!param8000) { params = func_8001F404(params & 0x00FF); } if (params != -1) { - spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, - spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param3F00); + 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; spawnedActor->actor.speedXZ = 2.0f; @@ -985,7 +984,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; @@ -996,15 +995,15 @@ 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, - spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, FAIRY_HEAL_TIMED); - EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, - DEADSOUND_REPEAT_MODE_OFF, 40); + 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(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, - spawnPos->y, spawnPos->z, 0, 0, 0, params | param8000 | param3F00); + 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; spawnedActor->actor.speedXZ = 0.0f; @@ -1018,7 +1017,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; @@ -1065,9 +1064,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, - 0, 0, FAIRY_HEAL_TIMED); - EffectSsDeadSound_SpawnStationary(globalCtx, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, + Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0, + FAIRY_HEAL_TIMED); + EffectSsDeadSound_SpawnStationary(play, spawnPos, NA_SE_EV_BUTTERFRY_TO_FAIRY, true, DEADSOUND_REPEAT_MODE_OFF, 40); return; } else if (gSaveContext.health <= 0x30) { // 3 hearts or less @@ -1113,7 +1112,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3 if (!param8000) { dropId = func_8001F404(dropId); if (dropId != ITEM00_NONE) { - 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 != ITEM00_NONE)) { spawnedActor->actor.velocity.y = 8.0f; @@ -1132,7 +1131,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/src/code/z_face_reaction.c b/src/code/z_face_reaction.c index d463da4f7..2dbd56df2 100644 --- a/src/code/z_face_reaction.c +++ b/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/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c index 23889413a..20e8aa259 100644 --- a/src/code/z_fcurve_data_skelanime.c +++ b/src/code/z_fcurve_data_skelanime.c @@ -44,7 +44,7 @@ void SkelCurve_Clear(SkelCurve* skelCurve) { * * @return bool always true */ -s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, +s32 SkelCurve_Init(PlayState* play, SkelCurve* skelCurve, CurveSkeletonHeader* skeletonHeaderSeg, CurveAnimationHeader* animation) { SkelCurveLimb** limbs; CurveSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); @@ -62,7 +62,7 @@ s32 SkelCurve_Init(GlobalContext* globalCtx, SkelCurve* skelCurve, CurveSkeleton /** * Frees the joint table. */ -void SkelCurve_Destroy(GlobalContext* globalCtx, SkelCurve* skelCurve) { +void SkelCurve_Destroy(PlayState* play, SkelCurve* skelCurve) { if (skelCurve->jointTable != NULL) { ZeldaArena_FreeDebug(skelCurve->jointTable, "../z_fcurve_data_skelanime.c", 146); } @@ -92,7 +92,7 @@ typedef enum { * * @return bool true when the animation has finished. */ -s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) { +s32 SkelCurve_Update(PlayState* play, SkelCurve* skelCurve) { s16* jointData; u8* knotCounts; CurveAnimationHeader* animation; @@ -156,16 +156,16 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) { /** * Recursively draws limbs with appropriate properties. */ -void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skelCurve, - OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { +void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, + PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { SkelCurveLimb* limb = SEGMENTED_TO_VIRTUAL(skelCurve->skeleton[limbIndex]); - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279); + OPEN_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279); 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; @@ -192,7 +192,7 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_fcurve_data_skelanime.c", 321), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 321), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, dList); } @@ -201,13 +201,13 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel dList = limb->dList[0]; if (dList != NULL) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_fcurve_data_skelanime.c", 332), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 332), 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, "../z_fcurve_data_skelanime.c", 338), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 338), G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, dList); } @@ -218,25 +218,25 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel } if (postLimbDraw != NULL) { - postLimbDraw(globalCtx, skelCurve, limbIndex, data); + postLimbDraw(play, skelCurve, limbIndex, data); } if (limb->child != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + SkelCurve_DrawLimb(play, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } Matrix_Pop(); if (limb->sibling != LIMB_DONE) { - SkelCurve_DrawLimb(globalCtx, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + SkelCurve_DrawLimb(play, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_fcurve_data_skelanime.c", 371); + CLOSE_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 371); } -void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelCurve* skelCurve, - OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { +void SkelCurve_Draw(Actor* actor, PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw, + PostCurveLimbDraw postLimbDraw, s32 lod, void* data) { if (skelCurve->jointTable != NULL) { - SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); + SkelCurve_DrawLimb(play, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, data); } } diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c index 6f6697619..278cb5620 100644 --- a/src/code/z_game_dlftbls.c +++ b/src/code/z_game_dlftbls.c @@ -12,7 +12,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(Play_Init, Play_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/src/code/z_game_over.c b/src/code/z_game_over.c index e66b66e64..a0551a91e 100644 --- a/src/code/z_game_over.c +++ b/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; @@ -41,7 +41,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); } } } @@ -72,7 +72,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gSaveContext.buttonStatus[3] = gSaveContext.buttonStatus[4] = BTN_ENABLED; gSaveContext.unk_13E7 = gSaveContext.unk_13E8 = gSaveContext.unk_13EA = gSaveContext.unk_13EC = 0; - Environment_InitGameOverLights(globalCtx); + Environment_InitGameOverLights(play); gGameOverTimer = 20; if (1) {} v90 = VREG(90); @@ -92,7 +92,7 @@ void GameOver_Update(GlobalContext* globalCtx) { gGameOverTimer--; if (gGameOverTimer == 0) { - globalCtx->pauseCtx.state = 8; + play->pauseCtx.state = 8; gameOverCtx->state++; func_800AA15C(); } @@ -101,7 +101,7 @@ void GameOver_Update(GlobalContext* globalCtx) { case GAMEOVER_REVIVE_START: gameOverCtx->state++; gGameOverTimer = 0; - Environment_InitGameOverLights(globalCtx); + Environment_InitGameOverLights(play); ShrinkWindow_SetVal(0x20); return; @@ -137,7 +137,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/src/code/z_horse.c b/src/code/z_horse.c index d19444812..0cddd54b7 100644 --- a/src/code/z_horse.c +++ b/src/code/z_horse.c @@ -15,7 +15,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; @@ -23,7 +23,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; @@ -40,7 +40,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 }, @@ -49,41 +49,40 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) { }; if ((AREG(6) != 0) && (Flags_GetEventChkInf(EVENTCHKINF_18) || (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, "player->ride.actor != NULL", "../z_horse.c", 343); - 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); + horseActor = 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 == ENTR_SPOT20_7) && GET_EVENTCHKINF(EVENTCHKINF_18)) { 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, "horse_actor != NULL", "../z_horse.c", 389); - } else if ((globalCtx->sceneNum == gSaveContext.horseData.scene) && + } else if ((play->sceneNum == gSaveContext.horseData.scene) && (Flags_GetEventChkInf(EVENTCHKINF_18) || DREG(1) != 0)) { // "Set by existence of horse %d %d %d" osSyncPrintf("馬存在によるセット %d %d %d\n", gSaveContext.horseData.scene, Flags_GetEventChkInf(EVENTCHKINF_18), DREG(1)); if (func_8006CFC0(gSaveContext.horseData.scene)) { - Actor* horseActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, - gSaveContext.horseData.pos.x, gSaveContext.horseData.pos.y, - gSaveContext.horseData.pos.z, 0, gSaveContext.horseData.angle, 0, 1); + 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, "horse_actor != NULL", "../z_horse.c", 414); - if (globalCtx->sceneNum == SCENE_SPOT12) { + if (play->sceneNum == SCENE_SPOT12) { horseActor->room = -1; } } else { @@ -91,21 +90,20 @@ 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(EVENTCHKINF_18) && (DREG(1) == 0)) { - Actor* horseActor = - Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_HORSE, 0.0f, 0.0f, -500.0f, 0, 0, 0, 1); + } else if ((play->sceneNum == SCENE_SPOT20) && !Flags_GetEventChkInf(EVENTCHKINF_18) && (DREG(1) == 0)) { + Actor* horseActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_HORSE, 0.0f, 0.0f, -500.0f, 0, 0, 0, 1); ASSERT(horseActor != NULL, "horse_actor != NULL", "../z_horse.c", 443); } else if (Flags_GetEventChkInf(EVENTCHKINF_18) || (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, "horse_actor != NULL", "../z_horse.c", 466); - if (globalCtx->sceneNum == SCENE_SPOT12) { + if (play->sceneNum == SCENE_SPOT12) { horseActor->room = -1; } @@ -113,8 +111,8 @@ void func_8006D0EC(GlobalContext* globalCtx, Player* player) { } } } else if (!Flags_GetEventChkInf(EVENTCHKINF_18)) { - 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); } } } @@ -127,7 +125,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; @@ -152,24 +150,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, - spawnPos.z, 0, player->actor.world.rot.y, 0, 7); + 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, "player->ride.actor != NULL", "../z_horse.c", 561); - Actor_MountHorse(globalCtx, player, player->rideActor); - func_8002DE74(globalCtx, player); - gSaveContext.horseData.scene = globalCtx->sceneNum; - } else if ((globalCtx->sceneNum == SCENE_SPOT20) && (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6) && + Actor_MountHorse(play, player, player->rideActor); + func_8002DE74(play, player); + gSaveContext.horseData.scene = play->sceneNum; + } else if ((play->sceneNum == SCENE_SPOT20) && (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6) && !Flags_GetEventChkInf(EVENTCHKINF_18) && (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, "player->ride.actor != NULL", "../z_horse.c", 582); - 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 { @@ -181,22 +179,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, - 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); + 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, "player->ride.actor != NULL", "../z_horse.c", 628); - 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; @@ -205,9 +203,9 @@ void func_8006D684(GlobalContext* globalCtx, Player* player) { temp = 0x8000; } - player->rideActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + 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, "player->ride.actor != NULL", "../z_horse.c", 667); player->actor.world.pos.x = D_8011F9B8[i].pos.x; @@ -216,18 +214,17 @@ 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; - Play_CameraSetAtEye(globalCtx, globalCtx->activeCamId, &player->actor.world.pos, &sp54); + Play_CameraSetAtEye(play, play->activeCamId, &player->actor.world.pos, &sp54); } else { - Actor_Spawn(&globalCtx->actorCtx, globalCtx, 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); + 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); } break; } @@ -235,26 +232,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 == ENTR_SPOT00_11 || gSaveContext.entranceIndex == ENTR_SPOT00_12 || gSaveContext.entranceIndex == ENTR_SPOT00_13 || gSaveContext.entranceIndex == ENTR_SPOT00_15) && (gSaveContext.respawnFlag == 0)) || - ((globalCtx->sceneNum == SCENE_SPOT20) && (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6) && + ((play->sceneNum == SCENE_SPOT20) && (GET_EVENTINF_HORSES_STATE() == EVENTINF_HORSES_STATE_6) && !Flags_GetEventChkInf(EVENTCHKINF_18) && (DREG(1) == 0))) { - func_8006D684(globalCtx, player); + func_8006D684(play, player); } else { - func_8006D0EC(globalCtx, player); + func_8006D0EC(play, player); } } } diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index acc0ccb36..1c988043d 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -41,7 +41,7 @@ void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { } } -void KaleidoManager_Init(GlobalContext* globalCtx) { +void KaleidoManager_Init(PlayState* play) { s32 largestSize = 0; s32 size; u32 i; @@ -57,7 +57,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) { osSyncPrintf("KaleidoArea の最大サイズは %d バイトを確保します\n", largestSize); osSyncPrintf(VT_RST); - sKaleidoAreaPtr = GameState_Alloc(&globalCtx->state, largestSize, "../z_kaleido_manager.c", 150); + sKaleidoAreaPtr = GameState_Alloc(&play->state, largestSize, "../z_kaleido_manager.c", 150); LogUtils_CheckNullPointer("KaleidoArea_allocp", sKaleidoAreaPtr, "../z_kaleido_manager.c", 151); osSyncPrintf(VT_FGCOL(GREEN)); diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c index 13f7ab205..cb2fcf3d8 100644 --- a/src/code/z_kaleido_scope_call.c +++ b/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(void) { KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR]; @@ -30,7 +30,7 @@ void KaleidoScopeCall_LoadPlayer(void) { } } -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, "../z_kaleido_scope_call.c", 100); LOG_ADDRESS("kaleido_scope_draw_func", sKaleidoScopeDrawFunc, "../z_kaleido_scope_call.c", 101); - 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) { @@ -99,9 +99,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"); @@ -115,14 +115,14 @@ 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/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c index cb05b520e..bbc66d5bc 100644 --- a/src/code/z_kaleido_setup.c +++ b/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->transitionTrigger == TRANS_TRIGGER_OFF && globalCtx->transitionMode == TRANS_MODE_OFF && - gSaveContext.cutsceneIndex < 0xFFF0 && gSaveContext.nextCutsceneIndex < 0xFFF0 && !Play_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->transitionTrigger == TRANS_TRIGGER_OFF && play->transitionMode == TRANS_MODE_OFF && + 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 (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) { if (BREG(0)) { @@ -61,8 +61,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; @@ -114,8 +114,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/src/code/z_kankyo.c b/src/code/z_kankyo.c index 3a4d426b1..5715e84e5 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -239,15 +239,15 @@ u16 Environment_GetPixelDepth(s32 x, s32 y) { } void Environment_GraphCallback(GraphicsContext* gfxCtx, void* param) { - GlobalContext* globalCtx = (GlobalContext*)param; + PlayState* play = (PlayState*)param; sSunScreenDepth = Environment_GetPixelDepth(sSunDepthTestX, sSunDepthTestY); - 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; @@ -257,14 +257,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; @@ -340,11 +340,11 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 gSaveContext.chamberCutsceneNum = CREG(3) - 1; } - globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; - globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] = 0; - globalCtx->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; - globalCtx->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; - globalCtx->envCtx.precipitation[PRECIP_SOS_MAX] = 0; + play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; + play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0; + play->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; + play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; + play->envCtx.precipitation[PRECIP_SOS_MAX] = 0; if (gSaveContext.retainWeatherMode) { if (((void)0, gSaveContext.sceneSetupIndex) < 4) { @@ -354,8 +354,8 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 envCtx->changeSkyboxNextConfig = 1; envCtx->lightConfig = 3; envCtx->changeLightNextConfig = 3; - globalCtx->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; - globalCtx->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; + play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; + play->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; break; case WEATHER_MODE_CLOUDY_CONFIG2: @@ -365,8 +365,8 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 envCtx->changeSkyboxNextConfig = 1; envCtx->lightConfig = 2; envCtx->changeLightNextConfig = 2; - globalCtx->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; - globalCtx->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; + play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; + play->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; break; case WEATHER_MODE_HEAVY_RAIN: @@ -374,24 +374,23 @@ void Environment_Init(GlobalContext* globalCtx2, EnvironmentContext* envCtx, s32 envCtx->changeSkyboxNextConfig = 1; envCtx->lightConfig = 4; envCtx->changeLightNextConfig = 4; - globalCtx->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; - globalCtx->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; + play->envCtx.precipitation[PRECIP_SNOW_MAX] = 0; + play->envCtx.precipitation[PRECIP_SNOW_CUR] = 0; break; default: break; } - if (globalCtx->skyboxId == SKYBOX_NORMAL_SKY) { + if (play->skyboxId == SKYBOX_NORMAL_SKY) { if (gWeatherMode == WEATHER_MODE_SNOW) { - globalCtx->envCtx.precipitation[PRECIP_SNOW_CUR] = - globalCtx->envCtx.precipitation[PRECIP_SNOW_MAX] = 64; + play->envCtx.precipitation[PRECIP_SNOW_CUR] = play->envCtx.precipitation[PRECIP_SNOW_MAX] = 64; } else if (gWeatherMode == WEATHER_MODE_RAIN) { - globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] = 20; - globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] = 20; + play->envCtx.precipitation[PRECIP_RAIN_MAX] = 20; + play->envCtx.precipitation[PRECIP_RAIN_CUR] = 20; } else if (gWeatherMode == WEATHER_MODE_HEAVY_RAIN) { - globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] = 30; - globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] = 30; + play->envCtx.precipitation[PRECIP_RAIN_MAX] = 30; + play->envCtx.precipitation[PRECIP_RAIN_CUR] = 30; } } } @@ -424,15 +423,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); } @@ -783,38 +782,38 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon } } -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.lightMode == LIGHT_MODE_TIME) { - gLightConfigAfterUnderwater = globalCtx->envCtx.changeLightNextConfig; + if (play->envCtx.lightMode == LIGHT_MODE_TIME) { + gLightConfigAfterUnderwater = play->envCtx.changeLightNextConfig; - if (globalCtx->envCtx.lightConfig != waterLightsIndex) { - globalCtx->envCtx.lightConfig = waterLightsIndex; - globalCtx->envCtx.changeLightNextConfig = waterLightsIndex; + if (play->envCtx.lightConfig != waterLightsIndex) { + play->envCtx.lightConfig = waterLightsIndex; + play->envCtx.changeLightNextConfig = waterLightsIndex; } } else { - globalCtx->envCtx.lightBlendEnabled = false; // instantly switch to water lights - globalCtx->envCtx.lightSettingOverride = waterLightsIndex; + play->envCtx.lightBlendEnabled = false; // instantly switch to water lights + play->envCtx.lightSettingOverride = waterLightsIndex; } } -void Environment_DisableUnderwaterLights(GlobalContext* globalCtx) { - if (globalCtx->envCtx.lightMode == LIGHT_MODE_TIME) { - globalCtx->envCtx.lightConfig = gLightConfigAfterUnderwater; - globalCtx->envCtx.changeLightNextConfig = gLightConfigAfterUnderwater; +void Environment_DisableUnderwaterLights(PlayState* play) { + if (play->envCtx.lightMode == LIGHT_MODE_TIME) { + play->envCtx.lightConfig = gLightConfigAfterUnderwater; + play->envCtx.changeLightNextConfig = gLightConfigAfterUnderwater; } else { - globalCtx->envCtx.lightBlendEnabled = false; // instantly switch to previous lights - globalCtx->envCtx.lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE; - globalCtx->envCtx.lightBlend = 1.0f; + play->envCtx.lightBlendEnabled = false; // instantly switch to previous lights + play->envCtx.lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE; + play->envCtx.lightBlend = 1.0f; } } -void Environment_PrintDebugInfo(GlobalContext* globalCtx, Gfx** gfx) { +void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) { GfxPrint printer; s32 pad[2]; @@ -869,18 +868,17 @@ void Environment_PrintDebugInfo(GlobalContext* globalCtx, Gfx** gfx) { GfxPrint_Destroy(&printer); } -void Environment_PlayTimeBasedSequence(GlobalContext* globalCtx); -void Environment_UpdateRain(GlobalContext* globalCtx); +void Environment_PlayTimeBasedSequence(PlayState* play); +void Environment_UpdateRain(PlayState* play); -void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, LightContext* lightCtx, - PauseContext* pauseCtx, MessageContext* msgCtx, GameOverContext* gameOverCtx, - GraphicsContext* gfxCtx) { +void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, PauseContext* pauseCtx, + MessageContext* msgCtx, GameOverContext* gameOverCtx, GraphicsContext* gfxCtx) { f32 sp8C; f32 sp88 = 0.0f; 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)) { @@ -888,16 +886,16 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li } 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; } } - Environment_UpdateRain(globalCtx); - Environment_PlayTimeBasedSequence(globalCtx); + Environment_UpdateRain(play); + Environment_PlayTimeBasedSequence(play); if (((void)0, gSaveContext.nextDayTime) >= 0xFF00 && ((void)0, gSaveContext.nextDayTime) != NEXT_TIME_NONE) { gSaveContext.nextDayTime -= 0x10; @@ -921,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->changeSkyboxTimer == 0) && !FrameAdvance_IsEnabled(globalCtx) && - (globalCtx->transitionMode == TRANS_MODE_OFF || ((void)0, gSaveContext.gameMode) != 0)) { + if ((envCtx->changeSkyboxTimer == 0) && !FrameAdvance_IsEnabled(play) && + (play->transitionMode == TRANS_MODE_OFF || ((void)0, gSaveContext.gameMode) != 0)) { if (IS_DAY || gTimeSpeed >= 400) { gSaveContext.dayTime += gTimeSpeed; @@ -953,17 +951,17 @@ void Environment_Update(GlobalContext* globalCtx, EnvironmentContext* envCtx, Li Gfx* displayList; Gfx* prevDisplayList; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 1682); + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1682); 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; if (1) {} - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 1690); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690); } if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) && @@ -1361,38 +1359,37 @@ 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, "../z_kankyo.c", 2266); + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 2266); - 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) - CLOCK_TIME(12, 0)) * 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) - CLOCK_TIME(12, 0)) * 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) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f, 1.0f, 0.8f, 0.8f); } else { - globalCtx->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.y = +(Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.z = +(Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f; + play->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; + play->envCtx.sunPos.y = +(Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; + play->envCtx.sunPos.z = +(Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f; } if (gSaveContext.entranceIndex != ENTR_SPOT00_0 || ((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; @@ -1419,13 +1416,12 @@ 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, "../z_kankyo.c", 2364), G_MTX_LOAD); - func_80093AD0(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_kankyo.c", 2364), G_MTX_LOAD); + func_80093AD0(play->state.gfxCtx); gSPDisplayList(POLY_OPA_DISP++, gSunDL); - 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); @@ -1439,8 +1435,8 @@ void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { alpha = temp * 255.0f; if (alpha > 0.0f) { - gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_kankyo.c", 2406), G_MTX_LOAD); - func_8009398C(globalCtx->state.gfxCtx); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_kankyo.c", 2406), 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); @@ -1448,15 +1444,14 @@ void Environment_DrawSunAndMoon(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 2429); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 2429); } -void Environment_DrawSunLensFlare(GlobalContext* globalCtx, EnvironmentContext* envCtx, View* view, - GraphicsContext* gfxCtx, Vec3f pos, s32 unused) { - if ((globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] == 0) && (globalCtx->envCtx.skyboxConfig == 0)) { - Environment_DrawLensFlare(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, pos, 2000, - 370, Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f, 400, - true); +void Environment_DrawSunLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, + Vec3f pos, s32 unused) { + if ((play->envCtx.precipitation[PRECIP_RAIN_CUR] == 0) && (play->envCtx.skyboxConfig == 0)) { + Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, pos, 2000, 370, + Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f, 400, true); } } @@ -1468,9 +1463,8 @@ typedef enum { /* 2 */ LENS_FLARE_RING } LensFlareType; -void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* envCtx, View* view, - GraphicsContext* gfxCtx, Vec3f pos, s32 unused, s16 scale, f32 colorIntensity, - s16 glareStrength, u8 isSun) { +void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View* view, GraphicsContext* gfxCtx, + Vec3f pos, s32 unused, s16 scale, f32 colorIntensity, s16 glareStrength, u8 isSun) { s16 i; f32 tempX; f32 tempY; @@ -1565,7 +1559,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env // don't draw lens flare } else { if (isSun) { - Play_GetScreenPos(globalCtx, &pos, &screenPos); + Play_GetScreenPos(play, &pos, &screenPos); sSunDepthTestX = (s16)screenPos.x; sSunDepthTestY = (s16)screenPos.y - 5.0f; if (sSunScreenDepth != GPACK_ZDZ(G_MAXFBZ, 0) || screenPos.x < 0.0f || screenPos.y < 0.0f || @@ -1578,7 +1572,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env Matrix_Translate(pos.x, pos.y, pos.z, MTXMODE_NEW); if (isSun) { - 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); @@ -1597,7 +1591,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); @@ -1644,7 +1638,7 @@ void Environment_DrawLensFlare(GlobalContext* globalCtx, EnvironmentContext* env alpha = alpha * glareStrength; 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); @@ -1678,7 +1672,7 @@ f32 Environment_RandCentered(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; @@ -1695,9 +1689,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.precipitation[PRECIP_SNOW_CUR] == 0)) { + if (!(play->cameraPtrs[0]->unk_14C & 0x100) && (play->envCtx.precipitation[PRECIP_SNOW_CUR] == 0)) { OPEN_DISPS(gfxCtx, "../z_kankyo.c", 2799); vec.x = view->at.x - view->eye.x; @@ -1717,14 +1711,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.precipitation[PRECIP_RAIN_CUR]) { + if (play->envCtx.precipitation[PRECIP_RAIN_CUR]) { 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.precipitation[PRECIP_RAIN_CUR]; i++) { + for (i = 0; i < play->envCtx.precipitation[PRECIP_RAIN_CUR]; i++) { temp2 = Rand_ZeroOne(); temp1 = Rand_ZeroOne(); temp3 = Rand_ZeroOne(); @@ -1732,9 +1726,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; @@ -1756,7 +1750,7 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* if (player->actor.world.pos.y < view->eye.y) { u8 materialFlag = false; - for (i = 0; i < globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR]; i++) { + for (i = 0; i < play->envCtx.precipitation[PRECIP_RAIN_CUR]; i++) { if (!materialFlag) { func_80093D84(gfxCtx); gDPSetEnvColor(POLY_XLU_DISP++, 155, 155, 155, 0); @@ -1784,16 +1778,16 @@ void Environment_DrawRain(GlobalContext* globalCtx, View* view, GraphicsContext* } } -void Environment_ChangeLightSetting(GlobalContext* globalCtx, u32 lightSetting) { - if ((globalCtx->envCtx.lightSetting != lightSetting) && (globalCtx->envCtx.lightBlend >= 1.0f) && - (globalCtx->envCtx.lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { +void Environment_ChangeLightSetting(PlayState* play, u32 lightSetting) { + if ((play->envCtx.lightSetting != lightSetting) && (play->envCtx.lightBlend >= 1.0f) && + (play->envCtx.lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { if (lightSetting >= LIGHT_SETTING_MAX) { lightSetting = 0; } - globalCtx->envCtx.lightBlend = 0.0f; - globalCtx->envCtx.prevLightSetting = globalCtx->envCtx.lightSetting; - globalCtx->envCtx.lightSetting = lightSetting; + play->envCtx.lightBlend = 0.0f; + play->envCtx.prevLightSetting = play->envCtx.lightSetting; + play->envCtx.lightSetting = lightSetting; } } @@ -1809,18 +1803,17 @@ void Environment_ChangeLightSetting(GlobalContext* globalCtx, u32 lightSetting) * * 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, "../z_kankyo.c", 3032); + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3032); - 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; } @@ -1828,38 +1821,37 @@ 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, "../z_kankyo.c", 3043); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3043); } - if (globalCtx->envCtx.customSkyboxFilter) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 3048); + if (play->envCtx.customSkyboxFilter) { + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3048); - 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, "../z_kankyo.c", 3056); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3056); } } -void Environment_DrawLightningFlash(GlobalContext* globalCtx, u8 red, u8 green, u8 blue, u8 alpha) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 3069); +void Environment_DrawLightningFlash(PlayState* play, u8 red, u8 green, u8 blue, u8 alpha) { + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3069); - 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, "../z_kankyo.c", 3079); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3079); } -void Environment_UpdateLightningStrike(GlobalContext* globalCtx) { - if (globalCtx->envCtx.lightningState != LIGHTNING_OFF) { +void Environment_UpdateLightningStrike(PlayState* play) { + if (play->envCtx.lightningState != LIGHTNING_OFF) { switch (gLightningStrike.state) { case LIGHTNING_STRIKE_WAIT: // every frame theres a 10% chance of the timer advancing 50 units @@ -1876,7 +1868,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++; @@ -1887,9 +1879,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; @@ -1900,26 +1892,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.lightningState == LIGHTNING_LAST) { - globalCtx->envCtx.lightningState = LIGHTNING_OFF; + if (play->envCtx.lightningState == LIGHTNING_LAST) { + play->envCtx.lightningState = LIGHTNING_OFF; } } break; @@ -1927,7 +1919,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); } } @@ -1936,7 +1928,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; @@ -1955,7 +1947,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, @@ -1970,20 +1962,20 @@ 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, "../z_kankyo.c", 3253); + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3253); for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { switch (sLightningBolts[i].state) { case LIGHTNING_BOLT_START: - dx = globalCtx->view.at.x - globalCtx->view.eye.x; - dz = globalCtx->view.at.z - globalCtx->view.eye.z; + dx = play->view.at.x - play->view.eye.x; + dz = play->view.at.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; @@ -2020,20 +2012,20 @@ 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, "../z_kankyo.c", 3333), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_kankyo.c", 3333), 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++, &D_01000000, G_MTX_NOPUSH | G_MTX_MUL | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gEffLightningDL); } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 3353); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 3353); } -void Environment_PlaySceneSequence(GlobalContext* globalCtx) { - globalCtx->envCtx.timeSeqState = TIMESEQ_DISABLED; +void Environment_PlaySceneSequence(PlayState* play) { + play->envCtx.timeSeqState = TIMESEQ_DISABLED; // both lost woods exits on the bridge from kokiri to hyrule field if (((void)0, gSaveContext.entranceIndex) == ENTR_SPOT10_8 || @@ -2044,111 +2036,108 @@ 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) >= CLOCK_TIME(7, 0) && ((void)0, gSaveContext.dayTime) <= CLOCK_TIME(17, 10)) { - 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.timeSeqState = TIMESEQ_FADE_DAY_BGM; + play->envCtx.timeSeqState = TIMESEQ_FADE_DAY_BGM; } 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) > CLOCK_TIME(17, 10) && ((void)0, gSaveContext.dayTime) <= CLOCK_TIME(19, 0)) { - globalCtx->envCtx.timeSeqState = TIMESEQ_EARLY_NIGHT_CRITTERS; + play->envCtx.timeSeqState = TIMESEQ_EARLY_NIGHT_CRITTERS; } else if (((void)0, gSaveContext.dayTime) > CLOCK_TIME(19, 0) + 1 || ((void)0, gSaveContext.dayTime) < CLOCK_TIME(6, 30)) { - globalCtx->envCtx.timeSeqState = TIMESEQ_NIGHT_CRITTERS; + play->envCtx.timeSeqState = TIMESEQ_NIGHT_CRITTERS; } else { - globalCtx->envCtx.timeSeqState = TIMESEQ_MORNING_CRITTERS; + play->envCtx.timeSeqState = TIMESEQ_MORNING_CRITTERS; } } 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.timeSeqState); + osSyncPrintf("\n BGM=[%d]", play->sequenceCtx.seqId); + osSyncPrintf("\n エンブ=[%d]", play->sequenceCtx.natureAmbienceId); + osSyncPrintf("\n status=[%d]", play->envCtx.timeSeqState); - Audio_SetEnvReverb(globalCtx->roomCtx.curRoom.echo); + Audio_SetEnvReverb(play->roomCtx.curRoom.echo); } -void Environment_PlayTimeBasedSequence(GlobalContext* globalCtx) { - switch (globalCtx->envCtx.timeSeqState) { +void Environment_PlayTimeBasedSequence(PlayState* play) { + switch (play->envCtx.timeSeqState) { case TIMESEQ_DAY_BGM: Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_4 << 4 | NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_1, 0); - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && - globalCtx->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { + if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { osSyncPrintf("\n\n\nNa_StartMorinigBgm\n\n"); - func_800F5510(globalCtx->sequenceCtx.seqId); + func_800F5510(play->sequenceCtx.seqId); } - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; break; case TIMESEQ_FADE_DAY_BGM: if (gSaveContext.dayTime > CLOCK_TIME(17, 10)) { - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && - globalCtx->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { + if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && + play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { Audio_QueueSeqCmd(0x1 << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xF000FF); } - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; } break; case TIMESEQ_NIGHT_BEGIN_SFX: if (gSaveContext.dayTime > CLOCK_TIME(18, 0)) { func_800788CC(NA_SE_EV_DOG_CRY_EVENING); - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; } break; case TIMESEQ_EARLY_NIGHT_CRITTERS: - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && - globalCtx->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { - Audio_PlayNatureAmbienceSequence(globalCtx->sequenceCtx.natureAmbienceId); + if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { + Audio_PlayNatureAmbienceSequence(play->sequenceCtx.natureAmbienceId); Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_1, 1); } - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; break; case TIMESEQ_NIGHT_DELAY: if (gSaveContext.dayTime > CLOCK_TIME(19, 0)) { - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; } break; case TIMESEQ_NIGHT_CRITTERS: Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_0, CHANNEL_IO_PORT_1, 0); - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && - globalCtx->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { + if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_1 << 4 | NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_1, 1); } - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; break; case TIMESEQ_DAY_BEGIN_SFX: @@ -2158,13 +2147,13 @@ void Environment_PlayTimeBasedSequence(GlobalContext* globalCtx) { gSaveContext.dogIsLost = true; func_80078884(NA_SE_EV_CHICKEN_CRY_M); - if ((Inventory_ReplaceItem(globalCtx, ITEM_WEIRD_EGG, ITEM_CHICKEN) || - Inventory_ReplaceItem(globalCtx, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO)) && - globalCtx->csCtx.state == 0 && !Player_InCsMode(globalCtx)) { - Message_StartTextbox(globalCtx, 0x3066, NULL); + if ((Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN) || + Inventory_ReplaceItem(play, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO)) && + play->csCtx.state == 0 && !Player_InCsMode(play)) { + Message_StartTextbox(play, 0x3066, NULL); } - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; } break; @@ -2172,24 +2161,23 @@ void Environment_PlayTimeBasedSequence(GlobalContext* globalCtx) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_1 << 4 | NATURE_CHANNEL_CRITTER_3, CHANNEL_IO_PORT_1, 0); - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && - globalCtx->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { + if (play->envCtx.precipitation[PRECIP_RAIN_MAX] == 0 && play->envCtx.precipitation[PRECIP_SOS_MAX] == 0) { Audio_SetNatureAmbienceChannelIO(NATURE_CHANNEL_CRITTER_4 << 4 | NATURE_CHANNEL_CRITTER_5, CHANNEL_IO_PORT_1, 1); } - globalCtx->envCtx.timeSeqState++; + play->envCtx.timeSeqState++; break; case TIMESEQ_DAY_DELAY: if (gSaveContext.dayTime > CLOCK_TIME(7, 0)) { - globalCtx->envCtx.timeSeqState = 0; + play->envCtx.timeSeqState = 0; } break; } } -void Environment_DrawCustomLensFlare(GlobalContext* globalCtx) { +void Environment_DrawCustomLensFlare(PlayState* play) { Vec3f pos; if (gCustomLensFlareOn) { @@ -2197,31 +2185,30 @@ void Environment_DrawCustomLensFlare(GlobalContext* globalCtx) { pos.y = gCustomLensFlarePos.y; pos.z = gCustomLensFlarePos.z; - Environment_DrawLensFlare(globalCtx, &globalCtx->envCtx, &globalCtx->view, globalCtx->state.gfxCtx, pos, - gLensFlareUnused, gLensFlareScale, gLensFlareColorIntensity, gLensFlareGlareStrength, - false); + Environment_DrawLensFlare(play, &play->envCtx, &play->view, play->state.gfxCtx, pos, gLensFlareUnused, + gLensFlareScale, gLensFlareColorIntensity, gLensFlareGlareStrength, false); } } -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, @@ -2235,33 +2222,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) { @@ -2271,8 +2258,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, @@ -2282,34 +2269,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 Environment_UpdateRain(GlobalContext* globalCtx) { - u8 max = MAX(globalCtx->envCtx.precipitation[PRECIP_RAIN_MAX], globalCtx->envCtx.precipitation[PRECIP_SOS_MAX]); +void Environment_UpdateRain(PlayState* play) { + u8 max = MAX(play->envCtx.precipitation[PRECIP_RAIN_MAX], play->envCtx.precipitation[PRECIP_SOS_MAX]); - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] != max && ((globalCtx->state.frames % 8) == 0)) { - if (globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] < max) { - globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] += 2; + if (play->envCtx.precipitation[PRECIP_RAIN_CUR] != max && ((play->state.frames % 8) == 0)) { + if (play->envCtx.precipitation[PRECIP_RAIN_CUR] < max) { + play->envCtx.precipitation[PRECIP_RAIN_CUR] += 2; } else { - globalCtx->envCtx.precipitation[PRECIP_RAIN_CUR] -= 2; + play->envCtx.precipitation[PRECIP_RAIN_CUR] -= 2; } } } @@ -2357,11 +2344,11 @@ Color_RGB8 sSandstormEnvColors[] = { { 50, 40, 0 }, }; -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; @@ -2372,11 +2359,11 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { switch (sandstormState) { case SANDSTORM_ACTIVE: - 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; } @@ -2387,31 +2374,31 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { case SANDSTORM_FILL: primA1 = 255; - envA1 = (globalCtx->envCtx.sandstormPrimA >= 255) ? 255 : 128; + envA1 = (play->envCtx.sandstormPrimA >= 255) ? 255 : 128; break; case SANDSTORM_UNFILL: envA1 = 128; - if (globalCtx->envCtx.sandstormEnvA > 128) { + if (play->envCtx.sandstormEnvA > 128) { primA1 = 255; } 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 = SANDSTORM_ACTIVE; + play->envCtx.sandstormState = SANDSTORM_ACTIVE; } break; case SANDSTORM_DISSIPATE: 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 = SANDSTORM_OFF; + play->envCtx.sandstormState = SANDSTORM_OFF; } break; } @@ -2432,8 +2419,8 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { 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); @@ -2441,8 +2428,8 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { sp98 = 6.0f; } - if ((globalCtx->envCtx.lightMode != LIGHT_MODE_TIME) || - (globalCtx->envCtx.lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE)) { + if ((play->envCtx.lightMode != LIGHT_MODE_TIME) || + (play->envCtx.lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE)) { primColor.r = sSandstormPrimColors[1].r; primColor.g = sSandstormPrimColors[1].g; primColor.b = sSandstormPrimColors[1].b; @@ -2479,30 +2466,30 @@ void Environment_DrawSandstorm(GlobalContext* globalCtx, u8 sandstormState) { sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f)); sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f)); - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_kankyo.c", 4044); + OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044); 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, "../z_kankyo.c", 4068); + CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068); sSandstormScroll += (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); @@ -2512,18 +2499,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); } } @@ -2534,8 +2521,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); } } } @@ -2566,37 +2553,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 = WEATHER_MODE_CLEAR; gSaveContext.cutsceneIndex = 0; gSaveContext.respawnFlag = -3; - globalCtx->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->nextEntranceIndex = gSaveContext.respawn[RESPAWN_MODE_RETURN].entranceIndex; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; - switch (globalCtx->nextEntranceIndex) { + switch (play->nextEntranceIndex) { case ENTR_SPOT17_0: Flags_SetEventChkInf(EVENTCHKINF_B9); break; diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c index df2d552a9..f4ba1ffb4 100644 --- a/src/code/z_lifemeter.c +++ b/src/code/z_lifemeter.c @@ -111,8 +111,8 @@ s16 sBeatingHeartsDDEnv[3]; s16 sHeartsDDPrim[2][3]; s16 sHeartsDDEnv[2][3]; -void Health_InitMeter(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Health_InitMeter(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; interfaceCtx->unk_228 = 0x140; interfaceCtx->unk_226 = gSaveContext.health; @@ -144,8 +144,8 @@ void Health_InitMeter(GlobalContext* globalCtx) { sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = HEARTS_DD_ENV_B; } -void Health_UpdateMeter(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Health_UpdateMeter(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; f32 factor = interfaceCtx->heartColorOscillator * 0.1f; f32 ddFactor; s32 type = 0; @@ -241,14 +241,14 @@ void Health_UpdateMeter(GlobalContext* globalCtx) { } // Unused -s32 func_80078E18(GlobalContext* globalCtx) { - gSaveContext.health = globalCtx->interfaceCtx.unk_226; +s32 func_80078E18(PlayState* play) { + gSaveContext.health = play->interfaceCtx.unk_226; return 1; } // Unused -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; @@ -262,8 +262,8 @@ s32 func_80078E34(GlobalContext* globalCtx) { } // Unused -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--; @@ -272,7 +272,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; } } @@ -295,7 +295,7 @@ static void* sHeartDDTextures[] = { gDefenseHeartThreeQuarterTex, }; -void Health_DrawMeter(GlobalContext* globalCtx) { +void Health_DrawMeter(PlayState* play) { s32 pad[5]; void* heartBgImg; u32 curColorSet; @@ -306,8 +306,8 @@ void Health_DrawMeter(GlobalContext* globalCtx) { f32 heartCenterX; f32 heartCenterY; f32 heartTexCoordPerPixel; - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; - GraphicsContext* gfxCtx = globalCtx->state.gfxCtx; + InterfaceContext* interfaceCtx = &play->interfaceCtx; + GraphicsContext* gfxCtx = play->state.gfxCtx; Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx; s32 curHeartFraction = gSaveContext.health % 0x10; s16 totalHeartCount = gSaveContext.healthCapacity / 0x10; @@ -498,16 +498,16 @@ void Health_DrawMeter(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx, "../z_lifemeter.c", 606); } -void Health_UpdateBeatingHeart(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Health_UpdateBeatingHeart(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; if (interfaceCtx->beatingHeartOscillatorDirection != 0) { interfaceCtx->beatingHeartOscillator--; if (interfaceCtx->beatingHeartOscillator <= 0) { interfaceCtx->beatingHeartOscillator = 0; interfaceCtx->beatingHeartOscillatorDirection = 0; - if (!Player_InCsMode(globalCtx) && (globalCtx->pauseCtx.state == 0) && - (globalCtx->pauseCtx.debugState == 0) && Health_IsCritical() && !Play_InCsMode(globalCtx)) { + if (!Player_InCsMode(play) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && + Health_IsCritical() && !Play_InCsMode(play)) { func_80078884(NA_SE_SY_HITPOINT_ALARM); } } diff --git a/src/code/z_lights.c b/src/code/z_lights.c index e4f690b53..18967a89d 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -195,8 +195,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); bzero(&sLightsBuffer, sizeof(sLightsBuffer)); @@ -223,13 +223,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; } } @@ -240,7 +240,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(); @@ -260,7 +260,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; @@ -316,7 +316,7 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient return lights; } -void Lights_GlowCheck(GlobalContext* globalCtx) { +void Lights_GlowCheck(PlayState* play) { LightNode* node; LightPoint* params; Vec3f pos; @@ -327,7 +327,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; @@ -336,7 +336,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) { pos.x = params->x; pos.y = params->y; pos.z = params->z; - Actor_ProjectPos(globalCtx, &pos, &multDest, &cappedInvWDest); + Actor_ProjectPos(play, &pos, &multDest, &cappedInvWDest); params->drawGlow = false; wX = multDest.x * cappedInvWDest; wY = multDest.y * cappedInvWDest; @@ -356,13 +356,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, "../z_lights.c", 887); + OPEN_DISPS(play->state.gfxCtx, "../z_lights.c", 887); POLY_XLU_DISP = func_800947AC(POLY_XLU_DISP++); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); @@ -384,7 +384,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, "../z_lights.c", 918), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_lights.c", 918), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, gGlowCircleDL); } @@ -392,5 +392,5 @@ void Lights_DrawGlow(GlobalContext* globalCtx) { node = node->next; } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_lights.c", 927); + CLOSE_DISPS(play->state.gfxCtx, "../z_lights.c", 927); } diff --git a/src/code/z_map_exp.c b/src/code/z_map_exp.c index 144f830ec..670623c1a 100644 --- a/src/code/z_map_exp.c +++ b/src/code/z_map_exp.c @@ -10,17 +10,17 @@ s16 sPlayerInitialPosZ = 0; s16 sPlayerInitialDirection = 0; s16 sEntranceIconMapIndex = 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) { @@ -37,9 +37,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; @@ -53,7 +53,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: @@ -75,19 +75,19 @@ 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; } } -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: @@ -109,19 +109,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) && !GET_EVENTCHKINF_CARPENTERS_FREE_ALL()) { extendedMapIndex = 0x16; } - } else if (globalCtx->sceneNum == SCENE_SPOT12) { + } else if (play->sceneNum == SCENE_SPOT12) { if (GET_EVENTCHKINF_CARPENTERS_FREE_ALL()) { extendedMapIndex = 0x17; } @@ -158,27 +158,27 @@ 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, (u32)_map_i_staticSegmentRomStart + ((gMapData->dgnMinimapTexIndexOffset[mapIndex] + room) * 0xFF0), 0xFF0, "../z_map_exp.c", 346); 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: @@ -201,11 +201,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 { @@ -217,27 +217,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(&globalCtx->state, 0x1000, "../z_map_exp.c", 457); + interfaceCtx->mapSegment = GameState_Alloc(&play->state, 0x1000, "../z_map_exp.c", 457); // "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, "parameter->mapSegment != NULL", "../z_map_exp.c", 459); - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_SPOT00: case SCENE_SPOT01: case SCENE_SPOT02: @@ -258,13 +258,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; @@ -293,31 +293,30 @@ void Map_Init(GlobalContext* globalCtx) { case SCENE_MIZUSIN_BS: case SCENE_JYASINBOSS: case SCENE_HAKADAN_BS: - mapIndex = - (globalCtx->sceneNum >= SCENE_YDAN_BOSS) ? globalCtx->sceneNum - SCENE_YDAN_BOSS : globalCtx->sceneNum; + mapIndex = (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->dgnTexIndexBase[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; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_map_exp.c", 565); + OPEN_DISPS(play->state.gfxCtx, "../z_map_exp.c", 565); - if (globalCtx->interfaceCtx.minimapAlpha >= 0xAA) { - func_80094A14(globalCtx->state.gfxCtx); + if (play->interfaceCtx.minimapAlpha >= 0xAA) { + func_80094A14(play->state.gfxCtx); gSPMatrix(OVERLAY_DISP++, &gMtxClear, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, @@ -334,7 +333,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, "../z_map_exp.c", 585), + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_map_exp.c", 585), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 255, 0, 255); @@ -348,25 +347,25 @@ 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, "../z_map_exp.c", 603), + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_map_exp.c", 603), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gDPSetPrimColor(OVERLAY_DISP++, 0, 0xFF, 200, 0, 0, 255); gSPDisplayList(OVERLAY_DISP++, gCompassArrowDL); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_map_exp.c", 607); + CLOSE_DISPS(play->state.gfxCtx, "../z_map_exp.c", 607); } -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; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_map_exp.c", 626); + OPEN_DISPS(play->state.gfxCtx, "../z_map_exp.c", 626); - if (globalCtx->pauseCtx.state < 4) { - switch (globalCtx->sceneNum) { + if (play->pauseCtx.state < 4) { + switch (play->sceneNum) { case SCENE_YDAN: case SCENE_DDAN: case SCENE_BDAN: @@ -378,7 +377,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); @@ -395,14 +394,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) && !Play_InCsMode(globalCtx)) { - osSyncPrintf("Game_play_demo_mode_check=%d\n", Play_InCsMode(globalCtx)); + if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_L) && !Play_InCsMode(play)) { + 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, @@ -438,7 +437,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); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, R_MINIMAP_COLOR(0), R_MINIMAP_COLOR(1), R_MINIMAP_COLOR(2), @@ -454,8 +453,8 @@ void Minimap_Draw(GlobalContext* globalCtx) { (R_OW_MINIMAP_Y + gMapData->owMinimapHeight[mapIndex]) << 2, G_TX_RENDERTILE, 0, 0, 1 << 10, 1 << 10); - 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)) { if ((gMapData->owEntranceFlag[sEntranceIconMapIndex] == 0xFFFF) || ((gMapData->owEntranceFlag[sEntranceIconMapIndex] != 0xFFFF) && @@ -475,7 +474,7 @@ void Minimap_Draw(GlobalContext* globalCtx) { } } - if ((globalCtx->sceneNum == SCENE_SPOT08) && + if ((play->sceneNum == SCENE_SPOT08) && (gSaveContext.infTable[INFTABLE_1AX_INDEX] & gBitFlags[INFTABLE_1A9_SHIFT])) { 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, @@ -485,10 +484,10 @@ void Minimap_Draw(GlobalContext* globalCtx) { 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) && !Play_InCsMode(globalCtx)) { + if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_L) && !Play_InCsMode(play)) { // clang-format off if (!R_MINIMAP_DISABLED) { Audio_PlaySoundGeneral(NA_SE_SY_CAMERA_ZOOM_UP, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, @@ -506,23 +505,23 @@ void Minimap_Draw(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_map_exp.c", 782); + CLOSE_DISPS(play->state.gfxCtx, "../z_map_exp.c", 782); } 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; - 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: @@ -568,9 +567,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); } } @@ -584,9 +583,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]; - R_MAP_TEX_INDEX = R_MAP_TEX_INDEX_BASE + - gMapData->floorTexIndexOffset[globalCtx->sceneNum - SCENE_YDAN_BOSS][VREG(30)]; + VREG(30) = gMapData->bossFloor[play->sceneNum - SCENE_YDAN_BOSS]; + R_MAP_TEX_INDEX = + R_MAP_TEX_INDEX_BASE + gMapData->floorTexIndexOffset[play->sceneNum - SCENE_YDAN_BOSS][VREG(30)]; break; } } diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.c index 8718b8de4..1cc055a03 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.c @@ -53,11 +53,11 @@ static MapMarkDataOverlay sMapMarkDataOvl = { static MapMarkData** sLoadedMarkDataTable; -void MapMark_Init(GlobalContext* globalCtx) { +void MapMark_Init(PlayState* play) { MapMarkDataOverlay* overlay = &sMapMarkDataOvl; u32 overlaySize = (u32)overlay->vramEnd - (u32)overlay->vramStart; - overlay->loadedRamAddr = GameState_Alloc(&globalCtx->state, overlaySize, "../z_map_mark.c", 235); + overlay->loadedRamAddr = GameState_Alloc(&play->state, overlaySize, "../z_map_mark.c", 235); LogUtils_CheckNullPointer("dlftbl->allocp", overlay->loadedRamAddr, "../z_map_mark.c", 236); Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr); @@ -69,12 +69,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; @@ -84,18 +84,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, "../z_map_mark.c", 303); + OPEN_DISPS(play->state.gfxCtx, "../z_map_mark.c", 303); while (true) { if (mapMarkIconData->markType == MAP_MARK_NONE) { @@ -109,7 +109,7 @@ void MapMark_DrawForDungeon(GlobalContext* globalCtx) { markPoint = &mapMarkIconData->points[0]; 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)) { markInfo = &sMapMarkInfoTable[mapMarkIconData->markType]; gDPPipeSync(OVERLAY_DISP++); @@ -128,11 +128,11 @@ void MapMark_DrawForDungeon(GlobalContext* globalCtx) { mapMarkIconData++; } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_map_mark.c", 339); + CLOSE_DISPS(play->state.gfxCtx, "../z_map_mark.c", 339); } -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: @@ -148,7 +148,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/src/code/z_message_PAL.c b/src/code/z_message_PAL.c index 18fd1d732..7d54ff2cb 100644 --- a/src/code/z_message_PAL.c +++ b/src/code/z_message_PAL.c @@ -132,12 +132,12 @@ void Message_ResetOcarinaNoteState(void) { sOcarinaButtonCEnvB = 10; } -void Message_UpdateOcarinaMemoryGame(GlobalContext* globalCtx) { - MessageContext* msgCtx = &globalCtx->msgCtx; +void Message_UpdateOcarinaMemoryGame(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) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaButtonIndexBufPos = 0; @@ -153,8 +153,8 @@ void Message_UpdateOcarinaMemoryGame(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]; if (CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B) || CHECK_BTN_ALL(input->press.button, BTN_CUP)) { @@ -165,8 +165,8 @@ u8 Message_ShouldAdvance(GlobalContext* globalCtx) { 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]; return CHECK_BTN_ALL(input->press.button, BTN_A) || CHECK_BTN_ALL(input->press.button, BTN_B) || CHECK_BTN_ALL(input->press.button, BTN_CUP); @@ -176,8 +176,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; @@ -188,10 +188,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]; if (input->rel.stick_y >= 30 && !sAnalogStickHeld) { sAnalogStickHeld = true; @@ -219,8 +219,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; @@ -288,7 +288,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; @@ -300,7 +300,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 == textId) { foundSeg = messageTableEntry->segment; @@ -323,7 +323,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 == textId) { foundSeg = *languageSegmentTable; @@ -344,7 +344,7 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) { } // "Message not found!!!" osSyncPrintf(" メッセージが,見つからなかった!!! = %x\n", textId); - font = &globalCtx->msgCtx.font; + font = &play->msgCtx.font; messageTableEntry = sNesMessageEntryTablePtr; if (gSaveContext.language == LANGUAGE_ENG) { @@ -364,7 +364,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; @@ -373,7 +373,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; @@ -477,7 +477,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 }, @@ -494,7 +494,7 @@ void Message_DrawTextboxIcon(GlobalContext* globalCtx, Gfx** p, s16 x, s16 y) { static s16 sIconEnvR = 0; static s16 sIconEnvG = 0; static s16 sIconEnvB = 0; - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; Font* font = &msgCtx->font; Gfx* gfx = *p; s16 primR; @@ -737,10 +737,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, &gSfxDefaultPos, 4, @@ -777,11 +777,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; @@ -847,18 +847,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; @@ -993,7 +993,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 @@ -1086,8 +1086,8 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { Audio_PlaySoundGeneral(NA_SE_SY_MESSAGE_END, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); 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); } } } @@ -1095,7 +1095,7 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { return; case MESSAGE_OCARINA: if (i + 1 == msgCtx->textDrawPos) { - Message_HandleOcarina(globalCtx); + Message_HandleOcarina(play); *gfxP = gfx; return; } @@ -1106,8 +1106,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; @@ -1137,7 +1137,7 @@ void Message_DrawText(GlobalContext* globalCtx, Gfx** gfxP) { Audio_PlaySoundGeneral(0, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } - 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)); @@ -1153,11 +1153,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; @@ -1186,7 +1186,7 @@ void Message_LoadItemIcon(GlobalContext* globalCtx, u16 itemId, s16 y) { msgCtx->choiceNum = 1; } -void Message_Decode(GlobalContext* globalCtx) { +void Message_Decode(PlayState* play) { u8 curChar; u8 curChar2; u16 value; @@ -1198,11 +1198,11 @@ 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; - 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) { @@ -1528,7 +1528,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 (curChar == MESSAGE_BACKGROUND) { msgCtx->textboxBackgroundIdx = font->msgBuf[msgCtx->msgBufPos + 1] * 2; msgCtx->textboxBackgroundForeColorIdx = (font->msgBuf[msgCtx->msgBufPos + 2] & 0xF0) >> 4; @@ -1581,9 +1581,9 @@ void Message_Decode(GlobalContext* globalCtx) { } } -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; @@ -1634,23 +1634,23 @@ void Message_OpenText(GlobalContext* globalCtx, u16 textId) { } if (sTextIsCredits) { - Message_FindCreditsMessage(globalCtx, textId); + Message_FindCreditsMessage(play, textId); msgCtx->msgLength = font->msgLength; DmaMgr_SendRequest1(font->msgBuf, (u32)(_staff_message_data_staticSegmentRomStart + font->msgOffset), font->msgLength, "../z_message_PAL.c", 1954); } else { if (gSaveContext.language == LANGUAGE_ENG) { - Message_FindMessage(globalCtx, textId); + Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; DmaMgr_SendRequest1(font->msgBuf, (u32)(_nes_message_data_staticSegmentRomStart + font->msgOffset), font->msgLength, "../z_message_PAL.c", 1966); } else if (gSaveContext.language == LANGUAGE_GER) { - Message_FindMessage(globalCtx, textId); + Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; DmaMgr_SendRequest1(font->msgBuf, (u32)(_ger_message_data_staticSegmentRomStart + font->msgOffset), font->msgLength, "../z_message_PAL.c", 1978); } else { - Message_FindMessage(globalCtx, textId); + Message_FindMessage(play, textId); msgCtx->msgLength = font->msgLength; DmaMgr_SendRequest1(font->msgBuf, (u32)(_fra_message_data_staticSegmentRomStart + font->msgOffset), font->msgLength, "../z_message_PAL.c", 1990); @@ -1697,8 +1697,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" @@ -1706,16 +1706,16 @@ void Message_StartTextbox(GlobalContext* globalCtx, u16 textId, Actor* actor) { osSyncPrintf(VT_RST); msgCtx->ocarinaAction = 0xFFFF; - 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" @@ -1723,7 +1723,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; @@ -1731,13 +1731,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), @@ -1753,7 +1753,7 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { (1 << OCARINA_SONG_STORMS), (1 << OCARINA_SONG_SCARECROW_SPAWN), }; - MessageContext* msgCtx = &globalCtx->msgCtx; + MessageContext* msgCtx = &play->msgCtx; s32 textId; s16 j; s16 i; @@ -1785,11 +1785,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); @@ -1799,10 +1799,10 @@ void Message_StartOcarina(GlobalContext* globalCtx, u16 ocarinaActionId) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } if (ocarinaActionId == OCARINA_ACTION_SCARECROW_SPAWN_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 { @@ -1810,19 +1810,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; @@ -1838,7 +1838,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; @@ -1853,7 +1853,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 -> " @@ -1871,18 +1871,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) { @@ -1920,8 +1920,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; gDPPipeSync(gfx++); @@ -1969,7 +1969,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, @@ -2001,10 +2001,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 buttonIndexPos; - Player* player = GET_PLAYER(globalCtx); + Player* player = GET_PLAYER(play); s32 pad; Gfx* gfx = *p; s16 r; @@ -2015,7 +2015,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) { @@ -2024,7 +2024,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); @@ -2042,19 +2042,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: @@ -2062,7 +2062,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaButtonIndexBufPos = 0; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; Message_ResetOcarinaNoteState(); sOcarinaNoteFlashTimer = 3; sOcarinaNoteFlashColorIndex = 1; @@ -2096,7 +2096,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: @@ -2131,7 +2131,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; @@ -2151,7 +2151,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; @@ -2163,7 +2163,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; @@ -2188,14 +2188,14 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); msgCtx->stateTimer = 10; msgCtx->msgMode = MSGMODE_OCARINA_FAIL; - } else if (CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B)) { + } else if (CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B)) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); - 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: @@ -2317,30 +2317,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) { @@ -2348,8 +2348,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; @@ -2386,14 +2386,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 = AudioOcarina_GetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaButtonIndexBufPos = 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]); @@ -2401,7 +2401,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } break; case MSGMODE_SETUP_DISPLAY_SONG_PLAYED: - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); AudioOcarina_SetPlaybackSong(msgCtx->lastPlayedSong + 1, 1); @@ -2409,7 +2409,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; } @@ -2441,28 +2441,28 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { sOcarinaButtonIndexBufPos = 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; msgCtx->stateTimer = 20; - 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: AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); 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--; @@ -2471,17 +2471,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) { - 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 (GET_EVENTINF_HORSES_STATE() != EVENTINF_HORSES_STATE_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; } @@ -2489,31 +2489,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_SPAWN) { - 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; @@ -2540,7 +2540,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 = AudioOcarina_GetPlayingStaff(); @@ -2554,7 +2554,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { msgCtx->ocarinaStaff->state); msgCtx->lastPlayedSong = msgCtx->ocarinaStaff->state; msgCtx->msgMode = MSGMODE_SONG_PLAYBACK_SUCCESS; - Item_Give(globalCtx, ITEM_SONG_MINUET + gOcarinaSongItemMap[msgCtx->ocarinaStaff->state]); + Item_Give(play, ITEM_SONG_MINUET + gOcarinaSongItemMap[msgCtx->ocarinaStaff->state]); osSyncPrintf(VT_FGCOL(YELLOW)); // "z_message.c Song Acquired" osSyncPrintf("z_message.c 取得メロディ=%d\n", ITEM_SONG_MINUET + msgCtx->ocarinaStaff->state); @@ -2568,12 +2568,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: @@ -2586,7 +2586,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { sOcarinaButtonIndexBufLen = 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 = AudioOcarina_GetRecordingStaff(); @@ -2611,7 +2611,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { } } if (msgCtx->ocarinaStaff->state == OCARINA_RECORD_OFF || - CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B)) { + CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B)) { if (sOcarinaButtonIndexBufLen != 0) { // "Recording complete!!!!!!!!!" osSyncPrintf("録音終了!!!!!!!!! message->info->status=%d \n", @@ -2623,8 +2623,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { osSyncPrintf("aaaaaaaaaaaaaa\n"); AudioOcarina_SetRecordingState(OCARINA_RECORD_OFF); 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)); @@ -2637,7 +2637,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_SPAWN_PLAYBACK: @@ -2662,8 +2662,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { if (msgCtx->ocarinaStaff->state == 0) { osSyncPrintf("bbbbbbbbbbb\n"); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_0F; - Message_CloseTextbox(globalCtx); + play->msgCtx.ocarinaMode = OCARINA_MODE_0F; + Message_CloseTextbox(play); } } else { msgCtx->stateTimer--; @@ -2673,7 +2673,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { AudioOcarina_SetRecordingState(OCARINA_RECORD_SCARECROW_SPAWN); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->msgMode = MSGMODE_SCARECROW_SPAWN_RECORDING_ONGOING; - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SCARECROW_SPAWN_RECORDING_ONGOING: msgCtx->ocarinaStaff = AudioOcarina_GetRecordingStaff(); @@ -2701,22 +2701,22 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { osSyncPrintf(VT_RST); osSyncPrintf("\n====================================================================\n"); } else if (msgCtx->ocarinaStaff->state == OCARINA_RECORD_REJECTED || - CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B)) { + CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B)) { // "Played an existing song!!!" osSyncPrintf("すでに存在する曲吹いた!!! \n"); AudioOcarina_SetRecordingState(OCARINA_RECORD_OFF); Audio_PlaySoundGeneral(NA_SE_SY_OCARINA_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); msgCtx->msgMode = MSGMODE_SCARECROW_SPAWN_RECORDING_FAILED; } - Message_DrawText(globalCtx, &gfx); + Message_DrawText(play, &gfx); break; case MSGMODE_SCARECROW_SPAWN_RECORDING_FAILED: osSyncPrintf("cccccccccccc\n"); AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_OFF); - 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: AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); @@ -2780,7 +2780,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { Audio_PlaySoundGeneral(NA_SE_SY_OCARINA_ERROR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); msgCtx->stateTimer = 10; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_03; + play->msgCtx.ocarinaMode = OCARINA_MODE_03; } else if (msgCtx->ocarinaStaff->state == OCARINA_SONG_MEMORY_GAME) { // "Musical round succeeded!!!!!!!!!" osSyncPrintf("輪唱成功!!!!!!!!!\n"); @@ -2789,7 +2789,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 = AudioOcarina_GetPlayingStaff(); @@ -2808,10 +2808,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)) { @@ -2825,7 +2825,7 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) { AudioOcarina_SetInstrument(OCARINA_INSTRUMENT_DEFAULT); msgCtx->ocarinaStaff = AudioOcarina_GetPlayingStaff(); msgCtx->ocarinaStaff->pos = sOcarinaButtonIndexBufPos = 0; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_01; + play->msgCtx.ocarinaMode = OCARINA_MODE_01; Message_ResetOcarinaNoteState(); AudioOcarina_Start(sOcarinaSongBitFlags + 0xC000); msgCtx->msgMode = MSGMODE_FROGS_PLAYING; @@ -2841,16 +2841,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) { @@ -2863,7 +2863,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; } @@ -2979,7 +2979,7 @@ void Message_DrawDebugVariableChanged(s16* var, GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_message_PAL.c", 3513); } -void Message_DrawDebugText(GlobalContext* globalCtx, Gfx** p) { +void Message_DrawDebugText(PlayState* play, Gfx** p) { s32 pad; GfxPrint printer; s32 pad1; @@ -2992,24 +2992,24 @@ 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, "../z_message_PAL.c", 3554); + OPEN_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3554); watchVar = gSaveContext.scarecrowLongSongSet; - 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; @@ -3017,14 +3017,14 @@ void Message_Draw(GlobalContext* globalCtx) { if (1) {} 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, "../z_message_PAL.c", 3582); + CLOSE_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3582); } -void Message_Update(GlobalContext* globalCtx) { +void Message_Update(PlayState* play) { static s16 sTextboxXPositions[] = { 34, 34, 34, 34, 34, 34, }; @@ -3047,10 +3047,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; @@ -3060,7 +3060,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) { @@ -3071,7 +3071,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; @@ -3096,7 +3096,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; @@ -3104,9 +3104,8 @@ void Message_Update(GlobalContext* globalCtx) { if (var) { if (msgCtx->talkActor != NULL) { - Actor_GetScreenPos(globalCtx, &GET_PLAYER(globalCtx)->actor, &focusScreenPosX, - &playerFocusScreenPosY); - Actor_GetScreenPos(globalCtx, msgCtx->talkActor, &focusScreenPosX, &actorFocusScreenPosY); + Actor_GetScreenPos(play, &GET_PLAYER(play)->actor, &focusScreenPosX, &playerFocusScreenPosY); + Actor_GetScreenPos(play, msgCtx->talkActor, &focusScreenPosX, &actorFocusScreenPosY); if (playerFocusScreenPosY >= actorFocusScreenPosY) { averageY = ((playerFocusScreenPosY - actorFocusScreenPosY) / 2) + actorFocusScreenPosY; @@ -3123,14 +3122,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 = sTextboxMidYPositions[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 = sTextboxMidYPositions[var]; } else { @@ -3182,11 +3181,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); } @@ -3198,18 +3197,18 @@ 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: if (msgCtx->textBoxType != TEXTBOX_TYPE_NONE_BOTTOM && YREG(31) == 0 && - CHECK_BTN_ALL(globalCtx->state.input[0].press.button, BTN_B) && !msgCtx->textUnskippable) { + CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B) && !msgCtx->textUnskippable) { sTextboxSkipped = true; msgCtx->textDrawPos = msgCtx->decodedTextLen; } 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++; } @@ -3221,7 +3220,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++; @@ -3231,30 +3230,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; + if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_2_CHOICE && 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 --> ", GET_EVENTINF_HORSES_STATE(), 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, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - Message_ContinueTextbox(globalCtx, sNextTextId); + Message_ContinueTextbox(play, sNextTextId); } else { Audio_PlaySoundGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); - Message_CloseTextbox(globalCtx); + Message_CloseTextbox(play); } } } @@ -3273,15 +3271,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->activeCamId); + osSyncPrintf("day_time=%x active_camera=%d ", gSaveContext.cutsceneIndex, play->activeCamId); 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->activeCamId == CAM_ID_MAIN) { + if (play->activeCamId == CAM_ID_MAIN) { if (gSaveContext.unk_13EE == 0 || gSaveContext.unk_13EE == 1 || gSaveContext.unk_13EE == 2) { gSaveContext.unk_13EE = 0x32; } @@ -3298,7 +3296,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; } @@ -3317,16 +3315,15 @@ 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/src/code/z_onepointdemo.c b/src/code/z_onepointdemo.c index 0eb0b946c..832caf254 100644 --- a/src/code/z_onepointdemo.c +++ b/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 subCamId, s16 csId, Actor* actor, s16 timer) { - Camera* subCam = globalCtx->cameraPtrs[subCamId]; - Camera* childCam = globalCtx->cameraPtrs[subCam->childCamId]; - Camera* mainCam = globalCtx->cameraPtrs[CAM_ID_MAIN]; +s32 OnePointCutscene_SetInfo(PlayState* play, s16 subCamId, s16 csId, Actor* actor, s16 timer) { + Camera* subCam = play->cameraPtrs[subCamId]; + Camera* childCam = play->cameraPtrs[subCam->childCamId]; + Camera* mainCam = play->cameraPtrs[CAM_ID_MAIN]; Player* player = mainCam->player; VecSph spD0; s32 i; @@ -75,9 +75,9 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A if (timer < 20) { timer = 20; } - D_801208EC[0].atTargetInit = globalCtx->view.at; - D_801208EC[0].eyeTargetInit = globalCtx->view.eye; - D_801208EC[0].fovTargetInit = globalCtx->view.fovy; + D_801208EC[0].atTargetInit = play->view.at; + 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 subCamId, s16 csId, A csInfo->keyFrames = D_801208EC; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 1030: - D_80120964[0].atTargetInit = globalCtx->view.at; - D_80120964[0].eyeTargetInit = globalCtx->view.eye; - D_80120964[0].fovTargetInit = globalCtx->view.fovy; + D_80120964[0].atTargetInit = play->view.at; + 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 = CAM_BINANG_TO_DEG(spD0.yaw); D_80120964[1].timerInit = timer - 1; @@ -101,12 +101,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80120964; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 5000: - D_801209B4[0].atTargetInit = D_801209B4[1].atTargetInit = globalCtx->view.at; - 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.at; + 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 subCamId, s16 csId, A csInfo->keyFrames = D_801209B4; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 5010: - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_ATTENTION); - Play_CameraSetAtEye(globalCtx, subCamId, &mainCam->at, &mainCam->eye); + func_800C0808(play, subCamId, player, CAM_SET_CS_ATTENTION); + Play_CameraSetAtEye(play, subCamId, &mainCam->at, &mainCam->eye); subCam->roll = 0; break; case 9500: csInfo->keyFrames = D_80120A54; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 2270: csInfo->keyFrames = D_80120B94; @@ -153,8 +153,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A } D_80120B94[subCamId - 1].eyeTargetInit.y = - ((mainCam->globalCtx->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + ((mainCam->play->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 5); Quake_SetSpeed(i, 400); @@ -174,8 +174,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A } } D_80120D4C[subCamId - 1].eyeTargetInit.y = - ((mainCam->globalCtx->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + ((mainCam->play->state.frames & 1) ? 3.0f : -3.0f) + Rand_ZeroOne(); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 5); Quake_SetSpeed(i, 400); @@ -186,7 +186,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80120E64; csInfo->keyFrameCnt = 8; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 5); Quake_SetSpeed(i, 400); @@ -202,13 +202,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80120FA4; csInfo->keyFrameCnt = 6; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 2340: csInfo->keyFrames = D_80121094; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 5); Quake_SetSpeed(i, 400); @@ -219,7 +219,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_8012110C; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 2200: { s16 sp82; @@ -227,15 +227,15 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A 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.at.x + actor->focus.pos.x) * 0.5f; - D_80121184[0].atTargetInit.y = (globalCtx->view.at.y + actor->focus.pos.y) * 0.5f; - D_80121184[0].atTargetInit.z = (globalCtx->view.at.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.at.x + actor->focus.pos.x) * 0.5f; + D_80121184[0].atTargetInit.y = (play->view.at.y + actor->focus.pos.y) * 0.5f; + D_80121184[0].atTargetInit.z = (play->view.at.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 subCamId, s16 csId, A csInfo->keyFrames = D_801211D4; csInfo->keyFrameCnt = 2; } - Play_ChangeCameraStatus(globalCtx, CAM_ID_MAIN, CAM_STAT_UNK3); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + Play_ChangeCameraStatus(play, CAM_ID_MAIN, CAM_STAT_UNK3); + func_800C0808(play, subCamId, 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 subCamId, s16 csId, A csInfo->keyFrames = D_80121224; csInfo->keyFrameCnt = 6; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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); - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); - func_8002DF54(globalCtx, NULL, 8); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); + func_8002DF54(play, NULL, 8); subCam->roll = 0; subCam->fov = 50.0f; if (subCam->childCamId != CAM_ID_MAIN) { - OnePointCutscene_EndCutscene(globalCtx, subCam->childCamId); + OnePointCutscene_EndCutscene(play, subCam->childCamId); } break; case 2210: @@ -314,34 +314,34 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 1010: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &childCam->at, &childCam->eye); - Play_CameraSetFov(globalCtx, subCamId, childCam->fov); - Play_SetCameraRoll(globalCtx, subCamId, childCam->roll); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &childCam->at, &childCam->eye); + Play_CameraSetFov(play, subCamId, childCam->fov); + Play_SetCameraRoll(play, subCamId, childCam->roll); break; case 9601: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_CS_3); - Play_CameraChangeSetting(globalCtx, CAM_ID_MAIN, mainCam->prevSetting); + Play_CameraChangeSetting(play, subCamId, CAM_SET_CS_3); + Play_CameraChangeSetting(play, CAM_ID_MAIN, mainCam->prevSetting); OnePointCutscene_SetCsCamPoints(subCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120398); break; case 9602: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_CS_3); - Play_CameraChangeSetting(globalCtx, CAM_ID_MAIN, mainCam->prevSetting); + Play_CameraChangeSetting(play, subCamId, CAM_SET_CS_3); + Play_CameraChangeSetting(play, CAM_ID_MAIN, mainCam->prevSetting); OnePointCutscene_SetCsCamPoints(subCam, D_80120430 | 0x1000, D_8012042C, D_80120308, D_80120434); break; case 4175: csInfo->keyFrames = D_8012147C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4180: spC0.x = -1881.0f; @@ -350,24 +350,24 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A spB4.x = -1979.0f; spB4.y = 703.0f; spB4.z = -269.0f; - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 6; subCam->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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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 subCamId, s16 csId, A csInfo->keyFrames = D_8012156C; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); - func_8002DF54(globalCtx, NULL, 8); + func_800C0808(play, subCamId, 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 subCamId, s16 csId, A csInfo->keyFrames = D_801215BC; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3070: csInfo->keyFrames = D_801215E4; csInfo->keyFrameCnt = 10; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 3); Quake_SetSpeed(i, 22000); @@ -406,34 +406,34 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80121774; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_PIVOT_VERTICAL); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + func_800C0808(play, subCamId, player, CAM_SET_PIVOT_VERTICAL); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->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, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 1); Quake_SetSpeed(i, 24000); @@ -444,12 +444,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80121904; csInfo->keyFrameCnt = 2; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3050: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_CS_3); - func_8002DF54(globalCtx, &player->actor, 5); + Play_CameraChangeSetting(play, subCamId, CAM_SET_CS_3); + func_8002DF54(play, &player->actor, 5); OnePointCutscene_SetCsCamPoints(subCam, 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 subCamId, s16 csId, A subCam->unk_14C |= 2; csInfo->keyFrameCnt = 2; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3130: csInfo->keyFrames = D_80121A44; csInfo->keyFrameCnt = 12; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); subCam->unk_14C |= 2; break; case 3140: - D_80121C24[0].atTargetInit = globalCtx->view.at; - D_80121C24[0].eyeTargetInit = globalCtx->view.eye; - D_80121C24[0].fovTargetInit = globalCtx->view.fovy; + D_80121C24[0].atTargetInit = play->view.at; + D_80121C24[0].eyeTargetInit = play->view.eye; + D_80121C24[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_80121C24; csInfo->keyFrameCnt = 7; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3150: spC0.x = 1890.0f; @@ -506,11 +506,11 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A spB4.x = 1729.0f; spB4.y = 995.0f; spB4.z = -1405.0f; - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0x50; subCam->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 subCamId, s16 csId, A Actor_GetWorld(&spA0, &player->actor); spD0.yaw = OnePointCutscene_Vec3fYaw(&spC0, &spA0.pos) - 0x7D0; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); - Play_CopyCamera(globalCtx, CAM_ID_MAIN, subCamId); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); + Play_CopyCamera(play, CAM_ID_MAIN, subCamId); subCam->roll = -1; subCam->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 subCamId, s16 csId, A spD0.yaw = spA0.rot.y; spD0.r = 150.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->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 subCamId, s16 csId, A spD0.yaw = spA0.rot.y; spD0.pitch = -0xAF0; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->fov = 60.0f; - func_8002DF38(globalCtx, actor, 1); + func_8002DF38(play, actor, 1); break; case 3190: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FOREST_DEFEAT_POE); + Play_CameraChangeSetting(play, subCamId, 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 subCamId, s16 csId, A spB4.x = 80.0f; spB4.y = 445.0f; spB4.z = -1425.0f; - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0x1E; subCam->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 subCamId, s16 csId, A spD0.pitch = 0x5DC; spD0.r = 120.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Play_CameraSetAtEye(globalCtx, CAM_ID_MAIN, &spC0, &spB4); + Play_CameraSetAtEye(play, CAM_ID_MAIN, &spC0, &spB4); i = Quake_Add(subCam, 3); Quake_SetSpeed(i, 22000); @@ -596,27 +596,27 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A spD0.yaw = spA0.rot.y + 0x7FFF; spD0.r = 300.0f; OnePointCutscene_AddVecSphToVec3f(&spB4, &spC0, &spD0); - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FREE2); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->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, subCamId, player, CAM_SET_PIVOT_VERTICAL); + func_800C0808(play, subCamId, 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; - Play_CameraSetAtEye(globalCtx, subCamId, &spC0, &spB4); + Play_CameraSetAtEye(play, subCamId, &spC0, &spB4); subCam->roll = 0; subCam->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 subCamId, s16 csId, A csInfo->keyFrames = D_80121D3C; csInfo->keyFrameCnt = 3; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 6001: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_CS_3); - func_8002DF54(globalCtx, NULL, 8); + Play_CameraChangeSetting(play, subCamId, CAM_SET_CS_3); + func_8002DF54(play, NULL, 8); Actor_GetWorld(&spA0, actor); if (spA0.pos.z > -750.0f) { OnePointCutscene_SetCsCamPoints(subCam, D_801208E8, D_801208E4, D_801206A0, D_80120820); @@ -643,8 +643,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A Quake_SetCountdown(i, D_801208E4 - 10); break; case 3400: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_CS_3); - func_8002DF38(globalCtx, &player->actor, 8); + Play_CameraChangeSetting(play, subCamId, CAM_SET_CS_3); + func_8002DF38(play, &player->actor, 8); OnePointCutscene_SetCsCamPoints(subCam, 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 subCamId, s16 csId, A csInfo->keyFrames = D_80121DB4; csInfo->keyFrameCnt = 9; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3310: - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FIRE_STAIRCASE); - func_8002DF54(globalCtx, NULL, 8); - Play_CopyCamera(globalCtx, subCamId, CAM_ID_MAIN); + Play_CameraChangeSetting(play, subCamId, CAM_SET_FIRE_STAIRCASE); + func_8002DF54(play, NULL, 8); + Play_CopyCamera(play, subCamId, CAM_ID_MAIN); i = Quake_Add(subCam, 1); Quake_SetSpeed(i, 32000); @@ -674,16 +674,16 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A Quake_SetCountdown(i, timer); break; case 3290: - D_80121F1C[0].atTargetInit = globalCtx->view.at; - D_80121F1C[0].eyeTargetInit = globalCtx->view.eye; - D_80121F1C[0].fovTargetInit = globalCtx->view.fovy; + D_80121F1C[0].atTargetInit = play->view.at; + 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 3); Quake_SetSpeed(i, 12000); @@ -691,15 +691,15 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A Quake_SetCountdown(i, 5); break; case 3340: - D_80121FBC[0].atTargetInit = globalCtx->view.at; - D_80121FBC[0].eyeTargetInit = globalCtx->view.eye; - D_80121FBC[0].fovTargetInit = globalCtx->view.fovy; + D_80121FBC[0].atTargetInit = play->view.at; + 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, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 3); Quake_SetSpeed(i, 12000); @@ -710,13 +710,13 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_8012205C; csInfo->keyFrameCnt = 3; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3350: - D_801220D4[0].atTargetInit = globalCtx->view.at; - D_801220D4[0].eyeTargetInit = globalCtx->view.eye; - D_801220D4[0].fovTargetInit = globalCtx->view.fovy; + D_801220D4[0].atTargetInit = play->view.at; + 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 subCamId, s16 csId, A 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3330: csInfo->keyFrames = D_8012219C; csInfo->keyFrameCnt = 7; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 3410: csInfo->keyFrames = D_801222B4; csInfo->keyFrameCnt = 5; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 1); Quake_SetSpeed(i, 32000); @@ -755,8 +755,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_8012237C; csInfo->keyFrameCnt = 2; - func_8002DF38(globalCtx, &player->actor, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 1); Quake_SetSpeed(i, 32000); @@ -767,8 +767,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_801223CC; csInfo->keyFrameCnt = 6; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); player->stateFlags1 |= PLAYER_STATE1_29; player->actor.freezeTimer = 90; @@ -781,8 +781,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_801224BC; csInfo->keyFrameCnt = 7; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 1); Quake_SetSpeed(i, 32000); @@ -794,70 +794,70 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrameCnt = 5; player->actor.shape.rot.y = player->actor.world.rot.y = player->currentYaw = 0x3FFC; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); - func_8002DF54(globalCtx, NULL, 8); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 8); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4140: csInfo->keyFrames = D_801227B4; csInfo->keyFrameCnt = 6; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4210: player->actor.freezeTimer = timer; @@ -865,7 +865,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80122C14; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); i = Quake_Add(subCam, 3); Quake_SetSpeed(i, 12000); @@ -876,8 +876,8 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = (player->actor.world.pos.z < -15.0f) ? D_80122C3C : D_80122C64; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); - func_8002DF38(globalCtx, &player->actor, 1); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); + func_8002DF38(play, &player->actor, 1); i = Quake_Add(subCam, 3); Quake_SetSpeed(i, 12000); @@ -888,38 +888,38 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80122C8C; csInfo->keyFrameCnt = 1; - func_8002DF54(globalCtx, NULL, 8); - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_8002DF54(play, NULL, 8); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 8010: csInfo->keyFrames = D_80122D54; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 8002: csInfo->keyFrames = D_80122DCC; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 8700: Actor_GetFocus(&spA0, actor); @@ -930,16 +930,16 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80122E44[timer & 1]; csInfo->keyFrameCnt = 7; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, 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; @@ -948,22 +948,22 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_8012313C; csInfo->keyFrameCnt = 3; } - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); - sPrevFrameCs1100 = globalCtx->state.frames; + func_800C0808(play, subCamId, player, CAM_SET_CS_C); + sPrevFrameCs1100 = play->state.frames; } break; case 9806: subCam->timer = -99; - if (func_800C0CB8(globalCtx)) { - func_800C0808(globalCtx, subCamId, player, CAM_SET_TURN_AROUND); + if (func_800C0CB8(play)) { + func_800C0808(play, subCamId, player, CAM_SET_TURN_AROUND); subCam->data2 = 0xC; } else { - Play_CopyCamera(globalCtx, subCamId, CAM_ID_MAIN); - Play_CameraChangeSetting(globalCtx, subCamId, CAM_SET_FREE2); + Play_CopyCamera(play, subCamId, CAM_ID_MAIN); + Play_CameraChangeSetting(play, subCamId, 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 & PLAYER_STATE1_27) { @@ -982,7 +982,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_801231B4; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); } else { D_80123254[1].timerInit = timer - 1; D_80123254[0].fovTargetInit = mainCam->fov; @@ -992,60 +992,60 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80123254; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); } break; case 1000: - D_801232A4[0].atTargetInit = globalCtx->view.at; - D_801232A4[0].eyeTargetInit = globalCtx->view.eye; - D_801232A4[0].fovTargetInit = globalCtx->view.fovy; + D_801232A4[0].atTargetInit = play->view.at; + D_801232A4[0].eyeTargetInit = play->view.eye; + D_801232A4[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_801232A4; csInfo->keyFrameCnt = 1; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 8603: csInfo->keyFrames = D_801232CC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 8604: csInfo->keyFrames = D_80123394; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4000: csInfo->keyFrames = D_8012345C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4010: csInfo->keyFrames = D_801234FC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4011: csInfo->keyFrames = D_801235C4; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4020: csInfo->keyFrames = D_8012368C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4021: csInfo->keyFrames = D_8012372C; csInfo->keyFrameCnt = 4; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 4022: subCam->timer = D_801237CC[0].timerInit + D_801237CC[3].timerInit + D_801237CC[1].timerInit + @@ -1054,12 +1054,12 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_801237CC; csInfo->keyFrameCnt = 5; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 9703: - D_80123894[0].atTargetInit = globalCtx->view.at; - D_80123894[0].eyeTargetInit = globalCtx->view.eye; - D_80123894[0].fovTargetInit = globalCtx->view.fovy; + D_80123894[0].atTargetInit = play->view.at; + 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; @@ -1068,27 +1068,27 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_80123894; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 9704: - D_8012390C[0].atTargetInit = globalCtx->view.at; - D_8012390C[0].eyeTargetInit = globalCtx->view.eye; - D_8012390C[0].fovTargetInit = globalCtx->view.fovy; + D_8012390C[0].atTargetInit = play->view.at; + D_8012390C[0].eyeTargetInit = play->view.eye; + D_8012390C[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_8012390C; csInfo->keyFrameCnt = 2; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 9705: - D_8012395C[0].atTargetInit = globalCtx->view.at; - D_8012395C[0].eyeTargetInit = globalCtx->view.eye; - D_8012395C[0].fovTargetInit = globalCtx->view.fovy; + D_8012395C[0].atTargetInit = play->view.at; + D_8012395C[0].eyeTargetInit = play->view.eye; + D_8012395C[0].fovTargetInit = play->view.fovy; csInfo->keyFrames = D_8012395C; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, player, CAM_SET_CS_C); + func_800C0808(play, subCamId, player, CAM_SET_CS_C); break; case 5110: D_801239D4[1].timerInit = 10; @@ -1096,7 +1096,7 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A csInfo->keyFrames = D_801239D4; csInfo->keyFrameCnt = 3; - func_800C0808(globalCtx, subCamId, (Player*)actor, CAM_SET_CS_C); + func_800C0808(play, subCamId, (Player*)actor, CAM_SET_CS_C); break; default: osSyncPrintf(VT_COL(RED, WHITE) "onepointdemo camera: demo number not found !! (%d)\n" VT_RST, csId); @@ -1105,11 +1105,11 @@ s32 OnePointCutscene_SetInfo(GlobalContext* globalCtx, s16 subCamId, s16 csId, A return 0; } -s16 OnePointCutscene_SetAsChild(GlobalContext* globalCtx, s16 newCamId, s16 parentCamId) { - s16 prevCamId = globalCtx->cameraPtrs[parentCamId]->childCamId; +s16 OnePointCutscene_SetAsChild(PlayState* play, s16 newCamId, s16 parentCamId) { + s16 prevCamId = play->cameraPtrs[parentCamId]->childCamId; - globalCtx->cameraPtrs[newCamId]->parentCamId = parentCamId; - globalCtx->cameraPtrs[parentCamId]->childCamId = newCamId; + play->cameraPtrs[newCamId]->parentCamId = parentCamId; + play->cameraPtrs[parentCamId]->childCamId = newCamId; return prevCamId; } @@ -1118,8 +1118,8 @@ s16 OnePointCutscene_SetAsChild(GlobalContext* globalCtx, s16 newCamId, s16 pare * Removes a cutscene camera from the list. Returns the parent cam if the removed camera is active, otherwise returns * CAM_ID_NONE */ -s32 OnePointCutscene_RemoveCamera(GlobalContext* globalCtx, s16 subCamId) { - Camera* subCam = globalCtx->cameraPtrs[subCamId]; +s32 OnePointCutscene_RemoveCamera(PlayState* play, s16 subCamId) { + Camera* subCam = play->cameraPtrs[subCamId]; s32 nextCamId; if (subCam->camId == CHILD_CAM(subCam)->parentCamId) { @@ -1128,11 +1128,11 @@ s32 OnePointCutscene_RemoveCamera(GlobalContext* globalCtx, s16 subCamId) { if (subCam->camId == PARENT_CAM(subCam)->childCamId) { PARENT_CAM(subCam)->childCamId = subCam->childCamId; } - nextCamId = (globalCtx->activeCamId == subCamId) ? subCam->parentCamId : CAM_ID_NONE; + nextCamId = (play->activeCamId == subCamId) ? subCam->parentCamId : CAM_ID_NONE; subCam->parentCamId = CAM_ID_MAIN; subCam->childCamId = subCam->parentCamId; subCam->timer = -1; - Play_ClearCamera(subCam->globalCtx, subCam->camId); + Play_ClearCamera(subCam->play, subCam->camId); return nextCamId; } @@ -1146,16 +1146,16 @@ s32 OnePointCutscene_RemoveCamera(GlobalContext* globalCtx, s16 subCamId) { * 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 parentCamId) { +s16 OnePointCutscene_Init(PlayState* play, s16 csId, s16 timer, Actor* actor, s16 parentCamId) { s16 temp1; s16 temp2; s16 subCamId; Camera* subCam; if (parentCamId == CAM_ID_NONE) { - parentCamId = globalCtx->activeCamId; + parentCamId = play->activeCamId; } - subCamId = Play_CreateSubCamera(globalCtx); + subCamId = Play_CreateSubCamera(play); if (subCamId == CAM_ID_NONE) { osSyncPrintf(VT_COL(RED, WHITE) "onepoint demo: error: too many cameras ... give up! type=%d\n" VT_RST, csId); return CAM_ID_NONE; @@ -1163,58 +1163,58 @@ s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* // Inserts the cutscene camera into the cutscene queue in front of parentCam - vChildCamId = globalCtx->cameraPtrs[parentCamId]->childCamId; + vChildCamId = play->cameraPtrs[parentCamId]->childCamId; vSubCamStatus = CAM_STAT_ACTIVE; if (vChildCamId >= CAM_ID_SUB_FIRST) { - OnePointCutscene_SetAsChild(globalCtx, vChildCamId, subCamId); + OnePointCutscene_SetAsChild(play, vChildCamId, subCamId); vSubCamStatus = CAM_STAT_WAIT; } else { Interface_ChangeAlpha(2); } - OnePointCutscene_SetAsChild(globalCtx, subCamId, parentCamId); + OnePointCutscene_SetAsChild(play, subCamId, parentCamId); - subCam = globalCtx->cameraPtrs[subCamId]; + subCam = play->cameraPtrs[subCamId]; subCam->timer = timer; subCam->target = actor; - subCam->at = globalCtx->view.at; - subCam->eye = globalCtx->view.eye; - subCam->fov = globalCtx->view.fovy; + subCam->at = play->view.at; + subCam->eye = play->view.eye; + subCam->fov = play->view.fovy; subCam->csId = csId; if (parentCamId == CAM_ID_MAIN) { - Play_ChangeCameraStatus(globalCtx, parentCamId, CAM_STAT_UNK3); + Play_ChangeCameraStatus(play, parentCamId, CAM_STAT_UNK3); } else { - Play_ChangeCameraStatus(globalCtx, parentCamId, CAM_STAT_WAIT); + Play_ChangeCameraStatus(play, parentCamId, CAM_STAT_WAIT); } - OnePointCutscene_SetInfo(globalCtx, subCamId, csId, actor, timer); - Play_ChangeCameraStatus(globalCtx, subCamId, vSubCamStatus); + OnePointCutscene_SetInfo(play, subCamId, csId, actor, timer); + Play_ChangeCameraStatus(play, subCamId, vSubCamStatus); // Removes all lower priority cutscenes in front of this cutscene from the queue. vCurCamId = subCamId; - vNextCamId = globalCtx->cameraPtrs[subCamId]->childCamId; + vNextCamId = play->cameraPtrs[subCamId]->childCamId; while (vNextCamId >= CAM_ID_SUB_FIRST) { - s16 nextCsId = globalCtx->cameraPtrs[vNextCamId]->csId; - s16 thisCsId = globalCtx->cameraPtrs[subCamId]->csId; + s16 nextCsId = play->cameraPtrs[vNextCamId]->csId; + s16 thisCsId = play->cameraPtrs[subCamId]->csId; if ((nextCsId / 100) < (thisCsId / 100)) { osSyncPrintf(VT_COL(YELLOW, BLACK) "onepointdemo camera[%d]: killed 'coz low priority (%d < %d)\n" VT_RST, vNextCamId, nextCsId, thisCsId); - if (globalCtx->cameraPtrs[vNextCamId]->csId != 5010) { - if ((vNextCamId = OnePointCutscene_RemoveCamera(globalCtx, vNextCamId)) != CAM_ID_NONE) { - Play_ChangeCameraStatus(globalCtx, vNextCamId, CAM_STAT_ACTIVE); + if (play->cameraPtrs[vNextCamId]->csId != 5010) { + if ((vNextCamId = OnePointCutscene_RemoveCamera(play, vNextCamId)) != CAM_ID_NONE) { + Play_ChangeCameraStatus(play, vNextCamId, CAM_STAT_ACTIVE); } } else { vCurCamId = vNextCamId; - OnePointCutscene_EndCutscene(globalCtx, vNextCamId); + OnePointCutscene_EndCutscene(play, vNextCamId); } } else { vCurCamId = vNextCamId; } - vNextCamId = globalCtx->cameraPtrs[vCurCamId]->childCamId; + vNextCamId = play->cameraPtrs[vCurCamId]->childCamId; } return subCamId; } @@ -1222,17 +1222,17 @@ s16 OnePointCutscene_Init(GlobalContext* globalCtx, s16 csId, s16 timer, Actor* /** * Ends the cutscene in subCamId by setting its timer to 0. For attention cutscenes, it is set to 5 instead. */ -s16 OnePointCutscene_EndCutscene(GlobalContext* globalCtx, s16 subCamId) { +s16 OnePointCutscene_EndCutscene(PlayState* play, s16 subCamId) { if (subCamId == CAM_ID_NONE) { - subCamId = globalCtx->activeCamId; + subCamId = play->activeCamId; } - if (globalCtx->cameraPtrs[subCamId] != NULL) { - osSyncPrintf("onepointdemo camera[%d]: delete timer=%d next=%d\n", subCamId, - globalCtx->cameraPtrs[subCamId]->timer, globalCtx->cameraPtrs[subCamId]->parentCamId); - if (globalCtx->cameraPtrs[subCamId]->csId == 5010) { - globalCtx->cameraPtrs[subCamId]->timer = 5; + if (play->cameraPtrs[subCamId] != NULL) { + osSyncPrintf("onepointdemo camera[%d]: delete timer=%d next=%d\n", subCamId, play->cameraPtrs[subCamId]->timer, + play->cameraPtrs[subCamId]->parentCamId); + if (play->cameraPtrs[subCamId]->csId == 5010) { + play->cameraPtrs[subCamId]->timer = 5; } else { - globalCtx->cameraPtrs[subCamId]->timer = 0; + play->cameraPtrs[subCamId]->timer = 0; } } return subCamId; @@ -1246,7 +1246,7 @@ s16 OnePointCutscene_EndCutscene(GlobalContext* globalCtx, s16 subCamId) { /** * 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; @@ -1258,7 +1258,7 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { } sUnused = -1; - parentCam = globalCtx->cameraPtrs[CAM_ID_MAIN]; + parentCam = play->cameraPtrs[CAM_ID_MAIN]; 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); @@ -1269,7 +1269,7 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { vLastHigherCat = -1; while (parentCam->childCamId != CAM_ID_MAIN) { - parentCam = globalCtx->cameraPtrs[parentCam->childCamId]; + parentCam = play->cameraPtrs[parentCam->childCamId]; if (parentCam == NULL) { break; } else if (parentCam->setting != CAM_SET_CS_ATTENTION) { @@ -1309,11 +1309,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. @@ -1322,12 +1322,12 @@ s32 OnePointCutscene_Attention(GlobalContext* globalCtx, Actor* actor) { return CAM_ID_NONE; } osSyncPrintf("→ " VT_FGCOL(BLUE) "○" VT_RST " (%d)\n", actor->id); - vSubCamId = OnePointCutscene_Init(globalCtx, 5010, timer, actor, vParentCamId); + vSubCamId = OnePointCutscene_Init(play, 5010, timer, actor, vParentCamId); if (vSubCamId == CAM_ID_NONE) { osSyncPrintf(VT_COL(RED, WHITE) "actor attention demo: give up! \n" VT_RST, actor->id); return CAM_ID_NONE; } else { - s32* data = (s32*)&globalCtx->cameraPtrs[vSubCamId]->data1; + s32* data = (s32*)&play->cameraPtrs[vSubCamId]->data1; *data = NA_SE_SY_CORRECT_CHIME; return vSubCamId; @@ -1337,11 +1337,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 subCamId = OnePointCutscene_Attention(globalCtx, actor); +s32 OnePointCutscene_AttentionSetSfx(PlayState* play, Actor* actor, s32 sfxId) { + s32 subCamId = OnePointCutscene_Attention(play, actor); if (subCamId != CAM_ID_NONE) { - s32* data = (s32*)&globalCtx->cameraPtrs[subCamId]->data1; + s32* data = (s32*)&play->cameraPtrs[subCamId]->data1; *data = sfxId; } @@ -1358,11 +1358,11 @@ void OnePointCutscene_DisableAttention(void) { sDisableAttention = true; } -s32 OnePointCutscene_CheckForCategory(GlobalContext* globalCtx, s32 actorCategory) { - Camera* parentCam = globalCtx->cameraPtrs[CAM_ID_MAIN]; +s32 OnePointCutscene_CheckForCategory(PlayState* play, s32 actorCategory) { + Camera* parentCam = play->cameraPtrs[CAM_ID_MAIN]; while (parentCam->childCamId != CAM_ID_MAIN) { - parentCam = globalCtx->cameraPtrs[parentCam->childCamId]; + parentCam = play->cameraPtrs[parentCam->childCamId]; if ((parentCam == NULL) || (parentCam->setting != CAM_SET_CS_ATTENTION)) { break; } else if (actorCategory == parentCam->target->category) { @@ -1373,5 +1373,5 @@ s32 OnePointCutscene_CheckForCategory(GlobalContext* globalCtx, s32 actorCategor } // unused, also empty. -void OnePointCutscene_Noop(GlobalContext* globalCtx, s32 arg1) { +void OnePointCutscene_Noop(PlayState* play, s32 arg1) { } diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index 46866eea8..20255ca48 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -177,8 +177,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) { @@ -231,11 +231,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; } @@ -260,8 +260,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) { @@ -316,7 +316,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; @@ -370,7 +370,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; @@ -390,7 +390,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; @@ -404,7 +404,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: @@ -443,7 +443,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; @@ -591,7 +591,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; @@ -612,24 +612,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 = false; 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 & PLAYER_STATE1_23) || (globalCtx->shootingGalleryStatus > 1) || - ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { + if ((player->stateFlags1 & PLAYER_STATE1_23) || (play->shootingGalleryStatus > 1) || + ((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38))) { if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { gSaveContext.unk_13E7 = 1; @@ -644,22 +644,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); } } } @@ -669,13 +669,13 @@ void func_80083108(GlobalContext* globalCtx) { Interface_ChangeAlpha(6); } - if (globalCtx->transitionMode != TRANS_MODE_OFF) { + if (play->transitionMode != TRANS_MODE_OFF) { 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 & PLAYER_STATE1_23) { Interface_ChangeAlpha(12); @@ -685,16 +685,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); } @@ -706,7 +706,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] = @@ -722,7 +722,7 @@ void func_80083108(GlobalContext* globalCtx) { Interface_ChangeAlpha(50); } } else if (msgCtx->msgMode == MSGMODE_NONE) { - if ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) { + if ((func_8008F2F8(play) >= 2) && (func_8008F2F8(play) < 5)) { if (gSaveContext.buttonStatus[0] != BTN_DISABLED) { sp28 = true; } @@ -730,7 +730,7 @@ void func_80083108(GlobalContext* globalCtx) { gSaveContext.buttonStatus[0] = BTN_DISABLED; for (i = 1; i < 4; i++) { - if (func_8008F2F8(globalCtx) == 2) { + if (func_8008F2F8(play) == 2) { if ((gSaveContext.equips.buttonItems[i] != ITEM_HOOKSHOT) && (gSaveContext.equips.buttonItems[i] != ITEM_LONGSHOT)) { if (gSaveContext.buttonStatus[i] == BTN_ENABLED) { @@ -796,7 +796,7 @@ void func_80083108(GlobalContext* globalCtx) { } if (sp28) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); sp28 = false; } @@ -834,7 +834,7 @@ void func_80083108(GlobalContext* globalCtx) { sp28 = true; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } } else if ((gSaveContext.buttonStatus[0] & 0xFF) == BTN_DISABLED) { @@ -858,7 +858,7 @@ void func_80083108(GlobalContext* globalCtx) { sp28 = true; if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } } else { @@ -1021,7 +1021,7 @@ void func_80083108(GlobalContext* globalCtx) { (gSaveContext.equips.buttonItems[i] <= ITEM_POE)) && !((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[i] == BTN_ENABLED) { sp28 = true; @@ -1064,7 +1064,7 @@ void func_80083108(GlobalContext* globalCtx) { if (sp28) { gSaveContext.unk_13EA = 0; - if ((globalCtx->transitionTrigger == TRANS_TRIGGER_OFF) && (globalCtx->transitionMode == TRANS_MODE_OFF)) { + if ((play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF)) { Interface_ChangeAlpha(50); osSyncPrintf("???????? alpha_change( 50 ); ?????\n"); } else { @@ -1073,8 +1073,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; @@ -1088,10 +1088,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; @@ -1250,8 +1250,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; @@ -1259,7 +1259,7 @@ void Interface_InitHorsebackArchery(GlobalContext* globalCtx) { interfaceCtx->hbaAmmo = 20; } -void func_800849EC(GlobalContext* globalCtx) { +void func_800849EC(PlayState* play) { gSaveContext.inventory.equipment |= OWNED_EQUIP_FLAG(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BGS); gSaveContext.inventory.equipment ^= OWNED_EQUIP_FLAG_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE); @@ -1269,11 +1269,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, @@ -1282,8 +1282,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, @@ -1292,7 +1292,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) || @@ -1303,12 +1303,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[INFTABLE_1DX_INDEX] == 0)) { gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } @@ -1318,11 +1318,11 @@ void func_80084BF4(GlobalContext* globalCtx, u16 flag) { } else { gSaveContext.buttonStatus[0] = gSaveContext.buttonStatus[1] = gSaveContext.buttonStatus[2] = gSaveContext.buttonStatus[3] = BTN_ENABLED; - func_80083108(globalCtx); + func_80083108(play); } } -u8 Item_Give(GlobalContext* globalCtx, u8 item) { +u8 Item_Give(PlayState* play, u8 item) { static s16 sAmmoRefillCounts[] = { 5, 10, 20, 30 }; // Sticks, nuts, bombs static s16 sArrowRefillCounts[] = { 5, 10, 30 }; static s16 sBombchuRefillCounts[] = { 5, 20 }; @@ -1348,7 +1348,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { osSyncPrintf(VT_RST); if (item == ITEM_MEDALLION_WATER) { - func_8006D0AC(globalCtx); + func_8006D0AC(play); } return ITEM_NONE; @@ -1403,14 +1403,14 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { OWNED_EQUIP_FLAG_ALT(EQUIP_TYPE_SWORD, EQUIP_INV_SWORD_BROKENGIANTKNIFE); if (gSaveContext.equips.buttonItems[0] == ITEM_SWORD_KNIFE) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_BGS; - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } } } else if (item == ITEM_SWORD_MASTER) { gSaveContext.equips.buttonItems[0] = ITEM_SWORD_MASTER; gSaveContext.equips.equipment &= (u16) ~(0xF << (EQUIP_TYPE_SWORD * 4)); gSaveContext.equips.equipment |= EQUIP_VALUE_SWORD_MASTER << (EQUIP_TYPE_SWORD * 4); - Interface_LoadItemIcon1(globalCtx, 0); + Interface_LoadItemIcon1(play, 0); } return ITEM_NONE; @@ -1536,7 +1536,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < 4; i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_HOOKSHOT) { gSaveContext.equips.buttonItems[i] = ITEM_LONGSHOT; - Interface_LoadItemIcon1(globalCtx, i); + Interface_LoadItemIcon1(play, i); } } return ITEM_NONE; @@ -1670,7 +1670,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { for (i = 1; i < 4; i++) { if (gSaveContext.equips.buttonItems[i] == ITEM_OCARINA_FAIRY) { gSaveContext.equips.buttonItems[i] = ITEM_OCARINA_TIME; - Interface_LoadItemIcon1(globalCtx, i); + Interface_LoadItemIcon1(play, i); } } return ITEM_NONE; @@ -1693,14 +1693,14 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return ITEM_NONE; } else if (item == ITEM_HEART) { osSyncPrintf("回復ハート回復ハート回復ハート\n"); // "Recovery Heart" - Health_ChangeBy(globalCtx, 0x10); + Health_ChangeBy(play, 0x10); return item; } else if (item == ITEM_MAGIC_SMALL) { if (gSaveContext.unk_13F0 != 10) { - Magic_Fill(globalCtx); + Magic_Fill(play); } - func_80087708(globalCtx, 12, 5); + func_80087708(play, 12, 5); if (!GET_INFTABLE(INFTABLE_198)) { SET_INFTABLE(INFTABLE_198); @@ -1710,10 +1710,10 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { return item; } else if (item == ITEM_MAGIC_LARGE) { if (gSaveContext.unk_13F0 != 10) { - Magic_Fill(globalCtx); + Magic_Fill(play); } - func_80087708(globalCtx, 24, 5); + func_80087708(play, 24, 5); if (!GET_INFTABLE(INFTABLE_198)) { SET_INFTABLE(INFTABLE_198); @@ -1751,15 +1751,15 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if ((temp + i) == gSaveContext.equips.cButtonSlots[0]) { gSaveContext.equips.buttonItems[1] = item; - Interface_LoadItemIcon2(globalCtx, 1); + Interface_LoadItemIcon2(play, 1); gSaveContext.buttonStatus[1] = BTN_ENABLED; } else if ((temp + i) == gSaveContext.equips.cButtonSlots[1]) { gSaveContext.equips.buttonItems[2] = item; - Interface_LoadItemIcon2(globalCtx, 2); + Interface_LoadItemIcon2(play, 2); gSaveContext.buttonStatus[2] = BTN_ENABLED; } else if ((temp + i) == gSaveContext.equips.cButtonSlots[2]) { gSaveContext.equips.buttonItems[3] = item; - Interface_LoadItemIcon1(globalCtx, 3); + Interface_LoadItemIcon1(play, 3); gSaveContext.buttonStatus[3] = BTN_ENABLED; } @@ -1788,7 +1788,7 @@ u8 Item_Give(GlobalContext* globalCtx, u8 item) { if (temp == gSaveContext.equips.buttonItems[i]) { if (item != ITEM_SOLD_OUT) { gSaveContext.equips.buttonItems[i] = item; - Interface_LoadItemIcon1(globalCtx, i); + Interface_LoadItemIcon1(play, i); } else { gSaveContext.equips.buttonItems[i] = ITEM_NONE; } @@ -1953,7 +1953,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++) { @@ -1963,7 +1963,7 @@ s32 Inventory_ReplaceItem(GlobalContext* globalCtx, u16 oldItem, u16 newItem) { for (i = 1; i < 4; i++) { if (gSaveContext.equips.buttonItems[i] == oldItem) { gSaveContext.equips.buttonItems[i] = newItem; - Interface_LoadItemIcon1(globalCtx, i); + Interface_LoadItemIcon1(play, i); break; } } @@ -2006,7 +2006,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]]); @@ -2020,13 +2020,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] = BTN_ENABLED; } -s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { +s32 Inventory_ConsumeFairy(PlayState* play) { s32 bottleSlot = SLOT(ITEM_FAIRY); s16 i; s16 j; @@ -2036,7 +2036,7 @@ s32 Inventory_ConsumeFairy(GlobalContext* globalCtx) { for (j = 1; j < 4; 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; @@ -2088,9 +2088,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; @@ -2103,11 +2103,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)) { // clang-format off if (naviCallState == 0x1E) { Audio_PlaySoundGeneral(NA_SE_VO_NAVY_CALL, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, @@ -2127,8 +2127,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; if (gSaveContext.language != LANGUAGE_ENG) { action += DO_ACTION_MAX; @@ -2149,7 +2149,7 @@ void Interface_LoadActionLabelB(GlobalContext* globalCtx, u16 action) { interfaceCtx->unk_1FA = true; } -s32 Health_ChangeBy(GlobalContext* globalCtx, s16 healthChange) { +s32 Health_ChangeBy(PlayState* play, s16 healthChange) { u16 heartCount; u16 healthLevel; @@ -2264,7 +2264,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 * 0x30) + 0x30; @@ -2272,7 +2272,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; @@ -2281,7 +2281,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; } @@ -2299,7 +2299,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; @@ -2312,7 +2312,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; @@ -2325,7 +2325,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 { @@ -2341,7 +2341,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; @@ -2368,7 +2368,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 }, @@ -2378,8 +2378,8 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { static s16 sMagicBorderIndices[] = { 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; @@ -2482,16 +2482,15 @@ 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->transitionTrigger == TRANS_TRIGGER_OFF) && (globalCtx->transitionMode == TRANS_MODE_OFF) && - !Play_InCsMode(globalCtx)) { - if ((gSaveContext.magic == 0) || ((func_8008F2F8(globalCtx) >= 2) && (func_8008F2F8(globalCtx) < 5)) || + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && + (play->gameOverCtx.state == GAMEOVER_INACTIVE) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play)) { + if ((gSaveContext.magic == 0) || ((func_8008F2F8(play) >= 2) && (func_8008F2F8(play) < 5)) || ((gSaveContext.equips.buttonItems[1] != ITEM_LENS) && (gSaveContext.equips.buttonItems[2] != ITEM_LENS) && (gSaveContext.equips.buttonItems[3] != ITEM_LENS)) || - !globalCtx->actorCtx.lensActive) { - globalCtx->actorCtx.lensActive = false; + !play->actorCtx.lensActive) { + play->actorCtx.lensActive = false; Audio_PlaySoundGeneral(NA_SE_SY_GLASSMODE_OFF, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); gSaveContext.unk_13F0 = 0; @@ -2559,11 +2558,11 @@ void Interface_UpdateMagicBar(GlobalContext* globalCtx) { } } -void Interface_DrawMagicBar(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_DrawMagicBar(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; s16 magicBarY; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 2650); + OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 2650); if (gSaveContext.magicLevel != 0) { if (gSaveContext.healthCapacity > 0xA0) { @@ -2572,7 +2571,7 @@ void Interface_DrawMagicBar(GlobalContext* globalCtx) { magicBarY = R_MAGIC_BAR_SMALL_Y; } - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, sMagicBorderR, sMagicBorderG, sMagicBorderB, interfaceCtx->magicAlpha); gDPSetEnvColor(OVERLAY_DISP++, 100, 50, 50, 255); @@ -2630,7 +2629,7 @@ void Interface_DrawMagicBar(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 2731); + CLOSE_DISPS(play->state.gfxCtx, "../z_parameter.c", 2731); } void func_80088AA0(s16 arg0) { @@ -2646,7 +2645,7 @@ void func_80088AA0(s16 arg0) { } } -void func_80088AF0(GlobalContext* globalCtx) { +void func_80088AF0(PlayState* play) { if (gSaveContext.timer2State != 0) { if (GET_EVENTINF(EVENTINF_10)) { gSaveContext.timer2Value = 239; @@ -2681,18 +2680,18 @@ void Interface_DrawActionLabel(GraphicsContext* gfxCtx, void* texture) { CLOSE_DISPS(gfxCtx, "../z_parameter.c", 2829); } -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; s16 height; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 2900); + OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 2900); // B Button Color & Texture // Also loads the Item Button Texture reused by other buttons afterwards @@ -2727,7 +2726,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++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 120, 120, 120, interfaceCtx->startAlpha); @@ -2754,15 +2753,15 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { } } - 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 & PLAYER_STATE1_21) || (func_8008F2F8(globalCtx) == 4) || + } else if ((player->stateFlags1 & PLAYER_STATE1_21) || (func_8008F2F8(play) == 4) || (player->stateFlags2 & PLAYER_STATE2_18)) { temp = 70; } else { @@ -2816,11 +2815,11 @@ void Interface_DrawItemButtons(GlobalContext* globalCtx) { } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3071); + CLOSE_DISPS(play->state.gfxCtx, "../z_parameter.c", 3071); } -void Interface_DrawItemIconTexture(GlobalContext* globalCtx, void* texture, s16 button) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3079); +void Interface_DrawItemIconTexture(PlayState* play, void* texture, s16 button) { + OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 3079); gDPLoadTextureBlock(OVERLAY_DISP++, texture, G_IM_FMT_RGBA, G_IM_SIZ_32b, 32, 32, 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); @@ -2830,14 +2829,14 @@ void Interface_DrawItemIconTexture(GlobalContext* globalCtx, void* texture, s16 (R_ITEM_ICON_Y(button) + R_ITEM_ICON_WIDTH(button)) << 2, G_TX_RENDERTILE, 0, 0, R_ITEM_ICON_DD(button) << 1, R_ITEM_ICON_DD(button) << 1); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3094); + CLOSE_DISPS(play->state.gfxCtx, "../z_parameter.c", 3094); } -void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { +void Interface_DrawAmmoCount(PlayState* play, s16 button, s16 alpha) { s16 i; s16 ammo; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3105); + OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 3105); i = gSaveContext.equips.buttonItems[button]; @@ -2854,11 +2853,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; } @@ -2888,19 +2887,19 @@ void Interface_DrawAmmoCount(GlobalContext* globalCtx, s16 button, s16 alpha) { R_ITEM_AMMO_X(button) + 6, R_ITEM_AMMO_Y(button), 8, 8, 1 << 10, 1 << 10); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3158); + CLOSE_DISPS(play->state.gfxCtx, "../z_parameter.c", 3158); } -void Interface_DrawActionButton(GlobalContext* globalCtx) { - InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx; +void Interface_DrawActionButton(PlayState* play) { + InterfaceContext* interfaceCtx = &play->interfaceCtx; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3172); + OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 3172); Matrix_Translate(0.0f, 0.0f, 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, "../z_parameter.c", 3177), + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_parameter.c", 3177), G_MTX_MODELVIEW | G_MTX_LOAD); gSPVertex(OVERLAY_DISP++, &interfaceCtx->actionVtx[0], 4, 0); @@ -2910,14 +2909,14 @@ void Interface_DrawActionButton(GlobalContext* globalCtx) { gSP1Quadrangle(OVERLAY_DISP++, 0, 2, 3, 1, 0); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3187); + CLOSE_DISPS(play->state.gfxCtx, "../z_parameter.c", 3187); } -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)); interfaceCtx->actionVtx[0].v.ob[0] = interfaceCtx->actionVtx[2].v.ob[0] = -14; interfaceCtx->actionVtx[1].v.ob[0] = interfaceCtx->actionVtx[3].v.ob[0] = interfaceCtx->actionVtx[0].v.ob[0] + 28; @@ -2959,7 +2958,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; @@ -2988,8 +2987,8 @@ void Interface_InitVertices(GlobalContext* globalCtx) { 255; } -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; @@ -3017,7 +3016,7 @@ void func_8008A994(InterfaceContext* interfaceCtx) { View_ApplyOrthoToOverlay(&interfaceCtx->view); } -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 }; @@ -3037,10 +3036,10 @@ 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; @@ -3048,7 +3047,7 @@ void Interface_Draw(GlobalContext* globalCtx) { s16 svar5; s16 svar6; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 3405); + OPEN_DISPS(play->state.gfxCtx, "../z_parameter.c", 3405); gSPSegment(OVERLAY_DISP++, 0x02, interfaceCtx->parameterSegment); gSPSegment(OVERLAY_DISP++, 0x07, interfaceCtx->doActionSegment); @@ -3056,18 +3055,18 @@ void Interface_Draw(GlobalContext* globalCtx) { gSPSegment(OVERLAY_DISP++, 0x0B, interfaceCtx->mapSegment); if (pauseCtx->debugState == 0) { - Interface_InitVertices(globalCtx); + Interface_InitVertices(play); func_8008A994(interfaceCtx); - Health_DrawMeter(globalCtx); + Health_DrawMeter(play); - func_80094520(globalCtx->state.gfxCtx); + func_80094520(play->state.gfxCtx); // Rupee Icon gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 200, 255, 100, interfaceCtx->magicAlpha); gDPSetEnvColor(OVERLAY_DISP++, 0, 80, 0, 255); OVERLAY_DISP = Gfx_TextureIA8(OVERLAY_DISP, gRupeeCounterIconTex, 16, 16, 26, 206, 16, 16, 1 << 10, 1 << 10); - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_BMORI1: case SCENE_HIDAN: case SCENE_MIZUSIN: @@ -3162,16 +3161,16 @@ void Interface_Draw(GlobalContext* globalCtx) { 16, svar3, 206, 8, 16, 1 << 10, 1 << 10); } - Interface_DrawMagicBar(globalCtx); - Minimap_Draw(globalCtx); + Interface_DrawMagicBar(play); + 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); - Interface_DrawItemButtons(globalCtx); + Interface_DrawItemButtons(play); gDPPipeSync(OVERLAY_DISP++); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, 255, 255, 255, interfaceCtx->bAlpha); @@ -3180,14 +3179,14 @@ void Interface_Draw(GlobalContext* globalCtx) { if (!(interfaceCtx->unk_1FA)) { // B Button Icon & Ammo Count if (gSaveContext.equips.buttonItems[0] != ITEM_NONE) { - Interface_DrawItemIconTexture(globalCtx, interfaceCtx->iconItemSegment, 0); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment, 0); - if ((player->stateFlags1 & PLAYER_STATE1_23) || (globalCtx->shootingGalleryStatus > 1) || - ((globalCtx->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(globalCtx, 0x38))) { + if ((player->stateFlags1 & PLAYER_STATE1_23) || (play->shootingGalleryStatus > 1) || + ((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38))) { 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 { @@ -3215,11 +3214,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, interfaceCtx->iconItemSegment + 0x1000, 1); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment + 0x1000, 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++); @@ -3228,11 +3227,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, interfaceCtx->iconItemSegment + 0x2000, 2); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment + 0x2000, 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++); @@ -3241,23 +3240,23 @@ 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, interfaceCtx->iconItemSegment + 0x3000, 3); + Interface_DrawItemIconTexture(play, interfaceCtx->iconItemSegment + 0x3000, 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); } // A Button - func_80094A14(globalCtx->state.gfxCtx); - func_8008A8B8(globalCtx, R_A_BTN_Y, R_A_BTN_Y + 45, R_A_BTN_X, R_A_BTN_X + 45); + func_80094A14(play->state.gfxCtx); + func_8008A8B8(play, R_A_BTN_Y, R_A_BTN_Y + 45, R_A_BTN_X, R_A_BTN_X + 45); gSPClearGeometryMode(OVERLAY_DISP++, G_CULL_BOTH); gDPSetCombineMode(OVERLAY_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM); gDPSetPrimColor(OVERLAY_DISP++, 0, 0, R_A_BTN_COLOR(0), R_A_BTN_COLOR(1), R_A_BTN_COLOR(2), interfaceCtx->aAlpha); - Interface_DrawActionButton(globalCtx); + Interface_DrawActionButton(play); gDPPipeSync(OVERLAY_DISP++); - func_8008A8B8(globalCtx, R_A_ICON_Y, R_A_ICON_Y + 45, R_A_ICON_X, R_A_ICON_X + 45); + func_8008A8B8(play, R_A_ICON_Y, R_A_ICON_Y + 45, R_A_ICON_X, R_A_ICON_X + 45); gSPSetGeometryMode(OVERLAY_DISP++, G_CULL_BACK); gDPSetCombineLERP(OVERLAY_DISP++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0); @@ -3266,14 +3265,14 @@ void Interface_Draw(GlobalContext* globalCtx) { Matrix_Translate(0.0f, 0.0f, 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, "../z_parameter.c", 3701), + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_parameter.c", 3701), 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++); @@ -3283,7 +3282,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); @@ -3329,9 +3328,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) { @@ -3388,12 +3387,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->transitionTrigger = TRANS_TRIGGER_START; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE; + play->transitionTrigger = TRANS_TRIGGER_START; + play->transitionType = TRANS_TYPE_FADE_WHITE; gSaveContext.timer2State = 0; if ((gSaveContext.equips.buttonItems[0] != ITEM_SWORD_KOKIRI) && @@ -3414,25 +3413,24 @@ void Interface_Draw(GlobalContext* globalCtx) { (u16) ~(EVENTINF_HORSES_STATE_MASK | EVENTINF_HORSES_HORSETYPE_MASK | EVENTINF_HORSES_05_MASK | EVENTINF_HORSES_06_MASK | EVENTINF_HORSES_0F_MASK); osSyncPrintf("EVENT_INF=%x\n", gSaveContext.eventInf[EVENTINF_HORSES_INDEX]); - globalCtx->nextEntranceIndex = spoilingItemEntrances[svar1]; + play->nextEntranceIndex = spoilingItemEntrances[svar1]; INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; for (svar2 = 1; svar2 < 4; 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 & PLAYER_STATE2_24) && (globalCtx->transitionTrigger == TRANS_TRIGGER_OFF) && - (globalCtx->transitionMode == TRANS_MODE_OFF) && !Play_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 & PLAYER_STATE2_24) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && + (play->transitionMode == TRANS_MODE_OFF) && !Play_InCsMode(play) && (gSaveContext.minigameState != 1) && + (play->shootingGalleryStatus <= 1) && !((play->sceneNum == SCENE_BOWLING) && Flags_GetSwitch(play, 0x38))) { svar6 = 0; switch (gSaveContext.timer1State) { case 1: @@ -3522,7 +3520,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gSaveContext.timer1State = 10; if (D_80125A5C) { gSaveContext.health = 0; - globalCtx->damagePlayer(globalCtx, -(gSaveContext.health + 2)); + play->damagePlayer(play, -(gSaveContext.health + 2)); } D_80125A5C = false; } else if (gSaveContext.timer1Value > 60) { @@ -3690,16 +3688,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; @@ -3725,7 +3723,7 @@ void Interface_Draw(GlobalContext* globalCtx) { gSaveContext.timer2Value++; if (GET_EVENTINF(EVENTINF_10)) { if (gSaveContext.timer2Value == 240) { - Message_StartTextbox(globalCtx, 0x6083, NULL); + Message_StartTextbox(play, 0x6083, NULL); CLEAR_EVENTINF(EVENTINF_10); gSaveContext.timer2State = 0; } @@ -3814,7 +3812,7 @@ void Interface_Draw(GlobalContext* globalCtx) { } if (pauseCtx->debugState == 3) { - FlagSet_Update(globalCtx); + FlagSet_Update(play); } if (interfaceCtx->unk_244 != 0) { @@ -3824,19 +3822,19 @@ void Interface_Draw(GlobalContext* globalCtx) { gDPFillRectangle(OVERLAY_DISP++, 0, 0, gScreenWidth - 1, gScreenHeight - 1); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_parameter.c", 4269); + CLOSE_DISPS(play->state.gfxCtx, "../z_parameter.c", 4269); } -void Interface_Update(GlobalContext* globalCtx) { +void Interface_Update(PlayState* play) { static u8 D_80125B60 = false; static s16 sPrevTimeSpeed = 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]; if (CHECK_BTN_ALL(debugInput->press.button, BTN_DLEFT)) { gSaveContext.language = LANGUAGE_ENG; @@ -3849,13 +3847,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); } } } @@ -3880,7 +3878,7 @@ void Interface_Update(GlobalContext* globalCtx) { alpha = 0; } - func_80082850(globalCtx, alpha); + func_80082850(play, alpha); gSaveContext.unk_13EC++; if (alpha == 0) { @@ -3899,7 +3897,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; @@ -3909,7 +3907,7 @@ void Interface_Update(GlobalContext* globalCtx) { interfaceCtx->magicAlpha = alpha1; } - switch (globalCtx->sceneNum) { + switch (play->sceneNum) { case SCENE_SPOT00: case SCENE_SPOT01: case SCENE_SPOT02: @@ -3951,13 +3949,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; @@ -3978,25 +3976,25 @@ void Interface_Update(GlobalContext* globalCtx) { } } - Health_UpdateBeatingHeart(globalCtx); - D_80125A58 = func_8008F2F8(globalCtx); + Health_UpdateBeatingHeart(play); + D_80125A58 = func_8008F2F8(play); if (D_80125A58 == 1) { if (CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC) == EQUIP_VALUE_TUNIC_GORON) { 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_TYPE_TUNIC) == EQUIP_VALUE_TUNIC_ZORA) { D_80125A58 = 0; } } - Health_UpdateMeter(globalCtx); + Health_UpdateMeter(play); - if ((gSaveContext.timer1State >= 3) && (globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && + if ((gSaveContext.timer1State >= 3) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && !(player->stateFlags2 & PLAYER_STATE2_24) && - (globalCtx->transitionTrigger == TRANS_TRIGGER_OFF) && (globalCtx->transitionMode == TRANS_MODE_OFF) && - !Play_InCsMode(globalCtx)) {} + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->transitionMode == TRANS_MODE_OFF) && + !Play_InCsMode(play)) {} if (gSaveContext.rupeeAccumulator != 0) { if (gSaveContext.rupeeAccumulator > 0) { @@ -4078,10 +4076,9 @@ void Interface_Update(GlobalContext* globalCtx) { WREG(7) = interfaceCtx->unk_1F4; - if ((globalCtx->pauseCtx.state == 0) && (globalCtx->pauseCtx.debugState == 0) && - (msgCtx->msgMode == MSGMODE_NONE) && (globalCtx->transitionTrigger == TRANS_TRIGGER_OFF) && - (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE) && (globalCtx->transitionMode == TRANS_MODE_OFF) && - ((globalCtx->csCtx.state == CS_STATE_IDLE) || !Player_InCsMode(globalCtx))) { + if ((play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) && (msgCtx->msgMode == MSGMODE_NONE) && + (play->transitionTrigger == TRANS_TRIGGER_OFF) && (play->gameOverCtx.state == GAMEOVER_INACTIVE) && + (play->transitionMode == TRANS_MODE_OFF) && ((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; @@ -4094,7 +4091,7 @@ void Interface_Update(GlobalContext* globalCtx) { osSyncPrintf(VT_RST); } - Interface_UpdateMagicBar(globalCtx); + Interface_UpdateMagicBar(play); } if (gSaveContext.timer1State == 0) { @@ -4148,11 +4145,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.sceneTimeSpeed != 0) { + if (play->envCtx.sceneTimeSpeed != 0) { if (gSaveContext.sunsSongState != SUNSSONG_SPEED_TIME) { D_80125B60 = false; if ((gSaveContext.dayTime >= CLOCK_TIME(6, 30)) && (gSaveContext.dayTime <= CLOCK_TIME(18, 0) + 1)) { @@ -4166,35 +4163,35 @@ void Interface_Update(GlobalContext* globalCtx) { if ((gSaveContext.dayTime >= CLOCK_TIME(6, 30)) && (gSaveContext.dayTime <= CLOCK_TIME(18, 0) + 1)) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gTimeSpeed = sPrevTimeSpeed; - globalCtx->msgCtx.ocarinaMode = OCARINA_MODE_04; + play->msgCtx.ocarinaMode = OCARINA_MODE_04; } } else if (gSaveContext.dayTime > CLOCK_TIME(18, 0) + 1) { gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gTimeSpeed = sPrevTimeSpeed; - 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 >= CLOCK_TIME(6, 30)) && (gSaveContext.dayTime < CLOCK_TIME(18, 0) + 1)) { gSaveContext.nextDayTime = NEXT_TIME_NIGHT; - globalCtx->transitionType = TRANS_TYPE_FADE_BLACK_FAST; + play->transitionType = TRANS_TYPE_FADE_BLACK_FAST; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_BLACK; - globalCtx->unk_11DE9 = true; + play->unk_11DE9 = true; } else { gSaveContext.nextDayTime = NEXT_TIME_DAY; - globalCtx->transitionType = TRANS_TYPE_FADE_WHITE_FAST; + play->transitionType = TRANS_TYPE_FADE_WHITE_FAST; gSaveContext.nextTransitionType = TRANS_TYPE_FADE_WHITE; - globalCtx->unk_11DE9 = true; + play->unk_11DE9 = true; } - if (globalCtx->sceneNum == SCENE_SPOT13) { - globalCtx->transitionType = TRANS_TYPE_SANDSTORM_PERSIST; + if (play->sceneNum == SCENE_SPOT13) { + play->transitionType = TRANS_TYPE_SANDSTORM_PERSIST; gSaveContext.nextTransitionType = TRANS_TYPE_SANDSTORM_PERSIST; } gSaveContext.respawnFlag = -2; - globalCtx->nextEntranceIndex = gSaveContext.entranceIndex; - globalCtx->transitionTrigger = TRANS_TRIGGER_START; + play->nextEntranceIndex = gSaveContext.entranceIndex; + play->transitionTrigger = TRANS_TRIGGER_START; gSaveContext.sunsSongState = SUNSSONG_INACTIVE; func_800F6964(30); gSaveContext.seqId = (u8)NA_BGM_DISABLED; diff --git a/src/code/z_path.c b/src/code/z_path.c index 1c2f94d90..db3c8af4d 100644 --- a/src/code/z_path.c +++ b/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/src/code/z_play.c b/src/code/z_play.c index f841cd4c1..706b12a32 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -13,13 +13,13 @@ FaultClient D_801614B8; s16 sTransitionFillTimer; u64 D_801614D0[0xA00]; -void Play_SpawnScene(GlobalContext* this, s32 sceneNum, s32 spawn); +void Play_SpawnScene(PlayState* this, s32 sceneNum, s32 spawn); -void func_800BC450(GlobalContext* this) { +void func_800BC450(PlayState* this) { Camera_ChangeDataIdx(GET_ACTIVE_CAM(this), this->unk_1242B - 1); } -void func_800BC490(GlobalContext* this, s16 point) { +void func_800BC490(PlayState* this, s16 point) { ASSERT(point == 1 || point == 2, "point == 1 || point == 2", "../z_play.c", 2160); this->unk_1242B = point; @@ -32,12 +32,12 @@ void func_800BC490(GlobalContext* this, s16 point) { func_800BC450(this); } -s32 func_800BC56C(GlobalContext* this, s16 arg1) { +s32 func_800BC56C(PlayState* this, s16 arg1) { return (arg1 == this->unk_1242B); } // original name: "Game_play_shop_pr_vr_switch_set" -void func_800BC590(GlobalContext* this) { +void func_800BC590(PlayState* this) { osSyncPrintf("Game_play_shop_pr_vr_switch_set()\n"); if (YREG(15) == 0x10) { @@ -45,7 +45,7 @@ void func_800BC590(GlobalContext* this) { } } -void Play_SetupTransition(GlobalContext* this, s32 transitionType) { +void Play_SetupTransition(PlayState* this, s32 transitionType) { TransitionContext* transitionCtx = &this->transitionCtx; bzero(transitionCtx, sizeof(TransitionContext)); @@ -143,17 +143,17 @@ void Play_SetupTransition(GlobalContext* this, s32 transitionType) { } } -void func_800BC88C(GlobalContext* this) { +void func_800BC88C(PlayState* this) { this->transitionCtx.transitionType = -1; } -Gfx* Play_SetFog(GlobalContext* this, Gfx* gfx) { +Gfx* Play_SetFog(PlayState* this, Gfx* gfx) { return Gfx_SetFog2(gfx, this->lightCtx.fogColor[0], this->lightCtx.fogColor[1], this->lightCtx.fogColor[2], 0, this->lightCtx.fogNear, 1000); } void Play_Destroy(GameState* thisx) { - GlobalContext* this = (GlobalContext*)thisx; + PlayState* this = (PlayState*)thisx; Player* player = GET_PLAYER(this); this->state.gfxCtx->callback = NULL; @@ -195,7 +195,7 @@ void Play_Destroy(GameState* thisx) { } void Play_Init(GameState* thisx) { - GlobalContext* this = (GlobalContext*)thisx; + PlayState* this = (PlayState*)thisx; GraphicsContext* gfxCtx = this->state.gfxCtx; u32 zAlloc; u32 zAllocAligned; @@ -418,7 +418,7 @@ void Play_Init(GameState* thisx) { } } -void Play_Update(GlobalContext* this) { +void Play_Update(PlayState* this) { s32 pad1; s32 sp80; Input* input; @@ -603,7 +603,7 @@ void Play_Update(GlobalContext* this) { this->state.running = false; if (gSaveContext.gameMode != 2) { - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); gSaveContext.entranceIndex = this->nextEntranceIndex; if (gSaveContext.minigameState == 1) { @@ -654,7 +654,7 @@ void Play_Update(GlobalContext* this) { if (sTransitionFillTimer >= 20) { this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); gSaveContext.entranceIndex = this->nextEntranceIndex; this->transitionTrigger = TRANS_TRIGGER_OFF; this->transitionMode = TRANS_MODE_OFF; @@ -696,7 +696,7 @@ void Play_Update(GlobalContext* this) { case TRANS_MODE_INSTANT: if (this->transitionTrigger != TRANS_TRIGGER_END) { this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); gSaveContext.entranceIndex = this->nextEntranceIndex; this->transitionTrigger = TRANS_TRIGGER_OFF; this->transitionMode = TRANS_MODE_OFF; @@ -742,7 +742,7 @@ void Play_Update(GlobalContext* this) { } else { if (this->envCtx.sandstormEnvA == 255) { this->state.running = false; - SET_NEXT_GAMESTATE(&this->state, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); gSaveContext.entranceIndex = this->nextEntranceIndex; this->transitionTrigger = TRANS_TRIGGER_OFF; this->transitionMode = TRANS_MODE_OFF; @@ -1073,7 +1073,7 @@ skip: this->state.gfxCtx); } -void Play_DrawOverlayElements(GlobalContext* this) { +void Play_DrawOverlayElements(PlayState* this) { if ((this->pauseCtx.state != 0) || (this->pauseCtx.debugState != 0)) { KaleidoScopeCall_Draw(this); } @@ -1089,7 +1089,7 @@ void Play_DrawOverlayElements(GlobalContext* this) { } } -void Play_Draw(GlobalContext* this) { +void Play_Draw(PlayState* this) { GraphicsContext* gfxCtx = this->state.gfxCtx; Lights* sp228; Vec3f sp21C; @@ -1346,7 +1346,7 @@ void Play_Draw(GlobalContext* this) { } void Play_Main(GameState* thisx) { - GlobalContext* this = (GlobalContext*)thisx; + PlayState* this = (PlayState*)thisx; D_8012D1F8 = &this->state.input[0]; @@ -1389,11 +1389,11 @@ void Play_Main(GameState* thisx) { } // original name: "Game_play_demo_mode_check" -s32 Play_InCsMode(GlobalContext* this) { +s32 Play_InCsMode(PlayState* this) { return (this->csCtx.state != CS_STATE_IDLE) || Player_InCsMode(this); } -f32 func_800BFCB8(GlobalContext* this, MtxF* mf, Vec3f* vec) { +f32 func_800BFCB8(PlayState* this, MtxF* mf, Vec3f* vec) { CollisionPoly poly; f32 temp1; f32 temp2; @@ -1459,7 +1459,7 @@ f32 func_800BFCB8(GlobalContext* this, MtxF* mf, Vec3f* vec) { return floorY; } -void* Play_LoadFile(GlobalContext* this, RomFile* file) { +void* Play_LoadFile(PlayState* this, RomFile* file) { u32 size; void* allocp; @@ -1470,12 +1470,12 @@ void* Play_LoadFile(GlobalContext* this, RomFile* file) { return allocp; } -void Play_InitEnvironment(GlobalContext* this, s16 skyboxId) { +void Play_InitEnvironment(PlayState* this, s16 skyboxId) { Skybox_Init(&this->state, &this->skyboxCtx, skyboxId); Environment_Init(this, &this->envCtx, 0); } -void Play_InitScene(GlobalContext* this, s32 spawn) { +void Play_InitScene(PlayState* this, s32 spawn) { this->curSpawn = spawn; this->linkActorEntry = NULL; this->unk_11DFC = NULL; @@ -1494,7 +1494,7 @@ void Play_InitScene(GlobalContext* this, s32 spawn) { Play_InitEnvironment(this, this->skyboxId); } -void Play_SpawnScene(GlobalContext* this, s32 sceneNum, s32 spawn) { +void Play_SpawnScene(PlayState* this, s32 sceneNum, s32 spawn) { SceneTableEntry* scene = &gSceneTable[sceneNum]; scene->unk_13 = 0; @@ -1515,7 +1515,7 @@ void Play_SpawnScene(GlobalContext* this, s32 sceneNum, s32 spawn) { osSyncPrintf("ROOM SIZE=%fK\n", func_80096FE8(this, &this->roomCtx) / 1024.0f); } -void Play_GetScreenPos(GlobalContext* this, Vec3f* src, Vec3f* dest) { +void Play_GetScreenPos(PlayState* this, Vec3f* src, Vec3f* dest) { f32 w; Matrix_Mult(&this->viewProjectionMtxF, MTXMODE_NEW); @@ -1528,7 +1528,7 @@ void Play_GetScreenPos(GlobalContext* this, Vec3f* src, Vec3f* dest) { dest->y = (SCREEN_HEIGHT / 2) - ((dest->y / w) * (SCREEN_HEIGHT / 2)); } -s16 Play_CreateSubCamera(GlobalContext* this) { +s16 Play_CreateSubCamera(PlayState* this) { s16 i; for (i = CAM_ID_SUB_FIRST; i < NUM_CAMS; i++) { @@ -1553,11 +1553,11 @@ s16 Play_CreateSubCamera(GlobalContext* this) { return i; } -s16 Play_GetActiveCamId(GlobalContext* this) { +s16 Play_GetActiveCamId(PlayState* this) { return this->activeCamId; } -s16 Play_ChangeCameraStatus(GlobalContext* this, s16 camId, s16 status) { +s16 Play_ChangeCameraStatus(PlayState* this, s16 camId, s16 status) { s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; if (status == CAM_STAT_ACTIVE) { @@ -1567,7 +1567,7 @@ s16 Play_ChangeCameraStatus(GlobalContext* this, s16 camId, s16 status) { return Camera_ChangeStatus(this->cameraPtrs[camIdx], status); } -void Play_ClearCamera(GlobalContext* this, s16 camId) { +void Play_ClearCamera(PlayState* this, s16 camId) { s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; if (camIdx == CAM_ID_MAIN) { @@ -1585,7 +1585,7 @@ void Play_ClearCamera(GlobalContext* this, s16 camId) { } } -void Play_ClearAllSubCameras(GlobalContext* this) { +void Play_ClearAllSubCameras(PlayState* this) { s16 subCamId; for (subCamId = CAM_ID_SUB_FIRST; subCamId < NUM_CAMS; subCamId++) { @@ -1597,13 +1597,13 @@ void Play_ClearAllSubCameras(GlobalContext* this) { this->activeCamId = CAM_ID_MAIN; } -Camera* Play_GetCamera(GlobalContext* this, s16 camId) { +Camera* Play_GetCamera(PlayState* this, s16 camId) { s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; return this->cameraPtrs[camIdx]; } -s32 Play_CameraSetAtEye(GlobalContext* this, s16 camId, Vec3f* at, Vec3f* eye) { +s32 Play_CameraSetAtEye(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye) { s32 ret = 0; s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; Camera* camera = this->cameraPtrs[camIdx]; @@ -1629,7 +1629,7 @@ s32 Play_CameraSetAtEye(GlobalContext* this, s16 camId, Vec3f* at, Vec3f* eye) { return ret; } -s32 Play_CameraSetAtEyeUp(GlobalContext* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up) { +s32 Play_CameraSetAtEyeUp(PlayState* this, s16 camId, Vec3f* at, Vec3f* eye, Vec3f* up) { s32 ret = 0; s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; Camera* camera = this->cameraPtrs[camIdx]; @@ -1657,14 +1657,14 @@ s32 Play_CameraSetAtEyeUp(GlobalContext* this, s16 camId, Vec3f* at, Vec3f* eye, return ret; } -s32 Play_CameraSetFov(GlobalContext* this, s16 camId, f32 fov) { +s32 Play_CameraSetFov(PlayState* this, s16 camId, f32 fov) { s32 ret = Camera_SetParam(this->cameraPtrs[camId], 0x20, &fov) & 1; if (1) {} return ret; } -s32 Play_SetCameraRoll(GlobalContext* this, s16 camId, s16 roll) { +s32 Play_SetCameraRoll(PlayState* this, s16 camId, s16 roll) { s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; Camera* camera = this->cameraPtrs[camIdx]; @@ -1673,14 +1673,14 @@ s32 Play_SetCameraRoll(GlobalContext* this, s16 camId, s16 roll) { return 1; } -void Play_CopyCamera(GlobalContext* this, s16 destCamId, s16 srcCamId) { +void Play_CopyCamera(PlayState* this, s16 destCamId, s16 srcCamId) { s16 srcCamId2 = (srcCamId == CAM_ID_NONE) ? this->activeCamId : srcCamId; s16 destCamId1 = (destCamId == CAM_ID_NONE) ? this->activeCamId : destCamId; Camera_Copy(this->cameraPtrs[destCamId1], this->cameraPtrs[srcCamId2]); } -s32 func_800C0808(GlobalContext* this, s16 camId, Player* player, s16 setting) { +s32 func_800C0808(PlayState* this, s16 camId, Player* player, s16 setting) { Camera* camera; s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; @@ -1689,11 +1689,11 @@ s32 func_800C0808(GlobalContext* this, s16 camId, Player* player, s16 setting) { return Camera_ChangeSetting(camera, setting); } -s32 Play_CameraChangeSetting(GlobalContext* this, s16 camId, s16 setting) { +s32 Play_CameraChangeSetting(PlayState* this, s16 camId, s16 setting) { return Camera_ChangeSetting(Play_GetCamera(this, camId), setting); } -void func_800C08AC(GlobalContext* this, s16 camId, s16 arg2) { +void func_800C08AC(PlayState* this, s16 camId, s16 arg2) { s16 camIdx = (camId == CAM_ID_NONE) ? this->activeCamId : camId; s16 i; @@ -1716,7 +1716,7 @@ void func_800C08AC(GlobalContext* this, s16 camId, s16 arg2) { } } -s16 Play_CameraGetUID(GlobalContext* this, s16 camId) { +s16 Play_CameraGetUID(PlayState* this, s16 camId) { Camera* camera = this->cameraPtrs[camId]; if (camera != NULL) { @@ -1726,7 +1726,7 @@ s16 Play_CameraGetUID(GlobalContext* this, s16 camId) { } } -s16 func_800C09D8(GlobalContext* this, s16 camId, s16 arg2) { +s16 func_800C09D8(PlayState* this, s16 camId, s16 arg2) { Camera* camera = this->cameraPtrs[camId]; if (camera != NULL) { @@ -1740,7 +1740,7 @@ s16 func_800C09D8(GlobalContext* this, s16 camId, s16 arg2) { } } -void Play_SaveSceneFlags(GlobalContext* this) { +void Play_SaveSceneFlags(PlayState* this) { SavedSceneFlags* savedSceneFlags = &gSaveContext.sceneFlags[this->sceneNum]; savedSceneFlags->chest = this->actorCtx.flags.chest; @@ -1749,7 +1749,7 @@ void Play_SaveSceneFlags(GlobalContext* this) { savedSceneFlags->collect = this->actorCtx.flags.collect; } -void Play_SetRespawnData(GlobalContext* this, s32 respawnMode, s16 entranceIndex, s32 roomIndex, s32 playerParams, +void Play_SetRespawnData(PlayState* this, s32 respawnMode, s16 entranceIndex, s32 roomIndex, s32 playerParams, Vec3f* pos, s16 yaw) { RespawnData* respawnData = &gSaveContext.respawn[respawnMode]; @@ -1762,7 +1762,7 @@ void Play_SetRespawnData(GlobalContext* this, s32 respawnMode, s16 entranceIndex respawnData->tempCollectFlags = this->actorCtx.flags.tempCollect; } -void Play_SetupRespawnPoint(GlobalContext* this, s32 respawnMode, s32 playerParams) { +void Play_SetupRespawnPoint(PlayState* this, s32 respawnMode, s32 playerParams) { Player* player = GET_PLAYER(this); s32 entranceIndex; s8 roomIndex; @@ -1775,7 +1775,7 @@ void Play_SetupRespawnPoint(GlobalContext* this, s32 respawnMode, s32 playerPara } } -void Play_TriggerVoidOut(GlobalContext* this) { +void Play_TriggerVoidOut(PlayState* this) { gSaveContext.respawn[RESPAWN_MODE_DOWN].tempSwchFlags = this->actorCtx.flags.tempSwch; gSaveContext.respawn[RESPAWN_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.tempCollect; gSaveContext.respawnFlag = 1; @@ -1784,7 +1784,7 @@ void Play_TriggerVoidOut(GlobalContext* this) { this->transitionType = TRANS_TYPE_FADE_BLACK; } -void Play_LoadToLastEntrance(GlobalContext* this) { +void Play_LoadToLastEntrance(PlayState* this) { gSaveContext.respawnFlag = -1; this->transitionTrigger = TRANS_TRIGGER_START; @@ -1802,21 +1802,21 @@ void Play_LoadToLastEntrance(GlobalContext* this) { this->transitionType = TRANS_TYPE_FADE_BLACK; } -void Play_TriggerRespawn(GlobalContext* this) { +void Play_TriggerRespawn(PlayState* this) { Play_SetupRespawnPoint(this, RESPAWN_MODE_DOWN, 0xDFF); Play_LoadToLastEntrance(this); } -s32 func_800C0CB8(GlobalContext* this) { +s32 func_800C0CB8(PlayState* this) { return (this->roomCtx.curRoom.meshHeader->base.type != 1) && (YREG(15) != 0x20) && (YREG(15) != 0x30) && (YREG(15) != 0x40) && (this->sceneNum != SCENE_HAIRAL_NIWA); } -s32 FrameAdvance_IsEnabled(GlobalContext* this) { +s32 FrameAdvance_IsEnabled(PlayState* this) { return !!this->frameAdvCtx.enabled; } -s32 func_800C0D34(GlobalContext* this, Actor* actor, s16* yaw) { +s32 func_800C0D34(PlayState* this, Actor* actor, s16* yaw) { TransitionActorEntry* transitionActor; s32 frontRoom; @@ -1840,7 +1840,7 @@ s32 func_800C0D34(GlobalContext* this, Actor* actor, s16* yaw) { return 1; } -s32 func_800C0DB4(GlobalContext* this, Vec3f* pos) { +s32 func_800C0DB4(PlayState* this, Vec3f* pos) { WaterBox* waterBox; CollisionPoly* poly; Vec3f waterSurfacePos; diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c index 0663dc6ae..ea9a4be3e 100644 --- a/src/code/z_player_call.c +++ b/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, @@ -36,23 +36,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/src/code/z_player_lib.c b/src/code/z_player_lib.c index 6f15c1c07..b71c89ccc 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -435,7 +435,7 @@ Vec3f sGetItemRefPos; s32 sLeftHandType; s32 sRightHandType; -void Player_SetBootData(GlobalContext* globalCtx, Player* this) { +void Player_SetBootData(PlayState* play, Player* this) { s32 currentBoots; s16* bootRegs; @@ -474,22 +474,22 @@ 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) { +s32 Player_InBlockingCsMode(PlayState* play, Player* this) { return (this->stateFlags1 & (PLAYER_STATE1_7 | PLAYER_STATE1_29)) || (this->csMode != 0) || - (globalCtx->transitionTrigger == TRANS_TRIGGER_START) || (this->stateFlags1 & PLAYER_STATE1_0) || + (play->transitionTrigger == TRANS_TRIGGER_START) || (this->stateFlags1 & PLAYER_STATE1_0) || (this->stateFlags3 & PLAYER_STATE3_7) || ((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) { @@ -568,19 +568,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 = SHIELD_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_SHIELD)); this->currentTunic = TUNIC_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_TUNIC)); this->currentBoots = BOOTS_EQUIP_TO_PLAYER(CUR_EQUIP_VALUE(EQUIP_TYPE_BOOTS)); this->currentSwordItemId = 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; @@ -609,30 +609,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 |= PLAYER_STATE1_16; - Camera_SetParam(Play_GetCamera(globalCtx, CAM_ID_MAIN), 8, actor); - Camera_ChangeMode(Play_GetCamera(globalCtx, CAM_ID_MAIN), CAM_MODE_FOLLOWTARGET); + Camera_SetParam(Play_GetCamera(play, CAM_ID_MAIN), 8, actor); + Camera_ChangeMode(Play_GetCamera(play, CAM_ID_MAIN), CAM_MODE_FOLLOWTARGET); } -s32 func_8008EF30(GlobalContext* globalCtx) { - Player* this = GET_PLAYER(globalCtx); +s32 func_8008EF30(PlayState* play) { + Player* this = GET_PLAYER(play); return (this->stateFlags1 & PLAYER_STATE1_23); } -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; @@ -656,28 +656,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 == PLAYER_MODELTYPE_RH_SHIELD) && (this->currentShield == PLAYER_SHIELD_MIRROR); } @@ -770,12 +770,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 @@ -787,7 +787,7 @@ 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 (0) {} @@ -796,7 +796,7 @@ s32 func_8008F2F8(GlobalContext* globalCtx) { (((var == 0) && (this->currentTunic != PLAYER_TUNIC_GORON)) || (((var == 1) || (var == 3)) && (this->currentBoots == PLAYER_BOOTS_IRON) && (this->currentTunic != PLAYER_TUNIC_ZORA)))) { - Message_StartTextbox(globalCtx, triggerEntry->textId, NULL); + Message_StartTextbox(play, triggerEntry->textId, NULL); gSaveContext.textTriggerFlags |= triggerEntry->flag; } } @@ -858,14 +858,13 @@ Gfx* sBootDListGroups[][2] = { { gLinkAdultLeftHoverBootDL, gLinkAdultRightHoverBootDL }, // PLAYER_BOOTS_HOVER }; -void Player_DrawImpl(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount, s32 lod, s32 tunic, - s32 boots, s32 face, OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, - void* data) { +void Player_DrawImpl(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, "../z_player_lib.c", 1721); + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 1721); if (eyeIndex < 0) { eyeIndex = sEyeMouthIndices[face][0]; @@ -892,7 +891,7 @@ void Player_DrawImpl(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTabl 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 != Player_OverrideLimbDrawGameplayFirstPerson) && (overrideLimbDraw != Player_OverrideLimbDrawGameplay_80090440) && (gSaveContext.gameMode != 3)) { @@ -928,7 +927,7 @@ void Player_DrawImpl(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTabl } } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 1803); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 1803); } Vec3f sZeroVec = { 0.0f, 0.0f, 0.0f }; @@ -945,8 +944,8 @@ 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, - s32 thighLimbIndex, s32 shinLimbIndex, s32 footLimbIndex) { +void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, s32 thighLimbIndex, + s32 shinLimbIndex, s32 footLimbIndex) { Vec3f spA4; Vec3f sp98; Vec3f footprintPos; @@ -988,7 +987,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; @@ -1028,17 +1027,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 Player_OverrideLimbDrawGameplayCommon(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; @@ -1097,10 +1096,10 @@ s32 Player_OverrideLimbDrawGameplayCommon(GlobalContext* globalCtx, s32 limbInde Matrix_RotateZ(BINANG_TO_RAD(this->unk_6C0), 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 { @@ -1111,11 +1110,11 @@ s32 Player_OverrideLimbDrawGameplayCommon(GlobalContext* globalCtx, s32 limbInde return false; } -s32 Player_OverrideLimbDrawGameplayDefault(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, +s32 Player_OverrideLimbDrawGameplayDefault(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; - if (!Player_OverrideLimbDrawGameplayCommon(globalCtx, limbIndex, dList, pos, rot, thisx)) { + if (!Player_OverrideLimbDrawGameplayCommon(play, limbIndex, dList, pos, rot, thisx)) { if (limbIndex == PLAYER_LIMB_L_HAND) { Gfx** dLists = this->leftHandDLists; @@ -1168,11 +1167,11 @@ s32 Player_OverrideLimbDrawGameplayDefault(GlobalContext* globalCtx, s32 limbInd return false; } -s32 Player_OverrideLimbDrawGameplayFirstPerson(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, void* thisx) { +s32 Player_OverrideLimbDrawGameplayFirstPerson(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { Player* this = (Player*)thisx; - if (!Player_OverrideLimbDrawGameplayCommon(globalCtx, limbIndex, dList, pos, rot, thisx)) { + if (!Player_OverrideLimbDrawGameplayCommon(play, limbIndex, dList, pos, rot, thisx)) { if (this->unk_6AD != 2) { *dList = NULL; } else if (limbIndex == PLAYER_LIMB_L_FOREARM) { @@ -1194,20 +1193,19 @@ s32 Player_OverrideLimbDrawGameplayFirstPerson(GlobalContext* globalCtx, s32 lim return false; } -s32 Player_OverrideLimbDrawGameplay_80090440(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, - Vec3s* rot, void* thisx) { - if (!Player_OverrideLimbDrawGameplayCommon(globalCtx, limbIndex, dList, pos, rot, thisx)) { +s32 Player_OverrideLimbDrawGameplay_80090440(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, + void* thisx) { + if (!Player_OverrideLimbDrawGameplayCommon(play, limbIndex, dList, pos, rot, thisx)) { *dList = NULL; } return false; } -u8 func_80090480(GlobalContext* globalCtx, ColliderQuad* collider, WeaponInfo* weaponInfo, Vec3f* newTip, - Vec3f* newBase) { +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); @@ -1217,13 +1215,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); @@ -1232,7 +1230,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, @@ -1251,8 +1249,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); } } @@ -1266,14 +1264,14 @@ 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->meleeWeaponInfo[0], &newTipPos[0], &newBasePos[0]) && + if (func_80090480(play, NULL, &this->meleeWeaponInfo[0], &newTipPos[0], &newBasePos[0]) && !(this->stateFlags1 & PLAYER_STATE1_22)) { EffectBlure_AddVertex(Effect_GetByIndex(this->meleeWeaponEffectIndex), &this->meleeWeaponInfo[0].tip, &this->meleeWeaponInfo[0].base); @@ -1281,15 +1279,15 @@ void func_800906D4(GlobalContext* globalCtx, Player* this, Vec3f* newTipPos) { if ((this->meleeWeaponState > 0) && ((this->meleeWeaponAnimation < PLAYER_MWA_SPIN_ATTACK_1H) || (this->stateFlags2 & PLAYER_STATE2_17))) { - func_80090480(globalCtx, &this->meleeWeaponQuads[0], &this->meleeWeaponInfo[1], &newTipPos[1], &newBasePos[1]); - func_80090480(globalCtx, &this->meleeWeaponQuads[1], &this->meleeWeaponInfo[2], &newTipPos[2], &newBasePos[2]); + func_80090480(play, &this->meleeWeaponQuads[0], &this->meleeWeaponInfo[1], &newTipPos[1], &newBasePos[1]); + func_80090480(play, &this->meleeWeaponQuads[1], &this->meleeWeaponInfo[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, "../z_player_lib.c", 2401); + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2401); gSegments[6] = VIRTUAL_TO_PHYSICAL(this->giObjectSegment); @@ -1298,18 +1296,18 @@ 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); - GetItem_Draw(globalCtx, drawIdPlusOne - 1); + GetItem_Draw(play, drawIdPlusOne - 1); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2421); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2421); } -void Player_DrawGetItem(GlobalContext* globalCtx, Player* this) { +void Player_DrawGetItem(PlayState* play, Player* this) { if (!this->giObjectLoading || osRecvMesg(&this->giObjectLoadQueue, NULL, OS_MESG_NOBLOCK) == 0) { this->giObjectLoading = false; - Player_DrawGetItemImpl(globalCtx, this, &sGetItemRefPos, ABS(this->unk_862)); + Player_DrawGetItemImpl(play, this, &sGetItemRefPos, ABS(this->unk_862)); } } @@ -1329,7 +1327,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; @@ -1347,24 +1345,24 @@ void Player_DrawHookshotReticle(GlobalContext* globalCtx, Player* this, f32 arg2 if (1) {} - if (BgCheck_AnyLineTest3(&globalCtx->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &bgId)) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2572); + if (BgCheck_AnyLineTest3(&play->colCtx, &sp8C, &sp80, &sp74, &sp9C, 1, 1, 1, 1, &bgId)) { + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2572); OVERLAY_DISP = Gfx_CallSetupDL(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(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2587), + gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_player_lib.c", 2587), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - gSPSegment(OVERLAY_DISP++, 0x06, globalCtx->objectCtx.status[this->actor.objBankIndex].segment); + gSPSegment(OVERLAY_DISP++, 0x06, play->objectCtx.status[this->actor.objBankIndex].segment); gSPDisplayList(OVERLAY_DISP++, gLinkAdultHookshotReticleDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2592); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2592); } } @@ -1414,7 +1412,7 @@ Vec3f D_801261E0[] = { { 200.0f, 200.0f, 0.0f }, }; -void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { +void Player_PostLimbDrawGameplay(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, void* thisx) { Player* this = (Player*)thisx; if (*dList != NULL) { @@ -1430,13 +1428,13 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** if (this->itemActionParam == PLAYER_AP_STICK) { Vec3f sp124[3]; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2633); + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2633); if (this->actor.scale.y >= 0.0f) { D_80126080.x = this->unk_85C * 5000.0f; func_80090A28(this, sp124); if (this->meleeWeaponState != 0) { - func_800906D4(globalCtx, this, sp124); + func_800906D4(play, this, sp124); } else { Math_Vec3f_Copy(&this->meleeWeaponInfo[0].tip, &sp124[0]); } @@ -1446,11 +1444,11 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** 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, "../z_player_lib.c", 2653), + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_player_lib.c", 2653), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_OPA_DISP++, gLinkChildLinkDekuStickDL); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2656); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2656); } else if ((this->actor.scale.y >= 0.0f) && (this->meleeWeaponState != 0)) { Vec3f spE4[3]; @@ -1461,18 +1459,18 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** } func_80090A28(this, spE4); - func_800906D4(globalCtx, this, spE4); + func_800906D4(play, this, spE4); } else if ((*dList != NULL) && (this->leftHandType == PLAYER_MODELTYPE_LH_BOTTLE)) { Color_RGB8* bottleColor = &sBottleColors[Player_ActionToBottle(this, this->itemActionParam)]; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2710); + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2710); - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2712), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_player_lib.c", 2712), 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[((void)0, gSaveContext.linkAge)]); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2717); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2717); } if (this->actor.scale.y >= 0.0f) { @@ -1509,7 +1507,7 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** (this->rightHandType == PLAYER_MODELTYPE_12)) { BowStringData* stringData = &sBowStringData[gSaveContext.linkAge]; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2783); + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2783); Matrix_Push(); Matrix_Translate(stringData->pos.x, stringData->pos.y, stringData->pos.z, MTXMODE_APPLY); @@ -1540,16 +1538,16 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** Matrix_RotateZ(this->unk_858 * -0.2f, MTXMODE_APPLY); } - gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_player_lib.c", 2804), + gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_player_lib.c", 2804), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); gSPDisplayList(POLY_XLU_DISP++, stringData->dList); Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 2809); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 2809); } else if ((this->actor.scale.y >= 0.0f) && (this->rightHandType == PLAYER_MODELTYPE_RH_SHIELD)) { 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) { @@ -1570,7 +1568,7 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** 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); } } } @@ -1595,7 +1593,7 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** if ((this->rightHandType != PLAYER_MODELTYPE_RH_SHIELD) && (this->rightHandType != PLAYER_MODELTYPE_RH_FF)) { 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); @@ -1611,7 +1609,7 @@ void Player_PostLimbDrawGameplay(GlobalContext* globalCtx, s32 limbIndex, Gfx** } } -u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { +u32 func_80091738(PlayState* play, u8* segment, SkelAnime* skelAnime) { s16 linkObjectId = gLinkObjectIds[(void)0, gSaveContext.linkAge]; u32 size; void* ptr; @@ -1630,8 +1628,8 @@ u32 func_80091738(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime) { gSegments[6] = VIRTUAL_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE); - SkelAnime_InitLink(globalCtx, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.linkAge], &gPlayerAnim_003238, 9, - ptr, ptr, PLAYER_LIMB_MAX); + SkelAnime_InitLink(play, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.linkAge], &gPlayerAnim_003238, 9, ptr, + ptr, PLAYER_LIMB_MAX); return size + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + sizeof(Vec3s[PLAYER_LIMB_BUF_COUNT]); @@ -1643,8 +1641,7 @@ u8 D_801261F8[] = { PLAYER_MODELGROUP_BGS, // PLAYER_SWORD_BGS }; -s32 Player_OverrideLimbDrawPause(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, - void* arg) { +s32 Player_OverrideLimbDrawPause(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* arg) { u8* playerSwordAndShield = arg; //! @bug `playerSwordAndShield[0]` can be 0 (`PLAYER_SWORD_NONE`), which indexes `D_801261F8[-1]`. The result //! happens to be 0 (`PLAYER_MODELGROUP_0`) in vanilla, but weird values are likely to cause a crash @@ -1687,9 +1684,9 @@ s32 Player_OverrideLimbDrawPause(GlobalContext* globalCtx, s32 limbIndex, Gfx** return 0; } -void Player_DrawPauseImpl(GlobalContext* globalCtx, void* gameplayKeep, void* linkObject, 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* colorFrameBuffer, void* depthFrameBuffer) { +void Player_DrawPauseImpl(PlayState* play, void* gameplayKeep, void* linkObject, 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* colorFrameBuffer, void* depthFrameBuffer) { // Note: the viewport x and y values are overwritten below, before usage static Vp viewport = { (PAUSE_EQUIP_PLAYER_WIDTH / 2) << 2, (PAUSE_EQUIP_PLAYER_HEIGHT / 2) << 2, G_MAXZ / 2, 0, (PAUSE_EQUIP_PLAYER_WIDTH / 2) << 2, (PAUSE_EQUIP_PLAYER_HEIGHT / 2) << 2, G_MAXZ / 2, 0 }; @@ -1699,10 +1696,10 @@ void Player_DrawPauseImpl(GlobalContext* globalCtx, void* gameplayKeep, void* li Gfx* opaRef; Gfx* xluRef; 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, "../z_player_lib.c", 3129); + OPEN_DISPS(play->state.gfxCtx, "../z_player_lib.c", 3129); { s32 pad[2]; } @@ -1772,15 +1769,15 @@ void Player_DrawPauseImpl(GlobalContext* globalCtx, void* gameplayKeep, void* li 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); - Player_DrawImpl(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, + Player_DrawImpl(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount, 0, tunic, boots, 0, Player_OverrideLimbDrawPause, NULL, &playerSwordAndShield); gSPEndDisplayList(POLY_OPA_DISP++); @@ -1789,11 +1786,11 @@ void Player_DrawPauseImpl(GlobalContext* globalCtx, void* gameplayKeep, void* li gSPBranchList(opaRef, POLY_OPA_DISP); gSPBranchList(xluRef, POLY_XLU_DISP); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_player_lib.c", 3288); + CLOSE_DISPS(play->state.gfxCtx, "../z_player_lib.c", 3288); } -void Player_DrawPause(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, - s32 sword, s32 tunic, s32 shield, s32 boots) { +void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f* pos, Vec3s* rot, f32 scale, s32 sword, + s32 tunic, s32 shield, s32 boots) { static Vec3f eye = { 0.0f, 0.0f, -400.0f }; static Vec3f at = { 0.0f, 0.0f, 0.0f }; Vec3s* destTable; @@ -1826,10 +1823,9 @@ void Player_DrawPause(GlobalContext* globalCtx, u8* segment, SkelAnime* skelAnim *destTable++ = *srcTable++; } - Player_DrawPauseImpl(globalCtx, segment + PAUSE_EQUIP_BUFFER_SIZE, + Player_DrawPauseImpl(play, segment + PAUSE_EQUIP_BUFFER_SIZE, segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE, skelAnime, pos, rot, scale, sword, tunic, shield, boots, PAUSE_EQUIP_PLAYER_WIDTH, - PAUSE_EQUIP_PLAYER_HEIGHT, &eye, &at, 60.0f, globalCtx->state.gfxCtx->curFrameBuffer, - globalCtx->state.gfxCtx->curFrameBuffer + - (PAUSE_EQUIP_PLAYER_WIDTH * PAUSE_EQUIP_PLAYER_HEIGHT)); + PAUSE_EQUIP_PLAYER_HEIGHT, &eye, &at, 60.0f, play->state.gfxCtx->curFrameBuffer, + play->state.gfxCtx->curFrameBuffer + (PAUSE_EQUIP_PLAYER_WIDTH * PAUSE_EQUIP_PLAYER_HEIGHT)); } diff --git a/src/code/z_quake.c b/src/code/z_quake.c index ac9290e09..02fb8e63d 100644 --- a/src/code/z_quake.c +++ b/src/code/z_quake.c @@ -317,9 +317,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; @@ -342,7 +342,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/src/code/z_rcp.c b/src/code/z_rcp.c index 395f5434b..7130768bb 100644 --- a/src/code/z_rcp.c +++ b/src/code/z_rcp.c @@ -1007,12 +1007,12 @@ void func_80093C14(GraphicsContext* gfxCtx) { CLOSE_DISPS(gfxCtx, "../z_rcp.c", 1443); } -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, "../z_rcp.c", 1460); gDPSetColorDither(POLY_OPA_DISP++, G_CD_DISABLE); diff --git a/src/code/z_room.c b/src/code/z_room.c index e2f9292e7..7c97bc43d 100644 --- a/src/code/z_room.c +++ b/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, "../z_room.c", 193); + OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 193); 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, "../z_room.c", 239); + CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 239); } #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,18 +99,18 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { PolygonDlist2* polygonDlistIter; f32 temp_f2; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 287); + OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 287); 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 (1) {} 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); } @@ -125,10 +125,10 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { pos.x = polygonDlist->pos.x; pos.y = polygonDlist->pos.y; pos.z = polygonDlist->pos.z; - SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &pos, &projectedPos, &projectedW); + SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &projectedPos, &projectedW); if (-(f32)polygonDlist->unk_06 < projectedPos.z) { temp_f2 = projectedPos.z - polygonDlist->unk_06; - if (temp_f2 < globalCtx->lightCtx.fogFar) { + if (temp_f2 < play->lightCtx.fogFar) { spA4->unk_00 = polygonDlist; spA4->unk_04 = temp_f2; iter = spB4; @@ -212,7 +212,7 @@ void func_80095D04(GlobalContext* globalCtx, Room* room, u32 flags) { iREG(88) = i - 1; - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 430); + CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 430); } #define JPEG_MARKER 0xFFD8FFE0 @@ -306,7 +306,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* activeCam; Gfx* spA8; PolygonType1* polygon1; @@ -316,9 +316,9 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { u32 drawOpa; u32 drawXlu; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 628); + OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 628); - activeCam = GET_ACTIVE_CAM(globalCtx); + activeCam = GET_ACTIVE_CAM(play); isFixedCamera = (activeCam->setting == CAM_SET_PREREND_FIXED); polygon1 = &room->meshHeader->polygon1; polygonDlist = SEGMENTED_TO_VIRTUAL(polygon1->dlist); @@ -330,7 +330,7 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); if (drawOpa) { - 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); } @@ -355,16 +355,16 @@ void func_80096680(GlobalContext* globalCtx, Room* room, u32 flags) { if (drawXlu) { 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, "../z_room.c", 691); + CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 691); } -BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { - Camera* activeCam = GET_ACTIVE_CAM(globalCtx); +BgImage* func_80096A74(PolygonType1* polygon1, PlayState* play) { + Camera* activeCam = GET_ACTIVE_CAM(play); s32 camDataIdx; s16 camDataIdx2; Player* player; @@ -373,12 +373,12 @@ BgImage* func_80096A74(PolygonType1* polygon1, GlobalContext* globalCtx) { camDataIdx = activeCam->camDataIdx; // jfifid - camDataIdx2 = func_80041C10(&globalCtx->colCtx, camDataIdx, BGCHECK_SCENE)[2].y; + camDataIdx2 = func_80041C10(&play->colCtx, camDataIdx, BGCHECK_SCENE)[2].y; if (camDataIdx2 >= 0) { camDataIdx = camDataIdx2; } - player = GET_PLAYER(globalCtx); + player = GET_PLAYER(play); player->actor.params = (player->actor.params & 0xFF00) | camDataIdx; bgImage = SEGMENTED_TO_VIRTUAL(polygon1->multi.list); @@ -397,7 +397,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* activeCam; Gfx* gfx; PolygonType1* polygon1; @@ -408,13 +408,13 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { u32 drawOpa; u32 drawXlu; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_room.c", 752); + OPEN_DISPS(play->state.gfxCtx, "../z_room.c", 752); - activeCam = GET_ACTIVE_CAM(globalCtx); + activeCam = GET_ACTIVE_CAM(play); isFixedCamera = (activeCam->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); drawBg = (flags & 1) && isFixedCamera && bgImage->source && !(SREG(25) & 1); drawOpa = (flags & 1) && (polygonDlist->opa != NULL) && !(SREG(25) & 2); drawXlu = (flags & 2) && (polygonDlist->xlu != NULL) && !(SREG(25) & 4); @@ -423,7 +423,7 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { gSPSegment(POLY_OPA_DISP++, 0x03, room->segment); if (drawOpa) { - 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); } @@ -449,35 +449,35 @@ void func_80096B6C(GlobalContext* globalCtx, Room* room, u32 flags) { if (drawXlu) { 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, "../z_room.c", 819); + CLOSE_DISPS(play->state.gfxCtx, "../z_room.c", 819); } // 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 { LogUtils_HungupThread("../z_room.c", 841); } } -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; @@ -487,7 +487,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) { @@ -495,13 +495,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, "../z_room.c", 912); + LOG_NUM("game_play->room_rom_address.num", play->numRooms, "../z_room.c", 912); - 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; @@ -520,7 +520,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(&globalCtx->state, maxRoomSize, "../z_room.c", 946); + roomCtx->bufPtrs[0] = GameState_Alloc(&play->state, maxRoomSize, "../z_room.c", 946); // "Room buffer initial pointer=%08x" osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]); roomCtx->bufPtrs[1] = (void*)((s32)roomCtx->bufPtrs[0] + maxRoomSize); @@ -531,13 +531,13 @@ 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) { u32 size; if (roomCtx->status == 0) { @@ -546,13 +546,13 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { roomCtx->curRoom.segment = NULL; roomCtx->status = 1; - ASSERT(roomNum < globalCtx->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); + ASSERT(roomNum < play->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); - size = globalCtx->roomList[roomNum].vromEnd - globalCtx->roomList[roomNum].vromStart; + size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; roomCtx->unk_34 = (void*)ALIGN16((u32)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, NULL, "../z_room.c", 1036); roomCtx->unk_30 ^= 1; @@ -562,16 +562,16 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum) { return 0; } -s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx) { +s32 func_800973FC(PlayState* play, RoomContext* roomCtx) { if (roomCtx->status == 1) { if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) { roomCtx->status = 0; 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; } @@ -582,23 +582,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), "this->ground_shape->polygon.type < number(Room_Draw_Proc)", "../z_room.c", 1125); - 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/src/code/z_sample.c b/src/code/z_sample.c index 2957aea9b..4d0bae9ae 100644 --- a/src/code/z_sample.c +++ b/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, Play_Init, GlobalContext); + SET_NEXT_GAMESTATE(&this->state, Play_Init, PlayState); this->state.running = false; } } diff --git a/src/code/z_scene.c b/src/code/z_scene.c index b558b6f15..8c63346c5 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -33,24 +33,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?) u32 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; @@ -69,7 +69,7 @@ void Object_InitBank(GlobalContext* globalCtx, ObjectContext* objectCtx) { osSyncPrintf(VT_RST); objectCtx->spaceStart = objectCtx->status[0].segment = - GameState_Alloc(&globalCtx->state, spaceSize, "../z_scene.c", 219); + GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219); objectCtx->spaceEnd = (void*)((s32)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP); @@ -158,7 +158,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) { @@ -171,7 +171,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" @@ -182,29 +182,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); @@ -213,41 +213,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 = Play_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; @@ -258,19 +258,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; } @@ -285,7 +285,7 @@ void Scene_CommandObjectList(GlobalContext* globalCtx, SceneCmd* cmd) { "../z_scene.c", 705); 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; } @@ -294,71 +294,72 @@ 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.skyboxConfig = globalCtx->envCtx.changeSkyboxNextConfig = cmd->skyboxSettings.unk_05; - globalCtx->envCtx.lightMode = cmd->skyboxSettings.unk_06; +void Scene_CommandSkyboxSettings(PlayState* play, SceneCmd* cmd) { + play->skyboxId = cmd->skyboxSettings.skyboxId; + play->envCtx.skyboxConfig = play->envCtx.changeSkyboxNextConfig = cmd->skyboxSettings.unk_05; + play->envCtx.lightMode = 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.sceneTimeSpeed = cmd->timeSettings.unk_06; + play->envCtx.sceneTimeSpeed = cmd->timeSettings.unk_06; } else { - globalCtx->envCtx.sceneTimeSpeed = 0; + play->envCtx.sceneTimeSpeed = 0; } if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) { - gTimeSpeed = globalCtx->envCtx.sceneTimeSpeed; + gTimeSpeed = play->envCtx.sceneTimeSpeed; } - globalCtx->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; - globalCtx->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f; + play->envCtx.sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; + play->envCtx.sunPos.y = (Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f; + play->envCtx.sunPos.z = (Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 20.0f) * 25.0f; - if (((globalCtx->envCtx.sceneTimeSpeed == 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) || + if (((play->envCtx.sceneTimeSpeed == 0) && (gSaveContext.cutsceneIndex < 0xFFF0)) || (gSaveContext.entranceIndex == ENTR_SPOT06_8)) { gSaveContext.skyboxTime = ((void)0, gSaveContext.dayTime); + if ((gSaveContext.skyboxTime > CLOCK_TIME(4, 0)) && (gSaveContext.skyboxTime < CLOCK_TIME(6, 30))) { gSaveContext.skyboxTime = CLOCK_TIME(5, 0) + 1; } else if ((gSaveContext.skyboxTime >= CLOCK_TIME(6, 30)) && (gSaveContext.skyboxTime <= CLOCK_TIME(8, 0))) { @@ -372,39 +373,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; @@ -418,7 +419,7 @@ void Scene_CommandAlternateHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) { if (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!" @@ -432,7 +433,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; } } @@ -440,24 +441,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, @@ -466,7 +467,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/src/code/z_scene_table.c b/src/code/z_scene_table.c index a80de06a1..44f6b19d7 100644 --- a/src/code/z_scene_table.c +++ b/src/code/z_scene_table.c @@ -73,34 +73,34 @@ Gfx sDefaultDisplayList[] = { gsSPEndDisplayList(), }; -void Scene_SetTransitionForNextEntrance(GlobalContext* globalCtx) { +void Scene_SetTransitionForNextEntrance(PlayState* play) { s16 entranceIndex; if (!IS_DAY) { if (!LINK_IS_ADULT) { - entranceIndex = globalCtx->nextEntranceIndex + 1; + entranceIndex = play->nextEntranceIndex + 1; } else { - entranceIndex = globalCtx->nextEntranceIndex + 3; + entranceIndex = play->nextEntranceIndex + 3; } } else { if (!LINK_IS_ADULT) { - entranceIndex = globalCtx->nextEntranceIndex; + entranceIndex = play->nextEntranceIndex; } else { - entranceIndex = globalCtx->nextEntranceIndex + 2; + entranceIndex = play->nextEntranceIndex + 2; } } - globalCtx->transitionType = gEntranceTable[entranceIndex].field & 0x7F; // Fade out + play->transitionType = gEntranceTable[entranceIndex].field & 0x7F; // Fade out } // Scene Draw Config 0 -void func_80099550(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4725); +void func_80099550(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4725); gSPDisplayList(POLY_OPA_DISP++, sDefaultDisplayList); gSPDisplayList(POLY_XLU_DISP++, sDefaultDisplayList); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4735); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4735); } void* D_8012A2F8[] = { @@ -109,38 +109,38 @@ 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, "../z_scene_table.c", 4763); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4763); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (gameplayFrames % 128), (gameplayFrames * 1) % 128, - 32, 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A2F8[((void)0, gSaveContext.nightFlag)])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4783); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4783); } // Scene Draw Config 28 -void func_80099760(GlobalContext* globalCtx) { +void func_80099760(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 4845); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4845); - 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, "../z_scene_table.c", 4859); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4859); } void* gDCEntranceTextures[] = { @@ -153,21 +153,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, "../z_scene_table.c", 4905); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4905); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(gDCEntranceTextures[((void)0, 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)); gDPPipeSync(POLY_OPA_DISP++); @@ -178,25 +178,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, "../z_scene_table.c", 4956); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 4956); } // 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, "../z_scene_table.c", 5069); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5069); - 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); @@ -213,7 +213,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); @@ -221,7 +221,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); @@ -229,16 +229,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, "../z_scene_table.c", 5145); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5145); if (gSaveContext.sceneSetupIndex == 5) { gCustomLensFlareOn = true; @@ -252,25 +252,24 @@ 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, "../z_scene_table.c", 5171); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5171); - 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, - 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, 127 - (gameplayFrames % 128), (gameplayFrames * 1) % 128, 32, 32, + 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 32)); + gSPSegment(POLY_OPA_DISP++, 0x0A, + 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); @@ -278,27 +277,27 @@ void func_8009A45C(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5212); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5212); } // Scene Draw Config 32 -void func_8009A798(GlobalContext* globalCtx) { +void func_8009A798(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5226); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5226); - 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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, - (gameplayFrames * 1) % 256, 32, 64, 1, 0, 0, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -306,22 +305,22 @@ void func_8009A798(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5264); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5264); } // Scene Draw Config 33 -void func_8009A9DC(GlobalContext* globalCtx) { +void func_8009A9DC(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5278); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5278); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 256, 32, - 64, 1, gameplayFrames % 128, (gameplayFrames * 3) % 256, 32, 64)); + 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -329,17 +328,17 @@ void func_8009A9DC(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5301); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5301); } // Scene Draw Config 48 -void func_8009AB98(GlobalContext* globalCtx) { +void func_8009AB98(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5317); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5317); - 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); @@ -347,20 +346,20 @@ void func_8009AB98(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5330); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5330); } // Scene Draw Config 39 -void func_8009ACA8(GlobalContext* globalCtx) { +void func_8009ACA8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5346); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5346); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->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)); + 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(play->state.gfxCtx, 0, gameplayFrames % 64, 256, 16)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -368,24 +367,24 @@ void func_8009ACA8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5367); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5367); } // Scene Draw Config 24 -void func_8009AE30(GlobalContext* globalCtx) { +void func_8009AE30(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5384); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5384); - 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)); } @@ -395,7 +394,7 @@ void func_8009AE30(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5416); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5416); } void* sThievesHideoutEntranceTextures[] = { @@ -404,18 +403,18 @@ void* sThievesHideoutEntranceTextures[] = { }; // Scene Draw Config 40 -void func_8009AFE0(GlobalContext* globalCtx) { +void func_8009AFE0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5490); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5490); - 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)); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sThievesHideoutEntranceTextures[((void)0, gSaveContext.nightFlag)])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5507); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5507); } void* D_8012A330[] = { @@ -424,123 +423,122 @@ 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, "../z_scene_table.c", 5535); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5535); if (1) {} // Necessary to match - 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[((void)0, 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, - 0, 0, 0, spAC)); + 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, - 0, 0, 0, 255)); + 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, - 0, 0, 0, 160)); + 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, - 0, 0, 0, spAC)); + 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, - 0, 0, 0, 255)); + 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, - 0, 0, 0, 160)); + 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, - 0, 0, 0, 160)); + 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, - 0, 0, 0, 180)); + 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, - 32, 32, 0, 0, 0, 160 + (s32)((spAC / 200.0f) * 95.0f))); + 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, - 0, 0, 0, 185 + (s32)((spAC / 200.0f) * 70.0f))); + 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, - 0, 127 - (gameplayFrames * 1), 32, 32, 0, 0, 0, 128)); + 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, - gameplayFrames * 4, 0, 32, 32, 0, 0, 0, 128)); + Gfx_TwoTexScrollEnvColor(play->state.gfxCtx, 0, gameplayFrames * 4, 0, 32, 32, 1, gameplayFrames * 4, 0, + 32, 32, 0, 0, 0, 128)); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5644); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5644); } // Scene Draw Config 29 -void func_8009B86C(GlobalContext* globalCtx) { +void func_8009B86C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5791); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5791); - 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, "../z_scene_table.c", 5808); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5808); } // Scene Draw Config 34 -void func_8009B9BC(GlobalContext* globalCtx) { +void func_8009B9BC(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5822); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5822); - 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, "../z_scene_table.c", 5836); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5836); } // Scene Draw Config 35 -void func_8009BAA4(GlobalContext* globalCtx) { +void func_8009BAA4(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5850); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5850); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 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) { - gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 10) % 256, 32, 64)); + if (play->sceneNum == SCENE_HAIRAL_NIWA) { + gSPSegment(POLY_XLU_DISP++, 0x09, Gfx_TexScroll(play->state.gfxCtx, 0, (gameplayFrames * 10) % 256, 32, 64)); } gDPPipeSync(POLY_OPA_DISP++); @@ -549,34 +547,32 @@ void func_8009BAA4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5876); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5876); } // Scene Draw Config 36 -void func_8009BC44(GlobalContext* globalCtx) { +void func_8009BC44(PlayState* play) { u32 gameplayFrames; s8 sp83; if (1) {} // Necessary to match - sp83 = coss((globalCtx->gameplayFrames * 1500) & 0xFFFF) >> 8; + sp83 = coss((play->gameplayFrames * 1500) & 0xFFFF) >> 8; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5894); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5894); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; - if (globalCtx->sceneNum == SCENE_GANON_TOU) { - gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (gameplayFrames * 1) % 256, 64, 64)); + if (play->sceneNum == SCENE_GANON_TOU) { + gSPSegment(POLY_XLU_DISP++, 0x09, 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, - (gameplayFrames * 1) % 128, 32, 32, 1, (gameplayFrames * 1) % 128, - (gameplayFrames * 1) % 128, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 255 - (gameplayFrames * 1) % 128, (gameplayFrames * 1) % 128, 32, + 32, 1, (gameplayFrames * 1) % 128, (gameplayFrames * 1) % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -588,22 +584,22 @@ void func_8009BC44(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, sp83, sp83, sp83, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5930); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5930); } // 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)); @@ -611,25 +607,25 @@ void func_8009BEEC(GlobalContext* globalCtx) { } // Scene Draw Config 38 -void func_8009C0AC(GlobalContext* globalCtx) { +void func_8009C0AC(PlayState* play) { u32 gameplayFrames; s8 sp7B; if (1) {} // Necessary to match - sp7B = coss((globalCtx->gameplayFrames * 1500) & 0xFFFF) >> 8; + sp7B = coss((play->gameplayFrames * 1500) & 0xFFFF) >> 8; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 5968); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 5968); - 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++); @@ -642,12 +638,12 @@ void func_8009C0AC(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, sp7B, sp7B, sp7B, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6004); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6004); - 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); } } } @@ -658,22 +654,22 @@ void* sIceCavernEntranceTextures[] = { }; // Scene Draw Config 37 -void func_8009C3EC(GlobalContext* globalCtx) { +void func_8009C3EC(PlayState* play) { u32 gameplayFrames; if (0) {} // Necessary to match - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6042); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6042); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sIceCavernEntranceTextures[((void)0, gSaveContext.nightFlag)])); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -681,25 +677,25 @@ void func_8009C3EC(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6076); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6076); } // Scene Draw Config 42 -void func_8009C608(GlobalContext* globalCtx) { +void func_8009C608(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6151); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6151); - 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++); @@ -708,23 +704,22 @@ void func_8009C608(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6187); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6187); } // Scene Draw Config 43 -void func_8009C8B8(GlobalContext* globalCtx) { +void func_8009C8B8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6201); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6201); - 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, - 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_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(play->state.gfxCtx, 0, 255 - (gameplayFrames * 10) % 256, 32, 64)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -732,19 +727,19 @@ void func_8009C8B8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6232); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6232); } // Scene Draw Config 47 -void func_8009CAC0(GlobalContext* globalCtx) { +void func_8009CAC0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6249); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6249); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -752,7 +747,7 @@ void func_8009CAC0(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6264); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6264); } void* sGTGEntranceTextures[] = { @@ -761,21 +756,21 @@ void* sGTGEntranceTextures[] = { }; // Scene Draw Config 27 -void func_8009CC00(GlobalContext* globalCtx) { +void func_8009CC00(PlayState* play) { u32 gameplayFrames; if (0) {} // Necessary to match - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6290); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6290); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGTGEntranceTextures[((void)0, gSaveContext.nightFlag)])); gSPSegment(POLY_OPA_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -783,7 +778,7 @@ void func_8009CC00(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6320); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6320); } Gfx* Gfx_TwoTexScrollPrimColor(GraphicsContext* gfxCtx, s32 tile1, u32 x1, u32 y1, s32 width1, s32 height1, s32 tile2, @@ -806,17 +801,16 @@ 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, "../z_scene_table.c", 6433); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6433); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScrollPrimColor(globalCtx->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)); + 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, play->roomCtx.unk_74[0] + 127)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -824,24 +818,21 @@ void func_8009CF84(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6449); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6449); } // Scene Draw Config 41 -void func_8009D0E8(GlobalContext* globalCtx) { +void func_8009D0E8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6463); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6463); - gameplayFrames = globalCtx->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)); - gSPSegment(POLY_OPA_DISP++, 0x0A, - Gfx_TexScroll(globalCtx->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)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_XLU_DISP++, 0x08, 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(play->state.gfxCtx, 0, 63 - (gameplayFrames * 2) % 64, 16, 16)); + gSPSegment(POLY_XLU_DISP++, 0x0B, + 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); @@ -849,7 +840,7 @@ void func_8009D0E8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6491); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6491); } void* sLonLonHouseEntranceTextures[] = { @@ -858,8 +849,8 @@ void* sLonLonHouseEntranceTextures[] = { }; // Scene Draw Config 44 -void func_8009D31C(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6515); +void func_8009D31C(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6515); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonHouseEntranceTextures[((void)0, gSaveContext.nightFlag)])); @@ -870,7 +861,7 @@ void func_8009D31C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6528); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6528); } void* sGuardHouseView2Textures[] = { @@ -883,10 +874,10 @@ void* sGuardHouseView1Textures[] = { }; // Scene Draw Config 45 -void func_8009D438(GlobalContext* globalCtx) { +void func_8009D438(PlayState* play) { s32 var; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6560); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6560); if (LINK_IS_ADULT) { var = 1; @@ -903,19 +894,19 @@ void func_8009D438(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6581); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6581); } // Scene Draw Config 46 -void func_8009D5B4(GlobalContext* globalCtx) { +void func_8009D5B4(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6595); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6595); - 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++); @@ -924,7 +915,7 @@ void func_8009D5B4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6615); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6615); } void* sForestTempleEntranceTextures[] = { @@ -933,22 +924,22 @@ void* sForestTempleEntranceTextures[] = { }; // Scene Draw Config 22 -void func_8009D758(GlobalContext* globalCtx) { +void func_8009D758(PlayState* play) { u32 gameplayFrames; if (0) {} // Necessary to match - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6640); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6640); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sForestTempleEntranceTextures[((void)0, gSaveContext.nightFlag)])); gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -956,7 +947,7 @@ void func_8009D758(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6671); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6671); } void* sSpiritTempleEntranceTextures[] = { @@ -965,31 +956,31 @@ void* sSpiritTempleEntranceTextures[] = { }; // Scene Draw Config 25 -void func_8009D974(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6752); +void func_8009D974(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6752); gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sSpiritTempleEntranceTextures[((void)0, gSaveContext.nightFlag)])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6762); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6762); } // 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, "../z_scene_table.c", 6814); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6814); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1003,21 +994,21 @@ void func_8009DA30(GlobalContext* globalCtx) { gSPEndDisplayList(displayListHead); } else { if (gSaveContext.dayTime > CLOCK_TIME(18, 30)) { - 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 >= CLOCK_TIME(6, 0)) { - 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, "../z_scene_table.c", 6866); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6866); } void* sKakarikoWindowTextures[] = { @@ -1026,8 +1017,8 @@ void* sKakarikoWindowTextures[] = { }; // Scene Draw Config 2 -void func_8009DD5C(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6890); +void func_8009DD5C(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6890); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sKakarikoWindowTextures[((void)0, gSaveContext.nightFlag)])); @@ -1037,25 +1028,25 @@ void func_8009DD5C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6903); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6903); } // Scene Draw Config 3 -void func_8009DE78(GlobalContext* globalCtx) { +void func_8009DE78(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6917); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6917); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 6) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 6) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1063,11 +1054,11 @@ void func_8009DE78(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6948); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6948); } // Scene Draw Config 4 -void func_8009E0B8(GlobalContext* globalCtx) { +void func_8009E0B8(PlayState* play) { u32 gameplayFrames; u8 spA3; u16 spA0; @@ -1075,20 +1066,20 @@ 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)); if (1) {} if (1) {} - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 6965); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 6965); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x09, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1097,9 +1088,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) && GET_EVENTCHKINF(EVENTCHKINF_07)) { spA0 = 2150; } @@ -1116,34 +1107,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, "../z_scene_table.c", 7044); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7044); } // Scene Draw Config 5 -void func_8009E54C(GlobalContext* globalCtx) { +void func_8009E54C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7058); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7058); if ((gSaveContext.sceneSetupIndex > 3) || (LINK_IS_ADULT && !GET_EVENTCHKINF(EVENTCHKINF_69))) { - 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, "../z_scene_table.c", 7097); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7097); } void* sZorasDomainEntranceTextures[] = { @@ -1152,18 +1143,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, "../z_scene_table.c", 7123); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7123); - 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); @@ -1171,23 +1162,23 @@ void func_8009E730(GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sZorasDomainEntranceTextures[((void)0, gSaveContext.nightFlag)])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7147); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7147); } // Scene Draw Config 7 -void func_8009E8C0(GlobalContext* globalCtx) { +void func_8009E8C0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7161); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7161); - 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++); @@ -1196,33 +1187,32 @@ void func_8009E8C0(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7192); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7192); } // Scene Draw Config 8 -void func_8009EAD8(GlobalContext* globalCtx) { +void func_8009EAD8(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7206); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7206); - 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)); + gSPSegment(POLY_OPA_DISP++, 0x0B, + 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++); @@ -1231,23 +1221,23 @@ void func_8009EAD8(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7260); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7260); } // Scene Draw Config 9 -void func_8009EE44(GlobalContext* globalCtx) { +void func_8009EE44(PlayState* play) { u32 gameplayFrames; if (0) {} // Necessary to match - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7274); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7274); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, gameplayFrames % 128, 0, 32, 16, 1, gameplayFrames % 128, 0, - 32, 16)); + gameplayFrames = play->gameplayFrames; + gSPSegment( + POLY_XLU_DISP++, 0x08, + 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++); @@ -1256,26 +1246,26 @@ void func_8009EE44(GlobalContext* globalCtx) { gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); - if ((globalCtx->roomCtx.unk_74[0] == 0) && (INV_CONTENT(ITEM_COJIRO) == ITEM_COJIRO)) { - 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) && (INV_CONTENT(ITEM_COJIRO) == ITEM_COJIRO)) { + 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, "../z_scene_table.c", 7309); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7309); } // Scene Draw Config 10 -void func_8009F074(GlobalContext* globalCtx) { +void func_8009F074(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7323); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7323); - 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); @@ -1283,7 +1273,7 @@ void func_8009F074(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7339); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7339); } void* D_8012A380[] = { @@ -1292,27 +1282,27 @@ void* D_8012A380[] = { }; // Scene Draw Config 11 -void func_8009F1B4(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7363); +void func_8009F1B4(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7363); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(D_8012A380[((void)0, gSaveContext.nightFlag)])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7371); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7371); } // Scene Draw Config 12 -void func_8009F270(GlobalContext* globalCtx) { +void func_8009F270(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7385); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7385); - gameplayFrames = globalCtx->gameplayFrames; - gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->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, - 32, 32)); + gameplayFrames = play->gameplayFrames; + gSPSegment( + POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, 32, 32)); + gSPSegment( + POLY_XLU_DISP++, 0x09, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1320,22 +1310,22 @@ void func_8009F270(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7409); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7409); } // Scene Draw Config 13 -void func_8009F40C(GlobalContext* globalCtx) { +void func_8009F40C(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7423); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7423); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, - 32, 1, gameplayFrames % 128, (gameplayFrames * 10) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 3) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1343,14 +1333,14 @@ void func_8009F40C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7443); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7443); } // 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, "../z_scene_table.c", 7461); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7461); gSPSegment(POLY_XLU_DISP++, 0x08, displayListHead); @@ -1358,16 +1348,16 @@ void func_8009F5D4(GlobalContext* globalCtx) { gSPEndDisplayList(displayListHead); } else { if (gSaveContext.dayTime > CLOCK_TIME(18, 0)) { - 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 >= CLOCK_TIME(6, 0)) { - 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); } @@ -1378,24 +1368,24 @@ void func_8009F5D4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7495); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7495); } // 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, "../z_scene_table.c", 7512); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7512); - 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, - 32, 32)); + gSPSegment( + POLY_OPA_DISP++, 0x08, + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames % 128, 32, 32, 1, 0, gameplayFrames % 128, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, sp6F, sp6E, 255, 128); @@ -1403,7 +1393,7 @@ void func_8009F7D4(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7530); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7530); } void* sGoronCityEntranceTextures[] = { @@ -1412,15 +1402,15 @@ void* sGoronCityEntranceTextures[] = { }; // Scene Draw Config 16 -void func_8009F9D0(GlobalContext* globalCtx) { +void func_8009F9D0(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7555); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7555); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_OPA_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 127 - gameplayFrames % 128, 32, 32, 1, - gameplayFrames % 128, 0, 32, 32)); + Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 127 - gameplayFrames % 128, 32, 32, 1, gameplayFrames % 128, + 0, 32, 32)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1431,7 +1421,7 @@ void func_8009F9D0(GlobalContext* globalCtx) { gSPSegment(POLY_XLU_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sGoronCityEntranceTextures[((void)0, gSaveContext.nightFlag)])); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7578); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7578); } void* sLonLonRanchWindowTextures[] = { @@ -1440,8 +1430,8 @@ void* sLonLonRanchWindowTextures[] = { }; // Scene Draw Config 17 -void func_8009FB74(GlobalContext* globalCtx) { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7602); +void func_8009FB74(PlayState* play) { + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7602); gSPSegment(POLY_OPA_DISP++, 0x08, SEGMENTED_TO_VIRTUAL(sLonLonRanchWindowTextures[((void)0, gSaveContext.nightFlag)])); @@ -1452,23 +1442,22 @@ void func_8009FB74(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7615); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7615); } // Scene Draw Config 18 -void func_8009FC90(GlobalContext* globalCtx) { +void func_8009FC90(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7630); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7630); - 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, - 127 - (gameplayFrames * 6) % 128, 32, 32, 1, (gameplayFrames * 6) % 128, - 127 - (gameplayFrames * 3) % 128, 32, 32)); + 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)); gDPPipeSync(POLY_OPA_DISP++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 64); @@ -1476,31 +1465,31 @@ void func_8009FC90(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 64); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7653); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7653); } 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, "../z_scene_table.c", 7712); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7712); - 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, - 32, 1, 127 - gameplayFrames % 128, (gameplayFrames * 2) % 128, 32, 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, - (gameplayFrames * 1) % 128, 32, 32)); + gSPSegment( + POLY_OPA_DISP++, 0x08, + Gfx_TexScroll(play->state.gfxCtx, (127 - (gameplayFrames * 1)) % 128, (gameplayFrames * 1) % 128, 32, 32)); } gDPPipeSync(POLY_OPA_DISP++); @@ -1509,71 +1498,71 @@ 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; - View_SetDistortionOrientation(&globalCtx->view, + 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; } - D_8012A398 += 0.15f + (globalCtx->roomCtx.unk_74[1] * 0.001f); + 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, "../z_scene_table.c", 7809)); + gSPSegment(POLY_OPA_DISP++, 0x0D, Matrix_NewMtx(play->state.gfxCtx, "../z_scene_table.c", 7809)); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7811); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7811); } // Scene Draw Config 26 -void func_800A0334(GlobalContext* globalCtx) { +void func_800A0334(PlayState* play) { u32 gameplayFrames; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7825); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7825); - gameplayFrames = globalCtx->gameplayFrames; + gameplayFrames = play->gameplayFrames; gSPSegment(POLY_XLU_DISP++, 0x08, - Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - gameplayFrames % 128, (gameplayFrames * 1) % 512, 32, - 128, 1, gameplayFrames % 128, (gameplayFrames * 1) % 512, 32, 128)); + 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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, - 32, 1, gameplayFrames % 128, (gameplayFrames * 1) % 128, 32, 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++); gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128); @@ -1581,29 +1570,28 @@ void func_800A0334(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7852); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7852); } // 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, "../z_scene_table.c", 7893); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7893); - gameplayFrames = globalCtx->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)); + gameplayFrames = play->gameplayFrames; + gSPSegment(POLY_OPA_DISP++, 0x08, 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); @@ -1611,10 +1599,10 @@ void func_800A059C(GlobalContext* globalCtx) { gDPPipeSync(POLY_XLU_DISP++); gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 7910); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 7910); } -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, @@ -1625,7 +1613,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; @@ -1644,19 +1632,19 @@ void Scene_Draw(GlobalContext* globalCtx) { HREG(94) = 0; } - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 8104); + OPEN_DISPS(play->state.gfxCtx, "../z_scene_table.c", 8104); if (HREG(81) == 1) { gSPDisplayList(POLY_OPA_DISP++, sDefaultDisplayList); gSPDisplayList(POLY_XLU_DISP++, sDefaultDisplayList); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_scene_table.c", 8109); + CLOSE_DISPS(play->state.gfxCtx, "../z_scene_table.c", 8109); if (HREG(82) == 1) { - sSceneDrawHandlers[globalCtx->sceneConfig](globalCtx); + sSceneDrawHandlers[play->sceneConfig](play); } } else { - sSceneDrawHandlers[globalCtx->sceneConfig](globalCtx); + sSceneDrawHandlers[play->sceneConfig](play); } } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 844903e14..9ccf57a56 100644 --- a/src/code/z_skelanime.c +++ b/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, "../z_skelanime.c", 773); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 773); Matrix_Push(); limb = (LodLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]); @@ -38,10 +38,10 @@ 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, "../z_skelanime.c", 805), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_skelanime.c", 805), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dList); } } @@ -49,28 +49,28 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele if (1) {} 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, "../z_skelanime.c", 821); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 821); } /** * 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, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) { +void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, + PostLimbDrawOpa postLimbDraw, void* arg, s32 lod) { LodLimb* rootLimb; s32 pad; Gfx* dList; @@ -84,7 +84,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 849); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 849); Matrix_Push(); @@ -96,32 +96,31 @@ 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, "../z_skelanime.c", 881), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_skelanime.c", 881), 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, - lod); + SkelAnime_DrawLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod); } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 894); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 894); } /** * 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; @@ -143,15 +142,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, "../z_skelanime.c", 945); { - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 946); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 946); gSPMatrix(POLY_OPA_DISP++, *mtx, G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, newDList); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 949); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 949); } (*mtx)++; } else if (limbDList != NULL) { @@ -160,18 +159,18 @@ 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, - lod, mtx); + 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, - lod, mtx); + SkelAnime_DrawFlexLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod, + mtx); } } @@ -180,7 +179,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; @@ -188,7 +187,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)); @@ -197,7 +196,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi return; } - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1000); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1000); gSPSegment(POLY_OPA_DISP++, 0xD, mtx); Matrix_Push(); @@ -211,7 +210,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, "../z_skelanime.c", 1033); @@ -225,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, - lod, &mtx); + SkelAnime_DrawFlexLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, lod, + &mtx); } Matrix_Pop(); - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1053); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1053); } /** * 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, "../z_skelanime.c", 1076); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1076); Matrix_Push(); limb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[limbIndex]); @@ -258,10 +257,10 @@ 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, "../z_skelanime.c", 1103), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_skelanime.c", 1103), G_MTX_LOAD); gSPDisplayList(POLY_OPA_DISP++, dList); } } @@ -269,26 +268,26 @@ void SkelAnime_DrawLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skele if (1) {} 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, "../z_skelanime.c", 1121); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1121); } /** * Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer */ -void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, - OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, void* arg) { +void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw, + PostLimbDrawOpa postLimbDraw, void* arg) { StandardLimb* rootLimb; s32 pad; Gfx* dList; @@ -302,7 +301,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa return; } - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1148); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1148); Matrix_Push(); rootLimb = (StandardLimb*)SEGMENTED_TO_VIRTUAL(skeleton[0]); @@ -314,31 +313,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, "../z_skelanime.c", 1176), G_MTX_LOAD); + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_skelanime.c", 1176), 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, "../z_skelanime.c", 1190); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1190); } /** * 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** limbMatrices) { StandardLimb* limb; @@ -347,7 +346,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s Vec3f pos; Vec3s rot; - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1214); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1214); Matrix_Push(); @@ -361,7 +360,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(*limbMatrices, "../z_skelanime.c", 1242); @@ -375,21 +374,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, limbMatrices); } 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, limbMatrices); } - CLOSE_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1265); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1265); } /** @@ -397,7 +396,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; @@ -405,7 +404,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)); @@ -414,7 +413,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi return; } - OPEN_DISPS(globalCtx->state.gfxCtx, "../z_skelanime.c", 1294); + OPEN_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1294); gSPSegment(POLY_OPA_DISP++, 0xD, mtx); @@ -430,7 +429,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, "../z_skelanime.c", 1327); @@ -444,16 +443,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, "../z_skelanime.c", 1347); + CLOSE_DISPS(play->state.gfxCtx, "../z_skelanime.c", 1347); } /** @@ -502,7 +501,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; @@ -522,28 +521,26 @@ 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, "../z_skelanime.c", 1489), G_MTX_LOAD); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx, "../z_skelanime.c", 1489), 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); + 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); + gfx = SkelAnime_DrawLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); } return gfx; @@ -552,7 +549,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; @@ -580,21 +577,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, "../z_skelanime.c", 1558), G_MTX_LOAD); + gSPMatrix(gfx++, Matrix_NewMtx(play->state.gfxCtx, "../z_skelanime.c", 1558), 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); + gfx = SkelAnime_DrawLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, gfx); } Matrix_Pop(); @@ -605,7 +601,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; @@ -625,7 +621,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, "../z_skelanime.c", 1623); @@ -638,18 +634,18 @@ 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, - mtx, gfx); + 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, - arg, mtx, gfx); + gfx = SkelAnime_DrawFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + mtx, gfx); } return gfx; @@ -660,7 +656,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; @@ -668,7 +664,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)); @@ -690,7 +686,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, "../z_skelanime.c", 1710); @@ -703,11 +699,11 @@ 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, - arg, &mtx, gfx); + gfx = SkelAnime_DrawFlexLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, arg, + &mtx, gfx); } Matrix_Pop(); @@ -810,14 +806,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; } @@ -838,9 +834,9 @@ 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) { - AnimationEntry* entry = AnimationContext_AddEntry(&globalCtx->animationCtx, ANIMENTRY_LOADFRAME); + AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMENTRY_LOADFRAME); if (entry != NULL) { LinkAnimationHeader* linkAnimHeader = SEGMENTED_TO_VIRTUAL(animation); @@ -857,8 +853,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; @@ -871,8 +867,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; @@ -886,8 +882,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; @@ -901,8 +897,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; @@ -916,8 +912,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; @@ -929,7 +925,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); @@ -938,7 +934,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)) { @@ -955,7 +951,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)) { @@ -966,7 +962,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)) { @@ -986,7 +982,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)) { @@ -1006,7 +1002,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; @@ -1020,7 +1016,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, @@ -1028,7 +1024,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; @@ -1039,7 +1035,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) { FlexSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); @@ -1084,7 +1080,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); } /** @@ -1103,15 +1099,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; @@ -1121,7 +1117,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; } @@ -1130,8 +1126,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; @@ -1140,7 +1136,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); } } @@ -1149,7 +1145,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; @@ -1158,18 +1154,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; @@ -1180,14 +1176,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; } @@ -1198,7 +1194,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) { skelAnime->mode = mode; if ((morphFrames != 0.0f) && ((animation != skelAnime->animation) || (startFrame != skelAnime->curFrame))) { @@ -1208,15 +1204,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, - skelAnime->jointTable); + AnimationContext_SetLoadFrame(play, animation, (s32)startFrame, skelAnime->limbCount, skelAnime->jointTable); skelAnime->morphWeight = 0.0f; } @@ -1232,105 +1227,101 @@ 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), - ANIMMODE_ONCE, 0.0f); + 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), - ANIMMODE_LOOP, 0.0f); + 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, - f32 frame) { - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->morphTable); +void LinkAnimation_LoadToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { + 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, - f32 frame) { - AnimationContext_SetLoadFrame(globalCtx, animation, (s32)frame, skelAnime->limbCount, skelAnime->jointTable); +void LinkAnimation_LoadToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 frame) { + 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, - f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, - Vec3s* blendTable) { +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((u32)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, - f32 frame1, LinkAnimationHeader* animation2, f32 frame2, f32 blendWeight, - Vec3s* blendTable) { +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((u32)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); } /** @@ -1380,8 +1371,8 @@ 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, - AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { +s32 SkelAnime_Init(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg, AnimationHeader* animation, + Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) { SkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); skelAnime->limbCount = skeletonHeader->limbCount + 1; @@ -1410,7 +1401,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) { FlexSkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); @@ -1444,7 +1435,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) { SkeletonHeader* skeletonHeader = SEGMENTED_TO_VIRTUAL(skeletonHeaderSeg); @@ -1839,7 +1830,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) { ZeldaArena_FreeDebug(skelAnime->jointTable, "../z_skelanime.c", 3729); } else { diff --git a/src/code/z_skin.c b/src/code/z_skin.c index 9c886fa2e..e61ed3d09 100644 --- a/src/code/z_skin.c +++ b/src/code/z_skin.c @@ -185,12 +185,12 @@ void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dlis CLOSE_DISPS(gfxCtx, "../z_skin.c", 433); } -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, "../z_skin.c", 471); @@ -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/src/code/z_skin_awb.c b/src/code/z_skin_awb.c index 13ceafa91..e16556ca6 100644 --- a/src/code/z_skin_awb.c +++ b/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) { s32 limbCount; s32 i; SkinLimb** skeleton; @@ -74,17 +74,17 @@ void Skin_Init(GlobalContext* globalCtx, Skin* skin, SkeletonHeader* skeletonHea ZeldaArena_MallocDebug(animatedLimbData->totalVtxCount * sizeof(Vtx), "../z_skin_awb.c", 240); ASSERT(vtxEntry->buf[1] != NULL, "psavb->buf[1] != NULL", "../z_skin_awb.c", 242); - 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; @@ -103,7 +103,7 @@ void Skin_Free(GlobalContext* globalCtx, Skin* skin) { ZeldaArena_FreeDebug(skin->vtxTable, "../z_skin_awb.c", 286); } - SkelAnime_Free(&skin->skelAnime, globalCtx); + SkelAnime_Free(&skin->skelAnime, play); } } diff --git a/src/code/z_sound_source.c b/src/code/z_sound_source.c index fe9088a70..6e89130d7 100644 --- a/src/code/z_sound_source.c +++ b/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,7 +57,7 @@ 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, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } diff --git a/src/code/z_sram.c b/src/code/z_sram.c index 83e7ba9e0..746413491 100644 --- a/src/code/z_sram.c +++ b/src/code/z_sram.c @@ -899,5 +899,5 @@ void Sram_Alloc(GameState* gameState, SramContext* sramCtx) { ASSERT(sramCtx->readBuff != NULL, "sram->read_buff != NULL", "../z_sram.c", 1295); } -void Sram_Init(GlobalContext* globalCtx, SramContext* sramCtx) { +void Sram_Init(PlayState* play, SramContext* sramCtx) { } diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index fd87904d1..9c9da69fb 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -370,7 +370,7 @@ void func_800AF178(SkyboxContext* skyboxCtx, s32 arg1) { } } -void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyboxId) { +void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { u32 size; s16 i; u8 skybox1Index; @@ -390,25 +390,23 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox if (gSaveContext.skyboxTime >= gTimeBasedSkyboxConfigs[skyboxConfig][i].startTime && (gSaveContext.skyboxTime < gTimeBasedSkyboxConfigs[skyboxConfig][i].endTime || gTimeBasedSkyboxConfigs[skyboxConfig][i].endTime == 0xFFFF)) { - globalCtx->envCtx.skybox1Index = skybox1Index = - gTimeBasedSkyboxConfigs[skyboxConfig][i].skybox1Index; - globalCtx->envCtx.skybox2Index = skybox2Index = - gTimeBasedSkyboxConfigs[skyboxConfig][i].skybox2Index; + play->envCtx.skybox1Index = skybox1Index = gTimeBasedSkyboxConfigs[skyboxConfig][i].skybox1Index; + play->envCtx.skybox2Index = skybox2Index = gTimeBasedSkyboxConfigs[skyboxConfig][i].skybox2Index; if (gTimeBasedSkyboxConfigs[skyboxConfig][i].changeSkybox) { - globalCtx->envCtx.skyboxBlend = + play->envCtx.skyboxBlend = Environment_LerpWeight(gTimeBasedSkyboxConfigs[skyboxConfig][i].endTime, gTimeBasedSkyboxConfigs[skyboxConfig][i].startTime, ((void)0, gSaveContext.skyboxTime)) * 255.0f; } else { - globalCtx->envCtx.skyboxBlend = 0; + play->envCtx.skyboxBlend = 0; } break; } } size = gNormalSkyFiles[skybox1Index].file.vromEnd - gNormalSkyFiles[skybox1Index].file.vromStart; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1054); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1054); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1055); @@ -416,7 +414,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox "../z_vr_box.c", 1058); size = gNormalSkyFiles[skybox2Index].file.vromEnd - gNormalSkyFiles[skybox2Index].file.vromStart; - skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1060); + skyboxCtx->staticSegments[1] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1060); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1061); @@ -426,7 +424,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox if ((skybox1Index & 1) ^ ((skybox1Index & 4) >> 2)) { size = gNormalSkyFiles[skybox1Index].palette.vromEnd - gNormalSkyFiles[skybox1Index].palette.vromStart; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1072); + skyboxCtx->palettes = GameState_Alloc(&play->state, size * 2, "../z_vr_box.c", 1072); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1073); @@ -437,7 +435,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox } else { size = gNormalSkyFiles[skybox1Index].palette.vromEnd - gNormalSkyFiles[skybox1Index].palette.vromStart; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1085); + skyboxCtx->palettes = GameState_Alloc(&play->state, size * 2, "../z_vr_box.c", 1085); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1086); @@ -453,7 +451,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_SP1a_staticSegmentRomStart; size = _vr_SP1a_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1127); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1127); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1128); @@ -461,7 +459,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_SP1a_pal_staticSegmentRomStart; size = _vr_SP1a_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1132); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1132); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1133); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1134); @@ -470,13 +468,13 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_OVERCAST_SUNSET: start = _vr_cloud2_staticSegmentRomStart; size = _vr_cloud2_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1155); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1155); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1156); DmaMgr_SendRequest1(skyboxCtx->staticSegments[0], start, size, "../z_vr_box.c", 1159); - skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1162); + skyboxCtx->staticSegments[1] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1162); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1163); @@ -484,7 +482,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_cloud2_pal_staticSegmentRomStart; size = _vr_cloud2_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1170); + skyboxCtx->palettes = GameState_Alloc(&play->state, size * 2, "../z_vr_box.c", 1170); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1171); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1173); @@ -495,7 +493,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_RUVR_staticSegmentRomStart; size = _vr_RUVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1182); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1182); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1183); @@ -505,7 +503,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox size = _vr_RUVR_pal_staticSegmentRomEnd - start; osSyncPrintf("SIZE = %d\n", size); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1188); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1188); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1189); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1190); @@ -513,7 +511,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox case SKYBOX_CUTSCENE_MAP: start = _vr_holy0_staticSegmentRomStart; size = _vr_holy0_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1196); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1196); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1197); @@ -521,7 +519,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_holy1_staticSegmentRomStart; size = _vr_holy1_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[1] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1203); + skyboxCtx->staticSegments[1] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1203); ASSERT(skyboxCtx->staticSegments[1] != NULL, "vr_box->vr_box_staticSegment[1] != NULL", "../z_vr_box.c", 1204); @@ -529,7 +527,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_holy0_pal_staticSegmentRomStart; size = _vr_holy0_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size * 2, "../z_vr_box.c", 1211); + skyboxCtx->palettes = GameState_Alloc(&play->state, size * 2, "../z_vr_box.c", 1211); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1212); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1214); @@ -541,7 +539,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_LHVR_staticSegmentRomStart; size = _vr_LHVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1226); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1226); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1227); @@ -549,7 +547,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_LHVR_pal_staticSegmentRomStart; size = _vr_LHVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1231); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1231); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1232); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1233); @@ -559,7 +557,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_MDVR_staticSegmentRomStart; size = _vr_MDVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1257); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1257); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1258); @@ -567,7 +565,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_MDVR_pal_staticSegmentRomStart; size = _vr_MDVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1262); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1262); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1263); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1264); @@ -577,7 +575,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_MNVR_staticSegmentRomStart; size = _vr_MNVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1271); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1271); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1272); @@ -587,7 +585,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox size = _vr_MNVR_pal_staticSegmentRomEnd - start; osSyncPrintf("SIZE = %d\n", size); - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1277); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1277); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1278); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1279); @@ -597,7 +595,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_FCVR_staticSegmentRomStart; size = _vr_FCVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1286); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1286); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1287); @@ -605,7 +603,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_FCVR_pal_staticSegmentRomStart; size = _vr_FCVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1291); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1291); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1292); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1293); @@ -616,7 +614,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KHVR_staticSegmentRomStart; size = _vr_KHVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1301); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1301); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1302); @@ -624,7 +622,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KHVR_pal_staticSegmentRomStart; size = _vr_KHVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1306); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1306); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1307); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1308); @@ -634,7 +632,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_K3VR_staticSegmentRomStart; size = _vr_K3VR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1331); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1331); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1332); @@ -642,7 +640,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_K3VR_pal_staticSegmentRomStart; size = _vr_K3VR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1336); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1336); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1337); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1338); @@ -652,7 +650,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_MLVR_staticSegmentRomStart; size = _vr_MLVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1345); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1345); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1346); @@ -660,7 +658,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_MLVR_pal_staticSegmentRomStart; size = _vr_MLVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1350); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1350); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1351); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1352); @@ -670,7 +668,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KKRVR_staticSegmentRomStart; size = _vr_KKRVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1359); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1359); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1360); @@ -678,7 +676,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KKRVR_pal_staticSegmentRomStart; size = _vr_KKRVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1364); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1364); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1365); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1366); @@ -688,7 +686,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KSVR_staticSegmentRomStart; size = _vr_KSVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1373); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1373); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1374); @@ -696,7 +694,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KSVR_pal_staticSegmentRomStart; size = _vr_KSVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1378); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1378); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1379); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1380); @@ -707,7 +705,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_GLVR_staticSegmentRomStart; size = _vr_GLVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1405); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1405); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1406); @@ -715,7 +713,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_GLVR_pal_staticSegmentRomStart; size = _vr_GLVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1410); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1410); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1411); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1412); @@ -726,7 +724,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_ZRVR_staticSegmentRomStart; size = _vr_ZRVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1420); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1420); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1421); @@ -734,7 +732,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_ZRVR_pal_staticSegmentRomStart; size = _vr_ZRVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1425); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1425); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1426); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1427); @@ -745,7 +743,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_DGVR_staticSegmentRomStart; size = _vr_DGVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1451); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1451); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1452); @@ -753,7 +751,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_DGVR_pal_staticSegmentRomStart; size = _vr_DGVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1456); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1456); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1457); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1458); @@ -764,7 +762,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_ALVR_staticSegmentRomStart; size = _vr_ALVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1466); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1466); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1467); @@ -772,7 +770,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_ALVR_pal_staticSegmentRomStart; size = _vr_ALVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1471); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1471); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1472); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1473); @@ -783,7 +781,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_NSVR_staticSegmentRomStart; size = _vr_NSVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1481); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1481); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1482); @@ -791,7 +789,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_NSVR_pal_staticSegmentRomStart; size = _vr_NSVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1486); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1486); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1487); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1488); @@ -802,7 +800,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_IPVR_staticSegmentRomStart; size = _vr_IPVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1512); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1512); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1513); @@ -810,7 +808,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_IPVR_pal_staticSegmentRomStart; size = _vr_IPVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1517); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1517); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1518); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1519); @@ -820,7 +818,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_LBVR_staticSegmentRomStart; size = _vr_LBVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1526); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1526); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1527); @@ -828,7 +826,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_LBVR_pal_staticSegmentRomStart; size = _vr_LBVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1531); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1531); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1532); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1533); @@ -838,7 +836,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_TTVR_staticSegmentRomStart; size = _vr_TTVR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1540); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1540); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1541); @@ -846,7 +844,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_TTVR_pal_staticSegmentRomStart; size = _vr_TTVR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1545); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1545); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1546); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1547); @@ -856,7 +854,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_K4VR_staticSegmentRomStart; size = _vr_K4VR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1560); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1560); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1561); @@ -864,7 +862,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_K4VR_pal_staticSegmentRomStart; size = _vr_K4VR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1565); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1565); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1566); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1567); @@ -874,7 +872,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_K5VR_staticSegmentRomStart; size = _vr_K5VR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1574); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1574); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1575); @@ -882,7 +880,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_K5VR_pal_staticSegmentRomStart; size = _vr_K5VR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1579); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1579); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1580); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1581); @@ -892,7 +890,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KR3VR_staticSegmentRomStart; size = _vr_KR3VR_staticSegmentRomEnd - start; - skyboxCtx->staticSegments[0] = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1588); + skyboxCtx->staticSegments[0] = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1588); ASSERT(skyboxCtx->staticSegments[0] != NULL, "vr_box->vr_box_staticSegment[0] != NULL", "../z_vr_box.c", 1589); @@ -900,7 +898,7 @@ void Skybox_Setup(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skybox start = _vr_KR3VR_pal_staticSegmentRomStart; size = _vr_KR3VR_pal_staticSegmentRomEnd - start; - skyboxCtx->palettes = GameState_Alloc(&globalCtx->state, size, "../z_vr_box.c", 1593); + skyboxCtx->palettes = GameState_Alloc(&play->state, size, "../z_vr_box.c", 1593); ASSERT(skyboxCtx->palettes != NULL, "vr_box->vr_box_staticSegment[2] != NULL", "../z_vr_box.c", 1594); DmaMgr_SendRequest1(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1595); @@ -911,12 +909,12 @@ 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->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", |
