mirror of
https://github.com/zeldaret/mm.git
synced 2026-05-22 22:44:14 -04:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user