summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Overton <tom-overton@users.noreply.github.com>2026-02-10 02:59:32 -0800
committerGitHub <noreply@github.com>2026-02-10 07:59:32 -0300
commit1ffe903d317e34b522be1f383e7f71c337e6b24c (patch)
tree89651e8558af3b5bf422517334168d70a78264d9
parent035595f37c889f65c3e873c5b695e8a2fa6bbf18 (diff)
Match `Bg_F40_Switch` for JP 1.1 (#1854)
* Match `Bg_F40_Switch` for JP 1.1 * Put some data and BSS behind the version flag too * Delete comment
-rw-r--r--src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c43
-rw-r--r--src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h2
2 files changed, 45 insertions, 0 deletions
diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c
index 69b6e0a8e..470e7d236 100644
--- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c
+++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.c
@@ -33,12 +33,15 @@ ActorProfile Bg_F40_Switch_Profile = {
/**/ BgF40Switch_Draw,
};
+#if MM_VERSION >= N64_US
s32 sBgF40SwitchGlobalsInitialized = false;
u32 sBgF40SwitchLastUpdateFrame;
+#endif
/*
* Updates all instances of this actor in the current room, unless it's already been called this frame.
*/
+#if MM_VERSION >= N64_US
void BgF40Switch_CheckAll(BgF40Switch* this, PlayState* play) {
if (play->gameplayFrames != sBgF40SwitchLastUpdateFrame) {
u32 pressedSwitchFlags[4] = { 0 };
@@ -94,6 +97,7 @@ void BgF40Switch_CheckAll(BgF40Switch* this, PlayState* play) {
sBgF40SwitchLastUpdateFrame = play->gameplayFrames;
}
}
+#endif
static InitChainEntry sInitChain[] = {
ICHAIN_F32(cullingVolumeDistance, 4000, ICHAIN_CONTINUE),
@@ -111,10 +115,12 @@ void BgF40Switch_Init(Actor* thisx, PlayState* play) {
this->dyna.actor.world.pos.y = this->dyna.actor.home.pos.y + 1.0f;
DynaPolyActor_Init(&this->dyna, DYNA_TRANSFORM_POS);
DynaPolyActor_LoadMesh(play, &this->dyna, &gStoneTowerFloorSwitchCol);
+#if MM_VERSION >= N64_US
if (!sBgF40SwitchGlobalsInitialized) {
sBgF40SwitchLastUpdateFrame = play->gameplayFrames;
sBgF40SwitchGlobalsInitialized = true;
}
+#endif
}
void BgF40Switch_Destroy(Actor* thisx, PlayState* play) {
@@ -133,9 +139,22 @@ void BgF40Switch_Unpress(BgF40Switch* this, PlayState* play) {
}
void BgF40Switch_IdlePressed(BgF40Switch* this, PlayState* play) {
+#if MM_VERSION >= N64_US
if (!this->isPressed) {
this->actionFunc = BgF40Switch_Unpress;
}
+#else
+ if (!DynaPolyActor_IsSwitchPressed(&this->dyna) && !Player_InCsMode(play)) {
+ if (this->switchReleaseDelay <= 0) {
+ this->actionFunc = BgF40Switch_Unpress;
+ Flags_UnsetSwitch(play, BGF40SWITCH_GET_SWITCH_FLAG(&this->dyna.actor));
+ } else {
+ this->switchReleaseDelay--;
+ }
+ } else {
+ this->switchReleaseDelay = 6;
+ }
+#endif
}
void BgF40Switch_Press(BgF40Switch* this, PlayState* play) {
@@ -143,10 +162,14 @@ void BgF40Switch_Press(BgF40Switch* this, PlayState* play) {
if (this->dyna.actor.scale.y <= 0.0165f) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_IKANA_BLOCK_SWITCH);
Rumble_Request(this->dyna.actor.xyzDistToPlayerSq, 120, 20, 10);
+#if MM_VERSION >= N64_US
if (this->isInitiator) {
CutsceneManager_Stop(this->dyna.actor.csId);
this->isInitiator = false;
}
+#else
+ CutsceneManager_Stop(this->dyna.actor.csId);
+#endif
this->actionFunc = BgF40Switch_IdlePressed;
this->dyna.actor.scale.y = 0.0165f;
this->switchReleaseDelay = 6;
@@ -154,32 +177,52 @@ void BgF40Switch_Press(BgF40Switch* this, PlayState* play) {
}
void BgF40Switch_WaitToPress(BgF40Switch* this, PlayState* play) {
+#if MM_VERSION >= N64_US
if (!this->isInitiator || (this->dyna.actor.csId == CS_ID_NONE)) {
+#else
+ if (this->dyna.actor.csId == CS_ID_NONE) {
+#endif
this->actionFunc = BgF40Switch_Press;
+#if MM_VERSION >= N64_US
if (this->isInitiator) {
Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCH_FLAG(&this->dyna.actor));
}
+#else
+ Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCH_FLAG(&this->dyna.actor));
+#endif
} else if (CutsceneManager_IsNext(this->dyna.actor.csId)) {
CutsceneManager_StartWithPlayerCs(this->dyna.actor.csId, &this->dyna.actor);
this->actionFunc = BgF40Switch_Press;
+#if MM_VERSION >= N64_US
if (this->isInitiator) {
Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCH_FLAG(&this->dyna.actor));
}
+#else
+ Flags_SetSwitch(play, BGF40SWITCH_GET_SWITCH_FLAG(&this->dyna.actor));
+#endif
} else {
CutsceneManager_Queue(this->dyna.actor.csId);
}
}
void BgF40Switch_IdleUnpressed(BgF40Switch* this, PlayState* play) {
+#if MM_VERSION >= N64_US
if (this->isPressed) {
this->actionFunc = BgF40Switch_WaitToPress;
}
+#else
+ if (DynaPolyActor_IsSwitchPressed(&this->dyna)) {
+ this->actionFunc = BgF40Switch_WaitToPress;
+ }
+#endif
}
void BgF40Switch_Update(Actor* thisx, PlayState* play) {
BgF40Switch* this = (BgF40Switch*)thisx;
+#if MM_VERSION >= N64_US
BgF40Switch_CheckAll(this, play);
+#endif
this->actionFunc(this, play);
}
diff --git a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h
index 2d9fc589b..41e85469a 100644
--- a/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h
+++ b/src/overlays/actors/ovl_Bg_F40_Switch/z_bg_f40_switch.h
@@ -14,9 +14,11 @@ typedef struct BgF40Switch {
/* 0x15C */ s16 switchReleaseDelay; // frames until a pressed switch becomes released if nothing is still pressing it
/* 0x15E */ s8 isPressed; // Logical state of the switch (pressed or unpressed). Animation state may lag behind this slightly.
/* 0x15F */ s8 wasPressed; // used as temporary during update function
+#if MM_VERSION >= N64_US
// true if this switch is the one that initiated a state change; false if this switch is changing as a result of another switch tied to the same flag.
// this is a temporary flag related to something currently happening, not a permanent property of the switch.
/* 0x160 */ s8 isInitiator;
+#endif
/* 0x164 */ BgF40SwitchActionFunc actionFunc;
} BgF40Switch; // size = 0x168