summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authormzxrules <mzxrules@gmail.com>2022-07-04 20:52:50 -0400
committermzxrules <mzxrules@gmail.com>2022-07-04 20:52:50 -0400
commit0b99719f7cb3cf4e5b5bc39cac5b9eb39b99616b (patch)
tree9e4937739b4429c81b396ee4fb0f808c29b26af2 /src/code
parent7769846704621adcc2dadf7482ba3e8dea675128 (diff)
parent45eed680d613642bc3e1591f95902f6d57e0f8e6 (diff)
Merge remote-tracking branch 'upstream/master' into z_map_
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_800E8EA0.c25
-rw-r--r--src/code/code_8012EC80.c22
-rw-r--r--src/code/code_8013EC10.c19
-rw-r--r--src/code/code_80182CE0.c7
-rw-r--r--src/code/flg_set.c6
-rw-r--r--src/code/game.c5
-rw-r--r--src/code/padmgr.c4
-rw-r--r--src/code/sys_rumble.c160
-rw-r--r--src/code/z_actor.c1073
-rw-r--r--src/code/z_bg_item.c14
-rw-r--r--src/code/z_bgcheck.c182
-rw-r--r--src/code/z_cheap_proc.c16
-rw-r--r--src/code/z_collision_check.c901
-rw-r--r--src/code/z_construct.c2
-rw-r--r--src/code/z_debug_display.c42
-rw-r--r--src/code/z_demo.c567
-rw-r--r--src/code/z_eff_footmark.c24
-rw-r--r--src/code/z_eff_shield_particle.c8
-rw-r--r--src/code/z_eff_spark.c4
-rw-r--r--src/code/z_eff_ss_dead.c40
-rw-r--r--src/code/z_effect.c26
-rw-r--r--src/code/z_effect_soft_sprite.c36
-rw-r--r--src/code/z_effect_soft_sprite_old_init.c344
-rw-r--r--src/code/z_elf_message.c6
-rw-r--r--src/code/z_en_a_keep.c32
-rw-r--r--src/code/z_en_hy_code.c68
-rw-r--r--src/code/z_en_item00.c306
-rw-r--r--src/code/z_env_flags.c18
-rw-r--r--src/code/z_face_reaction.c6
-rw-r--r--src/code/z_fcurve_data_skelanime.c36
-rw-r--r--src/code/z_fireobj.c61
-rw-r--r--src/code/z_game_dlftbls.c2
-rw-r--r--src/code/z_game_over.c31
-rw-r--r--src/code/z_kaleido_manager.c4
-rw-r--r--src/code/z_kaleido_scope_call.c34
-rw-r--r--src/code/z_kaleido_setup.c42
-rw-r--r--src/code/z_kanfont.c6
-rw-r--r--src/code/z_lifemeter.c41
-rw-r--r--src/code/z_lights.c39
-rw-r--r--src/code/z_map_disp.c1
-rw-r--r--src/code/z_message.c178
-rw-r--r--src/code/z_message_nes.c66
-rw-r--r--src/code/z_message_staff.c4
-rw-r--r--src/code/z_path.c4
-rw-r--r--src/code/z_play.c126
-rw-r--r--src/code/z_player_call.c32
-rw-r--r--src/code/z_quake.c30
-rw-r--r--src/code/z_rcp.c4
-rw-r--r--src/code/z_room.c68
-rw-r--r--src/code/z_rumble.c104
-rw-r--r--src/code/z_scene.c240
-rw-r--r--src/code/z_scene_proc.c237
-rw-r--r--src/code/z_schedule.c50
-rw-r--r--src/code/z_skelanime.c379
-rw-r--r--src/code/z_skin.c24
-rw-r--r--src/code/z_skin_awb.c2
-rw-r--r--src/code/z_snap.c26
-rw-r--r--src/code/z_sound_source.c32
-rw-r--r--src/code/z_sram_NES.c35
-rw-r--r--src/code/z_sub_s.c151
-rw-r--r--src/code/z_vr_box.c10
61 files changed, 3113 insertions, 2949 deletions
diff --git a/src/code/code_800E8EA0.c b/src/code/code_800E8EA0.c
index 6fb787451..7485f2d3a 100644
--- a/src/code/code_800E8EA0.c
+++ b/src/code/code_800E8EA0.c
@@ -1,7 +1,7 @@
#include "global.h"
-void Actor_ContinueText(GlobalContext* globalCtx, Actor* actor, u16 textId) {
- func_80151938(globalCtx, textId);
+void Actor_ContinueText(PlayState* play, Actor* actor, u16 textId) {
+ func_80151938(play, textId);
actor->textId = textId;
}
@@ -77,16 +77,15 @@ s32 Actor_TrackPoint(Actor* actor, Vec3f* target, Vec3s* headRot, Vec3s* torsoRo
*
* @note same note as Actor_TrackPlayer
*/
-s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot,
- f32 focusHeight) {
- Player* player = GET_PLAYER(globalCtx);
+s32 Actor_TrackPlayerSetFocusHeight(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, f32 focusHeight) {
+ Player* player = GET_PLAYER(play);
s16 yaw;
Vec3f target;
actor->focus.pos = actor->world.pos;
actor->focus.pos.y += focusHeight;
- if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) {
+ if (!((play->csCtx.state != 0) || gDbgCamEnabled)) {
yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y));
if (yaw >= 0x4300) {
Actor_TrackNone(headRot, torsoRot);
@@ -94,8 +93,8 @@ s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3
}
}
- if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) {
- target = globalCtx->view.eye;
+ if ((play->csCtx.state != 0) || gDbgCamEnabled) {
+ target = play->view.eye;
} else {
target = player->actor.focus.pos;
}
@@ -121,14 +120,14 @@ s32 Actor_TrackPlayerSetFocusHeight(GlobalContext* globalCtx, Actor* actor, Vec3
* @note if in a cutscene or debug camera is enabled, the computed rotation will instead turn towards the view eye no
* matter the yaw.
*/
-s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) {
- Player* player = GET_PLAYER(globalCtx);
+s32 Actor_TrackPlayer(PlayState* play, Actor* actor, Vec3s* headRot, Vec3s* torsoRot, Vec3f focusPos) {
+ Player* player = GET_PLAYER(play);
s16 yaw;
Vec3f target;
actor->focus.pos = focusPos;
- if (!((globalCtx->csCtx.state != 0) || gDbgCamEnabled)) {
+ if (!((play->csCtx.state != 0) || gDbgCamEnabled)) {
yaw = ABS_ALT(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y));
if (yaw >= 0x4300) {
Actor_TrackNone(headRot, torsoRot);
@@ -136,8 +135,8 @@ s32 Actor_TrackPlayer(GlobalContext* globalCtx, Actor* actor, Vec3s* headRot, Ve
}
}
- if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) {
- target = globalCtx->view.eye;
+ if ((play->csCtx.state != 0) || gDbgCamEnabled) {
+ target = play->view.eye;
} else {
target = player->actor.focus.pos;
}
diff --git a/src/code/code_8012EC80.c b/src/code/code_8012EC80.c
index 5dee17fb5..ea3c30aa6 100644
--- a/src/code/code_8012EC80.c
+++ b/src/code/code_8012EC80.c
@@ -474,15 +474,15 @@ u16 gScenesPerRegion[11][27] = {
},
};
-s32 Inventory_GetBtnBItem(GlobalContext* globalCtx) {
+s32 Inventory_GetBtnBItem(PlayState* play) {
if (gSaveContext.buttonStatus[0] == BTN_DISABLED) {
return ITEM_NONE;
} else if (gSaveContext.unk_1015 == ITEM_NONE) {
return ITEM_NONE;
} else if (CUR_FORM_EQUIP(EQUIP_SLOT_B) == ITEM_NONE) {
- if (globalCtx->interfaceCtx.unk_21C != 0) {
- if (globalCtx->interfaceCtx.unk_21E != 0) {
- return globalCtx->interfaceCtx.unk_21E;
+ if (play->interfaceCtx.unk_21C != 0) {
+ if (play->interfaceCtx.unk_21E != 0) {
+ return play->interfaceCtx.unk_21E;
}
}
return ITEM_NONE;
@@ -501,12 +501,12 @@ void Inventory_ChangeEquipment(s16 value) {
/**
* Only deletes shield, equipment argument unused and is a remnant of OoT
*/
-u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment) {
- Player* player = GET_PLAYER(globalCtx);
+u8 Inventory_DeleteEquipment(PlayState* play, s16 equipment) {
+ Player* player = GET_PLAYER(play);
if (GET_CUR_EQUIP_VALUE(EQUIP_SHIELD) != 0) {
SET_EQUIP_VALUE(EQUIP_SHIELD, 0);
- Player_SetEquipmentData(globalCtx, player);
+ Player_SetEquipmentData(play, player);
return true;
}
@@ -719,12 +719,12 @@ s16 Inventory_GetSkullTokenCount(s16 sceneIndex) {
}
}
-void Inventory_SaveLotteryCodeGuess(GlobalContext* globalCtx) {
+void Inventory_SaveLotteryCodeGuess(PlayState* play) {
u16 lotteryCodeGuess;
- lotteryCodeGuess = ((globalCtx->msgCtx.unk12054[0] & 0xF) << 8); // First Digit
- lotteryCodeGuess |= ((globalCtx->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit
- lotteryCodeGuess |= (globalCtx->msgCtx.unk12054[2] & 0xF); // Third Digit
+ lotteryCodeGuess = ((play->msgCtx.unk12054[0] & 0xF) << 8); // First Digit
+ lotteryCodeGuess |= ((play->msgCtx.unk12054[1] & 0xF) << 4); // Second Digit
+ lotteryCodeGuess |= (play->msgCtx.unk12054[2] & 0xF); // Third Digit
gSaveContext.save.lotteryCodeGuess =
(gSaveContext.save.lotteryCodeGuess & 0xFFFF0000) | (lotteryCodeGuess & 0xFFFF);
}
diff --git a/src/code/code_8013EC10.c b/src/code/code_8013EC10.c
deleted file mode 100644
index b44ed73a8..000000000
--- a/src/code/code_8013EC10.c
+++ /dev/null
@@ -1,19 +0,0 @@
-#include "global.h"
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EC10.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EC44.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013ECE0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013ED9C.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EDD0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE04.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE24.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE38.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_8013EC10/func_8013EE48.s")
diff --git a/src/code/code_80182CE0.c b/src/code/code_80182CE0.c
deleted file mode 100644
index 6ff8736e5..000000000
--- a/src/code/code_80182CE0.c
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "global.h"
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80182CE0.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183020.s")
-
-#pragma GLOBAL_ASM("asm/non_matchings/code/code_80182CE0/func_80183058.s")
diff --git a/src/code/flg_set.c b/src/code/flg_set.c
index 715d3756f..20818c06e 100644
--- a/src/code/flg_set.c
+++ b/src/code/flg_set.c
@@ -134,8 +134,8 @@ static u32 sCurrentBit = 0;
static s32 sTimer = 0;
void FlagSet_Update(GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
- Input* input = CONTROLLER1(&globalCtx->state);
+ PlayState* play = (PlayState*)gameState;
+ Input* input = CONTROLLER1(&play->state);
/* Intra-byte navigation */
@@ -255,7 +255,7 @@ void FlagSet_Update(GameState* gameState) {
// Pressing B will exit
} else if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
- globalCtx->pauseCtx.debugState = 0;
+ play->pauseCtx.debugState = 0;
}
}
diff --git a/src/code/game.c b/src/code/game.c
index 6f796bc12..c8d3e14ba 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -1,5 +1,6 @@
#include "global.h"
#include "system_malloc.h"
+#include "z64rumble.h"
s32 gFramerateDivisor = 1;
f32 gFramerateDivisorF = 1.0f;
@@ -216,7 +217,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
VisMono_Init(&sMonoColors);
func_80140898(&D_801F8048);
func_801773A0(&D_801F7FF0);
- func_8013ED9C();
+ Rumble_Init();
osSendMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK);
}
@@ -231,7 +232,7 @@ void GameState_Destroy(GameState* gameState) {
gameState->destroy(gameState);
}
- func_8013EDD0();
+ Rumble_Destroy();
func_801773C4(&D_801F7FF0);
func_80140D04(&D_801F8010);
func_801420F4(&D_801F8020);
diff --git a/src/code/padmgr.c b/src/code/padmgr.c
index 0d539126a..077ef1b2b 100644
--- a/src/code/padmgr.c
+++ b/src/code/padmgr.c
@@ -31,9 +31,9 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_8017544C.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_80175474.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_RumbleSet.s")
-#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_801754C0.s")
+#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_ControllerHasRumblePak.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_CalcStickEdges.s")
diff --git a/src/code/sys_rumble.c b/src/code/sys_rumble.c
new file mode 100644
index 000000000..4101758be
--- /dev/null
+++ b/src/code/sys_rumble.c
@@ -0,0 +1,160 @@
+/*
+ * File: sys_rumble.c
+ * Description: Internal scheduler system for rumble requests
+ */
+
+#include "global.h"
+#include "z64rumble.h"
+
+// sRumbleWasEnabledOnLastTick/sWillDisableRumble? Probably name it after updateEnabled
+u8 D_801D1E70 = true;
+
+void RumbleManager_Update(RumbleManager* rumbleMgr) {
+ s32 strongestIndex = -1;
+ s32 i;
+ s32 temp;
+
+ // Turn rumbling off for all controllers
+ for (i = 0; i < ARRAY_COUNT(rumbleMgr->rumbleEnabled); i++) {
+ rumbleMgr->rumbleEnabled[i] = false;
+ }
+
+ if (!rumbleMgr->updateEnabled) {
+ // Rumbling update is disabled
+
+ if (D_801D1E70) {
+ for (i = 0; i < MAXCONTROLLERS; i++) {
+ func_8017544C(i, false);
+ }
+ }
+
+ D_801D1E70 = rumbleMgr->updateEnabled;
+ func_80175434();
+
+ return;
+ }
+
+ D_801D1E70 = rumbleMgr->updateEnabled;
+
+ // Start up the manager by wiping old requests
+ if (rumbleMgr->state == RUMBLEMANAGER_STATE_INITIAL) {
+ for (i = 0; i < MAXCONTROLLERS; i++) {
+ func_8017544C(i, false);
+ }
+
+ for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
+ rumbleMgr->requestIntensities[i] = 0;
+ rumbleMgr->requestDecayTimers[i] = 0;
+ rumbleMgr->requestDecaySteps[i] = 0;
+ rumbleMgr->requestAccumulators[i] = 0;
+ }
+
+ rumbleMgr->rumblingDuration = 0;
+ rumbleMgr->downTime = 0;
+
+ rumbleMgr->overrideIntensity = 0;
+ rumbleMgr->overrideDecayTimer = 0;
+ rumbleMgr->overrideDecayStep = 0;
+ rumbleMgr->overrideAccumulator = 0;
+
+ rumbleMgr->state = RUMBLEMANAGER_STATE_RUNNING;
+
+ func_80175434();
+ }
+
+ if (rumbleMgr->state != RUMBLEMANAGER_STATE_WIPE) {
+ // Process arrays of rumble requests
+ for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
+ if (rumbleMgr->requestIntensities[i] != 0) { // This entry has a non-empty rumble request
+ if (rumbleMgr->requestDecayTimers[i] > 0) {
+ rumbleMgr->requestDecayTimers[i]--;
+ } else {
+ temp = rumbleMgr->requestIntensities[i] - rumbleMgr->requestDecaySteps[i];
+ if (temp > 0) {
+ rumbleMgr->requestIntensities[i] = temp;
+ } else {
+ rumbleMgr->requestIntensities[i] = 0;
+ }
+ }
+
+ temp = rumbleMgr->requestAccumulators[i] + rumbleMgr->requestIntensities[i];
+ rumbleMgr->requestAccumulators[i] = temp; // overflows
+ if (strongestIndex == -1) {
+ strongestIndex = i;
+ rumbleMgr->rumbleEnabled[0] = (temp >= 0x100);
+ } else if (rumbleMgr->requestIntensities[strongestIndex] < rumbleMgr->requestIntensities[i]) {
+ strongestIndex = i;
+ rumbleMgr->rumbleEnabled[0] = (temp >= 0x100);
+ }
+ }
+ }
+
+ // Process Override request. Note it takes priority over the values set by the request arrays
+ if (rumbleMgr->overrideIntensity != 0) {
+ if (rumbleMgr->overrideDecayTimer > 0) {
+ rumbleMgr->overrideDecayTimer--;
+ } else {
+ temp = rumbleMgr->overrideIntensity - rumbleMgr->overrideDecayStep;
+ if (temp > 0) {
+ rumbleMgr->overrideIntensity = temp;
+ } else {
+ rumbleMgr->overrideIntensity = 0;
+ }
+ }
+
+ temp = rumbleMgr->overrideAccumulator + rumbleMgr->overrideIntensity;
+ rumbleMgr->overrideAccumulator = temp; // overflows
+ rumbleMgr->rumbleEnabled[0] = (temp >= 0x100);
+ }
+
+ if (rumbleMgr->overrideIntensity != 0) {
+ temp = rumbleMgr->overrideIntensity;
+ } else if (strongestIndex == -1) {
+ temp = 0;
+ } else {
+ temp = rumbleMgr->requestIntensities[strongestIndex];
+ }
+
+ // Keep track of how long this have been rumbling (almost) nonstop
+ if (temp == 0) {
+ rumbleMgr->downTime++;
+ if (rumbleMgr->downTime > 5) {
+ rumbleMgr->rumblingDuration = 0;
+ rumbleMgr->downTime = 5;
+ }
+ } else {
+ rumbleMgr->downTime = 0;
+ rumbleMgr->rumblingDuration++;
+ if (rumbleMgr->rumblingDuration > 2 * 60 * 60) { // 2 minutes
+ // Rumbling has lasted too long, clear system
+ rumbleMgr->state = RUMBLEMANAGER_STATE_WIPE;
+ }
+ }
+ } else { // RUMBLEMANAGER_STATE_WIPE
+ for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
+ rumbleMgr->requestIntensities[i] = 0;
+ rumbleMgr->requestDecayTimers[i] = 0;
+ rumbleMgr->requestDecaySteps[i] = 0;
+ rumbleMgr->requestAccumulators[i] = 0;
+ }
+
+ rumbleMgr->rumblingDuration = 0;
+ rumbleMgr->downTime = 0;
+
+ rumbleMgr->overrideIntensity = 0;
+ rumbleMgr->overrideDecayTimer = 0;
+ rumbleMgr->overrideDecayStep = 0;
+ rumbleMgr->overrideAccumulator = 0;
+
+ func_80175434();
+ }
+}
+
+void RumbleManager_Init(RumbleManager* rumbleMgr) {
+ bzero(rumbleMgr, sizeof(RumbleManager));
+ rumbleMgr->state = RUMBLEMANAGER_STATE_INITIAL;
+ rumbleMgr->updateEnabled = true;
+}
+
+void RumbleManager_Destroy(RumbleManager* rumbleMgr) {
+}
diff --git a/src/code/z_actor.c b/src/code/z_actor.c
index ddc22949b..273581621 100644
--- a/src/code/z_actor.c
+++ b/src/code/z_actor.c
@@ -5,6 +5,7 @@
#include "global.h"
#include "z64load.h"
+#include "z64rumble.h"
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
#include "overlays/actors/ovl_En_Part/z_en_part.h"
#include "overlays/actors/ovl_En_Box/z_en_box.h"
@@ -30,13 +31,13 @@ extern Mtx D_801ED8E0; // 1 func
extern Actor* D_801ED920; // 2 funcs. 1 out of z_actor
// Internal forward declarations
-void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx);
-Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx);
-Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx);
+void func_800BA8B8(PlayState* play, ActorContext* actorCtx);
+Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play);
+Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play);
void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, Actor** arg3, Player* player);
-s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW);
+s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW);
void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory);
-Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actorToRemove);
+Actor* Actor_RemoveFromCategory(PlayState* play, ActorContext* actorCtx, Actor* actorToRemove);
void Actor_PrintLists(ActorContext* actorCtx) {
ActorListEntry* actorList = &actorCtx->actorLists[0];
@@ -64,7 +65,7 @@ void ActorShape_Init(ActorShape* actorShape, f32 yOffset, ActorShadowFunc shadow
actorShape->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) {
if (actor->floorPoly != NULL) {
f32 dy = actor->world.pos.y - actor->floorHeight;
@@ -72,7 +73,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf
f32 shadowScale;
MtxF mtx;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C);
@@ -102,48 +103,48 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf
shadowScale *= actor->shape.shadowScale;
Matrix_Scale(actor->scale.x * shadowScale, 1.0f, actor->scale.z * shadowScale, MTXMODE_APPLY);
- gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, dlist);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
}
-void ActorShadow_DrawCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) {
+void ActorShadow_DrawCircle(Actor* actor, Lights* lights, PlayState* play) {
if (actor->bgCheckFlags & 0x400) {
- func_800B4AEC(globalCtx, actor, 50.0f);
+ func_800B4AEC(play, actor, 50.0f);
}
- ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, NULL);
+ ActorShadow_Draw(actor, lights, play, gCircleShadowDL, NULL);
}
-void ActorShadow_DrawSquare(Actor* actor, Lights* lights, GlobalContext* globalCtx) {
+void ActorShadow_DrawSquare(Actor* actor, Lights* lights, PlayState* play) {
if (actor->bgCheckFlags & 0x400) {
- func_800B4AEC(globalCtx, actor, 50.0f);
+ func_800B4AEC(play, actor, 50.0f);
}
- ActorShadow_Draw(actor, lights, globalCtx, gSquareShadowDL, NULL);
+ ActorShadow_Draw(actor, lights, play, gSquareShadowDL, NULL);
}
-void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, GlobalContext* globalCtx) {
+void ActorShadow_DrawWhiteCircle(Actor* actor, Lights* lights, PlayState* play) {
static Color_RGBA8 color = { 255, 255, 255, 255 };
- ActorShadow_Draw(actor, lights, globalCtx, gCircleShadowDL, &color);
+ ActorShadow_Draw(actor, lights, play, gCircleShadowDL, &color);
}
-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 lightNum, f32 shadowAlpha,
- f32 shadowScaleX, f32 shadowScaleZ) {
+void ActorShadow_DrawFoot(PlayState* play, Light* light, MtxF* arg2, s32 lightNum, f32 shadowAlpha, f32 shadowScaleX,
+ f32 shadowScaleZ) {
s32 pad;
s16 sp58;
f32 dir2;
f32 dir0;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, (u8)(CLAMP_MAX(lightNum * 1.3e-05f, 1.0f) * shadowAlpha));
@@ -156,13 +157,13 @@ void ActorShadow_DrawFoot(GlobalContext* globalCtx, Light* light, MtxF* arg2, s3
Matrix_RotateYS(sp58, MTXMODE_APPLY);
Matrix_Scale(shadowScaleX, 1.0f, shadowScaleX * shadowScaleZ, MTXMODE_APPLY);
- gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, gFootShadowDL);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx) {
+void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, PlayState* play) {
f32 distToFloor = actor->world.pos.y - actor->floorHeight;
if (distToFloor > 0.0f) {
@@ -177,13 +178,13 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
actor->shape.shadowScale *= 0.2f;
alphaRatio = distToFloor * 0.03f;
actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f);
- ActorShadow_Draw(actor, mapper, globalCtx, gCircleShadowDL, NULL);
+ ActorShadow_Draw(actor, mapper, play, gCircleShadowDL, NULL);
actor->scale.z = tmpScaleZ;
} else {
actor->shape.shadowScale *= 0.3f;
alphaRatio = (distToFloor - 20.0f) * 0.02f;
actor->shape.shadowAlpha = actor->shape.shadowAlpha * CLAMP_MAX(alphaRatio, 1.0f);
- ActorShadow_DrawCircle(actor, mapper, globalCtx);
+ ActorShadow_DrawCircle(actor, mapper, play);
}
actor->shape.shadowScale = shadowScale;
@@ -214,7 +215,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
feetPosPtr = actor->shape.feetPos;
floorHeightPtr = floorHeight;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C);
actor->shape.feetFloorFlags = 0;
@@ -222,7 +223,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
for (i = 0; i < ARRAY_COUNT(floorHeight); i++, spB8 >>= 1) {
feetPosPtr->y += 50.0f;
- *floorHeightPtr = func_80169100(globalCtx, &sp13C, &spF8, &bgId, feetPosPtr);
+ *floorHeightPtr = func_80169100(play, &sp13C, &spF8, &bgId, feetPosPtr);
feetPosPtr->y -= 50.0f;
distToFloor = feetPosPtr->y - *floorHeightPtr;
@@ -233,10 +234,10 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
actor->shape.feetFloorFlags |= spB8;
if ((actor->depthInWater < 0.0f) && (bgId == 0x32) && ((actor->shape.unk_17 & spB8) != 0)) {
- if (func_800C9C24(&globalCtx->colCtx, spF8, bgId, 1) != 0) {
+ if (func_800C9C24(&play->colCtx, spF8, bgId, 1) != 0) {
SkinMatrix_MtxFCopy(&sp13C, &spFC);
SkinMatrix_MulYRotation(&spFC, actor->shape.rot.y);
- EffFootmark_Add(globalCtx, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f),
+ EffFootmark_Add(play, &spFC, actor, i, feetPosPtr, (actor->shape.shadowScale * 0.3f),
IREG(88) + 80, IREG(89) + 60, IREG(90) + 40, 30000, 200, 60);
}
actor->shape.unk_17 &= ~spB8;
@@ -259,7 +260,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
if (lightNum > 0) {
lightNumMax += lightNum;
- ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX,
+ ActorShadow_DrawFoot(play, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX,
shadowScaleZ);
}
}
@@ -272,7 +273,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
ABS_ALT(lightPtr->l.dir[1])) -
(lightNumMax * 8);
if (lightNum > 0) {
- ActorShadow_DrawFoot(globalCtx, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX,
+ ActorShadow_DrawFoot(play, lightPtr, &sp13C, lightNum, shadowAlpha, shadowScaleX,
shadowScaleZ);
}
}
@@ -295,7 +296,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* mapper, GlobalContext* globalCtx
}
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
@@ -308,18 +309,18 @@ void Actor_SetFeetPos(Actor* actor, s32 limbIndex, s32 leftFootIndex, Vec3f* lef
}
}
-void func_800B4AEC(GlobalContext* globalCtx, Actor* actor, f32 y) {
+void func_800B4AEC(PlayState* play, Actor* actor, f32 y) {
s32 floorBgId;
f32 yPos = actor->world.pos.y;
actor->world.pos.y += y;
- actor->floorHeight = BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId,
- actor, &actor->world.pos);
+ actor->floorHeight =
+ BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &actor->floorPoly, &floorBgId, actor, &actor->world.pos);
actor->floorBgId = floorBgId;
actor->world.pos.y = yPos;
}
-void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) {
+void func_800B4B50(Actor* actor, Lights* mapper, PlayState* play) {
f32 spEC;
f32 temp_f12;
f32 shadowScaleZ;
@@ -335,7 +336,7 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) {
s32 lightNumMax;
if (actor->bgCheckFlags & 0x400) {
- func_800B4AEC(globalCtx, actor, 50.0f);
+ func_800B4AEC(play, actor, 50.0f);
}
if (actor->floorPoly != NULL) {
@@ -349,13 +350,13 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) {
actor->shape.shadowScale *= 0.3f;
temp_f12 = (spEC - 20.0f) * 0.02f;
actor->shape.shadowAlpha = CLAMP_MAX(temp_f12, 1.0f) * actor->shape.shadowAlpha;
- ActorShadow_DrawCircle(actor, mapper, globalCtx);
+ ActorShadow_DrawCircle(actor, mapper, play);
actor->shape.shadowScale = temp_f20;
actor->shape.shadowAlpha = temp_v0;
} else if (spEC >= -1.0f) {
numLights = mapper->numLights - 2;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C);
@@ -371,7 +372,7 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) {
lightNum = (phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2]) * ABS_ALT(phi_s0->l.dir[1]);
if (lightNum > 0) {
lightNumMax += lightNum;
- ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ);
+ ActorShadow_DrawFoot(play, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ);
}
}
}
@@ -381,17 +382,17 @@ void func_800B4B50(Actor* actor, Lights* mapper, GlobalContext* globalCtx) {
lightNum = ((phi_s0->l.col[0] + phi_s0->l.col[1] + phi_s0->l.col[2]) * ABS_ALT(phi_s0->l.dir[1])) -
(8 * lightNumMax);
if (lightNum > 0) {
- ActorShadow_DrawFoot(globalCtx, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ);
+ ActorShadow_DrawFoot(play, phi_s0, &sp94, lightNum, temp_f22, temp_f24, shadowScaleZ);
}
}
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
}
-void Actor_GetProjectedPos(GlobalContext* globalCtx, Vec3f* arg1, Vec3f* arg2, f32* arg3) {
- SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, arg1, arg2, arg3);
+void Actor_GetProjectedPos(PlayState* play, Vec3f* arg1, Vec3f* arg2, f32* arg3) {
+ SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, arg1, arg2, arg3);
if (*arg3 < 1.0f) {
*arg3 = 1.0f;
} else {
@@ -421,12 +422,12 @@ TatlColor sTatlColorList[] = {
{ { 0, 255, 0, 255 }, { 0, 255, 0, 0 } }
};
-void func_800B4F78(TargetContext* targetCtx, s32 type, GlobalContext* globalCtx) {
+void func_800B4F78(TargetContext* targetCtx, s32 type, PlayState* play) {
TatlColor* tatlColorEntry;
s32 i;
TargetContextEntry* targetEntry;
- Math_Vec3f_Copy(&targetCtx->targetCenterPos, &globalCtx->view.eye);
+ Math_Vec3f_Copy(&targetCtx->targetCenterPos, &play->view.eye);
targetCtx->unk48 = 0x100;
tatlColorEntry = &sTatlColorList[type];
targetCtx->unk44 = 500.0f;
@@ -441,7 +442,7 @@ void func_800B4F78(TargetContext* targetCtx, s32 type, GlobalContext* globalCtx)
}
}
-void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, GlobalContext* globalCtx) {
+void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, PlayState* play) {
targetCtx->unk0.x = actor->focus.pos.x;
targetCtx->unk0.y = actor->focus.pos.y + (actor->targetArrowOffset * actor->scale.y);
targetCtx->unk0.z = actor->focus.pos.z;
@@ -456,7 +457,7 @@ void Target_SetColors(TargetContext* targetCtx, Actor* actor, s32 type, GlobalCo
targetCtx->fairyOuter.a = sTatlColorList[type].outer.a;
}
-void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalContext* globalCtx) {
+void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, PlayState* play) {
targetCtx->bgmEnemy = NULL;
targetCtx->unk8C = NULL;
targetCtx->targetedActor = NULL;
@@ -464,17 +465,17 @@ void Actor_TargetContextInit(TargetContext* targetCtx, Actor* actor, GlobalConte
targetCtx->unk4B = 0;
targetCtx->unk4C = 0;
targetCtx->unk40 = 0.0f;
- Target_SetColors(targetCtx, actor, actor->category, globalCtx);
- func_800B4F78(targetCtx, actor->category, globalCtx);
+ Target_SetColors(targetCtx, actor, actor->category, play);
+ func_800B4F78(targetCtx, actor->category, play);
}
-void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) {
- Player* player = GET_PLAYER(globalCtx);
+void Actor_DrawZTarget(TargetContext* targetCtx, PlayState* play) {
+ Player* player = GET_PLAYER(play);
if (!(player->stateFlags1 & 0x300006C2)) {
Actor* actor = targetCtx->targetedActor;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
if (targetCtx->unk48 != 0) {
TargetContextEntry* entry;
s16 alpha = 255;
@@ -504,7 +505,7 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) {
alpha = targetCtx->unk48;
}
- Actor_GetProjectedPos(globalCtx, &targetCtx->targetCenterPos, &spBC, &spB4);
+ Actor_GetProjectedPos(play, &targetCtx->targetCenterPos, &spBC, &spB4);
spBC.x = (160 * (spBC.x * spB4)) * var1;
spBC.x = CLAMP(spBC.x, -320.0f, 320.0f);
@@ -546,8 +547,7 @@ void Actor_DrawZTarget(TargetContext* targetCtx, GlobalContext* globalCtx) {
Matrix_RotateZS(0x4000, MTXMODE_APPLY);
Matrix_Push();
Matrix_Translate(entry->unkC, entry->unkC, 0.0f, MTXMODE_APPLY);
- gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
- G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(OVERLAY_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(OVERLAY_DISP++, gZTargetLockOnTriangleDL);
Matrix_Pop();
}
@@ -570,22 +570,22 @@ void Actor_DrawZTarget(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_RotateYS((globalCtx->gameplayFrames * 3000), MTXMODE_APPLY);
+ Matrix_RotateYS((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, color->inner.r, color->inner.g, color->inner.b, 255);
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, gZTargetArrowDL);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
// OoT: func_8002C7BC
void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+ PlayState* play = (PlayState*)gameState;
Actor* sp68 = NULL;
s32 category;
Vec3f sp58;
@@ -594,7 +594,7 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
if ((player->unk_730 != 0) && (player->unk_AE3[player->unk_ADE] == 2)) {
targetCtx->unk_94 = NULL;
} else {
- func_800BB8EC(gameState, &globalCtx->actorCtx, &sp68, &D_801ED920, player);
+ func_800BB8EC(gameState, &play->actorCtx, &sp68, &D_801ED920, player);
targetCtx->unk_94 = sp68;
}
@@ -637,11 +637,11 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
targetCtx->unk0.y += y * temp_f0;
targetCtx->unk0.z += z * temp_f0;
} else {
- Target_SetColors(targetCtx, sp68, category, globalCtx);
+ Target_SetColors(targetCtx, sp68, category, play);
}
if (actor != NULL && targetCtx->unk4B == 0) {
- Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp58, &sp54);
+ Actor_GetProjectedPos(play, &actor->focus.pos, &sp58, &sp54);
if ((sp58.z <= 0.0f) || (fabsf(sp58.x * sp54) >= 1.0f) || (fabsf(sp58.y * sp54) >= 1.0f)) {
actor = NULL;
}
@@ -651,7 +651,7 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
if (actor != targetCtx->targetedActor) {
s32 sfxId;
- func_800B4F78(targetCtx, actor->category, globalCtx);
+ func_800B4F78(targetCtx, actor->category, play);
targetCtx->targetedActor = actor;
@@ -693,9 +693,9 @@ void func_800B5814(TargetContext* targetCtx, Player* player, Actor* actor, GameS
/**
* Tests if current scene switch flag is set.
*/
-s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) {
+s32 Flags_GetSwitch(PlayState* play, s32 flag) {
if (flag >= 0 && flag < 0x80) {
- return globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F));
+ return play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F));
}
return 0;
}
@@ -703,97 +703,97 @@ s32 Flags_GetSwitch(GlobalContext* globalCtx, s32 flag) {
/**
* Sets current scene switch flag.
*/
-void Flags_SetSwitch(GlobalContext* globalCtx, s32 flag) {
+void Flags_SetSwitch(PlayState* play, s32 flag) {
if (flag >= 0 && flag < 0x80) {
- globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F);
+ play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F);
}
}
/**
* Unsets current scene switch flag.
*/
-void Flags_UnsetSwitch(GlobalContext* globalCtx, s32 flag) {
+void Flags_UnsetSwitch(PlayState* play, s32 flag) {
if (flag >= 0 && flag < 0x80) {
- globalCtx->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F));
+ play->actorCtx.flags.switches[(flag & ~0x1F) >> 5] &= ~(1 << (flag & 0x1F));
}
}
/**
* 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);
}
/**
* Overrides the all the chest flags.
*/
-void Flags_SetAllTreasure(GlobalContext* globalCtx, s32 flag) {
- globalCtx->actorCtx.flags.chest = flag;
+void Flags_SetAllTreasure(PlayState* play, s32 flag) {
+ play->actorCtx.flags.chest = flag;
}
/**
* Returns all the chest flags.
*/
-s32 Flags_GetAllTreasure(GlobalContext* globalCtx) {
- return globalCtx->actorCtx.flags.chest;
+s32 Flags_GetAllTreasure(PlayState* play) {
+ return play->actorCtx.flags.chest;
}
/**
* Tests if current scene clear flag is set.
*/
-s32 Flags_GetClear(GlobalContext* globalCtx, s32 roomNumber) {
- return globalCtx->actorCtx.flags.clearedRoom & (1 << roomNumber);
+s32 Flags_GetClear(PlayState* play, s32 roomNumber) {
+ return play->actorCtx.flags.clearedRoom & (1 << roomNumber);
}
/**
* Sets current scene clear flag.
*/
-void Flags_SetClear(GlobalContext* globalCtx, s32 roomNumber) {
- globalCtx->actorCtx.flags.clearedRoom |= (1 << roomNumber);
+void Flags_SetClear(PlayState* play, s32 roomNumber) {
+ play->actorCtx.flags.clearedRoom |= (1 << roomNumber);
}
/**
* Unsets current scene clear flag.
*/
-void Flags_UnsetClear(GlobalContext* globalCtx, s32 roomNumber) {
- globalCtx->actorCtx.flags.clearedRoom &= ~(1 << roomNumber);
+void Flags_UnsetClear(PlayState* play, s32 roomNumber) {
+ play->actorCtx.flags.clearedRoom &= ~(1 << roomNumber);
}
/**
* Tests if current scene temp clear flag is set.
*/
-s32 Flags_GetClearTemp(GlobalContext* globalCtx, s32 roomNumber) {
- return globalCtx->actorCtx.flags.clearedRoomTemp & (1 << roomNumber);
+s32 Flags_GetClearTemp(PlayState* play, s32 roomNumber) {
+ return play->actorCtx.flags.clearedRoomTemp & (1 << roomNumber);
}
/**
* Sets current scene temp clear flag.
*/
-void Flags_SetClearTemp(GlobalContext* globalCtx, s32 roomNumber) {
- globalCtx->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber);
+void Flags_SetClearTemp(PlayState* play, s32 roomNumber) {
+ play->actorCtx.flags.clearedRoomTemp |= (1 << roomNumber);
}
/**
* Unsets current scene temp clear flag.
*/
-void Flags_UnsetClearTemp(GlobalContext* globalCtx, s32 roomNumber) {
- globalCtx->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber);
+void Flags_UnsetClearTemp(PlayState* play, s32 roomNumber) {
+ play->actorCtx.flags.clearedRoomTemp &= ~(1 << roomNumber);
}
/**
* Tests if current scene collectible flag is set.
*/
-s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) {
+s32 Flags_GetCollectible(PlayState* play, s32 flag) {
if (flag > 0 && flag < 0x80) {
- return globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F));
+ return play->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] & (1 << (flag & 0x1F));
}
return 0;
}
@@ -801,9 +801,9 @@ s32 Flags_GetCollectible(GlobalContext* globalCtx, s32 flag) {
/**
* Sets current scene collectible flag.
*/
-void Flags_SetCollectible(GlobalContext* globalCtx, s32 flag) {
+void Flags_SetCollectible(PlayState* play, s32 flag) {
if (flag > 0 && flag < 0x80) {
- globalCtx->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F);
+ play->actorCtx.flags.collectible[(flag & ~0x1F) >> 5] |= 1 << (flag & 0x1F);
}
}
@@ -898,8 +898,8 @@ void TitleCard_Draw(GameState* gameState, TitleCardContext* titleCtx) {
/* End of TitleCard section */
// unused
-s32 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
- if ((globalCtx->actorCtx.titleCtxt.delayTimer != 0) || (globalCtx->actorCtx.titleCtxt.alpha != 0)) {
+s32 func_800B6434(PlayState* play, TitleCardContext* titleCtx) {
+ if ((play->actorCtx.titleCtxt.delayTimer != 0) || (play->actorCtx.titleCtxt.alpha != 0)) {
titleCtx->durationTimer = 0;
titleCtx->delayTimer = 0;
return false;
@@ -907,57 +907,57 @@ s32 func_800B6434(GlobalContext* globalCtx, TitleCardContext* titleCtx) {
return true;
}
-void func_800B6468(GlobalContext* globalCtx) {
- globalCtx->actorCtx.unk1F5 = 0;
+void func_800B6468(PlayState* play) {
+ play->actorCtx.unk1F5 = 0;
}
-void func_800B6474(GlobalContext* globalCtx) {
- if (globalCtx->actorCtx.unk1F5 != 0) {
- globalCtx->actorCtx.unk1F5--;
+void func_800B6474(PlayState* play) {
+ if (play->actorCtx.unk1F5 != 0) {
+ play->actorCtx.unk1F5--;
}
}
-s32 func_800B648C(GlobalContext* globalCtx, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) {
- if ((globalCtx->actorCtx.unk1F5 != 0) && (arg3 < globalCtx->actorCtx.unk1F8)) {
+s32 func_800B648C(PlayState* play, s32 arg1, s32 arg2, f32 arg3, Vec3f* arg4) {
+ if ((play->actorCtx.unk1F5 != 0) && (arg3 < play->actorCtx.unk1F8)) {
return false;
}
- globalCtx->actorCtx.unk1F4 = arg1;
- globalCtx->actorCtx.unk1F5 = arg2;
- globalCtx->actorCtx.unk1F8 = arg3;
- Math_Vec3f_Copy(&globalCtx->actorCtx.unk1FC, arg4);
+ play->actorCtx.unk1F4 = arg1;
+ play->actorCtx.unk1F5 = arg2;
+ play->actorCtx.unk1F8 = arg3;
+ Math_Vec3f_Copy(&play->actorCtx.unk1FC, arg4);
return true;
}
-f32 func_800B64FC(GlobalContext* globalCtx, f32 arg1, Vec3f* arg2, u32* arg3) {
+f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3) {
f32 temp_f8;
- if ((globalCtx->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) {
+ if ((play->actorCtx.unk1F5 == 0) || (arg1 == 0.0f)) {
return -1.0f;
}
- temp_f8 = Math_Vec3f_DistXYZ(&globalCtx->actorCtx.unk1FC, arg2) / arg1;
- *arg3 = globalCtx->actorCtx.unk1F4;
- return globalCtx->actorCtx.unk1F8 - temp_f8;
+ temp_f8 = Math_Vec3f_DistXYZ(&play->actorCtx.unk1FC, arg2) / arg1;
+ *arg3 = play->actorCtx.unk1F4;
+ return play->actorCtx.unk1F8 - temp_f8;
}
/**
- * Initializes an element of the `globalCtx->actorCtx.unk_20C` array to the `arg2` pointer, or allocates one using the
+ * Initializes an element of the `play->actorCtx.unk_20C` array to the `arg2` pointer, or allocates one using the
* `size` argument in case `arg2` is NULL. This element is associated to an `id`
*
* In success returns the allocated pointer if `arg2` was NULL or the `arg2` pointer otherwise
- * In failure (There's no space left in `globalCtx->actorCtx.unk_20C` or an allocation error happened) returns NULL
+ * In failure (There's no space left in `play->actorCtx.unk_20C` or an allocation error happened) returns NULL
*
* Note there are no duplicated id checks.
*
* Used only by EnLiftNuts.
*/
-void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size) {
- ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C;
+void* func_800B6584(PlayState* play, s16 id, void* arg2, size_t size) {
+ ActorContext_unk_20C* entry = play->actorCtx.unk_20C;
s32 i;
- for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) {
+ for (i = 0; i < ARRAY_COUNT(play->actorCtx.unk_20C); i++) {
if (entry->id == 0) {
if (arg2 == NULL) {
arg2 = ZeldaArena_Malloc(size);
@@ -979,18 +979,18 @@ void* func_800B6584(GlobalContext* globalCtx, s16 id, void* arg2, size_t size) {
}
/**
- * Frees the first element of `globalCtx->actorCtx.unk_20C` with id `id`.
+ * Frees the first element of `play->actorCtx.unk_20C` with id `id`.
*
* If success, the free'd pointer is returned.
* If failure, NULL is returned.
*
* Used only by EnLiftNuts.
*/
-void* func_800B6608(GlobalContext* globalCtx, s16 id) {
- ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C;
+void* func_800B6608(PlayState* play, s16 id) {
+ ActorContext_unk_20C* entry = play->actorCtx.unk_20C;
s32 i;
- for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) {
+ for (i = 0; i < ARRAY_COUNT(play->actorCtx.unk_20C); i++) {
if (id == entry->id) {
entry->id = 0;
if (entry->isDynamicallyInitialised) {
@@ -1012,11 +1012,11 @@ void* func_800B6608(GlobalContext* globalCtx, s16 id) {
*
* Used only by EnLiftNuts.
*/
-void* func_800B6680(GlobalContext* globalCtx, s16 id) {
- ActorContext_unk_20C* entry = globalCtx->actorCtx.unk_20C;
+void* func_800B6680(PlayState* play, s16 id) {
+ ActorContext_unk_20C* entry = play->actorCtx.unk_20C;
s32 i;
- for (i = 0; i < ARRAY_COUNT(globalCtx->actorCtx.unk_20C); i++) {
+ for (i = 0; i < ARRAY_COUNT(play->actorCtx.unk_20C); i++) {
if (id == entry->id) {
return entry->ptr;
}
@@ -1061,11 +1061,11 @@ void Actor_SetScale(Actor* actor, f32 scale) {
actor->scale.x = scale;
}
-void Actor_SetObjectDependency(GlobalContext* globalCtx, Actor* actor) {
- gSegments[0x06] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[actor->objBankIndex].segment);
+void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
+ gSegments[0x06] = PHYSICAL_TO_VIRTUAL(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);
@@ -1085,17 +1085,17 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) {
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) {
if (actor->init == NULL) {
if (actor->destroy != NULL) {
- actor->destroy(actor, globalCtx);
+ actor->destroy(actor, play);
actor->destroy = NULL;
}
}
@@ -1280,8 +1280,8 @@ f32 Actor_HeightDiff(Actor* actor1, Actor* actor2) {
/**
* Sets the current and new inputs.
*/
-void func_800B6F20(GlobalContext* globalCtx, Input* input, f32 magnitude, s16 baseYaw) {
- s16 relativeYaw = baseYaw - Camera_GetInputDirYaw(GET_ACTIVE_CAM(globalCtx));
+void func_800B6F20(PlayState* play, Input* input, f32 magnitude, s16 baseYaw) {
+ s16 relativeYaw = baseYaw - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play));
input->cur.stick_x = -Math_SinS(relativeYaw) * magnitude;
input->rel.stick_x = input->cur.stick_x;
@@ -1332,23 +1332,23 @@ s32 func_800B7128(Player* player) {
return func_800B7118(player) && player->unk_ACC;
}
-s32 func_800B715C(GlobalContext* globalCtx) {
- Player* player = GET_PLAYER(globalCtx);
+s32 func_800B715C(PlayState* play) {
+ Player* player = GET_PLAYER(play);
return player->stateFlags2 & 0x8;
}
-void Actor_SetCameraHorseSetting(GlobalContext* globalCtx, Player* player) {
- if ((globalCtx->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) {
+void Actor_SetCameraHorseSetting(PlayState* play, Player* player) {
+ if ((play->roomCtx.currRoom.unk3 != 4) && (player->actor.id == ACTOR_PLAYER)) {
EnHorse* rideActor = (EnHorse*)player->rideActor;
if ((rideActor != NULL) && !(rideActor->unk_1EC & 0x10)) {
- func_800DFAC8(Play_GetCamera(globalCtx, CAM_ID_MAIN), 4);
+ func_800DFAC8(Play_GetCamera(play, CAM_ID_MAIN), 4);
}
}
}
-void Actor_MountHorse(GlobalContext* globalCtx, Player* player, Actor* horse) {
+void Actor_MountHorse(PlayState* play, Player* player, Actor* horse) {
player->rideActor = horse;
player->stateFlags1 |= 0x800000;
horse->child = &player->actor;
@@ -1362,8 +1362,8 @@ void func_800B722C(GameState* gameState, Player* player) {
func_800F40A0(gameState, player);
}
-s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode) {
- Player* player = GET_PLAYER(globalCtx);
+s32 func_800B724C(PlayState* play, Actor* actor, u8 csMode) {
+ Player* player = GET_PLAYER(play);
if ((player->csMode == 5) || ((csMode == 6) && (player->csMode == 0))) {
return false;
@@ -1375,10 +1375,10 @@ s32 func_800B724C(GlobalContext* globalCtx, Actor* actor, u8 csMode) {
return true;
}
-u32 func_800B7298(GlobalContext* globalCtx, Actor* actor, u8 csMode) {
- Player* player = GET_PLAYER(globalCtx);
+u32 func_800B7298(PlayState* play, Actor* actor, u8 csMode) {
+ Player* player = GET_PLAYER(play);
- if (func_800B724C(globalCtx, actor, csMode)) {
+ if (func_800B724C(play, actor, csMode)) {
player->unk_3BA = 1;
return true;
}
@@ -1400,8 +1400,8 @@ void func_800B72F8(DynaPolyActor* dyna, f32 extraPushForce, s16 yRotation) {
* Check if the player is facing the specified actor.
* The maximum angle difference that qualifies as "facing" is specified by `maxAngleDiff`.
*/
-s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, GlobalContext* globalCtx) {
- Player* player = GET_PLAYER(globalCtx);
+s32 Player_IsFacingActor(Actor* actor, s16 maxAngleDiff, PlayState* play) {
+ Player* player = GET_PLAYER(play);
s16 yawDiff = BINANG_ADD(actor->yawTowardsPlayer, 0x8000) - player->actor.shape.rot.y;
if (ABS_ALT(yawDiff) < maxAngleDiff) {
@@ -1511,14 +1511,13 @@ s32 func_800B761C(Actor* actor, f32 arg1, s32 arg2) {
return true;
}
-s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags) {
+s32 func_800B7678(PlayState* play, Actor* actor, Vec3f* pos, s32 flags) {
f32 distToFloor;
s32 bgId;
pos->y += (flags & 0x800) ? 10.0f : 50.0f;
- actor->floorHeight =
- BgCheck_EntityRaycastFloor5_2(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &bgId, actor, pos);
+ actor->floorHeight = BgCheck_EntityRaycastFloor5_2(play, &play->colCtx, &actor->floorPoly, &bgId, actor, pos);
actor->bgCheckFlags &= ~(0x80 | 0x04 | 0x02);
if (actor->floorHeight <= BGCHECK_Y_MIN) {
return func_800B761C(actor, BGCHECK_Y_MIN, flags);
@@ -1553,7 +1552,7 @@ s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags)
}
actor->bgCheckFlags |= 1;
- BgCheck2_AttachToMesh(&globalCtx->colCtx, actor, (s32)actor->floorBgId);
+ BgCheck2_AttachToMesh(&play->colCtx, actor, (s32)actor->floorBgId);
}
} else {
return func_800B761C(actor, distToFloor, flags);
@@ -1562,14 +1561,14 @@ s32 func_800B7678(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, s32 flags)
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, u32 flags) {
f32 sp94 = actor->world.pos.y - actor->prevPos.y;
s32 pad;
Vec3f pos;
if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) {
- BgCheck2_UpdateActorAttachedToMesh(&globalCtx->colCtx, actor->floorBgId, actor);
+ BgCheck2_UpdateActorAttachedToMesh(&play->colCtx, actor->floorBgId, actor);
}
if (flags & 1) {
@@ -1577,10 +1576,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
actor->bgCheckFlags &= ~0x1000;
if ((!(flags & 0x80) &&
- (BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius,
+ (BgCheck_EntitySphVsWall3(&play->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius,
&actor->wallPoly, &bgId, actor, wallCheckHeight))) ||
((flags & 0x80) &&
- (BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius,
+ (BgCheck_EntitySphVsWall4(&play->colCtx, &pos, &actor->world.pos, &actor->prevPos, wallCheckRadius,
&actor->wallPoly, &bgId, actor, wallCheckHeight)))) {
CollisionPoly* sp7C = actor->wallPoly;
@@ -1605,7 +1604,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
f32 y;
pos.y = actor->prevPos.y + 4.0f;
- if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0,
+ if (BgCheck_EntityCheckCeiling(&play->colCtx, &y, &pos, (ceilingCheckHeight + sp94) - 4.0f, &D_801ED8B0,
&D_801ED8B4, actor)) {
actor->bgCheckFlags |= 0x10;
actor->world.pos.y = (y + sp94) - 4.0f;
@@ -1618,11 +1617,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
f32 y;
pos.y = actor->prevPos.y;
- func_800B7678(globalCtx, actor, &pos, flags);
+ func_800B7678(play, actor, &pos, flags);
y = actor->world.pos.y;
- if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y,
- &waterbox)) {
+ if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, &waterbox)) {
actor->depthInWater = y - actor->world.pos.y;
if (actor->depthInWater <= 0.0f) {
actor->bgCheckFlags &= ~(0x40 | 0x20);
@@ -1635,9 +1633,9 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
sp64.y = y;
sp64.z = actor->world.pos.z;
- EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 0);
- EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 4);
- EffectSsGRipple_Spawn(globalCtx, &sp64, 100, 500, 8);
+ EffectSsGRipple_Spawn(play, &sp64, 100, 500, 0);
+ EffectSsGRipple_Spawn(play, &sp64, 100, 500, 4);
+ EffectSsGRipple_Spawn(play, &sp64, 100, 500, 8);
}
} else {
actor->bgCheckFlags &= ~0x40;
@@ -1652,8 +1650,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
WaterBox* waterbox;
f32 y = actor->world.pos.y;
- if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->world.pos.x, actor->world.pos.z, &y,
- &waterbox)) {
+ if (WaterBox_GetSurface1(play, &play->colCtx, actor->world.pos.x, actor->world.pos.z, &y, &waterbox)) {
actor->depthInWater = y - actor->world.pos.y;
if (actor->depthInWater < 0.0f) {
@@ -1667,9 +1664,9 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
sp50.y = y;
sp50.z = actor->world.pos.z;
- EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 0);
- EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 4);
- EffectSsGRipple_Spawn(globalCtx, &sp50, 100, 500, 8);
+ EffectSsGRipple_Spawn(play, &sp50, 100, 500, 0);
+ EffectSsGRipple_Spawn(play, &sp50, 100, 500, 4);
+ EffectSsGRipple_Spawn(play, &sp50, 100, 500, 8);
}
} else {
actor->bgCheckFlags &= ~0x40;
@@ -1721,41 +1718,41 @@ Hilite* Hilite_DrawXlu(Vec3f* object, Vec3f* eye, Vec3f* lightDir, GraphicsConte
return hilite;
}
-void func_800B8050(Actor* actor, GlobalContext* globalCtx, s32 flag) {
- Hilite* hilite = func_800BCBF4(&actor->world.pos, globalCtx);
+void func_800B8050(Actor* actor, PlayState* play, s32 flag) {
+ Hilite* hilite = func_800BCBF4(&actor->world.pos, play);
if (flag != 0) {
Gfx* displayListHead;
- Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx));
+ Gfx* displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx));
displayListHead = displayList;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10);
gSPEndDisplayList(displayListHead);
gSPSegment(POLY_OPA_DISP++, 0x07, displayList);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
-void func_800B8118(Actor* actor, GlobalContext* globalCtx, s32 flag) {
- Hilite* hilite = func_800BCC68(&actor->world.pos, globalCtx);
+void func_800B8118(Actor* actor, PlayState* play, s32 flag) {
+ Hilite* hilite = func_800BCC68(&actor->world.pos, play);
if (flag != 0) {
Gfx* displayListHead;
- Gfx* displayList = GRAPH_ALLOC(globalCtx->state.gfxCtx, 2 * sizeof(Gfx));
+ Gfx* displayList = GRAPH_ALLOC(play->state.gfxCtx, 2 * sizeof(Gfx));
displayListHead = displayList;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gDPSetHilite1Tile(displayListHead++, 1, hilite, 0x10, 0x10);
gSPEndDisplayList(displayListHead);
gSPSegment(POLY_XLU_DISP++, 0x07, displayList);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
@@ -1856,11 +1853,11 @@ s32 Actor_ProcessTalkRequest(Actor* actor, GameState* gameState) {
// Actor_PickUpExchange? Seems to be called with exchangeItemId -1 if the same actor used Actor_PickUp
// This function is also used to toggle the "Speak" action on the A button
-s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId) {
- Player* player = GET_PLAYER(globalCtx);
+s32 func_800B8500(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId) {
+ Player* player = GET_PLAYER(play);
if ((player->actor.flags & ACTOR_FLAG_100) ||
- ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(&globalCtx->state)) ||
+ ((exchangeItemId > EXCH_ITEM_NONE) && Player_InCsMode(&play->state)) ||
(!actor->isTargeted &&
((fabsf(actor->playerHeightRel) > fabsf(yRange)) || ((actor->xzDistToPlayer > player->targetActorDistance)) ||
(xzRange < actor->xzDistToPlayer)))) {
@@ -1875,22 +1872,22 @@ s32 func_800B8500(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
return true;
}
-s32 func_800B85E0(Actor* actor, GlobalContext* globalCtx, f32 radius, s32 exchangeItemId) {
- return func_800B8500(actor, globalCtx, radius, radius, exchangeItemId);
+s32 func_800B85E0(Actor* actor, PlayState* play, f32 radius, s32 exchangeItemId) {
+ return func_800B8500(actor, play, radius, radius, exchangeItemId);
}
-s32 func_800B8614(Actor* actor, GlobalContext* globalCtx, f32 radius) {
- return func_800B85E0(actor, globalCtx, radius, EXCH_ITEM_NONE);
+s32 func_800B8614(Actor* actor, PlayState* play, f32 radius) {
+ return func_800B85E0(actor, play, radius, EXCH_ITEM_NONE);
}
-s32 func_800B863C(Actor* actor, GlobalContext* globalCtx) {
+s32 func_800B863C(Actor* actor, PlayState* play) {
f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f;
- return func_800B8614(actor, globalCtx, cylRadius);
+ return func_800B8614(actor, play, cylRadius);
}
-s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) {
- if (Message_GetState(&globalCtx->msgCtx) == 2) {
+s32 Actor_TextboxIsClosing(Actor* actor, PlayState* play) {
+ if (Message_GetState(&play->msgCtx) == 2) {
actor->flags &= ~ACTOR_FLAG_100;
return true;
}
@@ -1902,9 +1899,9 @@ s32 Actor_TextboxIsClosing(Actor* actor, GlobalContext* globalCtx) {
* Changes the actor the Player is focussing on
* Fails if Player is not already focussing on an actor or in a talking state
*/
-s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2) {
+s32 Actor_ChangeFocus(Actor* actor1, PlayState* play, Actor* actor2) {
Actor* targetActor;
- Player* player = GET_PLAYER(globalCtx);
+ Player* player = GET_PLAYER(play);
targetActor = player->targetActor;
@@ -1917,8 +1914,8 @@ s32 Actor_ChangeFocus(Actor* actor1, GlobalContext* globalCtx, Actor* actor2) {
return false;
}
-s32 Player_GetExchangeItemId(GlobalContext* globalCtx) {
- Player* player = GET_PLAYER(globalCtx);
+s32 Player_GetExchangeItemId(PlayState* play) {
+ Player* player = GET_PLAYER(play);
return player->exchangeItemId;
}
@@ -1933,10 +1930,10 @@ s32 func_800B8718(Actor* actor, GameState* gameState) {
}
// Similar to func_800B8500
-s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange) {
- Player* player = GET_PLAYER(globalCtx);
+s32 func_800B874C(Actor* actor, PlayState* play, f32 xzRange, f32 yRange) {
+ Player* player = GET_PLAYER(play);
- if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(&globalCtx->state) ||
+ if ((player->actor.flags & ACTOR_FLAG_20000000) || Player_InCsMode(&play->state) ||
(yRange < fabsf(actor->playerHeightRel)) || ((player->unk_A94 < actor->xzDistToPlayer)) ||
(xzRange < actor->xzDistToPlayer)) {
return false;
@@ -1947,44 +1944,44 @@ s32 func_800B874C(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
return true;
}
-s32 func_800B8804(Actor* actor, GlobalContext* globalCtx, f32 xzRange) {
- return func_800B874C(actor, globalCtx, xzRange, 20.0f);
+s32 func_800B8804(Actor* actor, PlayState* play, f32 xzRange) {
+ return func_800B874C(actor, play, xzRange, 20.0f);
}
-s32 func_800B882C(Actor* actor, GlobalContext* globalCtx) {
+s32 func_800B882C(Actor* actor, PlayState* play) {
f32 cylRadius = actor->colChkInfo.cylRadius + 50.0f;
- return func_800B8804(actor, globalCtx, cylRadius);
+ return func_800B8804(actor, play, cylRadius);
}
-s32 func_800B886C(Actor* actor, GlobalContext* globalCtx) {
- if (!(GET_PLAYER(globalCtx)->actor.flags & ACTOR_FLAG_20000000)) {
+s32 func_800B886C(Actor* actor, PlayState* play) {
+ if (!(GET_PLAYER(play)->actor.flags & ACTOR_FLAG_20000000)) {
return true;
}
return false;
}
-void Actor_GetScreenPos(GlobalContext* globalCtx, Actor* actor, s16* x, s16* y) {
+void Actor_GetScreenPos(PlayState* play, Actor* actor, s16* x, s16* y) {
Vec3f projectedPos;
f32 w;
- Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &projectedPos, &w);
+ Actor_GetProjectedPos(play, &actor->focus.pos, &projectedPos, &w);
*x = (projectedPos.x * w * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2);
*y = (projectedPos.y * w * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2);
}
-s32 func_800B8934(GlobalContext* globalCtx, Actor* actor) {
+s32 func_800B8934(PlayState* play, Actor* actor) {
Vec3f sp2C;
f32 sp28;
s32 pad[2];
- Actor_GetProjectedPos(globalCtx, &actor->focus.pos, &sp2C, &sp28);
+ Actor_GetProjectedPos(play, &actor->focus.pos, &sp2C, &sp28);
return (sp2C.x * sp28 >= -1.0f) && (sp2C.x * sp28 <= 1.0f) && (sp2C.y * sp28 >= -1.0f) && (sp2C.y * sp28 <= 1.0f);
}
-s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) {
+s32 Actor_HasParent(Actor* actor, PlayState* play) {
if (actor->parent != NULL) {
return true;
} else {
@@ -1999,8 +1996,8 @@ s32 Actor_HasParent(Actor* actor, GlobalContext* globalCtx) {
* GI_NONE is usually used as a special case to lift an actor
* GI_MAX is usually used to catch an actor in a bottle
*/
-s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRange, f32 yRange) {
- Player* player = GET_PLAYER(globalCtx);
+s32 Actor_PickUp(Actor* actor, PlayState* play, s32 getItemId, f32 xzRange, f32 yRange) {
+ Player* player = GET_PLAYER(play);
if (!(player->stateFlags1 & 0x3C7080) && Player_GetExplosiveHeld(player) < 0) {
if ((actor->xzDistToPlayer <= xzRange) && (fabsf(actor->playerHeightRel) <= fabsf(yRange))) {
@@ -2018,7 +2015,7 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa
player->getItemDirection = absYawDiff;
if ((getItemId > GI_NONE) && (getItemId < GI_MAX)) {
- ActorCutscene_SetIntentToPlay(globalCtx->playerActorCsIds[1]);
+ ActorCutscene_SetIntentToPlay(play->playerActorCsIds[1]);
}
return true;
@@ -2030,19 +2027,19 @@ s32 Actor_PickUp(Actor* actor, GlobalContext* globalCtx, s32 getItemId, f32 xzRa
return false;
}
-s32 Actor_PickUpNearby(Actor* actor, GlobalContext* globalCtx, s32 getItemId) {
- return Actor_PickUp(actor, globalCtx, getItemId, 50.0f, 10.0f);
+s32 Actor_PickUpNearby(Actor* actor, PlayState* play, s32 getItemId) {
+ return Actor_PickUp(actor, play, getItemId, 50.0f, 10.0f);
}
-s32 Actor_LiftActor(Actor* actor, GlobalContext* globalCtx) {
- return Actor_PickUpNearby(actor, globalCtx, GI_NONE);
+s32 Actor_LiftActor(Actor* actor, PlayState* play) {
+ return Actor_PickUpNearby(actor, play, GI_NONE);
}
-s32 Actor_PickUpFar(Actor* actor, GlobalContext* globalCtx, s32 getItemId) {
- return Actor_PickUp(actor, globalCtx, getItemId, 9999.9f, 9999.9f);
+s32 Actor_PickUpFar(Actor* actor, PlayState* play, s32 getItemId) {
+ return Actor_PickUp(actor, play, getItemId, 9999.9f, 9999.9f);
}
-s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) {
+s32 Actor_HasNoParent(Actor* actor, PlayState* play) {
if (actor->parent == NULL) {
return true;
}
@@ -2050,7 +2047,7 @@ s32 Actor_HasNoParent(Actor* actor, GlobalContext* globalCtx) {
return false;
}
-void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) {
+void func_800B8C20(Actor* actorA, Actor* actorB, PlayState* play) {
Actor* parent = actorA->parent;
if (parent->id == ACTOR_PLAYER) {
@@ -2065,15 +2062,15 @@ void func_800B8C20(Actor* actorA, Actor* actorB, GlobalContext* globalCtx) {
actorA->parent = NULL;
}
-void func_800B8C50(Actor* actor, GlobalContext* globalCtx) {
- Player* player = GET_PLAYER(globalCtx);
+void func_800B8C50(Actor* actor, PlayState* play) {
+ Player* player = GET_PLAYER(play);
if (actor->xyzDistToPlayerSq < player->unk_AA0) {
player->unk_AA0 = actor->xyzDistToPlayerSq;
}
}
-s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) {
+s32 Actor_HasRider(PlayState* play, Actor* horse) {
if (horse->child != NULL) {
return true;
}
@@ -2081,8 +2078,8 @@ s32 Actor_HasRider(GlobalContext* globalCtx, Actor* horse) {
return false;
}
-s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) {
- Player* player = GET_PLAYER(globalCtx);
+s32 Actor_SetRideActor(PlayState* play, Actor* horse, s32 mountSide) {
+ Player* player = GET_PLAYER(play);
if (!(player->stateFlags1 & 0x003C7880)) {
player->rideActor = horse;
@@ -2094,7 +2091,7 @@ s32 Actor_SetRideActor(GlobalContext* globalCtx, Actor* horse, s32 mountSide) {
return false;
}
-s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse) {
+s32 Actor_HasNoRider(PlayState* play, Actor* horse) {
if (horse->child == NULL) {
return true;
}
@@ -2102,8 +2099,8 @@ s32 Actor_HasNoRider(GlobalContext* globalCtx, Actor* horse) {
return false;
}
-void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) {
- Player* player = GET_PLAYER(globalCtx);
+void func_800B8D10(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5, u32 arg6) {
+ Player* player = GET_PLAYER(play);
player->unk_B74 = arg6;
player->unk_B75 = arg5;
@@ -2112,20 +2109,20 @@ void func_800B8D10(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f
player->unk_B7C = arg4;
}
-void func_800B8D50(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5) {
- func_800B8D10(globalCtx, actor, arg2, yaw, arg4, 3, arg5);
+void func_800B8D50(PlayState* play, Actor* actor, f32 arg2, s16 yaw, f32 arg4, u32 arg5) {
+ func_800B8D10(play, actor, arg2, yaw, arg4, 3, arg5);
}
-void func_800B8D98(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) {
- func_800B8D50(globalCtx, actor, arg2, arg3, arg4, 0);
+void func_800B8D98(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) {
+ func_800B8D50(play, actor, arg2, arg3, arg4, 0);
}
-void func_800B8DD4(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) {
- func_800B8D10(globalCtx, actor, arg2, arg3, arg4, 2, arg5);
+void func_800B8DD4(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4, u32 arg5) {
+ func_800B8D10(play, actor, arg2, arg3, arg4, 2, arg5);
}
-void func_800B8E1C(GlobalContext* globalCtx, Actor* actor, f32 arg2, s16 arg3, f32 arg4) {
- func_800B8DD4(globalCtx, actor, arg2, arg3, arg4, 0);
+void func_800B8E1C(PlayState* play, Actor* actor, f32 arg2, s16 arg3, f32 arg4) {
+ func_800B8DD4(play, actor, arg2, arg3, arg4, 0);
}
void func_800B8E58(Player* player, u16 sfxId) {
@@ -2143,7 +2140,7 @@ void Actor_PlaySfxAtPos(Actor* actor, u16 sfxId) {
Audio_PlaySfxAtPos(&actor->projectedPos, sfxId);
}
-void func_800B8EF4(GlobalContext* globalCtx, Actor* actor) {
+void func_800B8EF4(PlayState* play, Actor* actor) {
u32 sfxId;
if (actor->bgCheckFlags & 0x20) {
@@ -2153,7 +2150,7 @@ void func_800B8EF4(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);
}
Audio_PlaySfxAtPos(&actor->projectedPos, NA_SE_EV_BOMB_BOUND);
@@ -2208,18 +2205,18 @@ void func_800B9098(Actor* actor) {
actor->audioFlags |= 0x40;
}
-s32 func_800B90AC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4) {
- if (func_800C99D4(&globalCtx->colCtx, polygon, index) == 8) {
+s32 func_800B90AC(PlayState* play, Actor* actor, CollisionPoly* polygon, s32 index, s32 arg4) {
+ if (func_800C99D4(&play->colCtx, polygon, index) == 8) {
return true;
}
return false;
}
-void func_800B90F4(GlobalContext* globalCtx) {
- if (globalCtx->actorCtx.unk3 != 0) {
- globalCtx->actorCtx.unk3 = 0;
- func_80115D5C(&globalCtx->state);
+void func_800B90F4(PlayState* play) {
+ if (play->actorCtx.unk3 != 0) {
+ play->actorCtx.unk3 = 0;
+ func_80115D5C(&play->state);
}
}
@@ -2233,18 +2230,18 @@ void func_800B9120(ActorContext* actorCtx) {
actorCtx->unkC = 0x200 >> phi_v0;
}
-void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEntry* actorEntry) {
+void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* actorEntry) {
ActorOverlay* overlayEntry;
CycleSceneFlags* cycleFlags;
s32 i;
gSaveContext.save.weekEventReg[92] |= 0x80;
- cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)];
+ cycleFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(play->sceneNum)];
bzero(actorCtx, sizeof(ActorContext));
ActorOverlayTable_Init();
- Matrix_MtxFCopy(&globalCtx->billboardMtxF, &gIdentityMtxF);
- Matrix_MtxFCopy(&globalCtx->viewProjectionMtxF, &gIdentityMtxF);
+ Matrix_MtxFCopy(&play->billboardMtxF, &gIdentityMtxF);
+ Matrix_MtxFCopy(&play->viewProjectionMtxF, &gIdentityMtxF);
overlayEntry = gActorOverlayTable;
for (i = 0; i < ARRAY_COUNT(gActorOverlayTable); i++) {
@@ -2256,42 +2253,42 @@ void Actor_InitContext(GlobalContext* globalCtx, ActorContext* actorCtx, ActorEn
actorCtx->flags.chest = cycleFlags->chest;
actorCtx->flags.switches[0] = cycleFlags->switch0;
actorCtx->flags.switches[1] = cycleFlags->switch1;
- if (globalCtx->sceneNum == SCENE_INISIE_R) {
- cycleFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum];
+ if (play->sceneNum == SCENE_INISIE_R) {
+ cycleFlags = &gSaveContext.cycleSceneFlags[play->sceneNum];
}
actorCtx->flags.collectible[0] = cycleFlags->collectible;
actorCtx->flags.clearedRoom = cycleFlags->clearedRoom;
- TitleCard_ContextInit(&globalCtx->state, &actorCtx->titleCtxt);
- func_800B6468(globalCtx);
+ TitleCard_ContextInit(&play->state, &actorCtx->titleCtxt);
+ func_800B6468(play);
actorCtx->absoluteSpace = NULL;
- Actor_SpawnEntry(actorCtx, actorEntry, globalCtx);
- Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx);
+ Actor_SpawnEntry(actorCtx, actorEntry, play);
+ Actor_TargetContextInit(&actorCtx->targetContext, actorCtx->actorLists[ACTORCAT_PLAYER].first, play);
func_800B9120(actorCtx);
Fault_AddClient(&sActorFaultClient, (void*)Actor_PrintLists, actorCtx, NULL);
- func_800B722C(&globalCtx->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first);
+ func_800B722C(&play->state, (Player*)actorCtx->actorLists[ACTORCAT_PLAYER].first);
}
/**
* Spawns the actors in the current setup (of the current scene/setup/room triple)
* Only spawns actors based on the time flags embedded in their rotation parameters
*/
-void Actor_SpawnSetupActors(GlobalContext* globalCtx, ActorContext* actorCtx) {
- if (globalCtx->numSetupActors > 0) {
- ActorEntry* actorEntry = globalCtx->setupActorList;
+void Actor_SpawnSetupActors(PlayState* play, ActorContext* actorCtx) {
+ if (play->numSetupActors > 0) {
+ ActorEntry* actorEntry = play->setupActorList;
s32 temp_fp = actorCtx->unkC;
s32 temp_s1;
s32 phi_v0;
s32 i;
func_800B9120(actorCtx);
- func_800BA8B8(globalCtx, &globalCtx->actorCtx);
+ func_800BA8B8(play, &play->actorCtx);
temp_s1 = (actorCtx->unkC * 2) & 0x2FF;
- for (i = 0; i < globalCtx->numSetupActors; i++) {
+ for (i = 0; i < play->numSetupActors; i++) {
phi_v0 = ((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F);
if (phi_v0 == 0) {
phi_v0 = 0x3FF;
@@ -2299,18 +2296,18 @@ void Actor_SpawnSetupActors(GlobalContext* globalCtx, ActorContext* actorCtx) {
if (!(phi_v0 & temp_fp) && (phi_v0 & actorCtx->unkC) &&
(!(gSaveContext.eventInf[1] & 0x80) || !(phi_v0 & temp_s1) || !(actorEntry->id & 0x800))) {
- Actor_SpawnEntry(&globalCtx->actorCtx, actorEntry, globalCtx);
+ Actor_SpawnEntry(&play->actorCtx, actorEntry, play);
}
actorEntry++;
}
// Prevents re-spawning the setup actors
- globalCtx->numSetupActors = -globalCtx->numSetupActors;
+ play->numSetupActors = -play->numSetupActors;
}
}
typedef struct {
- /* 0x00 */ GlobalContext* globalCtx;
+ /* 0x00 */ PlayState* play;
/* 0x04 */ Actor* actor;
/* 0x08 */ u32 unk_08;
/* 0x0C */ u32 unkC;
@@ -2321,7 +2318,7 @@ typedef struct {
} UpdateActor_Params; // size = 0x1C
Actor* Actor_UpdateActor(UpdateActor_Params* params) {
- GlobalContext* globalCtx = params->globalCtx;
+ PlayState* play = params->play;
Actor* actor = params->actor;
Actor* nextActor;
@@ -2333,21 +2330,21 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) {
actor->audioFlags &= ~0x7F;
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;
}
nextActor = actor->next;
} else if (actor->update == NULL) {
if (!actor->isDrawn) {
- nextActor = Actor_Delete(&globalCtx->actorCtx, actor, globalCtx);
+ nextActor = Actor_Delete(&play->actorCtx, actor, play);
} else {
- Actor_Destroy(actor, globalCtx);
+ Actor_Destroy(actor, play);
nextActor = actor->next;
}
} else {
- if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) {
+ if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
Actor_MarkForDeath(actor);
} else {
s32 tmp = (params->unk_08 == 0);
@@ -2379,14 +2376,14 @@ Actor* Actor_UpdateActor(UpdateActor_Params* params) {
actor->targetPriority = 0;
}
- Actor_SetObjectDependency(globalCtx, actor);
+ Actor_SetObjectDependency(play, actor);
if (actor->colorFilterTimer != 0) {
actor->colorFilterTimer--;
}
- actor->update(actor, globalCtx);
- BgCheck_ResetFlagsIfLoadedActor(globalCtx, &globalCtx->colCtx.dyna, actor);
+ actor->update(actor, play);
+ BgCheck_ResetFlagsIfLoadedActor(play, &play->colCtx.dyna, actor);
}
CollisionCheck_ResetDamage(&actor->colChkInfo);
@@ -2402,10 +2399,10 @@ u32 D_801AED58[] = {
0x10000282, 0x00000002, 0x300002C2, 0x100006C2, 0x00000002, 0x100002C2,
};
-void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
+void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
s32 i;
Actor* actor;
- Player* player = GET_PLAYER(globalCtx);
+ Player* player = GET_PLAYER(play);
u32* tmp;
s32 cat;
Actor* next;
@@ -2413,15 +2410,15 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
UpdateActor_Params params;
params.player = player;
- params.globalCtx = globalCtx;
+ params.play = play;
- if (globalCtx->unk_18844 != 0) {
+ if (play->unk_18844 != 0) {
params.unk_18 = ACTOR_FLAG_200000;
} else {
params.unk_18 = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_10;
}
- Actor_SpawnSetupActors(globalCtx, actorCtx);
+ Actor_SpawnSetupActors(play, actorCtx);
if (actorCtx->unk2 != 0) {
actorCtx->unk2--;
@@ -2450,7 +2447,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
if (i == ACTORCAT_BG) {
- DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna);
+ DynaPoly_Setup(play, &play->colCtx.dyna);
}
}
@@ -2465,7 +2462,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
next = actor->next;
cat = actor->category;
actor->category = i;
- Actor_RemoveFromCategory(globalCtx, actorCtx, actor);
+ Actor_RemoveFromCategory(play, actorCtx, actor);
Actor_AddToCategory(actorCtx, actor, cat);
actor = next;
}
@@ -2489,43 +2486,43 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
if (!(player->stateFlags1 & 2)) {
- func_800B5814(&actorCtx->targetContext, player, actor, &globalCtx->state);
+ func_800B5814(&actorCtx->targetContext, player, actor, &play->state);
}
- TitleCard_Update(&globalCtx->state, &actorCtx->titleCtxt);
- func_800B6474(globalCtx);
- DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna);
+ TitleCard_Update(&play->state, &actorCtx->titleCtxt);
+ func_800B6474(play);
+ DynaPoly_UpdateBgActorTransforms(play, &play->colCtx.dyna);
}
-void Actor_Draw(GlobalContext* globalCtx, Actor* actor) {
+void Actor_Draw(PlayState* play, Actor* actor) {
Lights* light;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- light = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx);
- if ((actor->flags & ACTOR_FLAG_10000000) && (globalCtx->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) {
+ light = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx);
+ if ((actor->flags & ACTOR_FLAG_10000000) && (play->roomCtx.currRoom.enablePosLights || (MREG(93) != 0))) {
light->enablePosLights = true;
}
- Lights_BindAll(light, globalCtx->lightCtx.listHead,
- (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, globalCtx);
- Lights_Draw(light, globalCtx->state.gfxCtx);
+ Lights_BindAll(light, play->lightCtx.listHead,
+ (actor->flags & (ACTOR_FLAG_10000000 | ACTOR_FLAG_400000)) ? NULL : &actor->world.pos, play);
+ Lights_Draw(light, play->state.gfxCtx);
if (actor->flags & ACTOR_FLAG_1000) {
- Matrix_SetTranslateRotateYXZ(
- actor->world.pos.x + globalCtx->mainCamera.skyboxOffset.x,
- actor->world.pos.y + ((actor->shape.yOffset * actor->scale.y) + globalCtx->mainCamera.skyboxOffset.y),
- actor->world.pos.z + globalCtx->mainCamera.skyboxOffset.z, &actor->shape.rot);
+ Matrix_SetTranslateRotateYXZ(actor->world.pos.x + play->mainCamera.skyboxOffset.x,
+ actor->world.pos.y +
+ ((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) {
s32 temp_v0_2 = actor->colorFilterParams & 0xC000;
@@ -2543,28 +2540,28 @@ void Actor_Draw(GlobalContext* globalCtx, Actor* actor) {
}
if (actor->colorFilterParams & 0x2000) {
- func_800AE778(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF);
+ func_800AE778(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF);
} else {
- func_800AE434(globalCtx, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF);
+ func_800AE434(play, &actorDefaultHitColor, actor->colorFilterTimer, actor->colorFilterParams & 0xFF);
}
}
- actor->draw(actor, globalCtx);
+ actor->draw(actor, play);
if (actor->colorFilterTimer != 0) {
if (actor->colorFilterParams & 0x2000) {
- func_800AE8EC(globalCtx);
+ func_800AE8EC(play);
} else {
- func_800AE5A0(globalCtx);
+ func_800AE5A0(play);
}
}
if (actor->shape.shadowDraw != NULL) {
- actor->shape.shadowDraw(actor, light, globalCtx);
+ actor->shape.shadowDraw(actor, light, play);
}
actor->isDrawn = true;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
void func_800B9D1C(Actor* actor) {
@@ -2595,18 +2592,18 @@ void func_800B9D1C(Actor* actor) {
}
}
-void Actor_DrawAllSetup(GlobalContext* globalCtx) {
- globalCtx->actorCtx.undrawnActorCount = 0;
- globalCtx->actorCtx.unkB = 0;
+void Actor_DrawAllSetup(PlayState* play) {
+ play->actorCtx.undrawnActorCount = 0;
+ play->actorCtx.unkB = 0;
}
-s32 Actor_RecordUndrawnActor(GlobalContext* globalCtx, Actor* actor) {
- if (globalCtx->actorCtx.undrawnActorCount >= 32) {
+s32 Actor_RecordUndrawnActor(PlayState* play, Actor* actor) {
+ if (play->actorCtx.undrawnActorCount >= 32) {
return false;
}
- globalCtx->actorCtx.undrawnActors[globalCtx->actorCtx.undrawnActorCount] = actor;
- globalCtx->actorCtx.undrawnActorCount++;
+ play->actorCtx.undrawnActors[play->actorCtx.undrawnActorCount] = actor;
+ play->actorCtx.undrawnActorCount++;
return true;
}
@@ -2616,7 +2613,7 @@ void func_800B9E84(Gfx** arg0, s32 arg1) {
#ifdef NON_EQUIVALENT
// Related to draw actors with lens
-void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
+void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors) {
s32 spB4;
Gfx* spAC;
void* spA8; // pad
@@ -2634,18 +2631,18 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
Gfx* phi_s1_2;
// void* phi_s1_4;
- OPEN_DISPS(globalCtx->state.gfxCtx);
- // temp_s2 = globalCtx->state.gfxCtx;
+ OPEN_DISPS(play->state.gfxCtx);
+ // temp_s2 = play->state.gfxCtx;
if (numActors > 0) {
spAC = POLY_XLU_DISP;
- // sp34 = globalCtx + 0x18000;
- spA4 = globalCtx->unk_18E68;
+ // sp34 = play + 0x18000;
+ spA4 = play->unk_18E68;
- PreRender_SetValues(&globalCtx->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer,
+ PreRender_SetValues(&play->pauseBgPreRender, D_801FBBCC, D_801FBBCE, __gfxCtx->curFrameBuffer,
__gfxCtx->zbuffer);
- func_80170200(&globalCtx->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4);
+ func_80170200(&play->pauseBgPreRender, &spAC, __gfxCtx->zbuffer, (void*)spA4);
// spAC->words.w0 = 0xE7000000;
// spAC->words.w1 = 0;
@@ -2673,7 +2670,7 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
gDPSetPrimColor(spAC++, 0, 0, 0, 0, 0, 255);
// temp_s1_5 = spAC;
- if (globalCtx->roomCtx.currRoom.unk5 == 0) {
+ if (play->roomCtx.currRoom.unk5 == 0) {
// temp_s1_5->words.w0 = 0xFC61E6C3;
// temp_s1_5->words.w1 = 0x11CF9FCF;
// phi_s1 = temp_s1_5 + 8;
@@ -2687,14 +2684,14 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
}
// spAC = phi_s1;
- func_800B9E84(&spAC, globalCtx->actorCtx.unk4);
- phi_s1_2 = func_801660B8(globalCtx, spAC);
+ func_800B9E84(&spAC, play->actorCtx.unk4);
+ phi_s1_2 = func_801660B8(play, spAC);
for (spB4 = 0; spB4 < numActors; spB4++, actors++) {
- Actor_Draw(globalCtx, *actors);
+ Actor_Draw(play, *actors);
}
- // temp_s0_2 = &globalCtx->pauseBgPreRender;
+ // temp_s0_2 = &play->pauseBgPreRender;
// phi_s1_2->words.w0 = 0xE7000000;
// phi_s1_2->words.w1 = 0;
@@ -2723,7 +2720,7 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
// temp_a0_2 = &spAC;
// if (sp34->unk_6E5 == 0) {
- if (globalCtx->roomCtx.currRoom.unk5 == 0) {
+ if (play->roomCtx.currRoom.unk5 == 0) {
// temp_s1_10->unk_0 = 0xFC119623;
// temp_s1_10->unk_4 = 0xFF2FFFFF;
// phi_s1_4 = temp_s1_10 + 8;
@@ -2741,14 +2738,13 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
// phi_s1_4->unk_0 = (s32) (((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000);
// temp_s1_11 = phi_s1_4 + 8;
// phi_s1_4->unk_4 = spA4;
- gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF),
- spA4);
+ gDPSetColorImage(phi_s1_2++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((play->pauseBgPreRender.width - 1) & 0xFFF), spA4);
// temp_s1_11 = phi_s1_2;
spAC = phi_s1_2;
// spAC = temp_s1_11;
- func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4);
+ func_800B9E84(&spAC, (s32)play->actorCtx.unk4);
// temp_s1_11->words.w0 = 0xE7000000;
// temp_s1_11->words.w1 = 0;
// temp_s1_12 = temp_s1_11 + 8;
@@ -2762,13 +2758,13 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
// temp_s1_14 = temp_s1_13 + 8;
// temp_s1_13->words.w0 = ((sp34->unk_B4C - 1) & 0xFFF) | 0xFF100000;
// temp_s1_13->words.w1 = sp34->unk_B5C;
- gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((globalCtx->pauseBgPreRender.width - 1) & 0xFFF),
- globalCtx->pauseBgPreRender.fbuf);
+ gDPSetColorImage(spAC++, G_IM_FMT_RGBA, G_IM_SIZ_16b, ((play->pauseBgPreRender.width - 1) & 0xFFF),
+ play->pauseBgPreRender.fbuf);
// temp_a1 = &spAC;
// spAC = temp_s1_14;
- // func_8016FDB8(&globalCtx->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U);
- func_8016FDB8(&globalCtx->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U);
+ // func_8016FDB8(&play->pauseBgPreRender, temp_a1, (void* ) spA4, spA8, 1U);
+ func_8016FDB8(&play->pauseBgPreRender, &spAC, (void*)spA4, __gfxCtx->zbuffer, 1U);
//
// POLY_OPA_DISP = temp_s1_14;
POLY_OPA_DISP = spAC;
@@ -2800,22 +2796,22 @@ void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors) {
// spAC = temp_s1_18 + 8;
gDPSetPrimColor(spAC++, 0, 0, 74, 0, 0, 74);
- func_800B9E84(&spAC, (s32)globalCtx->actorCtx.unk4);
+ func_800B9E84(&spAC, (s32)play->actorCtx.unk4);
OVERLAY_DISP = spAC;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
#else
-void func_800B9EF4(GlobalContext* globalCtx, s32 numActors, Actor** actors);
+void func_800B9EF4(PlayState* play, s32 numActors, Actor** actors);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B9EF4.s")
#endif
-s32 func_800BA2D8(GlobalContext* globalCtx, Actor* actor) {
- return func_800BA2FC(globalCtx, actor, &actor->projectedPos, actor->projectedW);
+s32 func_800BA2D8(PlayState* play, Actor* actor) {
+ return func_800BA2FC(play, actor, &actor->projectedPos, actor->projectedW);
}
-s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f32 projectedW) {
+s32 func_800BA2FC(PlayState* play, Actor* actor, Vec3f* projectedPos, f32 projectedW) {
if ((-actor->uncullZoneScale < projectedPos->z) &&
(projectedPos->z < (actor->uncullZoneForward + actor->uncullZoneScale))) {
f32 phi_f12;
@@ -2823,10 +2819,10 @@ s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f
f32 phi_f14;
f32 phi_f16;
- if (globalCtx->view.fovy != 60.0f) {
- phi_f12 = actor->uncullZoneScale * globalCtx->unk_187F0.x * 0.76980036f; // sqrt(16/27)
+ if (play->view.fovy != 60.0f) {
+ phi_f12 = actor->uncullZoneScale * play->unk_187F0.x * 0.76980036f; // sqrt(16/27)
- phi_f14 = globalCtx->unk_187F0.y * 0.57735026f; // 1 / sqrt(3)
+ phi_f14 = play->unk_187F0.y * 0.57735026f; // 1 / sqrt(3)
phi_f16 = actor->uncullZoneScale * phi_f14;
phi_f14 *= actor->uncullZoneDownward;
} else {
@@ -2843,7 +2839,7 @@ s32 func_800BA2FC(GlobalContext* globalCtx, Actor* actor, Vec3f* projectedPos, f
return false;
}
-void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
+void Actor_DrawAll(PlayState* play, ActorContext* actorCtx) {
s32 pad[2];
Gfx* ref2;
Gfx* tmp2;
@@ -2854,15 +2850,15 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
s32 actorFlags;
s32 i;
- if (globalCtx->unk_18844 != 0) {
+ if (play->unk_18844 != 0) {
actorFlags = ACTOR_FLAG_200000;
} else {
actorFlags = ACTOR_FLAG_200000 | ACTOR_FLAG_40 | ACTOR_FLAG_20;
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- Actor_DrawAllSetup(globalCtx);
+ Actor_DrawAllSetup(play);
sp58 = POLY_XLU_DISP;
POLY_XLU_DISP = &sp58[1];
@@ -2871,14 +2867,14 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
actor = actorEntry->first;
while (actor != NULL) {
- SkinMatrix_Vec3fMtxFMultXYZW(&globalCtx->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos,
+ SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &actor->world.pos, &actor->projectedPos,
&actor->projectedW);
if (actor->audioFlags & 0x7F) {
func_800B9D1C(actor);
}
- if (func_800BA2D8(globalCtx, actor)) {
+ if (func_800BA2D8(play, actor)) {
actor->flags |= ACTOR_FLAG_40;
} else {
actor->flags &= ~ACTOR_FLAG_40;
@@ -2887,11 +2883,11 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
actor->isDrawn = false;
if ((actor->init == NULL) && (actor->draw != NULL) && (actor->flags & actorFlags)) {
if ((actor->flags & ACTOR_FLAG_80) &&
- ((globalCtx->roomCtx.currRoom.unk5 == 0) || (globalCtx->actorCtx.unk4 == 0x64) ||
- (actor->room != globalCtx->roomCtx.currRoom.num))) {
- if (Actor_RecordUndrawnActor(globalCtx, actor)) {}
+ ((play->roomCtx.currRoom.unk5 == 0) || (play->actorCtx.unk4 == 0x64) ||
+ (actor->room != play->roomCtx.currRoom.num))) {
+ if (Actor_RecordUndrawnActor(play, actor)) {}
} else {
- Actor_Draw(globalCtx, actor);
+ Actor_Draw(play, actor);
}
}
@@ -2899,25 +2895,25 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
}
- Effect_DrawAll(globalCtx->state.gfxCtx);
- EffectSS_DrawAllParticles(globalCtx);
- EffFootmark_Draw(globalCtx);
+ Effect_DrawAll(play->state.gfxCtx);
+ EffectSS_DrawAllParticles(play);
+ EffFootmark_Draw(play);
ref2 = POLY_XLU_DISP;
gSPDisplayList(sp58, &ref2[1]);
POLY_XLU_DISP = &ref2[1];
- if (globalCtx->actorCtx.unk3 != 0) {
- Math_StepToC(&globalCtx->actorCtx.unk4, 100, 20);
- if (GET_PLAYER(globalCtx)->stateFlags2 & 0x8000000) {
- func_800B90F4(globalCtx);
+ if (play->actorCtx.unk3 != 0) {
+ Math_StepToC(&play->actorCtx.unk4, 100, 20);
+ if (GET_PLAYER(play)->stateFlags2 & 0x8000000) {
+ func_800B90F4(play);
}
} else {
- Math_StepToC(&globalCtx->actorCtx.unk4, 0, 10);
+ Math_StepToC(&play->actorCtx.unk4, 0, 10);
}
- if (globalCtx->actorCtx.unk4 != 0) {
- globalCtx->actorCtx.unkB = 1;
- func_800B9EF4(globalCtx, globalCtx->actorCtx.undrawnActorCount, globalCtx->actorCtx.undrawnActors);
+ if (play->actorCtx.unk4 != 0) {
+ play->actorCtx.unkB = 1;
+ func_800B9EF4(play, play->actorCtx.undrawnActorCount, play->actorCtx.undrawnActors);
}
tmp2 = POLY_XLU_DISP;
@@ -2925,19 +2921,19 @@ void Actor_DrawAll(GlobalContext* globalCtx, ActorContext* actorCtx) {
gSPBranchList(ref2, &tmp2[1]);
POLY_XLU_DISP = &tmp2[1];
- if (globalCtx->unk_18844 == 0) {
- Lights_DrawGlow(globalCtx);
+ if (play->unk_18844 == 0) {
+ Lights_DrawGlow(play);
}
- TitleCard_Draw(&globalCtx->state, &actorCtx->titleCtxt);
+ TitleCard_Draw(&play->state, &actorCtx->titleCtxt);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Kills every actor which its object is not loaded
*/
-void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) {
+void func_800BA6FC(PlayState* play, ActorContext* actorCtx) {
Actor* actor;
s32 i;
@@ -2945,7 +2941,7 @@ void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) {
actor = actorCtx->actorLists[i].first;
while (actor != NULL) {
- if (!Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) {
+ if (!Object_IsLoaded(&play->objectCtx, actor->objBankIndex)) {
Actor_MarkForDeath(actor);
}
@@ -2957,7 +2953,7 @@ void func_800BA6FC(GlobalContext* globalCtx, ActorContext* actorCtx) {
/**
* Kill actors on room change and update flags accordingly
*/
-void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) {
+void func_800BA798(PlayState* play, ActorContext* actorCtx) {
Actor* actor;
s32 i;
@@ -2965,13 +2961,13 @@ void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) {
actor = actorCtx->actorLists[i].first;
while (actor != NULL) {
- if ((actor->room >= 0) && (actor->room != globalCtx->roomCtx.currRoom.num) &&
- (actor->room != globalCtx->roomCtx.prevRoom.num)) {
+ if ((actor->room >= 0) && (actor->room != play->roomCtx.currRoom.num) &&
+ (actor->room != play->roomCtx.prevRoom.num)) {
if (!actor->isDrawn) {
- actor = Actor_Delete(actorCtx, actor, globalCtx);
+ actor = Actor_Delete(actorCtx, actor, play);
} else {
Actor_MarkForDeath(actor);
- Actor_Destroy(actor, globalCtx);
+ Actor_Destroy(actor, play);
actor = actor->next;
}
} else {
@@ -2980,14 +2976,14 @@ void func_800BA798(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
}
- CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx);
+ CollisionCheck_ClearContext(play, &play->colChkCtx);
actorCtx->flags.clearedRoomTemp = 0;
actorCtx->flags.switches[3] = 0;
actorCtx->flags.collectible[3] = 0;
- globalCtx->msgCtx.unk_12030 = 0;
+ play->msgCtx.unk_12030 = 0;
}
-void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) {
+void func_800BA8B8(PlayState* play, ActorContext* actorCtx) {
s32 i;
for (i = 0; i < ARRAY_COUNT(actorCtx->actorLists); i++) {
@@ -2995,12 +2991,12 @@ void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) {
while (actor != NULL) {
if (!(actor->unk20 & actorCtx->unkC)) {
- func_80123590(globalCtx, actor);
+ func_80123590(play, actor);
if (!actor->isDrawn) {
- actor = Actor_Delete(actorCtx, actor, globalCtx);
+ actor = Actor_Delete(actorCtx, actor, play);
} else {
Actor_MarkForDeath(actor);
- Actor_Destroy(actor, globalCtx);
+ Actor_Destroy(actor, play);
actor = actor->next;
}
} else {
@@ -3009,11 +3005,11 @@ void func_800BA8B8(GlobalContext* globalCtx, ActorContext* actorCtx) {
}
}
- CollisionCheck_ClearContext(globalCtx, &globalCtx->colChkCtx);
- globalCtx->msgCtx.unk_12030 = 0;
+ CollisionCheck_ClearContext(play, &play->colChkCtx);
+ play->msgCtx.unk_12030 = 0;
}
-void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) {
+void Actor_CleanupContext(ActorContext* actorCtx, PlayState* play) {
s32 i;
Fault_RemoveClient(&sActorFaultClient);
@@ -3023,14 +3019,14 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) {
Actor* actor = actorCtx->actorLists[i].first;
while (actor != NULL) {
- Actor_Delete(actorCtx, actor, globalCtx);
+ Actor_Delete(actorCtx, actor, play);
actor = actorCtx->actorLists[i].first;
}
}
}
while (actorCtx->actorLists[ACTORCAT_PLAYER].first != NULL) {
- Actor_Delete(actorCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, globalCtx);
+ Actor_Delete(actorCtx, actorCtx->actorLists[ACTORCAT_PLAYER].first, play);
}
if (actorCtx->absoluteSpace != NULL) {
@@ -3038,7 +3034,7 @@ void Actor_CleanupContext(ActorContext* actorCtx, GlobalContext* globalCtx) {
actorCtx->absoluteSpace = NULL;
}
- Play_SaveCycleSceneFlags(&globalCtx->state);
+ Play_SaveCycleSceneFlags(&play->state);
ActorOverlayTable_Cleanup();
}
@@ -3075,7 +3071,7 @@ void Actor_AddToCategory(ActorContext* actorCtx, Actor* actor, u8 actorCategory)
* 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->totalLoadedActors--;
@@ -3096,9 +3092,9 @@ Actor* Actor_RemoveFromCategory(GlobalContext* globalCtx, ActorContext* actorCtx
actorToRemove->next = NULL;
actorToRemove->prev = NULL;
- if ((actorToRemove->room == globalCtx->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) &&
+ if ((actorToRemove->room == play->roomCtx.currRoom.num) && (actorToRemove->category == ACTORCAT_ENEMY) &&
(actorCtx->actorLists[ACTORCAT_ENEMY].length == 0)) {
- Flags_SetClearTemp(globalCtx, globalCtx->roomCtx.currRoom.num);
+ Flags_SetClearTemp(play, play->roomCtx.currRoom.num);
}
return newHead;
@@ -3121,10 +3117,10 @@ void Actor_FreeOverlay(ActorOverlay* entry) {
}
}
-Actor* Actor_Spawn(ActorContext* actorCtx, GlobalContext* globalCtx, s16 actorId, f32 posX, f32 posY, f32 posZ,
- s16 rotX, s16 rotY, s16 rotZ, s32 params) {
- return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1,
- 0x3FF, NULL);
+Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 posX, f32 posY, f32 posZ, s16 rotX,
+ s16 rotY, s16 rotZ, s32 params) {
+ return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1, 0x3FF,
+ NULL);
}
ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) {
@@ -3167,8 +3163,8 @@ ActorInit* Actor_LoadOverlay(ActorContext* actorCtx, s16 index) {
return actorInit;
}
-Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* globalCtx, s16 index, f32 x, f32 y, f32 z,
- s16 rotX, s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) {
+Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, PlayState* play, s16 index, f32 x, f32 y, f32 z, s16 rotX,
+ s16 rotY, s16 rotZ, s32 params, u32 cutscene, s32 arg11, Actor* parent) {
s32 pad;
Actor* actor;
ActorInit* actorInit;
@@ -3184,10 +3180,9 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* glob
return NULL;
}
- objBankIndex = Object_GetIndex(&globalCtx->objectCtx, actorInit->objectId);
- if ((objBankIndex < 0) ||
- ((actorInit->type == ACTORCAT_ENEMY) && Flags_GetClear(globalCtx, globalCtx->roomCtx.currRoom.num) &&
- (actorInit->id != ACTOR_BOSS_05))) {
+ objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId);
+ if ((objBankIndex < 0) || ((actorInit->type == ACTORCAT_ENEMY) &&
+ Flags_GetClear(play, play->roomCtx.currRoom.num) && (actorInit->id != ACTOR_BOSS_05))) {
Actor_FreeOverlay(&gActorOverlayTable[index]);
return NULL;
}
@@ -3225,7 +3220,7 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* glob
actor->parent = parent;
parent->child = actor;
} else {
- actor->room = globalCtx->roomCtx.currRoom.num;
+ actor->room = play->roomCtx.currRoom.num;
}
actor->home.pos.x = x;
@@ -3252,48 +3247,48 @@ Actor* Actor_SpawnAsChildAndCutscene(ActorContext* actorCtx, GlobalContext* glob
{
u32 sp20 = gSegments[6];
- Actor_Init(actor, globalCtx);
+ Actor_Init(actor, play);
gSegments[6] = sp20;
}
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, s32 params) {
- return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1,
+Actor* Actor_SpawnAsChild(ActorContext* actorCtx, Actor* parent, PlayState* play, s16 actorId, f32 posX, f32 posY,
+ f32 posZ, s16 rotX, s16 rotY, s16 rotZ, s32 params) {
+ return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorId, posX, posY, posZ, rotX, rotY, rotZ, params, -1,
parent->unk20, parent);
}
-void Actor_SpawnTransitionActors(GlobalContext* globalCtx, ActorContext* actorCtx) {
- TransitionActorEntry* transitionActorList = globalCtx->doorCtx.transitionActorList;
+void Actor_SpawnTransitionActors(PlayState* play, ActorContext* actorCtx) {
+ TransitionActorEntry* transitionActorList = play->doorCtx.transitionActorList;
s32 i;
- s16 numTransitionActors = globalCtx->doorCtx.numTransitionActors;
+ s16 numTransitionActors = play->doorCtx.numTransitionActors;
for (i = 0; i < numTransitionActors; transitionActorList++, i++) {
if (transitionActorList->id >= 0) {
if ((transitionActorList->sides[0].room >= 0 &&
- (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[0].room ||
- globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) ||
+ (play->roomCtx.currRoom.num == transitionActorList->sides[0].room ||
+ play->roomCtx.prevRoom.num == transitionActorList->sides[0].room)) ||
(transitionActorList->sides[1].room >= 0 &&
- (globalCtx->roomCtx.currRoom.num == transitionActorList->sides[1].room ||
- globalCtx->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) {
+ (play->roomCtx.currRoom.num == transitionActorList->sides[1].room ||
+ play->roomCtx.prevRoom.num == transitionActorList->sides[1].room))) {
s16 rotY = ((transitionActorList->rotY >> 7) & 0x1FF) * (0x10000 / 360.0f);
- if (Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, transitionActorList->id & 0x1FFF,
+ if (Actor_SpawnAsChildAndCutscene(actorCtx, play, transitionActorList->id & 0x1FFF,
transitionActorList->pos.x, transitionActorList->pos.y,
transitionActorList->pos.z, 0, rotY, 0,
(i << 0xA) + (transitionActorList->params & 0x3FF),
transitionActorList->rotY & 0x7F, 0x3FF, 0) != NULL) {
transitionActorList->id = -transitionActorList->id;
}
- numTransitionActors = globalCtx->doorCtx.numTransitionActors;
+ numTransitionActors = play->doorCtx.numTransitionActors;
}
}
}
}
-Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalContext* globalCtx) {
+Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, PlayState* play) {
s16 rotX = (actorEntry->rot.x >> 7) & 0x1FF;
s16 rotY = (actorEntry->rot.y >> 7) & 0x1FF;
s16 rotZ = (actorEntry->rot.z >> 7) & 0x1FF;
@@ -3316,21 +3311,21 @@ Actor* Actor_SpawnEntry(ActorContext* actorCtx, ActorEntry* actorEntry, GlobalCo
rotZ -= 360;
}
- return Actor_SpawnAsChildAndCutscene(actorCtx, globalCtx, actorEntry->id & 0x1FFF, actorEntry->pos.x,
- actorEntry->pos.y, actorEntry->pos.z, rotX, rotY, rotZ,
- actorEntry->params & 0xFFFF, actorEntry->rot.y & 0x7F,
+ return Actor_SpawnAsChildAndCutscene(actorCtx, play, actorEntry->id & 0x1FFF, actorEntry->pos.x, actorEntry->pos.y,
+ actorEntry->pos.z, rotX, rotY, rotZ, actorEntry->params & 0xFFFF,
+ actorEntry->rot.y & 0x7F,
((actorEntry->rot.x & 7) << 7) | (actorEntry->rot.z & 0x7F), NULL);
}
-Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalCtx) {
+Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, PlayState* play) {
s32 pad;
- Player* player = GET_PLAYER(globalCtx);
+ Player* player = GET_PLAYER(play);
Actor* newHead;
ActorOverlay* overlayEntry = actor->overlayEntry;
if ((player != NULL) && (actor == player->unk_730)) {
func_80123DA4(player);
- Camera_ChangeMode(Play_GetCamera(globalCtx, Play_GetActiveCamId(globalCtx)), 0);
+ Camera_ChangeMode(Play_GetCamera(play, Play_GetActiveCamId(play)), 0);
}
if (actor == actorCtx->targetContext.arrowPointedActor) {
@@ -3346,9 +3341,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_Free(actor);
if (overlayEntry->vramStart != NULL) {
@@ -3359,17 +3354,17 @@ Actor* Actor_Delete(ActorContext* actorCtx, Actor* actor, GlobalContext* globalC
return newHead;
}
-s32 func_800BB59C(GlobalContext* globalCtx, Actor* actor) {
+s32 func_800BB59C(PlayState* play, Actor* actor) {
s16 x;
s16 y;
- Actor_GetScreenPos(globalCtx, actor, &x, &y);
+ Actor_GetScreenPos(play, actor, &x, &y);
return (x > -20) && (x < gScreenWidth + 20) && (y > -160) && (y < gScreenHeight + 160);
}
void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player, s32 actorCategory) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+ PlayState* play = (PlayState*)gameState;
f32 temp_f0_2;
Actor* sp8C;
Actor* actor;
@@ -3404,11 +3399,10 @@ void func_800BB604(GameState* gameState, ActorContext* actorCtx, Player* player,
}
if (((phi_s2) || (phi_s2_2)) && (func_800B83BC(actor, temp_f0_2))) {
- if (func_800BB59C(globalCtx, actor)) {
- if (((!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.focus.pos,
- &actor->focus.pos, &sp70, &sp80, true, true, true, true,
- &sp7C)) ||
- (SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C)))) {
+ if (func_800BB59C(play, actor)) {
+ if (((!BgCheck_CameraLineTest1(&play->colCtx, &player->actor.focus.pos, &actor->focus.pos,
+ &sp70, &sp80, true, true, true, true, &sp7C)) ||
+ (SurfaceType_IsIgnoredByProjectiles(&play->colCtx, sp80, sp7C)))) {
if (actor->targetPriority != 0) {
if ((phi_s2 != 0) && (actor->targetPriority < D_801ED8D4)) {
D_801ED8BC = actor;
@@ -3486,9 +3480,9 @@ void func_800BB8EC(GameState* gameState, ActorContext* actorCtx, Actor** arg2, A
* 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);
}
// blinking routine
@@ -3537,7 +3531,7 @@ s16 func_800BBC20(s16 arg0[2], s16 arg1, s16 arg2, s16 arg3) {
return arg0[0];
}
-void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx** dList) {
+void Actor_SpawnBodyParts(Actor* actor, PlayState* play, s32 arg2, Gfx** dList) {
EnPart* part;
Actor* spawnedPart;
MtxF* currentMatrix;
@@ -3545,7 +3539,7 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx*
if (*dList != NULL) {
currentMatrix = Matrix_GetCurrent();
spawnedPart =
- Actor_SpawnAsChild(&globalCtx->actorCtx, actor, globalCtx, ACTOR_EN_PART, currentMatrix->mf[3][0],
+ Actor_SpawnAsChild(&play->actorCtx, actor, play, ACTOR_EN_PART, currentMatrix->mf[3][0],
currentMatrix->mf[3][1], currentMatrix->mf[3][2], 0, 0, actor->objBankIndex, arg2);
if (spawnedPart != NULL) {
part = (EnPart*)spawnedPart;
@@ -3557,7 +3551,7 @@ void Actor_SpawnBodyParts(Actor* actor, GlobalContext* globalCtx, s32 arg2, Gfx*
}
}
-void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne,
+void Actor_SpawnFloorDustRing(PlayState* play, Actor* actor, Vec3f* posXZ, f32 radius, s32 countMinusOne,
f32 randAccelWeight, s16 scale, s16 scaleStep, u8 useLighting) {
Vec3f pos;
Vec3f accel = { 0.0f, 0.3f, 0.0f };
@@ -3576,17 +3570,17 @@ void Actor_SpawnFloorDustRing(GlobalContext* globalCtx, Actor* actor, Vec3f* pos
accel.z = (Rand_ZeroOne() - 0.5f) * randAccelWeight;
if (scale == 0) {
- func_800B10C0(globalCtx, &pos, &gZeroVec3f, &accel);
+ func_800B10C0(play, &pos, &gZeroVec3f, &accel);
} else if (useLighting) {
- func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep);
+ func_800B1210(play, &pos, &gZeroVec3f, &accel, scale, scaleStep);
} else {
- func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep);
+ func_800B11A0(play, &pos, &gZeroVec3f, &accel, scale, scaleStep);
}
angle += (2.0f * 3.14f) / (countMinusOne + 1.0f);
}
}
-void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) {
+void func_800BBFB0(PlayState* play, Vec3f* position, f32 arg2, s32 arg3, s16 arg4, s16 scaleStep, u8 arg6) {
Vec3f pos;
Vec3f accel = { 0.0f, 0.3f, 0.0f };
s32 i;
@@ -3602,14 +3596,14 @@ void func_800BBFB0(GlobalContext* globalCtx, Vec3f* position, f32 arg2, s32 arg3
scale += arg4;
if (arg6) {
- func_800B1210(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep);
+ func_800B1210(play, &pos, &gZeroVec3f, &accel, scale, scaleStep);
} else {
- func_800B11A0(globalCtx, &pos, &gZeroVec3f, &accel, scale, scaleStep);
+ func_800B11A0(play, &pos, &gZeroVec3f, &accel, scale, scaleStep);
}
}
}
-void func_800BC154(GlobalContext* globalCtx, ActorContext* actorCtx, Actor* actor, u8 actorCategory) {
+void func_800BC154(PlayState* play, ActorContext* actorCtx, Actor* actor, u8 actorCategory) {
actorCtx->actorLists[actor->category].unk_08 = 1;
actor->category = actorCategory;
}
@@ -3639,8 +3633,8 @@ s32 func_800BC1B4(Actor* actor, Actor* arg1, f32 arg2, f32 arg3) {
return false;
}
-Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3) {
- Actor* itemAction = globalCtx->actorCtx.actorLists[ACTORCAT_ITEMACTION].first;
+Actor* func_800BC270(PlayState* play, Actor* actor, f32 arg2, s32 arg3) {
+ Actor* itemAction = play->actorCtx.actorLists[ACTORCAT_ITEMACTION].first;
while (itemAction != NULL) {
if (((itemAction->id == ACTOR_ARMS_HOOK) && (arg3 & 0x80)) ||
@@ -3648,7 +3642,7 @@ Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3)
((itemAction->id == ACTOR_EN_ARROW) && (func_800BC188(itemAction->params) & arg3))) {
f32 speedXZ;
- if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(globalCtx)->unk_D57 != 0)) {
+ if ((itemAction->speedXZ <= 0.0f) && (GET_PLAYER(play)->unk_D57 != 0)) {
if (itemAction->id == ACTOR_ARMS_HOOK) {
speedXZ = 20.0f;
} else if (itemAction->id == ACTOR_EN_BOOM) {
@@ -3679,8 +3673,8 @@ Actor* func_800BC270(GlobalContext* globalCtx, Actor* actor, f32 arg2, s32 arg3)
return itemAction;
}
-Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2) {
- Actor* explosive = globalCtx->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first;
+Actor* func_800BC444(PlayState* play, Actor* actor, f32 arg2) {
+ Actor* explosive = play->actorCtx.actorLists[ACTORCAT_EXPLOSIVES].first;
while (explosive != NULL) {
if (((explosive->id == ACTOR_EN_BOM) || (explosive->id == ACTOR_EN_BOM_CHU) ||
@@ -3701,7 +3695,7 @@ Actor* func_800BC444(GlobalContext* globalCtx, Actor* actor, f32 arg2) {
*
* 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;
u16 bgCheckFlags;
f32 dx;
@@ -3718,7 +3712,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista
actor->world.pos.x += dx;
actor->world.pos.z += dz;
- Actor_UpdateBgCheckInfo(globalCtx, actor, 0.0f, 0.0f, 0.0f, 4);
+ Actor_UpdateBgCheckInfo(play, actor, 0.0f, 0.0f, 0.0f, 4);
Math_Vec3f_Copy(&actor->world.pos, &actorPos);
ret = actor->bgCheckFlags & 1;
@@ -3731,8 +3725,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->stateFlags3 & 0x80000000) && actor->isTargeted) {
return true;
@@ -3744,8 +3738,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->stateFlags3 & 0x80000000) && !actor->isTargeted) {
return true;
@@ -3754,13 +3748,13 @@ s32 Actor_OtherIsTargeted(GlobalContext* globalCtx, Actor* actor) {
return false;
}
-void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) {
+void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play) {
MtxF sp58;
f32 sp54;
Vec3f sp48;
CollisionPoly* sp44;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
POLY_OPA_DISP = Gfx_CallSetupDL(POLY_OPA_DISP, 0x2C);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0, 0, 0, alpha);
@@ -3769,7 +3763,7 @@ void func_800BC620(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx)
sp48.y = arg0->y + 1.0f;
sp48.z = arg0->z;
- sp54 = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp44, &sp48);
+ sp54 = BgCheck_EntityRaycastFloor2(play, &play->colCtx, &sp44, &sp48);
if (sp44 != NULL) {
func_800C0094(sp44, arg0->x, sp54, arg0->z, &sp58);
Matrix_Put(&sp58);
@@ -3778,35 +3772,36 @@ void func_800BC620(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), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, gCircleShadowDL);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800BC770(GlobalContext* globalCtx, s16 y, s16 countdown) {
- s16 idx = Quake_Add(&globalCtx->mainCamera, 3);
+void func_800BC770(PlayState* play, s16 y, s16 countdown) {
+ s16 idx = Quake_Add(&play->mainCamera, 3);
Quake_SetSpeed(idx, 20000);
Quake_SetQuakeValues(idx, y, 0, 0, 0);
Quake_SetCountdown(idx, countdown);
}
-void func_800BC7D8(GlobalContext* globalCtx, s16 y, s16 countdown, s16 speed) {
- s16 idx = Quake_Add(&globalCtx->mainCamera, 3);
+void func_800BC7D8(PlayState* play, s16 y, s16 countdown, s16 speed) {
+ s16 idx = Quake_Add(&play->mainCamera, 3);
Quake_SetSpeed(idx, speed);
Quake_SetQuakeValues(idx, y, 0, 0, 0);
Quake_SetCountdown(idx, countdown);
}
-void func_800BC848(Actor* actor, GlobalContext* globalCtx, s16 y, s16 countdown) {
+// Actor_RequestRumble?
+void func_800BC848(Actor* actor, PlayState* play, s16 y, s16 countdown) {
if (y >= 5) {
- func_8013ECE0(actor->xyzDistToPlayerSq, 255, 20, 150);
+ Rumble_Request(actor->xyzDistToPlayerSq, 255, 20, 150);
} else {
- func_8013ECE0(actor->xyzDistToPlayerSq, 180, 20, 100);
+ Rumble_Request(actor->xyzDistToPlayerSq, 180, 20, 100);
}
- func_800BC770(globalCtx, y, countdown);
+ func_800BC770(play, y, countdown);
}
typedef struct {
@@ -3829,7 +3824,7 @@ DoorLockInfo sDoorLocksInfo[DOORLOCK_MAX] = {
* 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) {
s32 pad[2];
MtxF baseMtxF;
s32 i;
@@ -3839,7 +3834,7 @@ void Actor_DrawDoorLock(GlobalContext* globalCtx, s32 frame, s32 type) {
f32 chainRotZ = entry->chainsRotZInit;
f32 rotZStep;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Translate(0.0f, entry->yShift, 500.0f, MTXMODE_APPLY);
Matrix_Get(&baseMtxF);
@@ -3855,7 +3850,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), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, entry->chainDL);
if ((i % 2) != 0) {
@@ -3870,14 +3865,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), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, entry->lockDL);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void Actor_SpawnShieldParticlesMetal(GlobalContext* globalCtx, Vec3f* pos) {
- CollisionCheck_SpawnShieldParticlesMetal(globalCtx, pos);
+void Actor_SpawnShieldParticlesMetal(PlayState* play, Vec3f* pos) {
+ CollisionCheck_SpawnShieldParticlesMetal(play, pos);
}
void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u16 xluFlag, u16 duration) {
@@ -3889,24 +3884,24 @@ void Actor_SetColorFilter(Actor* actor, u16 colorFlag, u16 colorIntensityMax, u1
actor->colorFilterTimer = duration;
}
-Hilite* func_800BCBF4(Vec3f* arg0, GlobalContext* globalCtx) {
+Hilite* func_800BCBF4(Vec3f* arg0, 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 Hilite_DrawOpa(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx);
+ return Hilite_DrawOpa(arg0, &play->view.eye, &lightDir, play->state.gfxCtx);
}
-Hilite* func_800BCC68(Vec3f* arg0, GlobalContext* globalCtx) {
+Hilite* func_800BCC68(Vec3f* arg0, 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 Hilite_DrawXlu(arg0, &globalCtx->view.eye, &lightDir, globalCtx->state.gfxCtx);
+ return Hilite_DrawXlu(arg0, &play->view.eye, &lightDir, play->state.gfxCtx);
}
/**
@@ -4055,20 +4050,20 @@ void Actor_GetClosestPosOnPath(Vec3s* points, s32 numPoints, Vec3f* srcPos, Vec3
}
// unused
-s32 func_800BD2B4(GlobalContext* globalCtx, Actor* actor, s16* arg2, f32 arg3,
- u16 (*textIdCallback)(GlobalContext*, Actor*), s16 (*arg5)(GlobalContext*, Actor*)) {
- if (Actor_ProcessTalkRequest(actor, &globalCtx->state)) {
+s32 func_800BD2B4(PlayState* play, Actor* actor, s16* arg2, f32 arg3, u16 (*textIdCallback)(PlayState*, Actor*),
+ s16 (*arg5)(PlayState*, Actor*)) {
+ if (Actor_ProcessTalkRequest(actor, &play->state)) {
*arg2 = true;
return true;
} else if (*arg2) {
- *arg2 = arg5(globalCtx, actor);
+ *arg2 = arg5(play, actor);
return false;
- } else if (!func_800B8934(globalCtx, actor)) {
+ } else if (!func_800B8934(play, actor)) {
return false;
- } else if (!func_800B8614(actor, globalCtx, arg3)) {
+ } else if (!func_800B8614(actor, play, arg3)) {
return false;
} else {
- actor->textId = textIdCallback(globalCtx, actor);
+ actor->textId = textIdCallback(play, actor);
return false;
}
}
@@ -4250,39 +4245,39 @@ Gfx* func_800BD9A0(GraphicsContext* gfxCtx) {
}
// unused
-void func_800BD9E0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw,
- PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
- func_8012C28C(globalCtx->state.gfxCtx);
+void func_800BD9E0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw,
+ Actor* actor, s16 alpha) {
+ OPEN_DISPS(play->state.gfxCtx);
+ func_8012C28C(play->state.gfxCtx);
gDPSetEnvColor(POLY_OPA_DISP++, 0, 0, 0, alpha);
gSPSegment(POLY_OPA_DISP++, 0x0C, gEmptyDL);
- POLY_OPA_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount,
+ POLY_OPA_DISP = SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount,
overrideLimbDraw, postLimbDraw, actor, POLY_OPA_DISP);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800BDAA0(GlobalContext* globalCtx, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw,
- PostLimbDraw postLimbDraw, Actor* actor, s16 alpha) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
- func_8012C2DC(globalCtx->state.gfxCtx);
+void func_800BDAA0(PlayState* play, SkelAnime* skelAnime, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw,
+ Actor* actor, s16 alpha) {
+ OPEN_DISPS(play->state.gfxCtx);
+ func_8012C2DC(play->state.gfxCtx);
gDPSetEnvColor(POLY_XLU_DISP++, 0, 0, 0, alpha);
- gSPSegment(POLY_XLU_DISP++, 0x0C, func_800BD9A0(globalCtx->state.gfxCtx));
+ gSPSegment(POLY_XLU_DISP++, 0x0C, func_800BD9A0(play->state.gfxCtx));
- POLY_XLU_DISP = SkelAnime_DrawFlex(globalCtx, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount,
+ POLY_XLU_DISP = SkelAnime_DrawFlex(play, skelAnime->skeleton, skelAnime->jointTable, skelAnime->dListCount,
overrideLimbDraw, postLimbDraw, actor, POLY_XLU_DISP);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
// Unused
-s16 func_800BDB6C(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3) {
- Player* player = GET_PLAYER(globalCtx);
+s16 func_800BDB6C(Actor* actor, PlayState* play, s16 arg2, f32 arg3) {
+ Player* player = GET_PLAYER(play);
f32 phi_f2;
- if ((globalCtx->csCtx.state != 0) || gDbgCamEnabled) {
- phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &globalCtx->view.eye) * 0.25f;
+ if ((play->csCtx.state != 0) || gDbgCamEnabled) {
+ phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &play->view.eye) * 0.25f;
} else {
phi_f2 = Math_Vec3f_DistXYZ(&actor->world.pos, &player->actor.world.pos);
}
@@ -4313,8 +4308,8 @@ void Actor_ChangeAnimationByInfo(SkelAnime* skelAnime, AnimationInfo* animation,
}
// Unused
-void func_800BDCF4(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 size) {
- s32 frames = globalCtx->gameplayFrames;
+void func_800BDCF4(PlayState* play, s16* arg1, s16* arg2, s32 size) {
+ s32 frames = play->gameplayFrames;
s32 i;
for (i = 0; i < size; i++) {
@@ -4323,7 +4318,7 @@ void func_800BDCF4(GlobalContext* globalCtx, s16* arg1, s16* arg2, s32 size) {
}
}
-void Actor_Noop(Actor* actor, GlobalContext* globalCtx) {
+void Actor_Noop(Actor* actor, PlayState* play) {
}
#include "z_cheap_proc.c"
@@ -4333,8 +4328,8 @@ void Actor_Noop(Actor* actor, 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* inActor, s16 actorId, u8 actorCategory, f32 distance) {
- Actor* actor = globalCtx->actorCtx.actorLists[actorCategory].first;
+Actor* Actor_FindNearby(PlayState* play, Actor* inActor, s16 actorId, u8 actorCategory, f32 distance) {
+ Actor* actor = play->actorCtx.actorLists[actorCategory].first;
while (actor != NULL) {
if (actor == inActor || ((actorId != -1) && (actorId != actor->id))) {
@@ -4352,8 +4347,8 @@ Actor* Actor_FindNearby(GlobalContext* globalCtx, Actor* inActor, s16 actorId, u
return NULL;
}
-s32 func_800BE184(GlobalContext* globalCtx, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5) {
- Player* player = GET_PLAYER(globalCtx);
+s32 func_800BE184(PlayState* play, Actor* actor, f32 xzDist, s16 arg3, s16 arg4, s16 arg5) {
+ Player* player = GET_PLAYER(play);
s16 phi_v0 = BINANG_SUB(BINANG_ROT180(actor->yawTowardsPlayer), player->actor.shape.rot.y);
s16 temp_t0 = actor->yawTowardsPlayer - arg5;
@@ -4502,7 +4497,7 @@ TexturePtr sElectricSparkTextures[] = {
/**
* Draw common damage effects applied to each limb provided in limbPos
*/
-void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale,
+void Actor_DrawDamageEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s16 limbPosCount, f32 effectScale,
f32 frozenSteamScale, f32 effectAlpha, u8 type) {
if (effectAlpha > 0.001f) {
s32 twoTexScrollParam;
@@ -4514,13 +4509,13 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
f32 electricSparksScale;
f32 steamScale;
Vec3f* limbPosStart = limbPos;
- u32 gameplayFrames = globalCtx->gameplayFrames;
+ u32 gameplayFrames = play->gameplayFrames;
f32 effectAlphaScaled;
currentMatrix = Matrix_GetCurrent();
// Apply sfx along with damage effect
- if ((actor != NULL) && (effectAlpha > 0.05f) && (globalCtx->gameOverCtx.state == 0)) {
+ if ((actor != NULL) && (effectAlpha > 0.05f) && (play->gameOverCtx.state == 0)) {
if (type == ACTOR_DRAW_DMGEFF_FIRE) {
Actor_PlaySfxAtPos(actor, NA_SE_EV_BURN_OUT - SFX_FLAG);
} else if (type == ACTOR_DRAW_DMGEFF_BLUE_FIRE) {
@@ -4532,21 +4527,21 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
}
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C2DC(globalCtx->state.gfxCtx);
+ func_8012C2DC(play->state.gfxCtx);
switch (type) {
case ACTOR_DRAW_DMGEFF_FROZEN_NO_SFX:
case ACTOR_DRAW_DMGEFF_FROZEN_SFX:
frozenScale = ((KREG(19) * 0.01f) + 2.3f) * effectScale;
steamScale = ((KREG(28) * 0.0001f) + 0.035f) * frozenSteamScale;
- func_800BCC68(limbPos, globalCtx);
+ func_800BCC68(limbPos, play);
// Setup to draw ice over frozen actor
gSPSegment(POLY_XLU_DISP++, 0x08,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0,
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, gameplayFrames & 0xFF, 32, 16, 1, 0,
(gameplayFrames * 2) & 0xFF, 64, 32));
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, 170, 255, 255, 255);
gSPDisplayList(POLY_XLU_DISP++, gFrozenIceDL);
@@ -4577,7 +4572,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
Matrix_RotateZF(M_PI, MTXMODE_APPLY);
}
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gFrozenIceVtxDL);
@@ -4602,14 +4597,14 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
for (limbIndex = 0; limbIndex < limbPosCount; limbIndex++, limbPos++) {
twoTexScrollParam = ((limbIndex * 3) + gameplayFrames);
gSPSegment(POLY_XLU_DISP++, 0x08,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, twoTexScrollParam * 3,
- twoTexScrollParam * -12, 32, 64, 1, 0, 0, 32, 32));
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, twoTexScrollParam * 3, twoTexScrollParam * -12,
+ 32, 64, 1, 0, 0, 32, 32));
Matrix_Translate(limbPos->x, limbPos->y, limbPos->z, MTXMODE_NEW);
- Matrix_ReplaceRotation(&globalCtx->billboardMtxF);
+ Matrix_ReplaceRotation(&play->billboardMtxF);
Matrix_Scale(steamScale, steamScale, 1.0f, MTXMODE_APPLY);
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gFrozenSteamVtxDL);
@@ -4626,7 +4621,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
type = 255;
}
- Matrix_Put(&globalCtx->billboardMtxF);
+ Matrix_Put(&play->billboardMtxF);
Matrix_Scale((effectScale * 0.005f) * 1.35f, (effectScale * 0.005f), (effectScale * 0.005f) * 1.35f,
MTXMODE_APPLY);
@@ -4649,7 +4644,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gDPSetPrimColor(POLY_XLU_DISP++, 0x80, 0x80, 255, 255, type, (u8)alpha);
gSPSegment(POLY_XLU_DISP++, 0x08,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0,
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0,
((limbIndex * 10 + gameplayFrames) * -20) & 0x1FF, 32, 128));
Matrix_RotateYF(M_PI, MTXMODE_APPLY);
@@ -4657,7 +4652,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
currentMatrix->mf[3][1] = limbPos->y;
currentMatrix->mf[3][2] = limbPos->z;
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL);
@@ -4689,7 +4684,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 100, 128);
}
- Matrix_Put(&globalCtx->billboardMtxF);
+ Matrix_Put(&play->billboardMtxF);
Matrix_Scale(lightOrbsScale, lightOrbsScale, 1.0f, MTXMODE_APPLY);
// Apply and draw a light orb over each limb of frozen actor
@@ -4699,7 +4694,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
currentMatrix->mf[3][1] = limbPos->y;
currentMatrix->mf[3][2] = limbPos->z;
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gLightOrbVtxDL);
@@ -4718,7 +4713,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
}
gSPSegment(POLY_XLU_DISP++, 0x08,
- Lib_SegmentedToVirtual(sElectricSparkTextures[globalCtx->gameplayFrames % 4]));
+ Lib_SegmentedToVirtual(sElectricSparkTextures[play->gameplayFrames % 4]));
gSPDisplayList(POLY_XLU_DISP++, gElectricSparkDL);
@@ -4727,7 +4722,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
gDPSetEnvColor(POLY_XLU_DISP++, (u8)(sREG(20) + 255), (u8)(sREG(21) + 255), (u8)sREG(22), (u8)sREG(23));
- Matrix_Put(&globalCtx->billboardMtxF);
+ Matrix_Put(&play->billboardMtxF);
Matrix_Scale(electricSparksScale, electricSparksScale, electricSparksScale, MTXMODE_APPLY);
// Every limb draws two electric sparks at random orientations
@@ -4739,7 +4734,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y;
currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z;
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL);
@@ -4751,7 +4746,7 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
currentMatrix->mf[3][1] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->y;
currentMatrix->mf[3][2] = randPlusMinusPoint5Scaled((f32)sREG(24) + 30.0f) + limbPos->z;
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gElectricSparkVtxDL);
@@ -4760,12 +4755,12 @@ void Actor_DrawDamageEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbP
break;
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
-void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos[], s32 limbPosCount,
- s32 effectsPerLimb, f32 scale, f32 scaleRange) {
+void Actor_SpawnIceEffects(PlayState* play, Actor* actor, Vec3f limbPos[], s32 limbPosCount, s32 effectsPerLimb,
+ f32 scale, f32 scaleRange) {
static Color_RGBA8 primColor = { 170, 255, 255, 255 };
static Color_RGBA8 envColor = { 200, 200, 255, 255 };
static Vec3f accel = { 0.0f, -1.0f, 0.0f };
@@ -4776,7 +4771,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos
s16 yaw;
s32 j;
- SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN);
+ SoundSource_PlaySfxAtFixedWorldPos(play, &actor->world.pos, 30, NA_SE_EV_ICE_BROKEN);
for (i = 0; i < limbPosCount; i++) {
yaw = Actor_YawToPoint(actor, limbPos);
@@ -4790,7 +4785,7 @@ void Actor_SpawnIceEffects(GlobalContext* globalCtx, Actor* actor, Vec3f limbPos
velocity.y = Rand_ZeroFloat(4.0f) + 8.0f;
velocity.z *= Math_CosS(randomYaw);
- EffectSsEnIce_Spawn(globalCtx, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor,
+ EffectSsEnIce_Spawn(play, limbPos, Rand_ZeroFloat(scaleRange) + scale, &velocity, &accel, &primColor,
&envColor, 30);
}
diff --git a/src/code/z_bg_item.c b/src/code/z_bg_item.c
index 74adbe695..79bdf2b82 100644
--- a/src/code/z_bg_item.c
+++ b/src/code/z_bg_item.c
@@ -15,11 +15,11 @@ void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags) {
dynaActor->stateFlags = DYNAPOLY_STATE_NONE;
}
-void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) {
+void DynaPolyActor_LoadMesh(PlayState* play, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) {
CollisionHeader* header = NULL;
CollisionHeader_GetVirtual(meshHeader, &header);
- dynaActor->bgId = DynaPoly_SetBgActor(globalCtx, &globalCtx->colCtx.dyna, &dynaActor->actor, header);
+ dynaActor->bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &dynaActor->actor, header);
}
void DynaPolyActor_ResetState(DynaPolyActor* dynaActor) {
@@ -102,7 +102,7 @@ s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor) {
}
}
-s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius,
+s32 DynaPolyActor_ValidateMove(PlayState* play, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius,
s16 startHeight) {
Vec3f startPos;
Vec3f endPos;
@@ -125,16 +125,16 @@ s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActo
endPos.y = startPos.y;
endPos.z = sign * adjustedEndRadius * cos + startPos.z;
- if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false,
- true, &bgId, &dynaActor->actor, 0.0f)) {
+ if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true,
+ &bgId, &dynaActor->actor, 0.0f)) {
return false;
}
startPos.x = (dynaActor->actor.world.pos.x * 2.0f) - startPos.x;
startPos.z = (dynaActor->actor.world.pos.z * 2.0f) - startPos.z;
endPos.x = sign * adjustedEndRadius * sin + startPos.x;
endPos.z = sign * adjustedEndRadius * cos + startPos.z;
- if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false,
- true, &bgId, &dynaActor->actor, 0.0f)) {
+ if (BgCheck_EntityLineTest3(&play->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true,
+ &bgId, &dynaActor->actor, 0.0f)) {
return false;
}
return true;
diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c
index 0667bd84b..7aaae22bc 100644
--- a/src/code/z_bgcheck.c
+++ b/src/code/z_bgcheck.c
@@ -124,13 +124,13 @@ void DynaSSNodeList_SetSSListHead(DynaSSNodeList* list, SSList* ssList, s16* pol
ssList->head = index;
}
-void DynaSSNodeList_Init(GlobalContext* globalCtx, DynaSSNodeList* list) {
+void DynaSSNodeList_Init(PlayState* play, DynaSSNodeList* list) {
list->tbl = NULL;
list->count = 0;
}
-void DynaSSNodeList_Alloc(GlobalContext* globalCtx, DynaSSNodeList* list, u32 numNodes) {
- list->tbl = (SSNode*)THA_AllocEndAlign(&globalCtx->state.heap, numNodes * sizeof(SSNode), -2);
+void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* list, u32 numNodes) {
+ list->tbl = (SSNode*)THA_AllocEndAlign(&play->state.heap, numNodes * sizeof(SSNode), -2);
list->maxNodes = numNodes;
list->count = 0;
}
@@ -1376,7 +1376,7 @@ s32 BgCheck_PolyIntersectsSubdivision(Vec3f* min, Vec3f* max, CollisionPoly* pol
* Initialize StaticLookup Table
* returns size of table, in bytes
*/
-u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx, StaticLookup* lookupTbl) {
+u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, PlayState* play, StaticLookup* lookupTbl) {
Vec3s* vtxList;
CollisionPoly* polyList;
s32 polyMax;
@@ -1460,11 +1460,11 @@ u32 BgCheck_InitStaticLookup(CollisionContext* colCtx, GlobalContext* globalCtx,
/**
* Returns whether the current scene should reserve less memory for it's collision lookup
*/
-s32 BgCheck_IsSmallMemScene(GlobalContext* globalCtx) {
+s32 BgCheck_IsSmallMemScene(PlayState* play) {
s16* i;
for (i = sSmallMemScenes; i < sSmallMemScenes + ARRAY_COUNT(sSmallMemScenes); i++) {
- if (globalCtx->sceneNum == *i) {
+ if (play->sceneNum == *i) {
return true;
}
}
@@ -1499,11 +1499,11 @@ void BgCheck_SetSubdivisionDimension(f32 min, s32 subdivAmount, f32* max, f32* s
*max = *subdivLength * subdivAmount + min;
}
-s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s32* maxPolygons, s32* maxVertices) {
+s32 BgCheck_GetSpecialSceneMaxObjects(PlayState* play, s32* maxNodes, s32* maxPolygons, s32* maxVertices) {
s32 i;
for (i = 0; i < ARRAY_COUNT(sCustomDynapolyMem); i++) {
- if (globalCtx->sceneNum == sCustomDynapolyMem[i].sceneId) {
+ if (play->sceneNum == sCustomDynapolyMem[i].sceneId) {
*maxNodes = sCustomDynapolyMem[i].maxNodes;
*maxPolygons = sCustomDynapolyMem[i].maxPolygons;
*maxVertices = sCustomDynapolyMem[i].maxVertices;
@@ -1516,7 +1516,7 @@ s32 BgCheck_GetSpecialSceneMaxObjects(GlobalContext* globalCtx, s32* maxNodes, s
/**
* Allocate CollisionContext
*/
-void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, CollisionHeader* colHeader) {
+void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader* colHeader) {
u32 tblMax;
u32 memSize;
u32 lookupTblMemSize;
@@ -1527,7 +1527,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
colCtx->colHeader = colHeader;
colCtx->flags = 0;
- if (BgCheck_IsSmallMemScene(globalCtx)) {
+ if (BgCheck_IsSmallMemScene(play)) {
colCtx->memSize = 0xF000;
colCtx->dyna.polyNodesMax = 1000;
colCtx->dyna.polyListMax = 512;
@@ -1540,7 +1540,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
s32 useCustomSubdivisions;
s32 i;
- if (BgCheck_TryGetCustomMemsize(globalCtx->sceneNum, &customMemSize)) {
+ if (BgCheck_TryGetCustomMemsize(play->sceneNum, &customMemSize)) {
colCtx->memSize = customMemSize;
} else {
colCtx->memSize = 0x23000;
@@ -1548,12 +1548,12 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
colCtx->dyna.polyNodesMax = 1000;
colCtx->dyna.polyListMax = 544;
colCtx->dyna.vtxListMax = 512;
- BgCheck_GetSpecialSceneMaxObjects(globalCtx, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax,
+ BgCheck_GetSpecialSceneMaxObjects(play, &colCtx->dyna.polyNodesMax, &colCtx->dyna.polyListMax,
&colCtx->dyna.vtxListMax);
useCustomSubdivisions = false;
for (i = 0; i < ARRAY_COUNT(sSceneSubdivisionList); i++) {
- if (globalCtx->sceneNum == sSceneSubdivisionList[i].sceneId) {
+ if (play->sceneNum == sSceneSubdivisionList[i].sceneId) {
colCtx->subdivAmount.x = sSceneSubdivisionList[i].subdivAmount.x;
colCtx->subdivAmount.y = sSceneSubdivisionList[i].subdivAmount.y;
colCtx->subdivAmount.z = sSceneSubdivisionList[i].subdivAmount.z;
@@ -1568,7 +1568,7 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
}
}
colCtx->lookupTbl = THA_AllocEndAlign(
- &globalCtx->state.heap,
+ &play->state.heap,
colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1);
if (colCtx->lookupTbl == NULL) {
Fault_AddHungupAndCrash("../z_bgcheck.c", 3955);
@@ -1601,12 +1601,12 @@ void BgCheck_Allocate(CollisionContext* colCtx, GlobalContext* globalCtx, Collis
}
SSNodeList_Init(&colCtx->polyNodes);
- SSNodeList_Alloc(globalCtx, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons);
+ SSNodeList_Alloc(play, &colCtx->polyNodes, tblMax, colCtx->colHeader->numPolygons);
- lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, globalCtx, colCtx->lookupTbl);
+ lookupTblMemSize = BgCheck_InitStaticLookup(colCtx, play, colCtx->lookupTbl);
- DynaPoly_Init(globalCtx, &colCtx->dyna);
- DynaPoly_Alloc(globalCtx, &colCtx->dyna);
+ DynaPoly_Init(play, &colCtx->dyna);
+ DynaPoly_Alloc(play, &colCtx->dyna);
}
/**
@@ -1661,7 +1661,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 checkDist, s32 arg9) {
f32 yIntersectDyna;
f32 yIntersect;
@@ -1693,7 +1693,7 @@ f32 BgCheck_RaycastFloorImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
checkPos.y -= colCtx->subdivLength.y;
}
if (!(arg9 & 1)) {
- dynaRaycast.globalCtx = globalCtx;
+ dynaRaycast.play = play;
dynaRaycast.colCtx = colCtx;
dynaRaycast.xpFlags = xpFlags;
dynaRaycast.resultPoly = outPoly;
@@ -1741,22 +1741,20 @@ 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, 0);
+ return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 0);
}
/**
* Public raycast toward floor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor2_1(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
- Vec3f* pos) {
+f32 BgCheck_EntityRaycastFloor2_1(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, 1);
+ return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, &bgId, pos, NULL, 0x1C, 1.0f, 1);
}
/**
@@ -1780,18 +1778,18 @@ f32 BgCheck_EntityRaycastFloor5(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_2(GlobalContext* globalCtx, 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, 0);
+f32 BgCheck_EntityRaycastFloor5_2(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
+ Actor* actor, Vec3f* pos) {
+ return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x1C, 1.0f, 0);
}
/**
* Public raycast toward floor
* returns yIntersect of the poly found, or BGCHECK_Y_MIN if no poly detected
*/
-f32 BgCheck_EntityRaycastFloor5_3(GlobalContext* globalCtx, CollisionContext* colCtx, CollisionPoly** outPoly,
- s32* bgId, Actor* actor, Vec3f* pos) {
- return BgCheck_RaycastFloorImpl(globalCtx, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0);
+f32 BgCheck_EntityRaycastFloor5_3(PlayState* play, CollisionContext* colCtx, CollisionPoly** outPoly, s32* bgId,
+ Actor* actor, Vec3f* pos) {
+ return BgCheck_RaycastFloorImpl(play, colCtx, COLPOLY_IGNORE_ENTITY, outPoly, bgId, pos, actor, 0x3C, 1.0f, 0);
}
/**
@@ -2453,11 +2451,11 @@ void SSNodeList_Init(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.heap, tblMax * sizeof(SSNode), -2);
- this->polyCheckTbl = THA_AllocEndAlign16(&globalCtx->state.heap, numPolys * sizeof(u8));
+ this->tbl = THA_AllocEndAlign(&play->state.heap, tblMax * sizeof(SSNode), -2);
+ this->polyCheckTbl = THA_AllocEndAlign16(&play->state.heap, numPolys * sizeof(u8));
if (this->polyCheckTbl == NULL) {
sprintf(D_801ED950, "this->polygon_check == NULL(game_alloc() MemoryAllocationError.)\n");
@@ -2554,7 +2552,7 @@ void DynaLookup_ResetWaterBoxStartIndex(u16* waterBoxStartIndex) {
/**
* Initialize BgActor
*/
-void BgActor_Init(GlobalContext* globalCtx, BgActor* bgActor) {
+void BgActor_Init(PlayState* play, BgActor* bgActor) {
bgActor->actor = NULL;
bgActor->colHeader = NULL;
ScaleRotPos_Init(&bgActor->prevTransform);
@@ -2598,8 +2596,8 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) {
/**
* Allocate dyna.polyList
*/
-void DynaPoly_AllocPolyList(GlobalContext* globalCtx, CollisionPoly** polyList, s32 numPolys) {
- *polyList = THA_AllocEndAlign(&globalCtx->state.heap, numPolys * sizeof(CollisionPoly), -2);
+void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) {
+ *polyList = THA_AllocEndAlign(&play->state.heap, numPolys * sizeof(CollisionPoly), -2);
}
/**
@@ -2612,8 +2610,8 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) {
/**
* Allocate dyna.vtxList
*/
-void DynaPoly_AllocVtxList(GlobalContext* globalCtx, Vec3s** vtxList, s32 numVtx) {
- *vtxList = THA_AllocEndAlign(&globalCtx->state.heap, numVtx * sizeof(Vec3s), -2);
+void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) {
+ *vtxList = THA_AllocEndAlign(&play->state.heap, numVtx * sizeof(Vec3s), -2);
}
/**
@@ -2627,14 +2625,14 @@ void DynaPoly_InitWaterBoxList(DynaWaterBoxList* waterBoxList) {
/**
* Allocate dyna.waterBoxList
*/
-void DynaPoly_AllocWaterBoxList(GlobalContext* globalCtx, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) {
- waterBoxList->boxes = THA_AllocEndAlign(&globalCtx->state.heap, numWaterBoxes * sizeof(WaterBox), -2);
+void DynaPoly_AllocWaterBoxList(PlayState* play, DynaWaterBoxList* waterBoxList, s32 numWaterBoxes) {
+ waterBoxList->boxes = THA_AllocEndAlign(&play->state.heap, numWaterBoxes * sizeof(WaterBox), -2);
}
/**
* Update BgActor's prevTransform
*/
-void DynaPoly_SetBgActorPrevTransform(GlobalContext* globalCtx, BgActor* bgActor) {
+void DynaPoly_SetBgActorPrevTransform(PlayState* play, BgActor* bgActor) {
bgActor->prevTransform = bgActor->curTransform;
}
@@ -2651,43 +2649,42 @@ 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);
DynaPoly_InitWaterBoxList(&dyna->waterBoxList);
- DynaSSNodeList_Init(globalCtx, &dyna->polyNodes);
+ DynaSSNodeList_Init(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_Init(globalCtx, &dyna->bgActors[i]);
+ BgActor_Init(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);
DynaPoly_InitWaterBoxList(&dyna->waterBoxList);
- DynaPoly_AllocWaterBoxList(globalCtx, &dyna->waterBoxList, DYNA_WATERBOX_MAX);
+ DynaPoly_AllocWaterBoxList(play, &dyna->waterBoxList, DYNA_WATERBOX_MAX);
- DynaSSNodeList_Init(globalCtx, &dyna->polyNodes);
- DynaSSNodeList_Alloc(globalCtx, &dyna->polyNodes, dyna->polyNodesMax);
+ DynaSSNodeList_Init(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;
@@ -2721,42 +2718,42 @@ DynaPolyActor* DynaPoly_GetActor(CollisionContext* colCtx, s32 bgId) {
return (DynaPolyActor*)colCtx->dyna.bgActors[bgId].actor;
}
-void func_800C62BC(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
+void func_800C62BC(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] |= 4;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
-void func_800C6314(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
+void func_800C6314(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] &= ~4;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
-void func_800C636C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
+void func_800C636C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] |= 8;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
-void func_800C63C4(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
+void func_800C63C4(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] &= ~8;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
-void func_800C641C(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
+void func_800C641C(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] |= 0x20;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
-void func_800C6474(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId) {
+void func_800C6474(PlayState* play, DynaCollisionContext* dyna, s32 bgId) {
if (DynaPoly_IsBgIdBgActor(bgId)) {
dyna->bgActorFlags[bgId] &= ~0x20;
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
@@ -2766,13 +2763,13 @@ void func_800C6474(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;
if (DynaPoly_IsBgIdBgActor(bgId) == false) {
return;
}
- actor = DynaPoly_GetActor(&globalCtx->colCtx, bgId);
+ actor = DynaPoly_GetActor(&play->colCtx, bgId);
if (actor != NULL) {
actor->bgId = BGACTOR_NEG_ONE;
@@ -2781,7 +2778,7 @@ void DynaPoly_DeleteBgActor(GlobalContext* globalCtx, DynaCollisionContext* dyna
}
}
-void func_800C6554(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
+void func_800C6554(PlayState* play, DynaCollisionContext* dyna) {
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
@@ -2839,8 +2836,8 @@ void BgCheck_CalcWaterboxDimensions(Vec3f* minPos, Vec3f* maxXPos, Vec3f* maxZPo
/**
* original name: DynaPolyInfo_expandSRT
*/
-void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex,
- s32* polyStartIndex, s32* waterBoxStartIndex) {
+void DynaPoly_ExpandSRT(PlayState* play, DynaCollisionContext* dyna, s32 bgId, s32* vtxStartIndex, s32* polyStartIndex,
+ s32* waterBoxStartIndex) {
Actor* actor;
s32 pad;
s32 pad2;
@@ -3064,13 +3061,13 @@ void DynaPoly_ExpandSRT(GlobalContext* globalCtx, DynaCollisionContext* dyna, s3
#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/DynaPoly_ExpandSRT.s")
#endif
-void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionContext* dyna, Actor* actor) {
+void BgCheck_ResetFlagsIfLoadedActor(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) {
DynaPolyActor_ResetState((DynaPolyActor*)actor);
return;
@@ -3082,7 +3079,7 @@ void BgCheck_ResetFlagsIfLoadedActor(GlobalContext* globalCtx, DynaCollisionCont
/**
* original name: DynaPolyInfo_setup
*/
-void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
+void DynaPoly_Setup(PlayState* play, DynaCollisionContext* dyna) {
DynaPolyActor* actor;
s32 vtxStartIndex;
s32 polyStartIndex;
@@ -3099,19 +3096,19 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
if (dyna->bgActorFlags[i] & 2) {
// Initialize BgActor
dyna->bgActorFlags[i] = 0;
- BgActor_Init(globalCtx, &dyna->bgActors[i]);
+ BgActor_Init(play, &dyna->bgActors[i]);
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
if (dyna->bgActors[i].actor != NULL && dyna->bgActors[i].actor->update == NULL) {
// Delete BgActor
- 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_Init(globalCtx, &dyna->bgActors[i]);
+ BgActor_Init(play, &dyna->bgActors[i]);
dyna->bitFlag |= DYNAPOLY_INVALIDATE_LOOKUP;
}
}
@@ -3120,7 +3117,7 @@ void DynaPoly_Setup(GlobalContext* globalCtx, DynaCollisionContext* dyna) {
waterBoxStartIndex = 0;
for (i = 0; i < BG_ACTOR_MAX; i++) {
if ((dyna->bgActorFlags[i] & 1) && !(dyna->bgActorFlags[i] & 2)) {
- DynaPoly_ExpandSRT(globalCtx, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex);
+ DynaPoly_ExpandSRT(play, dyna, i, &vtxStartIndex, &polyStartIndex, &waterBoxStartIndex);
}
}
dyna->bitFlag &= ~DYNAPOLY_INVALIDATE_LOOKUP;
@@ -3150,12 +3147,12 @@ void func_800C756C(DynaCollisionContext* dyna, s32* numPolygons, s32* numVertice
/**
* 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]);
}
}
}
@@ -3295,10 +3292,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) {
- 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;
@@ -3983,7 +3980,7 @@ void CollisionHeader_GetVirtual(CollisionHeader* colHeader, CollisionHeader** de
/**
* SEGMENT_TO_VIRTUAL all active BgActor CollisionHeaders
*/
-void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globalCtx) {
+void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, PlayState* play) {
DynaCollisionContext* dyna = &colCtx->dyna;
s32 i;
u16 flag;
@@ -3991,7 +3988,7 @@ void BgCheck_InitCollisionHeaders(CollisionContext* colCtx, GlobalContext* globa
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);
}
}
@@ -4378,7 +4375,7 @@ u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32
* 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, s32* bgId) {
CollisionHeader* colHeader;
u32 room;
@@ -4392,7 +4389,7 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = 0x3F & (curWaterBox->properties >> 13);
- if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) {
+ if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) {
if (curWaterBox->properties & 0x80000) {
continue;
}
@@ -4438,16 +4435,16 @@ s32 WaterBox_GetSurfaceImpl(GlobalContext* globalCtx, CollisionContext* colCtx,
}
// boolean
-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) {
- return WaterBox_GetSurface1_2(globalCtx, colCtx, x, z, ySurface, outWaterBox);
+ return WaterBox_GetSurface1_2(play, colCtx, x, z, ySurface, outWaterBox);
}
// boolean
-s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
+s32 WaterBox_GetSurface1_2(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) {
s32 bgId;
- return WaterBox_GetSurfaceImpl(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId);
+ return WaterBox_GetSurfaceImpl(play, colCtx, x, z, ySurface, outWaterBox, &bgId);
}
#ifdef NON_MATCHING
@@ -4457,7 +4454,7 @@ s32 WaterBox_GetSurface1_2(GlobalContext* globalCtx, CollisionContext* colCtx, f
* 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 surfaceCheckDist,
+s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceCheckDist,
WaterBox** outWaterBox, s32* bgId) {
CollisionHeader* colHeader;
s32 room;
@@ -4477,7 +4474,7 @@ s32 WaterBox_GetSurface2(GlobalContext* globalCtx, CollisionContext* colCtx, Vec
waterBox = &colHeader->waterBoxes[i];
room = WATERBOX_ROOM(waterBox->properties);
- if (!(room == globalCtx->roomCtx.currRoom.num || room == 0x3F)) {
+ if (!(room == play->roomCtx.currRoom.num || room == 0x3F)) {
continue;
}
if ((waterBox->properties & 0x80000)) {
@@ -4596,8 +4593,8 @@ 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_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
- WaterBox** outWaterBox, s32* bgId) {
+s32 func_800CA6F0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox,
+ s32* bgId) {
CollisionHeader* colHeader;
u32 room;
WaterBox* curWaterBox;
@@ -4614,7 +4611,7 @@ s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32
for (curWaterBox = colHeader->waterBoxes; curWaterBox < colHeader->waterBoxes + colHeader->numWaterBoxes;
curWaterBox++) {
room = WATERBOX_ROOM(curWaterBox->properties);
- if (room == (u32)globalCtx->roomCtx.currRoom.num || room == 0x3F) {
+ if (room == (u32)play->roomCtx.currRoom.num || room == 0x3F) {
if ((curWaterBox->properties & 0x80000) != 0) {
if (curWaterBox->minPos.x < x && x < curWaterBox->minPos.x + curWaterBox->xLength) {
if (curWaterBox->minPos.z < z && z < curWaterBox->minPos.z + curWaterBox->zLength) {
@@ -4656,11 +4653,10 @@ s32 func_800CA6F0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32
#pragma GLOBAL_ASM("asm/non_matchings/code/z_bgcheck/func_800CA6F0.s")
#endif
-s32 func_800CA9D0(GlobalContext* globalCtx, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
- WaterBox** outWaterBox) {
+s32 func_800CA9D0(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox) {
s32 bgId;
- return func_800CA6F0(globalCtx, colCtx, x, z, ySurface, outWaterBox, &bgId);
+ return func_800CA6F0(play, colCtx, x, z, ySurface, outWaterBox, &bgId);
}
/**
diff --git a/src/code/z_cheap_proc.c b/src/code/z_cheap_proc.c
index d0709fde9..2b4f67cae 100644
--- a/src/code/z_cheap_proc.c
+++ b/src/code/z_cheap_proc.c
@@ -3,37 +3,37 @@
/**
* Draws a display list to the opaque display buffer
*/
-void Gfx_DrawDListOpa(GlobalContext* globalCtx, Gfx* dlist) {
+void Gfx_DrawDListOpa(PlayState* play, Gfx* dlist) {
Gfx* dl;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
dl = POLY_OPA_DISP;
gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]);
- gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(&dl[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(&dl[2], dlist);
POLY_OPA_DISP = &dl[3];
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Draws a display list to the translucent display buffer
*/
-void Gfx_DrawDListXlu(GlobalContext* globalCtx, Gfx* dlist) {
+void Gfx_DrawDListXlu(PlayState* play, Gfx* dlist) {
Gfx* dl;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
dl = POLY_XLU_DISP;
gSPDisplayList(&dl[0], &sSetupDL[6 * 0x19]);
- gSPMatrix(&dl[1], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(&dl[1], Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(&dl[2], dlist);
POLY_XLU_DISP = &dl[3];
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
diff --git a/src/code/z_collision_check.c b/src/code/z_collision_check.c
index 7ac956e5d..01234f7fc 100644
--- a/src/code/z_collision_check.c
+++ b/src/code/z_collision_check.c
@@ -90,7 +90,7 @@ s32 CollisionCheck_GetToucherDamage(Collider* at, ColliderInfo* atInfo, Collider
return atInfo->toucher.damage;
}
-s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_InitBase(PlayState* play, Collider* collider) {
static Collider defaultCollider = {
NULL, NULL, NULL, NULL, AT_NONE, AC_NONE, OC1_NONE, OC2_NONE, COLTYPE_HIT3, COLSHAPE_MAX,
};
@@ -99,14 +99,14 @@ s32 Collider_InitBase(GlobalContext* globalCtx, Collider* collider) {
return 1;
}
-s32 Collider_DestroyBase(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_DestroyBase(PlayState* play, Collider* collider) {
return 1;
}
/**
* Uses default OC2_TYPE_1 and COLTYPE_HIT0
*/
-s32 Collider_SetBaseToActor(GlobalContext* globalCtx, Collider* collider, ColliderInitToActor* src) {
+s32 Collider_SetBaseToActor(PlayState* play, Collider* collider, ColliderInitToActor* src) {
collider->actor = src->actor;
collider->atFlags = src->atFlags;
collider->acFlags = src->acFlags;
@@ -119,7 +119,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;
@@ -130,7 +130,7 @@ s32 Collider_SetBaseType1(GlobalContext* globalCtx, Collider* collider, Actor* a
return 1;
}
-s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor, ColliderInit* src) {
+s32 Collider_SetBase(PlayState* play, Collider* collider, Actor* actor, ColliderInit* src) {
collider->actor = actor;
collider->colType = src->colType;
collider->atFlags = src->atFlags;
@@ -141,62 +141,62 @@ s32 Collider_SetBase(GlobalContext* globalCtx, Collider* collider, Actor* actor,
return 1;
}
-void Collider_ResetATBase(GlobalContext* globalCtx, Collider* collider) {
+void Collider_ResetATBase(PlayState* play, Collider* collider) {
collider->at = NULL;
collider->atFlags &= ~(AT_HIT | AT_BOUNCED);
}
-void Collider_ResetACBase(GlobalContext* globalCtx, Collider* collider) {
+void Collider_ResetACBase(PlayState* play, Collider* collider) {
collider->ac = NULL;
collider->acFlags &= ~(AC_HIT | AC_BOUNCED);
}
-void Collider_ResetOCBase(GlobalContext* globalCtx, Collider* collider) {
+void Collider_ResetOCBase(PlayState* play, Collider* collider) {
collider->oc = NULL;
collider->ocFlags1 &= ~OC1_HIT;
collider->ocFlags2 &= ~OC2_HIT_PLAYER;
}
-s32 Collider_InitTouch(GlobalContext* globalCtx, ColliderTouch* touch) {
+s32 Collider_InitTouch(PlayState* play, ColliderTouch* touch) {
static ColliderTouch defaultColliderTouch = { 0x00000000, 0, 0 };
*touch = defaultColliderTouch;
return 1;
}
-s32 Collider_DestroyTouch(GlobalContext* globalCtx, ColliderTouch* touch) {
+s32 Collider_DestroyTouch(PlayState* play, ColliderTouch* touch) {
return 1;
}
-s32 Collider_SetTouch(GlobalContext* globalCtx, ColliderTouch* touch, ColliderTouchInit* src) {
+s32 Collider_SetTouch(PlayState* play, ColliderTouch* touch, ColliderTouchInit* src) {
touch->dmgFlags = src->dmgFlags;
touch->effect = src->effect;
touch->damage = src->damage;
return 1;
}
-void Collider_ResetATInfoUnk(GlobalContext* globalCtx, ColliderInfo* info) {
+void Collider_ResetATInfoUnk(PlayState* play, ColliderInfo* info) {
}
-s32 Collider_InitBump(GlobalContext* globalCtx, ColliderBump* bump) {
+s32 Collider_InitBump(PlayState* play, ColliderBump* bump) {
static ColliderBump defaultColliderBump = { 0xF7CFFFFF, 0, 0, { 0, 0, 0 } };
*bump = defaultColliderBump;
return 1;
}
-s32 Collider_DestroyBump(GlobalContext* globalCtx, ColliderBump* bump) {
+s32 Collider_DestroyBump(PlayState* play, ColliderBump* bump) {
return 1;
}
-s32 Collider_SetBump(GlobalContext* globalCtx, ColliderBump* bump, ColliderBumpInit* src) {
+s32 Collider_SetBump(PlayState* play, ColliderBump* bump, ColliderBumpInit* src) {
bump->dmgFlags = src->dmgFlags;
bump->effect = src->effect;
bump->defense = src->defense;
return 1;
}
-s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info) {
+s32 Collider_InitInfo(PlayState* play, ColliderInfo* info) {
static ColliderInfo defaultColliderInfo = {
{ 0, 0, 0 }, { 0xF7CFFFFF, 0, 0, { 0, 0, 0 } },
ELEMTYPE_UNK0, TOUCH_NONE,
@@ -206,36 +206,36 @@ s32 Collider_InitInfo(GlobalContext* globalCtx, ColliderInfo* info) {
};
*info = defaultColliderInfo;
- Collider_InitTouch(globalCtx, &info->toucher);
- Collider_InitBump(globalCtx, &info->bumper);
+ Collider_InitTouch(play, &info->toucher);
+ Collider_InitBump(play, &info->bumper);
return 1;
}
-s32 Collider_DestroyInfo(GlobalContext* globalCtx, ColliderInfo* info) {
- Collider_DestroyTouch(globalCtx, &info->toucher);
- Collider_DestroyBump(globalCtx, &info->bumper);
+s32 Collider_DestroyInfo(PlayState* play, ColliderInfo* info) {
+ Collider_DestroyTouch(play, &info->toucher);
+ Collider_DestroyBump(play, &info->bumper);
return 1;
}
-s32 Collider_SetInfo(GlobalContext* globalCtx, ColliderInfo* info, ColliderInfoInit* src) {
+s32 Collider_SetInfo(PlayState* play, ColliderInfo* info, ColliderInfoInit* src) {
info->elemType = src->elemType;
- Collider_SetTouch(globalCtx, &info->toucher, &src->toucher);
- Collider_SetBump(globalCtx, &info->bumper, &src->bumper);
+ Collider_SetTouch(play, &info->toucher, &src->toucher);
+ Collider_SetBump(play, &info->bumper, &src->bumper);
info->toucherFlags = src->toucherFlags;
info->bumperFlags = src->bumperFlags;
info->ocElemFlags = src->ocElemFlags;
return 1;
}
-void Collider_ResetATInfo(GlobalContext* globalCtx, ColliderInfo* info) {
+void Collider_ResetATInfo(PlayState* play, ColliderInfo* info) {
info->atHit = NULL;
info->atHitInfo = NULL;
info->toucherFlags &= ~TOUCH_HIT;
info->toucherFlags &= ~TOUCH_DREW_HITMARK;
- Collider_ResetATInfoUnk(globalCtx, info);
+ Collider_ResetATInfoUnk(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;
@@ -243,11 +243,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 defaultColliderJntSphElementDim = {
{ { 0, 0, 0 }, 0 },
{ { 0, 0, 0 }, 0 },
@@ -259,56 +259,55 @@ s32 Collider_InitJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElemen
return 1;
}
-s32 Collider_DestroyJntSphElementDim(GlobalContext* globalCtx, ColliderJntSphElementDim* dim) {
+s32 Collider_DestroyJntSphElementDim(PlayState* play, ColliderJntSphElementDim* dim) {
return 1;
}
-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 1;
}
-s32 Collider_InitJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element) {
- Collider_InitInfo(globalCtx, &element->info);
- Collider_InitJntSphElementDim(globalCtx, &element->dim);
+s32 Collider_InitJntSphElement(PlayState* play, ColliderJntSphElement* element) {
+ Collider_InitInfo(play, &element->info);
+ Collider_InitJntSphElementDim(play, &element->dim);
return 1;
}
-s32 Collider_DestroyJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* element) {
- Collider_DestroyInfo(globalCtx, &element->info);
- Collider_DestroyJntSphElementDim(globalCtx, &element->dim);
+s32 Collider_DestroyJntSphElement(PlayState* play, ColliderJntSphElement* element) {
+ Collider_DestroyInfo(play, &element->info);
+ Collider_DestroyJntSphElementDim(play, &element->dim);
return 1;
}
-s32 Collider_SetJntSphElement(GlobalContext* globalCtx, ColliderJntSphElement* dest, ColliderJntSphElementInit* src) {
- Collider_SetInfo(globalCtx, &dest->info, &src->info);
- Collider_SetJntSphElementDim(globalCtx, &dest->dim, &src->dim);
+s32 Collider_SetJntSphElement(PlayState* play, ColliderJntSphElement* dest, ColliderJntSphElementInit* src) {
+ Collider_SetInfo(play, &dest->info, &src->info);
+ Collider_SetJntSphElementDim(play, &dest->dim, &src->dim);
return 1;
}
-s32 Collider_ResetJntSphElementAT(GlobalContext* globalCtx, ColliderJntSphElement* collider) {
- Collider_ResetATInfo(globalCtx, &collider->info);
+s32 Collider_ResetJntSphElementAT(PlayState* play, ColliderJntSphElement* collider) {
+ Collider_ResetATInfo(play, &collider->info);
return 1;
}
-s32 Collider_ResetJntSphElementAC(GlobalContext* globalCtx, ColliderJntSphElement* collider) {
- Collider_ResetACInfo(globalCtx, &collider->info);
+s32 Collider_ResetJntSphElementAC(PlayState* play, ColliderJntSphElement* collider) {
+ Collider_ResetACInfo(play, &collider->info);
return 1;
}
-s32 Collider_ResetJntSphElementOC(GlobalContext* globalCtx, ColliderJntSphElement* collider) {
- Collider_ResetOCInfo(globalCtx, &collider->info);
+s32 Collider_ResetJntSphElementOC(PlayState* play, ColliderJntSphElement* collider) {
+ Collider_ResetOCInfo(play, &collider->info);
return 1;
}
/**
* Initializes a ColliderJntSph to default values
*/
-s32 Collider_InitJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) {
- Collider_InitBase(globalCtx, &collider->base);
+s32 Collider_InitJntSph(PlayState* play, ColliderJntSph* collider) {
+ Collider_InitBase(play, &collider->base);
collider->count = 0;
collider->elements = NULL;
return 1;
@@ -317,12 +316,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;
@@ -336,13 +335,13 @@ 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;
@@ -353,11 +352,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.
*/
-s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider, ColliderJntSphInitToActor* src) {
+s32 Collider_SetJntSphToActor(PlayState* play, ColliderJntSph* collider, ColliderJntSphInitToActor* src) {
ColliderJntSphElement* destElem;
ColliderJntSphElementInit* srcElem;
- Collider_SetBaseToActor(globalCtx, &collider->base, &src->base);
+ Collider_SetBaseToActor(play, &collider->base, &src->base);
collider->count = src->count;
collider->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement));
@@ -368,8 +367,8 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider
for (destElem = collider->elements, srcElem = src->elements; destElem < &collider->elements[collider->count];
destElem++, srcElem++) {
- Collider_InitJntSphElement(globalCtx, destElem);
- Collider_SetJntSphElement(globalCtx, destElem, srcElem);
+ Collider_InitJntSphElement(play, destElem);
+ Collider_SetJntSphElement(play, destElem, srcElem);
}
return 1;
}
@@ -378,12 +377,12 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider
* Sets up the ColliderJntSph using the values in src and dynamically allocates the element array. Uses default
* OC2_TYPE_1.
*/
-s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor,
+s32 Collider_SetJntSphAllocType1(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor,
ColliderJntSphInitType1* src) {
ColliderJntSphElement* destElem;
ColliderJntSphElementInit* srcElem;
- Collider_SetBaseType1(globalCtx, &sphereGroup->base, actor, &src->base);
+ Collider_SetBaseType1(play, &sphereGroup->base, actor, &src->base);
sphereGroup->count = src->count;
sphereGroup->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement));
@@ -394,8 +393,8 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* spher
for (destElem = sphereGroup->elements, srcElem = src->elements;
destElem < &sphereGroup->elements[sphereGroup->count]; destElem++, srcElem++) {
- Collider_InitJntSphElement(globalCtx, destElem);
- Collider_SetJntSphElement(globalCtx, destElem, srcElem);
+ Collider_InitJntSphElement(play, destElem);
+ Collider_SetJntSphElement(play, destElem, srcElem);
}
return 1;
}
@@ -403,19 +402,19 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* spher
/**
* Sets up the ColliderJntSph using the values in src, placing the element array in elements.
*/
-s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src,
+s32 Collider_SetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src,
ColliderJntSphElement* elements) {
ColliderJntSphElement* destElem;
ColliderJntSphElementInit* srcElem;
- Collider_SetBase(globalCtx, &sphereGroup->base, actor, &src->base);
+ Collider_SetBase(play, &sphereGroup->base, actor, &src->base);
sphereGroup->count = src->count;
sphereGroup->elements = elements;
for (destElem = sphereGroup->elements, srcElem = src->elements;
destElem < &sphereGroup->elements[sphereGroup->count]; destElem++, srcElem++) {
- Collider_InitJntSphElement(globalCtx, destElem);
- Collider_SetJntSphElement(globalCtx, destElem, srcElem);
+ Collider_InitJntSphElement(play, destElem);
+ Collider_SetJntSphElement(play, destElem, srcElem);
}
return 1;
@@ -424,24 +423,24 @@ s32 Collider_SetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Ac
/**
* Fully initializes a ColliderJntSph using the values in `src`, placing the element array in elements.
*/
-s32 Collider_InitAndSetJntSph(GlobalContext* globalCtx, ColliderJntSph* sphereGroup, Actor* actor,
- ColliderJntSphInit* src, ColliderJntSphElement* elements) {
- Collider_InitJntSph(globalCtx, sphereGroup);
- Collider_SetJntSph(globalCtx, sphereGroup, actor, src, elements);
+s32 Collider_InitAndSetJntSph(PlayState* play, ColliderJntSph* sphereGroup, Actor* actor, ColliderJntSphInit* src,
+ ColliderJntSphElement* elements) {
+ Collider_InitJntSph(play, sphereGroup);
+ Collider_SetJntSph(play, sphereGroup, actor, src, elements);
return 0;
}
/**
* Resets the collider's AT collision flags.
*/
-s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetJntSphAT(PlayState* play, Collider* collider) {
ColliderJntSphElement* element;
ColliderJntSph* jntSph = (ColliderJntSph*)collider;
- Collider_ResetATBase(globalCtx, &jntSph->base);
+ Collider_ResetATBase(play, &jntSph->base);
for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) {
- Collider_ResetJntSphElementAT(globalCtx, element);
+ Collider_ResetJntSphElementAT(play, element);
}
return 1;
}
@@ -449,14 +448,14 @@ s32 Collider_ResetJntSphAT(GlobalContext* globalCtx, Collider* collider) {
/**
* Resets the collider's AC collision flags.
*/
-s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetJntSphAC(PlayState* play, Collider* collider) {
ColliderJntSphElement* element;
ColliderJntSph* jntSph = (ColliderJntSph*)collider;
- Collider_ResetACBase(globalCtx, &jntSph->base);
+ Collider_ResetACBase(play, &jntSph->base);
for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) {
- Collider_ResetJntSphElementAC(globalCtx, element);
+ Collider_ResetJntSphElementAC(play, element);
}
return 1;
}
@@ -464,30 +463,30 @@ s32 Collider_ResetJntSphAC(GlobalContext* globalCtx, Collider* collider) {
/**
* Resets the collider's OC collision flags.
*/
-s32 Collider_ResetJntSphOC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetJntSphOC(PlayState* play, Collider* collider) {
ColliderJntSphElement* element;
ColliderJntSph* jntSph = (ColliderJntSph*)collider;
- Collider_ResetOCBase(globalCtx, &jntSph->base);
+ Collider_ResetOCBase(play, &jntSph->base);
for (element = jntSph->elements; element < &jntSph->elements[jntSph->count]; element++) {
- Collider_ResetJntSphElementOC(globalCtx, element);
+ Collider_ResetJntSphElementOC(play, element);
}
return 1;
}
-s32 Collider_InitCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) {
+s32 Collider_InitCylinderDim(PlayState* play, Cylinder16* dim) {
static Cylinder16 defaultColliderCylinderDim = { 0, 0, 0, { 0, 0, 0 } };
*dim = defaultColliderCylinderDim;
return 1;
}
-s32 Collider_DestroyCylinderDim(GlobalContext* globalCtx, Cylinder16* dim) {
+s32 Collider_DestroyCylinderDim(PlayState* play, Cylinder16* dim) {
return 1;
}
-s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dim, Cylinder16* src) {
+s32 Collider_SetCylinderDim(PlayState* play, Cylinder16* dim, Cylinder16* src) {
*dim = *src;
return 1;
}
@@ -495,20 +494,20 @@ s32 Collider_SetCylinderDim(GlobalContext* globalCtx, Cylinder16* dim, Cylinder1
/**
* Initializes a ColliderCylinder to default values
*/
-s32 Collider_InitCylinder(GlobalContext* globalCtx, ColliderCylinder* collider) {
- Collider_InitBase(globalCtx, &collider->base);
- Collider_InitInfo(globalCtx, &collider->info);
- Collider_InitCylinderDim(globalCtx, &collider->dim);
+s32 Collider_InitCylinder(PlayState* play, ColliderCylinder* collider) {
+ Collider_InitBase(play, &collider->base);
+ Collider_InitInfo(play, &collider->info);
+ Collider_InitCylinderDim(play, &collider->dim);
return 1;
}
/**
* Destroys a ColliderCylinder
*/
-s32 Collider_DestroyCylinder(GlobalContext* globalCtx, ColliderCylinder* collider) {
- Collider_DestroyBase(globalCtx, &collider->base);
- Collider_DestroyInfo(globalCtx, &collider->info);
- Collider_DestroyCylinderDim(globalCtx, &collider->dim);
+s32 Collider_DestroyCylinder(PlayState* play, ColliderCylinder* collider) {
+ Collider_DestroyBase(play, &collider->base);
+ Collider_DestroyInfo(play, &collider->info);
+ Collider_DestroyCylinderDim(play, &collider->dim);
return 1;
}
@@ -516,80 +515,77 @@ 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.
*/
-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 1;
}
/**
* Sets up the ColliderCylinder using the values in src. Uses default OC2_TYPE_1
*/
-s32 Collider_SetCylinderType1(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor,
+s32 Collider_SetCylinderType1(PlayState* play, ColliderCylinder* collider, Actor* actor,
ColliderCylinderInitType1* src) {
- Collider_SetBaseType1(globalCtx, &collider->base, actor, &src->base);
- Collider_SetInfo(globalCtx, &collider->info, &src->info);
- Collider_SetCylinderDim(globalCtx, &collider->dim, &src->dim);
+ Collider_SetBaseType1(play, &collider->base, actor, &src->base);
+ Collider_SetInfo(play, &collider->info, &src->info);
+ Collider_SetCylinderDim(play, &collider->dim, &src->dim);
return 1;
}
/**
* Sets up the ColliderCylinder using the values in src.
*/
-s32 Collider_SetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor,
- 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 1;
}
/**
* Fully initializes a ColliderCylinder using the values in src.
*/
-s32 Collider_InitAndSetCylinder(GlobalContext* globalCtx, ColliderCylinder* collider, Actor* actor,
- ColliderCylinderInit* src) {
- Collider_InitCylinder(globalCtx, collider);
- Collider_SetCylinder(globalCtx, collider, actor, src);
+s32 Collider_InitAndSetCylinder(PlayState* play, ColliderCylinder* collider, Actor* actor, ColliderCylinderInit* src) {
+ Collider_InitCylinder(play, collider);
+ Collider_SetCylinder(play, collider, actor, src);
return 1;
}
/**
* Resets the collider's AT collision flags.
*/
-s32 Collider_ResetCylinderAT(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetCylinderAT(PlayState* play, Collider* collider) {
ColliderCylinder* cylinder = (ColliderCylinder*)collider;
- Collider_ResetATBase(globalCtx, &cylinder->base);
- Collider_ResetATInfo(globalCtx, &cylinder->info);
+ Collider_ResetATBase(play, &cylinder->base);
+ Collider_ResetATInfo(play, &cylinder->info);
return 1;
}
/**
* Resets the collider's AC collision flags.
*/
-s32 Collider_ResetCylinderAC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetCylinderAC(PlayState* play, Collider* collider) {
ColliderCylinder* cylinder = (ColliderCylinder*)collider;
- Collider_ResetACBase(globalCtx, &cylinder->base);
- Collider_ResetACInfo(globalCtx, &cylinder->info);
+ Collider_ResetACBase(play, &cylinder->base);
+ Collider_ResetACInfo(play, &cylinder->info);
return 1;
}
/**
* Resets the collider's OC collision flags.
*/
-s32 Collider_ResetCylinderOC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetCylinderOC(PlayState* play, Collider* collider) {
ColliderCylinder* cylinder = (ColliderCylinder*)collider;
- Collider_ResetOCBase(globalCtx, &cylinder->base);
- Collider_ResetOCInfo(globalCtx, &cylinder->info);
+ Collider_ResetOCBase(play, &cylinder->base);
+ Collider_ResetOCInfo(play, &cylinder->info);
return 1;
}
-s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) {
+s32 Collider_InitTrisElementDim(PlayState* play, TriNorm* dim) {
static TriNorm defaultColliderTrisElementDim = {
{ { 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 },
@@ -599,11 +595,11 @@ s32 Collider_InitTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) {
return 1;
}
-s32 Collider_DestroyTrisElementDim(GlobalContext* globalCtx, TriNorm* dim) {
+s32 Collider_DestroyTrisElementDim(PlayState* play, TriNorm* dim) {
return 1;
}
-s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dim, ColliderTrisElementDimInit* src) {
+s32 Collider_SetTrisElementDim(PlayState* play, TriNorm* dim, ColliderTrisElementDimInit* src) {
Vec3f* destVtx;
Vec3f* srcVtx;
f32 nx;
@@ -624,44 +620,44 @@ s32 Collider_SetTrisElementDim(GlobalContext* globalCtx, TriNorm* dim, ColliderT
return 1;
}
-s32 Collider_InitTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element) {
- Collider_InitInfo(globalCtx, &element->info);
- Collider_InitTrisElementDim(globalCtx, &element->dim);
+s32 Collider_InitTrisElement(PlayState* play, ColliderTrisElement* element) {
+ Collider_InitInfo(play, &element->info);
+ Collider_InitTrisElementDim(play, &element->dim);
return 1;
}
-s32 Collider_DestroyTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element) {
- Collider_DestroyInfo(globalCtx, &element->info);
- Collider_DestroyTrisElementDim(globalCtx, &element->dim);
+s32 Collider_DestroyTrisElement(PlayState* play, ColliderTrisElement* element) {
+ Collider_DestroyInfo(play, &element->info);
+ Collider_DestroyTrisElementDim(play, &element->dim);
return 1;
}
-s32 Collider_SetTrisElement(GlobalContext* globalCtx, ColliderTrisElement* element, ColliderTrisElementInit* src) {
- Collider_SetInfo(globalCtx, &element->info, &src->info);
- Collider_SetTrisElementDim(globalCtx, &element->dim, &src->dim);
+s32 Collider_SetTrisElement(PlayState* play, ColliderTrisElement* element, ColliderTrisElementInit* src) {
+ Collider_SetInfo(play, &element->info, &src->info);
+ Collider_SetTrisElementDim(play, &element->dim, &src->dim);
return 1;
}
-s32 Collider_ResetTrisElementAT(GlobalContext* globalCtx, ColliderTrisElement* element) {
- Collider_ResetATInfo(globalCtx, &element->info);
+s32 Collider_ResetTrisElementAT(PlayState* play, ColliderTrisElement* element) {
+ Collider_ResetATInfo(play, &element->info);
return 1;
}
-s32 Collider_ResetTrisElementAC(GlobalContext* globalCtx, ColliderTrisElement* element) {
- Collider_ResetACInfo(globalCtx, &element->info);
+s32 Collider_ResetTrisElementAC(PlayState* play, ColliderTrisElement* element) {
+ Collider_ResetACInfo(play, &element->info);
return 1;
}
-s32 Collider_ResetTrisElementOC(GlobalContext* globalCtx, ColliderTrisElement* element) {
- Collider_ResetOCInfo(globalCtx, &element->info);
+s32 Collider_ResetTrisElementOC(PlayState* play, ColliderTrisElement* element) {
+ Collider_ResetOCInfo(play, &element->info);
return 1;
}
/**
* Initializes a ColliderTris to default values
*/
-s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris) {
- Collider_InitBase(globalCtx, &tris->base);
+s32 Collider_InitTris(PlayState* play, ColliderTris* tris) {
+ Collider_InitBase(play, &tris->base);
tris->count = 0;
tris->elements = NULL;
return 1;
@@ -670,13 +666,13 @@ s32 Collider_InitTris(GlobalContext* globalCtx, ColliderTris* tris) {
/**
* Destroys a dynamically allocated ColliderTris
*/
-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;
@@ -691,13 +687,13 @@ 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;
tris->elements = NULL;
@@ -708,11 +704,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.
*/
-s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src) {
+s32 Collider_SetTrisAllocType1(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInitType1* src) {
ColliderTrisElement* element;
ColliderTrisElementInit* srcElem;
- Collider_SetBaseType1(globalCtx, &tris->base, actor, &src->base);
+ Collider_SetBaseType1(play, &tris->base, actor, &src->base);
tris->count = src->count;
tris->elements = ZeldaArena_Malloc(tris->count * sizeof(ColliderTrisElement));
@@ -723,8 +719,8 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Act
for (element = tris->elements, srcElem = src->elements; element < &tris->elements[tris->count];
element++, srcElem++) {
- Collider_InitTrisElement(globalCtx, element);
- Collider_SetTrisElement(globalCtx, element, srcElem);
+ Collider_InitTrisElement(play, element);
+ Collider_SetTrisElement(play, element, srcElem);
}
return 1;
@@ -733,19 +729,19 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Act
/**
* Sets up the ColliderTris using the values in src, placing the element array in elements.
*/
-s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src,
+s32 Collider_SetTris(PlayState* play, ColliderTris* triGroup, Actor* actor, ColliderTrisInit* src,
ColliderTrisElement* tris) {
ColliderTrisElement* element;
ColliderTrisElementInit* srcElem;
- Collider_SetBase(globalCtx, &triGroup->base, actor, &src->base);
+ Collider_SetBase(play, &triGroup->base, actor, &src->base);
triGroup->count = src->count;
triGroup->elements = tris;
for (element = triGroup->elements, srcElem = src->elements; element < &triGroup->elements[triGroup->count];
element++, srcElem++) {
- Collider_InitTrisElement(globalCtx, element);
- Collider_SetTrisElement(globalCtx, element, srcElem);
+ Collider_InitTrisElement(play, element);
+ Collider_SetTrisElement(play, element, srcElem);
}
return 1;
@@ -754,24 +750,24 @@ s32 Collider_SetTris(GlobalContext* globalCtx, ColliderTris* triGroup, Actor* ac
/**
* Fully initializes a ColliderTris using the values in src, placing the element array in elements.
*/
-s32 Collider_InitAndSetTris(GlobalContext* globalCtx, ColliderTris* tris, Actor* actor, ColliderTrisInit* src,
+s32 Collider_InitAndSetTris(PlayState* play, ColliderTris* tris, Actor* actor, ColliderTrisInit* src,
ColliderTrisElement* elements) {
- Collider_InitTris(globalCtx, tris);
- Collider_SetTris(globalCtx, tris, actor, src, elements);
+ Collider_InitTris(play, tris);
+ Collider_SetTris(play, tris, actor, src, elements);
return 0;
}
/**
* Resets the collider's AT collision flags.
*/
-s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetTrisAT(PlayState* play, Collider* collider) {
ColliderTrisElement* element;
ColliderTris* tris = (ColliderTris*)collider;
- Collider_ResetATBase(globalCtx, &tris->base);
+ Collider_ResetATBase(play, &tris->base);
for (element = tris->elements; element < &tris->elements[tris->count]; element++) {
- Collider_ResetTrisElementAT(globalCtx, element);
+ Collider_ResetTrisElementAT(play, element);
}
return 1;
}
@@ -779,14 +775,14 @@ s32 Collider_ResetTrisAT(GlobalContext* globalCtx, Collider* collider) {
/**
* Resets the collider's AC collision flags.
*/
-s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetTrisAC(PlayState* play, Collider* collider) {
ColliderTrisElement* element;
ColliderTris* tris = (ColliderTris*)collider;
- Collider_ResetACBase(globalCtx, &tris->base);
+ Collider_ResetACBase(play, &tris->base);
for (element = tris->elements; element < &tris->elements[tris->count]; element++) {
- Collider_ResetTrisElementAC(globalCtx, element);
+ Collider_ResetTrisElementAC(play, element);
}
return 1;
}
@@ -794,19 +790,19 @@ s32 Collider_ResetTrisAC(GlobalContext* globalCtx, Collider* collider) {
/**
* Resets the collider's OC collision flags.
*/
-s32 Collider_ResetTrisOC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetTrisOC(PlayState* play, Collider* collider) {
ColliderTrisElement* element;
ColliderTris* tris = (ColliderTris*)collider;
- Collider_ResetOCBase(globalCtx, &tris->base);
+ Collider_ResetOCBase(play, &tris->base);
for (element = tris->elements; element < &tris->elements[tris->count]; element++) {
- Collider_ResetTrisElementOC(globalCtx, element);
+ Collider_ResetTrisElementOC(play, element);
}
return 1;
}
-s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) {
+s32 Collider_InitQuadDim(PlayState* play, ColliderQuadDim* dim) {
static ColliderQuadDim defaultColliderQuadDim = {
{ { 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 },
@@ -818,11 +814,11 @@ s32 Collider_InitQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) {
return 1;
}
-s32 Collider_DestroyQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim) {
+s32 Collider_DestroyQuadDim(PlayState* play, ColliderQuadDim* dim) {
return 1;
}
-s32 Collider_ResetQuadACDist(GlobalContext* globalCtx, ColliderQuadDim* dim) {
+s32 Collider_ResetQuadACDist(PlayState* play, ColliderQuadDim* dim) {
dim->acDist = 1.0E38f;
return 1;
}
@@ -836,7 +832,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* dim, ColliderQuadDimInit* init) {
+s32 Collider_SetQuadDim(PlayState* play, ColliderQuadDim* dim, ColliderQuadDimInit* init) {
dim->quad[0] = init->quad[0];
dim->quad[1] = init->quad[1];
dim->quad[2] = init->quad[2];
@@ -849,83 +845,83 @@ s32 Collider_SetQuadDim(GlobalContext* globalCtx, ColliderQuadDim* dim, Collider
/**
* Initializes a ColliderQuad to default values.
*/
-s32 Collider_InitQuad(GlobalContext* globalCtx, ColliderQuad* collider) {
- Collider_InitBase(globalCtx, &collider->base);
- Collider_InitInfo(globalCtx, &collider->info);
- Collider_InitQuadDim(globalCtx, &collider->dim);
+s32 Collider_InitQuad(PlayState* play, ColliderQuad* collider) {
+ Collider_InitBase(play, &collider->base);
+ Collider_InitInfo(play, &collider->info);
+ Collider_InitQuadDim(play, &collider->dim);
return 1;
}
/**
* Destroys a ColliderQuad.
*/
-s32 Collider_DestroyQuad(GlobalContext* globalCtx, ColliderQuad* collider) {
- Collider_DestroyBase(globalCtx, &collider->base);
- Collider_DestroyInfo(globalCtx, &collider->info);
- Collider_DestroyQuadDim(globalCtx, &collider->dim);
+s32 Collider_DestroyQuad(PlayState* play, ColliderQuad* collider) {
+ Collider_DestroyBase(play, &collider->base);
+ Collider_DestroyInfo(play, &collider->info);
+ Collider_DestroyQuadDim(play, &collider->dim);
return 1;
}
/**
* Sets up the ColliderQuad using the values in src. Uses the default OC2_TYPE_1
*/
-s32 Collider_SetQuadType1(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src) {
- Collider_SetBaseType1(globalCtx, &collider->base, actor, &src->base);
- Collider_SetInfo(globalCtx, &collider->info, &src->info);
- Collider_SetQuadDim(globalCtx, &collider->dim, &src->dim);
+s32 Collider_SetQuadType1(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInitType1* src) {
+ Collider_SetBaseType1(play, &collider->base, actor, &src->base);
+ Collider_SetInfo(play, &collider->info, &src->info);
+ Collider_SetQuadDim(play, &collider->dim, &src->dim);
return 1;
}
/**
* Sets up the ColliderQuad using the values in src.
*/
-s32 Collider_SetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) {
- Collider_SetBase(globalCtx, &collider->base, actor, &src->base);
- Collider_SetInfo(globalCtx, &collider->info, &src->info);
- Collider_SetQuadDim(globalCtx, &collider->dim, &src->dim);
+s32 Collider_SetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) {
+ Collider_SetBase(play, &collider->base, actor, &src->base);
+ Collider_SetInfo(play, &collider->info, &src->info);
+ Collider_SetQuadDim(play, &collider->dim, &src->dim);
return 1;
}
/**
* Fully initializes a ColliderQuad using the values in src.
*/
-s32 Collider_InitAndSetQuad(GlobalContext* globalCtx, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) {
- Collider_InitQuad(globalCtx, collider);
- Collider_SetQuad(globalCtx, collider, actor, src);
+s32 Collider_InitAndSetQuad(PlayState* play, ColliderQuad* collider, Actor* actor, ColliderQuadInit* src) {
+ Collider_InitQuad(play, collider);
+ Collider_SetQuad(play, collider, actor, src);
return 0;
}
/**
* Resets the collider's AT collision flags.
*/
-s32 Collider_ResetQuadAT(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetQuadAT(PlayState* play, Collider* collider) {
ColliderQuad* quad = (ColliderQuad*)collider;
- Collider_ResetATBase(globalCtx, &quad->base);
- Collider_ResetATInfo(globalCtx, &quad->info);
- Collider_ResetQuadACDist(globalCtx, &quad->dim);
+ Collider_ResetATBase(play, &quad->base);
+ Collider_ResetATInfo(play, &quad->info);
+ Collider_ResetQuadACDist(play, &quad->dim);
return 1;
}
/**
* Resets the collider's AC collision flags.
*/
-s32 Collider_ResetQuadAC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetQuadAC(PlayState* play, Collider* collider) {
ColliderQuad* quad = (ColliderQuad*)collider;
- Collider_ResetACBase(globalCtx, &quad->base);
- Collider_ResetACInfo(globalCtx, &quad->info);
+ Collider_ResetACBase(play, &quad->base);
+ Collider_ResetACInfo(play, &quad->info);
return 1;
}
/**
* Resets the collider's OC collision flags.
*/
-s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetQuadOC(PlayState* play, Collider* collider) {
ColliderQuad* quad = (ColliderQuad*)collider;
- Collider_ResetOCBase(globalCtx, &quad->base);
- Collider_ResetOCInfo(globalCtx, &quad->info);
+ Collider_ResetOCBase(play, &quad->base);
+ Collider_ResetOCInfo(play, &quad->info);
return 1;
}
@@ -933,7 +929,7 @@ s32 Collider_ResetQuadOC(GlobalContext* globalCtx, Collider* collider) {
* For quad colliders with TOUCH_NEAREST, resets the previous AC collider it hit if the current element is closer,
* otherwise returns false. Used on player AT colliders to prevent multiple collisions from registering.
*/
-s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3f* hitPos) {
+s32 Collider_QuadSetNearestAC(PlayState* play, ColliderQuad* quad, Vec3f* hitPos) {
f32 acDist;
Vec3f dcMid;
@@ -947,10 +943,10 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3
quad->dim.acDist = acDist;
if (quad->info.atHit != NULL) {
- Collider_ResetACBase(globalCtx, quad->info.atHit);
+ Collider_ResetACBase(play, quad->info.atHit);
}
if (quad->info.atHitInfo != NULL) {
- Collider_ResetACInfo(globalCtx, quad->info.atHitInfo);
+ Collider_ResetACInfo(play, quad->info.atHitInfo);
}
return 1;
} else {
@@ -961,80 +957,79 @@ s32 Collider_QuadSetNearestAC(GlobalContext* globalCtx, ColliderQuad* quad, Vec3
/**
* Initializes a ColliderSphere to default values.
*/
-s32 Collider_InitSphere(GlobalContext* globalCtx, ColliderSphere* collider) {
- Collider_InitBase(globalCtx, &collider->base);
- Collider_InitInfo(globalCtx, &collider->info);
- Collider_InitJntSphElementDim(globalCtx, &collider->dim);
+s32 Collider_InitSphere(PlayState* play, ColliderSphere* collider) {
+ Collider_InitBase(play, &collider->base);
+ Collider_InitInfo(play, &collider->info);
+ Collider_InitJntSphElementDim(play, &collider->dim);
return 1;
}
/**
* Destroys a ColliderSphere.
*/
-s32 Collider_DestroySphere(GlobalContext* globalCtx, ColliderSphere* collider) {
- Collider_DestroyBase(globalCtx, &collider->base);
- Collider_DestroyInfo(globalCtx, &collider->info);
- Collider_DestroyJntSphElementDim(globalCtx, &collider->dim);
+s32 Collider_DestroySphere(PlayState* play, ColliderSphere* collider) {
+ Collider_DestroyBase(play, &collider->base);
+ Collider_DestroyInfo(play, &collider->info);
+ Collider_DestroyJntSphElementDim(play, &collider->dim);
return 1;
}
/**
* Sets up the ColliderSphere using the values in src.
*/
-s32 Collider_SetSphere(GlobalContext* globalCtx, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src) {
- Collider_SetBase(globalCtx, &collider->base, actor, &src->base);
- Collider_SetInfo(globalCtx, &collider->info, &src->info);
- Collider_SetJntSphElementDim(globalCtx, &collider->dim, &src->dim);
+s32 Collider_SetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src) {
+ Collider_SetBase(play, &collider->base, actor, &src->base);
+ Collider_SetInfo(play, &collider->info, &src->info);
+ Collider_SetJntSphElementDim(play, &collider->dim, &src->dim);
return 1;
}
/**
* Fully initializes a ColliderSphere using the values in src.
*/
-s32 Collider_InitAndSetSphere(GlobalContext* globalCtx, ColliderSphere* collider, Actor* actor,
- ColliderSphereInit* src) {
- Collider_InitSphere(globalCtx, collider);
- Collider_SetSphere(globalCtx, collider, actor, src);
+s32 Collider_InitAndSetSphere(PlayState* play, ColliderSphere* collider, Actor* actor, ColliderSphereInit* src) {
+ Collider_InitSphere(play, collider);
+ Collider_SetSphere(play, collider, actor, src);
return 0;
}
/**
* Resets the collider's AT collision flags.
*/
-s32 Collider_ResetSphereAT(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetSphereAT(PlayState* play, Collider* collider) {
ColliderSphere* sphere = (ColliderSphere*)collider;
- Collider_ResetATBase(globalCtx, &sphere->base);
- Collider_ResetATInfo(globalCtx, &sphere->info);
+ Collider_ResetATBase(play, &sphere->base);
+ Collider_ResetATInfo(play, &sphere->info);
return 1;
}
/**
* Resets the collider's AC collision flags.
*/
-s32 Collider_ResetSphereAC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetSphereAC(PlayState* play, Collider* collider) {
ColliderSphere* sphere = (ColliderSphere*)collider;
- Collider_ResetACBase(globalCtx, &sphere->base);
- Collider_ResetACInfo(globalCtx, &sphere->info);
+ Collider_ResetACBase(play, &sphere->base);
+ Collider_ResetACInfo(play, &sphere->info);
return 1;
}
/**
* Resets the collider's OC collision flags.
*/
-s32 Collider_ResetSphereOC(GlobalContext* globalCtx, Collider* collider) {
+s32 Collider_ResetSphereOC(PlayState* play, Collider* collider) {
ColliderSphere* sphere = (ColliderSphere*)collider;
- Collider_ResetOCBase(globalCtx, &sphere->base);
- Collider_ResetOCInfo(globalCtx, &sphere->info);
+ Collider_ResetOCBase(play, &sphere->base);
+ Collider_ResetOCInfo(play, &sphere->info);
return 1;
}
/**
* Initializes an OcLine to default values
*/
-s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line) {
+s32 Collider_InitLine(PlayState* play, OcLine* line) {
static Vec3f defaultLinePoint = { 0.0f, 0.0f, 0.0f };
Math_Vec3f_Copy(&line->line.a, &defaultLinePoint);
@@ -1045,14 +1040,14 @@ s32 Collider_InitLine(GlobalContext* globalCtx, OcLine* line) {
/**
* Destroys an OcLine
*/
-s32 Collider_DestroyLine(GlobalContext* globalCtx, OcLine* line) {
+s32 Collider_DestroyLine(PlayState* play, OcLine* line) {
return 1;
}
/**
* Sets up an OcLine with endpoints a and b.
*/
-s32 Collider_SetLinePoints(GlobalContext* globalCtx, OcLine* line, Vec3f* a, Vec3f* b) {
+s32 Collider_SetLinePoints(PlayState* play, OcLine* line, Vec3f* a, Vec3f* b) {
Math_Vec3f_Copy(&line->line.a, a);
Math_Vec3f_Copy(&line->line.b, b);
return 1;
@@ -1061,16 +1056,16 @@ s32 Collider_SetLinePoints(GlobalContext* globalCtx, OcLine* line, Vec3f* a, Vec
/**
* Sets up an OcLine using the values in src.
*/
-s32 Collider_SetLine(GlobalContext* globalCtx, OcLine* line, OcLine* src) {
+s32 Collider_SetLine(PlayState* play, OcLine* line, OcLine* src) {
line->ocFlags = src->ocFlags;
- Collider_SetLinePoints(globalCtx, line, &src->line.a, &src->line.b);
+ Collider_SetLinePoints(play, line, &src->line.a, &src->line.b);
return 1;
}
/**
* Resets the OcLine's collision flags.
*/
-s32 Collider_ResetLineOC(GlobalContext* globalCtx, OcLine* line) {
+s32 Collider_ResetLineOC(PlayState* play, OcLine* line) {
line->ocFlags &= ~OCLINE_HIT;
return 1;
}
@@ -1079,18 +1074,18 @@ 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* colCtxt) {
+void CollisionCheck_InitContext(PlayState* play, CollisionCheckContext* colCtxt) {
colCtxt->sacFlags = 0;
- CollisionCheck_ClearContext(globalCtx, colCtxt);
+ CollisionCheck_ClearContext(play, colCtxt);
}
-void CollisionCheck_DestroyContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) {
+void CollisionCheck_DestroyContext(PlayState* play, CollisionCheckContext* colCtxt) {
}
/**
* Clears all collider lists in CollisionCheckContext when not in SAC mode.
*/
-void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) {
+void CollisionCheck_ClearContext(PlayState* play, CollisionCheckContext* colCtxt) {
Collider** col;
OcLine** line;
@@ -1123,14 +1118,14 @@ void CollisionCheck_ClearContext(GlobalContext* globalCtx, CollisionCheckContext
/**
* Enables SAC, an alternate collision check mode that allows direct management of collider lists.
*/
-void CollisionCheck_EnableSAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) {
+void CollisionCheck_EnableSAC(PlayState* play, CollisionCheckContext* colCtxt) {
colCtxt->sacFlags |= SAC_ON;
}
/**
* Disables SAC, an alternate collision check mode that allows direct management of collider lists.
*/
-void CollisionCheck_DisableSAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt) {
+void CollisionCheck_DisableSAC(PlayState* play, CollisionCheckContext* colCtxt) {
colCtxt->sacFlags &= ~SAC_ON;
}
@@ -1142,13 +1137,13 @@ ColChkResetFunc sATResetFuncs[] = {
/**
* Sets collider as an AT (attack) for the current frame, which will be checked against ACs (attack colliders)
*/
-s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+s32 CollisionCheck_SetAT(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
s32 index;
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- sATResetFuncs[collider->shape](globalCtx, collider);
+ sATResetFuncs[collider->shape](play, collider);
if (collider->actor != NULL && collider->actor->update == NULL) {
return -1;
@@ -1170,11 +1165,11 @@ s32 CollisionCheck_SetAT(GlobalContext* globalCtx, CollisionCheckContext* colCtx
* 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* colCtxt, Collider* collider, s32 index) {
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+s32 CollisionCheck_SetAT_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- sATResetFuncs[collider->shape](globalCtx, collider);
+ sATResetFuncs[collider->shape](play, collider);
if (collider->actor != NULL && collider->actor->update == NULL) {
return -1;
@@ -1202,13 +1197,13 @@ ColChkResetFunc sACResetFuncs[] = {
/**
* Sets collider as an AC (attack collider) for the current frame, allowing it to detect ATs (attacks)
*/
-s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+s32 CollisionCheck_SetAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
s32 index;
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- sACResetFuncs[collider->shape](globalCtx, collider);
+ sACResetFuncs[collider->shape](play, collider);
if (collider->actor != NULL && collider->actor->update == NULL) {
return -1;
@@ -1230,11 +1225,11 @@ s32 CollisionCheck_SetAC(GlobalContext* globalCtx, CollisionCheckContext* colCtx
* 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* colCtxt, Collider* collider, s32 index) {
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+s32 CollisionCheck_SetAC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- sACResetFuncs[collider->shape](globalCtx, collider);
+ sACResetFuncs[collider->shape](play, collider);
if (collider->actor != NULL && collider->actor->update == NULL) {
return -1;
@@ -1262,13 +1257,13 @@ ColChkResetFunc sOCResetFuncs[] = {
/**
* Sets collider as an OC (object collider) for the current frame, allowing it to detect other OCs.
*/
-s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+s32 CollisionCheck_SetOC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
s32 index;
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- sOCResetFuncs[collider->shape](globalCtx, collider);
+ sOCResetFuncs[collider->shape](play, collider);
if (collider->actor != NULL && collider->actor->update == NULL) {
return -1;
@@ -1290,11 +1285,11 @@ s32 CollisionCheck_SetOC(GlobalContext* globalCtx, CollisionCheckContext* colCtx
* 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* colCtxt, Collider* collider, s32 index) {
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+s32 CollisionCheck_SetOC_SAC(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider, s32 index) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- sOCResetFuncs[collider->shape](globalCtx, collider);
+ sOCResetFuncs[collider->shape](play, collider);
if (collider->actor != NULL && collider->actor->update == NULL) {
return -1;
@@ -1320,14 +1315,14 @@ s32 CollisionCheck_SetOC_SAC(GlobalContext* globalCtx, CollisionCheckContext* co
/**
* Sets a line as an OC collider for this frame.
*/
-s32 CollisionCheck_SetOCLine(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, OcLine* line) {
+s32 CollisionCheck_SetOCLine(PlayState* play, CollisionCheckContext* colCtxt, OcLine* line) {
s32 index;
- if (FrameAdvance_IsEnabled(&globalCtx->state)) {
+ if (FrameAdvance_IsEnabled(&play->state)) {
return -1;
}
- Collider_ResetLineOC(globalCtx, line);
+ Collider_ResetLineOC(play, line);
if (colCtxt->colLineCount >= ARRAY_COUNT(colCtxt->colLine)) {
return -1;
@@ -1372,7 +1367,7 @@ s32 CollisionCheck_NoSharedFlags(ColliderInfo* toucher, ColliderInfo* bumper) {
* 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) {
}
/**
@@ -1381,7 +1376,7 @@ void CollisionCheck_NoBlood(GlobalContext* globalCtx, Collider* collider, Vec3f*
*/
#ifdef NON_MATCHING
// needs in-function static bss
-void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
+void CollisionCheck_BlueBlood(PlayState* play, Collider* collider, Vec3f* v) {
static EffectSparkInit D_801EEC00;
s32 effectIndex;
@@ -1427,7 +1422,7 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3
D_801EEC00.speed = 8.0f;
D_801EEC00.gravity = -1.0f;
- Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EEC00);
+ Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EEC00);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_BlueBlood.s")
@@ -1439,7 +1434,7 @@ void CollisionCheck_BlueBlood(GlobalContext* globalCtx, Collider* collider, Vec3
*/
#ifdef NON_MATCHING
// needs in-function static bss
-void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
+void CollisionCheck_GreenBlood(PlayState* play, Collider* collider, Vec3f* v) {
static EffectSparkInit D_801EF0C8;
s32 effectIndex;
@@ -1484,7 +1479,7 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec
D_801EF0C8.duration = 16;
D_801EF0C8.speed = 8.0f;
D_801EF0C8.gravity = -1.0f;
- Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EF0C8);
+ Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EF0C8);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_GreenBlood.s")
@@ -1494,55 +1489,55 @@ void CollisionCheck_GreenBlood(GlobalContext* globalCtx, Collider* collider, Vec
* Spawns a burst of water.
* Used by collider type HIT4.
*/
-void CollisionCheck_WaterBurst(GlobalContext* globalCtx, Collider* collider, Vec3f* v) {
- EffectSsSibuki_SpawnBurst(globalCtx, v);
- CollisionCheck_SpawnWaterDroplets(globalCtx, v);
+void CollisionCheck_WaterBurst(PlayState* play, Collider* collider, Vec3f* v) {
+ EffectSsSibuki_SpawnBurst(play, v);
+ CollisionCheck_SpawnWaterDroplets(play, v);
}
/**
* Spawns red blood drops.
* Used by collider type HIT7.
*/
-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.
*/
-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, 0, hitPos);
+ EffectSsHitMark_SpawnFixedScale(play, 0, hitPos);
if (collider->actor == NULL) {
play_sound(NA_SE_IT_SHIELD_BOUND);
} else {
Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND);
}
} else if (flags == TOUCH_SFX_NORMAL) {
- EffectSsHitMark_SpawnFixedScale(globalCtx, 3, hitPos);
+ EffectSsHitMark_SpawnFixedScale(play, 3, 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, 0, hitPos);
+ EffectSsHitMark_SpawnFixedScale(play, 0, hitPos);
if (collider->actor == NULL) {
play_sound(NA_SE_IT_SHIELD_BOUND);
} else {
Audio_PlaySfxAtPos(&collider->actor->projectedPos, NA_SE_IT_SHIELD_BOUND);
}
} else if (flags == TOUCH_SFX_WOOD) {
- EffectSsHitMark_SpawnFixedScale(globalCtx, 1, hitPos);
+ EffectSsHitMark_SpawnFixedScale(play, 1, hitPos);
if (collider->actor == NULL) {
play_sound(NA_SE_IT_REFLECTION_WOOD);
} else {
@@ -1584,8 +1579,8 @@ 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;
}
@@ -1595,26 +1590,26 @@ void CollisionCheck_HitEffects(GlobalContext* globalCtx, Collider* at, ColliderI
}
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);
play_sound(NA_SE_IT_REFLECTION_WOOD);
} 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, 0, hitPos);
+ EffectSsHitMark_SpawnFixedScale(play, 0, hitPos);
if (ac->actor == NULL) {
play_sound(NA_SE_IT_SHIELD_BOUND);
} else {
@@ -1634,7 +1629,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) {
f32 damage;
u32 effect;
@@ -1684,7 +1679,7 @@ s32 CollisionCheck_SetATvsAC(GlobalContext* globalCtx, Collider* at, ColliderInf
ac->colType != COLTYPE_HARD) {
acInfo->bumperFlags |= BUMP_DRAW_HITMARK;
} else {
- CollisionCheck_HitEffects(globalCtx, at, atInfo, ac, acInfo, hitPos);
+ CollisionCheck_HitEffects(play, at, atInfo, ac, acInfo, hitPos);
atInfo->toucherFlags |= TOUCH_DREW_HITMARK;
}
return 1;
@@ -1707,7 +1702,7 @@ void CollisionCheck_QuadAvgPoint(ColliderQuad* quad, Vec3f* avg) {
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
+void CollisionCheck_AC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT,
Collider* colAC) {
ColliderJntSph* at = (ColliderJntSph*)colAT;
ColliderJntSphElement* atElem;
@@ -1748,8 +1743,8 @@ void CollisionCheck_AC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info,
- &acPos, &hitPos);
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos,
+ &hitPos);
if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) {
return;
@@ -1763,8 +1758,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* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderJntSph* at = (ColliderJntSph*)colAT;
ColliderJntSphElement* atElem;
ColliderCylinder* ac = (ColliderCylinder*)colAC;
@@ -1803,8 +1797,7 @@ void CollisionCheck_AC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos,
- &hitPos);
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos);
return;
}
}
@@ -1814,8 +1807,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_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_JntSphVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderJntSph* at = (ColliderJntSph*)colAT;
ColliderJntSphElement* atElem;
ColliderTris* ac = (ColliderTris*)colAC;
@@ -1840,8 +1832,8 @@ void CollisionCheck_AC_JntSphVsTris(GlobalContext* globalCtx, CollisionCheckCont
Math_Vec3s_ToVec3f(&atPos, &atElem->dim.worldSphere.center);
CollisionCheck_TrisAvgPoint(acElem, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info,
- &acPos, &hitPos);
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos,
+ &hitPos);
return;
}
}
@@ -1852,8 +1844,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_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_JntSphVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderJntSph* at = (ColliderJntSph*)colAT;
ColliderQuad* ac = (ColliderQuad*)colAC;
Vec3f hitPos;
@@ -1880,7 +1871,7 @@ void CollisionCheck_AC_JntSphVsQuad(GlobalContext* globalCtx, CollisionCheckCont
Math_Vec3s_ToVec3f(&atPos, &sphElem->dim.worldSphere.center);
CollisionCheck_QuadAvgPoint(ac, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos,
+ CollisionCheck_SetATvsAC(play, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos,
&hitPos);
return;
}
@@ -1891,7 +1882,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_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
+void CollisionCheck_AC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT,
Collider* colAC) {
ColliderJntSph* at = (ColliderJntSph*)colAT;
ColliderSphere* ac = (ColliderSphere*)colAC;
@@ -1927,7 +1918,7 @@ void CollisionCheck_AC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos,
+ CollisionCheck_SetATvsAC(play, &at->base, &sphElem->info, &atPos, &ac->base, &ac->info, &acPos,
&hitPos);
}
}
@@ -1937,8 +1928,7 @@ void CollisionCheck_AC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderCylinder* at = (ColliderCylinder*)colAT;
ColliderJntSph* ac = (ColliderJntSph*)colAC;
f32 overlapSize;
@@ -1977,7 +1967,7 @@ void CollisionCheck_AC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckConte
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &sphElem->info, &acPos,
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &sphElem->info, &acPos,
&hitPos);
if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) {
break;
@@ -1990,8 +1980,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_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderCylinder* at = (ColliderCylinder*)colAT;
ColliderCylinder* ac = (ColliderCylinder*)colAC;
f32 overlapSize;
@@ -2035,7 +2024,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);
}
}
}
@@ -2043,8 +2032,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* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_CylVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderCylinder* at = (ColliderCylinder*)colAT;
ColliderTris* ac = (ColliderTris*)colAC;
ColliderTrisElement* acElem;
@@ -2069,8 +2057,7 @@ void CollisionCheck_AC_CylVsTris(GlobalContext* globalCtx, CollisionCheckContext
Math_Vec3s_ToVec3f(&atPos, &at->dim.pos);
CollisionCheck_TrisAvgPoint(acElem, &acPos);
- 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;
}
}
@@ -2080,8 +2067,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_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_CylVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderCylinder* at = (ColliderCylinder*)colAT;
ColliderQuad* ac = (ColliderQuad*)colAC;
@@ -2104,16 +2090,14 @@ void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext
Math_Vec3s_ToVec3f(&atPos, &at->dim.pos);
CollisionCheck_QuadAvgPoint(ac, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos,
- &D_801EDE00);
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE00);
} else if (Math3D_ColCylinderTri(&at->dim, &D_801EF638, &D_801EDE00) != 0) {
Vec3f atPos;
Vec3f acPos;
Math_Vec3s_ToVec3f(&atPos, &at->dim.pos);
CollisionCheck_QuadAvgPoint(ac, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos,
- &D_801EDE00);
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDE00);
}
}
}
@@ -2121,8 +2105,7 @@ void CollisionCheck_AC_CylVsQuad(GlobalContext* globalCtx, CollisionCheckContext
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderCylinder* at = (ColliderCylinder*)colAT;
ColliderSphere* ac = (ColliderSphere*)colAC;
f32 overlapSize;
@@ -2160,7 +2143,7 @@ void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- 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);
}
}
}
@@ -2168,8 +2151,7 @@ void CollisionCheck_AC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_TrisVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderTris* at = (ColliderTris*)colAT;
ColliderJntSphElement* acElem;
ColliderJntSph* ac = (ColliderJntSph*)colAC;
@@ -2194,8 +2176,8 @@ void CollisionCheck_AC_TrisVsJntSph(GlobalContext* globalCtx, CollisionCheckCont
Math_Vec3s_ToVec3f(&acPos, &acElem->dim.worldSphere.center);
CollisionCheck_TrisAvgPoint(atElem, &atPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info,
- &acPos, &hitPos);
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos,
+ &hitPos);
if (!(ac->base.ocFlags2 & OC2_FIRST_ONLY)) {
return;
@@ -2209,8 +2191,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_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_TrisVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderTris* at = (ColliderTris*)colAT;
ColliderCylinder* ac = (ColliderCylinder*)colAC;
ColliderTrisElement* atElem;
@@ -2232,7 +2213,7 @@ void CollisionCheck_AC_TrisVsCyl(GlobalContext* globalCtx, CollisionCheckContext
CollisionCheck_TrisAvgPoint(atElem, &atPos);
Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos,
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos,
&D_801EDE10);
return;
}
@@ -2243,8 +2224,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_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_TrisVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderTris* at = (ColliderTris*)colAT;
ColliderTrisElement* atElem;
ColliderTris* ac = (ColliderTris*)colAC;
@@ -2268,8 +2248,8 @@ void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContex
CollisionCheck_TrisAvgPoint(atElem, &atPos);
CollisionCheck_TrisAvgPoint(acElem, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info,
- &acPos, &D_801EDE20);
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &acElem->info, &acPos,
+ &D_801EDE20);
return;
}
}
@@ -2280,8 +2260,7 @@ void CollisionCheck_AC_TrisVsTris(GlobalContext* globalCtx, CollisionCheckContex
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_TrisVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderTris* at = (ColliderTris*)colAT;
ColliderQuad* ac = (ColliderQuad*)colAC;
ColliderTrisElement* atElem;
@@ -2308,7 +2287,7 @@ void CollisionCheck_AC_TrisVsQuad(GlobalContext* globalCtx, CollisionCheckContex
CollisionCheck_TrisAvgPoint(atElem, &atPos);
CollisionCheck_QuadAvgPoint(ac, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos,
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos,
&D_801EDE30);
return;
}
@@ -2319,8 +2298,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_TrisVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_TrisVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderTris* at = (ColliderTris*)colAT;
ColliderTrisElement* atElem;
ColliderSphere* ac = (ColliderSphere*)colAC;
@@ -2343,8 +2321,7 @@ void CollisionCheck_AC_TrisVsSphere(GlobalContext* globalCtx, CollisionCheckCont
Math_Vec3s_ToVec3f(&acPos, &ac->dim.worldSphere.center);
CollisionCheck_TrisAvgPoint(atElem, &atPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos,
- &hitPos);
+ CollisionCheck_SetATvsAC(play, &at->base, &atElem->info, &atPos, &ac->base, &ac->info, &acPos, &hitPos);
}
}
}
@@ -2353,8 +2330,7 @@ void CollisionCheck_AC_TrisVsSphere(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* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_QuadVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderJntSphElement* acElem;
Vec3f hitPos;
ColliderQuad* at = (ColliderQuad*)colAT;
@@ -2379,13 +2355,12 @@ void CollisionCheck_AC_QuadVsJntSph(GlobalContext* globalCtx, CollisionCheckCont
Vec3f atPos;
Vec3f acPos;
- if (!Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) {
+ if (!Collider_QuadSetNearestAC(play, at, &hitPos)) {
continue;
}
Math_Vec3s_ToVec3f(&acPos, &acElem->dim.worldSphere.center);
CollisionCheck_QuadAvgPoint(at, &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;
@@ -2398,8 +2373,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_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_QuadVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderQuad* at = (ColliderQuad*)colAT;
ColliderCylinder* ac = (ColliderCylinder*)colAC;
@@ -2418,26 +2392,24 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext
Math3D_TriSetCoords(&D_801EDF90, &at->dim.quad[2], &at->dim.quad[1], &at->dim.quad[0]);
if (Math3D_ColCylinderTri(&ac->dim, &D_801EDF58, &D_801EDFE0) != 0) {
- if (Collider_QuadSetNearestAC(globalCtx, at, &D_801EDFE0)) {
+ if (Collider_QuadSetNearestAC(play, at, &D_801EDFE0)) {
Vec3f atPos;
Vec3f acPos;
CollisionCheck_QuadAvgPoint(at, &atPos);
Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos,
- &D_801EDFE0);
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDFE0);
return;
}
}
if (Math3D_ColCylinderTri(&ac->dim, &D_801EDF90, &D_801EDFE0) != 0) {
- if (Collider_QuadSetNearestAC(globalCtx, at, &D_801EDFE0)) {
+ if (Collider_QuadSetNearestAC(play, at, &D_801EDFE0)) {
Vec3f atPos;
Vec3f acPos;
CollisionCheck_QuadAvgPoint(at, &atPos);
Math_Vec3s_ToVec3f(&acPos, &ac->dim.pos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos,
- &D_801EDFE0);
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EDFE0);
}
}
}
@@ -2446,8 +2418,7 @@ void CollisionCheck_AC_QuadVsCyl(GlobalContext* globalCtx, CollisionCheckContext
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_QuadVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderQuad* at = (ColliderQuad*)colAT;
ColliderTris* ac = (ColliderTris*)colAC;
ColliderTrisElement* acElem;
@@ -2470,13 +2441,13 @@ void CollisionCheck_AC_QuadVsTris(GlobalContext* globalCtx, CollisionCheckContex
if ((Math3d_ColTriTri(&D_801EE000, &acElem->dim, &D_801EDFF0) != 0) ||
(Math3d_ColTriTri(&D_801EE038, &acElem->dim, &D_801EDFF0) != 0)) {
- if (Collider_QuadSetNearestAC(globalCtx, at, &D_801EDFF0)) {
+ if (Collider_QuadSetNearestAC(play, at, &D_801EDFF0)) {
Vec3f atPos;
Vec3f acPos;
CollisionCheck_TrisAvgPoint(acElem, &acPos);
CollisionCheck_QuadAvgPoint(at, &atPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos,
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &acElem->info, &acPos,
&D_801EDFF0);
return;
}
@@ -2488,8 +2459,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* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_QuadVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderQuad* at = (ColliderQuad*)colAT;
ColliderQuad* ac = (ColliderQuad*)colAC;
s32 i;
@@ -2513,14 +2483,13 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (Math3d_ColTriTri(&D_801EE0E8[j], &D_801EE070[i], &D_801EE0D8) != 0 &&
- Collider_QuadSetNearestAC(globalCtx, at, &D_801EE0D8) != 0) {
+ Collider_QuadSetNearestAC(play, at, &D_801EE0D8) != 0) {
Vec3f atPos;
Vec3f acPos;
CollisionCheck_QuadAvgPoint(at, &atPos);
CollisionCheck_QuadAvgPoint(ac, &acPos);
- CollisionCheck_SetATvsAC(globalCtx, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos,
- &D_801EE0D8);
+ CollisionCheck_SetATvsAC(play, &at->base, &at->info, &atPos, &ac->base, &ac->info, &acPos, &D_801EE0D8);
return;
}
}
@@ -2530,8 +2499,7 @@ void CollisionCheck_AC_QuadVsQuad(GlobalContext* globalCtx, CollisionCheckContex
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_QuadVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderQuad* at = (ColliderQuad*)colAT;
Vec3f hitPos;
ColliderSphere* ac = (ColliderSphere*)colAC;
@@ -2548,13 +2516,13 @@ void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckCont
if ((Math3D_ColSphereTri(&ac->dim.worldSphere, &D_801EE150, &hitPos) != 0) ||
(Math3D_ColSphereTri(&ac->dim.worldSphere, &D_801EE188, &hitPos) != 0)) {
- if (Collider_QuadSetNearestAC(globalCtx, at, &hitPos)) {
+ if (Collider_QuadSetNearestAC(play, at, &hitPos)) {
Vec3f atPos;
Vec3f acPos;
Math_Vec3s_ToVec3f(&acPos, &ac->dim.worldSphere.center);
CollisionCheck_QuadAvgPoint(at, &atPos);
- 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);
}
}
}
@@ -2562,7 +2530,7 @@ void CollisionCheck_AC_QuadVsSphere(GlobalContext* globalCtx, CollisionCheckCont
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
+void CollisionCheck_AC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT,
Collider* colAC) {
ColliderSphere* at = (ColliderSphere*)colAT;
ColliderJntSph* ac = (ColliderJntSph*)colAC;
@@ -2600,8 +2568,7 @@ void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckCo
} 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);
}
}
}
@@ -2610,7 +2577,7 @@ void CollisionCheck_AC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckCo
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
+void CollisionCheck_AC_SphereVsCylinder(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT,
Collider* colAC) {
ColliderCylinder* ac = (ColliderCylinder*)colAC;
ColliderSphere* at = (ColliderSphere*)colAT;
@@ -2648,7 +2615,7 @@ void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheck
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- 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);
}
if (at) {}
@@ -2657,8 +2624,7 @@ void CollisionCheck_AC_SphereVsCylinder(GlobalContext* globalCtx, CollisionCheck
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_SphereVsTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderSphere* at = (ColliderSphere*)colAT;
ColliderTris* ac = (ColliderTris*)colAC;
ColliderTrisElement* acElem;
@@ -2681,8 +2647,7 @@ void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckCont
Math_Vec3s_ToVec3f(&atPos, &at->dim.worldSphere.center);
CollisionCheck_TrisAvgPoint(acElem, &acPos);
- 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;
}
}
@@ -2691,8 +2656,7 @@ void CollisionCheck_AC_SphereVsTris(GlobalContext* globalCtx, CollisionCheckCont
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_SphereVsQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
- Collider* colAC) {
+void CollisionCheck_AC_SphereVsQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT, Collider* colAC) {
ColliderSphere* at = (ColliderSphere*)colAT;
Vec3f hitPos;
ColliderQuad* ac = (ColliderQuad*)colAC;
@@ -2714,14 +2678,14 @@ void CollisionCheck_AC_SphereVsQuad(GlobalContext* globalCtx, CollisionCheckCont
Math_Vec3s_ToVec3f(&atPos, &at->dim.worldSphere.center);
CollisionCheck_QuadAvgPoint(ac, &acPos);
- 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);
}
}
/**
* AC overlap check. Calculates the center of each collider element and the point of contact.
*/
-void CollisionCheck_AC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT,
+void CollisionCheck_AC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT,
Collider* colAC) {
ColliderSphere* at = (ColliderSphere*)colAT;
ColliderSphere* ac = (ColliderSphere*)colAC;
@@ -2755,14 +2719,14 @@ void CollisionCheck_AC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckCo
} else {
Math_Vec3f_Copy(&hitPos, &atPos);
}
- 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);
}
}
/**
* Sets a ColliderJntSph's hit effects
*/
-void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_SetJntSphHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderJntSph* jntSph = (ColliderJntSph*)collider;
ColliderJntSphElement* element;
@@ -2772,8 +2736,8 @@ void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckConte
Vec3f hitPos;
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;
}
@@ -2783,7 +2747,7 @@ void CollisionCheck_SetJntSphHitFX(GlobalContext* globalCtx, CollisionCheckConte
/**
* Sets a ColliderCylinder's hit effects
*/
-void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_SetCylHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderCylinder* cylinder = (ColliderCylinder*)collider;
if ((cylinder->info.bumperFlags & BUMP_DRAW_HITMARK) && cylinder->info.acHitInfo != NULL &&
@@ -2791,7 +2755,7 @@ void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext*
Vec3f hitPos;
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;
}
@@ -2800,7 +2764,7 @@ void CollisionCheck_SetCylHitFX(GlobalContext* globalCtx, CollisionCheckContext*
/**
* Sets a ColliderTris's hit effects
*/
-void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_SetTrisHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderTris* tris = (ColliderTris*)collider;
ColliderTrisElement* element;
@@ -2810,8 +2774,8 @@ void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext
Vec3f hitPos;
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;
}
@@ -2821,7 +2785,7 @@ void CollisionCheck_SetTrisHitFX(GlobalContext* globalCtx, CollisionCheckContext
/**
* Sets a ColliderQuad's hit effects
*/
-void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_SetQuadHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderQuad* quad = (ColliderQuad*)collider;
if ((quad->info.bumperFlags & BUMP_DRAW_HITMARK) && quad->info.acHitInfo != NULL &&
@@ -2829,7 +2793,7 @@ void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext
Vec3f hitPos;
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;
}
}
@@ -2837,7 +2801,7 @@ void CollisionCheck_SetQuadHitFX(GlobalContext* globalCtx, CollisionCheckContext
/**
* Sets a ColliderSphere's hit effects
*/
-void CollisionCheck_SetSphereHitFX(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_SetSphereHitFX(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderSphere* sphere = (ColliderSphere*)collider;
if ((sphere->info.bumperFlags & BUMP_DRAW_HITMARK) && sphere->info.acHitInfo != NULL &&
@@ -2845,7 +2809,7 @@ void CollisionCheck_SetSphereHitFX(GlobalContext* globalCtx, CollisionCheckConte
Vec3f hitPos;
Math_Vec3s_ToVec3f(&hitPos, &sphere->info.bumper.hitPos);
- CollisionCheck_HitEffects(globalCtx, sphere->info.acHit, sphere->info.acHitInfo, &sphere->base, &sphere->info,
+ CollisionCheck_HitEffects(play, sphere->info.acHit, sphere->info.acHitInfo, &sphere->base, &sphere->info,
&hitPos);
sphere->info.acHitInfo->toucherFlags |= TOUCH_DREW_HITMARK;
}
@@ -2859,7 +2823,7 @@ 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* colCtxt) {
+void CollisionCheck_SetHitEffects(PlayState* play, CollisionCheckContext* colCtxt) {
Collider** col;
for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[colCtxt->colACCount]; col++) {
@@ -2869,7 +2833,7 @@ void CollisionCheck_SetHitEffects(GlobalContext* globalCtx, CollisionCheckContex
if (colAC->actor != NULL && colAC->actor->update == NULL) {
continue;
}
- sColChkApplyFuncs[colAC->shape](globalCtx, colCtxt, colAC);
+ sColChkApplyFuncs[colAC->shape](play, colCtxt, colAC);
}
}
}
@@ -2890,7 +2854,7 @@ ColChkVsFunc sACVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = {
/**
* Iterates through all AC colliders, performing AC collisions with the AT collider.
*/
-void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* colAT) {
+void CollisionCheck_AC(PlayState* play, CollisionCheckContext* colCtxt, Collider* colAT) {
Collider** col;
for (col = &colCtxt->colAC[0]; col < &colCtxt->colAC[colCtxt->colACCount]; col++) {
@@ -2904,7 +2868,7 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt,
if (!(colAT->atFlags & AT_SELF) && colAT->actor != NULL && colAC->actor == colAT->actor) {
continue;
}
- sACVsFuncs[colAT->shape][colAC->shape](globalCtx, colCtxt, colAT, colAC);
+ sACVsFuncs[colAT->shape][colAC->shape](play, colCtxt, colAT, colAC);
}
}
}
@@ -2916,7 +2880,7 @@ void CollisionCheck_AC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt,
* 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* colCtxt) {
+void CollisionCheck_AT(PlayState* play, CollisionCheckContext* colCtxt) {
Collider** col;
if (colCtxt->colATCount == 0 || colCtxt->colACCount == 0) {
@@ -2930,11 +2894,11 @@ void CollisionCheck_AT(GlobalContext* globalCtx, CollisionCheckContext* colCtxt)
if (colAC->actor != NULL && colAC->actor->update == NULL) {
continue;
}
- CollisionCheck_AC(globalCtx, colCtxt, colAC);
+ CollisionCheck_AC(play, colCtxt, colAC);
}
}
- CollisionCheck_SetHitEffects(globalCtx, colCtxt);
+ CollisionCheck_SetHitEffects(play, colCtxt);
}
/**
@@ -2955,8 +2919,8 @@ s32 CollisionCheck_GetMassType(u8 mass) {
* Sets OC collision flags for OC collider overlaps. If both colliders are attached to actors and can push,
* also performs an elastic collision where both colliders are moved apart in proportion to their masses.
*/
-void CollisionCheck_SetOCvsOC(GlobalContext* globalCtx, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos,
- Collider* right, ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap) {
+void CollisionCheck_SetOCvsOC(PlayState* play, Collider* left, ColliderInfo* leftInfo, Vec3f* leftPos, Collider* right,
+ ColliderInfo* rightInfo, Vec3f* rightPos, f32 overlap) {
f32 pad;
f32 leftDispRatio;
f32 rightDispRatio;
@@ -3053,8 +3017,7 @@ void CollisionCheck_SetOCvsOC(GlobalContext* globalCtx, Collider* left, Collider
/**
* OC overlap check for two JntSphs
*/
-void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l,
- Collider* r) {
+void CollisionCheck_OC_JntSphVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
ColliderJntSph* left = (ColliderJntSph*)l;
ColliderJntSph* right = (ColliderJntSph*)r;
ColliderJntSphElement* leftElem;
@@ -3079,7 +3042,7 @@ void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo
Math_Vec3s_ToVec3f(&leftPos, &leftElem->dim.worldSphere.center);
Math_Vec3s_ToVec3f(&rightPos, &rightElem->dim.worldSphere.center);
- CollisionCheck_SetOCvsOC(globalCtx, &left->base, &leftElem->info, &leftPos, &right->base,
+ CollisionCheck_SetOCvsOC(play, &left->base, &leftElem->info, &leftPos, &right->base,
&rightElem->info, &rightPos, overlap);
}
}
@@ -3090,7 +3053,7 @@ void CollisionCheck_OC_JntSphVsJntSph(GlobalContext* globalCtx, CollisionCheckCo
/**
* OC overlap check for a JntSph and Cylinder
*/
-void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
+void CollisionCheck_OC_JntSphVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
ColliderJntSph* left = (ColliderJntSph*)l;
ColliderCylinder* right = (ColliderCylinder*)r;
ColliderJntSphElement* leftElem;
@@ -3109,7 +3072,7 @@ void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte
Math_Vec3s_ToVec3f(&leftPos, &leftElem->dim.worldSphere.center);
Math_Vec3s_ToVec3f(&rightPos, &right->dim.pos);
- CollisionCheck_SetOCvsOC(globalCtx, &left->base, &leftElem->info, &leftPos, &right->base, &right->info,
+ CollisionCheck_SetOCvsOC(play, &left->base, &leftElem->info, &leftPos, &right->base, &right->info,
&rightPos, overlap);
}
}
@@ -3119,8 +3082,7 @@ void CollisionCheck_OC_JntSphVsCyl(GlobalContext* globalCtx, CollisionCheckConte
/**
* OC overlap check for a JntSph and Sphere
*/
-void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l,
- Collider* r) {
+void CollisionCheck_OC_JntSphVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
ColliderJntSph* left = (ColliderJntSph*)l;
ColliderSphere* right = (ColliderSphere*)r;
ColliderJntSphElement* leftElem;
@@ -3139,7 +3101,7 @@ void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo
Math_Vec3s_ToVec3f(&leftPos, &leftElem->dim.worldSphere.center);
Math_Vec3s_ToVec3f(&rightPos, &right->dim.worldSphere.center);
- CollisionCheck_SetOCvsOC(globalCtx, &left->base, &leftElem->info, &leftPos, &right->base, &right->info,
+ CollisionCheck_SetOCvsOC(play, &left->base, &leftElem->info, &leftPos, &right->base, &right->info,
&rightPos, overlap);
}
}
@@ -3149,14 +3111,14 @@ void CollisionCheck_OC_JntSphVsSphere(GlobalContext* globalCtx, CollisionCheckCo
/**
* OC overlap check for a Cylinder and JntSph
*/
-void CollisionCheck_OC_CylVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
- CollisionCheck_OC_JntSphVsCyl(globalCtx, colCtxt, r, l);
+void CollisionCheck_OC_CylVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
+ CollisionCheck_OC_JntSphVsCyl(play, colCtxt, r, l);
}
/**
* OC overlap check for two Cylinders
*/
-void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
+void CollisionCheck_OC_CylVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
ColliderCylinder* left = (ColliderCylinder*)l;
ColliderCylinder* right = (ColliderCylinder*)r;
f32 overlap;
@@ -3169,8 +3131,8 @@ void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext*
Math_Vec3s_ToVec3f(&leftPos, &left->dim.pos);
Math_Vec3s_ToVec3f(&rightPos, &right->dim.pos);
- CollisionCheck_SetOCvsOC(globalCtx, &left->base, &left->info, &leftPos, &right->base, &right->info,
- &rightPos, overlap);
+ CollisionCheck_SetOCvsOC(play, &left->base, &left->info, &leftPos, &right->base, &right->info, &rightPos,
+ overlap);
}
}
}
@@ -3178,7 +3140,7 @@ void CollisionCheck_OC_CylVsCyl(GlobalContext* globalCtx, CollisionCheckContext*
/**
* OC overlap check for a Cylinder and Sphere
*/
-void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
+void CollisionCheck_OC_CylVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
ColliderCylinder* left = (ColliderCylinder*)l;
ColliderSphere* right = (ColliderSphere*)r;
f32 overlap;
@@ -3191,8 +3153,8 @@ void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte
Math_Vec3s_ToVec3f(&leftPos, &left->dim.pos);
Math_Vec3s_ToVec3f(&rightPos, &right->dim.worldSphere.center);
- CollisionCheck_SetOCvsOC(globalCtx, &left->base, &left->info, &leftPos, &right->base, &right->info,
- &rightPos, overlap);
+ CollisionCheck_SetOCvsOC(play, &left->base, &left->info, &leftPos, &right->base, &right->info, &rightPos,
+ overlap);
}
}
}
@@ -3200,23 +3162,21 @@ void CollisionCheck_OC_CylVsSphere(GlobalContext* globalCtx, CollisionCheckConte
/**
* OC overlap check for a Sphere and JntSph
*/
-void CollisionCheck_OC_SphereVsJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l,
- Collider* r) {
- CollisionCheck_OC_JntSphVsSphere(globalCtx, colCtxt, r, l);
+void CollisionCheck_OC_SphereVsJntSph(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
+ CollisionCheck_OC_JntSphVsSphere(play, colCtxt, r, l);
}
/**
* OC overlap check for a Sphere and Cylinder
*/
-void CollisionCheck_OC_SphereVsCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
- CollisionCheck_OC_CylVsSphere(globalCtx, colCtxt, r, l);
+void CollisionCheck_OC_SphereVsCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
+ CollisionCheck_OC_CylVsSphere(play, colCtxt, r, l);
}
/**
* OC overlap check for two Spheres
*/
-void CollisionCheck_OC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* l,
- Collider* r) {
+void CollisionCheck_OC_SphereVsSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* l, Collider* r) {
ColliderSphere* left = (ColliderSphere*)l;
ColliderSphere* right = (ColliderSphere*)r;
f32 overlap;
@@ -3229,8 +3189,8 @@ void CollisionCheck_OC_SphereVsSphere(GlobalContext* globalCtx, CollisionCheckCo
Math_Vec3s_ToVec3f(&leftPos, &left->dim.worldSphere.center);
Math_Vec3s_ToVec3f(&rightPos, &right->dim.worldSphere.center);
- CollisionCheck_SetOCvsOC(globalCtx, &left->base, &left->info, &leftPos, &right->base, &right->info,
- &rightPos, overlap);
+ CollisionCheck_SetOCvsOC(play, &left->base, &left->info, &leftPos, &right->base, &right->info, &rightPos,
+ overlap);
}
}
}
@@ -3278,7 +3238,7 @@ ColChkVsFunc sOCVsFuncs[COLSHAPE_MAX][COLSHAPE_MAX] = {
* colliders 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* colCtxt) {
+void CollisionCheck_OC(PlayState* play, CollisionCheckContext* colCtxt) {
Collider** left;
Collider** right;
ColChkVsFunc vsFunc;
@@ -3295,7 +3255,7 @@ void CollisionCheck_OC(GlobalContext* globalCtx, CollisionCheckContext* colCtxt)
if (vsFunc == NULL) {
continue;
}
- vsFunc(globalCtx, colCtxt, *left, *right);
+ vsFunc(play, colCtxt, *left, *right);
}
}
}
@@ -3365,7 +3325,7 @@ void CollisionCheck_SetInfoGetDamageTable(CollisionCheckInfo* info, s32 index, C
/**
* Apply AC damage effect
*/
-void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider,
+void CollisionCheck_ApplyDamage(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider,
ColliderInfo* info) {
f32 damage;
f32 finalDamage = 0.0f;
@@ -3416,13 +3376,13 @@ void CollisionCheck_ApplyDamage(GlobalContext* globalCtx, CollisionCheckContext*
/**
* Apply ColliderJntSph AC damage effect
*/
-void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_ApplyDamageJntSph(PlayState* play, CollisionCheckContext* colCtxt, 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, colCtxt, &jntSph->base, &jntSph->elements[i].info);
+ CollisionCheck_ApplyDamage(play, colCtxt, &jntSph->base, &jntSph->elements[i].info);
}
}
}
@@ -3430,42 +3390,42 @@ void CollisionCheck_ApplyDamageJntSph(GlobalContext* globalCtx, CollisionCheckCo
/**
* Apply ColliderCylinder AC damage effect
*/
-void CollisionCheck_ApplyDamageCyl(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_ApplyDamageCyl(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderCylinder* cylinder = (ColliderCylinder*)collider;
- CollisionCheck_ApplyDamage(globalCtx, colCtxt, &cylinder->base, &cylinder->info);
+ CollisionCheck_ApplyDamage(play, colCtxt, &cylinder->base, &cylinder->info);
}
/**
* Apply ColliderTris AC damage effect
*/
-void CollisionCheck_ApplyDamageTris(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_ApplyDamageTris(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderTris* tris = (ColliderTris*)collider;
s32 i;
// unlike sphere groups above, tri groups are not guarded against
// tris->elements being NULL
for (i = 0; i < tris->count; i++) {
- CollisionCheck_ApplyDamage(globalCtx, colCtxt, &tris->base, &tris->elements[i].info);
+ CollisionCheck_ApplyDamage(play, colCtxt, &tris->base, &tris->elements[i].info);
}
}
/**
* Apply ColliderQuad AC damage effect
*/
-void CollisionCheck_ApplyDamageQuad(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_ApplyDamageQuad(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderQuad* quad = (ColliderQuad*)collider;
- CollisionCheck_ApplyDamage(globalCtx, colCtxt, &quad->base, &quad->info);
+ CollisionCheck_ApplyDamage(play, colCtxt, &quad->base, &quad->info);
}
/**
* Apply ColliderSphere AC damage effect
*/
-void CollisionCheck_ApplyDamageSphere(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Collider* collider) {
+void CollisionCheck_ApplyDamageSphere(PlayState* play, CollisionCheckContext* colCtxt, Collider* collider) {
ColliderSphere* sphere = (ColliderSphere*)collider;
- CollisionCheck_ApplyDamage(globalCtx, colCtxt, &sphere->base, &sphere->info);
+ CollisionCheck_ApplyDamage(play, colCtxt, &sphere->base, &sphere->info);
}
ColChkApplyFunc sApplyDamageFuncs[] = {
@@ -3477,7 +3437,7 @@ ColChkApplyFunc sApplyDamageFuncs[] = {
* 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* colCtxt) {
+void CollisionCheck_Damage(PlayState* play, CollisionCheckContext* colCtxt) {
s32 i;
for (i = 0; i < colCtxt->colACCount; i++) {
@@ -3489,15 +3449,15 @@ void CollisionCheck_Damage(GlobalContext* globalCtx, CollisionCheckContext* colC
if (col->acFlags & AC_NO_DAMAGE) {
continue;
}
- sApplyDamageFuncs[col->shape](globalCtx, colCtxt, col);
+ sApplyDamageFuncs[col->shape](play, colCtxt, col);
}
}
/**
* Checks if the line segment 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) {
ColliderJntSph* jntSph = (ColliderJntSph*)collider;
s32 i;
@@ -3520,7 +3480,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) {
ColliderCylinder* cylinder = (ColliderCylinder*)collider;
@@ -3538,8 +3498,8 @@ s32 CollisionCheck_LineOC_Cyl(GlobalContext* globalCtx, CollisionCheckContext* c
/**
* Checks if the line segment ab intersects the ColliderSphere
*/
-s32 CollisionCheck_LineOC_Sphere(GlobalContext* globalCtx, CollisionCheckContext* colChkCtx, Collider* collider,
- Vec3f* a, Vec3f* b) {
+s32 CollisionCheck_LineOC_Sphere(PlayState* play, CollisionCheckContext* colChkCtx, Collider* collider, Vec3f* a,
+ Vec3f* b) {
ColliderSphere* sphere = (ColliderSphere*)collider;
if (!(sphere->info.ocElemFlags & OCELEM_ON)) {
@@ -3563,8 +3523,8 @@ ColChkLineFunc sOCLineCheckFuncs[] = {
* 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;
@@ -3592,7 +3552,7 @@ s32 CollisionCheck_LineOC(GlobalContext* globalCtx, CollisionCheckContext* colCh
continue;
}
- result = lineCheck(globalCtx, colChkCtx, (*col), a, b);
+ result = lineCheck(play, colChkCtx, (*col), a, b);
if (result) {
break;
}
@@ -3604,17 +3564,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.
*/
-s32 CollisionCheck_LineOCCheckAll(GlobalContext* globalCtx, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b) {
- return CollisionCheck_LineOC(globalCtx, colCtxt, a, b, NULL, 0);
+s32 CollisionCheck_LineOCCheckAll(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b) {
+ return CollisionCheck_LineOC(play, colCtxt, 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* colCtxt, Vec3f* a, Vec3f* b,
- Actor** exclusions, s32 numExclusions) {
- return CollisionCheck_LineOC(globalCtx, colCtxt, a, b, exclusions, numExclusions);
+s32 CollisionCheck_LineOCCheck(PlayState* play, CollisionCheckContext* colCtxt, Vec3f* a, Vec3f* b, Actor** exclusions,
+ s32 numExclusions) {
+ return CollisionCheck_LineOC(play, colCtxt, a, b, exclusions, numExclusions);
}
/**
@@ -3669,11 +3629,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* init) {
+void Collider_SetTrisDim(PlayState* play, ColliderTris* collider, s32 index, ColliderTrisElementDimInit* init) {
ColliderTrisElement* element = &collider->elements[index];
- Collider_SetTrisElementDim(globalCtx, &element->dim, init);
+ Collider_SetTrisElementDim(play, &element->dim, init);
}
/**
@@ -3750,7 +3709,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) {
*/
#ifdef NON_MATCHING
// needs in-function static bss
-void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) {
+void CollisionCheck_SpawnRedBlood(PlayState* play, Vec3f* v) {
static EffectSparkInit D_801EE200;
s32 effectIndex;
@@ -3796,7 +3755,7 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) {
D_801EE200.speed = 8.0f;
D_801EE200.gravity = -1.0f;
- Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE200);
+ Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE200);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnRedBlood.s")
@@ -3808,7 +3767,7 @@ void CollisionCheck_SpawnRedBlood(GlobalContext* globalCtx, Vec3f* v) {
*/
#ifdef NON_MATCHING
// needs in-function static bss
-void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) {
+void CollisionCheck_SpawnWaterDroplets(PlayState* play, Vec3f* v) {
static EffectSparkInit D_801EE738;
s32 effectIndex;
@@ -3854,7 +3813,7 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) {
D_801EE738.speed = 8.0f;
D_801EE738.gravity = -1.0f;
- Effect_Add(globalCtx, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE738);
+ Effect_Add(play, &effectIndex, EFFECT_SPARK, 0, 1, &D_801EE738);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_collision_check/CollisionCheck_SpawnWaterDroplets.s")
@@ -3863,7 +3822,7 @@ void CollisionCheck_SpawnWaterDroplets(GlobalContext* globalCtx, Vec3f* v) {
/**
* 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 shieldParticleInitMetal = {
16,
{ 0, 0, 0 },
@@ -3889,36 +3848,36 @@ void CollisionCheck_SpawnShieldParticles(GlobalContext* globalCtx, Vec3f* v) {
shieldParticleInitMetal.lightPoint.y = shieldParticleInitMetal.position.y;
shieldParticleInitMetal.lightPoint.z = shieldParticleInitMetal.position.z;
- Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitMetal);
+ Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitMetal);
}
/**
* 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);
play_sound(NA_SE_IT_SHIELD_REFLECT_SW);
}
/**
* 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_PlaySfxAtPos(pos, NA_SE_IT_SHIELD_REFLECT_SW);
}
/**
* 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* pos) {
+void CollisionCheck_SpawnShieldParticlesWood(PlayState* play, Vec3f* v, Vec3f* pos) {
static EffectShieldParticleInit shieldParticleInitWood = {
16,
{ 0, 0, 0 },
@@ -3944,7 +3903,7 @@ void CollisionCheck_SpawnShieldParticlesWood(GlobalContext* globalCtx, Vec3f* v,
shieldParticleInitWood.lightPoint.y = shieldParticleInitWood.position.y;
shieldParticleInitWood.lightPoint.z = shieldParticleInitWood.position.z;
- Effect_Add(globalCtx, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitWood);
+ Effect_Add(play, &effectIndex, EFFECT_SHIELD_PARTICLE, 0, 1, &shieldParticleInitWood);
Audio_PlaySfxAtPos(pos, NA_SE_IT_REFLECTION_WOOD);
}
diff --git a/src/code/z_construct.c b/src/code/z_construct.c
index a2e295da2..5e92d4958 100644
--- a/src/code/z_construct.c
+++ b/src/code/z_construct.c
@@ -1,4 +1,4 @@
#include "global.h"
-void func_801AAAA0(GlobalContext* globalCtx) {
+void func_801AAAA0(PlayState* play) {
}
diff --git a/src/code/z_debug_display.c b/src/code/z_debug_display.c
index fb7378751..a8b851ed7 100644
--- a/src/code/z_debug_display.c
+++ b/src/code/z_debug_display.c
@@ -7,10 +7,10 @@ typedef struct {
/* 0x04 */ void* drawArg; // segment address (display list or texture) passed to the draw funciton when called
} DebugDispObjectInfo; // size = 0x8
-typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, GlobalContext*);
+typedef void (*DebugDispObject_DrawFunc)(DebugDispObject*, void*, PlayState*);
-void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, GlobalContext*);
-void DebugDisplay_DrawPolygon(DebugDispObject*, void*, GlobalContext*);
+void DebugDisplay_DrawSpriteI8(DebugDispObject*, void*, PlayState*);
+void DebugDisplay_DrawPolygon(DebugDispObject*, void*, PlayState*);
DebugDispObject* DebugDisplay_Init(void) {
sDebugObjectListHead = NULL;
@@ -51,44 +51,44 @@ DebugDispObjectInfo sDebugObjectInfoTable[] = {
{ 1, &sDebugDisplay2DL },
};
-void DebugDisplay_DrawObjects(GlobalContext* globalCtx) {
+void DebugDisplay_DrawObjects(PlayState* play) {
DebugDispObject* dispObj = sDebugObjectListHead;
DebugDispObjectInfo* objInfo;
while (dispObj != NULL) {
objInfo = &sDebugObjectInfoTable[dispObj->type];
- sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, globalCtx);
+ sDebugObjectDrawFuncTable[objInfo->drawType](dispObj, objInfo->drawArg, play);
dispObj = dispObj->next;
}
}
-void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, GlobalContext* globalCtx) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
+void DebugDisplay_DrawSpriteI8(DebugDispObject* dispObj, void* texture, PlayState* play) {
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C6FC(globalCtx->state.gfxCtx);
+ func_8012C6FC(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), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, sDebugDisplaySpriteDL);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
Lights1 sDebugDisplayLight1 = gdSPDefLights1(128, 128, 128, 255, 255, 255, 73, 73, 73);
-void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContext* globalCtx) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
+void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, PlayState* play) {
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C588(globalCtx->state.gfxCtx);
+ func_8012C588(play->state.gfxCtx);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0, dispObj->color.r, dispObj->color.g, dispObj->color.b, dispObj->color.a);
@@ -96,10 +96,10 @@ void DebugDisplay_DrawPolygon(DebugDispObject* dispObj, void* arg1, GlobalContex
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), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, arg1);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
s32 D_801BB068[] = {
@@ -110,16 +110,16 @@ s32 D_801BB08C = 0;
Gfx* func_800E99B0(GraphicsContext* gfxCtx, s32 arg1);
-void func_800E992C(GlobalContext* globalCtx, s32 arg1) {
+void func_800E992C(PlayState* play, s32 arg1) {
s32 pad;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C560(globalCtx->state.gfxCtx);
+ func_8012C560(play->state.gfxCtx);
gSPMatrix(POLY_XLU_DISP++, &gIdentityMtx, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
- gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(globalCtx->state.gfxCtx, arg1));
+ gSPDisplayList(POLY_XLU_DISP++, func_800E99B0(play->state.gfxCtx, arg1));
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug_display/func_800E99B0.s")
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index 67a4d5608..1367198c1 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -1,13 +1,14 @@
#include "global.h"
+#include "z64rumble.h"
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
-void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx);
-void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx);
-void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx);
-void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx);
-void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx);
-void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx);
-void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx);
+void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx);
+void func_800EA258(PlayState* play, CutsceneContext* csCtx);
+void func_800ED9C4(PlayState* play, CutsceneContext* csCtx);
+void func_800EA2B8(PlayState* play, CutsceneContext* csCtx);
+void func_800ED980(PlayState* play, CutsceneContext* csCtx);
+void func_800EDA04(PlayState* play, CutsceneContext* csCtx);
+void func_800EDA84(PlayState* play, CutsceneContext* csCtx);
// Unused
UNK_TYPE4 D_801BB120 = 0;
@@ -27,14 +28,14 @@ UNK_TYPE D_801F4DDC;
u8 D_801F4DE0;
s16 D_801F4DE2;
-void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void Cutscene_Init(PlayState* play, CutsceneContext* csCtx) {
s32 i;
csCtx->state = CS_STATE_0;
csCtx->frames = 0;
csCtx->unk_0C = 0.0f;
- globalCtx->csCtx.sceneCsCount = 0;
- globalCtx->csCtx.currentCsIndex = 0;
+ play->csCtx.sceneCsCount = 0;
+ play->csCtx.currentCsIndex = 0;
for (i = 0; i < ARRAY_COUNT(D_801F4DC8); i++) {
D_801F4DC8[i] = 0;
@@ -45,18 +46,18 @@ void Cutscene_Init(GlobalContext* globalCtx, CutsceneContext* csCtx) {
Audio_SetCutsceneFlag(false);
}
-void Cutscene_Start(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void Cutscene_Start(PlayState* play, CutsceneContext* csCtx) {
csCtx->state = CS_STATE_1;
csCtx->playerAction = NULL;
}
-void Cutscene_End(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void Cutscene_End(PlayState* play, CutsceneContext* csCtx) {
if (csCtx->state != CS_STATE_4) {
csCtx->state = CS_STATE_3;
}
}
-typedef void (*CutsceneStateHandler)(GlobalContext* globalCtx, CutsceneContext* csCtx);
+typedef void (*CutsceneStateHandler)(PlayState* play, CutsceneContext* csCtx);
CutsceneStateHandler sCsStateHandlers1[] = {
Cutscene_DoNothing, // CS_STATE_0
@@ -66,9 +67,9 @@ CutsceneStateHandler sCsStateHandlers1[] = {
Cutscene_DoNothing, // CS_STATE_4
};
-void Cutscene_Update1(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void Cutscene_Update1(PlayState* play, CutsceneContext* csCtx) {
if (gSaveContext.save.cutscene < 0xFFF0) {
- sCsStateHandlers1[csCtx->state](globalCtx, csCtx);
+ sCsStateHandlers1[csCtx->state](play, csCtx);
}
}
@@ -80,8 +81,8 @@ CutsceneStateHandler sCsStateHandlers2[] = {
func_800ED980, // CS_STATE_4
};
-void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) {
- if ((gSaveContext.cutsceneTrigger != 0) && (globalCtx->sceneLoadFlag == 0x14)) {
+void Cutscene_Update2(PlayState* play, CutsceneContext* csCtx) {
+ if ((gSaveContext.cutsceneTrigger != 0) && (play->sceneLoadFlag == 0x14)) {
gSaveContext.cutsceneTrigger = 0;
}
@@ -91,32 +92,32 @@ void Cutscene_Update2(GlobalContext* globalCtx, CutsceneContext* csCtx) {
}
if (gSaveContext.save.cutscene >= 0xFFF0) {
- func_800EDA84(globalCtx, csCtx);
- sCsStateHandlers2[csCtx->state](globalCtx, csCtx);
+ func_800EDA84(play, csCtx);
+ sCsStateHandlers2[csCtx->state](play, csCtx);
}
}
-void Cutscene_DoNothing(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void Cutscene_DoNothing(PlayState* play, CutsceneContext* csCtx) {
}
-s32 func_800EA220(GlobalContext* globalCtx, CutsceneContext* csCtx, f32 target) {
+s32 func_800EA220(PlayState* play, CutsceneContext* csCtx, f32 target) {
return Math_StepToF(&csCtx->unk_0C, target, 0.1f);
}
-void func_800EA258(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void func_800EA258(PlayState* play, CutsceneContext* csCtx) {
Interface_ChangeAlpha(1);
ShrinkWindow_SetLetterboxTarget(32);
- if (func_800EA220(globalCtx, csCtx, 1.0f)) {
+ if (func_800EA220(play, csCtx, 1.0f)) {
Audio_SetCutsceneFlag(true);
csCtx->state++;
}
}
-void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) {
- func_800ED980(globalCtx, csCtx);
+void func_800EA2B8(PlayState* play, CutsceneContext* csCtx) {
+ func_800ED980(play, csCtx);
Interface_ChangeAlpha(1);
ShrinkWindow_SetLetterboxTarget(32);
- if (func_800EA220(globalCtx, csCtx, 1.0f)) {
+ if (func_800EA220(play, csCtx, 1.0f)) {
Audio_SetCutsceneFlag(true);
csCtx->state++;
}
@@ -125,10 +126,10 @@ void func_800EA2B8(GlobalContext* globalCtx, CutsceneContext* csCtx) {
/* Start of command handling section */
// Command 0x96: Miscellaneous commands.
-void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_Misc(PlayState* play2, CutsceneContext* csCtx, CsCmdBase* cmd) {
static u16 D_801BB15C = 0xFFFF;
- Player* player = GET_PLAYER(globalCtx2);
- GlobalContext* globalCtx = globalCtx2;
+ Player* player = GET_PLAYER(play2);
+ PlayState* play = play2;
u8 isStartFrame = false;
f32 progress;
SceneTableEntry* loadedScene;
@@ -146,33 +147,33 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
switch (cmd->base) {
case 0x1:
if (isStartFrame) {
- func_800FD78C(globalCtx);
- globalCtx->envCtx.unk_F2[0] = 0x3C;
+ func_800FD78C(play);
+ play->envCtx.unk_F2[0] = 0x3C;
}
break;
case 0x2:
if (isStartFrame) {
func_801A47DC(NATURE_CHANNEL_LIGHTNING, CHANNEL_IO_PORT_0, 0);
- Environment_AddLightningBolts(globalCtx, 3);
+ Environment_AddLightningBolts(play, 3);
D_801F4E68 = 1;
}
break;
case 0x3:
- if (globalCtx->envCtx.lightSettings.fogFar < 12800) {
- globalCtx->envCtx.lightSettings.fogFar += 35;
+ if (play->envCtx.lightSettings.fogFar < 12800) {
+ play->envCtx.lightSettings.fogFar += 35;
}
break;
case 0x4:
if (isStartFrame) {
- globalCtx->envCtx.unk_19 = 1;
- globalCtx->envCtx.unk_17 = 1;
- globalCtx->envCtx.unk_18 = 0;
- globalCtx->envCtx.unk_1A = 0x3C;
- globalCtx->envCtx.unk_21 = 1;
- globalCtx->envCtx.unk_1F = 0;
- globalCtx->envCtx.unk_20 = 1;
- globalCtx->envCtx.unk_24 = 0x3C;
- globalCtx->envCtx.unk_22 = globalCtx->envCtx.unk_24;
+ play->envCtx.unk_19 = 1;
+ play->envCtx.unk_17 = 1;
+ play->envCtx.unk_18 = 0;
+ play->envCtx.unk_1A = 0x3C;
+ play->envCtx.unk_21 = 1;
+ play->envCtx.unk_1F = 0;
+ play->envCtx.unk_20 = 1;
+ play->envCtx.unk_24 = 0x3C;
+ play->envCtx.unk_22 = play->envCtx.unk_24;
}
break;
case 0x5:
@@ -182,16 +183,16 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
break;
case 0x7:
if (isStartFrame) {
- loadedScene = globalCtx->loadedScene;
+ loadedScene = play->loadedScene;
if (loadedScene->titleTextId != 0) {
- func_80151A68(globalCtx, loadedScene->titleTextId);
+ func_80151A68(play, loadedScene->titleTextId);
}
}
break;
case 0x8:
func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG);
if (isStartFrame) {
- sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6);
+ sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6);
Quake_SetSpeed(sCutsceneQuakeIndex, 22000);
Quake_SetQuakeValues(sCutsceneQuakeIndex, 6, 4, 0, 0);
Quake_SetCountdown(sCutsceneQuakeIndex, 800);
@@ -215,32 +216,32 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
D_801F6D30.a = 255 * progress;
break;
case 0xC:
- globalCtx->roomCtx.currRoom.segment = NULL;
+ play->roomCtx.currRoom.segment = NULL;
break;
case 0xD:
- if (globalCtx->state.frames & 8) {
- if (globalCtx->envCtx.lightSettings.ambientColor[0] < 40) {
- globalCtx->envCtx.lightSettings.ambientColor[0] += 2;
- globalCtx->envCtx.lightSettings.diffuseColor1[1] -= 3;
- globalCtx->envCtx.lightSettings.diffuseColor1[2] -= 3;
+ if (play->state.frames & 8) {
+ if (play->envCtx.lightSettings.ambientColor[0] < 40) {
+ play->envCtx.lightSettings.ambientColor[0] += 2;
+ play->envCtx.lightSettings.diffuseColor1[1] -= 3;
+ play->envCtx.lightSettings.diffuseColor1[2] -= 3;
}
} else {
- if (globalCtx->envCtx.lightSettings.ambientColor[0] > 2) {
- globalCtx->envCtx.lightSettings.ambientColor[0] -= 2;
- globalCtx->envCtx.lightSettings.diffuseColor1[1] += 3;
- globalCtx->envCtx.lightSettings.diffuseColor1[2] += 3;
+ if (play->envCtx.lightSettings.ambientColor[0] > 2) {
+ play->envCtx.lightSettings.ambientColor[0] -= 2;
+ play->envCtx.lightSettings.diffuseColor1[1] += 3;
+ play->envCtx.lightSettings.diffuseColor1[2] += 3;
}
}
break;
case 0xE:
- globalCtx->unk_18845 = 1;
+ play->unk_18845 = 1;
break;
case 0xF:
- globalCtx->unk_18845 = 0;
+ play->unk_18845 = 0;
break;
case 0x10:
if (isStartFrame) {
- globalCtx->envCtx.sandstormState = 1;
+ play->envCtx.sandstormState = 1;
}
func_8019F128(NA_SE_EV_SAND_STORM - SFX_FLAG);
break;
@@ -260,10 +261,10 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
csCtx->frames = cmd->startFrame - 1;
break;
case 0x14:
- EnvFlags_Set(globalCtx, 3);
+ EnvFlags_Set(play, 3);
break;
case 0x15:
- EnvFlags_Set(globalCtx, 4);
+ EnvFlags_Set(play, 4);
break;
case 0x16:
gSaveContext.save.playerForm = PLAYER_FORM_DEKU;
@@ -282,7 +283,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
case 0x1A:
func_8019F128(NA_SE_EV_EARTHQUAKE_LAST2 - SFX_FLAG);
if (isStartFrame) {
- sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6);
+ sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6);
Quake_SetSpeed(sCutsceneQuakeIndex, 30000);
Quake_SetQuakeValues(sCutsceneQuakeIndex, 20, 10, 0, 0);
Quake_SetCountdown(sCutsceneQuakeIndex, 800);
@@ -290,15 +291,15 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
break;
case 0x1B:
if (isStartFrame) {
- globalCtx->nextEntranceIndex = 0x1C00;
+ play->nextEntranceIndex = 0x1C00;
gSaveContext.nextCutsceneIndex = 0xFFF8;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
}
break;
case 0x1C:
if (isStartFrame) {
- globalCtx->envCtx.unk_17 = 0xD;
+ play->envCtx.unk_17 = 0xD;
}
break;
case 0x1D:
@@ -312,12 +313,12 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
break;
case 0x21:
if (isStartFrame) {
- Sram_SaveSpecialEnterClockTown(globalCtx);
+ Sram_SaveSpecialEnterClockTown(play);
}
break;
case 0x22:
if (isStartFrame) {
- func_80144A94(&globalCtx->sramCtx);
+ func_80144A94(&play->sramCtx);
}
break;
case 0x23:
@@ -334,7 +335,7 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
case 0x24:
func_8019F128(NA_SE_EV_EARTHQUAKE_LAST - SFX_FLAG);
if (isStartFrame) {
- sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(globalCtx), 6);
+ sCutsceneQuakeIndex = Quake_Add(GET_ACTIVE_CAM(play), 6);
Quake_SetSpeed(sCutsceneQuakeIndex, 22000);
Quake_SetQuakeValues(sCutsceneQuakeIndex, 2, 1, 0, 0);
Quake_SetCountdown(sCutsceneQuakeIndex, 800);
@@ -347,12 +348,12 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
gSaveContext.save.day = 9;
{
- GameState* gameState = &globalCtx->state;
+ GameState* gameState = &play->state;
gameState->running = false;
}
- SET_NEXT_GAMESTATE(&globalCtx->state, Daytelop_Init, DaytelopContext);
+ SET_NEXT_GAMESTATE(&play->state, Daytelop_Init, DaytelopContext);
- Sram_SaveSpecialNewDay(globalCtx);
+ Sram_SaveSpecialNewDay(play);
break;
case 0x27:
@@ -366,33 +367,33 @@ void Cutscene_Command_Misc(GlobalContext* globalCtx2, CutsceneContext* csCtx, Cs
}
// Command 0x97: 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) {
if (cmd->setting != 0x20) {
- globalCtx->envCtx.lightSettingOverride = cmd->setting - 1;
- globalCtx->envCtx.lightBlend = 1.0f;
+ play->envCtx.lightSettingOverride = cmd->setting - 1;
+ play->envCtx.lightBlend = 1.0f;
} else {
- globalCtx->envCtx.lightSettingOverride = 0xFF;
+ play->envCtx.lightSettingOverride = 0xFF;
}
}
}
// Command 0x12C: Plays a sequence (Background music or Fanfare)
-void Cutscene_Command_PlaySequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) {
+void Cutscene_Command_PlaySequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) {
if (csCtx->frames == cmd->startFrame) {
func_801A2C88(cmd->sequence - 1);
}
}
// Command 0x12D: Stops a sequence (Background music or Fanfare)
-void Cutscene_Command_StopSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) {
+void Cutscene_Command_StopSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceChange* cmd) {
if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) {
func_801A2D54(cmd->sequence - 1);
}
}
// Command 0x9C: Fade a sequence (Background music or Fanfare) over duration
-void Cutscene_Command_FadeSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) {
+void Cutscene_Command_FadeSequence(PlayState* play, CutsceneContext* csCtx, CsCmdSequenceFade* cmd) {
if ((csCtx->frames == cmd->startFrame) && (csCtx->frames < cmd->endFrame)) {
u8 fadeTimer = cmd->endFrame - cmd->startFrame;
@@ -405,16 +406,16 @@ void Cutscene_Command_FadeSequence(GlobalContext* globalCtx, CutsceneContext* cs
}
// Command 0x12E: Play Ambience sequence
-void Cutscene_Command_PlayAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_PlayAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if (csCtx->frames == cmd->startFrame) {
// Audio_PlayNatureAmbienceSequence
// nightSeqIndex is natureAmbienceId
- func_801A4A28(globalCtx->soundCtx.nightSeqIndex);
+ func_801A4A28(play->soundCtx.nightSeqIndex);
}
}
// Command 0x130:
-void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void func_800EAD48(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if (csCtx->frames == cmd->startFrame) {
// Audio_SetSfxReverbIndexExceptOcarinaBank
func_801A4428(2);
@@ -422,7 +423,7 @@ void func_800EAD48(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
}
// Command 0x131:
-void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void func_800EAD7C(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if (csCtx->frames == cmd->startFrame) {
// Audio_SetSfxReverbIndexExceptOcarinaBank
func_801A4428(1);
@@ -432,7 +433,7 @@ void func_800EAD7C(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
#ifdef NON_MATCHING
// needs in-function static bss
// audio related
-void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void func_800EADB0(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
static u16 seqId;
u8 dayMinusOne;
@@ -492,7 +493,7 @@ void func_800EADB0(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase*
#endif
// Command 0x12F: Fade Ambience sequence
-void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_FadeAmbienceSequence(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if (csCtx->frames == cmd->startFrame && csCtx->frames < cmd->endFrame) {
u8 fadeTimer = cmd->endFrame - cmd->startFrame;
@@ -501,18 +502,18 @@ void Cutscene_Command_FadeAmbienceSequence(GlobalContext* globalCtx, CutsceneCon
}
// Command 0x190: Rumble
-void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdRumble* cmd) {
+void Cutscene_Command_Rumble(PlayState* play, CutsceneContext* csCtx, CsCmdRumble* cmd) {
switch (cmd->type) {
case 1:
if (csCtx->frames == cmd->startFrame) {
- func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8);
+ Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep);
}
break;
case 2:
if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) {
- if ((csCtx->frames == cmd->startFrame) || (globalCtx->state.frames % 64 == 0)) {
- func_8013ECE0(0.0f, cmd->unk6, cmd->unk7, cmd->unk8);
+ if ((csCtx->frames == cmd->startFrame) || (play->state.frames % 64 == 0)) {
+ Rumble_Request(0.0f, cmd->intensity, cmd->decayTimer, cmd->decayStep);
}
}
break;
@@ -520,29 +521,29 @@ void Cutscene_Command_Rumble(GlobalContext* globalCtx, CutsceneContext* csCtx, C
}
// Command 0x9B:
-void Cutscene_Command_FadeColorScreen(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) {
+void Cutscene_Command_FadeColorScreen(PlayState* play, CutsceneContext* csCtx, CsCmdFadeScreen* cmd) {
if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) {
f32 alpha;
- globalCtx->envCtx.fillScreen = true;
+ play->envCtx.fillScreen = true;
alpha = Environment_LerpWeight(cmd->endFrame, cmd->startFrame, csCtx->frames);
if (((cmd->unk0 == 1)) || (cmd->unk0 == 2)) {
- globalCtx->envCtx.screenFillColor[0] = cmd->color.r;
- globalCtx->envCtx.screenFillColor[1] = cmd->color.g;
- globalCtx->envCtx.screenFillColor[2] = cmd->color.b;
+ play->envCtx.screenFillColor[0] = cmd->color.r;
+ play->envCtx.screenFillColor[1] = cmd->color.g;
+ play->envCtx.screenFillColor[2] = cmd->color.b;
if (cmd->unk0 == 2) {
- globalCtx->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f;
+ play->envCtx.screenFillColor[3] = (1.0f - alpha) * 255.0f;
} else {
- globalCtx->envCtx.screenFillColor[3] = 255.0f * alpha;
+ play->envCtx.screenFillColor[3] = 255.0f * alpha;
}
}
}
}
// Command 0x9D: Set Time of Day & Environment Time
-void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdDayTime* cmd) {
+void Cutscene_Command_SetTime(PlayState* play, CutsceneContext* csCtx, CsCmdDayTime* cmd) {
u16 nextTime;
u16 hourAsMinutes;
u16 minutes;
@@ -557,7 +558,7 @@ void Cutscene_Command_SetTime(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
}
-void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_TerminatorImpl(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
csCtx->state = CS_STATE_4;
func_80165690();
Audio_SetCutsceneFlag(false);
@@ -569,32 +570,32 @@ void Cutscene_TerminatorImpl(GlobalContext* globalCtx, CutsceneContext* csCtx, C
gSaveContext.save.cutscene = 0;
if (cmd->base == 1) {
- globalCtx->nextEntranceIndex = globalCtx->csCtx.sceneCsList[globalCtx->csCtx.currentCsIndex].nextEntranceIndex;
+ play->nextEntranceIndex = play->csCtx.sceneCsList[play->csCtx.currentCsIndex].nextEntranceIndex;
gSaveContext.nextCutsceneIndex = 0;
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
if (gSaveContext.gameMode != 1) {
- Scene_SetExitFade(globalCtx);
+ Scene_SetExitFade(play);
} else {
D_801BB12C++;
if (D_801BB12C >= 2) {
D_801BB12C = 0;
}
- globalCtx->unk_1887F = 4;
+ play->unk_1887F = 4;
}
- if ((globalCtx->nextEntranceIndex & 0xF) > 0) {
- gSaveContext.nextCutsceneIndex = (globalCtx->nextEntranceIndex & 0xF) + 0xFFEF;
+ if ((play->nextEntranceIndex & 0xF) > 0) {
+ gSaveContext.nextCutsceneIndex = (play->nextEntranceIndex & 0xF) + 0xFFEF;
}
- globalCtx->nextEntranceIndex &= ~0xF;
+ play->nextEntranceIndex &= ~0xF;
}
}
// Command 0x15E
-void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_Terminator(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if (cmd->base == 1) {
if (csCtx->frames == cmd->startFrame) {
- Cutscene_TerminatorImpl(globalCtx, csCtx, cmd);
+ Cutscene_TerminatorImpl(play, csCtx, cmd);
}
} else if (cmd->base == 2) {
if (csCtx->frames == cmd->startFrame) {
@@ -603,44 +604,44 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt
switch (D_801F4DE2) {
case 0x1F:
if (gSaveContext.save.weekEventReg[20] & 2) {
- globalCtx->nextEntranceIndex = 0x3010;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->nextEntranceIndex = 0x3010;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
} else {
- globalCtx->nextEntranceIndex = 0x8600;
+ play->nextEntranceIndex = 0x8600;
gSaveContext.nextCutsceneIndex = 0xFFF0;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
}
break;
case 0x44:
if (gSaveContext.save.weekEventReg[33] & 0x80) {
- globalCtx->nextEntranceIndex = 0xAE70;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->nextEntranceIndex = 0xAE70;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
} else {
- globalCtx->nextEntranceIndex = 0xAE00;
+ play->nextEntranceIndex = 0xAE00;
gSaveContext.nextCutsceneIndex = 0xFFF0;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
}
break;
case 0x5F:
gSaveContext.save.weekEventReg[55] |= 0x80;
- globalCtx->nextEntranceIndex = 0x6A80;
+ play->nextEntranceIndex = 0x6A80;
gSaveContext.nextCutsceneIndex = 0xFFF0;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
break;
case 0x36:
gSaveContext.save.weekEventReg[52] |= 0x20;
- globalCtx->nextEntranceIndex = 0x2000;
+ play->nextEntranceIndex = 0x2000;
gSaveContext.nextCutsceneIndex = 0xFFF1;
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 3;
+ play->sceneLoadFlag = 0x14;
+ play->unk_1887F = 3;
break;
}
}
@@ -649,142 +650,142 @@ void Cutscene_Command_Terminator(GlobalContext* globalCtx, CutsceneContext* csCt
// Command 0x15F: Chooses between a cutscene or a rotating mask depending on whether the player has the corresponding
// mask
-void Cutscene_Command_ChooseCreditsScenes(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_ChooseCreditsScenes(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if ((csCtx->frames >= cmd->startFrame) && (func_801A3950(0, true) != 0xFF)) {
switch (cmd->base) {
case 1:
- Cutscene_TerminatorImpl(globalCtx, csCtx, cmd);
+ Cutscene_TerminatorImpl(play, csCtx, cmd);
break;
case 2:
if (INV_CONTENT(ITEM_MASK_KAMARO) == ITEM_MASK_KAMARO) {
// Milk bar
- globalCtx->nextEntranceIndex = 0x2400;
+ play->nextEntranceIndex = 0x2400;
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C00;
+ play->nextEntranceIndex = 0x1C00;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 3:
if (INV_CONTENT(ITEM_MASK_GREAT_FAIRY) == ITEM_MASK_GREAT_FAIRY) {
// Fairy's fountain
- globalCtx->nextEntranceIndex = 0x4600;
+ play->nextEntranceIndex = 0x4600;
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C10;
+ play->nextEntranceIndex = 0x1C10;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 4:
if (INV_CONTENT(ITEM_MASK_ROMANI) == ITEM_MASK_ROMANI) {
// Romani ranch
- globalCtx->nextEntranceIndex = 0x6400;
+ play->nextEntranceIndex = 0x6400;
gSaveContext.nextCutsceneIndex = 0xFFF1;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C20;
+ play->nextEntranceIndex = 0x1C20;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 5:
if (INV_CONTENT(ITEM_MASK_BLAST) == ITEM_MASK_BLAST) {
// West clock town
- globalCtx->nextEntranceIndex = 0xD400;
+ play->nextEntranceIndex = 0xD400;
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C30;
+ play->nextEntranceIndex = 0x1C30;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 6:
if (INV_CONTENT(ITEM_MASK_CIRCUS_LEADER) == ITEM_MASK_CIRCUS_LEADER) {
// Milk bar
- globalCtx->nextEntranceIndex = 0x2400;
+ play->nextEntranceIndex = 0x2400;
gSaveContext.nextCutsceneIndex = 0xFFF1;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C50;
+ play->nextEntranceIndex = 0x1C50;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 7:
if (INV_CONTENT(ITEM_MASK_BREMEN) == ITEM_MASK_BREMEN) {
// Milk bar
- globalCtx->nextEntranceIndex = 0x2400;
+ play->nextEntranceIndex = 0x2400;
gSaveContext.nextCutsceneIndex = 0xFFF3;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C60;
+ play->nextEntranceIndex = 0x1C60;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 8:
// Ikana canyon
- globalCtx->nextEntranceIndex = 0x2000;
+ play->nextEntranceIndex = 0x2000;
gSaveContext.nextCutsceneIndex = 0xFFF3;
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 9:
if (INV_CONTENT(ITEM_MASK_COUPLE) == ITEM_MASK_COUPLE) {
// Termina field
- globalCtx->nextEntranceIndex = 0x5400;
+ play->nextEntranceIndex = 0x5400;
gSaveContext.nextCutsceneIndex = 0xFFF8;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C70;
+ play->nextEntranceIndex = 0x1C70;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 10:
if (INV_CONTENT(ITEM_MASK_BUNNY) == ITEM_MASK_BUNNY) {
// Cucco shack
- globalCtx->nextEntranceIndex = 0x7E00;
+ play->nextEntranceIndex = 0x7E00;
gSaveContext.nextCutsceneIndex = 0xFFF0;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C40;
+ play->nextEntranceIndex = 0x1C40;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
case 11:
if (INV_CONTENT(ITEM_MASK_POSTMAN) == ITEM_MASK_POSTMAN) {
// Termina field
- globalCtx->nextEntranceIndex = 0x5410;
+ play->nextEntranceIndex = 0x5410;
gSaveContext.nextCutsceneIndex = 0xFFF8;
} else {
// SPOT00
- globalCtx->nextEntranceIndex = 0x1C80;
+ play->nextEntranceIndex = 0x1C80;
gSaveContext.nextCutsceneIndex = 0xFFF9;
}
- globalCtx->sceneLoadFlag = 0x14;
+ play->sceneLoadFlag = 0x14;
break;
}
}
}
// Command 0x99: Motion blur
-void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_MotionBlur(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) {
if ((csCtx->frames == cmd->startFrame) && (cmd->base == 1)) {
func_8016566C(180);
@@ -803,8 +804,8 @@ void Cutscene_Command_MotionBlur(GlobalContext* globalCtx, CutsceneContext* csCt
}
// Command 0x9A: Gives Tatl to the player
-void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
- Player* player = GET_PLAYER(globalCtx);
+void Cutscene_Command_GiveTatlToPlayer(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
+ Player* player = GET_PLAYER(play);
if (csCtx->frames == cmd->startFrame) {
if (cmd->base == 1) {
@@ -812,69 +813,69 @@ void Cutscene_Command_GiveTatlToPlayer(GlobalContext* globalCtx, CutsceneContext
if (player->tatlActor != NULL) {
return;
}
- player->tatlActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, player->actor.world.pos.x,
+ player->tatlActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, player->actor.world.pos.x,
player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0);
}
}
}
// Command 0x98
-void Cutscene_Command_TransitionFX(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdBase* cmd) {
+void Cutscene_Command_TransitionFX(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
if ((csCtx->frames >= cmd->startFrame) && (cmd->endFrame >= csCtx->frames)) {
f32 temp_f0;
- globalCtx->envCtx.fillScreen = true;
+ play->envCtx.fillScreen = true;
temp_f0 = 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_f0;
+ play->envCtx.screenFillColor[3] = 255.0f * temp_f0;
if (temp_f0 == 0.0f) {
func_8019F128(NA_SE_EV_S_STONE_FLASH);
}
} else {
- globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f;
+ play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 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_f0;
+ play->envCtx.screenFillColor[3] = 255.0f * temp_f0;
} else {
- globalCtx->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f;
+ play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 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_f0) * 255.0f;
+ play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f;
} else {
- globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0;
+ play->envCtx.screenFillColor[3] = 255.0f * temp_f0;
}
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_f0) * 255.0f;
+ play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f;
} else {
- globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0;
+ play->envCtx.screenFillColor[3] = 255.0f * temp_f0;
}
break;
@@ -884,35 +885,35 @@ 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_f0) * 255.0f;
+ play->envCtx.screenFillColor[3] = (1.0f - temp_f0) * 255.0f;
} else {
- globalCtx->envCtx.screenFillColor[3] = 255.0f * temp_f0;
+ play->envCtx.screenFillColor[3] = 255.0f * temp_f0;
}
break;
case 12:
- globalCtx->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0));
- globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0];
- globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0];
- globalCtx->envCtx.screenFillColor[3] = 255;
+ play->envCtx.screenFillColor[0] = (160.0f * (1.0f - temp_f0));
+ play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[0];
+ play->envCtx.screenFillColor[2] = play->envCtx.screenFillColor[0];
+ play->envCtx.screenFillColor[3] = 255;
break;
case 13:
- globalCtx->envCtx.screenFillColor[0] = (160.0f * temp_f0);
- globalCtx->envCtx.screenFillColor[1] = globalCtx->envCtx.screenFillColor[0];
- globalCtx->envCtx.screenFillColor[2] = globalCtx->envCtx.screenFillColor[0];
- globalCtx->envCtx.screenFillColor[3] = 255;
+ play->envCtx.screenFillColor[0] = (160.0f * temp_f0);
+ play->envCtx.screenFillColor[1] = play->envCtx.screenFillColor[0];
+ play->envCtx.screenFillColor[2] = play->envCtx.screenFillColor[0];
+ play->envCtx.screenFillColor[3] = 255;
break;
}
}
}
// Command 0x5A: Camera
-s32 Cutscene_Command_Camera(GlobalContext* globalCtx, u8* cmd) {
+s32 Cutscene_Command_Camera(PlayState* play, u8* cmd) {
s32 sp1C = 0;
bcopy(cmd, &sp1C, sizeof(s32));
@@ -995,7 +996,7 @@ s32 Cutscene_CountNormalMasks(void) {
}
// Command 0xA: Textbox
-void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx, CsCmdTextbox* cmd) {
+void Cutscene_Command_Textbox(PlayState* play, CutsceneContext* csCtx, CsCmdTextbox* cmd) {
static s32 D_801BB160 = CS_TEXTBOX_TYPE_DEFAULT;
u8 dialogState;
s32 pad;
@@ -1017,21 +1018,21 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx,
if (CHECK_QUEST_ITEM(QUEST_REMAINS_ODOWLA) && CHECK_QUEST_ITEM(QUEST_REMAINS_GOHT) &&
CHECK_QUEST_ITEM(QUEST_REMAINS_GYORG) && CHECK_QUEST_ITEM(QUEST_REMAINS_TWINMOLD)) {
if (cmd->textId1 != 0xFFFF) {
- 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);
}
} else if (cmd->type == CS_TEXTBOX_TYPE_ALL_NORMAL_MASKS) {
if (Cutscene_CountNormalMasks() == 20) {
if (cmd->textId1 != 0xFFFF) {
- 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);
}
} else {
- Message_StartTextbox(globalCtx, cmd->base, NULL);
+ Message_StartTextbox(play, cmd->base, NULL);
}
} else {
goto else_label;
@@ -1039,7 +1040,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx,
} else if (D_801BB128 != cmd->base) {
D_801BB160 = CS_TEXTBOX_TYPE_LEARN_SONG;
D_801BB128 = cmd->base;
- func_80152434(globalCtx, cmd->base);
+ func_80152434(play, cmd->base);
} else {
else_label:
if (csCtx->frames >= cmd->endFrame) {
@@ -1047,17 +1048,17 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx,
// a textbox that is expected to be closed by the user is still open.
originalCsFrames = csCtx->frames;
- dialogState = Message_GetState(&globalCtx->msgCtx);
+ dialogState = Message_GetState(&play->msgCtx);
if ((dialogState != 2) && (dialogState != 0) && (dialogState != 7) && (dialogState != 8)) {
csCtx->frames--;
- if ((dialogState == 4) && Message_ShouldAdvance(globalCtx)) {
- if (globalCtx->msgCtx.choiceIndex == 0) {
+ if ((dialogState == 4) && Message_ShouldAdvance(play)) {
+ if (play->msgCtx.choiceIndex == 0) {
if (cmd->base == 0x33BD) {
func_8019F230();
}
if (cmd->textId1 != 0xFFFF) {
- func_80151938(globalCtx, cmd->textId1);
+ func_80151938(play, cmd->textId1);
if (cmd->type == CS_TEXTBOX_TYPE_3) {
D_801BB160 = CS_TEXTBOX_TYPE_3;
if (cmd->textId2 != 0xFFFF) {
@@ -1065,7 +1066,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
}
} else {
- func_801477B4(globalCtx);
+ func_801477B4(play);
csCtx->frames++;
}
} else {
@@ -1074,7 +1075,7 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
if (cmd->textId2 != 0xFFFF) {
- func_80151938(globalCtx, cmd->textId2);
+ func_80151938(play, cmd->textId2);
if (cmd->type == CS_TEXTBOX_TYPE_3) {
D_801BB160 = CS_TEXTBOX_TYPE_3;
if (cmd->textId1 != 0xFFFF) {
@@ -1082,14 +1083,14 @@ void Cutscene_Command_Textbox(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
}
} else {
- func_801477B4(globalCtx);
+ func_801477B4(play);
csCtx->frames++;
}
}
}
- if (dialogState == 5 && Message_ShouldAdvance(globalCtx)) {
- func_80152434(globalCtx, cmd->base);
+ if (dialogState == 5 && Message_ShouldAdvance(play)) {
+ func_80152434(play, cmd->base);
}
}
@@ -1157,7 +1158,7 @@ void func_800ECD7C(CutsceneContext* csCtx, u8** cutscenePtr, s16 index) {
*
* TODO: consider changing the type of `cutscenePtr` to `uintptr_t` when this function matches.
*/
-void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr) {
+void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutscenePtr) {
s32 i;
s16 phi_s0;
s32 totalEntries;
@@ -1175,7 +1176,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cutsceneEndFrame, sizeof(s32));
cutscenePtr += sizeof(s32);
- if (((u16)cutsceneEndFrame < csCtx->frames) && (globalCtx->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) {
+ if (((u16)cutsceneEndFrame < csCtx->frames) && (play->sceneLoadFlag != 0x14) && (csCtx->state != CS_STATE_4)) {
csCtx->state = CS_STATE_3;
return;
}
@@ -1213,7 +1214,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_Misc(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_Misc(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1222,7 +1223,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_SetLighting(globalCtx, csCtx, (CsCmdEnvLighting*)cutscenePtr);
+ Cutscene_Command_SetLighting(play, csCtx, (CsCmdEnvLighting*)cutscenePtr);
cutscenePtr += sizeof(CsCmdEnvLighting);
}
break;
@@ -1231,7 +1232,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_PlaySequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr);
+ Cutscene_Command_PlaySequence(play, csCtx, (CsCmdSequenceChange*)cutscenePtr);
cutscenePtr += sizeof(CsCmdSequenceChange);
}
break;
@@ -1240,7 +1241,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_StopSequence(globalCtx, csCtx, (CsCmdSequenceChange*)cutscenePtr);
+ Cutscene_Command_StopSequence(play, csCtx, (CsCmdSequenceChange*)cutscenePtr);
cutscenePtr += sizeof(CsCmdSequenceChange);
}
break;
@@ -1249,7 +1250,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_FadeSequence(globalCtx, csCtx, (CsCmdSequenceFade*)cutscenePtr);
+ Cutscene_Command_FadeSequence(play, csCtx, (CsCmdSequenceFade*)cutscenePtr);
cutscenePtr += sizeof(CsCmdSequenceFade);
}
break;
@@ -1258,7 +1259,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_PlayAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_PlayAmbienceSequence(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1267,7 +1268,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_FadeAmbienceSequence(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_FadeAmbienceSequence(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1276,7 +1277,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- func_800EAD48(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ func_800EAD48(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1285,7 +1286,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- func_800EAD7C(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ func_800EAD7C(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1294,7 +1295,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- func_800EADB0(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ func_800EADB0(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1303,7 +1304,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_Rumble(globalCtx, csCtx, (CsCmdRumble*)cutscenePtr);
+ Cutscene_Command_Rumble(play, csCtx, (CsCmdRumble*)cutscenePtr);
cutscenePtr += sizeof(CsCmdRumble);
}
break;
@@ -1312,7 +1313,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_FadeColorScreen(globalCtx, csCtx, (CsCmdFadeScreen*)cutscenePtr);
+ Cutscene_Command_FadeColorScreen(play, csCtx, (CsCmdFadeScreen*)cutscenePtr);
cutscenePtr += sizeof(CsCmdFadeScreen);
}
break;
@@ -1321,7 +1322,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_SetTime(globalCtx, csCtx, (CsCmdDayTime*)cutscenePtr);
+ Cutscene_Command_SetTime(play, csCtx, (CsCmdDayTime*)cutscenePtr);
cutscenePtr += sizeof(CsCmdDayTime);
}
break;
@@ -1339,14 +1340,14 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
break;
case CS_CMD_CAMERA:
- cutscenePtr = &cutscenePtr[Cutscene_Command_Camera(globalCtx, cutscenePtr)];
+ cutscenePtr = &cutscenePtr[Cutscene_Command_Camera(play, cutscenePtr)];
break;
case CS_CMD_TERMINATOR:
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_Terminator(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_Terminator(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1355,7 +1356,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_ChooseCreditsScenes(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_ChooseCreditsScenes(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1366,7 +1367,7 @@ 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, (CsCmdTextbox*)cutscenePtr);
+ Cutscene_Command_Textbox(play, csCtx, (CsCmdTextbox*)cutscenePtr);
}
cutscenePtr += sizeof(CsCmdTextbox);
}
@@ -1376,7 +1377,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_TransitionFX(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_TransitionFX(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1385,7 +1386,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_MotionBlur(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_MotionBlur(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1394,7 +1395,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
bcopy(cutscenePtr, &cmdEntries, sizeof(s32));
cutscenePtr += sizeof(s32);
for (j = 0; j < cmdEntries; j++) {
- Cutscene_Command_GiveTatlToPlayer(globalCtx, csCtx, (CsCmdBase*)cutscenePtr);
+ Cutscene_Command_GiveTatlToPlayer(play, csCtx, (CsCmdBase*)cutscenePtr);
cutscenePtr += sizeof(CsCmdBase);
}
break;
@@ -1413,29 +1414,29 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
}
#else
-void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx, u8* cutscenePtr);
+void Cutscene_ProcessCommands(PlayState* play, CutsceneContext* csCtx, u8* cutscenePtr);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/Cutscene_ProcessCommands.s")
#endif
/* End of command handling section */
-void func_800ED980(GlobalContext* globalCtx, CutsceneContext* csCtx) {
+void func_800ED980(PlayState* play, CutsceneContext* csCtx) {
if (gSaveContext.save.cutscene >= 0xFFF0) {
csCtx->frames++;
- Cutscene_ProcessCommands(globalCtx, csCtx, (u8*)globalCtx->csCtx.csData);
+ Cutscene_ProcessCommands(play, csCtx, (u8*)play->csCtx.csData);
}
}
-void func_800ED9C4(GlobalContext* globalCtx, CutsceneContext* csCtx) {
- if (func_800EA220(globalCtx, csCtx, 0.0f)) {
+void func_800ED9C4(PlayState* play, CutsceneContext* csCtx) {
+ if (func_800EA220(play, csCtx, 0.0f)) {
Audio_SetCutsceneFlag(false);
csCtx->state = CS_STATE_0;
}
}
// unused
-void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) {
- if (func_800EA220(globalCtx, csCtx, 0.0f)) {
+void func_800EDA04(PlayState* play, CutsceneContext* csCtx) {
+ if (func_800EA220(play, csCtx, 0.0f)) {
s16 i;
csCtx->playerAction = NULL;
@@ -1452,8 +1453,8 @@ void func_800EDA04(GlobalContext* globalCtx, CutsceneContext* csCtx) {
}
}
-void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) {
- if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&globalCtx->state)) {
+void func_800EDA84(PlayState* play, CutsceneContext* csCtx) {
+ if ((gSaveContext.cutsceneTrigger != 0) && (csCtx->state == CS_STATE_0) && !Player_InCsMode(&play->state)) {
gSaveContext.save.cutscene = 0xFFFD;
}
@@ -1474,7 +1475,7 @@ void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) {
csCtx->frames = 0xFFFF;
csCtx->csCamId = ActorCutscene_GetCurrentCamera(0x7F);
- func_8016119C(Play_GetCamera(globalCtx, csCtx->csCamId), &sCutsceneCameraInfo);
+ func_8016119C(Play_GetCamera(play, csCtx->csCamId), &sCutsceneCameraInfo);
csCtx->unk_18 = 0xFFFF;
if (gSaveContext.cutsceneTrigger == 0) {
@@ -1484,7 +1485,7 @@ void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) {
csCtx->state++;
}
- func_800ED980(globalCtx, csCtx);
+ func_800ED980(play, csCtx);
}
gSaveContext.cutsceneTrigger = 0;
@@ -1494,7 +1495,7 @@ void func_800EDA84(GlobalContext* globalCtx, CutsceneContext* csCtx) {
#ifdef NON_MATCHING
// HandleFlags?
// regalloc
-void func_800EDBE0(GlobalContext* globalCtx) {
+void func_800EDBE0(PlayState* play) {
CutsceneEntry* temp_a3;
s16 sp2A;
SceneTableEntry* sp24;
@@ -1505,7 +1506,7 @@ void func_800EDBE0(GlobalContext* globalCtx) {
if (sp2A != -1) {
temp_v0_3 = func_800F2138(sp2A);
if (temp_v0_3 != -1) {
- temp_a3 = ((void)0, globalCtx->csCtx.sceneCsList);
+ temp_a3 = ((void)0, play->csCtx.sceneCsList);
if ((temp_a3[temp_v0_3].unk7 != 0xFF) && (gSaveContext.respawnFlag == 0)) {
if (temp_a3[temp_v0_3].unk7 == 0xFE) {
ActorCutscene_Start(sp2A, NULL);
@@ -1525,11 +1526,11 @@ void func_800EDBE0(GlobalContext* globalCtx) {
}
if ((gSaveContext.respawnFlag == 0) || (gSaveContext.respawnFlag == -2)) {
- sp24 = globalCtx->loadedScene;
+ sp24 = play->loadedScene;
if ((sp24->titleTextId != 0) && gSaveContext.showTitleCard) {
if ((Entrance_GetTransitionFlags(gSaveContext.sceneSetupIndex + gSaveContext.save.entranceIndex) &
0x4000) != 0) {
- func_80151A68(globalCtx, sp24->titleTextId);
+ func_80151A68(play, sp24->titleTextId);
}
}
@@ -1540,16 +1541,16 @@ void func_800EDBE0(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_demo/func_800EDBE0.s")
#endif
-void func_800EDDB0(GlobalContext* globalCtx) {
+void func_800EDDB0(PlayState* play) {
}
void func_800EDDBC(UNK_TYPE arg0, UNK_TYPE arg1) {
}
-void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) {
+void Cutscene_LoadCutsceneData(PlayState* play, u8 csIndex) {
if (dREG(95) == 0) {
- globalCtx->csCtx.currentCsIndex = csIndex;
- globalCtx->csCtx.csData = Lib_SegmentedToVirtual(globalCtx->csCtx.sceneCsList[csIndex].segmentedData);
+ play->csCtx.currentCsIndex = csIndex;
+ play->csCtx.csData = Lib_SegmentedToVirtual(play->csCtx.sceneCsList[csIndex].segmentedData);
}
gSaveContext.cutsceneTrigger = 1;
@@ -1561,10 +1562,10 @@ void Cutscene_LoadCutsceneData(GlobalContext* globalCtx, u8 csIndex) {
* Interpolates the actor's position based on the corresponding actor action's position
* and the current cutscene frame
*/
-void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) {
+void Cutscene_ActorTranslate(Actor* actor, PlayState* play, s32 actorActionIndex) {
Vec3f start;
Vec3f end;
- CsCmdActorAction* entry = globalCtx->csCtx.actorActions[actorActionIndex];
+ CsCmdActorAction* entry = play->csCtx.actorActions[actorActionIndex];
f32 progress;
start.x = entry->startPos.x;
@@ -1574,7 +1575,7 @@ void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorAc
end.y = entry->endPos.y;
end.z = entry->endPos.z;
- progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames);
+ progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames);
VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress);
}
@@ -1583,10 +1584,10 @@ void Cutscene_ActorTranslate(Actor* actor, GlobalContext* globalCtx, s32 actorAc
* Interpolates the actor's position based on the corresponding actor action's position
* and the current cutscene frame, and sets the actor's yaw using the actor action yaw
*/
-void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) {
- Cutscene_ActorTranslate(actor, globalCtx, actorActionIndex);
+void Cutscene_ActorTranslateAndYaw(Actor* actor, PlayState* play, s32 actorActionIndex) {
+ Cutscene_ActorTranslate(actor, play, actorActionIndex);
- actor->world.rot.y = globalCtx->csCtx.actorActions[actorActionIndex]->urot.y;
+ actor->world.rot.y = play->csCtx.actorActions[actorActionIndex]->urot.y;
actor->shape.rot.y = actor->world.rot.y;
}
@@ -1594,21 +1595,21 @@ void Cutscene_ActorTranslateAndYaw(Actor* actor, GlobalContext* globalCtx, s32 a
* Interpolates the actor's position and yaw based on the corresponding actor action's
* position and the current cutscene frame
*/
-void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) {
+void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex) {
Vec3f start;
Vec3f end;
CsCmdActorAction* entry;
f32 progress;
- start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x;
- start.y = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.y;
- start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z;
- end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x;
- end.y = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.y;
- end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z;
+ start.x = play->csCtx.actorActions[actorActionIndex]->startPos.x;
+ start.y = play->csCtx.actorActions[actorActionIndex]->startPos.y;
+ start.z = play->csCtx.actorActions[actorActionIndex]->startPos.z;
+ end.x = play->csCtx.actorActions[actorActionIndex]->endPos.x;
+ end.y = play->csCtx.actorActions[actorActionIndex]->endPos.y;
+ end.z = play->csCtx.actorActions[actorActionIndex]->endPos.z;
- entry = globalCtx->csCtx.actorActions[actorActionIndex];
- progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames);
+ entry = play->csCtx.actorActions[actorActionIndex];
+ progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames);
VEC3F_LERPIMPDST(&actor->world.pos, &start, &end, progress);
@@ -1620,19 +1621,19 @@ void Cutscene_ActorTranslateAndYawSmooth(Actor* actor, GlobalContext* globalCtx,
* Interpolates the actor's XZ position and yaw based on the corresponding actor action's
* position and the current cutscene frame
*/
-void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCtx, s32 actorActionIndex) {
+void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, PlayState* play, s32 actorActionIndex) {
Vec3f start;
Vec3f end;
CsCmdActorAction* entry;
f32 progress;
- start.x = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.x;
- start.z = globalCtx->csCtx.actorActions[actorActionIndex]->startPos.z;
- end.x = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.x;
- end.z = globalCtx->csCtx.actorActions[actorActionIndex]->endPos.z;
+ start.x = play->csCtx.actorActions[actorActionIndex]->startPos.x;
+ start.z = play->csCtx.actorActions[actorActionIndex]->startPos.z;
+ end.x = play->csCtx.actorActions[actorActionIndex]->endPos.x;
+ end.z = play->csCtx.actorActions[actorActionIndex]->endPos.z;
- entry = globalCtx->csCtx.actorActions[actorActionIndex];
- progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, globalCtx->csCtx.frames);
+ entry = play->csCtx.actorActions[actorActionIndex];
+ progress = Environment_LerpWeight(entry->endFrame, entry->startFrame, play->csCtx.frames);
actor->world.pos.x = start.x + (end.x - start.x) * progress;
actor->world.pos.z = start.z + (end.z - start.z) * progress;
@@ -1641,7 +1642,7 @@ void Cutscene_ActorTranslateXZAndYawSmooth(Actor* actor, GlobalContext* globalCt
actor->shape.rot.y = actor->world.rot.y;
}
-s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) {
+s32 Cutscene_GetSceneSetupIndex(PlayState* play) {
s32 sceneSetupIndex = 0;
if (gSaveContext.sceneSetupIndex > 0) {
@@ -1650,7 +1651,7 @@ s32 Cutscene_GetSceneSetupIndex(GlobalContext* globalCtx) {
return sceneSetupIndex;
}
-s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) {
+s32 Cutscene_GetActorActionIndex(PlayState* play, u16 actorActionCmd) {
s32 i;
s32 index = -1;
@@ -1663,20 +1664,20 @@ s32 Cutscene_GetActorActionIndex(GlobalContext* globalCtx, u16 actorActionCmd) {
return index;
}
-s32 Cutscene_CheckActorAction(GlobalContext* globalCtx, u16 actorActionCmd) {
- if (globalCtx->csCtx.state != CS_STATE_0) {
- s32 index = Cutscene_GetActorActionIndex(globalCtx, actorActionCmd);
+s32 Cutscene_CheckActorAction(PlayState* play, u16 actorActionCmd) {
+ if (play->csCtx.state != CS_STATE_0) {
+ s32 index = Cutscene_GetActorActionIndex(play, actorActionCmd);
if (index != -1) {
- return globalCtx->csCtx.actorActions[index] != NULL;
+ return play->csCtx.actorActions[index] != NULL;
}
}
return false;
}
-u8 Cutscene_IsPlaying(GlobalContext* globalCtx) {
- return (gSaveContext.cutsceneTrigger != 0) || (globalCtx->csCtx.state != CS_STATE_0);
+u8 Cutscene_IsPlaying(PlayState* play) {
+ return (gSaveContext.cutsceneTrigger != 0) || (play->csCtx.state != CS_STATE_0);
}
/* End of actor utilities section */
diff --git a/src/code/z_eff_footmark.c b/src/code/z_eff_footmark.c
index f959867fe..2205d2d95 100644
--- a/src/code/z_eff_footmark.c
+++ b/src/code/z_eff_footmark.c
@@ -1,10 +1,10 @@
#include "global.h"
-void EffFootmark_Init(GlobalContext* globalCtx) {
+void EffFootmark_Init(PlayState* play) {
EffFootmark* footmark;
s32 i;
- for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
+ for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
footmark->actor = NULL;
footmark->location.x = 0;
footmark->location.y = 0;
@@ -16,15 +16,15 @@ void EffFootmark_Init(GlobalContext* globalCtx) {
}
}
-void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size,
- u8 red, u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) {
+void EffFootmark_Add(PlayState* play, MtxF* displayMatrix, Actor* actor, u8 id, Vec3f* location, u16 size, u8 red,
+ u8 green, u8 blue, u16 alpha, u16 alphaChange, u16 fadeoutDelay) {
s32 i;
EffFootmark* footmark;
EffFootmark* destination = NULL;
EffFootmark* oldest = NULL;
s32 isNew = 1;
- for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
+ for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (((actor == footmark->actor) && (footmark->id == id)) && ((footmark->flags & 1) == 0)) {
if (fabsf((footmark->location).x - location->x) <= 1) {
if (fabsf((footmark->location).z - location->z) <= 1) {
@@ -70,11 +70,11 @@ void EffFootmark_Add(GlobalContext* globalCtx, MtxF* displayMatrix, Actor* actor
}
}
-void EffFootmark_Update(GlobalContext* globalCtx) {
+void EffFootmark_Update(PlayState* play) {
EffFootmark* footmark;
s32 i;
- for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
+ for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
if ((footmark->flags & 1) == 1) {
if (footmark->age < 0xFFFFu) { // TODO replace with MAX_U16 or something
@@ -95,21 +95,21 @@ void EffFootmark_Update(GlobalContext* globalCtx) {
}
}
-void EffFootmark_Draw(GlobalContext* globalCtx) {
+void EffFootmark_Draw(PlayState* play) {
EffFootmark* footmark;
s32 i;
- GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
+ GraphicsContext* gfxCtx = play->state.gfxCtx;
- func_8012C448(globalCtx->state.gfxCtx);
+ func_8012C448(play->state.gfxCtx);
gSPDisplayList(gfxCtx->polyXlu.p++, D_801BC240);
- for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
+ for (footmark = play->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
Matrix_Put(&footmark->displayMatrix);
Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY);
- gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD);
+ gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD);
gDPSetPrimColor(gfxCtx->polyXlu.p++, 0, 0, footmark->red, footmark->green, footmark->blue,
footmark->alpha >> 8);
diff --git a/src/code/z_eff_shield_particle.c b/src/code/z_eff_shield_particle.c
index e3a051fb4..90833947b 100644
--- a/src/code/z_eff_shield_particle.c
+++ b/src/code/z_eff_shield_particle.c
@@ -43,7 +43,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;
}
@@ -54,10 +54,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 697c55398..fd92516df 100644
--- a/src/code/z_eff_spark.c
+++ b/src/code/z_eff_spark.c
@@ -122,7 +122,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;
@@ -199,7 +199,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 bd93f5eed..b7c6af97e 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_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
+void func_800AE2A0(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
f32 absCos;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
displayListHead = POLY_OPA_DISP;
cos = Math_CosS((0x8000 / arg3) * arg2);
@@ -23,14 +23,14 @@ void func_800AE2A0(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_OPA_DISP = displayListHead;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
+void func_800AE434(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
Gfx* displayListHead;
f32 cos;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
cos = Math_CosS((0x4000 / arg3) * arg2);
displayListHead = POLY_OPA_DISP;
@@ -41,26 +41,26 @@ void func_800AE434(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_OPA_DISP = displayListHead;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800AE5A0(GlobalContext* globalCtx) {
+void func_800AE5A0(PlayState* play) {
s32 pad;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gDPPipeSync(POLY_OPA_DISP++);
- POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP);
+ POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
+void func_800AE5E4(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
f32 absCos;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
displayListHead = POLY_XLU_DISP;
cos = Math_CosS((0x8000 / arg3) * arg2);
@@ -78,14 +78,14 @@ void func_800AE5E4(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_XLU_DISP = displayListHead;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 arg3) {
+void func_800AE778(PlayState* play, Color_RGBA8* color, s16 arg2, s16 arg3) {
f32 cos;
Gfx* displayListHead;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
displayListHead = POLY_XLU_DISP;
cos = Math_CosS((0x4000 / arg3) * arg2);
@@ -96,16 +96,16 @@ void func_800AE778(GlobalContext* globalCtx, Color_RGBA8* color, s16 arg2, s16 a
POLY_XLU_DISP = displayListHead;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void func_800AE8EC(GlobalContext* globalCtx) {
+void func_800AE8EC(PlayState* play) {
s32 pad;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gDPPipeSync(POLY_XLU_DISP++);
- POLY_XLU_DISP = func_801660B8(globalCtx, POLY_XLU_DISP);
+ POLY_XLU_DISP = func_801660B8(play, POLY_XLU_DISP);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
diff --git a/src/code/z_effect.c b/src/code/z_effect.c
index 4c446b650..b4a76380e 100644
--- a/src/code/z_effect.c
+++ b/src/code/z_effect.c
@@ -40,8 +40,8 @@ EffectInfo sEffectInfoTable[] = {
},
};
-GlobalContext* Effect_GetGlobalCtx(void) {
- return sEffectContext.globalCtx;
+PlayState* Effect_GetPlayState(void) {
+ return sEffectContext.play;
}
void* Effect_GetByIndex(s32 index) {
@@ -93,7 +93,7 @@ void Effect_InitStatus(EffectStatus* status) {
status->unk2 = 0;
}
-void Effect_Init(GlobalContext* globalCtx) {
+void Effect_Init(PlayState* play) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
@@ -113,10 +113,10 @@ void Effect_Init(GlobalContext* globalCtx) {
Effect_InitStatus(&sEffectContext.tireMarks[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) {
u32 slotFound;
s32 i;
void* effect = NULL;
@@ -124,7 +124,7 @@ void Effect_Add(GlobalContext* globalCtx, s32* pIndex, s32 type, u8 arg3, u8 arg
*pIndex = TOTAL_EFFECT_COUNT;
- if (FrameAdvance_IsEnabled(&globalCtx->state) != true) {
+ if (FrameAdvance_IsEnabled(&play->state) != true) {
slotFound = false;
switch (type) {
case EFFECT_SPARK:
@@ -217,14 +217,14 @@ 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 (1) {} // necessary to match
if (sEffectContext.sparks[i].status.active) {
if (sEffectInfoTable[EFFECT_SPARK].update(&sEffectContext.sparks[i].effect) == 1) {
- Effect_Destroy(globalCtx, i);
+ Effect_Destroy(play, i);
}
}
}
@@ -233,7 +233,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) {
if (1) {} // necessary to match
if (sEffectContext.blures[i].status.active) {
if (sEffectInfoTable[EFFECT_BLURE1].update(&sEffectContext.blures[i].effect) == 1) {
- Effect_Destroy(globalCtx, i + SPARK_COUNT);
+ Effect_Destroy(play, i + SPARK_COUNT);
}
}
}
@@ -242,7 +242,7 @@ void Effect_UpdateAll(GlobalContext* globalCtx) {
if (1) {} // necessary to match
if (sEffectContext.shieldParticles[i].status.active) {
if (sEffectInfoTable[EFFECT_SHIELD_PARTICLE].update(&sEffectContext.shieldParticles[i].effect) == 1) {
- Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT);
+ Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT);
}
}
}
@@ -251,13 +251,13 @@ void Effect_UpdateAll(GlobalContext* globalCtx) {
if (1) {} // necessary to match
if (sEffectContext.tireMarks[i].status.active) {
if (sEffectInfoTable[EFFECT_TIRE_MARK].update(&sEffectContext.tireMarks[i].effect) == 1) {
- Effect_Destroy(globalCtx, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT);
+ Effect_Destroy(play, i + SPARK_COUNT + BLURE_COUNT + SHIELD_PARTICLE_COUNT);
}
}
}
}
-void Effect_Destroy(GlobalContext* globalCtx, s32 index) {
+void Effect_Destroy(PlayState* play, s32 index) {
if (index == TOTAL_EFFECT_COUNT) {
return;
}
@@ -290,7 +290,7 @@ void Effect_Destroy(GlobalContext* globalCtx, s32 index) {
}
}
-void Effect_DestroyAll(GlobalContext* globalCtx) {
+void Effect_DestroyAll(PlayState* play) {
s32 i;
for (i = 0; i < SPARK_COUNT; i++) {
diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c
index 56eab9e8a..422bb401e 100644
--- a/src/code/z_effect_soft_sprite.c
+++ b/src/code/z_effect_soft_sprite.c
@@ -3,12 +3,12 @@
EffectSsInfo sEffectSsInfo = { NULL, 0, 0 };
-void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) {
+void EffectSS_Init(PlayState* play, s32 numEntries) {
u32 i;
EffectSs* effectsSs;
EffectSsOverlay* overlay;
- sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&globalCtx->state.heap, numEntries * sizeof(EffectSs));
+ sEffectSsInfo.data_table = (EffectSs*)THA_AllocEndAlign16(&play->state.heap, numEntries * sizeof(EffectSs));
sEffectSsInfo.searchIndex = 0;
sEffectSsInfo.size = numEntries;
@@ -24,7 +24,7 @@ void EffectSS_Init(GlobalContext* globalCtx, s32 numEntries) {
}
}
-void EffectSS_Clear(GlobalContext* globalCtx) {
+void EffectSS_Clear(PlayState* play) {
u32 i;
EffectSs* effectsSs;
EffectSsOverlay* overlay;
@@ -150,10 +150,10 @@ s32 EffectSS_FindFreeSpace(s32 priority, s32* tableEntry) {
return false;
}
-void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
+void EffectSS_Copy(PlayState* play, EffectSs* effectsSs) {
s32 index;
- if (FrameAdvance_IsEnabled(&globalCtx->state) != true) {
+ if (FrameAdvance_IsEnabled(&play->state) != true) {
if (EffectSS_FindFreeSpace(effectsSs->priority, &index) == 0) {
sEffectSsInfo.searchIndex = index + 1;
sEffectSsInfo.data_table[index] = *effectsSs;
@@ -161,7 +161,7 @@ void EffectSS_Copy(GlobalContext* globalCtx, EffectSs* effectsSs) {
}
}
-void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* initData) {
+void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initData) {
s32 index;
u32 overlaySize;
EffectSsOverlay* entry = &gParticleOverlayTable[type];
@@ -199,13 +199,13 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init
sEffectSsInfo.data_table[index].type = type;
sEffectSsInfo.data_table[index].priority = priority;
- if (initInfo->init(globalCtx, index, &sEffectSsInfo.data_table[index], initData) == 0) {
+ if (initInfo->init(play, index, &sEffectSsInfo.data_table[index], initData) == 0) {
EffectSS_ResetEntry(&sEffectSsInfo.data_table[index]);
}
}
}
-void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
+void EffectSS_UpdateParticle(PlayState* play, s32 index) {
EffectSs* particle = &sEffectSsInfo.data_table[index];
if (particle->update != NULL) {
@@ -217,11 +217,11 @@ void EffectSS_UpdateParticle(GlobalContext* globalCtx, s32 index) {
particle->pos.y += particle->velocity.y;
particle->pos.z += particle->velocity.z;
- particle->update(globalCtx, index, particle);
+ particle->update(play, index, particle);
}
}
-void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) {
+void EffectSS_UpdateAllParticles(PlayState* play) {
s32 i;
for (i = 0; i < sEffectSsInfo.size; i++) {
@@ -234,25 +234,25 @@ void EffectSS_UpdateAllParticles(GlobalContext* globalCtx) {
}
if (sEffectSsInfo.data_table[i].life > -1) {
- EffectSS_UpdateParticle(globalCtx, i);
+ EffectSS_UpdateParticle(play, i);
}
}
}
-void EffectSS_DrawParticle(GlobalContext* globalCtx, s32 index) {
+void EffectSS_DrawParticle(PlayState* play, s32 index) {
EffectSs* entry = &sEffectSsInfo.data_table[index];
if (entry->draw != NULL) {
- entry->draw(globalCtx, index, entry);
+ entry->draw(play, index, entry);
}
}
-void EffectSS_DrawAllParticles(GlobalContext* globalCtx) {
- Lights* lights = LightContext_NewLights(&globalCtx->lightCtx, globalCtx->state.gfxCtx);
+void EffectSS_DrawAllParticles(PlayState* play) {
+ Lights* lights = LightContext_NewLights(&play->lightCtx, play->state.gfxCtx);
s32 i;
- Lights_BindAll(lights, globalCtx->lightCtx.listHead, NULL, globalCtx);
- Lights_Draw(lights, globalCtx->state.gfxCtx);
+ Lights_BindAll(lights, play->lightCtx.listHead, NULL, play);
+ Lights_Draw(lights, play->state.gfxCtx);
for (i = 0; i < sEffectSsInfo.size; i++) {
if (sEffectSsInfo.data_table[i].life > -1) {
@@ -264,7 +264,7 @@ void EffectSS_DrawAllParticles(GlobalContext* globalCtx) {
(sEffectSsInfo.data_table[i].pos.z < BGCHECK_Y_MIN)) {
EffectSS_Delete(&sEffectSsInfo.data_table[i]);
} else {
- EffectSS_DrawParticle(globalCtx, i);
+ EffectSS_DrawParticle(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 1e9b25573..c7b073540 100644
--- a/src/code/z_effect_soft_sprite_old_init.c
+++ b/src/code/z_effect_soft_sprite_old_init.c
@@ -32,8 +32,8 @@
#include "overlays/effects/ovl_Effect_Ss_Stick/z_eff_ss_stick.h"
#include "overlays/effects/ovl_Effect_Ss_Stone1/z_eff_ss_stone1.h"
-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;
@@ -41,14 +41,14 @@ void EffectSs_DrawGEffect(GlobalContext* globalCtx, EffectSs* this, void* textur
MtxF mfTrans11DA0;
s32 pad1;
Mtx* mtx;
- void* object = globalCtx->objectCtx.status[this->rgObjBankIdx].segment;
+ void* object = play->objectCtx.status[this->rgObjBankIdx].segment;
OPEN_DISPS(gfxCtx);
scale = this->rgScale * 0.0025f;
SkinMatrix_SetTranslate(&mfTrans, this->pos.x, this->pos.y, this->pos.z);
SkinMatrix_SetScale(&mfScale, scale, scale, scale);
- SkinMatrix_MtxFMtxFMult(&mfTrans, &globalCtx->billboardMtxF, &mfTrans11DA0);
+ SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0);
SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult);
gSegments[0x06] = PHYSICAL_TO_VIRTUAL(object);
gSPSegment(POLY_XLU_DISP++, 0x06, object);
@@ -70,7 +70,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;
@@ -86,80 +86,78 @@ 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_800B0DE0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B0DE0(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_800B0E48(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B0E48(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_800B0EB0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B0EB0(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_800B0F18(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B0F18(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_800B0F80(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B0F80(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);
}
-void func_800B0FE8(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B0FE8(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);
}
-void func_800B1054(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B1054(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_800B10C0(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- EffectSsDust_Spawn(globalCtx, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
+void func_800B10C0(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
+ EffectSsDust_Spawn(play, 4, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
}
-void func_800B1130(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
- EffectSsDust_Spawn(globalCtx, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
+void func_800B1130(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel) {
+ EffectSsDust_Spawn(play, 5, pos, velocity, accel, &sDustBrownPrim, &sDustBrownEnv, 100, 5, 10, 0);
}
-void func_800B11A0(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_800B11A0(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_800B1210(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_800B1210(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_800B1280(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_800B1280(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_800B12F0(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_800B12F0(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);
}
-void func_800B1360(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B1360(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor) {
- func_800B0DE0(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5);
+ func_800B0DE0(play, pos, velocity, accel, primColor, envColor, 100, 5);
}
-void func_800B139C(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
+void func_800B139C(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* primColor,
Color_RGBA8* envColor) {
- func_800B0E48(globalCtx, pos, velocity, accel, primColor, envColor, 100, 5);
+ func_800B0E48(play, pos, velocity, accel, primColor, envColor, 100, 5);
}
void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity, Vec3f* accel) {
@@ -182,7 +180,7 @@ void func_800B13D8(Vec3f* srcPos, f32 randScale, Vec3f* newPos, Vec3f* velocity,
accel->z = 0.0f;
}
-void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
+void func_800B14D4(PlayState* play, f32 randScale, Vec3f* srcPos) {
s32 i;
Vec3f pos;
Vec3f velocity;
@@ -190,11 +188,11 @@ void func_800B14D4(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
for (i = 0; i < 20; i++) {
func_800B13D8(srcPos, randScale, &pos, &velocity, &accel);
- func_800B1280(globalCtx, &pos, &velocity, &accel, 100, 30, 7);
+ func_800B1280(play, &pos, &velocity, &accel, 100, 30, 7);
}
}
-void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
+void func_800B1598(PlayState* play, f32 randScale, Vec3f* srcPos) {
s32 i;
Vec3f pos;
Vec3f velocity;
@@ -202,24 +200,24 @@ void func_800B1598(GlobalContext* globalCtx, f32 randScale, Vec3f* srcPos) {
for (i = 0; i < 20; i++) {
func_800B13D8(srcPos, randScale, &pos, &velocity, &accel);
- func_800B12F0(globalCtx, &pos, &velocity, &accel, 100, 30, 7);
+ func_800B12F0(play, &pos, &velocity, &accel, 100, 30, 7);
}
}
-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);
@@ -236,11 +234,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);
@@ -255,10 +253,10 @@ 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);
}
-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);
@@ -268,11 +266,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);
@@ -282,12 +279,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) {
EffectSsBlastInitParams initParams;
@@ -301,32 +298,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;
@@ -340,11 +337,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;
@@ -358,19 +355,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;
@@ -384,16 +381,16 @@ 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, s16 arg8, s32 life) {
EffectSsDFireInitParams initParams;
@@ -407,12 +404,12 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.unk_2C = arg8;
initParams.life = life;
- EffectSs_Spawn(globalCtx, EFFECT_SS_D_FIRE, 128, &initParams);
+ EffectSs_Spawn(play, EFFECT_SS_D_FIRE, 128, &initParams);
}
// 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;
@@ -422,12 +419,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);
@@ -435,13 +432,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);
@@ -456,23 +453,23 @@ void EffectSsGSplash_Spawn(GlobalContext* globalCtx, Vec3f* pos, Color_RGBA8* pr
initParams.customColor = 0;
}
- EffectSs_Spawn(globalCtx, EFFECT_SS_G_SPLASH, 128, &initParams);
+ EffectSs_Spawn(play, EFFECT_SS_G_SPLASH, 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);
@@ -483,13 +480,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);
@@ -501,10 +498,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;
@@ -518,7 +515,7 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec
initParams.randXZ = randXZ;
initParams.customColor = 1;
- EffectSs_Spawn(globalCtx, EFFECT_SS_DT_BUBBLE, 128, &initParams);
+ EffectSs_Spawn(play, EFFECT_SS_DT_BUBBLE, 128, &initParams);
}
// EffectSsHahen Spawn Functions
@@ -532,8 +529,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);
@@ -545,7 +542,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);
}
/**
@@ -557,8 +554,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;
@@ -571,15 +568,15 @@ 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);
}
}
-void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) {
+void func_800B2364(PlayState* play, Vec3f* pos, Gfx* dList) {
Vec3f accel = { 0.0f, -2.0f, 0.0f };
- EffectSsHahen_Spawn(globalCtx, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList);
+ EffectSsHahen_Spawn(play, pos, &gZeroVec3f, &accel, 1, 5, 1, 10, dList);
}
// EffectSsStick Spawn Functions
@@ -588,19 +585,19 @@ void func_800B2364(GlobalContext* globalCtx, Vec3f* pos, Gfx* dList) {
* 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);
@@ -610,48 +607,48 @@ 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 zeroVec = { 0.0f, 0.0f, 0.0f };
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);
}
}
// EffectSsStone1 Spawn Functions
-void EffectSsStone1_Spawn(GlobalContext* globalCtx, Vec3f* pos, s32 reg0) {
+void EffectSsStone1_Spawn(PlayState* play, Vec3f* pos, s32 reg0) {
EffectSsStone1InitParams initParams;
initParams.pos = *pos;
initParams.reg0 = reg0;
- 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
@@ -664,7 +661,7 @@ void EffectSsHitMark_SpawnCustomScale(GlobalContext* globalCtx, s32 type, s16 sc
* 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;
@@ -673,12 +670,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);
@@ -687,12 +684,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, s16 drawFlag) {
EffectSsSolderSrchBallInitParams initParams;
@@ -703,14 +700,14 @@ void EffectSsSolderSrchBall_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* v
initParams.linkDetected = linkDetected;
initParams.drawFlag = drawFlag;
- 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);
@@ -729,12 +726,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);
@@ -742,10 +739,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 },
@@ -776,15 +773,15 @@ 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, Color_RGBA8* prim,
- Color_RGBA8* env, f32 scale) {
+void EffectSsEnIce_SpawnFlyingVec3f(PlayState* play, Actor* actor, Vec3f* pos, Color_RGBA8* prim, Color_RGBA8* env,
+ f32 scale) {
EffectSsEnIceInitParams initParams;
initParams.actor = actor;
@@ -798,25 +795,25 @@ void EffectSsEnIce_SpawnFlyingVec3f(GlobalContext* globalCtx, Actor* actor, Vec3
Actor_PlaySfxAtPos(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 func_800B2B44(GlobalContext* globalCtx, Actor* actor, Vec3f* pos, f32 scale) {
+void func_800B2B44(PlayState* play, Actor* actor, Vec3f* pos, f32 scale) {
static Color_RGBA8 primColor = { 150, 150, 150, 250 };
static Color_RGBA8 envColor = { 235, 245, 255, 255 };
- EffectSsEnIce_SpawnFlyingVec3f(globalCtx, actor, pos, &primColor, &envColor, scale);
+ EffectSsEnIce_SpawnFlyingVec3f(play, actor, pos, &primColor, &envColor, scale);
}
-void func_800B2B7C(GlobalContext* globalCtx, Actor* actor, Vec3s* arg2, f32 scale) {
+void func_800B2B7C(PlayState* play, Actor* actor, Vec3s* arg2, f32 scale) {
Vec3f dest;
Math_Vec3s_ToVec3f(&dest, arg2);
- func_800B2B44(globalCtx, actor, &dest, scale);
+ func_800B2B44(play, actor, &dest, scale);
}
-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);
@@ -828,12 +825,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;
@@ -848,10 +845,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 };
@@ -863,20 +860,19 @@ 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
-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;
@@ -891,10 +887,10 @@ void EffectSsEnFire_SpawnVec3f(GlobalContext* globalCtx, Actor* actor, Vec3f* po
Actor_PlaySfxAtPos(actor, NA_SE_EV_FLAME_IGNITION);
}
- EffectSs_Spawn(globalCtx, EFFECT_SS_EN_FIRE, 128, &initParams);
+ EffectSs_Spawn(play, EFFECT_SS_EN_FIRE, 128, &initParams);
}
-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;
@@ -911,12 +907,12 @@ void EffectSsEnFire_SpawnVec3s(GlobalContext* globalCtx, Actor* actor, Vec3s* po
Actor_PlaySfxAtPos(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);
@@ -925,12 +921,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);
}
// EffectSsDeadDb Spawn Functions
-void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
+void EffectSsDeadDb_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) {
EffectSsDeadDbInitParams initParams;
@@ -948,10 +944,10 @@ void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.envColor.b = env->b;
initParams.unk_30 = unk;
- EffectSs_Spawn(globalCtx, EFFECT_SS_DEAD_DB, 120, &initParams);
+ EffectSs_Spawn(play, EFFECT_SS_DEAD_DB, 120, &initParams);
}
-void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
+void func_800B3030(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s32 colorIndex) {
static Color_RGBA8 primColor = { 255, 255, 255, 255 };
static Color_RGBA8 envColors[] = {
@@ -961,12 +957,12 @@ void func_800B3030(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f*
{ 150, 150, 150, 255 },
};
- EffectSsDeadDb_Spawn(globalCtx, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9);
+ EffectSsDeadDb_Spawn(play, pos, velocity, accel, &primColor, &envColors[colorIndex], scale, scaleStep, 9);
}
// EffectSsDeadDd Spawn Functions
-void EffectSsDeadDd_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
+void EffectSsDeadDd_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
Color_RGBA8* env, s16 scale, s16 scaleStep, s16 alphaStep, s32 life) {
EffectSsDeadDdInitParams initParams;
@@ -986,12 +982,12 @@ 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);
}
// 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;
@@ -1002,16 +998,16 @@ 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 func_800B31BC(GlobalContext* globalCtx, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) {
- EffectSsDeadDs_Spawn(globalCtx, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life);
+void func_800B31BC(PlayState* play, Vec3f* pos, s16 scale, s16 scaleStep, s16 alpha, s32 life) {
+ EffectSsDeadDs_Spawn(play, pos, &gZeroVec3f, &gZeroVec3f, scale, scaleStep, alpha, life);
}
// EffectSsIceSmoke Spawn Functions
-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);
@@ -1019,12 +1015,12 @@ 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);
}
// EffectSsIceBlock Spawn Functions
-void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) {
+void EffectSsIceBlock_Spawn(PlayState* play, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale) {
EffectEnIceBlockInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@@ -1032,5 +1028,5 @@ void EffectSsIceBlock_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocit
Math_Vec3f_Copy(&initParams.accel, accel);
initParams.scale = scale;
- EffectSs_Spawn(globalCtx, EFFECT_EN_ICE_BLOCK, 128, &initParams);
+ EffectSs_Spawn(play, EFFECT_EN_ICE_BLOCK, 128, &initParams);
}
diff --git a/src/code/z_elf_message.c b/src/code/z_elf_message.c
index cd2fa96b6..57e84e86b 100644
--- a/src/code/z_elf_message.c
+++ b/src/code/z_elf_message.c
@@ -1,6 +1,6 @@
#include "global.h"
-u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) {
+u16 ElfMessage_GetFirstCycleHint(PlayState* play) {
if (INV_CONTENT(ITEM_OCARINA) == ITEM_OCARINA) {
return 0;
}
@@ -20,7 +20,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) {
if (gSaveContext.save.weekEventReg[9] & 1) {
return 0x21E;
}
- if (globalCtx->sceneNum == SCENE_YOUSEI_IZUMI) {
+ if (play->sceneNum == SCENE_YOUSEI_IZUMI) {
return 0;
}
return 0x21D;
@@ -29,7 +29,7 @@ u16 ElfMessage_GetFirstCycleHint(GlobalContext* globalCtx) {
return 0x21F;
}
if (INV_CONTENT(ITEM_DEED_LAND) == ITEM_DEED_LAND) {
- if (globalCtx->sceneNum != SCENE_OKUJOU) {
+ if (play->sceneNum != SCENE_OKUJOU) {
return 0x244;
}
return 0;
diff --git a/src/code/z_en_a_keep.c b/src/code/z_en_a_keep.c
index 1d083b2c7..267da4e40 100644
--- a/src/code/z_en_a_keep.c
+++ b/src/code/z_en_a_keep.c
@@ -2,56 +2,56 @@
#define THIS ((EnAObj*)thisx)
-void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx);
-void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx);
+void EnAObj_Update1(EnAObj* this, PlayState* play);
+void EnAObj_Update2(EnAObj* this, PlayState* play);
-void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
+void EnAObj_Init(Actor* thisx, PlayState* play) {
EnAObj* this = THIS;
this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300;
this->actor.params = (this->actor.params & 0xFF) - 9;
Actor_ProcessInitChain(&this->actor, &enAObjInitVar);
ActorShape_Init(&this->actor.shape, 0, ActorShadow_DrawCircle, 12);
- Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit);
+ Collider_InitAndSetCylinder(play, &this->collision, &this->actor, &enAObjCylinderInit);
Collider_UpdateCylinder(&this->actor, &this->collision);
this->actor.colChkInfo.mass = MASS_IMMOVABLE;
this->actionFunc = EnAObj_Update1;
}
-void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) {
+void EnAObj_Destroy(Actor* thisx, PlayState* play) {
EnAObj* this = THIS;
- Collider_DestroyCylinder(globalCtx, &this->collision);
+ Collider_DestroyCylinder(play, &this->collision);
}
-void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) {
+void EnAObj_Update1(EnAObj* this, PlayState* play) {
s32 yawDiff;
- if (Actor_ProcessTalkRequest(&this->actor, &globalCtx->state)) {
+ if (Actor_ProcessTalkRequest(&this->actor, &play->state)) {
this->actionFunc = EnAObj_Update2;
} else {
yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y));
if ((yawDiff < 0x2800) || ((this->actor.params == 1) && (yawDiff > 0x5800))) {
- func_800B863C(&this->actor, globalCtx);
+ func_800B863C(&this->actor, play);
}
}
}
-void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) {
- if (Actor_TextboxIsClosing(&this->actor, globalCtx)) {
+void EnAObj_Update2(EnAObj* this, PlayState* play) {
+ if (Actor_TextboxIsClosing(&this->actor, play)) {
this->actionFunc = EnAObj_Update1;
}
}
-void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) {
+void EnAObj_Update(Actor* thisx, PlayState* play) {
EnAObj* this = THIS;
- this->actionFunc(this, globalCtx);
+ this->actionFunc(this, play);
Actor_SetFocus(&this->actor, 45.0f);
- CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base);
+ CollisionCheck_SetOC(play, &play->colChkCtx, &this->collision.base);
}
-void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) {
- Gfx_DrawDListOpa(globalCtx, enAObjDisplayLists[thisx->params]);
+void EnAObj_Draw(Actor* thisx, PlayState* play) {
+ Gfx_DrawDListOpa(play, enAObjDisplayLists[thisx->params]);
}
diff --git a/src/code/z_en_hy_code.c b/src/code/z_en_hy_code.c
index 28c177068..6549ed9e1 100644
--- a/src/code/z_en_hy_code.c
+++ b/src/code/z_en_hy_code.c
@@ -58,7 +58,7 @@ s32 EnHy_ChangeAnim(SkelAnime* skelAnime, s16 animIndex) {
return isChanged;
}
-EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
+EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) {
EnDoor* nearestDoor = NULL;
Actor* doorIter = NULL;
f32 dist;
@@ -67,7 +67,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
f32 minDist = 0.0f;
do {
- doorIter = SubS_FindActor(globalCtx, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR);
+ doorIter = SubS_FindActor(play, doorIter, ACTORCAT_DOOR, ACTOR_EN_DOOR);
door = (EnDoor*)doorIter;
dist = Actor_DistanceBetweenActors(actor, &door->dyna.actor);
if (!isSetup || (dist < minDist)) {
@@ -83,16 +83,16 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, GlobalContext* globalCtx) {
return nearestDoor;
}
-void EnHy_ChangeObjectAndAnim(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) {
- gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->animObjIndex].segment);
+void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) {
+ gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment);
EnHy_ChangeAnim(&enHy->skelAnime, animIndex);
}
-s32 EnHy_UpdateSkelAnime(EnHy* enHy, GlobalContext* globalCtx) {
+s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) {
s32 isUpdated = false;
if (enHy->actor.draw != NULL) {
- gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->animObjIndex].segment);
+ gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->animObjIndex].segment);
SkelAnime_Update(&enHy->skelAnime);
isUpdated = true;
}
@@ -109,26 +109,26 @@ void EnHy_Blink(EnHy* enHy, s32 eyeTexMaxIndex) {
}
}
-s32 EnHy_Init(EnHy* enHy, GlobalContext* globalCtx, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) {
+s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg, s16 animIndex) {
s32 isInitialized = false;
- if ((SubS_IsObjectLoaded(enHy->animObjIndex, globalCtx) == true) &&
- (SubS_IsObjectLoaded(enHy->headObjIndex, globalCtx) == true) &&
- (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, globalCtx) == true) &&
- (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, globalCtx) == true)) {
+ if ((SubS_IsObjectLoaded(enHy->animObjIndex, play) == true) &&
+ (SubS_IsObjectLoaded(enHy->headObjIndex, play) == true) &&
+ (SubS_IsObjectLoaded(enHy->skelUpperObjIndex, play) == true) &&
+ (SubS_IsObjectLoaded(enHy->skelLowerObjIndex, play) == true)) {
enHy->actor.objBankIndex = enHy->skelLowerObjIndex;
isInitialized = true;
ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f);
- gSegments[6] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[enHy->actor.objBankIndex].segment);
- SkelAnime_InitFlex(globalCtx, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
+ gSegments[6] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[enHy->actor.objBankIndex].segment);
+ SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
ENHY_LIMB_MAX);
- EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex);
+ EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
}
return isInitialized;
}
-void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3, s16 arg4) {
+void func_800F0BB4(EnHy* enHy, PlayState* play, EnDoor* door, s16 arg3, s16 arg4) {
s32 pad;
s8 animIndex;
Vec3f offset;
@@ -137,26 +137,26 @@ void func_800F0BB4(EnHy* enHy, GlobalContext* globalCtx, EnDoor* door, s16 arg3,
Actor_OffsetOfPointInActorCoords(&door->dyna.actor, &offset, &enHy->actor.world.pos);
phi_f0 = (offset.z >= 0.0f) ? 1.0f : -1.0f;
animIndex = ((s8)phi_f0 < 0) ? 0 : 2;
- EnHy_ChangeObjectAndAnim(enHy, globalCtx, (animIndex == 0) ? arg3 : arg4);
+ EnHy_ChangeObjectAndAnim(enHy, play, (animIndex == 0) ? arg3 : arg4);
enHy->skelAnime.baseTransl = *enHy->skelAnime.jointTable;
enHy->skelAnime.prevTransl = *enHy->skelAnime.jointTable;
enHy->skelAnime.moveFlags |= 3;
- AnimationContext_SetMoveActor(globalCtx, &enHy->actor, &enHy->skelAnime, 1.0f);
+ AnimationContext_SetMoveActor(play, &enHy->actor, &enHy->skelAnime, 1.0f);
door->unk_1A1 = 1;
door->animIndex = animIndex;
}
-s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) {
+s32 func_800F0CE4(EnHy* enHy, PlayState* play, ActorFunc draw, s16 arg3, s16 arg4, f32 arg5) {
s32 ret = false;
s16 yaw;
EnDoor* door;
s32 pad;
if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) {
- door = EnHy_FindNearestDoor(&enHy->actor, globalCtx);
+ door = EnHy_FindNearestDoor(&enHy->actor, play);
if (door != NULL) {
ret = true;
- func_800F0BB4(enHy, globalCtx, door, arg3, arg4);
+ func_800F0BB4(enHy, play, door, arg3, arg4);
yaw = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos);
enHy->actor.world.pos.x += arg5 * Math_SinS(yaw);
enHy->actor.world.pos.z += arg5 * Math_CosS(yaw);
@@ -168,17 +168,17 @@ s32 func_800F0CE4(EnHy* enHy, GlobalContext* globalCtx, ActorFunc draw, s16 arg3
return ret;
}
-s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) {
+s32 func_800F0DD4(EnHy* enHy, PlayState* play, s16 arg2, s16 arg3) {
s32 ret = false;
s32 pad;
EnDoor* door;
enHy->curPoint = 0;
if (SubS_CopyPointFromPath(enHy->path, enHy->curPoint, &enHy->actor.world.pos)) {
- door = EnHy_FindNearestDoor(&enHy->actor, globalCtx);
+ door = EnHy_FindNearestDoor(&enHy->actor, play);
if (door != NULL) {
ret = true;
- func_800F0BB4(enHy, globalCtx, door, arg2, arg3);
+ func_800F0BB4(enHy, play, door, arg2, arg3);
enHy->actor.shape.rot.y = Math_Vec3f_Yaw(&enHy->actor.world.pos, &door->dyna.actor.world.pos);
enHy->actor.world.rot.y = enHy->actor.shape.rot.y;
enHy->actor.gravity = 0.0f;
@@ -188,16 +188,16 @@ s32 func_800F0DD4(EnHy* enHy, GlobalContext* globalCtx, s16 arg2, s16 arg3) {
return ret;
}
-s32 EnHy_SetPointFowards(EnHy* enHy, GlobalContext* globalCtx, f32 gravity, s16 animIndex) {
+s32 EnHy_SetPointFowards(EnHy* enHy, PlayState* play, f32 gravity, s16 animIndex) {
enHy->actor.gravity = gravity;
enHy->actor.flags |= ACTOR_FLAG_1;
- EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex);
+ EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
enHy->curPoint++;
return false;
}
-s32 EnHy_SetPointBackwards(EnHy* enHy, GlobalContext* globalCtx, s16 animIndex) {
- EnHy_ChangeObjectAndAnim(enHy, globalCtx, animIndex);
+s32 EnHy_SetPointBackwards(EnHy* enHy, PlayState* play, s16 animIndex) {
+ EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
enHy->curPoint--;
return false;
}
@@ -238,16 +238,16 @@ s32 EnHy_MoveBackwards(EnHy* enHy, f32 speedTarget) {
return reachedEnd;
}
-void EnHy_UpdateCollider(EnHy* enHy, GlobalContext* globalCtx) {
+void EnHy_UpdateCollider(EnHy* enHy, PlayState* play) {
enHy->collider.dim.pos.x = enHy->actor.world.pos.x;
enHy->collider.dim.pos.y = enHy->actor.world.pos.y;
enHy->collider.dim.pos.z = enHy->actor.world.pos.z;
- CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &enHy->collider.base);
- CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &enHy->collider.base);
+ CollisionCheck_SetAC(play, &play->colChkCtx, &enHy->collider.base);
+ CollisionCheck_SetOC(play, &play->colChkCtx, &enHy->collider.base);
}
-s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThreshold) {
+s32 EnHy_PlayWalkingSound(EnHy* enHy, PlayState* play, f32 distAboveThreshold) {
u8 wasLeftFootOnGround = enHy->isLeftFootOnGround;
u8 wasRightFootOnGround = enHy->isRightFootOnGround;
s32 waterSfxId;
@@ -262,15 +262,15 @@ s32 EnHy_PlayWalkingSound(EnHy* enHy, GlobalContext* globalCtx, f32 distAboveThr
}
sfxId = waterSfxId + SFX_FLAG;
} else {
- sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG;
+ sfxId = SurfaceType_GetSfx(&play->colCtx, enHy->actor.floorPoly, enHy->actor.floorBgId) + SFX_FLAG;
}
- enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->leftFootPos, distAboveThreshold);
+ enHy->isLeftFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->leftFootPos, distAboveThreshold);
if (enHy->isLeftFootOnGround && !wasLeftFootOnGround && isFootOnGround) {
Actor_PlaySfxAtPos(&enHy->actor, sfxId);
}
- enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(globalCtx, &enHy->rightFootPos, distAboveThreshold);
+ enHy->isRightFootOnGround = isFootOnGround = SubS_IsFloorAbove(play, &enHy->rightFootPos, distAboveThreshold);
if (enHy->isRightFootOnGround && !wasRightFootOnGround && isFootOnGround) {
Actor_PlaySfxAtPos(&enHy->actor, sfxId);
}
diff --git a/src/code/z_en_item00.c b/src/code/z_en_item00.c
index 7ba6134fb..0e783e76c 100644
--- a/src/code/z_en_item00.c
+++ b/src/code/z_en_item00.c
@@ -6,16 +6,16 @@
#define THIS ((EnItem00*)thisx)
-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 EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx);
-void func_800A640C(EnItem00* this, GlobalContext* globalCtx);
-void func_800A6650(EnItem00* this, GlobalContext* globalCtx);
-void func_800A6780(EnItem00* this, GlobalContext* globalCtx);
-void func_800A6A40(EnItem00* this, GlobalContext* globalCtx);
+void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play);
+void func_800A640C(EnItem00* this, PlayState* play);
+void func_800A6650(EnItem00* this, PlayState* play);
+void func_800A6780(EnItem00* this, PlayState* play);
+void func_800A6A40(EnItem00* this, PlayState* play);
const ActorInit En_Item00_InitVars = {
ACTOR_EN_ITEM00,
@@ -53,8 +53,8 @@ static InitChainEntry sInitChain[] = {
ICHAIN_F32(targetArrowOffset, 2000, ICHAIN_STOP),
};
-void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOffset, f32* shadowScale) {
- Actor_SetObjectDependency(globalCtx, &this->actor);
+void EnItem00_SetObject(EnItem00* this, PlayState* play, f32* shadowOffset, f32* shadowScale) {
+ Actor_SetObjectDependency(play, &this->actor);
Actor_SetScale(&this->actor, 0.5f);
this->unk154 = 0.5f;
*shadowOffset = 0.0f;
@@ -62,7 +62,7 @@ void EnItem00_SetObject(EnItem00* this, GlobalContext* globalCtx, f32* shadowOff
this->actor.world.rot.x = 0x4000;
}
-void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
+void EnItem00_Init(Actor* thisx, PlayState* play) {
EnItem00* this = THIS;
s32 pad;
f32 shadowOffset = 980.0f;
@@ -74,7 +74,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
thisx->params &= 0xFF; // Has to be thisx to match
- if (Flags_GetCollectible(globalCtx, this->collectibleFlag)) {
+ if (Flags_GetCollectible(play, this->collectibleFlag)) {
if (this->actor.params == ITEM00_HEART_PIECE) {
sp30 = 0;
this->collectibleFlag = 0;
@@ -89,7 +89,7 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
}
Actor_ProcessInitChain(&this->actor, sInitChain);
- Collider_InitAndSetCylinder(globalCtx, &this->collider, &this->actor, &sCylinderInit);
+ Collider_InitAndSetCylinder(play, &this->collider, &this->actor, &sCylinderInit);
this->unk150 = 1;
@@ -164,16 +164,16 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
this->unk154 = 0.01f;
break;
case ITEM00_SHIELD_HERO:
- this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_SHIELD_2);
- EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
+ this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_SHIELD_2);
+ EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
case ITEM00_MAP:
- this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_MAP);
- EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
+ this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_MAP);
+ EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
case ITEM00_COMPASS:
- this->actor.objBankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_COMPASS);
- EnItem00_SetObject(this, globalCtx, &shadowOffset, &shadowScale);
+ this->actor.objBankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_COMPASS);
+ EnItem00_SetObject(this, play, &shadowOffset, &shadowScale);
break;
default:
break;
@@ -205,51 +205,51 @@ 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_HUGE:
- Item_Give(globalCtx, ITEM_RUPEE_HUGE);
+ Item_Give(play, ITEM_RUPEE_HUGE);
break;
case ITEM00_HEART:
- Item_Give(globalCtx, ITEM_HEART);
+ Item_Give(play, ITEM_HEART);
break;
case ITEM00_FLEXIBLE:
case ITEM00_BIG_FAIRY:
- func_80115908(globalCtx, 0x70);
+ func_80115908(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_10:
- Item_Give(globalCtx, ITEM_ARROWS_10);
+ Item_Give(play, ITEM_ARROWS_10);
break;
case ITEM00_ARROWS_30:
- Item_Give(globalCtx, ITEM_ARROWS_30);
+ Item_Give(play, ITEM_ARROWS_30);
break;
case ITEM00_ARROWS_40:
- Item_Give(globalCtx, ITEM_ARROWS_40);
+ Item_Give(play, ITEM_ARROWS_40);
break;
case ITEM00_ARROWS_50:
- Item_Give(globalCtx, ITEM_ARROWS_50);
+ Item_Give(play, ITEM_ARROWS_50);
break;
case ITEM00_MAGIC_LARGE:
- Item_Give(globalCtx, ITEM_MAGIC_LARGE);
+ Item_Give(play, ITEM_MAGIC_LARGE);
break;
case ITEM00_MAGIC_SMALL:
- Item_Give(globalCtx, ITEM_MAGIC_SMALL);
+ Item_Give(play, ITEM_MAGIC_SMALL);
break;
case ITEM00_SMALL_KEY:
- Item_Give(globalCtx, ITEM_KEY_SMALL);
+ Item_Give(play, ITEM_KEY_SMALL);
break;
case ITEM00_NUTS_1:
getItemId = GI_NUTS_1;
@@ -261,31 +261,31 @@ void EnItem00_Init(Actor* thisx, GlobalContext* globalCtx) {
break;
}
- if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, globalCtx) == 0)) {
- Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f);
+ if ((getItemId != GI_NONE) && (Actor_HasParent(&this->actor, play) == 0)) {
+ Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f);
}
this->actionFunc = func_800A6A40;
- this->actionFunc(this, globalCtx);
+ this->actionFunc(this, play);
}
-void EnItem00_Destroy(Actor* thisx, GlobalContext* globalCtx) {
+void EnItem00_Destroy(Actor* thisx, PlayState* play) {
EnItem00* this = THIS;
- Collider_DestroyCylinder(globalCtx, &this->collider);
+ Collider_DestroyCylinder(play, &this->collider);
}
-void EnItem00_WaitForHeartObject(EnItem00* this, GlobalContext* globalCtx) {
+void EnItem00_WaitForHeartObject(EnItem00* this, PlayState* play) {
s32 sp1C;
- sp1C = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS);
- if (Object_IsLoaded(&globalCtx->objectCtx, sp1C)) {
+ sp1C = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS);
+ if (Object_IsLoaded(&play->objectCtx, sp1C)) {
this->actor.objBankIndex = sp1C;
this->actionFunc = func_800A640C;
}
}
-void func_800A640C(EnItem00* this, GlobalContext* globalCtx) {
+void func_800A640C(EnItem00* this, PlayState* play) {
if ((this->actor.params <= ITEM00_RUPEE_RED) || ((this->actor.params == ITEM00_HEART) && (this->unk152 < 0)) ||
(this->actor.params == ITEM00_HEART_PIECE) || (this->actor.params == ITEM00_HEART_CONTAINER)) {
this->actor.shape.rot.y = this->actor.shape.rot.y + 960;
@@ -335,18 +335,18 @@ static Color_RGBA8 D_801ADF14 = { 255, 255, 255, 0 };
static Vec3f D_801ADF18 = { 0.0f, 0.1f, 0.0f };
static Vec3f D_801ADF24 = { 0.0f, 0.01f, 0.0f };
-void func_800A6650(EnItem00* this, GlobalContext* globalCtx) {
+void func_800A6650(EnItem00* this, PlayState* play) {
u32 pad;
Vec3f pos;
if (this->actor.params <= ITEM00_RUPEE_RED) {
this->actor.shape.rot.y = this->actor.shape.rot.y + 960;
}
- if ((globalCtx->gameplayFrames & 1) != 0) {
+ if ((play->gameplayFrames & 1) != 0) {
pos.x = this->actor.world.pos.x + randPlusMinusPoint5Scaled(10.0f);
pos.y = this->actor.world.pos.y + randPlusMinusPoint5Scaled(10.0f);
pos.z = this->actor.world.pos.z + randPlusMinusPoint5Scaled(10.0f);
- EffectSsKirakira_SpawnSmall(globalCtx, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
+ EffectSsKirakira_SpawnSmall(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
}
if ((this->actor.bgCheckFlags & 3) != 0) {
if (this->actor.velocity.y > -2.0f) {
@@ -359,7 +359,7 @@ void func_800A6650(EnItem00* this, GlobalContext* globalCtx) {
}
}
-void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
+void func_800A6780(EnItem00* this, PlayState* play) {
s32 pad;
Vec3f pos;
s32 var1;
@@ -399,11 +399,11 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
}
}
- if ((globalCtx->gameplayFrames & 1) == 0) {
+ if ((play->gameplayFrames & 1) == 0) {
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, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
+ EffectSsKirakira_SpawnSmall(play, &pos, &D_801ADF18, &D_801ADF24, &D_801ADF10, &D_801ADF14);
}
if (this->actor.bgCheckFlags & 0x0003) {
@@ -413,12 +413,12 @@ void func_800A6780(EnItem00* this, GlobalContext* globalCtx) {
}
}
-void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) {
- Player* player = GET_PLAYER(globalCtx);
+void func_800A6A40(EnItem00* this, PlayState* play) {
+ Player* player = GET_PLAYER(play);
if (this->unk14A != GI_NONE) {
- if (Actor_HasParent(&this->actor, globalCtx) == 0) {
- Actor_PickUp(&this->actor, globalCtx, this->unk14A, 50.0f, 80.0f);
+ if (Actor_HasParent(&this->actor, play) == 0) {
+ Actor_PickUp(&this->actor, play, this->unk14A, 50.0f, 80.0f);
this->unk152++;
} else {
this->unk14A = GI_NONE;
@@ -445,10 +445,10 @@ void func_800A6A40(EnItem00* this, GlobalContext* globalCtx) {
}
}
-void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
+void EnItem00_Update(Actor* thisx, PlayState* play) {
EnItem00* this = THIS;
s32 pad;
- Player* player = GET_PLAYER(globalCtx);
+ Player* player = GET_PLAYER(play);
s32 sp38 = player->stateFlags3 & 0x1000;
s32 getItemId = GI_NONE;
s32 params;
@@ -461,7 +461,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->unk14E = this->unk152;
}
- this->actionFunc(this, globalCtx);
+ this->actionFunc(this, play);
Math_SmoothStepToF(&this->actor.scale.x, this->unk154, 0.1f, this->unk154 * 0.1f, 0.0f);
this->actor.scale.z = this->actor.scale.x;
@@ -469,7 +469,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if (this->actor.gravity != 0.0f) {
Actor_MoveWithGravity(&this->actor);
- Actor_UpdateBgCheckInfo(globalCtx, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D);
+ Actor_UpdateBgCheckInfo(play, &this->actor, 20.0f, 15.0f, 15.0f, 0x1D);
if (this->actor.floorHeight <= BGCHECK_Y_MIN) {
Actor_MarkForDeath(&this->actor);
@@ -478,7 +478,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);
params = this->actor.params;
if ((params == ITEM00_SHIELD_HERO) || (params == ITEM00_MAP) || (params == ITEM00_COMPASS)) {
@@ -493,35 +493,35 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
(this->actor.playerHeightRel <= 100.0f)) &&
!((sp38 == 0) && (this->actor.xzDistToPlayer <= 30.0f) && (this->actor.playerHeightRel >= -50.0f) &&
(this->actor.playerHeightRel <= 50.0f))) {
- if (!Actor_HasParent(&this->actor, globalCtx)) {
+ if (!Actor_HasParent(&this->actor, play)) {
return;
}
}
- if (globalCtx->gameOverCtx.state != 0) {
+ if (play->gameOverCtx.state != 0) {
return;
}
switch (this->actor.params) {
case ITEM00_RUPEE_GREEN:
this->unk1A4 = 1;
- Item_Give(globalCtx, ITEM_RUPEE_GREEN);
+ Item_Give(play, ITEM_RUPEE_GREEN);
break;
case ITEM00_RUPEE_BLUE:
this->unk1A4 = 1;
- Item_Give(globalCtx, ITEM_RUPEE_BLUE);
+ Item_Give(play, ITEM_RUPEE_BLUE);
break;
case ITEM00_RUPEE_RED:
this->unk1A4 = 1;
- Item_Give(globalCtx, ITEM_RUPEE_RED);
+ Item_Give(play, ITEM_RUPEE_RED);
break;
case ITEM00_RUPEE_PURPLE:
this->unk1A4 = 1;
- Item_Give(globalCtx, ITEM_RUPEE_PURPLE);
+ Item_Give(play, ITEM_RUPEE_PURPLE);
break;
case ITEM00_RUPEE_HUGE:
this->unk1A4 = 1;
- Item_Give(globalCtx, ITEM_RUPEE_HUGE);
+ Item_Give(play, ITEM_RUPEE_HUGE);
break;
case ITEM00_STICK:
getItemId = GI_STICKS_1;
@@ -533,27 +533,27 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
getItemId = GI_NUTS_10;
break;
case ITEM00_HEART:
- Item_Give(globalCtx, ITEM_HEART);
+ Item_Give(play, ITEM_HEART);
break;
case ITEM00_FLEXIBLE:
case ITEM00_BIG_FAIRY:
- func_80115908(globalCtx, 0x70);
+ func_80115908(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_10:
- Item_Give(globalCtx, ITEM_ARROWS_10);
+ Item_Give(play, ITEM_ARROWS_10);
break;
case ITEM00_ARROWS_30:
- Item_Give(globalCtx, ITEM_ARROWS_30);
+ Item_Give(play, ITEM_ARROWS_30);
break;
case ITEM00_ARROWS_40:
- Item_Give(globalCtx, ITEM_ARROWS_40);
+ Item_Give(play, ITEM_ARROWS_40);
break;
case ITEM00_ARROWS_50:
- Item_Give(globalCtx, ITEM_ARROWS_50);
+ Item_Give(play, ITEM_ARROWS_50);
break;
case ITEM00_SMALL_KEY:
getItemId = GI_KEY_SMALL;
@@ -565,10 +565,10 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
getItemId = GI_HEART_CONTAINER;
break;
case ITEM00_MAGIC_LARGE:
- Item_Give(globalCtx, ITEM_MAGIC_LARGE);
+ Item_Give(play, ITEM_MAGIC_LARGE);
break;
case ITEM00_MAGIC_SMALL:
- Item_Give(globalCtx, ITEM_MAGIC_SMALL);
+ Item_Give(play, ITEM_MAGIC_SMALL);
break;
case ITEM00_SHIELD_HERO:
getItemId = GI_SHIELD_HERO;
@@ -584,8 +584,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
}
if (getItemId != GI_NONE) {
- if (!Actor_HasParent(&this->actor, globalCtx)) {
- Actor_PickUp(&this->actor, globalCtx, getItemId, 50.0f, 20.0f);
+ if (!Actor_HasParent(&this->actor, play)) {
+ Actor_PickUp(&this->actor, play, getItemId, 50.0f, 20.0f);
}
}
@@ -596,8 +596,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
case ITEM00_SHIELD_HERO:
case ITEM00_MAP:
case ITEM00_COMPASS:
- if (Actor_HasParent(&this->actor, globalCtx)) {
- Flags_SetCollectible(globalCtx, this->collectibleFlag);
+ if (Actor_HasParent(&this->actor, play)) {
+ Flags_SetCollectible(play, this->collectibleFlag);
Actor_MarkForDeath(&this->actor);
}
return;
@@ -608,8 +608,8 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
if ((this->actor.params <= ITEM00_RUPEE_RED) || (this->actor.params == ITEM00_RUPEE_HUGE)) {
play_sound(NA_SE_SY_GET_RUPY);
} 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_MarkForDeath(&this->actor);
}
return;
@@ -617,7 +617,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
play_sound(NA_SE_SY_GET_ITEM);
}
- Flags_SetCollectible(globalCtx, this->collectibleFlag);
+ Flags_SetCollectible(play, this->collectibleFlag);
this->unk152 = 15;
this->unk14C = 35;
@@ -632,12 +632,12 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actionFunc = func_800A6A40;
}
-void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx);
-void EnItem00_DrawSprite(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_DrawSprite(EnItem00* this, PlayState* play);
+void EnItem00_DrawHeartContainer(EnItem00* this, PlayState* play);
+void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play);
-void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
+void EnItem00_Draw(Actor* thisx, PlayState* play) {
s32 pad;
EnItem00* this = THIS;
@@ -648,26 +648,26 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
case ITEM00_RUPEE_RED:
case ITEM00_RUPEE_HUGE:
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->unk152 < 0) {
if (this->unk152 == -1) {
- s8 bankIndex = Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEART);
- if (Object_IsLoaded(&globalCtx->objectCtx, bankIndex)) {
+ s8 bankIndex = Object_GetIndex(&play->objectCtx, OBJECT_GI_HEART);
+ if (Object_IsLoaded(&play->objectCtx, bankIndex)) {
this->actor.objBankIndex = bankIndex;
- Actor_SetObjectDependency(globalCtx, &this->actor);
+ Actor_SetObjectDependency(play, &this->actor);
this->unk152 = -2;
}
} else {
Matrix_Scale(16.0f, 16.0f, 16.0f, MTXMODE_APPLY);
- GetItem_Draw(globalCtx, 8);
+ GetItem_Draw(play, 8);
}
break;
}
@@ -684,16 +684,16 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
case ITEM00_SMALL_KEY:
case ITEM00_NUTS_10:
case ITEM00_BOMBS_0:
- EnItem00_DrawSprite(this, globalCtx);
+ EnItem00_DrawSprite(this, play);
break;
case ITEM00_SHIELD_HERO:
- GetItem_Draw(globalCtx, GID_SHIELD_HERO);
+ GetItem_Draw(play, GID_SHIELD_HERO);
break;
case ITEM00_MAP:
- GetItem_Draw(globalCtx, GID_DUNGEON_MAP);
+ GetItem_Draw(play, GID_DUNGEON_MAP);
break;
case ITEM00_COMPASS:
- GetItem_Draw(globalCtx, GID_COMPASS);
+ GetItem_Draw(play, GID_COMPASS);
case ITEM00_MASK:
case ITEM00_FLEXIBLE:
case ITEM00_3_HEARTS:
@@ -712,14 +712,14 @@ TexturePtr D_801ADF30[] = {
gameplay_keep_Tex_062020 // Purple rupee
};
-void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) {
+void EnItem00_DrawRupee(EnItem00* this, PlayState* play) {
s32 pad;
s32 iconNb;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C28C(globalCtx->state.gfxCtx);
- func_800B8050(&this->actor, globalCtx, 0);
+ func_8012C28C(play->state.gfxCtx);
+ func_800B8050(&this->actor, play, 0);
if (this->actor.params <= ITEM00_RUPEE_RED) {
iconNb = this->actor.params;
@@ -727,13 +727,13 @@ void EnItem00_DrawRupee(EnItem00* this, GlobalContext* globalCtx) {
iconNb = this->actor.params - 0x10;
}
- gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF30[iconNb]));
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_0622C0); // TODO symbol
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
TexturePtr D_801ADF44[12] = {
@@ -751,12 +751,12 @@ TexturePtr D_801ADF44[12] = {
gameplay_keep_Tex_05F7C0 // Small Key
};
-void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) {
+void EnItem00_DrawSprite(EnItem00* this, PlayState* play) {
s32 iconNb = this->actor.params - 3;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- POLY_OPA_DISP = func_801660B8(globalCtx, POLY_OPA_DISP);
+ POLY_OPA_DISP = func_801660B8(play, POLY_OPA_DISP);
if (this->actor.params == ITEM00_NUTS_10) {
iconNb = 6;
@@ -773,45 +773,45 @@ void EnItem00_DrawSprite(EnItem00* this, GlobalContext* globalCtx) {
gSPSegment(POLY_OPA_DISP++, 0x08, Lib_SegmentedToVirtual(D_801ADF44[iconNb]));
- gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_OPA_DISP++, gameplay_keep_DL_05F6F0);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) {
+void EnItem00_DrawHeartContainer(EnItem00* actor, PlayState* play) {
s32 pad;
s32 pad2;
- if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ if (Object_GetIndex(&play->objectCtx, OBJECT_GI_HEARTS) == actor->actor.objBankIndex) {
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C2DC(globalCtx->state.gfxCtx);
+ func_8012C2DC(play->state.gfxCtx);
Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY);
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001290);
gSPDisplayList(POLY_XLU_DISP++, object_gi_hearts_DL_001470);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
-void EnItem00_DrawHeartPiece(EnItem00* this, GlobalContext* globalCtx) {
+void EnItem00_DrawHeartPiece(EnItem00* this, PlayState* play) {
s32 pad;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- func_8012C2DC(globalCtx->state.gfxCtx);
- func_800B8118(&this->actor, globalCtx, 0);
+ func_8012C2DC(play->state.gfxCtx);
+ func_800B8118(&this->actor, play, 0);
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(POLY_XLU_DISP++, gameplay_keep_DL_05AAB0);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
s16 func_800A7650(s16 dropId) {
@@ -834,7 +834,7 @@ s16 func_800A7650(s16 dropId) {
return dropId;
}
-Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 params) {
+Actor* Item_DropCollectible(PlayState* play, Vec3f* spawnPos, u32 params) {
s32 pad;
Actor* spawnedActor = NULL;
s32 newParamFF;
@@ -850,29 +850,28 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param
if (paramFF == ITEM00_3_HEARTS) {
for (i = 0; i < 3; i++) {
- spawnedActor = Item_DropCollectible(globalCtx, spawnPos, param7F00 | ITEM00_HEART | param8000);
+ spawnedActor = Item_DropCollectible(play, spawnPos, param7F00 | ITEM00_HEART | param8000);
}
} else if (paramFF == ITEM00_MUSHROOM_CLOUD) {
param7F00 >>= 8;
- if (!Flags_GetCollectible(globalCtx, param7F00)) {
- Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0,
- 0, param7F00);
+ if (!Flags_GetCollectible(play, param7F00)) {
+ Actor_Spawn(&play->actorCtx, play, ACTOR_OBJ_KINOKO, spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0,
+ param7F00);
}
} else if (((paramFF == ITEM00_FLEXIBLE) || (newParamFF == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
newParamFF = params & 0xFF;
if (newParamFF == ITEM00_FLEXIBLE) {
- spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
+ spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102);
- if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) {
- SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
+ if (!Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F)) {
+ SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
} else {
- spawnedActor =
- Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
- spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
+ spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
+ spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
if (param20000 == 0) {
- if (!Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F)) {
- SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
+ if (!Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F)) {
+ SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
}
}
@@ -881,8 +880,8 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param
params = func_800A7650(newParamFF);
}
if ((s32)params != ITEM00_NO_DROP) {
- spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y,
- spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00);
+ spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0,
+ 0, 0, (s32)params | param8000 | param7F00);
if ((spawnedActor != NULL) && (param8000 == 0)) {
if (param10000 == 0) {
spawnedActor->velocity.y = 8.0f;
@@ -907,7 +906,7 @@ Actor* Item_DropCollectible(GlobalContext* globalCtx, Vec3f* spawnPos, u32 param
return spawnedActor;
}
-Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 params) {
+Actor* Item_DropCollectible2(PlayState* play, Vec3f* spawnPos, s32 params) {
Actor* spawnedActor = NULL;
s32 pad;
s32 param10000 = params & 0x10000;
@@ -922,21 +921,20 @@ Actor* Item_DropCollectible2(GlobalContext* globalCtx, Vec3f* spawnPos, s32 para
if ((((params & 0xFF) == ITEM00_FLEXIBLE) || ((params & 0xFF) == ITEM00_BIG_FAIRY)) && (param10000 == 0)) {
if ((params & 0xFF) == ITEM00_FLEXIBLE) {
- spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
+ spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) << 9) & 0xFE00) | 0x102);
} else {
- spawnedActor =
- Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
- spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
+ spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELFORG, spawnPos->x, spawnPos->y + 40.0f,
+ spawnPos->z, 0, 0, 0, ((((param7F00 >> 8) & 0x7F) & 0x7F) << 9) | 7);
}
- if (Flags_GetCollectible(globalCtx, (param7F00 >> 8) & 0x7F) == 0) {
- SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
+ if (Flags_GetCollectible(play, (param7F00 >> 8) & 0x7F) == 0) {
+ SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
}
} else {
params = func_800A7650(params & 0xFF);
if (params != ITEM00_NO_DROP) {
- spawnedActor = Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y,
- spawnPos->z, 0, 0, 0, (s32)params | param8000 | param7F00);
+ spawnedActor = Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x, spawnPos->y, spawnPos->z, 0,
+ 0, 0, (s32)params | param8000 | param7F00);
if (spawnedActor != NULL) {
if (param8000 == 0) {
spawnedActor->velocity.y = 0.0f;
@@ -1032,7 +1030,7 @@ u8 sDropTableAmounts[DROP_TABLE_SIZE * DROP_TABLE_NUMBER] = {
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
};
-void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3f* spawnPos, s16 params) {
+void Item_DropCollectibleRandom(PlayState* play, Actor* fromActor, Vec3f* spawnPos, s16 params) {
EnItem00* spawnedActor;
u8 dropId;
s32 dropQuantity;
@@ -1084,9 +1082,9 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
if (dropId == ITEM00_FLEXIBLE) {
if (gSaveContext.save.playerData.health <= 0x10) {
- Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f,
- spawnPos->z, 0, 0, 0, 2);
- SoundSource_PlaySfxAtFixedWorldPos(globalCtx, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
+ Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ELF, spawnPos->x, spawnPos->y + 40.0f, spawnPos->z, 0, 0, 0,
+ 2);
+ SoundSource_PlaySfxAtFixedWorldPos(play, spawnPos, 40, NA_SE_EV_BUTTERFRY_TO_FAIRY);
return;
}
@@ -1129,8 +1127,8 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
if (param8000 == 0) {
dropId = func_800A7650(dropId);
if (dropId != (u8)ITEM00_NO_DROP) {
- spawnedActor = (EnItem00*)Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_EN_ITEM00,
- spawnPos->x, spawnPos->y, spawnPos->z, 0, 0, 0, dropId);
+ spawnedActor = (EnItem00*)Actor_Spawn(&play->actorCtx, play, ACTOR_EN_ITEM00, spawnPos->x,
+ spawnPos->y, spawnPos->z, 0, 0, 0, dropId);
if ((spawnedActor != 0) && (dropId != (u8)ITEM00_NO_DROP)) {
spawnedActor->actor.velocity.y = 8.0f;
spawnedActor->actor.speedXZ = 2.0f;
@@ -1148,7 +1146,7 @@ void Item_DropCollectibleRandom(GlobalContext* globalCtx, Actor* fromActor, Vec3
}
}
} else {
- Item_DropCollectible(globalCtx, spawnPos, params | 0x8000);
+ Item_DropCollectible(play, spawnPos, params | 0x8000);
}
dropQuantity--;
@@ -1185,6 +1183,6 @@ s32 func_800A817C(s32 index) {
return D_801AE214[index];
}
-s32 Item_CanDropBigFairy(GlobalContext* globalCtx, s32 index, s32 collectibleFlag) {
- return (func_800A8150(index) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(globalCtx, collectibleFlag));
+s32 Item_CanDropBigFairy(PlayState* play, s32 index, s32 collectibleFlag) {
+ return (func_800A8150(index) == ITEM00_BIG_FAIRY) && (!Flags_GetCollectible(play, collectibleFlag));
}
diff --git a/src/code/z_env_flags.c b/src/code/z_env_flags.c
index d76681512..06e216cd3 100644
--- a/src/code/z_env_flags.c
+++ b/src/code/z_env_flags.c
@@ -1,33 +1,33 @@
#include "global.h"
-void EnvFlags_UnsetAll(GlobalContext* globalCtx) {
+void EnvFlags_UnsetAll(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 EnvFlags_Set(GlobalContext* globalCtx, s16 flag) {
+void EnvFlags_Set(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 EnvFlags_Unset(GlobalContext* globalCtx, s16 flag) {
+void EnvFlags_Unset(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 EnvFlags_Get(GlobalContext* globalCtx, s16 flag) {
+s32 EnvFlags_Get(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/z_face_reaction.c b/src/code/z_face_reaction.c
index d54561fdd..e6d985d65 100644
--- a/src/code/z_face_reaction.c
+++ b/src/code/z_face_reaction.c
@@ -178,9 +178,9 @@ static u16 sReactionTextIds[][PLAYER_MASK_GIANT - 1] = {
};
// clang-format on
-u16 Text_GetFaceReaction(GlobalContext* globalCtx, u32 reactionSet) {
- if ((Player_GetMask(globalCtx) > PLAYER_MASK_NONE) && (Player_GetMask(globalCtx) < PLAYER_MASK_GIANT)) {
- return sReactionTextIds[reactionSet][Player_GetMask(globalCtx) - 1];
+u16 Text_GetFaceReaction(PlayState* play, u32 reactionSet) {
+ if ((Player_GetMask(play) > PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) {
+ return sReactionTextIds[reactionSet][Player_GetMask(play) - 1];
}
return 0;
}
diff --git a/src/code/z_fcurve_data_skelanime.c b/src/code/z_fcurve_data_skelanime.c
index b40a1c351..669e01348 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 = Lib_SegmentedToVirtual(skeletonHeaderSeg);
@@ -61,7 +61,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_Free(skelCurve->jointTable);
}
@@ -91,7 +91,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;
@@ -108,7 +108,7 @@ s32 SkelCurve_Update(GlobalContext* globalCtx, SkelCurve* skelCurve) {
constantData = Lib_SegmentedToVirtual(animation->constantData);
jointData = *skelCurve->jointTable;
- skelCurve->curFrame += skelCurve->playSpeed * ((s32)globalCtx->state.framerateDivisor * 0.5f);
+ skelCurve->curFrame += skelCurve->playSpeed * ((s32)play->state.framerateDivisor * 0.5f);
if (((skelCurve->playSpeed >= 0.0f) && (skelCurve->curFrame > skelCurve->endFrame)) ||
((skelCurve->playSpeed < 0.0f) && (skelCurve->curFrame < skelCurve->endFrame))) {
@@ -155,16 +155,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, Actor* thisx) {
+void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
+ PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
SkelCurveLimb* limb = Lib_SegmentedToVirtual(skelCurve->skeleton[limbIndex]);
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
if ((overrideLimbDraw == NULL) ||
- ((overrideLimbDraw != NULL) && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) {
+ ((overrideLimbDraw != NULL) && overrideLimbDraw(play, skelCurve, limbIndex, thisx))) {
Vec3f scale;
Vec3s rot;
Vec3f pos;
@@ -191,7 +191,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),
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, dList);
}
@@ -200,13 +200,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),
+ gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, dList);
}
dList = limb->dList[1];
if (dList != NULL) {
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, dList);
}
@@ -214,25 +214,25 @@ void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelCurve* skel
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, skelCurve, limbIndex, thisx);
+ postLimbDraw(play, skelCurve, limbIndex, thisx);
}
if (limb->child != LIMB_DONE) {
- SkelCurve_DrawLimb(globalCtx, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
+ SkelCurve_DrawLimb(play, limb->child, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- SkelCurve_DrawLimb(globalCtx, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
+ SkelCurve_DrawLimb(play, limb->sibling, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelCurve* skelCurve,
- OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
+void SkelCurve_Draw(Actor* actor, PlayState* play, SkelCurve* skelCurve, OverrideCurveLimbDraw overrideLimbDraw,
+ PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
if (skelCurve->jointTable != NULL) {
- SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
+ SkelCurve_DrawLimb(play, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
}
diff --git a/src/code/z_fireobj.c b/src/code/z_fireobj.c
index f627c6394..97d5d8373 100644
--- a/src/code/z_fireobj.c
+++ b/src/code/z_fireobj.c
@@ -37,7 +37,7 @@ FireObjLightParams sFireObjLightParams[] = {
{ 200, { 128, 128, 0 }, { 127, 127, 0 } },
};
-void FireObj_InitWithParams(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init) {
+void FireObj_InitWithParams(PlayState* play, FireObj* fire, FireObjInitParams* init) {
fire->size = init->size;
fire->sizeInv = 1.0f / init->size;
fire->dynamicSizeStep = init->dynamicSizeStep;
@@ -92,8 +92,8 @@ void FireObj_StepSize(FireObj* fire) {
fire->xScale = fire->dynamicSize * fire->size;
}
-void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
- Player* player = GET_PLAYER(globalCtx);
+void FireObj_UpdateStateTransitions(PlayState* play, FireObj* fire) {
+ Player* player = GET_PLAYER(play);
WaterBox* waterBox;
f32 waterY;
s32 sp40 = false;
@@ -114,7 +114,7 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
FireObj_SetState(fire, fire->dynamicSizeStep, nextState);
}
if ((fire->flags & 1) && (fire->state != FIRE_STATE_3) &&
- WaterBox_GetSurface1_2(globalCtx, &globalCtx->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) &&
+ WaterBox_GetSurface1_2(play, &play->colCtx, fire->position.x, fire->position.z, &waterY, &waterBox) &&
(waterY - fire->position.y > 6500.0f * fire->yScale)) {
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_3);
}
@@ -131,25 +131,24 @@ void FireObj_UpdateStateTransitions(GlobalContext* globalCtx, FireObj* fire) {
}
} else if (player->unk_B28 == 0) {
player->unk_B28 = 0xD2;
- SoundSource_PlaySfxAtFixedWorldPos(globalCtx, &fire->position, 20, NA_SE_EV_FLAME_IGNITION);
+ SoundSource_PlaySfxAtFixedWorldPos(play, &fire->position, 20, NA_SE_EV_FLAME_IGNITION);
} else if (player->unk_B28 < 0xC8) {
player->unk_B28 = 0xC8;
}
}
}
-void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) {
+void FireObj_Draw(PlayState* play, FireObj* fire) {
s32 pad;
FireObjColors* fireColors = &sFireObjColors[fire->colorsIndex];
if (fire->state != FIRE_STATE_3) {
Vec3s vec;
- OPEN_DISPS(globalCtx->state.gfxCtx);
- func_8012C2DC(globalCtx->state.gfxCtx);
- gSPSegment(
- POLY_XLU_DISP++, 0x08,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128));
+ OPEN_DISPS(play->state.gfxCtx);
+ func_8012C2DC(play->state.gfxCtx);
+ gSPSegment(POLY_XLU_DISP++, 0x08,
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (fire->unk26 * -20) & 511, 32, 128));
gDPSetPrimColor(POLY_XLU_DISP++, 0, fireColors->lod, fireColors->primColor.r, fireColors->primColor.g,
fireColors->primColor.b, fireColors->primColor.a);
@@ -157,31 +156,31 @@ void FireObj_Draw(GlobalContext* globalCtx, FireObj* fire) {
gDPSetEnvColor(POLY_XLU_DISP++, fireColors->envColor.r, fireColors->envColor.g, fireColors->envColor.b, 0);
vec.x = 0;
- vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(globalCtx)) + 0x8000;
+ vec.y = Camera_GetCamDirYaw(GET_ACTIVE_CAM(play)) + 0x8000;
vec.z = 0;
Matrix_SetTranslateRotateYXZ(fire->position.x, fire->position.y, fire->position.z, &vec);
Matrix_Scale(fire->xScale, fire->yScale, 1.0f, MTXMODE_APPLY);
- gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, gGameplayKeepDrawFlameDL);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
-void FireObj_InitLight(GlobalContext* globalCtx, FireObjLight* light, u8* paramsIndex, Vec3f* pos) {
+void FireObj_InitLight(PlayState* play, FireObjLight* light, u8* paramsIndex, Vec3f* pos) {
FireObjLightParams* objectParams = &sFireObjLightParams[*paramsIndex];
Lights_PointGlowSetInfo(&light->lightInfo, pos->x, pos->y, pos->z, objectParams->color.r, objectParams->color.g,
objectParams->color.b, objectParams->radius);
- light->light = LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, &light->lightInfo);
+ light->light = LightContext_InsertLight(play, &play->lightCtx, &light->lightInfo);
light->lightParamsIndex = *paramsIndex;
}
-void FireObj_DestroyLight(GlobalContext* globalCtx, FireObjLight* light) {
- LightContext_RemoveLight(globalCtx, &globalCtx->lightCtx, light->light);
+void FireObj_DestroyLight(PlayState* play, FireObjLight* light) {
+ LightContext_RemoveLight(play, &play->lightCtx, light->light);
}
-void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj* fire) {
+void FireObj_UpdateLight(PlayState* play, FireObjLight* light, FireObj* fire) {
FireObjLightParams* lightParams = &sFireObjLightParams[light->lightParamsIndex];
s16 radius;
@@ -198,33 +197,33 @@ void FireObj_UpdateLight(GlobalContext* globalCtx, FireObjLight* light, FireObj*
}
}
-void FireObj_Init(GlobalContext* globalCtx, FireObj* fire, FireObjInitParams* init, Actor* actor) {
+void FireObj_Init(PlayState* play, FireObj* fire, FireObjInitParams* init, Actor* actor) {
FireObj* fire2 = fire;
- FireObj_InitWithParams(globalCtx, fire, init);
- Collider_InitCylinder(globalCtx, &fire->collision);
- Collider_SetCylinder(globalCtx, &fire->collision, actor, &sFireObjCollisionInit);
+ FireObj_InitWithParams(play, fire, init);
+ Collider_InitCylinder(play, &fire->collision);
+ Collider_SetCylinder(play, &fire->collision, actor, &sFireObjCollisionInit);
fire2->collision.dim.radius = (fire->size * 4000.0f) + 2.5f;
fire2->collision.dim.height = fire->size * 16000.0f;
fire->collision.dim.yShift = fire->size * -1728.0f;
- FireObj_InitLight(globalCtx, &fire->light, &init->lightParamsIndex, &fire->position);
+ FireObj_InitLight(play, &fire->light, &init->lightParamsIndex, &fire->position);
}
-void FireObj_Destroy(GlobalContext* globalCtx, FireObj* fire) {
- Collider_DestroyCylinder(globalCtx, &fire->collision);
- FireObj_DestroyLight(globalCtx, &fire->light);
+void FireObj_Destroy(PlayState* play, FireObj* fire) {
+ Collider_DestroyCylinder(play, &fire->collision);
+ FireObj_DestroyLight(play, &fire->light);
}
void FireObj_SetState2(FireObj* fire, f32 dynamicSizeStep, u8 newState) {
FireObj_SetState(fire, dynamicSizeStep, newState);
}
-void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) {
+void FireObj_Update(PlayState* play, FireObj* fire, Actor* actor) {
s32 pad; // Gamestate cast?
EnArrow* arrow = (EnArrow*)fire->collision.base.ac;
- FireObj_UpdateStateTransitions(globalCtx, fire);
+ FireObj_UpdateStateTransitions(play, fire);
if (fire->state == FIRE_STATE_3) {
if ((fire->collision.base.acFlags & AC_HIT) && (fire->collision.info.acHitInfo->toucher.dmgFlags & 0x800)) {
FireObj_SetState(fire, fire->dynamicSizeStep, FIRE_STATE_0);
@@ -237,6 +236,6 @@ void FireObj_Update(GlobalContext* globalCtx, FireObj* fire, Actor* actor) {
fire->collision.dim.pos.x = fire->position.x;
fire->collision.dim.pos.y = fire->position.y;
fire->collision.dim.pos.z = fire->position.z;
- CollisionCheck_SetAC(globalCtx, &globalCtx->colChkCtx, &fire->collision.base);
- FireObj_UpdateLight(globalCtx, &fire->light, fire);
+ CollisionCheck_SetAC(play, &play->colChkCtx, &fire->collision.base);
+ FireObj_UpdateLight(play, &fire->light, fire);
}
diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c
index 4e2590a6a..26a17a84a 100644
--- a/src/code/z_game_dlftbls.c
+++ b/src/code/z_game_dlftbls.c
@@ -17,7 +17,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_Fini, sizeof(GlobalContext)),
+ GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Fini, sizeof(PlayState)),
GAMESTATE_OVERLAY(opening, Opening_Init, Opening_Destroy, sizeof(OpeningContext)),
GAMESTATE_OVERLAY(file_choose, FileChoose_Init, FileChoose_Destroy, sizeof(FileChooseContext)),
GAMESTATE_OVERLAY(daytelop, Daytelop_Init, Daytelop_Destroy, sizeof(DaytelopContext)),
diff --git a/src/code/z_game_over.c b/src/code/z_game_over.c
index 62d55bc00..18df07783 100644
--- a/src/code/z_game_over.c
+++ b/src/code/z_game_over.c
@@ -1,27 +1,28 @@
#include "global.h"
+#include "z64rumble.h"
-void GameOver_Init(GlobalContext* globalCtx) {
- globalCtx->gameOverCtx.state = GAMEOVER_INACTIVE;
+void GameOver_Init(PlayState* play) {
+ play->gameOverCtx.state = GAMEOVER_INACTIVE;
}
-void GameOver_FadeLights(GlobalContext* globalCtx) {
- GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
+void GameOver_FadeLights(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)) {
- Kankyo_FadeInGameOverLights(globalCtx);
+ Kankyo_FadeInGameOverLights(play);
}
}
static s16 sGameOverTimer = 0;
-void GameOver_Update(GlobalContext* globalCtx) {
- GameOverContext* gameOverCtx = &globalCtx->gameOverCtx;
+void GameOver_Update(PlayState* play) {
+ GameOverContext* gameOverCtx = &play->gameOverCtx;
s16 i;
switch (gameOverCtx->state) {
case GAMEOVER_DEATH_START:
- func_801477B4(globalCtx);
+ func_801477B4(play);
for (i = 0; i < ARRAY_COUNT(gSaveContext.unk_3DD0); i++) {
gSaveContext.unk_3DD0[i] = 0;
@@ -60,14 +61,14 @@ void GameOver_Update(GlobalContext* globalCtx) {
gSaveContext.unk_3F20 = 0;
gSaveContext.unk_3F22 = 0;
gSaveContext.unk_3F24 = 0;
- Kankyo_InitGameOverLights(globalCtx);
+ Kankyo_InitGameOverLights(play);
sGameOverTimer = 20;
- func_8013ECE0(0.0f, 126, 124, 63);
+ Rumble_Request(0.0f, 126, 124, 63);
gameOverCtx->state = GAMEOVER_DEATH_WAIT_GROUND;
break;
case GAMEOVER_DEATH_FADE_OUT:
if (func_801A8A50(1) != NA_BGM_GAME_OVER) {
- func_80169F78(&globalCtx->state);
+ func_80169F78(&play->state);
if (gSaveContext.respawnFlag != -7) {
gSaveContext.respawnFlag = -6;
}
@@ -78,19 +79,19 @@ void GameOver_Update(GlobalContext* globalCtx) {
gSaveContext.save.playerForm = PLAYER_FORM_HUMAN;
gSaveContext.save.equippedMask = PLAYER_MASK_NONE;
}
- func_8013EE24();
+ Rumble_StateReset();
}
break;
case GAMEOVER_REVIVE_START:
gameOverCtx->state++;
sGameOverTimer = 0;
- Kankyo_InitGameOverLights(globalCtx);
+ Kankyo_InitGameOverLights(play);
ShrinkWindow_SetLetterboxTarget(32);
break;
case GAMEOVER_REVIVE_RUMBLE:
sGameOverTimer = 50;
gameOverCtx->state++;
- func_8013ECE0(0.0f, 126, 124, 63);
+ Rumble_Request(0.0f, 126, 124, 63);
break;
case GAMEOVER_REVIVE_WAIT_GROUND:
sGameOverTimer--;
@@ -107,7 +108,7 @@ void GameOver_Update(GlobalContext* globalCtx) {
}
break;
case GAMEOVER_REVIVE_FADE_OUT:
- Kankyo_FadeOutGameOverLights(globalCtx);
+ Kankyo_FadeOutGameOverLights(play);
sGameOverTimer--;
if (sGameOverTimer == 0) {
gameOverCtx->state = GAMEOVER_INACTIVE;
diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c
index 73656d65d..48e8e2ad6 100644
--- a/src/code/z_kaleido_manager.c
+++ b/src/code/z_kaleido_manager.c
@@ -54,7 +54,7 @@ void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) {
}
}
-void KaleidoManager_Init(GlobalContext* globalCtx) {
+void KaleidoManager_Init(PlayState* play) {
s32 largestSize = 0;
s32 size;
u32 i;
@@ -66,7 +66,7 @@ void KaleidoManager_Init(GlobalContext* globalCtx) {
}
}
- sKaleidoAreaPtr = THA_AllocEndAlign16(&globalCtx->state.heap, largestSize);
+ sKaleidoAreaPtr = THA_AllocEndAlign16(&play->state.heap, largestSize);
gKaleidoMgrCurOvl = NULL;
Fault_AddAddrConvClient(&sKaleidoAreaFaultClient, KaleidoManager_FaultAddrConvFunc, NULL);
}
diff --git a/src/code/z_kaleido_scope_call.c b/src/code/z_kaleido_scope_call.c
index c3c616669..c40154bc7 100644
--- a/src/code/z_kaleido_scope_call.c
+++ b/src/code/z_kaleido_scope_call.c
@@ -1,11 +1,11 @@
#include "prevent_bss_reordering.h"
#include "global.h"
-void (*sKaleidoScopeUpdateFunc)(GlobalContext* globalCtx);
-void (*sKaleidoScopeDrawFunc)(GlobalContext* globalCtx);
+void (*sKaleidoScopeUpdateFunc)(PlayState* play);
+void (*sKaleidoScopeDrawFunc)(PlayState* play);
-extern void KaleidoScope_Update(GlobalContext* globalCtx);
-extern void KaleidoScope_Draw(GlobalContext* globalCtx);
+extern void KaleidoScope_Update(PlayState* play);
+extern void KaleidoScope_Draw(PlayState* play);
void KaleidoScopeCall_LoadPlayer() {
KaleidoMgrOverlay* playerActorOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_PLAYER_ACTOR];
@@ -19,21 +19,21 @@ void KaleidoScopeCall_LoadPlayer() {
}
}
-void KaleidoScopeCall_Init(GlobalContext* globalCtx) {
+void KaleidoScopeCall_Init(PlayState* play) {
sKaleidoScopeUpdateFunc = KaleidoManager_GetRamAddr(KaleidoScope_Update);
sKaleidoScopeDrawFunc = KaleidoManager_GetRamAddr(KaleidoScope_Draw);
- KaleidoSetup_Init(globalCtx);
+ KaleidoSetup_Init(play);
}
-void KaleidoScopeCall_Destroy(GlobalContext* globalCtx) {
- KaleidoSetup_Destroy(globalCtx);
+void KaleidoScopeCall_Destroy(PlayState* play) {
+ KaleidoSetup_Destroy(play);
}
-void KaleidoScopeCall_Update(GlobalContext* globalCtx) {
- PauseContext* pauseCtx = &globalCtx->pauseCtx;
+void KaleidoScopeCall_Update(PlayState* play) {
+ PauseContext* pauseCtx = &play->pauseCtx;
KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE];
- if ((globalCtx->pauseCtx.state != 0) || (globalCtx->pauseCtx.debugState != 0)) {
+ if ((play->pauseCtx.state != 0) || (play->pauseCtx.debugState != 0)) {
if (pauseCtx->state == 1 || pauseCtx->state == 19) {
if (ShrinkWindow_GetLetterboxMagnitude() == 0) {
R_PAUSE_MENU_MODE = 1;
@@ -60,9 +60,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)) {
KaleidoManager_ClearOvl(kaleidoScopeOvl);
KaleidoScopeCall_LoadPlayer();
}
@@ -71,14 +71,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 <= 26))) {
+ if (((play->pauseCtx.state >= 4) && (play->pauseCtx.state <= 7)) ||
+ ((play->pauseCtx.state >= 11) && (play->pauseCtx.state <= 26))) {
if (gKaleidoMgrCurOvl == kaleidoScopeOvl) {
- sKaleidoScopeDrawFunc(globalCtx);
+ sKaleidoScopeDrawFunc(play);
}
}
}
diff --git a/src/code/z_kaleido_setup.c b/src/code/z_kaleido_setup.c
index 5ed36d551..b5ec93f5a 100644
--- a/src/code/z_kaleido_setup.c
+++ b/src/code/z_kaleido_setup.c
@@ -1,15 +1,16 @@
#include "global.h"
+#include "z64rumble.h"
#include "overlays/gamestates/ovl_file_choose/z_file_choose.h"
s16 D_801BDB00[] = { PAUSE_1, PAUSE_2, PAUSE_3, PAUSE_0 };
f32 sKaleidoSetupEyeX[] = { -64.0f, 0.0f, 64.0f, 0.0f };
f32 sKaleidoSetupEyeZ[] = { 0.0f, -64.0f, 0.0f, 64.0f };
-void func_800F4A10(GlobalContext* globalCtx) {
- PauseContext* pauseCtx = &globalCtx->pauseCtx;
+void func_800F4A10(PlayState* play) {
+ PauseContext* pauseCtx = &play->pauseCtx;
s16 i;
- func_8013EE24();
+ Rumble_StateReset();
pauseCtx->unk_206 = 0;
pauseCtx->unk_200 = 1;
@@ -59,35 +60,34 @@ void func_800F4A10(GlobalContext* globalCtx) {
YREG(26) = -0x3840;
}
-void KaleidoSetup_Update(GlobalContext* globalCtx) {
- Input* input = CONTROLLER1(&globalCtx->state);
- MessageContext* msgCtx = &globalCtx->msgCtx;
- Player* player = GET_PLAYER(globalCtx);
- PauseContext* pauseCtx = &globalCtx->pauseCtx;
+void KaleidoSetup_Update(PlayState* play) {
+ Input* input = CONTROLLER1(&play->state);
+ MessageContext* msgCtx = &play->msgCtx;
+ Player* player = GET_PLAYER(play);
+ PauseContext* pauseCtx = &play->pauseCtx;
if (CHECK_BTN_ALL(input->cur.button, BTN_R)) {
if (msgCtx && msgCtx) {}
}
- if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (globalCtx->gameOverCtx.state == GAMEOVER_INACTIVE)) {
- if ((globalCtx->sceneLoadFlag == 0) && (globalCtx->unk_18B4A == 0)) {
+ if ((pauseCtx->state == 0) && (pauseCtx->debugState == 0) && (play->gameOverCtx.state == GAMEOVER_INACTIVE)) {
+ if ((play->sceneLoadFlag == 0) && (play->unk_18B4A == 0)) {
if ((gSaveContext.save.cutscene < 0xFFF0) && (gSaveContext.nextCutsceneIndex < 0xFFF0)) {
- if (!Play_InCsMode(globalCtx) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) {
- if ((globalCtx->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) {
+ if (!Play_InCsMode(play) || ((msgCtx->msgMode != 0) && (msgCtx->currentTextId == 0xFF))) {
+ if ((play->unk_1887C < 2) && (gSaveContext.unk_3F28 != 8) && (gSaveContext.unk_3F28 != 9)) {
if (!(gSaveContext.eventInf[1] & 0x80) && !(player->stateFlags1 & 0x20)) {
- if (!(globalCtx->actorCtx.unk5 & 2) && !(globalCtx->actorCtx.unk5 & 4)) {
- if ((globalCtx->actorCtx.unk268 == 0) &&
- CHECK_BTN_ALL(input->press.button, BTN_START)) {
+ if (!(play->actorCtx.unk5 & 2) && !(play->actorCtx.unk5 & 4)) {
+ if ((play->actorCtx.unk268 == 0) && CHECK_BTN_ALL(input->press.button, BTN_START)) {
gSaveContext.unk_3F26 = gSaveContext.unk_3F22;
pauseCtx->unk_2B9 = 0;
pauseCtx->state = 1;
- func_800F4A10(globalCtx);
+ func_800F4A10(play);
pauseCtx->mode = pauseCtx->pageIndex * 2 + 1;
func_801A3A7C(1);
}
if (pauseCtx->state == 1) {
- Game_SetFramerateDivisor(&globalCtx->state, 2);
+ Game_SetFramerateDivisor(&play->state, 2);
if (ShrinkWindow_GetLetterboxTarget() != 0) {
ShrinkWindow_SetLetterboxTarget(0);
}
@@ -102,8 +102,8 @@ void KaleidoSetup_Update(GlobalContext* globalCtx) {
}
}
-void KaleidoSetup_Init(GlobalContext* globalCtx) {
- PauseContext* pauseCtx = &globalCtx->pauseCtx;
+void KaleidoSetup_Init(PlayState* play) {
+ PauseContext* pauseCtx = &play->pauseCtx;
s32 pad[2];
bzero(pauseCtx, sizeof(PauseContext));
@@ -138,8 +138,8 @@ void KaleidoSetup_Init(GlobalContext* globalCtx) {
pauseCtx->unk_2BC = 40;
pauseCtx->unk_29E = 100;
- 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_kanfont.c b/src/code/z_kanfont.c
index 2a4849ccb..68c0fdd01 100644
--- a/src/code/z_kanfont.c
+++ b/src/code/z_kanfont.c
@@ -1,11 +1,11 @@
#include "global.h"
// stubbed in NTSC-U
-void Font_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32 offset) {
+void Font_LoadChar(PlayState* play, u16 codePointIndex, s32 offset) {
}
-void Font_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32 offset) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Font_LoadCharNES(PlayState* play, u8 codePointIndex, s32 offset) {
+ MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
DmaMgr_SendRequest0(&font->charBuf[font->unk_11D88][offset],
diff --git a/src/code/z_lifemeter.c b/src/code/z_lifemeter.c
index 73ba326b5..c31cf0016 100644
--- a/src/code/z_lifemeter.c
+++ b/src/code/z_lifemeter.c
@@ -1,7 +1,6 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "interface/parameter_static/parameter_static.h"
-#include "prevent_bss_reordering.h"
s16 sHeartsPrimColors[3][3] = { { 255, 70, 50 }, { 255, 190, 0 }, { 100, 100, 255 } };
s16 sHeartsEnvColors[3][3] = { { 50, 40, 60 }, { 255, 0, 0 }, { 0, 0, 255 } };
@@ -33,8 +32,8 @@ TexturePtr HeartDDTextures[] = {
gDefenseHeartThreeQuarterTex,
};
-void LifeMeter_Init(GlobalContext* globalCtx) {
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+void LifeMeter_Init(PlayState* play) {
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
interfaceCtx->unkTimer = 320;
@@ -71,8 +70,8 @@ void LifeMeter_Init(GlobalContext* globalCtx) {
sHeartsDDEnv[0][2] = sHeartsDDEnv[1][2] = 0;
}
-void LifeMeter_UpdateColors(GlobalContext* globalCtx) {
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+void LifeMeter_UpdateColors(PlayState* play) {
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
f32 factorBeating = interfaceCtx->lifeColorChange * 0.1f;
f32 ddFactor;
s32 type = 0;
@@ -167,26 +166,26 @@ void LifeMeter_UpdateColors(GlobalContext* globalCtx) {
sBeatingHeartsDDEnv[2] = (u8)(bFactor + 0) & 0xFF;
}
-s32 LifeMeter_SaveInterfaceHealth(GlobalContext* globalCtx) {
- gSaveContext.save.playerData.health = globalCtx->interfaceCtx.health;
+s32 LifeMeter_SaveInterfaceHealth(PlayState* play) {
+ gSaveContext.save.playerData.health = play->interfaceCtx.health;
return 1;
}
-s32 LifeMeter_IncreaseInterfaceHealth(GlobalContext* globalCtx) {
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+s32 LifeMeter_IncreaseInterfaceHealth(PlayState* play) {
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
interfaceCtx->unkTimer = 320;
interfaceCtx->health += 0x10;
- if (globalCtx->interfaceCtx.health >= gSaveContext.save.playerData.health) {
- globalCtx->interfaceCtx.health = gSaveContext.save.playerData.health;
+ if (play->interfaceCtx.health >= gSaveContext.save.playerData.health) {
+ play->interfaceCtx.health = gSaveContext.save.playerData.health;
return 1;
}
return 0;
}
-s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) {
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+s32 LifeMeter_DecreaseInterfaceHealth(PlayState* play) {
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
if (interfaceCtx->unkTimer != 0) {
interfaceCtx->unkTimer--;
@@ -195,14 +194,14 @@ s32 LifeMeter_DecreaseInterfaceHealth(GlobalContext* globalCtx) {
interfaceCtx->health -= 0x10;
if (interfaceCtx->health <= 0) {
interfaceCtx->health = 0;
- globalCtx->damagePlayer(globalCtx, -(((void)0, gSaveContext.save.playerData.health) + 1));
+ play->damagePlayer(play, -(((void)0, gSaveContext.save.playerData.health) + 1));
return 1;
}
}
return 0;
}
-void LifeMeter_Draw(GlobalContext* globalCtx) {
+void LifeMeter_Draw(PlayState* play) {
s32 pad[5];
TexturePtr heartTex;
s32 curColorSet;
@@ -213,8 +212,8 @@ void LifeMeter_Draw(GlobalContext* globalCtx) {
f32 posX;
f32 halfTexSize;
f32 temp_f4;
- GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+ GraphicsContext* gfxCtx = play->state.gfxCtx;
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
Vtx* beatingHeartVtx = interfaceCtx->beatingHeartVtx;
s32 fractionHeartCount = gSaveContext.save.playerData.health % 0x10;
s16 healthCapacity = gSaveContext.save.playerData.healthCapacity / 0x10;
@@ -391,16 +390,16 @@ void LifeMeter_Draw(GlobalContext* globalCtx) {
CLOSE_DISPS(gfxCtx);
}
-void LifeMeter_UpdateSizeAndBeep(GlobalContext* globalCtx) {
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+void LifeMeter_UpdateSizeAndBeep(PlayState* play) {
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
if (interfaceCtx->lifeSizeChangeDirection != 0) {
interfaceCtx->lifeSizeChange--;
if (interfaceCtx->lifeSizeChange <= 0) {
interfaceCtx->lifeSizeChange = 0;
interfaceCtx->lifeSizeChangeDirection = 0;
- if (!Player_InCsMode(&globalCtx->state) && (globalCtx->pauseCtx.state == 0) &&
- (globalCtx->pauseCtx.debugState == 0) && LifeMeter_IsCritical() && !Play_InCsMode(globalCtx)) {
+ if (!Player_InCsMode(&play->state) && (play->pauseCtx.state == 0) && (play->pauseCtx.debugState == 0) &&
+ LifeMeter_IsCritical() && !Play_InCsMode(play)) {
play_sound(NA_SE_SY_HITPOINT_ALARM);
}
}
diff --git a/src/code/z_lights.c b/src/code/z_lights.c
index e9fae530a..b602c66b1 100644
--- a/src/code/z_lights.c
+++ b/src/code/z_lights.c
@@ -124,7 +124,7 @@ void Lights_BindPointWithReference(Lights* lights, LightParams* params, Vec3f* p
}
}
-void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* globalCtx) {
+void Lights_BindPoint(Lights* lights, LightParams* params, PlayState* play) {
Light* light;
f32 radiusF = params->point.radius;
Vec3f posF;
@@ -135,7 +135,7 @@ void Lights_BindPoint(Lights* lights, LightParams* params, GlobalContext* global
posF.x = params->point.x;
posF.y = params->point.y;
posF.z = params->point.z;
- SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &posF, &adjustedPos);
+ SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &posF, &adjustedPos);
if ((adjustedPos.z > -radiusF) && (600 + radiusF > adjustedPos.z) && (400 > fabsf(adjustedPos.x) - radiusF) &&
(400 > fabsf(adjustedPos.y) - radiusF)) {
light = Lights_FindSlot(lights);
@@ -189,7 +189,7 @@ void Lights_BindDirectional(Lights* lights, LightParams* params, void* unused) {
* Note: Lights in a given list can only be binded to however many free slots are
* available in the Lights group. This is at most 7 slots for a new group, but could be less.
*/
-void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalContext* globalCtx) {
+void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, PlayState* play) {
static LightsPosBindFunc posBindFuncs[] = {
Lights_BindPoint,
(LightsPosBindFunc)Lights_BindDirectional,
@@ -204,7 +204,7 @@ void Lights_BindAll(Lights* lights, LightNode* listHead, Vec3f* refPos, GlobalCo
if (listHead != NULL) {
if ((refPos == NULL) && (lights->enablePosLights == 1)) {
do {
- posBindFuncs[listHead->info->type](lights, &listHead->info->params, globalCtx);
+ posBindFuncs[listHead->info->type](lights, &listHead->info->params, play);
listHead = listHead->next;
} while (listHead != NULL);
} else {
@@ -248,8 +248,8 @@ void 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);
func_80102544(lightCtx, 0, 0, 0, 0x3E4, 0x3200);
bzero(&sLightsBuffer, sizeof(LightsBuffer));
@@ -276,13 +276,13 @@ Lights* LightContext_NewLights(LightContext* lightCtx, GraphicsContext* gfxCtx)
return Lights_New(gfxCtx, lightCtx->ambient.r, lightCtx->ambient.g, lightCtx->ambient.b);
}
-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;
}
}
@@ -293,7 +293,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* light;
light = Lights_FindBufSlot();
@@ -312,7 +312,7 @@ LightNode* LightContext_InsertLight(GlobalContext* globalCtx, LightContext* ligh
return light;
}
-void LightContext_RemoveLight(GlobalContext* globalCtx, LightContext* lightCtx, LightNode* light) {
+void LightContext_RemoveLight(PlayState* play, LightContext* lightCtx, LightNode* light) {
if (light != NULL) {
if (light->prev != NULL) {
light->prev->next = light->next;
@@ -372,8 +372,8 @@ Lights* Lights_New(GraphicsContext* gfxCtx, u8 ambientR, u8 ambientG, u8 ambient
return lights;
}
-void Lights_GlowCheck(GlobalContext* globalCtx) {
- LightNode* light = globalCtx->lightCtx.listHead;
+void Lights_GlowCheck(PlayState* play) {
+ LightNode* light = play->lightCtx.listHead;
while (light != NULL) {
LightPoint* params = &light->info->params.point;
@@ -386,7 +386,7 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
pos.x = params->x;
pos.y = params->y;
pos.z = params->z;
- Actor_GetProjectedPos(globalCtx, &pos, &multDest, &wDest);
+ Actor_GetProjectedPos(play, &pos, &multDest, &wDest);
params->drawGlow = 0;
@@ -406,13 +406,13 @@ void Lights_GlowCheck(GlobalContext* globalCtx) {
}
}
-void Lights_DrawGlow(GlobalContext* globalCtx) {
+void Lights_DrawGlow(PlayState* play) {
Gfx* dl;
LightPoint* params;
- LightNode* light = globalCtx->lightCtx.listHead;
+ LightNode* light = play->lightCtx.listHead;
if (light != NULL) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
dl = func_8012C7FC(POLY_XLU_DISP);
@@ -434,8 +434,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) {
Matrix_Translate(params->x, params->y, params->z, MTXMODE_NEW);
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
- gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx),
- G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
+ gSPMatrix(dl++, Matrix_NewMtx(play->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(dl++, gameplay_keep_DL_029CF0);
}
@@ -446,6 +445,6 @@ void Lights_DrawGlow(GlobalContext* globalCtx) {
POLY_XLU_DISP = dl;
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
diff --git a/src/code/z_map_disp.c b/src/code/z_map_disp.c
index 496e6cd72..0ebe651df 100644
--- a/src/code/z_map_disp.c
+++ b/src/code/z_map_disp.c
@@ -1,6 +1,5 @@
#include "global.h"
#include "z64map.h"
-#define PlayState GlobalContext
void func_801031D0(PlayState* play, s32, s32, s32, s32, f32);
void func_80103090(u16*, s32*, s32*);
diff --git a/src/code/z_message.c b/src/code/z_message.c
index d8e2d5c8a..8081f9c87 100644
--- a/src/code/z_message.c
+++ b/src/code/z_message.c
@@ -42,8 +42,8 @@ void func_80147520(void) {
D_801CFCA4[7] = D_801CFCA4[8] = 0;
}
-void func_80147564(GlobalContext* globalCtx) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void func_80147564(PlayState* play) {
+ MessageContext* msgCtx = &play->msgCtx;
msgCtx->unk1204A[0] = 0xBD;
msgCtx->unk1204A[1] = 0xB8;
@@ -65,9 +65,9 @@ void func_80147564(GlobalContext* globalCtx) {
D_801F6B20 = 0xA;
}
-s32 Message_ShouldAdvance(GlobalContext* globalCtx) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
- Input* controller = CONTROLLER1(&globalCtx->state);
+s32 Message_ShouldAdvance(PlayState* play) {
+ MessageContext* msgCtx = &play->msgCtx;
+ Input* controller = CONTROLLER1(&play->state);
if ((msgCtx->unk12020 == 0x10) || (msgCtx->unk12020 == 0x11)) {
if (CHECK_BTN_ALL(controller->press.button, BTN_A)) {
@@ -84,9 +84,9 @@ s32 Message_ShouldAdvance(GlobalContext* globalCtx) {
}
}
-s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
- Input* controller = CONTROLLER1(&globalCtx->state);
+s32 Message_ShouldAdvanceSilent(PlayState* play) {
+ MessageContext* msgCtx = &play->msgCtx;
+ Input* controller = CONTROLLER1(&play->state);
if (msgCtx->unk12020 == 0x10 || msgCtx->unk12020 == 0x11) {
return CHECK_BTN_ALL(controller->press.button, BTN_A);
@@ -96,10 +96,10 @@ s32 Message_ShouldAdvanceSilent(GlobalContext* globalCtx) {
}
}
-void func_801477B4(GlobalContext* globalCtx) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void func_801477B4(PlayState* play) {
+ MessageContext* msgCtx = &play->msgCtx;
- if (globalCtx->msgCtx.unk11F10 != 0) {
+ if (play->msgCtx.unk11F10 != 0) {
msgCtx->unk12023 = 2;
msgCtx->msgMode = 0x43;
msgCtx->unk12020 = 0;
@@ -114,10 +114,10 @@ void func_801477B4(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148558.s")
#ifdef NON_MATCHING
-void func_80148B98(GlobalContext* globalCtx, u8 arg1) {
+void func_80148B98(PlayState* play, u8 arg1) {
static s16 held = 0;
- MessageContext* msgCtx = &globalCtx->msgCtx;
- Input* curInput = CONTROLLER1(&globalCtx->state);
+ MessageContext* msgCtx = &play->msgCtx;
+ Input* curInput = CONTROLLER1(&play->state);
if ((curInput->rel.stick_y > 29) && held == 0) {
held = 1;
@@ -147,8 +147,8 @@ void func_80148B98(GlobalContext* globalCtx, u8 arg1) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148B98.s")
#endif
-void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void func_80148CBC(PlayState* play, UNK_PTR puParm2, u8 arg2) {
+ MessageContext* msgCtx = &play->msgCtx;
msgCtx->unk11FF4 = 0x30;
if (arg2 == 1) {
@@ -156,7 +156,7 @@ void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) {
} else {
msgCtx->unk11FF6 = msgCtx->unk11FFE[msgCtx->choiceIndex];
}
- func_80147818(globalCtx, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6);
+ func_80147818(play, puParm2, msgCtx->unk11FF4, msgCtx->unk11FF6);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80148D64.s")
@@ -173,8 +173,8 @@ void func_80148CBC(GlobalContext* globalCtx, UNK_PTR puParm2, u8 arg2) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80149C18.s")
-void Message_FindMessage(GlobalContext* globalCtx, u16 textId) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_FindMessage(PlayState* play, u16 textId) {
+ MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
MessageTableEntry* msgEntry = msgCtx->messageEntryTable;
const char* segment = msgEntry->segment;
@@ -209,12 +209,12 @@ void Message_FindMessage(GlobalContext* globalCtx, u16 textId) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014C70C.s")
-void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadChar(PlayState* play, u16 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
+ MessageContext* msgCtx = &play->msgCtx;
s32 temp1 = *offset;
f32 temp2 = *arg3;
- Font_LoadChar(globalCtx, codePointIndex, temp1);
+ Font_LoadChar(play, codePointIndex, temp1);
msgCtx->decodedBuffer.wchar[decodedBufPos] = codePointIndex;
temp1 += FONT_CHAR_TEX_SIZE;
temp2 += (16.0f * msgCtx->unk12098);
@@ -223,21 +223,21 @@ void Message_LoadChar(GlobalContext* globalCtx, u16 codePointIndex, s32* offset,
}
// Message_LoadRupees JPN ?
-void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void func_8014CCB4(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) {
+ MessageContext* msgCtx = &play->msgCtx;
s16 t = *decodedBufPos;
s32 k = *offset;
f32 f = *arg3;
- Font_LoadChar(globalCtx, 0x838B, k); // 0x838b = ル in JISX0213
+ Font_LoadChar(play, 0x838B, k); // 0x838b = ル in JISX0213
k += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.wchar[t] = 0x838B;
t += 1;
- Font_LoadChar(globalCtx, 0x8373, k); // 0x8373 = ピ in JISX0213
+ Font_LoadChar(play, 0x8373, k); // 0x8373 = ピ in JISX0213
k += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.wchar[t] = 0x8373;
t += 1;
- Font_LoadChar(globalCtx, 0x815C, k); // Ox815C = ― in JISX0213
+ Font_LoadChar(play, 0x815C, k); // Ox815C = ― in JISX0213
k += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.wchar[t] = 0x815C;
@@ -257,7 +257,7 @@ void func_8014CCB4(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f3
extern u16* D_801D0188;
extern s16* D_801D0250;
-void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
+void func_8014D62C(PlayState* play, s32* arg1, f32* arg2, s16* arg3) {
f32 sp3C;
s16 temp_s0;
s16 temp_s1;
@@ -276,10 +276,10 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
temp_s1 = *arg3;
temp_s2 = *arg1;
sp3C = *arg2;
- if ((func_8010A0A4(arg0) != 0) || (arg0->sceneNum == 0x4F)) {
+ if ((func_8010A0A4(play) != 0) || (play->sceneNum == 0x4F)) {
phi_v0 = 0xA;
} else {
- phi_v0 = arg0->pauseCtx.unk_238[4];
+ phi_v0 = play->pauseCtx.unk_238[4];
}
temp_s6 = *(&D_801D0250 + (phi_v0 * 2));
phi_s0 = 0;
@@ -290,8 +290,8 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
phi_s2 = temp_s2;
do {
temp_v0 = (phi_v0 * 0x12) + &D_801D0188 + (phi_s0 * 2);
- (arg0 + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0;
- Font_LoadChar(arg0, *temp_v0, phi_s2);
+ (play + 0x4908 + (phi_s1 * 2))->decodedBuffer = (u16)*temp_v0;
+ Font_LoadChar(play, *temp_v0, phi_s2);
temp_s0 = phi_s0 + 1;
temp_s1_2 = phi_s1 + 1;
temp_s2_2 = phi_s2 + 0x80;
@@ -304,7 +304,7 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
}
*arg3 = phi_s1_2 - 1;
*arg1 = phi_s2_2;
- *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * arg0->msgCtx.unk12098));
+ *arg2 = sp3C + ((f32)(temp_s6 - 1) * (16.0f * play->msgCtx.unk12098));
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8014D62C.s")
@@ -318,53 +318,53 @@ void func_8014D62C(GlobalContext* arg0, s32* arg1, f32* arg2, s16* arg3) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801514B0.s")
-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;
msgCtx->ocarinaAction = 0xFFFF;
- func_80150D08(globalCtx, textId);
+ func_80150D08(play, textId);
msgCtx->unkActor = Actor;
msgCtx->msgMode = 1;
msgCtx->unk12023 = 0;
msgCtx->unk12024 = 0;
- globalCtx->msgCtx.ocarinaMode = 0;
+ play->msgCtx.ocarinaMode = 0;
}
-void func_80151938(GlobalContext* globalCtx, u16 textId) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
- InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
+void func_80151938(PlayState* play, u16 textId) {
+ MessageContext* msgCtx = &play->msgCtx;
+ InterfaceContext* interfaceCtx = &play->interfaceCtx;
msgCtx->unk11F10 = 0;
- func_80150D08(globalCtx, textId);
- func_80150A84(globalCtx);
+ func_80150D08(play, textId);
+ func_80150A84(play);
msgCtx->msgMode = 5;
msgCtx->unk12023 = 8;
msgCtx->unk12024 = 0;
if (interfaceCtx->unk_222 == 0) {
if (textId != 0x1B93) {
- func_8011552C(globalCtx, 0x10);
+ func_8011552C(play, 0x10);
} else if (textId != 0xF8) {
- func_8011552C(globalCtx, 6);
+ func_8011552C(play, 6);
}
}
msgCtx->unk1203C = msgCtx->unk1203A;
- if (globalCtx->pauseCtx.unk_1F0 != 0) {
+ if (play->pauseCtx.unk_1F0 != 0) {
msgCtx->unk12004 = 0x22;
msgCtx->unk12006 = 0x15E;
- func_80149C18(globalCtx);
+ func_80149C18(play);
msgCtx->unk12023 = 1;
}
}
-void func_80151A68(GlobalContext* globalCtx, u16 textId) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void func_80151A68(PlayState* play, u16 textId) {
+ MessageContext* msgCtx = &play->msgCtx;
msgCtx->unk11F10 = 0;
- func_80150D08(globalCtx, textId);
- func_80150A84(globalCtx);
- func_8015B198(globalCtx);
+ func_80150D08(play, textId);
+ func_80150A84(play);
+ func_8015B198(play);
msgCtx->msgMode = 0x45;
msgCtx->unk12024 = 0;
msgCtx->unk1203C = msgCtx->unk1203A = msgCtx->unk1201E = 0;
@@ -386,8 +386,8 @@ void func_80151A68(GlobalContext* globalCtx, u16 textId) {
}
}
-void func_80151BB4(GlobalContext* globalCtx, u8 arg1) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void func_80151BB4(PlayState* play, u8 arg1) {
+ MessageContext* msgCtx = &play->msgCtx;
u8 temp = arg1;
if (CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) {
@@ -403,8 +403,8 @@ void func_80151BB4(GlobalContext* globalCtx, u8 arg1) {
}
}
-u32 func_80151C9C(GlobalContext* globalCtx) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+u32 func_80151C9C(PlayState* play) {
+ MessageContext* msgCtx = &play->msgCtx;
while (true) {
if (msgCtx->unk120B1 == 0) {
@@ -419,7 +419,7 @@ u32 func_80151C9C(GlobalContext* globalCtx) {
(u8)D_801C6B28[msgCtx->unk120B2[msgCtx->unk120B1]];
if ((D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]] != 0) && CHECK_QUEST_ITEM(QUEST_BOMBERS_NOTEBOOK)) {
- func_80151938(globalCtx, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]);
+ func_80151938(play, D_801C6AB8[msgCtx->unk120B2[msgCtx->unk120B1]]);
play_sound(NA_SE_SY_SCHEDULE_WRITE);
return true;
}
@@ -429,14 +429,14 @@ u32 func_80151C9C(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80151DA4.s")
-void func_80152434(GlobalContext* globalCtx, u16 arg2) {
- globalCtx->msgCtx.unk12046 = 0;
- func_80151DA4(globalCtx, arg2);
+void func_80152434(PlayState* play, u16 arg2) {
+ play->msgCtx.unk12046 = 0;
+ func_80151DA4(play, arg2);
}
-void func_80152464(GlobalContext* globalCtx, u16 arg1) {
- globalCtx->msgCtx.unk12046 = 1;
- func_80151DA4(globalCtx, arg1);
+void func_80152464(PlayState* play, u16 arg1) {
+ play->msgCtx.unk12046 = 1;
+ func_80151DA4(play, arg1);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/Message_GetState.s")
@@ -451,21 +451,21 @@ void func_80152C64(View* view) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80152CAC.s")
// Spawn song effect?
-void func_80152EC0(GlobalContext* globalCtx) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
- Player* player = GET_PLAYER(globalCtx);
+void func_80152EC0(PlayState* play) {
+ MessageContext* msgCtx = &play->msgCtx;
+ Player* player = GET_PLAYER(play);
if (1) {}
if ((msgCtx->songPlayed < 0x17) && (msgCtx->songPlayed != 0xE) &&
((msgCtx->ocarinaAction < 0x43) || (msgCtx->ocarinaAction >= 0x47))) {
msgCtx->unk120B0 = 1;
if (msgCtx->songPlayed != 0x16) {
- Actor_Spawn(&globalCtx->actorCtx, globalCtx, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x,
+ Actor_Spawn(&play->actorCtx, play, D_801D02D8[msgCtx->songPlayed], player->actor.world.pos.x,
player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, D_801D02F8[msgCtx->songPlayed]);
return;
}
- Actor_Spawn(&globalCtx->actorCtx, globalCtx, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x,
- player->actor.world.pos.y, player->actor.world.pos.z, 0, 0, 0, 0);
+ Actor_Spawn(&play->actorCtx, play, ACTOR_OCEFF_WIPE4, player->actor.world.pos.x, player->actor.world.pos.y,
+ player->actor.world.pos.z, 0, 0, 0, 0);
}
}
@@ -473,34 +473,34 @@ void func_80152EC0(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153750.s")
-void func_80153E7C(GlobalContext* globalCtx, void* arg1) {
- if ((gSaveContext.options.language == 0) && (globalCtx->msgCtx.unk12090 == 0)) {
- func_8014ADBC(globalCtx, arg1);
+void func_80153E7C(PlayState* play, void* arg1) {
+ if ((gSaveContext.options.language == 0) && (play->msgCtx.unk12090 == 0)) {
+ func_8014ADBC(play, arg1);
return;
}
- if (globalCtx->msgCtx.unk12090 != 0) {
- func_8015E7EC(globalCtx, arg1);
+ if (play->msgCtx.unk12090 != 0) {
+ func_8015E7EC(play, arg1);
return;
}
- func_8015966C(globalCtx, arg1, 0);
+ func_8015966C(play, arg1, 0);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_80153EF0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_801541D4.s")
-void func_80156758(GlobalContext* globalCtx) {
+void func_80156758(PlayState* play) {
Gfx* nextDisplayList;
Gfx* polyOpa;
- GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
+ GraphicsContext* gfxCtx = play->state.gfxCtx;
OPEN_DISPS(gfxCtx);
polyOpa = POLY_OPA_DISP;
nextDisplayList = Graph_GfxPlusOne(polyOpa);
gSPDisplayList(OVERLAY_DISP++, nextDisplayList);
- if ((globalCtx->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(globalCtx)) {
- func_801541D4(globalCtx, &nextDisplayList);
+ if ((play->msgCtx.currentTextId != 0x5E6) || !Play_InCsMode(play)) {
+ func_801541D4(play, &nextDisplayList);
}
gSPEndDisplayList(nextDisplayList++);
@@ -511,17 +511,17 @@ void func_80156758(GlobalContext* globalCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_message/func_8015680C.s")
-void func_801586A4(GlobalContext* globalCtx) {
- globalCtx->msgCtx.messageEntryTableNes = D_801C6B98;
- globalCtx->msgCtx.messageTableStaff = D_801CFB08;
+void func_801586A4(PlayState* play) {
+ play->msgCtx.messageEntryTableNes = D_801C6B98;
+ play->msgCtx.messageTableStaff = D_801CFB08;
}
-void Message_Init(GlobalContext* globalCtx) {
+void Message_Init(PlayState* play) {
Font* font;
- MessageContext* messageCtx = &globalCtx->msgCtx;
+ MessageContext* messageCtx = &play->msgCtx;
- func_801586A4(globalCtx);
- globalCtx->msgCtx.ocarinaMode = 0;
+ func_801586A4(play);
+ play->msgCtx.ocarinaMode = 0;
messageCtx->msgMode = 0;
messageCtx->unk11F10 = 0;
messageCtx->currentTextId = 0;
@@ -529,10 +529,10 @@ void Message_Init(GlobalContext* globalCtx) {
messageCtx->choiceIndex = 0;
messageCtx->ocarinaAction = messageCtx->unk11FF2 = 0;
messageCtx->unk1201E = 0xFF;
- View_Init(&messageCtx->view, globalCtx->state.gfxCtx);
- messageCtx->unk11EF8 = THA_AllocEndAlign16(&globalCtx->state.heap, 0x13C00);
- font = &globalCtx->msgCtx.font;
- Font_LoadOrderedFont(&globalCtx->msgCtx.font);
+ View_Init(&messageCtx->view, play->state.gfxCtx);
+ messageCtx->unk11EF8 = THA_AllocEndAlign16(&play->state.heap, 0x13C00);
+ font = &play->msgCtx.font;
+ Font_LoadOrderedFont(&play->msgCtx.font);
font->unk_11D88 = 0;
messageCtx->unk12090 = messageCtx->unk12092 = 0;
messageCtx->unk12094 = 0;
diff --git a/src/code/z_message_nes.c b/src/code/z_message_nes.c
index 485f016ff..491427cef 100644
--- a/src/code/z_message_nes.c
+++ b/src/code/z_message_nes.c
@@ -42,8 +42,8 @@ extern u8 D_801D0710[4];
extern u8 D_801D0714[11][16];
extern s16 D_801D07C4[11];
-void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_FindMessageNES(PlayState* play, u16 textId) {
+ MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
MessageTableEntry* msgEntry = msgCtx->messageEntryTableNes;
const char* segment = msgEntry->segment;
@@ -70,12 +70,12 @@ void Message_FindMessageNES(GlobalContext* globalCtx, u16 textId) {
font->messageEnd = nextSegment - foundSegment;
}
-void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadCharNES(PlayState* play, u8 codePointIndex, s32* offset, f32* arg3, s16 decodedBufPos) {
+ MessageContext* msgCtx = &play->msgCtx;
s32 temp1 = *offset;
f32 temp2 = *arg3;
- Font_LoadCharNES(globalCtx, codePointIndex, temp1);
+ Font_LoadCharNES(play, codePointIndex, temp1);
msgCtx->decodedBuffer.schar[decodedBufPos] = codePointIndex;
temp1 += FONT_CHAR_TEX_SIZE;
temp2 += (16.0f * msgCtx->unk12098);
@@ -83,35 +83,35 @@ void Message_LoadCharNES(GlobalContext* globalCtx, u8 codePointIndex, s32* offse
*arg3 = temp2;
}
-void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadPluralRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) {
+ MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
msgCtx->decodedBuffer.schar[p] = 0x20;
p++;
- Font_LoadCharNES(globalCtx, 'R', o);
+ Font_LoadCharNES(play, 'R', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'R';
p++;
- Font_LoadCharNES(globalCtx, 'u', o);
+ Font_LoadCharNES(play, 'u', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'u';
p++;
- Font_LoadCharNES(globalCtx, 'p', o);
+ Font_LoadCharNES(play, 'p', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'p';
p++;
- Font_LoadCharNES(globalCtx, 'e', o);
+ Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
p++;
- Font_LoadCharNES(globalCtx, 'e', o);
+ Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
p++;
- Font_LoadCharNES(globalCtx, 's', o);
+ Font_LoadCharNES(play, 's', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 's';
@@ -121,8 +121,8 @@ void Message_LoadPluralRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s
*arg3 = f;
}
-void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadLocalizedRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) {
+ MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
@@ -132,7 +132,7 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos
p++;
for (j = 0; j < D_801D0710[gSaveContext.options.language - 1]; j++) {
- Font_LoadCharNES(globalCtx, D_801D06F0[gSaveContext.options.language - 1][j], o);
+ Font_LoadCharNES(play, D_801D06F0[gSaveContext.options.language - 1][j], o);
msgCtx->decodedBuffer.schar[p] = D_801D06F0[gSaveContext.options.language - 1][j];
o += FONT_CHAR_TEX_SIZE;
p++;
@@ -145,37 +145,37 @@ void Message_LoadLocalizedRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos
*arg3 = f;
}
-void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadRupeesNES(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3, s16 singular) {
+ MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
msgCtx->decodedBuffer.schar[p] = ' ';
p++;
- Font_LoadCharNES(globalCtx, 'R', o);
+ Font_LoadCharNES(play, 'R', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'R';
p++;
- Font_LoadCharNES(globalCtx, 'u', o);
+ Font_LoadCharNES(play, 'u', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'u';
p++;
- Font_LoadCharNES(globalCtx, 'p', o);
+ Font_LoadCharNES(play, 'p', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'p';
p++;
- Font_LoadCharNES(globalCtx, 'e', o);
+ Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
p++;
- Font_LoadCharNES(globalCtx, 'e', o);
+ Font_LoadCharNES(play, 'e', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 'e';
if (singular != 1) {
p++;
- Font_LoadCharNES(globalCtx, 's', o);
+ Font_LoadCharNES(play, 's', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = 's';
f += 16.0f * msgCtx->unk12098 * 6.0f;
@@ -188,8 +188,8 @@ void Message_LoadRupeesNES(GlobalContext* globalCtx, s16* decodedBufPos, s32* of
*arg3 = f;
}
-void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadTimeNES(PlayState* play, u8 arg1, s32* offset, f32* arg3, s16* decodedBufPos) {
+ MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg3;
@@ -225,12 +225,12 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar
}
for (i = 0; i < 4; i++) {
- Font_LoadCharNES(globalCtx, digits[i] + '0', o);
+ Font_LoadCharNES(play, digits[i] + '0', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = digits[i] + '0';
p++;
if (i == 1) {
- Font_LoadCharNES(globalCtx, ':', o);
+ Font_LoadCharNES(play, ':', o);
o += FONT_CHAR_TEX_SIZE;
msgCtx->decodedBuffer.schar[p] = ':';
p++;
@@ -243,8 +243,8 @@ void Message_LoadTimeNES(GlobalContext* globalCtx, u8 arg1, s32* offset, f32* ar
*arg3 = f;
}
-void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s16* decodedBufPos) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_LoadAreaTextNES(PlayState* play, s32* offset, f32* arg2, s16* decodedBufPos) {
+ MessageContext* msgCtx = &play->msgCtx;
s16 p = *decodedBufPos;
s32 o = *offset;
f32 f = *arg2;
@@ -253,10 +253,10 @@ void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s
s16 currentArea;
s16 stringLimit;
- if ((func_8010A0A4(globalCtx) != 0) || (globalCtx->sceneNum == SCENE_SECOM)) {
+ if ((func_8010A0A4(play) != 0) || (play->sceneNum == SCENE_SECOM)) {
currentArea = 10;
} else {
- currentArea = globalCtx->pauseCtx.unk_238[4];
+ currentArea = play->pauseCtx.unk_238[4];
}
stringLimit = D_801D07C4[currentArea];
@@ -264,7 +264,7 @@ void Message_LoadAreaTextNES(GlobalContext* globalCtx, s32* offset, f32* arg2, s
msgCtx->decodedBuffer.schar[p] = D_801D0714[currentArea][i];
currentChar = msgCtx->decodedBuffer.schar[p];
if (currentChar != ' ') {
- Font_LoadCharNES(globalCtx, D_801D0714[currentArea][i], o);
+ Font_LoadCharNES(play, D_801D0714[currentArea][i], o);
o += FONT_CHAR_TEX_SIZE;
}
currentChar = msgCtx->decodedBuffer.schar[p];
diff --git a/src/code/z_message_staff.c b/src/code/z_message_staff.c
index 6620f88d5..ab30a3d9c 100644
--- a/src/code/z_message_staff.c
+++ b/src/code/z_message_staff.c
@@ -1,8 +1,8 @@
#include "global.h"
#include "message_data_static.h"
-void Message_FindCreditsMessage(GlobalContext* globalCtx, u16 textId) {
- MessageContext* msgCtx = &globalCtx->msgCtx;
+void Message_FindCreditsMessage(PlayState* play, u16 textId) {
+ MessageContext* msgCtx = &play->msgCtx;
Font* font = &msgCtx->font;
MessageTableEntry* msgEntry = msgCtx->messageTableStaff;
const char* segment = msgEntry->segment;
diff --git a/src/code/z_path.c b/src/code/z_path.c
index 0462a40cd..3c446d49a 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 7d13ee8ee..e9f5803d2 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -58,8 +58,8 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/Play_Update.s")
-s32 Play_InCsMode(GlobalContext* globalCtx) {
- return (globalCtx->csCtx.state != 0) || Player_InCsMode(&globalCtx->state);
+s32 Play_InCsMode(PlayState* this) {
+ return (this->csCtx.state != 0) || Player_InCsMode(&this->state);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_play/func_80169100.s")
@@ -154,113 +154,113 @@ s16 Play_GetOriginalSceneNumber(s16 sceneNum) {
* Copies the flags set in ActorContext over to the current scene's CycleSceneFlags, usually using the original scene
* number. Exception for Inverted Stone Tower Temple, which uses its own.
*/
-void Play_SaveCycleSceneFlags(GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+void Play_SaveCycleSceneFlags(GameState* thisx) {
+ PlayState* this = (PlayState*)thisx;
CycleSceneFlags* cycleSceneFlags;
- cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(globalCtx->sceneNum)];
- cycleSceneFlags->chest = globalCtx->actorCtx.flags.chest;
- cycleSceneFlags->switch0 = globalCtx->actorCtx.flags.switches[0];
- cycleSceneFlags->switch1 = globalCtx->actorCtx.flags.switches[1];
+ cycleSceneFlags = &gSaveContext.cycleSceneFlags[Play_GetOriginalSceneNumber(this->sceneNum)];
+ cycleSceneFlags->chest = this->actorCtx.flags.chest;
+ cycleSceneFlags->switch0 = this->actorCtx.flags.switches[0];
+ cycleSceneFlags->switch1 = this->actorCtx.flags.switches[1];
- if (globalCtx->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple
- cycleSceneFlags = &gSaveContext.cycleSceneFlags[globalCtx->sceneNum];
+ if (this->sceneNum == SCENE_INISIE_R) { // Inverted Stone Tower Temple
+ cycleSceneFlags = &gSaveContext.cycleSceneFlags[this->sceneNum];
}
- cycleSceneFlags->collectible = globalCtx->actorCtx.flags.collectible[0];
- cycleSceneFlags->clearedRoom = globalCtx->actorCtx.flags.clearedRoom;
+ cycleSceneFlags->collectible = this->actorCtx.flags.collectible[0];
+ cycleSceneFlags->clearedRoom = this->actorCtx.flags.clearedRoom;
}
-void Play_SetRespawnData(GameState* gameState, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams,
+void Play_SetRespawnData(GameState* thisx, s32 respawnMode, u16 entranceIndex, s32 roomIndex, s32 playerParams,
Vec3f* pos, s16 yaw) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+ PlayState* this = (PlayState*)thisx;
gSaveContext.respawn[respawnMode].entranceIndex = Entrance_CreateIndex(entranceIndex >> 9, 0, entranceIndex & 0xF);
gSaveContext.respawn[respawnMode].roomIndex = roomIndex;
gSaveContext.respawn[respawnMode].pos = *pos;
gSaveContext.respawn[respawnMode].yaw = yaw;
gSaveContext.respawn[respawnMode].playerParams = playerParams;
- gSaveContext.respawn[respawnMode].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2];
- gSaveContext.respawn[respawnMode].unk_18 = globalCtx->actorCtx.flags.collectible[1];
- gSaveContext.respawn[respawnMode].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2];
+ gSaveContext.respawn[respawnMode].tempSwitchFlags = this->actorCtx.flags.switches[2];
+ gSaveContext.respawn[respawnMode].unk_18 = this->actorCtx.flags.collectible[1];
+ gSaveContext.respawn[respawnMode].tempCollectFlags = this->actorCtx.flags.collectible[2];
}
-void Play_SetupRespawnPoint(GameState* gameState, s32 respawnMode, s32 playerParams) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
- Player* player = GET_PLAYER(globalCtx);
+void Play_SetupRespawnPoint(GameState* thisx, s32 respawnMode, s32 playerParams) {
+ PlayState* this = (PlayState*)thisx;
+ Player* player = GET_PLAYER(this);
- if (globalCtx->sceneNum != SCENE_KAKUSIANA) { // Grottos
- Play_SetRespawnData(&globalCtx->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex),
- globalCtx->roomCtx.currRoom.num, playerParams, &player->actor.world.pos,
+ if (this->sceneNum != SCENE_KAKUSIANA) { // Grottos
+ Play_SetRespawnData(&this->state, respawnMode, (u16)((void)0, gSaveContext.save.entranceIndex),
+ this->roomCtx.currRoom.num, playerParams, &player->actor.world.pos,
player->actor.shape.rot.y);
}
}
// Override respawn data in Sakon's Hideout
-void func_80169ECC(GlobalContext* globalCtx) {
- if (globalCtx->sceneNum == SCENE_SECOM) {
- globalCtx->nextEntranceIndex = 0x2060;
+void func_80169ECC(PlayState* this) {
+ if (this->sceneNum == SCENE_SECOM) {
+ this->nextEntranceIndex = 0x2060;
gSaveContext.respawnFlag = -7;
}
}
// Gameplay_TriggerVoidOut ?
// Used by Player, Ikana_Rotaryroom, Bji01, Kakasi, LiftNuts, Test4, Warptag, WarpUzu, Roomtimer
-void func_80169EFC(GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+void func_80169EFC(GameState* thisx) {
+ PlayState* this = (PlayState*)thisx;
- gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = globalCtx->actorCtx.flags.switches[2];
- gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = globalCtx->actorCtx.flags.collectible[1];
- gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = globalCtx->actorCtx.flags.collectible[2];
- globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex;
+ gSaveContext.respawn[RESTART_MODE_DOWN].tempSwitchFlags = this->actorCtx.flags.switches[2];
+ gSaveContext.respawn[RESTART_MODE_DOWN].unk_18 = this->actorCtx.flags.collectible[1];
+ gSaveContext.respawn[RESTART_MODE_DOWN].tempCollectFlags = this->actorCtx.flags.collectible[2];
+ this->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_DOWN].entranceIndex;
gSaveContext.respawnFlag = 1;
- func_80169ECC(globalCtx);
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 2;
+ func_80169ECC(this);
+ this->sceneLoadFlag = 0x14;
+ this->unk_1887F = 2;
}
// Gameplay_LoadToLastEntrance ?
// Used by game_over and Test7
-void func_80169F78(GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+void func_80169F78(GameState* thisx) {
+ PlayState* this = (PlayState*)thisx;
- globalCtx->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex;
+ this->nextEntranceIndex = gSaveContext.respawn[RESTART_MODE_TOP].entranceIndex;
gSaveContext.respawnFlag = -1;
- func_80169ECC(globalCtx);
- globalCtx->sceneLoadFlag = 0x14;
- globalCtx->unk_1887F = 2;
+ func_80169ECC(this);
+ this->sceneLoadFlag = 0x14;
+ this->unk_1887F = 2;
}
// Gameplay_TriggerRespawn ?
// Used for void by Wallmaster, Deku Shrine doors. Also used by Player, Kaleido, DoorWarp1
-void func_80169FDC(GameState* gameState) {
- func_80169F78(gameState);
+void func_80169FDC(GameState* thisx) {
+ func_80169F78(thisx);
}
// Used by Kankyo to determine how to change the lighting, e.g. for game over.
-s32 func_80169FFC(GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+s32 func_80169FFC(GameState* thisx) {
+ PlayState* this = (PlayState*)thisx;
- return globalCtx->roomCtx.currRoom.mesh->type0.type != 1;
+ return this->roomCtx.currRoom.mesh->type0.type != 1;
}
-s32 FrameAdvance_IsEnabled(GameState* gameState) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+s32 FrameAdvance_IsEnabled(GameState* thisx) {
+ PlayState* this = (PlayState*)thisx;
- return globalCtx->frameAdvCtx.enabled != 0;
+ return this->frameAdvCtx.enabled != 0;
}
// Unused, unchanged from OoT, which uses it only in one Camera function.
/**
* @brief Tests if \p actor is a door and the sides are different rooms.
*
- * @param[in] gameState GameState, promoted to globalCtx inside.
+ * @param[in] thisx GameState, promoted to play inside.
* @param[in] actor Actor to test.
* @param[out] yaw Facing angle of the actor, or reverse if in the back room.
* @return true if \p actor is a door and the sides are in different rooms, false otherwise
*/
-s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+s32 func_8016A02C(GameState* thisx, Actor* actor, s16* yaw) {
+ PlayState* this = (PlayState*)thisx;
TransitionActorEntry* transitionActor;
s8 frontRoom;
@@ -268,7 +268,7 @@ s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
return false;
}
- transitionActor = &globalCtx->doorCtx.transitionActorList[(u16)actor->params >> 10];
+ transitionActor = &this->doorCtx.transitionActorList[(u16)actor->params >> 10];
frontRoom = transitionActor->sides[0].room;
if (frontRoom == transitionActor->sides[1].room) {
return false;
@@ -287,11 +287,11 @@ s32 func_8016A02C(GameState* gameState, Actor* actor, s16* yaw) {
/**
* @brief Tests if \p pos is underwater.
*
- * @param[in] globalCtx GlobalContext
+ * @param[in] play PlayState
* @param[in] pos position to test
* @return true if inside a waterbox and not above a void.
*/
-s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) {
+s32 Play_IsUnderwater(PlayState* this, Vec3f* pos) {
WaterBox* waterBox;
CollisionPoly* poly;
Vec3f waterSurfacePos;
@@ -299,10 +299,10 @@ s32 Play_IsUnderwater(GlobalContext* globalCtx, Vec3f* pos) {
waterSurfacePos = *pos;
- if ((WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
+ if ((WaterBox_GetSurface1(this, &this->colCtx, waterSurfacePos.x, waterSurfacePos.z, &waterSurfacePos.y,
&waterBox) == true) &&
(pos->y < waterSurfacePos.y) &&
- (BgCheck_EntityRaycastFloor3(&globalCtx->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) {
+ (BgCheck_EntityRaycastFloor3(&this->colCtx, &poly, &bgId, &waterSurfacePos) != BGCHECK_Y_MIN)) {
return true;
} else {
return false;
@@ -320,17 +320,17 @@ extern s16 D_801D0D64[];
// Used by Player
/**
* Extract the common actor cutscene ids used by Player from the scene and set the actor cutscene ids in
- * globalCtx->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set
+ * this->playerActorCsIds. If a playerActorCsId is not present in the scene, then that particular id is set
* to -1. Otherwise, if there is an ActorCutscene where csCamSceneDataId matches the appropriate element of D_801D0D64,
* set the corresponding playerActorCsId (and possibly change its priority for the zeroth one)
*/
-void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCsId) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+void Play_AssignPlayerActorCsIdsFromScene(GameState* thisx, s32 startActorCsId) {
+ PlayState* this = (PlayState*)thisx;
s32 i;
- s16* curPlayerActorCsId = globalCtx->playerActorCsIds;
+ s16* curPlayerActorCsId = this->playerActorCsIds;
s16* phi_s1 = D_801D0D64;
- for (i = 0; i < ARRAY_COUNT(globalCtx->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) {
+ for (i = 0; i < ARRAY_COUNT(this->playerActorCsIds); i++, curPlayerActorCsId++, phi_s1++) {
ActorCutscene* actorCutscene;
s32 curActorCsId;
@@ -352,7 +352,7 @@ void Play_AssignPlayerActorCsIdsFromScene(GameState* gameState, s32 startActorCs
}
// These regs are used by Gameplay_Draw, and several actors, purpose as yet unclear.
-void func_8016A268(GameState* gameState, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) {
+void func_8016A268(GameState* thisx, s16 arg1, u8 arg2, u8 arg3, u8 arg4, u8 arg5) {
MREG(64) = arg1;
MREG(65) = arg2;
MREG(66) = arg3;
diff --git a/src/code/z_player_call.c b/src/code/z_player_call.c
index 7ed1ce5ce..8cd8207b7 100644
--- a/src/code/z_player_call.c
+++ b/src/code/z_player_call.c
@@ -9,10 +9,10 @@ ActorFunc sPlayerCallDestroyFunc;
ActorFunc sPlayerCallUpdateFunc;
ActorFunc sPlayerCallDrawFunc;
-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);
const ActorInit Player_InitVars = {
ACTOR_PLAYER,
@@ -26,10 +26,10 @@ const ActorInit Player_InitVars = {
(ActorFunc)PlayerCall_Draw,
};
-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);
void PlayerCall_InitFuncPtrs(void) {
sPlayerCallInitFunc = KaleidoManager_GetRamAddr(Player_Init);
@@ -38,23 +38,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_quake.c b/src/code/z_quake.c
index d57dc8e54..2ada2ba78 100644
--- a/src/code/z_quake.c
+++ b/src/code/z_quake.c
@@ -303,7 +303,7 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
s32 ret;
u32 eq;
Vec3f originVec;
- GlobalContext* globalCtx = camera->globalCtx;
+ PlayState* play = camera->play;
originVec.x = 0.0f;
originVec.y = 0.0f;
@@ -326,7 +326,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->camId] == NULL) {
+ if (play->cameraPtrs[req->camId] == NULL) {
Quake_Remove(req);
} else {
eq = (camera->camId != req->camera->camId);
@@ -382,9 +382,9 @@ s16 Quake_Calc(Camera* camera, QuakeCamCalc* camData) {
return ret;
}
-void Distortion_Init(GlobalContext* globalCtx) {
- sDistortionContext.globalCtx = globalCtx;
- View_ClearDistortion(&globalCtx->view);
+void Distortion_Init(PlayState* play) {
+ sDistortionContext.play = play;
+ View_ClearDistortion(&play->view);
sDistortionContext.type = 0;
sDistortionContext.countdown = 0;
sDistortionContext.state = DISTORTION_INACTIVE;
@@ -419,9 +419,9 @@ void Distortion_ClearType(s32 type) {
* Checks that the bg surface is an underwater conveyor type and if so, returns the conveyor speed
*/
s32 Distortion_GetUnderwaterCurrentSpeed(Player* player) {
- if (SurfaceType_GetConveyorType(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly,
+ if (SurfaceType_GetConveyorType(&sDistortionContext.play->colCtx, player->actor.floorPoly,
player->actor.floorBgId) == CONVEYOR_WATER) {
- return SurfaceType_GetConveyorSpeed(&sDistortionContext.globalCtx->colCtx, player->actor.floorPoly,
+ return SurfaceType_GetConveyorSpeed(&sDistortionContext.play->colCtx, player->actor.floorPoly,
player->actor.floorBgId);
}
return 0;
@@ -446,9 +446,9 @@ void Distortion_Update(void) {
f32 zScale;
f32 speed;
Player* player;
- GlobalContext* globalCtx = sDistortionContext.globalCtx;
+ PlayState* play = sDistortionContext.play;
PosRot playerPosRot;
- Camera* camera = GET_ACTIVE_CAM(globalCtx);
+ Camera* camera = GET_ACTIVE_CAM(play);
f32 speedRatio = CLAMP_MAX(camera->speedRatio, 1.0f);
if (sDistortionContext.type != 0) {
@@ -636,7 +636,7 @@ void Distortion_Update(void) {
screenPlanePhase = 0x156;
sDistortionContext.countdown = 2;
- player = GET_PLAYER(globalCtx);
+ player = GET_PLAYER(play);
if (player != NULL) {
Actor_GetWorldPosShapeRot(&playerPosRot, &player->actor);
@@ -688,7 +688,7 @@ void Distortion_Update(void) {
screenPlanePhase = 0x156;
sDistortionContext.countdown = 2;
- player = GET_PLAYER(globalCtx);
+ player = GET_PLAYER(play);
depthPhaseStep = 359.2f;
screenPlanePhaseStep = -18.5f;
@@ -759,20 +759,20 @@ void Distortion_Update(void) {
depthPhase += DEGF_TO_BINANG(depthPhaseStep);
screenPlanePhase += DEGF_TO_BINANG(screenPlanePhaseStep);
- View_SetDistortionDirRot(&sDistortionContext.globalCtx->view,
+ View_SetDistortionDirRot(&sDistortionContext.play->view,
Math_CosS(depthPhase) * (DEGF_TO_RADF(rotX) * xyScaleFactor),
Math_SinS(depthPhase) * (DEGF_TO_RADF(rotY) * xyScaleFactor),
Math_SinS(screenPlanePhase) * (DEGF_TO_RADF(rotZ) * zScaleFactor));
- View_SetDistortionScale(&sDistortionContext.globalCtx->view,
+ View_SetDistortionScale(&sDistortionContext.play->view,
(Math_SinS(screenPlanePhase) * (xScale * xyScaleFactor)) + 1.0f,
(Math_CosS(screenPlanePhase) * (yScale * xyScaleFactor)) + 1.0f,
(Math_CosS(depthPhase) * (zScale * zScaleFactor)) + 1.0f);
- View_SetDistortionSpeed(&sDistortionContext.globalCtx->view, speed * speedScaleFactor);
+ View_SetDistortionSpeed(&sDistortionContext.play->view, speed * speedScaleFactor);
sDistortionContext.state = DISTORTION_ACTIVE;
} else if (sDistortionContext.state != DISTORTION_INACTIVE) {
- View_ClearDistortion(&globalCtx->view);
+ View_ClearDistortion(&play->view);
sDistortionContext.state = DISTORTION_INACTIVE;
sDistortionContext.countdown = 0;
diff --git a/src/code/z_rcp.c b/src/code/z_rcp.c
index 1d13be316..ace1cc4cd 100644
--- a/src/code/z_rcp.c
+++ b/src/code/z_rcp.c
@@ -896,8 +896,8 @@ void func_8012C240(GraphicsContext* gfxCtx) {
gSPDisplayList(gfxCtx->polyXlu.p++, &sSetupDL[6 * 0x19]);
}
-void func_8012C268(GlobalContext* globalCtx) {
- func_8012C28C(globalCtx->state.gfxCtx);
+void func_8012C268(PlayState* play) {
+ func_8012C28C(play->state.gfxCtx);
}
void func_8012C28C(GraphicsContext* gfxCtx) {
diff --git a/src/code/z_room.c b/src/code/z_room.c
index 7579c6200..d3b88bd5d 100644
--- a/src/code/z_room.c
+++ b/src/code/z_room.c
@@ -1,30 +1,30 @@
#include "global.h"
-void Room_nop8012D510(GlobalContext* globalCtx, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) {
+void Room_nop8012D510(PlayState* play, Room* room, UNK_PTR param_3, UNK_TYPE1 param_4) {
}
-void Room_DrawType3Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
+void Room_DrawType3Mesh(PlayState* play, Room* room, u32 flags) {
}
-void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
+void Room_DrawType0Mesh(PlayState* play, Room* room, u32 flags) {
RoomMeshType0* mesh;
s32 i;
RoomMeshType0Params* meshParams;
GraphicsContext* gfxCtx;
UNK_TYPE4 pad;
- gfxCtx = globalCtx->state.gfxCtx;
+ gfxCtx = play->state.gfxCtx;
if (flags & 1) {
- func_800BCBF4(&D_801C1D10, globalCtx);
+ func_800BCBF4(&D_801C1D10, play);
gSPSegment(gfxCtx->polyOpa.p++, 0x03, room->segment);
- func_8012C268(globalCtx);
+ func_8012C268(play);
gSPMatrix(gfxCtx->polyOpa.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD);
}
if (flags & 2) {
- func_800BCC68(&D_801C1D10, globalCtx);
+ func_800BCC68(&D_801C1D10, play);
gSPSegment(gfxCtx->polyXlu.p++, 0x03, room->segment);
- func_8012C2DC(globalCtx->state.gfxCtx);
+ func_8012C2DC(play->state.gfxCtx);
gSPMatrix(gfxCtx->polyXlu.p++, &gIdentityMtx, G_MTX_MODELVIEW | G_MTX_LOAD);
}
@@ -51,18 +51,18 @@ void Room_DrawType0Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/func_8012E32C.s")
-void Room_DrawType1Mesh(GlobalContext* globalCtx, Room* room, u32 flags) {
+void Room_DrawType1Mesh(PlayState* play, Room* room, u32 flags) {
RoomMeshType1* mesh = &room->mesh->type1;
if (mesh->format == 1) {
- func_8012DEE8(globalCtx, room, flags);
+ func_8012DEE8(play, room, flags);
} else if (mesh->format == 2) {
- func_8012E32C(globalCtx, room, flags);
+ func_8012E32C(play, room, flags);
} else {
__assert("../z_room.c", 0x3c5);
}
}
-void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) {
+void Room_Init(PlayState* play, RoomContext* roomCtx) {
s32 i;
roomCtx->currRoom.num = -1;
roomCtx->currRoom.segment = NULL;
@@ -75,7 +75,7 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) {
#pragma GLOBAL_ASM("asm/non_matchings/code/z_room/Room_AllocateAndLoad.s")
-s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) {
+s32 Room_StartRoomTransition(PlayState* play, RoomContext* roomCtx, s32 index) {
if (roomCtx->unk31 == 0) {
s32 size;
@@ -84,14 +84,14 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32
roomCtx->currRoom.segment = NULL;
roomCtx->unk31 = 1;
- size = globalCtx->roomList[index].vromEnd - globalCtx->roomList[index].vromStart;
+ size = play->roomList[index].vromEnd - play->roomList[index].vromStart;
roomCtx->activeRoomVram =
(void*)(((s32)roomCtx->roomMemPages[roomCtx->activeMemPage] - (size + 8) * roomCtx->activeMemPage + 8) &
0xfffffff0);
osCreateMesgQueue(&roomCtx->loadQueue, roomCtx->loadMsg, 1);
- DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, globalCtx->roomList[index].vromStart,
- size, 0, &roomCtx->loadQueue, NULL);
+ DmaMgr_SendRequestImpl(&roomCtx->dmaRequest, roomCtx->activeRoomVram, play->roomList[index].vromStart, size, 0,
+ &roomCtx->loadQueue, NULL);
roomCtx->activeMemPage ^= 1;
return 1;
@@ -100,7 +100,7 @@ s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32
return 0;
}
-s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) {
+s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) {
if (roomCtx->unk31 == 1) {
if (!osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK)) {
roomCtx->unk31 = 0;
@@ -108,18 +108,18 @@ s32 Room_HandleLoadCallbacks(GlobalContext* globalCtx, RoomContext* roomCtx) {
// TODO: Segment number enum
gSegments[0x03] = PHYSICAL_TO_VIRTUAL(roomCtx->activeRoomVram);
- Scene_ProcessHeader(globalCtx, (SceneCmd*)roomCtx->currRoom.segment);
- func_80123140(globalCtx, GET_PLAYER(globalCtx));
- Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx);
+ Scene_ProcessHeader(play, (SceneCmd*)roomCtx->currRoom.segment);
+ func_80123140(play, GET_PLAYER(play));
+ Actor_SpawnTransitionActors(play, &play->actorCtx);
- if (((globalCtx->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) &&
- (globalCtx->sceneNum != SCENE_IKNINSIDE)) {
- globalCtx->envCtx.lightSettingOverride = 0xff;
- globalCtx->envCtx.unk_E0 = 0;
+ if (((play->sceneNum != SCENE_IKANA) || (roomCtx->currRoom.num != 1)) &&
+ (play->sceneNum != SCENE_IKNINSIDE)) {
+ play->envCtx.lightSettingOverride = 0xff;
+ play->envCtx.unk_E0 = 0;
}
func_800FEAB0();
- if (!func_800FE4B8(globalCtx)) {
- func_800FD858(globalCtx);
+ if (!func_800FE4B8(play)) {
+ func_800FD858(play);
}
} else {
return 0;
@@ -129,23 +129,23 @@ s32 Room_HandleLoadCallbacks(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) {
// TODO: Segment number enum
gSegments[0x03] = PHYSICAL_TO_VIRTUAL(room->segment);
- roomDrawFuncs[room->mesh->type0.type](globalCtx, room, flags);
+ roomDrawFuncs[room->mesh->type0.type](play, room, flags);
}
return;
}
-void func_8012EBF8(GlobalContext* globalCtx, RoomContext* roomCtx) {
+void func_8012EBF8(PlayState* play, RoomContext* roomCtx) {
roomCtx->prevRoom.num = -1;
roomCtx->prevRoom.segment = NULL;
- func_800BA798(globalCtx, &globalCtx->actorCtx);
- Actor_SpawnTransitionActors(globalCtx, &globalCtx->actorCtx);
+ func_800BA798(play, &play->actorCtx);
+ Actor_SpawnTransitionActors(play, &play->actorCtx);
if (-1 < roomCtx->currRoom.num) {
- func_8010A33C(globalCtx, roomCtx->currRoom.num);
- func_8010A2DC(globalCtx);
+ func_8010A33C(play, roomCtx->currRoom.num);
+ func_8010A2DC(play);
}
- func_801A3CD8(globalCtx->roomCtx.currRoom.echo);
+ func_801A3CD8(play->roomCtx.currRoom.echo);
}
diff --git a/src/code/z_rumble.c b/src/code/z_rumble.c
new file mode 100644
index 000000000..ce5cc16b4
--- /dev/null
+++ b/src/code/z_rumble.c
@@ -0,0 +1,104 @@
+/*
+ * File: z_rumble.c
+ * Description: Rumble request system
+ *
+ * Provides a simple interface to allow scheduling up to RUMBLE_REQUEST_BUFFER_SIZE rumble requests to the RumblePak.
+ * There's an additional Override type of rumble request for requests which should take priorities over any other
+ * scheduled request.
+ */
+
+#include "global.h"
+#include "z64rumble.h"
+
+RumbleManager gRumbleMgr;
+
+void Rumble_Update(void* arg0) {
+ RumbleManager_Update(&gRumbleMgr);
+ PadMgr_RumbleSet(gRumbleMgr.rumbleEnabled);
+}
+
+// Used by some bosses (and fishing)
+void Rumble_Override(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) {
+ s32 intensity;
+ s32 distance;
+
+ if (SQ(1000.0f) < distSq) {
+ distance = 1000;
+ } else {
+ distance = sqrtf(distSq);
+ }
+
+ if ((distance < 1000) && (sourceIntensity != 0) && (decayStep != 0)) {
+ intensity = sourceIntensity - (distance * 255) / 1000;
+
+ if (intensity > 0) {
+ gRumbleMgr.overrideIntensity = intensity;
+ gRumbleMgr.overrideDecayTimer = decayTimer;
+ gRumbleMgr.overrideDecayStep = decayStep;
+ }
+ }
+}
+
+void Rumble_Request(f32 distSq, u8 sourceIntensity, u8 decayTimer, u8 decayStep) {
+ s32 intensity;
+ s32 distance;
+ s32 i;
+
+ if (SQ(1000.0f) < distSq) {
+ distance = 1000;
+ } else {
+ distance = sqrtf(distSq);
+ }
+
+ if ((distance < 1000) && (sourceIntensity != 0) && (decayStep != 0)) {
+ intensity = sourceIntensity - (distance * 255) / 1000;
+
+ for (i = 0; i < RUMBLE_REQUEST_BUFFER_SIZE; i++) {
+ if (gRumbleMgr.requestIntensities[i] == 0) {
+ if (intensity > 0) {
+ gRumbleMgr.requestIntensities[i] = intensity;
+ gRumbleMgr.requestDecayTimers[i] = decayTimer;
+ gRumbleMgr.requestDecaySteps[i] = decayStep;
+ }
+ break;
+ }
+ }
+ }
+}
+
+void Rumble_Init(void) {
+ RumbleManager_Init(&gRumbleMgr);
+ func_80174F24(Rumble_Update, NULL);
+}
+
+void Rumble_Destroy(void) {
+ func_80174F44(Rumble_Update, NULL);
+ RumbleManager_Destroy(&gRumbleMgr);
+}
+
+s32 Rumble_ControllerOneHasRumblePak(void) {
+ return PadMgr_ControllerHasRumblePak(0);
+}
+
+/**
+ * Wipes every old request for a fresh start, then proceeds to process them as normal
+ */
+void Rumble_StateReset(void) {
+ gRumbleMgr.state = RUMBLEMANAGER_STATE_INITIAL;
+}
+
+/**
+ * Changes the state of the manager to WIPE
+ *
+ * In this state, every request is deleted
+ */
+void Rumble_StateWipeRequests(void) {
+ gRumbleMgr.state = RUMBLEMANAGER_STATE_WIPE;
+}
+
+/**
+ * Request processing is paused if updateEnabled is set to false
+ */
+void Rumble_SetUpdateEnabled(s32 updateEnabled) {
+ gRumbleMgr.updateEnabled = !!updateEnabled;
+}
diff --git a/src/code/z_scene.c b/src/code/z_scene.c
index b9dbb35dd..7d2c4301b 100644
--- a/src/code/z_scene.c
+++ b/src/code/z_scene.c
@@ -23,17 +23,17 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) {
}
void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+ PlayState* play = (PlayState*)gameState;
s32 pad;
u32 spaceSize;
s32 i;
- if (globalCtx->sceneNum == SCENE_CLOCKTOWER || globalCtx->sceneNum == SCENE_TOWN ||
- globalCtx->sceneNum == SCENE_BACKTOWN || globalCtx->sceneNum == SCENE_ICHIBA) {
+ if (play->sceneNum == SCENE_CLOCKTOWER || play->sceneNum == SCENE_TOWN || play->sceneNum == SCENE_BACKTOWN ||
+ play->sceneNum == SCENE_ICHIBA) {
spaceSize = OBJECT_SPACE_SIZE_CLOCK_TOWN;
- } else if (globalCtx->sceneNum == SCENE_MILK_BAR) {
+ } else if (play->sceneNum == SCENE_MILK_BAR) {
spaceSize = OBJECT_SPACE_SIZE_MILK_BAR;
- } else if (globalCtx->sceneNum == SCENE_00KEIKOKU) {
+ } else if (play->sceneNum == SCENE_00KEIKOKU) {
spaceSize = OBJECT_SPACE_SIZE_TERMINA_FIELD;
} else {
spaceSize = OBJECT_SPACE_SIZE_DEFAULT;
@@ -141,45 +141,45 @@ void* func_8012F73C(ObjectContext* objectCtx, s32 iParm2, s16 id) {
}
// SceneTableEntry Header Command 0x00: Spawn List
-void Scene_HeaderCmdSpawnList(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdSpawnList(PlayState* play, SceneCmd* cmd) {
s32 loadedCount;
s16 playerObjectId;
void* nextObject;
- globalCtx->linkActorEntry = (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) +
- globalCtx->setupEntranceList[globalCtx->curSpawn].spawn;
- if ((globalCtx->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
+ play->linkActorEntry =
+ (ActorEntry*)Lib_SegmentedToVirtual(cmd->spawnList.segment) + play->setupEntranceList[play->curSpawn].spawn;
+ if ((play->linkActorEntry->params & 0x0F00) >> 8 == 0x0C ||
(gSaveContext.respawnFlag == 0x02 && gSaveContext.respawn[RESTART_MODE_RETURN].playerParams == 0x0CFF)) {
// Skull Kid Object
- Object_Spawn(&globalCtx->objectCtx, OBJECT_STK);
+ Object_Spawn(&play->objectCtx, OBJECT_STK);
return;
}
- loadedCount = Object_Spawn(&globalCtx->objectCtx, OBJECT_LINK_CHILD);
- nextObject = globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment;
- globalCtx->objectCtx.num = loadedCount;
- globalCtx->objectCtx.spawnedObjectCount = loadedCount;
+ loadedCount = Object_Spawn(&play->objectCtx, OBJECT_LINK_CHILD);
+ nextObject = play->objectCtx.status[play->objectCtx.num].segment;
+ play->objectCtx.num = loadedCount;
+ play->objectCtx.spawnedObjectCount = loadedCount;
playerObjectId = gLinkFormObjectIndexes[(void)0, gSaveContext.save.playerForm];
gActorOverlayTable[0].initInfo->objectId = playerObjectId;
- Object_Spawn(&globalCtx->objectCtx, playerObjectId);
+ Object_Spawn(&play->objectCtx, playerObjectId);
- globalCtx->objectCtx.status[globalCtx->objectCtx.num].segment = nextObject;
+ play->objectCtx.status[play->objectCtx.num].segment = nextObject;
}
// SceneTableEntry Header Command 0x01: Actor List
-void Scene_HeaderCmdActorList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->numSetupActors = cmd->actorList.num;
- globalCtx->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment);
- globalCtx->actorCtx.unkC = 0;
+void Scene_HeaderCmdActorList(PlayState* play, SceneCmd* cmd) {
+ play->numSetupActors = cmd->actorList.num;
+ play->setupActorList = Lib_SegmentedToVirtual(cmd->actorList.segment);
+ play->actorCtx.unkC = 0;
}
// SceneTableEntry Header Command 0x02: List of cameras for actor cutscenes
-void Scene_HeaderCmdActorCutsceneCamList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment);
+void Scene_HeaderCmdActorCutsceneCamList(PlayState* play, SceneCmd* cmd) {
+ play->csCamData = Lib_SegmentedToVirtual(cmd->csCameraList.segment);
}
// SceneTableEntry Header Command 0x03: Collision Header
-void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdColHeader(PlayState* play, SceneCmd* cmd) {
CollisionHeader* colHeaderTemp;
CollisionHeader* colHeader;
@@ -200,55 +200,55 @@ void Scene_HeaderCmdColHeader(GlobalContext* globalCtx, SceneCmd* cmd) {
colHeader->waterBoxes = Lib_SegmentedToVirtual(colHeader->waterBoxes);
}
- BgCheck_Allocate(&globalCtx->colCtx, globalCtx, colHeader);
+ BgCheck_Allocate(&play->colCtx, play, colHeader);
}
// SceneTableEntry Header Command 0x04: Room List
-void Scene_HeaderCmdRoomList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->numRooms = cmd->roomList.num;
- globalCtx->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment);
+void Scene_HeaderCmdRoomList(PlayState* play, SceneCmd* cmd) {
+ play->numRooms = cmd->roomList.num;
+ play->roomList = Lib_SegmentedToVirtual(cmd->roomList.segment);
}
// SceneTableEntry Header Command 0x06: Entrance List
-void Scene_HeaderCmdEntranceList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment);
+void Scene_HeaderCmdEntranceList(PlayState* play, SceneCmd* cmd) {
+ play->setupEntranceList = Lib_SegmentedToVirtual(cmd->entranceList.segment);
}
// SceneTableEntry Header Command 0x07: Special Files
-void Scene_HeaderCmdSpecialFiles(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdSpecialFiles(PlayState* play, SceneCmd* cmd) {
static RomFile tatlMessageFiles[2] = {
{ SEGMENT_ROM_START(elf_message_field), SEGMENT_ROM_END(elf_message_field) },
{ SEGMENT_ROM_START(elf_message_ydan), SEGMENT_ROM_END(elf_message_ydan) },
};
if (cmd->specialFiles.subKeepIndex != 0) {
- globalCtx->objectCtx.subKeepIndex = Object_Spawn(&globalCtx->objectCtx, cmd->specialFiles.subKeepIndex);
+ play->objectCtx.subKeepIndex = Object_Spawn(&play->objectCtx, cmd->specialFiles.subKeepIndex);
// TODO: Segment number enum?
- gSegments[0x05] = PHYSICAL_TO_VIRTUAL(globalCtx->objectCtx.status[globalCtx->objectCtx.subKeepIndex].segment);
+ gSegments[0x05] = PHYSICAL_TO_VIRTUAL(play->objectCtx.status[play->objectCtx.subKeepIndex].segment);
}
if (cmd->specialFiles.cUpElfMsgNum != 0) {
- globalCtx->unk_18868 = Play_LoadScene(globalCtx, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]);
+ play->unk_18868 = Play_LoadScene(play, &tatlMessageFiles[cmd->specialFiles.cUpElfMsgNum - 1]);
}
}
// SceneTableEntry Header Command 0x08: Room Behavior
-void Scene_HeaderCmdRoomBehavior(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1;
- globalCtx->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF;
- globalCtx->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1;
- globalCtx->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xa) & 1;
- globalCtx->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xb) & 1;
- globalCtx->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xc) & 1;
+void Scene_HeaderCmdRoomBehavior(PlayState* play, SceneCmd* cmd) {
+ play->roomCtx.currRoom.unk3 = cmd->roomBehavior.gpFlag1;
+ play->roomCtx.currRoom.unk2 = cmd->roomBehavior.gpFlag2 & 0xFF;
+ play->roomCtx.currRoom.unk5 = (cmd->roomBehavior.gpFlag2 >> 8) & 1;
+ play->msgCtx.unk12044 = (cmd->roomBehavior.gpFlag2 >> 0xa) & 1;
+ play->roomCtx.currRoom.enablePosLights = (cmd->roomBehavior.gpFlag2 >> 0xb) & 1;
+ play->envCtx.unk_E2 = (cmd->roomBehavior.gpFlag2 >> 0xc) & 1;
}
// SceneTableEntry Header Command 0x0A: Mesh Header
-void Scene_HeaderCmdMesh(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment);
+void Scene_HeaderCmdMesh(PlayState* play, SceneCmd* cmd) {
+ play->roomCtx.currRoom.mesh = Lib_SegmentedToVirtual(cmd->mesh.segment);
}
// SceneTableEntry Header Command 0x0B: Object List
-void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdObjectList(PlayState* play, SceneCmd* cmd) {
s32 i;
s32 j;
s32 k;
@@ -260,21 +260,21 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
objectEntry = Lib_SegmentedToVirtual(cmd->objectList.segment);
k = 0;
- i = globalCtx->objectCtx.spawnedObjectCount;
- status = &globalCtx->objectCtx.status[i];
- firstObject = globalCtx->objectCtx.status;
+ i = play->objectCtx.spawnedObjectCount;
+ status = &play->objectCtx.status[i];
+ firstObject = play->objectCtx.status;
- while (i < globalCtx->objectCtx.num) {
+ while (i < play->objectCtx.num) {
if (status->id != *objectEntry) {
- status2 = &globalCtx->objectCtx.status[i];
+ status2 = &play->objectCtx.status[i];
- for (j = i; j < globalCtx->objectCtx.num; j++) {
+ for (j = i; j < play->objectCtx.num; j++) {
status2->id = 0;
status2++;
}
- globalCtx->objectCtx.num = i;
- func_800BA6FC(globalCtx, &globalCtx->actorCtx);
+ play->objectCtx.num = i;
+ func_800BA6FC(play, &play->actorCtx);
continue;
}
@@ -286,7 +286,7 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
}
while (k < cmd->objectList.num) {
- nextPtr = func_8012F73C(&globalCtx->objectCtx, i, *objectEntry);
+ nextPtr = func_8012F73C(&play->objectCtx, i, *objectEntry);
if (i < OBJECT_EXCHANGE_BANK_MAX - 1) {
firstObject[i + 1].segment = nextPtr;
@@ -297,30 +297,30 @@ void Scene_HeaderCmdObjectList(GlobalContext* globalCtx, SceneCmd* cmd) {
objectEntry++;
}
- globalCtx->objectCtx.num = i;
+ play->objectCtx.num = i;
}
// SceneTableEntry Header Command 0x0C: Light List
-void Scene_HeaderCmdLightList(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdLightList(PlayState* play, SceneCmd* cmd) {
s32 i;
LightInfo* lightInfo = Lib_SegmentedToVirtual(cmd->lightList.segment);
for (i = 0; i < cmd->lightList.num; i++) {
- LightContext_InsertLight(globalCtx, &globalCtx->lightCtx, lightInfo);
+ LightContext_InsertLight(play, &play->lightCtx, lightInfo);
lightInfo++;
}
}
// SceneTableEntry Header Command 0x0D: Path List
-void Scene_HeaderCmdPathList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment);
+void Scene_HeaderCmdPathList(PlayState* play, SceneCmd* cmd) {
+ play->setupPathList = Lib_SegmentedToVirtual(cmd->pathList.segment);
}
// SceneTableEntry Header Command 0x0E: Transition Actor List
-void Scene_HeaderCmdTransiActorList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->doorCtx.numTransitionActors = cmd->transiActorList.num;
- globalCtx->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment);
- func_80105818(globalCtx, globalCtx->doorCtx.numTransitionActors, globalCtx->doorCtx.transitionActorList);
+void Scene_HeaderCmdTransiActorList(PlayState* play, SceneCmd* cmd) {
+ play->doorCtx.numTransitionActors = cmd->transiActorList.num;
+ play->doorCtx.transitionActorList = Lib_SegmentedToVirtual(cmd->transiActorList.segment);
+ func_80105818(play, play->doorCtx.numTransitionActors, play->doorCtx.transitionActorList);
}
// Init function for the transition system.
@@ -329,16 +329,16 @@ void Door_InitContext(GameState* state, DoorContext* doorCtx) {
}
// SceneTableEntry Header Command 0x0F: Environment Light Settings List
-void Scene_HeaderCmdEnvLightSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->envCtx.numLightSettings = cmd->lightSettingList.num;
- globalCtx->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment);
+void Scene_HeaderCmdEnvLightSettings(PlayState* play, SceneCmd* cmd) {
+ play->envCtx.numLightSettings = cmd->lightSettingList.num;
+ play->envCtx.lightSettingsList = Lib_SegmentedToVirtual(cmd->lightSettingList.segment);
}
/**
* Loads different texture files for each region of the world.
* These later are stored in segment 0x06, and used in maps.
*/
-void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) {
+void Scene_LoadAreaTextures(PlayState* play, s32 fileIndex) {
static RomFile sceneTextureFiles[9] = {
{ 0, 0 }, // Default
{ SEGMENT_ROM_START(scene_texture_01), SEGMENT_ROM_END(scene_texture_01) },
@@ -354,51 +354,51 @@ void Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) {
size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
if (size != 0) {
- globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size);
- DmaMgr_SendRequest0(globalCtx->roomCtx.unk74, vromStart, size);
+ play->roomCtx.unk74 = THA_AllocEndAlign16(&play->state.heap, size);
+ DmaMgr_SendRequest0(play->roomCtx.unk74, vromStart, size);
}
}
// SceneTableEntry Header Command 0x11: Skybox Settings
-void Scene_HeaderCmdSkyboxSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->skyboxId = cmd->skyboxSettings.skyboxId & 3;
- globalCtx->envCtx.unk_17 = globalCtx->envCtx.unk_18 = cmd->skyboxSettings.unk5;
- globalCtx->envCtx.unk_1E = cmd->skyboxSettings.unk6;
- Scene_LoadAreaTextures(globalCtx, cmd->skyboxSettings.data1);
+void Scene_HeaderCmdSkyboxSettings(PlayState* play, SceneCmd* cmd) {
+ play->skyboxId = cmd->skyboxSettings.skyboxId & 3;
+ play->envCtx.unk_17 = play->envCtx.unk_18 = cmd->skyboxSettings.unk5;
+ play->envCtx.unk_1E = cmd->skyboxSettings.unk6;
+ Scene_LoadAreaTextures(play, cmd->skyboxSettings.data1);
}
// SceneTableEntry Header Command 0x12: Skybox Disables
-void Scene_HeaderCmdSkyboxDisables(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4;
- globalCtx->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5;
+void Scene_HeaderCmdSkyboxDisables(PlayState* play, SceneCmd* cmd) {
+ play->envCtx.skyboxDisabled = cmd->skyboxDisables.unk4;
+ play->envCtx.sunMoonDisabled = cmd->skyboxDisables.unk5;
}
// SceneTableEntry Header Command 0x10: Time Settings
-void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdTimeSettings(PlayState* play, SceneCmd* cmd) {
if (cmd->timeSettings.hour != 0xFF && cmd->timeSettings.min != 0xFF) {
gSaveContext.environmentTime = gSaveContext.save.time =
(u16)(((cmd->timeSettings.hour + (cmd->timeSettings.min / 60.0f)) * 60.0f) / 0.021972656f);
}
if (cmd->timeSettings.unk6 != 0xFF) {
- globalCtx->envCtx.timeIncrement = cmd->timeSettings.unk6;
+ play->envCtx.timeIncrement = cmd->timeSettings.unk6;
} else {
- globalCtx->envCtx.timeIncrement = 0;
+ play->envCtx.timeIncrement = 0;
}
- if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (globalCtx->envCtx.timeIncrement != 0)) {
- globalCtx->envCtx.timeIncrement = 5;
+ if ((gSaveContext.save.inventory.items[SLOT_OCARINA] == ITEM_NONE) && (play->envCtx.timeIncrement != 0)) {
+ play->envCtx.timeIncrement = 5;
}
if (gSaveContext.sunsSongState == SUNSSONG_INACTIVE) {
- REG(15) = globalCtx->envCtx.timeIncrement;
+ REG(15) = play->envCtx.timeIncrement;
}
- globalCtx->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
- globalCtx->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
- globalCtx->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f;
+ play->envCtx.unk_4 = -(Math_SinS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
+ play->envCtx.unk_8 = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 120.0f) * 25.0f;
+ play->envCtx.unk_C = (Math_CosS(((void)0, gSaveContext.save.time) - 0x8000) * 20.0f) * 25.0f;
- if (globalCtx->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) {
+ if (play->envCtx.timeIncrement == 0 && gSaveContext.save.cutscene < 0xFFF0) {
gSaveContext.environmentTime = gSaveContext.save.time;
if (gSaveContext.environmentTime >= CLOCK_TIME(4, 0) && gSaveContext.environmentTime < CLOCK_TIME(6, 30)) {
@@ -417,30 +417,30 @@ void Scene_HeaderCmdTimeSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x05: Wind Settings
-void Scene_HeaderCmdWindSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdWindSettings(PlayState* play, SceneCmd* cmd) {
s8 temp1 = cmd->windSettings.west;
s8 temp2 = cmd->windSettings.vertical;
s8 temp3 = cmd->windSettings.south;
- globalCtx->envCtx.windDir.x = temp1;
- globalCtx->envCtx.windDir.y = temp2;
- globalCtx->envCtx.windDir.z = temp3;
- globalCtx->envCtx.windSpeed = cmd->windSettings.clothIntensity;
+ play->envCtx.windDir.x = temp1;
+ play->envCtx.windDir.y = temp2;
+ play->envCtx.windDir.z = temp3;
+ play->envCtx.windSpeed = cmd->windSettings.clothIntensity;
}
// SceneTableEntry Header Command 0x13: Exit List
-void Scene_HeaderCmdExitList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment);
+void Scene_HeaderCmdExitList(PlayState* play, SceneCmd* cmd) {
+ play->setupExitList = Lib_SegmentedToVirtual(cmd->exitList.segment);
}
// SceneTableEntry Header Command 0x09: Undefined
-void Scene_HeaderCmd09(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmd09(PlayState* play, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x15: Sound Settings=
-void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->soundCtx.seqIndex = cmd->soundSettings.musicSeq;
- globalCtx->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX;
+void Scene_HeaderCmdSoundSettings(PlayState* play, SceneCmd* cmd) {
+ play->soundCtx.seqIndex = cmd->soundSettings.musicSeq;
+ play->soundCtx.nightSeqIndex = cmd->soundSettings.nighttimeSFX;
if (gSaveContext.seqIndex == (u8)NA_BGM_DISABLED || func_801A8A50(0) == NA_BGM_FINAL_HOURS) {
audio_setBGM(cmd->soundSettings.bgmId);
@@ -448,12 +448,12 @@ void Scene_HeaderCmdSoundSettings(GlobalContext* globalCtx, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x16: Echo Setting
-void Scene_HeaderCmdEchoSetting(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->roomCtx.currRoom.echo = cmd->echoSettings.echo;
+void Scene_HeaderCmdEchoSetting(PlayState* play, SceneCmd* cmd) {
+ play->roomCtx.currRoom.echo = cmd->echoSettings.echo;
}
// SceneTableEntry Header Command 0x18: Alternate Header List=
-void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdAltHeaderList(PlayState* play, SceneCmd* cmd) {
SceneCmd** altHeaderList;
SceneCmd* altHeader;
@@ -462,40 +462,40 @@ void Scene_HeaderCmdAltHeaderList(GlobalContext* globalCtx, SceneCmd* cmd) {
altHeader = altHeaderList[gSaveContext.sceneSetupIndex - 1];
if (altHeader != NULL) {
- Scene_ProcessHeader(globalCtx, Lib_SegmentedToVirtual(altHeader));
+ Scene_ProcessHeader(play, Lib_SegmentedToVirtual(altHeader));
(cmd + 1)->base.code = 0x14;
}
}
}
// SceneTableEntry Header Command 0x17: Cutscene List
-void Scene_HeaderCmdCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->csCtx.sceneCsCount = cmd->base.data1;
- globalCtx->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2);
+void Scene_HeaderCmdCutsceneList(PlayState* play, SceneCmd* cmd) {
+ play->csCtx.sceneCsCount = cmd->base.data1;
+ play->csCtx.sceneCsList = Lib_SegmentedToVirtual(cmd->base.data2);
}
// SceneTableEntry Header Command 0x1B: Actor Cutscene List
-void Scene_HeaderCmdActorCutsceneList(GlobalContext* globalCtx, SceneCmd* cmd) {
- ActorCutscene_Init(globalCtx, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num);
+void Scene_HeaderCmdActorCutsceneList(PlayState* play, SceneCmd* cmd) {
+ ActorCutscene_Init(play, Lib_SegmentedToVirtual(cmd->cutsceneActorList.segment), cmd->cutsceneActorList.num);
}
// SceneTableEntry Header Command 0x1C: Mini Maps
-void Scene_HeaderCmdMiniMap(GlobalContext* globalCtx, SceneCmd* cmd) {
- func_80104CF4(globalCtx);
- func_8010549C(globalCtx, cmd->minimapSettings.segment);
+void Scene_HeaderCmdMiniMap(PlayState* play, SceneCmd* cmd) {
+ func_80104CF4(play);
+ func_8010549C(play, cmd->minimapSettings.segment);
}
// SceneTableEntry Header Command 0x1D: Undefined
-void Scene_HeaderCmd1D(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmd1D(PlayState* play, SceneCmd* cmd) {
}
// SceneTableEntry Header Command 0x1E: Minimap Compass Icon Info
-void Scene_HeaderCmdMiniMapCompassInfo(GlobalContext* globalCtx, SceneCmd* cmd) {
- func_8010565C(globalCtx, cmd->minimapChests.num, cmd->minimapChests.segment);
+void Scene_HeaderCmdMiniMapCompassInfo(PlayState* play, SceneCmd* cmd) {
+ func_8010565C(play, cmd->minimapChests.num, cmd->minimapChests.segment);
}
// SceneTableEntry Header Command 0x1A: Sets Area Visited Flag
-void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd) {
+void Scene_HeaderCmdSetAreaVisitedFlag(PlayState* play, SceneCmd* cmd) {
s16 j = 0;
s16 i = 0;
@@ -509,7 +509,7 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd)
}
}
- if (globalCtx->sceneNum == gScenesPerRegion[i][j]) {
+ if (play->sceneNum == gScenesPerRegion[i][j]) {
break;
}
@@ -522,22 +522,22 @@ void Scene_HeaderCmdSetAreaVisitedFlag(GlobalContext* globalCtx, SceneCmd* cmd)
}
// SceneTableEntry Header Command 0x1A: Material Animations
-void Scene_HeaderCmdAnimatedMaterials(GlobalContext* globalCtx, SceneCmd* cmd) {
- globalCtx->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment);
+void Scene_HeaderCmdAnimatedMaterials(PlayState* play, SceneCmd* cmd) {
+ play->sceneMaterialAnims = (AnimatedMaterial*)Lib_SegmentedToVirtual(cmd->textureAnimations.segment);
}
/**
* Sets the exit fade from the next entrance index.
*/
-void Scene_SetExitFade(GlobalContext* globalCtx) {
- globalCtx->unk_1887F = Entrance_GetTransitionFlags(globalCtx->nextEntranceIndex) & 0x7F;
+void Scene_SetExitFade(PlayState* play) {
+ play->unk_1887F = Entrance_GetTransitionFlags(play->nextEntranceIndex) & 0x7F;
}
/**
* Executes all of the commands in a scene or room header.
*/
-s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) {
- static void (*sceneCmdHandlers[])(GlobalContext*, SceneCmd*) = {
+s32 Scene_ProcessHeader(PlayState* play, SceneCmd* header) {
+ static void (*sceneCmdHandlers[])(PlayState*, SceneCmd*) = {
Scene_HeaderCmdSpawnList,
Scene_HeaderCmdActorList,
Scene_HeaderCmdActorCutsceneCamList,
@@ -580,7 +580,7 @@ s32 Scene_ProcessHeader(GlobalContext* globalCtx, SceneCmd* header) {
}
if (cmdId < SCENE_CMD_MAX) {
- sceneCmdHandlers[cmdId](globalCtx, header);
+ sceneCmdHandlers[cmdId](play, header);
}
header++;
diff --git a/src/code/z_scene_proc.c b/src/code/z_scene_proc.c
index 8f369008f..8bb8fa473 100644
--- a/src/code/z_scene_proc.c
+++ b/src/code/z_scene_proc.c
@@ -22,8 +22,8 @@ static Gfx sSceneDrawDefaultDL[] = {
/**
* Executes the current scene draw config handler.
*/
-void Scene_ExecuteDrawConfig(GlobalContext* globalCtx) {
- static void (*sceneDrawConfigHandlers[])(GlobalContext*) = {
+void Scene_ExecuteDrawConfig(PlayState* play) {
+ static void (*sceneDrawConfigHandlers[])(PlayState*) = {
Scene_DrawConfigDefault,
Scene_DrawConfigMatAnim,
Scene_DrawConfigDoNothing,
@@ -34,27 +34,27 @@ void Scene_ExecuteDrawConfig(GlobalContext* globalCtx) {
Scene_DrawConfigMatAnimManualStep,
};
- sceneDrawConfigHandlers[globalCtx->sceneConfig](globalCtx);
+ sceneDrawConfigHandlers[play->sceneConfig](play);
}
/**
* SceneTableEntry Draw Config 0:
* Default scene draw config function. This just executes `sSceneDrawDefaultDL`.
*/
-void Scene_DrawConfigDefault(GlobalContext* globalCtx) {
- OPEN_DISPS(globalCtx->state.gfxCtx);
+void Scene_DrawConfigDefault(PlayState* play) {
+ OPEN_DISPS(play->state.gfxCtx);
gSPDisplayList(POLY_OPA_DISP++, sSceneDrawDefaultDL);
gSPDisplayList(POLY_XLU_DISP++, sSceneDrawDefaultDL);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Returns a pointer to a single layer texture scroll displaylist.
*/
-Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params) {
- return Gfx_TexScroll(globalCtx->state.gfxCtx, params->xStep * sMatAnimStep, -(params->yStep * sMatAnimStep),
+Gfx* AnimatedMat_TexScroll(PlayState* play, AnimatedMatTexScrollParams* params) {
+ return Gfx_TexScroll(play->state.gfxCtx, params->xStep * sMatAnimStep, -(params->yStep * sMatAnimStep),
params->width, params->height);
}
@@ -62,11 +62,11 @@ Gfx* AnimatedMat_TexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams*
* Animated Material Type 0:
* Scrolls a single layer texture using the provided `AnimatedMatTexScrollParams`.
*/
-void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* params) {
+void AnimatedMat_DrawTexScroll(PlayState* play, s32 segment, void* params) {
AnimatedMatTexScrollParams* texScrollParams = (AnimatedMatTexScrollParams*)params;
- Gfx* texScrollDList = AnimatedMat_TexScroll(globalCtx, texScrollParams);
+ Gfx* texScrollDList = AnimatedMat_TexScroll(play, texScrollParams);
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
if (sMatAnimFlags & 1) {
gSPSegment(POLY_OPA_DISP++, segment, texScrollDList);
@@ -76,28 +76,27 @@ void AnimatedMat_DrawTexScroll(GlobalContext* globalCtx, s32 segment, void* para
gSPSegment(POLY_XLU_DISP++, segment, texScrollDList);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Returns a pointer to a two layer texture scroll displaylist.
*/
-Gfx* AnimatedMat_TwoLayerTexScroll(GlobalContext* globalCtx, AnimatedMatTexScrollParams* params) {
- return Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, params[0].xStep * sMatAnimStep,
- -(params[0].yStep * sMatAnimStep), params[0].width, params[0].height, 1,
- params[1].xStep * sMatAnimStep, -(params[1].yStep * sMatAnimStep), params[1].width,
- params[1].height);
+Gfx* AnimatedMat_TwoLayerTexScroll(PlayState* play, AnimatedMatTexScrollParams* params) {
+ return Gfx_TwoTexScroll(play->state.gfxCtx, 0, params[0].xStep * sMatAnimStep, -(params[0].yStep * sMatAnimStep),
+ params[0].width, params[0].height, 1, params[1].xStep * sMatAnimStep,
+ -(params[1].yStep * sMatAnimStep), params[1].width, params[1].height);
}
/**
* Animated Material Type 1:
* Scrolls a two layer texture using the provided `AnimatedMatTexScrollParams`.
*/
-void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* params) {
+void AnimatedMat_DrawTwoTexScroll(PlayState* play, s32 segment, void* params) {
AnimatedMatTexScrollParams* texScrollParams = (AnimatedMatTexScrollParams*)params;
- Gfx* texScrollDList = AnimatedMat_TwoLayerTexScroll(globalCtx, texScrollParams);
+ Gfx* texScrollDList = AnimatedMat_TwoLayerTexScroll(play, texScrollParams);
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
if (sMatAnimFlags & 1) {
gSPSegment(POLY_OPA_DISP++, segment, texScrollDList);
@@ -107,16 +106,16 @@ void AnimatedMat_DrawTwoTexScroll(GlobalContext* globalCtx, s32 segment, void* p
gSPSegment(POLY_XLU_DISP++, segment, texScrollDList);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Generates a displaylist that sets the prim and env color, and stores it in the provided segment ID.
*/
-void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) {
- Gfx* colorDList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 4);
+void AnimatedMat_SetColor(PlayState* play, s32 segment, F3DPrimColor* primColorResult, F3DEnvColor* envColor) {
+ Gfx* colorDList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 4);
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
// clang-format off
if (sMatAnimFlags & 1) { gSPSegment(POLY_OPA_DISP++, segment, colorDList); }
@@ -132,14 +131,14 @@ void AnimatedMat_SetColor(GlobalContext* globalCtx, s32 segment, F3DPrimColor* p
gSPEndDisplayList(colorDList++);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Animated Material Type 2:
* Color key frame animation without linear interpolation.
*/
-void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params) {
+void AnimatedMat_DrawColor(PlayState* play, s32 segment, void* params) {
AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params;
F3DPrimColor* primColor = Lib_SegmentedToVirtual(colorAnimParams->primColors);
F3DEnvColor* envColor;
@@ -150,7 +149,7 @@ void AnimatedMat_DrawColor(GlobalContext* globalCtx, s32 segment, void* params)
? (F3DEnvColor*)Lib_SegmentedToVirtual(colorAnimParams->envColors) + curFrame
: NULL;
- AnimatedMat_SetColor(globalCtx, segment, primColor, envColor);
+ AnimatedMat_SetColor(play, segment, primColor, envColor);
}
/**
@@ -164,7 +163,7 @@ s32 AnimatedMat_Lerp(s32 min, s32 max, f32 norm) {
* Animated Material Type 3:
* Color key frame animation with linear interpolation.
*/
-void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* params) {
+void AnimatedMat_DrawColorLerp(PlayState* play, s32 segment, void* params) {
AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params;
F3DPrimColor* primColorMax = Lib_SegmentedToVirtual(colorAnimParams->primColors);
F3DEnvColor* envColorMax;
@@ -216,7 +215,7 @@ void AnimatedMat_DrawColorLerp(GlobalContext* globalCtx, s32 segment, void* para
envColorMax = NULL;
}
- AnimatedMat_SetColor(globalCtx, segment, &primColorResult, (envColorMax != NULL) ? &envColorResult : NULL);
+ AnimatedMat_SetColor(play, segment, &primColorResult, (envColorMax != NULL) ? &envColorResult : NULL);
}
/**
@@ -277,7 +276,7 @@ u8 Scene_LagrangeInterpColor(s32 n, f32 x[], f32 fx[], f32 xp) {
* Animated Material Type 4:
* Color key frame animation with non-linear interpolation.
*/
-void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment, void* params) {
+void AnimatedMat_DrawColorNonLinearInterp(PlayState* play, s32 segment, void* params) {
AnimatedMatColorParams* colorAnimParams = (AnimatedMatColorParams*)params;
F3DPrimColor* primColorCur = Lib_SegmentedToVirtual(colorAnimParams->primColors);
F3DEnvColor* envColorCur = Lib_SegmentedToVirtual(colorAnimParams->envColors);
@@ -355,21 +354,21 @@ void AnimatedMat_DrawColorNonLinearInterp(GlobalContext* globalCtx, s32 segment,
envColorCur = NULL;
}
- AnimatedMat_SetColor(globalCtx, segment, &primColorResult, (envColorCur != NULL) ? &envColorResult : NULL);
+ AnimatedMat_SetColor(play, segment, &primColorResult, (envColorCur != NULL) ? &envColorResult : NULL);
}
/**
* Animated Material Type 5:
* Cycles between a list of textures (imagine like a GIF)
*/
-void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* params) {
+void AnimatedMat_DrawTexCycle(PlayState* play, s32 segment, void* params) {
AnimatedMatTexCycleParams* texAnimParams = params;
void** texList = Lib_SegmentedToVirtual(texAnimParams->textureList);
u8* texId = Lib_SegmentedToVirtual(texAnimParams->textureIndexList);
s32 curFrame = sMatAnimStep % texAnimParams->keyFrameLength;
void* tex = Lib_SegmentedToVirtual(texList[texId[curFrame]]);
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
if (sMatAnimFlags & 1) {
gSPSegment(POLY_OPA_DISP++, segment, tex);
@@ -379,15 +378,15 @@ void AnimatedMat_DrawTexCycle(GlobalContext* globalCtx, s32 segment, void* param
gSPSegment(POLY_XLU_DISP++, segment, tex);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* This is the main function that handles the animated material system.
* There are six different animated material types, which should be set in the provided `AnimatedMaterial`.
*/
-void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags) {
- static void (*matAnimDrawHandlers[])(GlobalContext*, s32 segment, void* params) = {
+void AnimatedMat_DrawMain(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step, u32 flags) {
+ static void (*matAnimDrawHandlers[])(PlayState*, s32 segment, void* params) = {
AnimatedMat_DrawTexScroll, AnimatedMat_DrawTwoTexScroll, AnimatedMat_DrawColor,
AnimatedMat_DrawColorLerp, AnimatedMat_DrawColorNonLinearInterp, AnimatedMat_DrawTexCycle,
};
@@ -402,7 +401,7 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f
do {
segment = matAnim->segment;
segmentAbs = ((segment < 0) ? -segment : segment) + 7;
- matAnimDrawHandlers[matAnim->type](globalCtx, segmentAbs, Lib_SegmentedToVirtual(matAnim->params));
+ matAnimDrawHandlers[matAnim->type](play, segmentAbs, Lib_SegmentedToVirtual(matAnim->params));
matAnim++;
} while (segment >= 0);
}
@@ -411,123 +410,123 @@ void AnimatedMat_DrawMain(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f
/**
* Draws an animated material to both OPA and XLU buffers.
*/
-void AnimatedMat_Draw(GlobalContext* globalCtx, AnimatedMaterial* matAnim) {
- AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 3);
+void AnimatedMat_Draw(PlayState* play, AnimatedMaterial* matAnim) {
+ AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 3);
}
/**
* Draws an animated material to only the OPA buffer.
*/
-void AnimatedMat_DrawOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim) {
- AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 1);
+void AnimatedMat_DrawOpa(PlayState* play, AnimatedMaterial* matAnim) {
+ AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 1);
}
/**
* Draws an animated material to only the XLU buffer.
*/
-void AnimatedMat_DrawXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim) {
- AnimatedMat_DrawMain(globalCtx, matAnim, 1, globalCtx->gameplayFrames, 2);
+void AnimatedMat_DrawXlu(PlayState* play, AnimatedMaterial* matAnim) {
+ AnimatedMat_DrawMain(play, matAnim, 1, play->gameplayFrames, 2);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) both OPA and XLU buffers.
*/
-void AnimatedMat_DrawAlpha(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) {
- AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 3);
+void AnimatedMat_DrawAlpha(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) {
+ AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 3);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) to only the OPA buffer.
*/
-void AnimatedMat_DrawAlphaOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) {
- AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 1);
+void AnimatedMat_DrawAlphaOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) {
+ AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 1);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) to only the XLU buffer.
*/
-void AnimatedMat_DrawAlphaXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio) {
- AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, globalCtx->gameplayFrames, 2);
+void AnimatedMat_DrawAlphaXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio) {
+ AnimatedMat_DrawMain(play, matAnim, alphaRatio, play->gameplayFrames, 2);
}
/**
* Draws an animated material with a step to both the OPA and XLU buffers.
*/
-void AnimatedMat_DrawStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step) {
- AnimatedMat_DrawMain(globalCtx, matAnim, 1, step, 3);
+void AnimatedMat_DrawStep(PlayState* play, AnimatedMaterial* matAnim, u32 step) {
+ AnimatedMat_DrawMain(play, matAnim, 1, step, 3);
}
/**
* Draws an animated material with a step to only the OPA buffer.
*/
-void AnimatedMat_DrawStepOpa(GlobalContext* globalCtx, AnimatedMaterial* textures, u32 step) {
- AnimatedMat_DrawMain(globalCtx, textures, 1, step, 1);
+void AnimatedMat_DrawStepOpa(PlayState* play, AnimatedMaterial* textures, u32 step) {
+ AnimatedMat_DrawMain(play, textures, 1, step, 1);
}
/**
* Draws an animated material with a step to only the XLU buffer.
*/
-void AnimatedMat_DrawStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, u32 step) {
- AnimatedMat_DrawMain(globalCtx, matAnim, 1, step, 2);
+void AnimatedMat_DrawStepXlu(PlayState* play, AnimatedMaterial* matAnim, u32 step) {
+ AnimatedMat_DrawMain(play, matAnim, 1, step, 2);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to both the OPA and XLU buffers.
*/
-void AnimatedMat_DrawAlphaStep(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
- AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 3);
+void AnimatedMat_DrawAlphaStep(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
+ AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 3);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to only the OPA buffer.
*/
-void AnimatedMat_DrawAlphaStepOpa(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
- AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 1);
+void AnimatedMat_DrawAlphaStepOpa(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
+ AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 1);
}
/**
* Draws an animated material with an alpha ratio (0.0 - 1.0) and a step to only the XLU buffer.
*/
-void AnimatedMat_DrawAlphaStepXlu(GlobalContext* globalCtx, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
- AnimatedMat_DrawMain(globalCtx, matAnim, alphaRatio, step, 2);
+void AnimatedMat_DrawAlphaStepXlu(PlayState* play, AnimatedMaterial* matAnim, f32 alphaRatio, u32 step) {
+ AnimatedMat_DrawMain(play, matAnim, alphaRatio, step, 2);
}
/**
* SceneTableEntry Draw Config 1:
* Allows the usage of the animated material system in scenes.
*/
-void Scene_DrawConfigMatAnim(GlobalContext* globalCtx) {
- AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims);
+void Scene_DrawConfigMatAnim(PlayState* play) {
+ AnimatedMat_Draw(play, play->sceneMaterialAnims);
}
/**
* SceneTableEntry Draw Config 3:
* This config is unused, although it is identical to the grotto scene config from Ocarina of Time.
*/
-void Scene_DrawConfig3(GlobalContext* globalCtx) {
+void Scene_DrawConfig3(PlayState* play) {
u32 frames;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- frames = globalCtx->gameplayFrames;
+ frames = play->gameplayFrames;
- gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (frames * 1) % 64, 256, 16));
+ gSPSegment(POLY_XLU_DISP++, 0x08, Gfx_TexScroll(play->state.gfxCtx, 0, (frames * 1) % 64, 256, 16));
gSPSegment(POLY_XLU_DISP++, 0x09,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - (frames % 128), (frames * 1) % 128, 32, 32, 1,
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - (frames % 128), (frames * 1) % 128, 32, 32, 1,
frames % 128, (frames * 1) % 128, 32, 32));
gSPSegment(POLY_OPA_DISP++, 0x0A,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (frames * 1) % 128, 32, 32));
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 32, 1, 0, 127 - (frames * 1) % 128, 32, 32));
- gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(globalCtx->state.gfxCtx, 0, (frames * 1) % 128, 32, 32));
+ gSPSegment(POLY_OPA_DISP++, 0x0B, Gfx_TexScroll(play->state.gfxCtx, 0, (frames * 1) % 128, 32, 32));
- gSPSegment(POLY_XLU_DISP++, 0x0C,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, (frames * 50) % 2048, 8, 512, 1, 0, (frames * 60) % 2048,
- 8, 512));
+ gSPSegment(
+ POLY_XLU_DISP++, 0x0C,
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, (frames * 50) % 2048, 8, 512, 1, 0, (frames * 60) % 2048, 8, 512));
gSPSegment(POLY_OPA_DISP++, 0x0D,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (frames * 1) % 128, 32, 32));
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 0, 0, 32, 64, 1, 0, (frames * 1) % 128, 32, 32));
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);
@@ -535,7 +534,7 @@ void Scene_DrawConfig3(GlobalContext* globalCtx) {
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
@@ -543,16 +542,16 @@ void Scene_DrawConfig3(GlobalContext* globalCtx) {
* This config is unused and just has a single TwoTexScroll intended for two 32x32 textures (likely two water textures).
* It is identical to the Castle Courtyard and Sacred Forest Meadow scene config from Ocarina of Time.
*/
-void Scene_DrawConfig4(GlobalContext* globalCtx) {
+void Scene_DrawConfig4(PlayState* play) {
u32 frames;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- frames = globalCtx->gameplayFrames;
+ frames = play->gameplayFrames;
gSPSegment(POLY_XLU_DISP++, 0x08,
- Gfx_TwoTexScroll(globalCtx->state.gfxCtx, 0, 127 - frames % 128, (frames * 1) % 128, 32, 32, 1,
- frames % 128, (frames * 1) % 128, 32, 32));
+ Gfx_TwoTexScroll(play->state.gfxCtx, 0, 127 - frames % 128, (frames * 1) % 128, 32, 32, 1, frames % 128,
+ (frames * 1) % 128, 32, 32));
gDPPipeSync(POLY_OPA_DISP++);
gDPSetEnvColor(POLY_OPA_DISP++, 128, 128, 128, 128);
@@ -560,20 +559,20 @@ void Scene_DrawConfig4(GlobalContext* globalCtx) {
gDPPipeSync(POLY_XLU_DISP++);
gDPSetEnvColor(POLY_XLU_DISP++, 128, 128, 128, 128);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* SceneTableEntry Draw Config 2:
* Has no effect, and is only used in SPOT00 (cutscene scene).
*/
-void Scene_DrawConfigDoNothing(GlobalContext* globalCtx) {
+void Scene_DrawConfigDoNothing(PlayState* play) {
}
/**
* Stores a displaylist in the provided segment ID that sets a render mode from the index provided.
*/
-void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) {
+void Scene_SetRenderModeXlu(PlayState* play, s32 index, u32 flags) {
static Gfx renderModeSetNoneDL[] = {
gsSPEndDisplayList(),
// These instructions will never get executed
@@ -612,7 +611,7 @@ void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) {
};
Gfx* dList = dLists[index];
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
if (flags & 1) {
gSPSegment(POLY_OPA_DISP++, 0x0C, dList);
@@ -622,14 +621,14 @@ void Scene_SetRenderModeXlu(GlobalContext* globalCtx, s32 index, u32 flags) {
gSPSegment(POLY_XLU_DISP++, 0x0C, dList);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Although this function is unused, it will store a displaylist in the provided segment ID that sets the culling mode
* from the index provided.
*/
-void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) {
+void Scene_SetCullFlag(PlayState* play, s32 index, u32 flags) {
static Gfx setBackCullDL[] = {
gsSPSetGeometryMode(G_CULL_BACK),
gsSPEndDisplayList(),
@@ -644,7 +643,7 @@ void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) {
};
Gfx* dList = dLists[index];
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
if (flags & 1) {
gSPSegment(POLY_OPA_DISP++, 0x0C, dList);
@@ -654,37 +653,37 @@ void Scene_SetCullFlag(GlobalContext* globalCtx, s32 index, u32 flags) {
gSPSegment(POLY_XLU_DISP++, 0x0C, dList);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* SceneTableEntry Draw Config 5:
* This config is unused, and its purpose is unknown.
*/
-void Scene_DrawConfig5(GlobalContext* globalCtx) {
+void Scene_DrawConfig5(PlayState* play) {
u32 dListIndex;
u32 alpha;
- if (globalCtx->roomCtx.unk7A[0] != 0) {
+ if (play->roomCtx.unk7A[0] != 0) {
dListIndex = 1;
- alpha = globalCtx->roomCtx.unk7A[1];
+ alpha = play->roomCtx.unk7A[1];
} else {
dListIndex = 0;
alpha = 255;
}
if (alpha == 0) {
- globalCtx->roomCtx.unk78 = 0;
+ play->roomCtx.unk78 = 0;
} else {
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- globalCtx->roomCtx.unk78 = 1;
- AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims);
- Scene_SetRenderModeXlu(globalCtx, dListIndex, 3);
+ play->roomCtx.unk78 = 1;
+ AnimatedMat_Draw(play, play->sceneMaterialAnims);
+ Scene_SetRenderModeXlu(play, dListIndex, 3);
gDPSetEnvColor(POLY_OPA_DISP++, 255, 255, 255, alpha);
gDPSetEnvColor(POLY_XLU_DISP++, 255, 255, 255, alpha);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
}
@@ -693,8 +692,8 @@ void Scene_DrawConfig5(GlobalContext* globalCtx) {
* This is a special draw config for Sakon's Hideout, as well as the Music Box House. Its step value is set manually
* rather than always animating like `Scene_DrawConfigMatAnim`.
*/
-void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx) {
- AnimatedMat_DrawStep(globalCtx, globalCtx->sceneMaterialAnims, globalCtx->roomCtx.unk7A[0]);
+void Scene_DrawConfigMatAnimManualStep(PlayState* play) {
+ AnimatedMat_DrawStep(play, play->sceneMaterialAnims, play->roomCtx.unk7A[0]);
}
/**
@@ -703,7 +702,7 @@ void Scene_DrawConfigMatAnimManualStep(GlobalContext* globalCtx) {
* fraction to a certain value when certain flags are set, which are likely used for the pipes whenever they are
* activated.
*/
-void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
+void Scene_DrawConfigGreatBayTemple(PlayState* play) {
static Gfx greatBayTempleColorSetDL[] = {
gsDPSetPrimColor(0, 255, 255, 255, 255, 255),
gsSPEndDisplayList(),
@@ -713,18 +712,18 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
Gfx* dListHead;
Gfx* dList;
- if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) &&
- Flags_GetSwitch(globalCtx, 0x36)) {
- BgCheck_SetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
+ if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) &&
+ Flags_GetSwitch(play, 0x36)) {
+ BgCheck_SetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
} else {
- BgCheck_UnsetContextFlags(&globalCtx->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
+ BgCheck_UnsetContextFlags(&play->colCtx, BGCHECK_FLAG_REVERSE_CONVEYOR_FLOW);
}
- dList = GRAPH_ALLOC(globalCtx->state.gfxCtx, sizeof(Gfx) * 18);
+ dList = GRAPH_ALLOC(play->state.gfxCtx, sizeof(Gfx) * 18);
- AnimatedMat_Draw(globalCtx, globalCtx->sceneMaterialAnims);
+ AnimatedMat_Draw(play, play->sceneMaterialAnims);
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
for (dListHead = dList, i = 0; i < 9; i++, dListHead += 2) {
lodFrac = 0;
@@ -733,50 +732,48 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
switch (i) {
case 0:
- if (Flags_GetSwitch(globalCtx, 0x33) && Flags_GetSwitch(globalCtx, 0x34) &&
- Flags_GetSwitch(globalCtx, 0x35) && Flags_GetSwitch(globalCtx, 0x36)) {
+ if (Flags_GetSwitch(play, 0x33) && Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) &&
+ Flags_GetSwitch(play, 0x36)) {
lodFrac = 255;
}
break;
case 1:
- if (Flags_GetSwitch(globalCtx, 0x37)) {
+ if (Flags_GetSwitch(play, 0x37)) {
lodFrac = 68;
}
break;
case 2:
- if (Flags_GetSwitch(globalCtx, 0x37) && Flags_GetSwitch(globalCtx, 0x38)) {
+ if (Flags_GetSwitch(play, 0x37) && Flags_GetSwitch(play, 0x38)) {
lodFrac = 68;
}
break;
case 3:
- if (Flags_GetSwitch(globalCtx, 0x37) && Flags_GetSwitch(globalCtx, 0x38) &&
- Flags_GetSwitch(globalCtx, 0x39)) {
+ if (Flags_GetSwitch(play, 0x37) && Flags_GetSwitch(play, 0x38) && Flags_GetSwitch(play, 0x39)) {
lodFrac = 68;
}
break;
case 4:
- if (!(Flags_GetSwitch(globalCtx, 0x33))) {
+ if (!(Flags_GetSwitch(play, 0x33))) {
lodFrac = 68;
}
break;
case 5:
- if (Flags_GetSwitch(globalCtx, 0x34)) {
+ if (Flags_GetSwitch(play, 0x34)) {
lodFrac = 68;
}
break;
case 6:
- if (Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35)) {
+ if (Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35)) {
lodFrac = 68;
}
break;
case 7:
- if (Flags_GetSwitch(globalCtx, 0x34) && Flags_GetSwitch(globalCtx, 0x35) &&
- Flags_GetSwitch(globalCtx, 0x36)) {
+ if (Flags_GetSwitch(play, 0x34) && Flags_GetSwitch(play, 0x35) && Flags_GetSwitch(play, 0x36)) {
lodFrac = 68;
}
break;
case 8:
- if (Flags_GetSwitch(globalCtx, 0x3A)) {
+ if (Flags_GetSwitch(play, 0x3A)) {
lodFrac = 68;
}
break;
@@ -788,5 +785,5 @@ void Scene_DrawConfigGreatBayTemple(GlobalContext* globalCtx) {
gSPSegment(POLY_OPA_DISP++, 0x06, dList);
gSPSegment(POLY_XLU_DISP++, 0x06, dList);
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
diff --git a/src/code/z_schedule.c b/src/code/z_schedule.c
index 4c57a57d4..2380cef13 100644
--- a/src/code/z_schedule.c
+++ b/src/code/z_schedule.c
@@ -6,7 +6,7 @@
(dest) = (temp) * (0x10000 / 60 / 24.0f); \
(dest) = SCHEDULE_CONVERT_TIME(dest);
-s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckFlagS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckFlagS* cmd = (ScheduleCmdCheckFlagS*)*script;
u16 flag = (cmd->flagByte << 8) | cmd->flagMask;
@@ -17,7 +17,7 @@ s32 Schedule_CheckFlagS(GlobalContext* globalCtx, u8** script, ScheduleResult* r
return false;
}
-s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckFlagL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckFlagL* cmd = (ScheduleCmdCheckFlagL*)*script;
u16 flag = (cmd->flagByte << 8) | cmd->flagMask;
@@ -28,7 +28,7 @@ s32 Schedule_CheckFlagL(GlobalContext* globalCtx, u8** script, ScheduleResult* r
return false;
}
-s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckTimeRangeS(PlayState* play, u8** script, ScheduleResult* result) {
s32 inRange = false;
ScheduleCmdCheckTimeRangeS* cmd = (ScheduleCmdCheckTimeRangeS*)*script;
f32 f;
@@ -54,7 +54,7 @@ s32 Schedule_CheckTimeRangeS(GlobalContext* globalCtx, u8** script, ScheduleResu
return false;
}
-s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckTimeRangeL(PlayState* play, u8** script, ScheduleResult* result) {
s32 inRange = false;
ScheduleCmdCheckTimeRangeL* cmd = (ScheduleCmdCheckTimeRangeL*)*script;
f32 f;
@@ -80,7 +80,7 @@ s32 Schedule_CheckTimeRangeL(GlobalContext* globalCtx, u8** script, ScheduleResu
return false;
}
-s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_ReturnValueL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdReturnValueL* cmd = (ScheduleCmdReturnValueL*)*script;
//! @bug result is a u8, value is truncated
@@ -90,36 +90,36 @@ s32 Schedule_ReturnValueL(GlobalContext* globalCtx, u8** script, ScheduleResult*
return true;
}
-s32 Schedule_ReturnNone(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_ReturnNone(PlayState* play, u8** script, ScheduleResult* result) {
result->hasResult = false;
return true;
}
-s32 Schedule_ReturnEmpty(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_ReturnEmpty(PlayState* play, u8** script, ScheduleResult* result) {
result->hasResult = true;
return true;
}
-s32 Schedule_Nop(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_Nop(PlayState* play, u8** script, ScheduleResult* result) {
return false;
}
-s32 Schedule_CheckMiscS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckMiscS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckMiscS* cmd = (ScheduleCmdCheckMiscS*)*script;
if (((cmd->which == SCHEDULE_CHECK_MISC_ROOM_KEY) && (INV_CONTENT(ITEM_ROOM_KEY) == ITEM_ROOM_KEY)) ||
((cmd->which == SCHEDULE_CHECK_MISC_LETTER_TO_KAFEI) &&
(INV_CONTENT(ITEM_LETTER_TO_KAFEI) == ITEM_LETTER_TO_KAFEI)) ||
- ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(globalCtx) == PLAYER_MASK_ROMANI))) {
+ ((cmd->which == SCHEDULE_CHECK_MISC_MASK_ROMANI) && (Player_GetMask(play) == PLAYER_MASK_ROMANI))) {
*script += cmd->offset;
}
return false;
}
-s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_ReturnValueS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdReturnValueS* cmd = (ScheduleCmdReturnValueS*)*script;
result->result = cmd->result;
@@ -128,29 +128,29 @@ s32 Schedule_ReturnValueS(GlobalContext* globalCtx, u8** script, ScheduleResult*
return true;
}
-s32 Schedule_CheckNotInSceneS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckNotInSceneS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInSceneS* cmd = (ScheduleCmdCheckNotInSceneS*)*script;
s16 scene = (cmd->sceneH << 8) | cmd->sceneL;
- if (scene != globalCtx->sceneNum) {
+ if (scene != play->sceneNum) {
*script += cmd->offset;
}
return false;
}
-s32 Schedule_CheckNotInSceneL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckNotInSceneL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInSceneL* cmd = (ScheduleCmdCheckNotInSceneL*)*script;
s16 scene = (cmd->sceneH << 8) | cmd->sceneL;
- if (scene != globalCtx->sceneNum) {
+ if (scene != play->sceneNum) {
*script = *script + (s16)((cmd->offsetH << 8) | cmd->offsetL);
}
return false;
}
-s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckNotInDayS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInDayS* cmd = (ScheduleCmdCheckNotInDayS*)*script;
s16 day = (cmd->dayH << 8) | cmd->dayL;
@@ -161,7 +161,7 @@ s32 Schedule_CheckNotInDayS(GlobalContext* globalCtx, u8** script, ScheduleResul
return false;
}
-s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckNotInDayL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckNotInDayL* cmd = (ScheduleCmdCheckNotInDayL*)*script;
s16 day = (cmd->dayH << 8) | cmd->dayL;
@@ -172,7 +172,7 @@ s32 Schedule_CheckNotInDayL(GlobalContext* globalCtx, u8** script, ScheduleResul
return false;
}
-s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_ReturnTime(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdReturnTime* cmd = (ScheduleCmdReturnTime*)*script;
f32 f;
u16 time0;
@@ -191,7 +191,7 @@ s32 Schedule_ReturnTime(GlobalContext* globalCtx, u8** script, ScheduleResult* r
return true;
}
-s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckBeforeTimeS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckBeforeTimeS* cmd = (ScheduleCmdCheckBeforeTimeS*)*script;
f32 f;
u16 testTime;
@@ -208,7 +208,7 @@ s32 Schedule_CheckBeforeTimeS(GlobalContext* globalCtx, u8** script, ScheduleRes
return false;
}
-s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_CheckBeforeTimeL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdCheckBeforeTimeL* cmd = (ScheduleCmdCheckBeforeTimeL*)*script;
f32 f;
u16 testTime;
@@ -225,21 +225,21 @@ s32 Schedule_CheckBeforeTimeL(GlobalContext* globalCtx, u8** script, ScheduleRes
return false;
}
-s32 Schedule_BranchS(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_BranchS(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdBranchS* cmd = (ScheduleCmdBranchS*)*script;
*script += cmd->offset;
return false;
}
-s32 Schedule_BranchL(GlobalContext* globalCtx, u8** script, ScheduleResult* result) {
+s32 Schedule_BranchL(PlayState* play, u8** script, ScheduleResult* result) {
ScheduleCmdBranchL* cmd = (ScheduleCmdBranchL*)*script;
*script += (s16)((cmd->offsetH << 8) | cmd->offsetL);
return false;
}
-static s32 (*sScheduleCmdFuncs[])(GlobalContext*, u8**, ScheduleResult*) = {
+static s32 (*sScheduleCmdFuncs[])(PlayState*, u8**, ScheduleResult*) = {
Schedule_CheckFlagS, Schedule_CheckFlagL, Schedule_CheckTimeRangeS, Schedule_CheckTimeRangeL,
Schedule_ReturnValueL, Schedule_ReturnNone, Schedule_ReturnEmpty, Schedule_Nop,
Schedule_CheckMiscS, Schedule_ReturnValueS, Schedule_CheckNotInSceneS, Schedule_CheckNotInSceneL,
@@ -269,13 +269,13 @@ static u8 sScheduleCmdSizes[] = {
sizeof(ScheduleCmdBranchL),
};
-s32 Schedule_RunScript(GlobalContext* globalCtx, u8* script, ScheduleResult* result) {
+s32 Schedule_RunScript(PlayState* play, u8* script, ScheduleResult* result) {
u8 size;
s32 stop;
do {
size = sScheduleCmdSizes[*script];
- stop = (*sScheduleCmdFuncs[*script])(globalCtx, &script, result);
+ stop = (*sScheduleCmdFuncs[*script])(play, &script, result);
script += size;
} while (!stop);
diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c
index 4c77b3669..a22357624 100644
--- a/src/code/z_skelanime.c
+++ b/src/code/z_skelanime.c
@@ -2,14 +2,14 @@
#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_LoopPartial(SkelAnime* skelAnime);
s32 SkelAnime_Once(SkelAnime* skelAnime);
void Animation_PlayLoop(SkelAnime* skelAnime, AnimationHeader* animation);
void SkelAnime_UpdateTranslation(SkelAnime* skelAnime, Vec3f* pos, s16 angle);
-void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed,
+void LinkAnimation_Change(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation, f32 playSpeed,
f32 frame, f32 frameCount, u8 animationMode, f32 morphFrames);
void SkelAnime_CopyFrameTable(SkelAnime* skelAnime, Vec3s* dst, Vec3s* src);
@@ -24,14 +24,14 @@ s32 sDisableAnimQueueFlags;
/*
* Draws the limb at `limbIndex` with a level of detail display lists index by `dListIndex`
*/
-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, Actor* actor, s32 lod) {
LodLimb* limb;
Gfx* dList;
Vec3f pos;
Vec3s rot;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
limb = Lib_SegmentedToVirtual(skeleton[limbIndex]);
@@ -43,12 +43,12 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele
pos.z = limb->jointPos.z;
dList = limb->dLists[lod];
- if ((overrideLimbDraw == NULL) || (overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor) == 0)) {
+ if ((overrideLimbDraw == NULL) || (overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor) == 0)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (dList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
- gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
+ gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD);
gSPDisplayList(&polyTemp[1], dList);
POLY_OPA_DISP = &polyTemp[2];
@@ -56,29 +56,28 @@ void SkelAnime_DrawLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skele
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor);
+ postLimbDraw(play, limbIndex, &dList, &rot, actor);
}
if (limb->child != LIMB_DONE) {
- SkelAnime_DrawLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod);
+ SkelAnime_DrawLimbLod(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- SkelAnime_DrawLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
- lod);
+ SkelAnime_DrawLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Draw all limbs of type `LodLimb` in a given skeleton
* Near or far display list is specified via `lod`
*/
-void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
- OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) {
+void SkelAnime_DrawLod(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw,
+ PostLimbDrawOpa postLimbDraw, Actor* actor, s32 lod) {
LodLimb* rootLimb;
s32 pad;
Gfx* dList;
@@ -89,7 +88,7 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa
return;
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
@@ -101,12 +100,12 @@ 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, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (dList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
- gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
+ gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD);
gSPDisplayList(&polyTemp[1], dList);
@@ -115,24 +114,23 @@ void SkelAnime_DrawLod(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &dList, &rot, actor);
+ postLimbDraw(play, 1, &dList, &rot, actor);
}
if (rootLimb->child != LIMB_DONE) {
- SkelAnime_DrawLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
- lod);
+ SkelAnime_DrawLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod);
}
Matrix_Pop();
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Draw a limb of type `LodLimb` contained within a flexible skeleton
* Near or far display list is specified via `lod`
*/
-void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable,
+void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable,
OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor,
s32 lod, Mtx** mtx) {
LodLimb* limb;
@@ -141,7 +139,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s
Vec3f pos;
Vec3s rot;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
@@ -156,7 +154,7 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s
newDList = limbDList = limb->dLists[lod];
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (newDList != NULL) {
Matrix_ToMtx(*mtx);
@@ -170,22 +168,22 @@ void SkelAnime_DrawFlexLimbLod(GlobalContext* globalCtx, s32 limbIndex, void** s
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &newDList, &limbDList, &rot, actor);
+ postLimbDraw(play, limbIndex, &newDList, &limbDList, &rot, actor);
}
if (limb->child != LIMB_DONE) {
- SkelAnime_DrawFlexLimbLod(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
- lod, mtx);
+ SkelAnime_DrawFlexLimbLod(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod,
+ mtx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- SkelAnime_DrawFlexLimbLod(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
- lod, mtx);
+ SkelAnime_DrawFlexLimbLod(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, lod,
+ mtx);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
@@ -193,7 +191,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,
OverrideLimbDrawFlex overrideLimbDraw, PostLimbDrawFlex postLimbDraw, Actor* actor,
s32 lod) {
LodLimb* rootLimb;
@@ -202,13 +200,13 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
Gfx* limbDList;
Vec3f pos;
Vec3s rot;
- Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
+ Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
if (skeleton == NULL) {
return;
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x0D, mtx);
Matrix_Push();
@@ -222,7 +220,7 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
newDList = limbDList = rootLimb->dLists[lod];
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (newDList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
@@ -238,30 +236,30 @@ void SkelAnime_DrawFlexLod(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &newDList, &limbDList, &rot, actor);
+ postLimbDraw(play, 1, &newDList, &limbDList, &rot, actor);
}
if (rootLimb->child != LIMB_DONE) {
- SkelAnime_DrawFlexLimbLod(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
- actor, lod, &mtx);
+ SkelAnime_DrawFlexLimbLod(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ lod, &mtx);
}
Matrix_Pop();
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/*
* Draws the limb of the Skeleton `skeleton` at `limbIndex`
*/
-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, Actor* actor) {
StandardLimb* limb;
Gfx* dList;
Vec3f pos;
Vec3s rot;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
@@ -273,39 +271,39 @@ 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, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (dList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
- gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
+ gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD);
gSPDisplayList(&polyTemp[1], dList);
POLY_OPA_DISP = &polyTemp[2];
}
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor);
+ postLimbDraw(play, limbIndex, &dList, &rot, actor);
}
if (limb->child != LIMB_DONE) {
- SkelAnime_DrawLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor);
+ SkelAnime_DrawLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- SkelAnime_DrawLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor);
+ SkelAnime_DrawLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
* Draw all limbs of type `StandardLimb` in a given skeleton to the polyOpa buffer
*/
-void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable,
- OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw, Actor* actor) {
+void SkelAnime_DrawOpa(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDrawOpa overrideLimbDraw,
+ PostLimbDrawOpa postLimbDraw, Actor* actor) {
StandardLimb* rootLimb;
s32 pad;
Gfx* dList;
@@ -316,7 +314,7 @@ void SkelAnime_DrawOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTa
return;
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
rootLimb = Lib_SegmentedToVirtual(skeleton[0]);
@@ -328,31 +326,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, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (dList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
- gSPMatrix(&polyTemp[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
+ gSPMatrix(&polyTemp[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD);
gSPDisplayList(&polyTemp[1], dList);
POLY_OPA_DISP = &polyTemp[2];
}
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &dList, &rot, actor);
+ postLimbDraw(play, 1, &dList, &rot, actor);
}
if (rootLimb->child != LIMB_DONE) {
- SkelAnime_DrawLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor);
+ SkelAnime_DrawLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor);
}
Matrix_Pop();
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-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, Actor* actor,
Mtx** limbMatricies) {
StandardLimb* limb;
@@ -361,7 +359,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s
Vec3f pos;
Vec3s rot;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
@@ -375,7 +373,7 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s
newDList = limbDList = limb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (newDList != NULL) {
Matrix_ToMtx(*limbMatricies);
@@ -389,22 +387,22 @@ void SkelAnime_DrawFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** s
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor);
+ postLimbDraw(play, limbIndex, &limbDList, &rot, actor);
}
if (limb->child != LIMB_DONE) {
- SkelAnime_DrawFlexLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ SkelAnime_DrawFlexLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
limbMatricies);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- SkelAnime_DrawFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ SkelAnime_DrawFlexLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
limbMatricies);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
@@ -412,7 +410,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, Actor* actor) {
StandardLimb* rootLimb;
s32 pad;
@@ -420,13 +418,13 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
Gfx* limbDList;
Vec3f pos;
Vec3s rot;
- Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
+ Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
if (skeleton == NULL) {
return;
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x0D, mtx);
@@ -441,7 +439,7 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
newDList = limbDList = rootLimb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (newDList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
@@ -459,20 +457,20 @@ void SkelAnime_DrawFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* joi
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &limbDList, &rot, actor);
+ postLimbDraw(play, 1, &limbDList, &rot, actor);
}
if (rootLimb->child != LIMB_DONE) {
- SkelAnime_DrawFlexLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
- actor, &mtx);
+ SkelAnime_DrawFlexLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ &mtx);
}
Matrix_Pop();
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
-void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable,
+void SkelAnime_DrawTransformFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable,
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw,
TransformLimbDrawOpa transformLimbDraw, Actor* actor, Mtx** mtx) {
StandardLimb* limb;
@@ -481,7 +479,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex,
Vec3f pos;
Vec3s rot;
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
Matrix_Push();
@@ -495,11 +493,11 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex,
newDList = limbDList = limb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Push();
- transformLimbDraw(globalCtx, limbIndex, actor);
+ transformLimbDraw(play, limbIndex, actor);
if (newDList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
@@ -518,22 +516,22 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex,
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor);
+ postLimbDraw(play, limbIndex, &limbDList, &rot, actor);
}
if (limb->child != LIMB_DONE) {
- SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
+ SkelAnime_DrawTransformFlexLimbOpa(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
transformLimbDraw, actor, mtx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- SkelAnime_DrawTransformFlexLimbOpa(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw,
- postLimbDraw, transformLimbDraw, actor, mtx);
+ SkelAnime_DrawTransformFlexLimbOpa(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
+ transformLimbDraw, actor, mtx);
}
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
@@ -545,7 +543,7 @@ void SkelAnime_DrawTransformFlexLimbOpa(GlobalContext* globalCtx, s32 limbIndex,
* coordinates.
* Note that the `TransformLimbDraw` does not have a NULL check, so must be provided even if empty.
*/
-void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount,
+void SkelAnime_DrawTransformFlexOpa(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount,
OverrideLimbDrawOpa overrideLimbDraw, PostLimbDrawOpa postLimbDraw,
TransformLimbDrawOpa transformLimbDraw, Actor* actor) {
StandardLimb* rootLimb;
@@ -560,9 +558,9 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V
return;
}
- OPEN_DISPS(globalCtx->state.gfxCtx);
+ OPEN_DISPS(play->state.gfxCtx);
- mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
+ mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
gSPSegment(POLY_OPA_DISP++, 0x0D, mtx);
@@ -577,11 +575,11 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V
newDList = limbDList = rootLimb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor)) {
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Push();
- transformLimbDraw(globalCtx, 1, actor);
+ transformLimbDraw(play, 1, actor);
if (newDList != NULL) {
Gfx* polyTemp = POLY_OPA_DISP;
@@ -599,17 +597,17 @@ void SkelAnime_DrawTransformFlexOpa(GlobalContext* globalCtx, void** skeleton, V
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &limbDList, &rot, actor);
+ postLimbDraw(play, 1, &limbDList, &rot, actor);
}
if (rootLimb->child != LIMB_DONE) {
- SkelAnime_DrawTransformFlexLimbOpa(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw,
- postLimbDraw, transformLimbDraw, actor, &mtx);
+ SkelAnime_DrawTransformFlexLimbOpa(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
+ transformLimbDraw, actor, &mtx);
}
Matrix_Pop();
- CLOSE_DISPS(globalCtx->state.gfxCtx);
+ CLOSE_DISPS(play->state.gfxCtx);
}
/**
@@ -651,7 +649,7 @@ s16 Animation_GetLastFrame(void* animation) {
* Draws the Skeleton `skeleton`'s limb at index `limbIndex`. Appends all generated graphics commands to
* `gfx`. Returns a pointer to the next gfx to be appended to.
*/
-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, Actor* actor, Gfx* gfx) {
StandardLimb* limb;
Gfx* dList;
@@ -670,29 +668,27 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton
dList = limb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &dList, &pos, &rot, actor, &gfx)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &dList, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (dList != NULL) {
- gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
+ gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD);
gSPDisplayList(&gfx[1], dList);
gfx = &gfx[2];
}
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &dList, &rot, actor, &gfx);
+ postLimbDraw(play, limbIndex, &dList, &rot, actor, &gfx);
}
if (limb->child != LIMB_DONE) {
- gfx = SkelAnime_DrawLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
- gfx);
+ gfx = SkelAnime_DrawLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, gfx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- gfx = SkelAnime_DrawLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
- gfx);
+ gfx = SkelAnime_DrawLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, gfx);
}
return gfx;
@@ -702,7 +698,7 @@ Gfx* SkelAnime_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton
* Draws the Skeleton `skeleton` Appends all generated graphics to `gfx`, and returns a pointer to the
* next gfx to be appended to.
*/
-Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw,
+Gfx* SkelAnime_Draw(PlayState* play, void** skeleton, Vec3s* jointTable, OverrideLimbDraw overrideLimbDraw,
PostLimbDraw postLimbDraw, Actor* actor, Gfx* gfx) {
StandardLimb* rootLimb;
s32 pad;
@@ -726,22 +722,22 @@ Gfx* SkelAnime_Draw(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable
dList = rootLimb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &dList, &pos, &rot, actor, &gfx)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &dList, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (dList != NULL) {
- gSPMatrix(&gfx[0], Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_LOAD);
+ gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_LOAD);
gSPDisplayList(&gfx[1], dList);
gfx = &gfx[2];
}
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &dList, &rot, actor, &gfx);
+ postLimbDraw(play, 1, &dList, &rot, actor, &gfx);
}
if (rootLimb->child != LIMB_DONE) {
- gfx = SkelAnime_DrawLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
- actor, gfx);
+ gfx =
+ SkelAnime_DrawLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor, gfx);
}
Matrix_Pop();
@@ -752,7 +748,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, Actor* actor, Mtx** mtx,
Gfx* gfx) {
StandardLimb* limb;
@@ -773,7 +769,7 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel
newDList = limbDList = limb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (newDList != NULL) {
gSPMatrix(&gfx[0], Matrix_ToMtx(*mtx), G_MTX_LOAD);
@@ -789,19 +785,19 @@ Gfx* SkelAnime_DrawFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skel
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx);
+ postLimbDraw(play, limbIndex, &limbDList, &rot, actor, &gfx);
}
if (limb->child != LIMB_DONE) {
- gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
- actor, mtx, gfx);
+ gfx = SkelAnime_DrawFlexLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ mtx, gfx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- gfx = SkelAnime_DrawFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
- actor, mtx, gfx);
+ gfx = SkelAnime_DrawFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ mtx, gfx);
}
return gfx;
@@ -812,7 +808,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, Actor* actor, Gfx* gfx) {
StandardLimb* rootLimb;
s32 pad;
@@ -826,7 +822,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT
return NULL;
}
- mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
+ mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(sizeof(Mtx) * dListCount));
gSPSegment(gfx++, 0x0D, mtx);
@@ -842,7 +838,7 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT
newDList = limbDList = rootLimb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, 1, &newDList, &pos, &rot, actor, &gfx)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, 1, &newDList, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
if (newDList != NULL) {
gSPMatrix(&gfx[0], Matrix_ToMtx(mtx), G_MTX_LOAD);
@@ -858,12 +854,12 @@ Gfx* SkelAnime_DrawFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointT
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &limbDList, &rot, actor, &gfx);
+ postLimbDraw(play, 1, &limbDList, &rot, actor, &gfx);
}
if (rootLimb->child != LIMB_DONE) {
- gfx = SkelAnime_DrawFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
- actor, &mtx, gfx);
+ gfx = SkelAnime_DrawFlexLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw, actor,
+ &mtx, gfx);
}
Matrix_Pop();
@@ -966,14 +962,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;
}
@@ -994,9 +990,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, ANIMATION_LINKANIMETION);
+ AnimationEntry* entry = AnimationContext_AddEntry(&play->animationCtx, ANIMATION_LINKANIMETION);
if (entry != NULL) {
LinkAnimationHeader* linkAnimHeader = Lib_SegmentedToVirtual(animation);
@@ -1012,8 +1008,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;
@@ -1026,8 +1022,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;
@@ -1041,8 +1037,8 @@ void AnimationContext_SetInterp(GlobalContext* globalCtx, s32 vecCount, Vec3s* b
/**
* Requests copying vectors from src frame table to dst frame table whose load 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;
@@ -1056,8 +1052,8 @@ void AnimationContext_SetCopyTrue(GlobalContext* globalCtx, s32 vecCount, Vec3s*
/**
* Requests copying vectors from src frame table to dst frame table whose load 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;
@@ -1071,8 +1067,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;
@@ -1084,7 +1080,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);
@@ -1093,7 +1089,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)) {
@@ -1110,7 +1106,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)) {
@@ -1121,7 +1117,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)) {
@@ -1141,7 +1137,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)) {
@@ -1161,7 +1157,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;
@@ -1175,11 +1171,11 @@ 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) {
AnimationEntry* entry = animationCtx->entries;
for (; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) {
- sAnimationLoadDone[entry->type](globalCtx, &entry->data);
+ sAnimationLoadDone[entry->type](play, &entry->data);
}
sAnimQueueFlags = 1;
@@ -1190,7 +1186,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;
@@ -1228,7 +1224,7 @@ void SkelAnime_InitLink(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkel
skelAnime->morphTable = (Vec3s*)ALIGN16((u32)morphTable);
}
- 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);
}
/**
@@ -1247,24 +1243,24 @@ 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.link(globalCtx, skelAnime);
+s32 LinkAnimation_Update(PlayState* play, SkelAnime* skelAnime) {
+ return skelAnime->update.link(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 = (s32)globalCtx->state.framerateDivisor * 0.5f;
+ f32 updateRate = (s32)play->state.framerateDivisor * 0.5f;
skelAnime->morphWeight -= skelAnime->morphRate * updateRate;
if (skelAnime->morphWeight <= 0.0f) {
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;
}
@@ -1273,16 +1269,16 @@ 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 = (s32)globalCtx->state.framerateDivisor * 0.5f;
+ f32 updateRate = (s32)play->state.framerateDivisor * 0.5f;
skelAnime->morphWeight -= skelAnime->morphRate * updateRate;
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);
}
}
@@ -1291,8 +1287,8 @@ void LinkAnimation_AnimateFrame(GlobalContext* globalCtx, SkelAnime* skelAnime)
/**
* Advances a Link animation that loops over its full length
*/
-s32 LinkAnimation_Loop(GlobalContext* globalCtx, SkelAnime* skelAnime) {
- f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f;
+s32 LinkAnimation_Loop(PlayState* play, SkelAnime* skelAnime) {
+ f32 updateRate = (s32)play->state.framerateDivisor * 0.5f;
skelAnime->curFrame += skelAnime->playSpeed * updateRate;
if (skelAnime->curFrame < 0.0f) {
@@ -1300,18 +1296,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) {
- f32 updateRate = (s32)globalCtx->state.framerateDivisor * 0.5f;
+s32 LinkAnimation_Once(PlayState* play, SkelAnime* skelAnime) {
+ f32 updateRate = (s32)play->state.framerateDivisor * 0.5f;
if (skelAnime->curFrame == skelAnime->endFrame) {
- LinkAnimation_AnimateFrame(globalCtx, skelAnime);
+ LinkAnimation_AnimateFrame(play, skelAnime);
return 1;
}
@@ -1326,14 +1322,14 @@ s32 LinkAnimation_Once(GlobalContext* globalCtx, SkelAnime* skelAnime) {
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;
}
@@ -1344,7 +1340,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))) {
@@ -1354,15 +1350,14 @@ void LinkAnimation_Change(GlobalContext* globalCtx, SkelAnime* skelAnime, LinkAn
morphFrames = -morphFrames;
} else {
skelAnime->update.link = 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;
}
@@ -1378,104 +1373,100 @@ 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->common),
+void LinkAnimation_PlayOnce(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) {
+ LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common),
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->common),
+ LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common),
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->common),
+void LinkAnimation_PlayLoop(PlayState* play, SkelAnime* skelAnime, LinkAnimationHeader* animation) {
+ LinkAnimation_Change(play, skelAnime, animation, 1.0f, 0.0f, Animation_GetLastFrame(&animation->common),
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->common),
+ LinkAnimation_Change(play, skelAnime, animation, playSpeed, 0.0f, Animation_GetLastFrame(&animation->common),
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
*/
-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);
}
/**
@@ -1525,7 +1516,7 @@ s32 LinkAnimation_OnFrame(SkelAnime* skelAnime, f32 frame) {
/**
* Initializes a normal skeleton to a looping animation, dynamically allocating the frame tables if not provided.
*/
-void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
+void SkelAnime_Init(PlayState* play, SkelAnime* skelAnime, SkeletonHeader* skeletonHeaderSeg,
AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) {
SkeletonHeader* skeletonHeader;
@@ -1548,7 +1539,7 @@ void SkelAnime_Init(GlobalContext* globalCtx, SkelAnime* skelAnime, SkeletonHead
/**
* Initializes a flex skeleton to a looping animation, dynamically allocating the frame tables if not given.
*/
-void SkelAnime_InitFlex(GlobalContext* globalCtx, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg,
+void SkelAnime_InitFlex(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeader* skeletonHeaderSeg,
AnimationHeader* animation, Vec3s* jointTable, Vec3s* morphTable, s32 limbCount) {
FlexSkeletonHeader* skeletonHeader;
@@ -1963,7 +1954,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_Free(skelAnime->jointTable);
}
diff --git a/src/code/z_skin.c b/src/code/z_skin.c
index de449c02d..0d3e0bf85 100644
--- a/src/code/z_skin.c
+++ b/src/code/z_skin.c
@@ -182,11 +182,11 @@ void Skin_DrawLimb(GraphicsContext* gfxCtx, Skin* skin, s32 limbIndex, Gfx* dLis
CLOSE_DISPS(gfxCtx);
}
-void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
+void Skin_DrawImpl(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw,
SkinOverrideLimbDraw overrideLimbDraw, s32 setTranslation, s32 arg6, s32 drawFlags) {
s32 i;
SkinLimb** skeleton;
- GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
+ GraphicsContext* gfxCtx = play->state.gfxCtx;
OPEN_DISPS(gfxCtx);
@@ -212,7 +212,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD
s32 segmentType;
if (overrideLimbDraw != NULL) {
- shouldDraw = overrideLimbDraw(actor, globalCtx, i, skin);
+ shouldDraw = overrideLimbDraw(actor, play, i, skin);
}
segmentType = ((SkinLimb*)Lib_SegmentedToVirtual(skeleton[i]))->segmentType;
@@ -225,7 +225,7 @@ void Skin_DrawImpl(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostD
}
if (postDraw != NULL) {
- postDraw(actor, globalCtx, skin);
+ postDraw(actor, play, skin);
}
close_disps:;
@@ -233,26 +233,26 @@ close_disps:;
}
// allows specifying postDraw and setTranslation
-void func_80138228(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) {
- Skin_DrawImpl(actor, globalCtx, skin, postDraw, NULL, setTranslation, false, 0);
+void func_80138228(Actor* actor, PlayState* play, Skin* skin, SkinPostDraw postDraw, s32 setTranslation) {
+ Skin_DrawImpl(actor, play, skin, postDraw, NULL, setTranslation, false, 0);
}
// allows specifying OverrideLimbDraw, postDraw and setTranslation
-void func_80138258(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
+void func_80138258(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, postDraw, setTranslation, and arg6
-void func_8013828C(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
+void func_8013828C(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_801382C4(Actor* actor, GlobalContext* globalCtx, Skin* skin, SkinPostDraw postDraw,
+void func_801382C4(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 d45b9bc25..edbcef05f 100644
--- a/src/code/z_skin_awb.c
+++ b/src/code/z_skin_awb.c
@@ -105,7 +105,7 @@ void Skin_Free(GameState* gameState, Skin* skin) {
ZeldaArena_Free(skin->vtxTable);
}
- SkelAnime_Free(&skin->skelAnime, (GlobalContext*)gameState);
+ SkelAnime_Free(&skin->skelAnime, (PlayState*)gameState);
}
}
diff --git a/src/code/z_snap.c b/src/code/z_snap.c
index f85f33f0a..2156950f1 100644
--- a/src/code/z_snap.c
+++ b/src/code/z_snap.c
@@ -2,10 +2,10 @@
typedef struct {
Actor actor;
- s32 (*pictoFunc)(GlobalContext* globalCtx, Actor* actor);
+ s32 (*pictoFunc)(PlayState* play, Actor* actor);
} PictoActor;
-s32 func_8013A240(GlobalContext* globalCtx) {
+s32 func_8013A240(PlayState* play) {
PictoActor* pictoActor;
Actor* actor;
s32 type = 0;
@@ -15,15 +15,15 @@ s32 func_8013A240(GlobalContext* globalCtx) {
gSaveContext.save.pictoFlags0 = 0;
gSaveContext.save.pictoFlags1 = 0;
- if (globalCtx->sceneNum == SCENE_20SICHITAI) {
+ if (play->sceneNum == SCENE_20SICHITAI) {
func_8013A41C(1);
}
for (; type < 12; type++) {
- for (actor = globalCtx->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) {
+ for (actor = play->actorCtx.actorLists[type].first; actor != NULL; actor = actor->next) {
seen = 0;
- switch (globalCtx->sceneNum) {
+ switch (play->sceneNum) {
case SCENE_20SICHITAI:
if ((actor->id == ACTOR_EN_MNK) || (actor->id == ACTOR_EN_BIGOKUTA)) {
seen = 1;
@@ -63,7 +63,7 @@ s32 func_8013A240(GlobalContext* globalCtx) {
if (seen != 0) {
pictoActor = (PictoActor*)actor;
if (pictoActor->pictoFunc != NULL) {
- if ((pictoActor->pictoFunc)(globalCtx, actor) == 0) {
+ if ((pictoActor->pictoFunc)(play, actor) == 0) {
count++;
}
}
@@ -107,14 +107,14 @@ s16 func_8013A504(s16 val) {
return (val >= 0) ? val : -val;
}
-s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin,
- f32 distanceMax, s16 angleError) {
+s32 func_8013A530(PlayState* play, Actor* actor, s32 flag, Vec3f* pos, Vec3s* rot, f32 distanceMin, f32 distanceMax,
+ s16 angleError) {
Vec3f screenSpace;
s16 x;
s16 y;
f32 distance;
CollisionPoly* poly;
- Camera* camera = GET_ACTIVE_CAM(globalCtx);
+ Camera* camera = GET_ACTIVE_CAM(play);
Actor* actors[2];
s32 ret = 0;
s32 bgId;
@@ -132,7 +132,7 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos,
ret |= 0x3E;
}
- Actor_GetProjectedPos(globalCtx, pos, &screenSpace, &distance);
+ Actor_GetProjectedPos(play, pos, &screenSpace, &distance);
x = (s16)(screenSpace.x * distance * 160.0f + 160.0f) - 85;
y = (s16)(screenSpace.y * distance * -120.0f + 120.0f) - 67;
if ((x < 0) || (150 < x) || (y < 0) || (105 < y)) {
@@ -140,15 +140,15 @@ s32 func_8013A530(GlobalContext* globalCtx, Actor* actor, s32 flag, Vec3f* pos,
ret |= 0x3D;
}
- if (BgCheck_ProjectileLineTest(&globalCtx->colCtx, pos, &camera->eye, &screenSpace, &poly, true, true, true, true,
+ if (BgCheck_ProjectileLineTest(&play->colCtx, pos, &camera->eye, &screenSpace, &poly, true, true, true, true,
&bgId)) {
func_8013A41C(0x3C);
ret |= 0x3C;
}
actors[0] = actor;
- actors[1] = &GET_PLAYER(globalCtx)->actor;
- if (CollisionCheck_LineOCCheck(globalCtx, &globalCtx->colChkCtx, pos, &camera->eye, actors, 2)) {
+ actors[1] = &GET_PLAYER(play)->actor;
+ if (CollisionCheck_LineOCCheck(play, &play->colChkCtx, pos, &camera->eye, actors, 2)) {
func_8013A41C(0x3B);
ret |= 0x3B;
}
diff --git a/src/code/z_sound_source.c b/src/code/z_sound_source.c
index ba7036a4c..2cdc3ab3a 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);
if (source->playSfxEachFrame) {
Audio_PlaySfxAtPos(&source->projectedPos, source->sfxId);
}
@@ -29,15 +29,15 @@ void SoundSource_UpdateAll(GlobalContext* globalCtx) {
}
}
-void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) {
+void SoundSource_Add(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId, u32 playSfxEachFrame) {
s32 countdown;
SoundSource* source;
s32 smallestCountdown = 0xFFFF;
SoundSource* backupSource = NULL;
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;
}
@@ -52,7 +52,7 @@ void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u1
}
// 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);
}
@@ -62,14 +62,14 @@ void SoundSource_Add(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u1
source->playSfxEachFrame = playSfxEachFrame;
source->sfxId = sfxId;
- SkinMatrix_Vec3fMtxFMultXYZ(&globalCtx->viewProjectionMtxF, &source->worldPos, &source->projectedPos);
+ SkinMatrix_Vec3fMtxFMultXYZ(&play->viewProjectionMtxF, &source->worldPos, &source->projectedPos);
Audio_PlaySfxAtPos(&source->projectedPos, sfxId);
}
-void SoundSource_PlaySfxAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) {
- SoundSource_Add(globalCtx, worldPos, duration, sfxId, false);
+void SoundSource_PlaySfxAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId) {
+ SoundSource_Add(play, worldPos, duration, sfxId, false);
}
-void SoundSource_PlaySfxEachFrameAtFixedWorldPos(GlobalContext* globalCtx, Vec3f* worldPos, u32 duration, u16 sfxId) {
- SoundSource_Add(globalCtx, worldPos, duration, sfxId, true);
+void SoundSource_PlaySfxEachFrameAtFixedWorldPos(PlayState* play, Vec3f* worldPos, u32 duration, u16 sfxId) {
+ SoundSource_Add(play, worldPos, duration, sfxId, true);
}
diff --git a/src/code/z_sram_NES.c b/src/code/z_sram_NES.c
index 90b60809e..5129212c2 100644
--- a/src/code/z_sram_NES.c
+++ b/src/code/z_sram_NES.c
@@ -226,7 +226,7 @@ void Sram_ClearFlagsAtDawnOfTheFirstDay(void) {
/**
* Used by Song of Time (when clicking "Yes") and (indirectly) by the "Dawn of the New Day" cutscene
*/
-void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
+void Sram_SaveEndOfCycle(PlayState* play) {
s16 sceneNum;
s32 j;
s32 i;
@@ -243,14 +243,14 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
gSaveContext.save.playerData.deaths = 999;
}
- sceneNum = Play_GetOriginalSceneNumber(globalCtx->sceneNum);
- Play_SaveCycleSceneFlags(&globalCtx->state);
+ sceneNum = Play_GetOriginalSceneNumber(play->sceneNum);
+ Play_SaveCycleSceneFlags(&play->state);
- globalCtx->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2];
- globalCtx->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0];
- globalCtx->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1];
- globalCtx->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3];
- globalCtx->actorCtx.flags.clearedRoom = 0;
+ play->actorCtx.flags.chest &= D_801C5FC0[sceneNum][2];
+ play->actorCtx.flags.switches[0] &= D_801C5FC0[sceneNum][0];
+ play->actorCtx.flags.switches[1] &= D_801C5FC0[sceneNum][1];
+ play->actorCtx.flags.collectible[0] &= D_801C5FC0[sceneNum][3];
+ play->actorCtx.flags.clearedRoom = 0;
for (i = 0; i < SCENE_MAX; i++) {
gSaveContext.cycleSceneFlags[i].switch0 = ((void)0, gSaveContext.cycleSceneFlags[i].switch0) & D_801C5FC0[i][0];
@@ -346,7 +346,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
for (j = 1; j < 4; j++) {
if (GET_CUR_FORM_BTN_ITEM(j) == gSaveContext.save.inventory.items[i]) {
SET_CUR_FORM_BTN_ITEM(j, ITEM_BOTTLE);
- func_80112B40(globalCtx, j);
+ func_80112B40(play, j);
}
}
gSaveContext.save.inventory.items[i] = ITEM_BOTTLE;
@@ -415,7 +415,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
for (j = 1; j < 4; j++) {
if (GET_CUR_FORM_BTN_ITEM(j) >= ITEM_MOON_TEAR && GET_CUR_FORM_BTN_ITEM(j) <= ITEM_PENDANT_MEMORIES) {
SET_CUR_FORM_BTN_ITEM(j, ITEM_NONE);
- func_80112B40(globalCtx, j);
+ func_80112B40(play, j);
}
}
@@ -446,7 +446,7 @@ void Sram_SaveEndOfCycle(GlobalContext* globalCtx) {
gSaveContext.jinxTimer = 0;
gSaveContext.rupeeAccumulator = 0;
- func_800F3B2C(globalCtx);
+ func_800F3B2C(play);
}
void Sram_IncrementDay(void) {
@@ -1519,9 +1519,9 @@ void func_80146EBC(SramContext* sramCtx, s32 curPage, s32 numPages) {
/**
* Saves the game on the very first time Player enters South Clock Town from the Clock Tower
*/
-void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) {
+void Sram_SaveSpecialEnterClockTown(PlayState* play) {
s32 pad[2];
- SramContext* sramCtx = &globalCtx->sramCtx;
+ SramContext* sramCtx = &play->sramCtx;
gSaveContext.save.isFirstCycle = true;
gSaveContext.save.isOwlSave = false;
@@ -1532,7 +1532,7 @@ void Sram_SaveSpecialEnterClockTown(GlobalContext* globalCtx) {
/**
* Saves when beating the game, after showing the "Dawn of the New Day" message
*/
-void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) {
+void Sram_SaveSpecialNewDay(PlayState* play) {
s32 cutscene = gSaveContext.save.cutscene;
s32 day;
u16 time = gSaveContext.save.time;
@@ -1542,14 +1542,13 @@ void Sram_SaveSpecialNewDay(GlobalContext* globalCtx) {
// Unconfirmed: "Obtained Fierce Deity Mask?"
gSaveContext.save.weekEventReg[84] &= (u8)~0x20;
- Sram_SaveEndOfCycle(globalCtx);
- func_8014546C(&globalCtx->sramCtx);
+ Sram_SaveEndOfCycle(play);
+ func_8014546C(&play->sramCtx);
gSaveContext.save.day = day;
gSaveContext.save.time = time;
gSaveContext.save.cutscene = cutscene;
- func_80185F64(globalCtx->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2],
- D_801C67F0[gSaveContext.fileNum * 2]);
+ func_80185F64(play->sramCtx.saveBuf, D_801C67C8[gSaveContext.fileNum * 2], D_801C67F0[gSaveContext.fileNum * 2]);
}
void func_80147008(SramContext* sramCtx, u32 curPage, u32 numPages) {
diff --git a/src/code/z_sub_s.c b/src/code/z_sub_s.c
index 4968185d0..f8c6b1a21 100644
--- a/src/code/z_sub_s.c
+++ b/src/code/z_sub_s.c
@@ -17,12 +17,12 @@ s32 D_801C5DBC[] = { 0, 1 }; // Unused
/**
* Finds the first EnDoor instance with unk_1A4 == 5 and the specified switchFlag.
*/
-EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) {
+EnDoor* SubS_FindDoor(PlayState* play, s32 switchFlag) {
Actor* actor = NULL;
EnDoor* door;
while (true) {
- actor = SubS_FindActor(globalCtx, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR);
+ actor = SubS_FindActor(play, actor, ACTORCAT_DOOR, ACTOR_EN_DOOR);
door = (EnDoor*)actor;
if (actor == NULL) {
@@ -44,7 +44,7 @@ EnDoor* SubS_FindDoor(GlobalContext* globalCtx, s32 switchFlag) {
return door;
}
-Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void** skeleton, Vec3s* jointTable,
+Gfx* SubS_DrawTransformFlexLimb(PlayState* play, s32 limbIndex, void** skeleton, Vec3s* jointTable,
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw,
TransformLimbDraw transformLimbDraw, Actor* actor, Mtx** mtx, Gfx* gfx) {
StandardLimb* limb;
@@ -62,11 +62,11 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void**
pos.z = limb->jointPos.z;
newDList = limbDList = limb->dList;
- if ((overrideLimbDraw == NULL) || !overrideLimbDraw(globalCtx, limbIndex, &newDList, &pos, &rot, actor, &gfx)) {
+ if ((overrideLimbDraw == NULL) || !overrideLimbDraw(play, limbIndex, &newDList, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Push();
- transformLimbDraw(globalCtx, limbIndex, actor, &gfx);
+ transformLimbDraw(play, limbIndex, actor, &gfx);
if (newDList != NULL) {
Matrix_ToMtx(*mtx);
@@ -80,15 +80,15 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void**
Matrix_Pop();
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, limbIndex, &limbDList, &rot, actor, &gfx);
+ postLimbDraw(play, limbIndex, &limbDList, &rot, actor, &gfx);
}
if (limb->child != LIMB_DONE) {
- gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
+ gfx = SubS_DrawTransformFlexLimb(play, limb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
transformLimbDraw, actor, mtx, gfx);
}
Matrix_Pop();
if (limb->sibling != LIMB_DONE) {
- gfx = SubS_DrawTransformFlexLimb(globalCtx, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
+ gfx = SubS_DrawTransformFlexLimb(play, limb->sibling, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
transformLimbDraw, actor, mtx, gfx);
}
return gfx;
@@ -103,7 +103,7 @@ Gfx* SubS_DrawTransformFlexLimb(GlobalContext* globalCtx, s32 limbIndex, void**
* coordinates.
* Note that the `TransformLimbDraw` does not have a NULL check, so must be provided even if empty.
*/
-Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, s32 dListCount,
+Gfx* SubS_DrawTransformFlex(PlayState* play, void** skeleton, Vec3s* jointTable, s32 dListCount,
OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw,
TransformLimbDraw transformLimbDraw, Actor* actor, Gfx* gfx) {
StandardLimb* rootLimb;
@@ -112,7 +112,7 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
Gfx* limbDList;
Vec3f pos;
Vec3s rot;
- Mtx* mtx = GRAPH_ALLOC(globalCtx->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx)));
+ Mtx* mtx = GRAPH_ALLOC(play->state.gfxCtx, ALIGN16(dListCount * sizeof(Mtx)));
if (skeleton == NULL) {
return NULL;
@@ -128,11 +128,11 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
newDlist = rootLimb->dList;
limbDList = rootLimb->dList;
- if (overrideLimbDraw == NULL || !overrideLimbDraw(globalCtx, 1, &newDlist, &pos, &rot, actor, &gfx)) {
+ if (overrideLimbDraw == NULL || !overrideLimbDraw(play, 1, &newDlist, &pos, &rot, actor, &gfx)) {
Matrix_TranslateRotateZYX(&pos, &rot);
Matrix_Push();
- transformLimbDraw(globalCtx, 1, actor, &gfx);
+ transformLimbDraw(play, 1, actor, &gfx);
if (newDlist != NULL) {
Matrix_ToMtx(mtx);
@@ -147,21 +147,21 @@ Gfx* SubS_DrawTransformFlex(GlobalContext* globalCtx, void** skeleton, Vec3s* jo
}
if (postLimbDraw != NULL) {
- postLimbDraw(globalCtx, 1, &limbDList, &rot, actor, &gfx);
+ postLimbDraw(play, 1, &limbDList, &rot, actor, &gfx);
}
if (rootLimb->child != LIMB_DONE) {
- gfx = SubS_DrawTransformFlexLimb(globalCtx, rootLimb->child, skeleton, jointTable, overrideLimbDraw,
- postLimbDraw, transformLimbDraw, actor, &mtx, gfx);
+ gfx = SubS_DrawTransformFlexLimb(play, rootLimb->child, skeleton, jointTable, overrideLimbDraw, postLimbDraw,
+ transformLimbDraw, actor, &mtx, gfx);
}
Matrix_Pop();
return gfx;
}
-s32 SubS_InCsMode(GlobalContext* globalCtx) {
+s32 SubS_InCsMode(PlayState* play) {
s32 inCsMode = false;
- if (Play_InCsMode(globalCtx)) {
+ if (Play_InCsMode(play)) {
inCsMode = true;
}
@@ -434,14 +434,14 @@ s32 SubS_TimePathing_Update(Path* path, f32* progress, s32* elapsedTime, s32 way
/**
* Computes the initial Y component of a time based path
*
- * @param[in] globalCtx
+ * @param[in] play
* @param[in] path
* @param[in] waypoint the current waypoint, this and the previous two points will be used to compute the target pos
* @param[out] targetPos the computed position to move to, only the Y component has meaning
*
* @note Same note as SubS_TimePathing_Update()
*/
-void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32 waypoint, Vec3f* targetPos) {
+void SubS_TimePathing_ComputeInitialY(PlayState* play, Path* path, s32 waypoint, Vec3f* targetPos) {
Vec3s* points = Lib_SegmentedToVirtual(path->points);
Vec3f posA;
Vec3f posB;
@@ -475,18 +475,17 @@ void SubS_TimePathing_ComputeInitialY(GlobalContext* globalCtx, Path* path, s32
posB = *targetPos;
posA.y = max;
posB.y = min;
- if (BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true,
- &bgId)) {
+ if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posResult, &outPoly, true, true, true, true, &bgId)) {
targetPos->y = posResult.y;
}
}
-Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) {
+Path* SubS_GetAdditionalPath(PlayState* play, u8 pathIndex, s32 max) {
Path* path;
s32 i = 0;
do {
- path = &globalCtx->setupPathList[pathIndex];
+ path = &play->setupPathList[pathIndex];
if (i >= max) {
break;
}
@@ -500,7 +499,7 @@ Path* SubS_GetAdditionalPath(GlobalContext* globalCtx, u8 pathIndex, s32 max) {
/**
* Finds the nearest actor instance of a specified Id and category to an actor.
*/
-Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCategory, s16 actorId) {
+Actor* SubS_FindNearestActor(Actor* actor, PlayState* play, u8 actorCategory, s16 actorId) {
Actor* actorIter = NULL;
Actor* actorTmp;
f32 dist;
@@ -509,7 +508,7 @@ Actor* SubS_FindNearestActor(Actor* actor, GlobalContext* globalCtx, u8 actorCat
s32 isSetup = false;
do {
- actorIter = SubS_FindActor(globalCtx, actorIter, actorCategory, actorId);
+ actorIter = SubS_FindActor(play, actorIter, actorCategory, actorId);
actorTmp = actorIter;
if (actorTmp == NULL) {
@@ -586,7 +585,7 @@ s32 SubS_HasReachedPoint(Actor* actor, Path* path, s32 pointIndex) {
return reached;
}
-Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s32* startPointIndex) {
+Path* SubS_GetDayDependentPath(PlayState* play, u8 pathIndex, u8 max, s32* startPointIndex) {
Path* path = NULL;
s32 found = false;
s32 time = (((s16)TIME_TO_MINUTES_F(gSaveContext.save.time) % 60) +
@@ -599,7 +598,7 @@ Path* SubS_GetDayDependentPath(GlobalContext* globalCtx, u8 pathIndex, u8 max, s
}
while (pathIndex != 0xFF) {
- path = &globalCtx->setupPathList[pathIndex];
+ path = &play->setupPathList[pathIndex];
if (sPathDayFlags[day] & path->unk2) {
found = true;
break;
@@ -817,29 +816,29 @@ s32 SubS_CopyPointFromPathCheckBounds(Path* path, s32 pointIndex, Vec3f* dst) {
}
//! TODO: Needs docs with func_800B8500
-s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 itemId, s32 type) {
+s32 func_8013C964(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 itemId, s32 type) {
s32 ret = false;
s16 x;
s16 y;
f32 xzDistToPlayerTemp;
- Actor_GetScreenPos(globalCtx, actor, &x, &y);
+ Actor_GetScreenPos(play, actor, &x, &y);
switch (type) {
case 1:
yRange = fabsf(actor->playerHeightRel) + 1.0f;
xzRange = actor->xzDistToPlayer + 1.0f;
- ret = Actor_PickUp(actor, globalCtx, itemId, xzRange, yRange);
+ ret = Actor_PickUp(actor, play, itemId, xzRange, yRange);
break;
case 2:
if ((fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) {
- ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
+ ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
case 3:
//! @bug: Both x and y conditionals are always true, || should be an &&
if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT))) {
- ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
+ ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
case 4:
@@ -848,7 +847,7 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
xzDistToPlayerTemp = actor->xzDistToPlayer;
actor->xzDistToPlayer = 0.0f;
actor->flags |= 0x10000;
- ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
+ ret = func_800B8500(actor, play, xzRange, yRange, itemId);
actor->xzDistToPlayer = xzDistToPlayerTemp;
break;
case 5:
@@ -856,7 +855,7 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) &&
(fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange) && actor->isTargeted) {
actor->flags |= 0x10000;
- ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
+ ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
case 6:
@@ -864,7 +863,7 @@ s32 func_8013C964(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRang
if (((x >= 0) || (x < SCREEN_WIDTH)) && ((y >= 0) || (y < SCREEN_HEIGHT)) &&
(fabsf(actor->playerHeightRel) <= yRange) && (actor->xzDistToPlayer <= xzRange)) {
actor->flags |= 0x10000;
- ret = func_800B8500(actor, globalCtx, xzRange, yRange, itemId);
+ ret = func_800B8500(actor, play, xzRange, yRange, itemId);
}
break;
}
@@ -1090,8 +1089,8 @@ s32 SubS_AngleDiffLessEqual(s16 angleA, s16 threshold, s16 angleB) {
return (ABS_ALT(BINANG_SUB(angleB, angleA)) <= threshold) ? true : false;
}
-Path* SubS_GetPathByIndex(GlobalContext* globalCtx, s16 pathIndex, s16 max) {
- return (pathIndex != max) ? &globalCtx->setupPathList[pathIndex] : NULL;
+Path* SubS_GetPathByIndex(PlayState* play, s16 pathIndex, s16 max) {
+ return (pathIndex != max) ? &play->setupPathList[pathIndex] : NULL;
}
s32 SubS_CopyPointFromPath(Path* path, s32 pointIndex, Vec3f* dst) {
@@ -1153,22 +1152,22 @@ s16 SubS_GetDistSqAndOrientPath(Path* path, s32 pointIndex, Vec3f* pos, f32* dis
return Math_Atan2S(diffX, diffZ);
}
-s8 SubS_IsObjectLoaded(s8 index, GlobalContext* globalCtx) {
- return !Object_IsLoaded(&globalCtx->objectCtx, index) ? false : true;
+s8 SubS_IsObjectLoaded(s8 index, PlayState* play) {
+ return !Object_IsLoaded(&play->objectCtx, index) ? false : true;
}
-s8 SubS_GetObjectIndex(s16 id, GlobalContext* globalCtx) {
- return Object_GetIndex(&globalCtx->objectCtx, id);
+s8 SubS_GetObjectIndex(s16 id, PlayState* play) {
+ return Object_GetIndex(&play->objectCtx, id);
}
/**
* Finds the first actor instance of a specified Id and category.
*/
-Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorCategory, s16 actorId) {
+Actor* SubS_FindActor(PlayState* play, Actor* actorListStart, u8 actorCategory, s16 actorId) {
Actor* actor = actorListStart;
if (actor == NULL) {
- actor = globalCtx->actorCtx.actorLists[actorCategory].first;
+ actor = play->actorCtx.actorLists[actorCategory].first;
}
while (actor != NULL && actorId != actor->id) {
@@ -1178,9 +1177,9 @@ Actor* SubS_FindActor(GlobalContext* globalCtx, Actor* actorListStart, u8 actorC
return actor;
}
-s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) {
+s32 SubS_FillLimbRotTables(PlayState* play, s16* limbRotTableY, s16* limbRotTableZ, s32 numLimbs) {
s32 i;
- u32 frames = globalCtx->gameplayFrames;
+ u32 frames = play->gameplayFrames;
for (i = 0; i < numLimbs; i++) {
limbRotTableY[i] = (i * 50 + 0x814) * frames;
@@ -1190,7 +1189,7 @@ s32 SubS_FillLimbRotTables(GlobalContext* globalCtx, s16* limbRotTableY, s16* li
return true;
}
-s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) {
+s32 SubS_IsFloorAbove(PlayState* play, Vec3f* pos, f32 distAbove) {
CollisionPoly* outPoly;
Vec3f posA;
Vec3f posB;
@@ -1199,8 +1198,7 @@ s32 SubS_IsFloorAbove(GlobalContext* globalCtx, Vec3f* pos, f32 distAbove) {
posA = posB = *pos;
posB.y += distAbove;
- return BgCheck_EntityLineTest1(&globalCtx->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true,
- &bgId);
+ return BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posResult, &outPoly, false, true, false, true, &bgId);
}
s32 SubS_CopyPointFromPathList(Path* paths, s32 pathIndex, s32 pointIndex, Vec3f* dst) {
@@ -1220,12 +1218,11 @@ u8 SubS_GetPathCountFromPathList(Path* paths, s32 pathIndex) {
return path->count;
}
-void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath,
- Path* paths, s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex,
- u8 flags) {
+void SubS_ActorPathing_Init(PlayState* play, Vec3f* worldPos, Actor* actor, ActorPathing* actorPath, Path* paths,
+ s32 pathIndex, s32 begPointIndex, s32 endPointIndex, s32 curPointIndex, u8 flags) {
Path* path;
- actorPath->setupPathList = globalCtx->setupPathList;
+ actorPath->setupPathList = play->setupPathList;
actorPath->pathIndex = pathIndex;
path = &paths[pathIndex];
actorPath->points = Lib_SegmentedToVirtual(path->points);
@@ -1250,9 +1247,9 @@ void SubS_ActorPathing_Init(GlobalContext* globalCtx, Vec3f* worldPos, Actor* ac
actorPath->prevFlags = flags;
}
-s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath,
- ActorPathingComputeFunc computePointInfoFunc, ActorPathingUpdateFunc updateActorInfoFunc,
- ActorPathingUpdateFunc moveFunc, ActorPathingUpdateFunc setNextPointFunc) {
+s32 SubS_ActorPathing_Update(PlayState* play, ActorPathing* actorPath, ActorPathingComputeFunc computePointInfoFunc,
+ ActorPathingUpdateFunc updateActorInfoFunc, ActorPathingUpdateFunc moveFunc,
+ ActorPathingUpdateFunc setNextPointFunc) {
s32 shouldSetNextPoint;
s32 reupdate;
@@ -1272,24 +1269,24 @@ s32 SubS_ActorPathing_Update(GlobalContext* globalCtx, ActorPathing* actorPath,
do {
shouldSetNextPoint = false;
if (actorPath->computePointInfoFunc != NULL) {
- actorPath->computePointInfoFunc(globalCtx, actorPath);
+ actorPath->computePointInfoFunc(play, actorPath);
}
if (actorPath->updateActorInfoFunc != NULL) {
- shouldSetNextPoint = actorPath->updateActorInfoFunc(globalCtx, actorPath);
+ shouldSetNextPoint = actorPath->updateActorInfoFunc(play, actorPath);
}
if (shouldSetNextPoint) {
if (actorPath->setNextPointFunc != NULL) {
- reupdate = actorPath->setNextPointFunc(globalCtx, actorPath);
+ reupdate = actorPath->setNextPointFunc(play, actorPath);
}
} else if (actorPath->moveFunc != NULL) {
- reupdate = actorPath->moveFunc(globalCtx, actorPath);
+ reupdate = actorPath->moveFunc(play, actorPath);
}
} while (reupdate);
actorPath->prevFlags = actorPath->flags;
return false;
}
-void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing* actorPath) {
+void SubS_ActorPathing_ComputePointInfo(PlayState* play, ActorPathing* actorPath) {
Vec3f diff;
actorPath->curPoint.x = actorPath->points[actorPath->curPointIndex].x + actorPath->pointOffset.x;
@@ -1305,17 +1302,17 @@ void SubS_ActorPathing_ComputePointInfo(GlobalContext* globalCtx, ActorPathing*
actorPath->rotToCurPoint.z = 0;
}
-s32 SubS_ActorPathing_MoveWithGravity(GlobalContext* globalCtx, ActorPathing* actorPath) {
+s32 SubS_ActorPathing_MoveWithGravity(PlayState* play, ActorPathing* actorPath) {
Actor_MoveWithGravity(actorPath->actor);
return false;
}
-s32 SubS_ActorPathing_MoveWithoutGravityReverse(GlobalContext* globalCtx, ActorPathing* actorPath) {
+s32 SubS_ActorPathing_MoveWithoutGravityReverse(PlayState* play, ActorPathing* actorPath) {
Actor_MoveWithoutGravityReverse(actorPath->actor);
return false;
}
-s32 SubS_ActorPathing_SetNextPoint(GlobalContext* globalCtx, ActorPathing* actorPath) {
+s32 SubS_ActorPathing_SetNextPoint(PlayState* play, ActorPathing* actorPath) {
s32 reupdate = true;
Math_Vec3f_Copy(&actorPath->prevPoint, &actorPath->curPoint);
@@ -1484,18 +1481,18 @@ s32 SubS_LineSegVsPlane(Vec3f* point, Vec3s* rot, Vec3f* unitVec, Vec3f* linePoi
* Finds the first actor instance of a specified Id and category verified with a custom callback.
* The callback should return `true` when the actor is succesfully verified.
*/
-Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actorListStart, u8 actorCategory,
- s16 actorId, void* verifyData, VerifyActor verifyActor) {
+Actor* SubS_FindActorCustom(PlayState* play, Actor* actor, Actor* actorListStart, u8 actorCategory, s16 actorId,
+ void* verifyData, VerifyActor verifyActor) {
Actor* actorIter = actorListStart;
if (actorListStart == NULL) {
- actorIter = globalCtx->actorCtx.actorLists[actorCategory].first;
+ actorIter = play->actorCtx.actorLists[actorCategory].first;
}
- while (actorIter != NULL && (actorId != actorIter->id ||
- (actorId == actorIter->id &&
- (verifyActor == NULL ||
- (verifyActor != NULL && !verifyActor(globalCtx, actor, actorIter, verifyData)))))) {
+ while (actorIter != NULL &&
+ (actorId != actorIter->id ||
+ (actorId == actorIter->id &&
+ (verifyActor == NULL || (verifyActor != NULL && !verifyActor(play, actor, actorIter, verifyData)))))) {
actorIter = actorIter->next;
}
@@ -1503,18 +1500,18 @@ Actor* SubS_FindActorCustom(GlobalContext* globalCtx, Actor* actor, Actor* actor
}
//! TODO: Needs docs with func_800B8500
-s32 func_8013E748(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data,
+s32 func_8013E748(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exchangeItemId, void* data,
func_8013E748_VerifyFunc verifyFunc) {
s32 ret = false;
- if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(globalCtx, actor, data))) {
- ret = func_800B8500(actor, globalCtx, xzRange, yRange, exchangeItemId);
+ if ((verifyFunc == NULL) || ((verifyFunc != NULL) && verifyFunc(play, actor, data))) {
+ ret = func_800B8500(actor, play, xzRange, yRange, exchangeItemId);
}
return ret;
}
-s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, void* data) {
- Player* player = GET_PLAYER(globalCtx);
+s32 SubS_ActorAndPlayerFaceEachOther(PlayState* play, Actor* actor, void* data) {
+ Player* player = GET_PLAYER(play);
Vec3s* yawTols = (Vec3s*)data;
s16 playerYaw = ABS(BINANG_SUB(Actor_YawBetweenActors(&player->actor, actor), player->actor.shape.rot.y));
s16 actorYaw = ABS(BINANG_SUB(actor->yawTowardsPlayer, actor->shape.rot.y));
@@ -1533,13 +1530,13 @@ s32 SubS_ActorAndPlayerFaceEachOther(GlobalContext* globalCtx, Actor* actor, voi
}
//! TODO: Needs docs with func_800B8500
-s32 func_8013E8F8(Actor* actor, GlobalContext* globalCtx, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol,
+s32 func_8013E8F8(Actor* actor, PlayState* play, f32 xzRange, f32 yRange, s32 exhangeItemId, s16 playerYawTol,
s16 actorYawTol) {
Vec3s yawTols;
yawTols.x = playerYawTol;
yawTols.y = actorYawTol;
- return func_8013E748(actor, globalCtx, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther);
+ return func_8013E748(actor, play, xzRange, yRange, exhangeItemId, &yawTols, SubS_ActorAndPlayerFaceEachOther);
}
/**
diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c
index 29d1a1aca..7975b1c85 100644
--- a/src/code/z_vr_box.c
+++ b/src/code/z_vr_box.c
@@ -36,7 +36,7 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) {
}
void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) {
- GlobalContext* globalCtx = (GlobalContext*)gameState;
+ PlayState* play = (PlayState*)gameState;
size_t size;
void* offset;
s32 pad;
@@ -75,13 +75,13 @@ void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType)
skyboxCtx->envB = 40;
// Inverted Stone Tower Temple and Inverted Stone Tower
- if ((globalCtx->sceneNum == SCENE_F41) || (globalCtx->sceneNum == SCENE_INISIE_R)) {
+ if ((play->sceneNum == SCENE_F41) || (play->sceneNum == SCENE_INISIE_R)) {
skyboxCtx->rotZ = 3.15000009537f;
}
}
}
-void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) {
+void func_80143324(PlayState* play, SkyboxContext* skyboxCtx, s16 skyType) {
size_t size;
if (1) {}
@@ -89,7 +89,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
if (skyType == 1) {
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
- if (globalCtx->envCtx.unk_10 == 0) {
+ if (play->envCtx.unk_10 == 0) {
// Send a DMA request for the clear sky texture
size = SEGMENT_ROM_SIZE(d2_fine_static);
@@ -106,7 +106,7 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
osRecvMesg(&skyboxCtx->loadQueue, NULL, OS_MESG_BLOCK);
osCreateMesgQueue(&skyboxCtx->loadQueue, &skyboxCtx->loadMsg, 1);
- if (globalCtx->envCtx.unk_11 == 0) {
+ if (play->envCtx.unk_11 == 0) {
// Send a DMA request for the clear sky texture
size = SEGMENT_ROM_SIZE(d2_fine_static);