mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-10 19:20:13 +00:00
Match EnTorch2_Update (#975)
* score = 965 * score = 305 * Clean-Up * More clean-up * Down to `sp30` <--> `sp34` swap, and extra `.data + 0x18` at the top? * clean-up * EnTorch2 OK, but does not reloc properly * final cleanup * Remove comments about non-matching * Fix reloc non-matching * Delete reloc * Better solution * PR Suggestions
This commit is contained in:
parent
ac8dd91626
commit
bf53f2c95e
4 changed files with 36 additions and 1886 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,13 +0,0 @@
|
||||||
.include "macro.inc"
|
|
||||||
|
|
||||||
# assembler directives
|
|
||||||
.set noat # allow manual use of $at
|
|
||||||
.set noreorder # don't insert nops after branches
|
|
||||||
.set gp=64 # allow use of 64-bit general purpose registers
|
|
||||||
|
|
||||||
.section .rodata
|
|
||||||
|
|
||||||
.balign 16
|
|
||||||
|
|
||||||
glabel D_80B1FA80
|
|
||||||
.incbin "baserom/ovl_En_Torch2", 0x2100, 0x000006B0
|
|
4
spec
4
spec
|
@ -2932,11 +2932,7 @@ endseg
|
||||||
beginseg
|
beginseg
|
||||||
name "ovl_En_Torch2"
|
name "ovl_En_Torch2"
|
||||||
include "build/src/overlays/actors/ovl_En_Torch2/z_en_torch2.o"
|
include "build/src/overlays/actors/ovl_En_Torch2/z_en_torch2.o"
|
||||||
#ifdef NON_MATCHING
|
|
||||||
include "build/src/overlays/actors/ovl_En_Torch2/ovl_En_Torch2_reloc.o"
|
include "build/src/overlays/actors/ovl_En_Torch2/ovl_En_Torch2_reloc.o"
|
||||||
#else
|
|
||||||
include "build/data/overlays/actors/z_en_torch2.reloc.o"
|
|
||||||
#endif
|
|
||||||
endseg
|
endseg
|
||||||
|
|
||||||
beginseg
|
beginseg
|
||||||
|
|
|
@ -228,32 +228,23 @@ void EnTorch2_Backflip(Player* this, Input* input, Actor* thisx) {
|
||||||
sCounterState = 0;
|
sCounterState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NON_MATCHING
|
|
||||||
/**
|
|
||||||
* Static variables are sometimes loaded from pointers and sometimes directly. While
|
|
||||||
* neither this nor the original are consistent about it, unfortunately they're not
|
|
||||||
* inconsistent in the same way. Also a small instruction mismatch in the input section
|
|
||||||
*/
|
|
||||||
void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
GlobalContext* globalCtx = globalCtx2;
|
GlobalContext* globalCtx = globalCtx2;
|
||||||
Player* player = GET_PLAYER(globalCtx);
|
Player* player2 = GET_PLAYER(globalCtx2);
|
||||||
|
Player* player = player2;
|
||||||
Player* this = THIS;
|
Player* this = THIS;
|
||||||
Input* input = &sInput;
|
Input* input = &sInput;
|
||||||
u16 phi_a2;
|
|
||||||
s8 tempX;
|
|
||||||
s8 tempY;
|
|
||||||
Camera* camera;
|
Camera* camera;
|
||||||
u8 staggerThreshold;
|
|
||||||
s8 temp;
|
|
||||||
s16 sp66;
|
s16 sp66;
|
||||||
u32 phi_v0;
|
u8 staggerThreshold;
|
||||||
|
s8 stickY;
|
||||||
|
s32 pad60;
|
||||||
Actor* attackItem;
|
Actor* attackItem;
|
||||||
s16 sp5A;
|
s16 sp5A;
|
||||||
s16 pad58;
|
s16 pad58;
|
||||||
s32 pad54;
|
u32 pad54;
|
||||||
f32 sp50;
|
f32 sp50;
|
||||||
s16 sp4E;
|
s16 sp4E;
|
||||||
s16 pad4C;
|
|
||||||
|
|
||||||
sp5A = player->actor.shape.rot.y - this->actor.shape.rot.y;
|
sp5A = player->actor.shape.rot.y - this->actor.shape.rot.y;
|
||||||
input->cur.button = 0;
|
input->cur.button = 0;
|
||||||
|
@ -275,9 +266,10 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
input->cur.button = BTN_A;
|
input->cur.button = BTN_A;
|
||||||
sZTargetFlag = false;
|
sZTargetFlag = false;
|
||||||
sp66 = camera->camDir.y - sStickAngle;
|
sp66 = camera->camDir.y - sStickAngle;
|
||||||
input->cur.stick_x = sStickTilt * Math_SinS(sp66);
|
sInput.cur.stick_x = sStickTilt * Math_SinS(sp66);
|
||||||
temp = sStickTilt * Math_CosS(sp66);
|
stickY = sStickTilt * Math_CosS(sp66);
|
||||||
input->cur.stick_y = temp;
|
if (stickY) {}
|
||||||
|
sInput.cur.stick_y = stickY;
|
||||||
}
|
}
|
||||||
func_800F5ACC(0x38);
|
func_800F5ACC(0x38);
|
||||||
sActionState = ENTORCH2_ATTACK;
|
sActionState = ENTORCH2_ATTACK;
|
||||||
|
@ -292,9 +284,9 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
if ((this->swordQuads[0].base.acFlags & AC_BOUNCED) || (this->swordQuads[1].base.acFlags & AC_BOUNCED)) {
|
if ((this->swordQuads[0].base.acFlags & AC_BOUNCED) || (this->swordQuads[1].base.acFlags & AC_BOUNCED)) {
|
||||||
this->swordQuads[0].base.acFlags &= ~AC_BOUNCED;
|
this->swordQuads[0].base.acFlags &= ~AC_BOUNCED;
|
||||||
this->swordQuads[1].base.acFlags &= ~AC_BOUNCED;
|
this->swordQuads[1].base.acFlags &= ~AC_BOUNCED;
|
||||||
this->swordQuads[0].base.atFlags |= AT_BOUNCED; // Loads these out of order
|
this->swordQuads[0].base.atFlags |= AT_BOUNCED;
|
||||||
this->swordQuads[1].base.atFlags |= AT_BOUNCED;
|
this->swordQuads[1].base.atFlags |= AT_BOUNCED;
|
||||||
this->cylinder.base.atFlags &= ~AC_HIT;
|
this->cylinder.base.acFlags &= ~AC_HIT;
|
||||||
|
|
||||||
if (sLastSwordAnim != this->swordAnimation) {
|
if (sLastSwordAnim != this->swordAnimation) {
|
||||||
sStaggerCount++;
|
sStaggerCount++;
|
||||||
|
@ -307,7 +299,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
* creating a hole in his defenses. This also makes Dark Link harder at low
|
* creating a hole in his defenses. This also makes Dark Link harder at low
|
||||||
* health, while the other health checks are intended to make him easier.
|
* health, while the other health checks are intended to make him easier.
|
||||||
*/
|
*/
|
||||||
if ((gSaveContext.health < 0x50) && (sCounterState != 0)) { // Loads in wrong order
|
if ((gSaveContext.health < 0x50) && (sCounterState != 0)) {
|
||||||
sCounterState = 0;
|
sCounterState = 0;
|
||||||
sStaggerTimer = 50;
|
sStaggerTimer = 50;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +312,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
// Ignores hits when jumping on Link's sword
|
// Ignores hits when jumping on Link's sword
|
||||||
if ((this->invincibilityTimer < 0) && (sActionState != ENTORCH2_DAMAGE) &&
|
if ((this->invincibilityTimer < 0) && (sActionState != ENTORCH2_DAMAGE) &&
|
||||||
(this->cylinder.base.acFlags & AC_HIT)) {
|
(this->cylinder.base.acFlags & AC_HIT)) {
|
||||||
this->cylinder.base.atFlags &= ~AC_HIT;
|
this->cylinder.base.acFlags &= ~AC_HIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles Dark Link rolling to dodge item attacks
|
// Handles Dark Link rolling to dodge item attacks
|
||||||
|
@ -345,10 +337,10 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
} else {
|
} else {
|
||||||
sStickAngle = this->actor.yawTowardsPlayer - 0x4000;
|
sStickAngle = this->actor.yawTowardsPlayer - 0x4000;
|
||||||
}
|
}
|
||||||
sStickTilt = 127.0f; // Does not store with pointer
|
sStickTilt = 127.0f;
|
||||||
sJumpslashFlag = false; // Does not store with POinter
|
|
||||||
input->cur.button |= BTN_A;
|
|
||||||
sJumpslashTimer = 15;
|
sJumpslashTimer = 15;
|
||||||
|
sJumpslashFlag = false;
|
||||||
|
input->cur.button |= BTN_A;
|
||||||
|
|
||||||
// Handles jumping on Link's sword
|
// Handles jumping on Link's sword
|
||||||
|
|
||||||
|
@ -364,7 +356,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
player->actor.world.pos.z,
|
player->actor.world.pos.z,
|
||||||
1.0f, 5.0f, 0.0f);
|
1.0f, 5.0f, 0.0f);
|
||||||
sSwordJumpTimer--;
|
sSwordJumpTimer--;
|
||||||
if ((sSwordJumpTimer == 0) || ((player->invincibilityTimer > 0) && (this->swordState == 0))) {
|
if (((u32)sSwordJumpTimer == 0) || ((player->invincibilityTimer > 0) && (this->swordState == 0))) {
|
||||||
this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
|
this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
|
||||||
input->cur.button = BTN_A;
|
input->cur.button = BTN_A;
|
||||||
player->stateFlags3 &= ~4;
|
player->stateFlags3 &= ~4;
|
||||||
|
@ -391,7 +383,6 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
// Handles Dark Link's reaction to sword attack other than jumpslashes
|
// Handles Dark Link's reaction to sword attack other than jumpslashes
|
||||||
|
|
||||||
if (func_800354B4(globalCtx, &this->actor, 120.0f, 0x7FFF, 0x7FFF, this->actor.world.rot.y)) {
|
if (func_800354B4(globalCtx, &this->actor, 120.0f, 0x7FFF, 0x7FFF, this->actor.world.rot.y)) {
|
||||||
// Loads arguments in wrong order. Probably related to static variables problem.
|
|
||||||
if ((player->swordAnimation == STAB_1H) && (this->actor.xzDistToPlayer < 90.0f)) {
|
if ((player->swordAnimation == STAB_1H) && (this->actor.xzDistToPlayer < 90.0f)) {
|
||||||
|
|
||||||
// Handles the reaction to a one-handed stab. If the conditions are satisfied,
|
// Handles the reaction to a one-handed stab. If the conditions are satisfied,
|
||||||
|
@ -421,17 +412,17 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
|
|
||||||
// Handles reactions to all other sword attacks
|
// Handles reactions to all other sword attacks
|
||||||
|
|
||||||
sStickAngle = this->actor.yawTowardsPlayer; // Not loaded into pointer
|
sStickAngle = thisx->yawTowardsPlayer;
|
||||||
input->cur.button = BTN_B;
|
input->cur.button = BTN_B;
|
||||||
|
|
||||||
if (player->swordAnimation <= FORWARD_COMBO_2H) {
|
if (player->swordAnimation <= FORWARD_COMBO_2H) {
|
||||||
sStickTilt = 0.0f;
|
sStickTilt = 0.0f;
|
||||||
} else if (player->swordAnimation <= RIGHT_COMBO_2H) {
|
} else if (player->swordAnimation <= RIGHT_COMBO_2H) {
|
||||||
sStickTilt = 127.0f;
|
sStickTilt = 127.0f;
|
||||||
sStickAngle += sStickAngle; // Not loaded from pointer
|
sStickAngle += 0x4000;
|
||||||
} else if (player->swordAnimation <= LEFT_COMBO_2H) {
|
} else if (player->swordAnimation <= LEFT_COMBO_2H) {
|
||||||
sStickTilt = 127.0f;
|
sStickTilt = 127.0f;
|
||||||
sStickAngle += -0x4000; // Not loaded from pointer
|
sStickAngle -= 0x4000;
|
||||||
} else if (player->swordAnimation <= HAMMER_SIDE) {
|
} else if (player->swordAnimation <= HAMMER_SIDE) {
|
||||||
input->cur.button = BTN_R;
|
input->cur.button = BTN_R;
|
||||||
} else if (player->swordAnimation <= BIG_SPIN_2H) {
|
} else if (player->swordAnimation <= BIG_SPIN_2H) {
|
||||||
|
@ -439,7 +430,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
} else {
|
} else {
|
||||||
EnTorch2_Backflip(this, input, &this->actor);
|
EnTorch2_Backflip(this, input, &this->actor);
|
||||||
}
|
}
|
||||||
if (CHECK_BTN_ANY(input->cur.button, BTN_A | BTN_R) && (this->swordState == 0) &&
|
if (!CHECK_BTN_ANY(input->cur.button, BTN_A | BTN_R) && (this->swordState == 0) &&
|
||||||
(player->swordState != 0)) {
|
(player->swordState != 0)) {
|
||||||
sCounterState = 1;
|
sCounterState = 1;
|
||||||
}
|
}
|
||||||
|
@ -448,7 +439,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
|
|
||||||
// Handles movement and attacks when not reacting to Link's actions
|
// Handles movement and attacks when not reacting to Link's actions
|
||||||
|
|
||||||
sStickAngle = this->actor.yawTowardsPlayer;
|
sStickAngle = thisx->yawTowardsPlayer;
|
||||||
sp50 = 0.0f;
|
sp50 = 0.0f;
|
||||||
if ((90.0f >= this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 70.0f) &&
|
if ((90.0f >= this->actor.xzDistToPlayer) && (this->actor.xzDistToPlayer > 70.0f) &&
|
||||||
(ABS(sp5A) >= 0x7800) && (this->actor.isTargeted || !(player->stateFlags1 & 0x00400000))) {
|
(ABS(sp5A) >= 0x7800) && (this->actor.isTargeted || !(player->stateFlags1 & 0x00400000))) {
|
||||||
|
@ -493,10 +484,11 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
} else if (sJumpslashFlag && (sAlpha == 255) && (this->actor.velocity.y > 0)) {
|
} else if (sJumpslashFlag && (sAlpha == 255) && (this->actor.velocity.y > 0)) {
|
||||||
input->cur.button |= BTN_B;
|
input->cur.button |= BTN_B;
|
||||||
} else if (!sJumpslashFlag && (this->actor.bgCheckFlags & 1)) {
|
} else if (!sJumpslashFlag && (this->actor.bgCheckFlags & 1)) {
|
||||||
sStickAngle = this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
|
this->actor.world.rot.y = this->actor.shape.rot.y = this->actor.yawTowardsPlayer;
|
||||||
|
sStickAngle = this->actor.yawTowardsPlayer;
|
||||||
if (sAlpha != 255) {
|
if (sAlpha != 255) {
|
||||||
sStickAngle += 0x8000;
|
sStickAngle += 0x8000;
|
||||||
sStickTilt = 127.0f; // Not loaded from pointer
|
sStickTilt = 127.0f;
|
||||||
sZTargetFlag = true;
|
sZTargetFlag = true;
|
||||||
}
|
}
|
||||||
input->cur.button |= BTN_A;
|
input->cur.button |= BTN_A;
|
||||||
|
@ -507,9 +499,10 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
// Rotates Dark Link's stick angle from Link-relative to camera-relative.
|
// Rotates Dark Link's stick angle from Link-relative to camera-relative.
|
||||||
|
|
||||||
sp66 = camera->camDir.y - sStickAngle;
|
sp66 = camera->camDir.y - sStickAngle;
|
||||||
input->cur.stick_x = Math_SinS(sp66) * sStickTilt;
|
sInput.cur.stick_x = sStickTilt * Math_SinS(sp66);
|
||||||
temp = Math_CosS(sp66) * sStickTilt;
|
stickY = sStickTilt * Math_CosS(sp66);
|
||||||
input->cur.stick_y = temp;
|
if (sAlpha) {}
|
||||||
|
sInput.cur.stick_y = stickY;
|
||||||
|
|
||||||
if ((sAlpha != 255) && ((globalCtx->gameplayFrames % 8) == 0)) {
|
if ((sAlpha != 255) && ((globalCtx->gameplayFrames % 8) == 0)) {
|
||||||
sAlpha++;
|
sAlpha++;
|
||||||
|
@ -579,18 +572,13 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
// Updates Dark Link's "controller". The conditional seems to cause him to
|
// Updates Dark Link's "controller". The conditional seems to cause him to
|
||||||
// stop targeting and hold shield if he's been holding it long enough.
|
// stop targeting and hold shield if he's been holding it long enough.
|
||||||
|
|
||||||
phi_a2 = input->cur.button;
|
pad54 = input->prev.button ^ input->cur.button;
|
||||||
pad54 = input->cur.button ^ input->prev.button;
|
|
||||||
input->press.button = input->cur.button & pad54;
|
input->press.button = input->cur.button & pad54;
|
||||||
phi_v0 = input->cur.button;
|
|
||||||
if (input->cur.button & BTN_R) {
|
if (input->cur.button & BTN_R) {
|
||||||
input->cur.button = phi_a2;
|
input->cur.button = ((sCounterState == 0) && (this->swordState == 0)) ? BTN_R : input->cur.button ^ BTN_R;
|
||||||
phi_a2 = ((sCounterState == 0) && (this->swordState == 0)) ? BTN_R : phi_v0 ^ BTN_R;
|
|
||||||
phi_v0 = phi_a2; // instruction mismatch
|
|
||||||
}
|
}
|
||||||
input->rel.button = input->prev.button & pad54;
|
input->rel.button = input->prev.button & pad54;
|
||||||
input->prev.button = phi_v0 & 0x3FFF; // & ~(BTN_A | BTN_B)
|
input->prev.button = input->cur.button & (u16)~(BTN_A | BTN_B);
|
||||||
input->cur.button = phi_a2;
|
|
||||||
PadUtils_UpdateRelXY(input);
|
PadUtils_UpdateRelXY(input);
|
||||||
|
|
||||||
input->press.stick_x += (s8)(input->cur.stick_x - input->prev.stick_x);
|
input->press.stick_x += (s8)(input->cur.stick_x - input->prev.stick_x);
|
||||||
|
@ -606,7 +594,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
}
|
}
|
||||||
if ((this->invincibilityTimer == 0) && (this->actor.colChkInfo.health != 0) &&
|
if ((this->invincibilityTimer == 0) && (this->actor.colChkInfo.health != 0) &&
|
||||||
(this->cylinder.base.acFlags & AC_HIT) && !(this->stateFlags1 & 0x04000000) &&
|
(this->cylinder.base.acFlags & AC_HIT) && !(this->stateFlags1 & 0x04000000) &&
|
||||||
!(this->swordQuads[0].base.acFlags & AT_HIT) && !(this->swordQuads[1].base.acFlags & AT_HIT)) {
|
!(this->swordQuads[0].base.atFlags & AT_HIT) && !(this->swordQuads[1].base.atFlags & AT_HIT)) {
|
||||||
|
|
||||||
if (!Actor_ApplyDamage(&this->actor)) {
|
if (!Actor_ApplyDamage(&this->actor)) {
|
||||||
func_800F5B58();
|
func_800F5B58();
|
||||||
|
@ -619,7 +607,7 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
sDeathFlag++;
|
sDeathFlag++;
|
||||||
sActionState = ENTORCH2_DEATH;
|
sActionState = ENTORCH2_DEATH;
|
||||||
Enemy_StartFinishingBlow(globalCtx, &this->actor);
|
Enemy_StartFinishingBlow(globalCtx, &this->actor);
|
||||||
Item_DropCollectibleRandom(globalCtx, &this->actor, &this->actor.world.pos, 0xC0);
|
Item_DropCollectibleRandom(globalCtx, &this->actor, &thisx->world.pos, 0xC0);
|
||||||
this->stateFlags3 &= ~4;
|
this->stateFlags3 &= ~4;
|
||||||
} else {
|
} else {
|
||||||
func_800F5ACC(0x38);
|
func_800F5ACC(0x38);
|
||||||
|
@ -631,9 +619,9 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this->actor.flags &= ~1;
|
this->actor.flags &= ~1;
|
||||||
|
this->unk_8A0 = this->actor.colChkInfo.damage;
|
||||||
this->unk_8A1 = 1;
|
this->unk_8A1 = 1;
|
||||||
this->unk_8A8 = 6.0f;
|
this->unk_8A8 = 6.0f;
|
||||||
this->unk_8A0 = this->actor.colChkInfo.damage;
|
|
||||||
this->unk_8A4 = 8.0f;
|
this->unk_8A4 = 8.0f;
|
||||||
this->unk_8A2 = this->actor.yawTowardsPlayer + 0x8000;
|
this->unk_8A2 = this->actor.yawTowardsPlayer + 0x8000;
|
||||||
Actor_SetDropFlag(&this->actor, &this->cylinder.info, 1);
|
Actor_SetDropFlag(&this->actor, &this->cylinder.info, 1);
|
||||||
|
@ -764,9 +752,6 @@ void EnTorch2_Update(Actor* thisx, GlobalContext* globalCtx2) {
|
||||||
this->actor.focus.pos.y += 20.0f;
|
this->actor.focus.pos.y += 20.0f;
|
||||||
this->actor.shape.yOffset = sSwordJumpHeight;
|
this->actor.shape.yOffset = sSwordJumpHeight;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Torch2/EnTorch2_Update.s")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
s32 EnTorch2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx,
|
s32 EnTorch2_OverrideLimbDraw(GlobalContext* globalCtx, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, void* thisx,
|
||||||
Gfx** gfx) {
|
Gfx** gfx) {
|
||||||
|
|
Loading…
Reference in a new issue